Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-cisco-ttag.c
blob3e348d8d1071ab6f33042f126fb3edc1c19bdc1a
1 /* packet-cisco-ttag.c
2 * Routines for dissection of Cisco's ttag protocol.
3 * Based on packet-cisco-metadata.c
5 * Copyright 2016 by Jaap Keuter (jkeuter[AT]xs4all.nl)
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include "config.h"
16 #include <epan/packet.h>
17 #include <epan/etypes.h>
18 #include <epan/to_str.h>
20 void proto_register_ttag(void);
21 void proto_reg_handoff_ttag(void);
23 static dissector_handle_t ttag_handle;
25 static dissector_handle_t ethertype_handle;
27 static int proto_ttag;
29 static int hf_ttag_time_stamp;
30 static int hf_ttag_eth_type;
32 static int ett_ttag;
34 static int
35 dissect_ttag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
37 uint64_t timestamp_value;
38 nstime_t timestamp;
39 uint16_t encap_proto;
40 ethertype_data_t ethertype_data;
42 proto_tree *ttag_tree;
43 proto_item *ti;
44 int offset = 0;
46 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TTAG");
47 col_clear(pinfo->cinfo, COL_INFO);
49 ti = proto_tree_add_item(tree, proto_ttag, tvb, 0, 8, ENC_NA);
50 ttag_tree = proto_item_add_subtree(ti, ett_ttag);
52 timestamp_value = tvb_get_uint48(tvb, offset, ENC_BIG_ENDIAN);
53 timestamp.secs = (time_t) (timestamp_value / UINT64_C(1000000000));
54 timestamp.nsecs = (uint32_t)(timestamp_value - (timestamp.secs * UINT64_C(1000000000)));
56 proto_item_append_text(ti, ", Timestamp: %s", rel_time_to_secs_str(pinfo->pool, &timestamp));
58 proto_tree_add_time(ttag_tree, hf_ttag_time_stamp, tvb, offset, 6, &timestamp);
59 offset += 6;
61 encap_proto = tvb_get_ntohs(tvb, offset);
62 proto_tree_add_uint(ttag_tree, hf_ttag_eth_type, tvb, offset, 2, encap_proto);
63 offset += 2;
65 ethertype_data.etype = encap_proto;
66 ethertype_data.payload_offset = offset;
67 ethertype_data.fh_tree = ttag_tree;
68 /* ttag doesn't define a trailer, but there's no way to tell Ethertype dissector that.
69 * At least use the correct header field to reflect that and allow proper filter expression,
70 * although it will still be attached to our tree instead of Ethernet II.
72 ethertype_data.trailer_id = proto_registrar_get_id_byname("eth.trailer");
73 ethertype_data.fcs_len = 0;
75 call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
77 return tvb_captured_length(tvb);
80 void
81 proto_register_ttag(void)
83 static hf_register_info hf[] = {
84 { &hf_ttag_time_stamp,
85 { "Time stamp", "ttag.time_stamp", FT_RELATIVE_TIME, 0, NULL, 0x0, NULL, HFILL }
87 { &hf_ttag_eth_type,
88 { "Type", "ttag.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, NULL, HFILL }
92 static int *ett[] = {
93 &ett_ttag
96 proto_ttag = proto_register_protocol("Cisco ttag", "Cisco ttag", "ttag");
97 proto_register_field_array(proto_ttag, hf, array_length(hf));
98 proto_register_subtree_array(ett, array_length(ett));
100 ttag_handle = register_dissector("ttag", dissect_ttag, proto_ttag);
103 void
104 proto_reg_handoff_ttag(void)
106 ethertype_handle = find_dissector_add_dependency("ethertype", proto_ttag);
108 dissector_add_for_decode_as("ethertype", ttag_handle);
112 * Editor modelines - https://www.wireshark.org/tools/modelines.html
114 * Local variables:
115 * c-basic-offset: 4
116 * tab-width: 8
117 * indent-tabs-mode: nil
118 * End:
120 * vi: set shiftwidth=4 tabstop=8 expandtab:
121 * :indentSize=4:tabSize=8:noTabs=true: