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
74 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Layer1");
75 col_set_str(pinfo->cinfo, COL_DEF_SRC,
76 pinfo->pseudo_header->l1event.uton? "TE" : "NT");
77 len = tvb_find_line_end(tvb, 0, tvb_ensure_length_remaining(tvb, 0),
80 col_add_str(pinfo->cinfo, COL_INFO, tvb_format_text(tvb, 0, len));
83 ti = proto_tree_add_item(tree, proto_l1_events,
86 proto_item_append_text(ti, ": %s", data_name);
87 subtree = proto_item_add_subtree(ti, ett_l1_events);
88 /* Read the media line by line */
89 while (tvb_reported_length_remaining(tvb, offset) != 0) {
91 * XXX - we need to be passed the parameters
92 * of the content type via data parameter,
93 * so that we know the character set. We'd
94 * have to handle that character set, which
95 * might be a multibyte character set such
96 * as "iso-10646-ucs-2", or might require other
99 len = tvb_find_line_end(tvb, offset,
100 tvb_ensure_length_remaining(tvb, offset),
101 &next_offset, FALSE);
105 /* We use next_offset - offset instead of len in the
106 * call to proto_tree_add_format_text() so it will include the
107 * line terminator(s) (\r and/or \n) in the display.
109 proto_tree_add_format_text(subtree, tvb, offset, next_offset - offset);
110 offset = next_offset;
114 return tvb_length(tvb);
118 proto_register_l1_events(void)
120 static gint *ett[] = {
124 proto_register_subtree_array(ett, array_length(ett));
126 proto_l1_events = proto_register_protocol(
127 "Layer 1 Event Messages", /* Long name */
128 "Layer 1 Events", /* Short name */
129 "data-l1-events"); /* Filter name */
130 new_register_dissector("data-l1-events", dissect_l1_events, proto_l1_events);
134 proto_reg_handoff_l1_events(void)
136 dissector_handle_t l1_events_handle;
138 l1_events_handle = find_dissector("data-l1-events");
139 dissector_add_uint("wtap_encap", WTAP_ENCAP_LAYER1_EVENT, l1_events_handle); /* for text msgs from trace files */
143 * Editor modelines - http://www.wireshark.org/tools/modelines.html
148 * indent-tabs-mode: t
151 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
152 * :indentSize=8:tabSize=8:noTabs=false: