Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-l1-events.c
blob06fc6e13076bd99e8ed4b353a0db1a5bb62564ba
1 /* packet-l1-events.c
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 */
18 #include "config.h"
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;
34 /* Subtrees */
35 static int ett_l1_events;
37 static int
38 dissect_l1_events(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
40 proto_tree *subtree;
41 proto_item *ti;
42 int offset = 0, next_offset;
43 int len;
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);
49 if(len>0)
50 col_add_str(pinfo->cinfo, COL_INFO, tvb_format_text(pinfo->pool, tvb, 0, len));
52 if (tree) {
53 ti = proto_tree_add_item(tree, proto_l1_events,
54 tvb, 0, -1, ENC_NA);
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
65 * special processing.
67 len = tvb_find_line_end(tvb, offset, -1, &next_offset, false);
68 if (len == -1)
69 break;
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);
76 offset = next_offset;
80 return tvb_captured_length(tvb);
83 void
84 proto_register_l1_events(void)
86 static int *ett[] = {
87 &ett_l1_events,
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);
97 void
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
106 * Local variables:
107 * c-basic-offset: 8
108 * tab-width: 8
109 * indent-tabs-mode: t
110 * End:
112 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
113 * :indentSize=8:tabSize=8:noTabs=false: