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 * SPDX-License-Identifier: GPL-2.0-or-later
16 /* Edit this file with 4-space tabs */
20 #include <epan/packet.h>
21 #include <wiretap/wtap.h>
23 void proto_register_l1_events(void);
24 void proto_reg_handoff_l1_events(void);
26 static dissector_handle_t l1_events_handle
;
28 * dissector for line-based text messages from layer 1
31 /* Filterable header fields */
32 static int proto_l1_events
;
35 static int ett_l1_events
;
38 dissect_l1_events(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
42 int offset
= 0, next_offset
;
45 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Layer1");
46 col_set_str(pinfo
->cinfo
, COL_DEF_SRC
,
47 pinfo
->pseudo_header
->l1event
.uton
? "TE" : "NT");
48 len
= tvb_find_line_end(tvb
, 0, -1, &next_offset
, false);
50 col_add_str(pinfo
->cinfo
, COL_INFO
, tvb_format_text(pinfo
->pool
, tvb
, 0, len
));
53 ti
= proto_tree_add_item(tree
, proto_l1_events
,
55 subtree
= proto_item_add_subtree(ti
, ett_l1_events
);
56 /* Read the media line by line */
57 while (tvb_offset_exists(tvb
, offset
)) {
59 * XXX - we need to be passed the parameters
60 * of the content type via data parameter,
61 * so that we know the character set. We'd
62 * have to handle that character set, which
63 * might be a multibyte character set such
64 * as "iso-10646-ucs-2", or might require other
67 len
= tvb_find_line_end(tvb
, offset
, -1, &next_offset
, false);
71 /* We use next_offset - offset instead of len in the
72 * call to proto_tree_add_format_text() so it will include the
73 * line terminator(s) (\r and/or \n) in the display.
75 proto_tree_add_format_text(subtree
, tvb
, offset
, next_offset
- offset
);
80 return tvb_captured_length(tvb
);
84 proto_register_l1_events(void)
90 proto_register_subtree_array(ett
, array_length(ett
));
92 proto_l1_events
= proto_register_protocol("Layer 1 Event Messages", "Layer 1 Events", "data-l1-events");
94 l1_events_handle
= register_dissector("data-l1-events", dissect_l1_events
, proto_l1_events
);
98 proto_reg_handoff_l1_events(void)
100 dissector_add_uint("wtap_encap", WTAP_ENCAP_LAYER1_EVENT
, l1_events_handle
); /* for text msgs from trace files */
104 * Editor modelines - https://www.wireshark.org/tools/modelines.html
109 * indent-tabs-mode: t
112 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
113 * :indentSize=8:tabSize=8:noTabs=false: