2 * Routines for text-based layer 1 messages in EyeSDN trace files
4 * (C) Rolf Fiedler 2008, based on packet-text-media.c by Olivier Biot, 2004.
6 * Refer to the AUTHORS file or the AUTHORS section in the man page
7 * for contacting the author(s) of this file.
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 /* Edit this file with 4-space tabs */
34 #include <epan/packet.h>
35 #include <wiretap/wtap.h>
36 #include <epan/strutil.h>
38 void proto_register_l1_events(void);
39 void proto_reg_handoff_l1_events(void);
42 * dissector for line-based text messages from layer 1
45 /* Filterable header fields */
46 static gint proto_l1_events = -1;
49 static gint ett_l1_events = -1;
52 dissect_l1_events(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
56 gint offset = 0, next_offset;
58 const char *data_name;
60 data_name = pinfo->match_string;
61 if (! (data_name && data_name[0])) {
63 * No information from "match_string"
65 data_name = (char *)data;
66 if (! (data_name && data_name[0])) {
68 * No information from dissector data
70 data_name = (char *)(pinfo->private_data);
71 if (! (data_name && data_name[0])) {
73 * No information from "private_data"
80 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Layer1");
81 col_set_str(pinfo->cinfo, COL_DEF_SRC,
82 pinfo->pseudo_header->l1event.uton? "TE" : "NT");
83 len = tvb_find_line_end(tvb, 0, tvb_ensure_length_remaining(tvb, 0),
86 col_add_str(pinfo->cinfo, COL_INFO, tvb_format_text(tvb, 0, len));
89 ti = proto_tree_add_item(tree, proto_l1_events,
92 proto_item_append_text(ti, ": %s", data_name);
93 subtree = proto_item_add_subtree(ti, ett_l1_events);
94 /* Read the media line by line */
95 while (tvb_reported_length_remaining(tvb, offset) != 0) {
97 * XXX - we need to be passed the parameters
98 * of the content type via "pinfo->private_data",
99 * so that we know the character set. We'd
100 * have to handle that character set, which
101 * might be a multibyte character set such
102 * as "iso-10646-ucs-2", or might require other
103 * special processing.
105 len = tvb_find_line_end(tvb, offset,
106 tvb_ensure_length_remaining(tvb, offset),
107 &next_offset, FALSE);
111 /* We use next_offset - offset instead of len in the
112 * call to proto_tree_add_format_text() so it will include the
113 * line terminator(s) (\r and/or \n) in the display.
115 proto_tree_add_format_text(subtree, tvb, offset, next_offset - offset);
116 offset = next_offset;
120 return tvb_length(tvb);
124 proto_register_l1_events(void)
126 static gint *ett[] = {
130 proto_register_subtree_array(ett, array_length(ett));
132 proto_l1_events = proto_register_protocol(
133 "Layer 1 Event Messages", /* Long name */
134 "Layer 1 Events", /* Short name */
135 "data-l1-events"); /* Filter name */
136 new_register_dissector("data-l1-events", dissect_l1_events, proto_l1_events);
140 proto_reg_handoff_l1_events(void)
142 dissector_handle_t l1_events_handle;
144 l1_events_handle = find_dissector("data-l1-events");
145 dissector_add_uint("wtap_encap", WTAP_ENCAP_LAYER1_EVENT, l1_events_handle); /* for text msgs from trace files */