Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-at-ldf.c
blob565083918d58b6ef26569066d6ca3285b7ed5f2c
1 /* packet-at-ldf.c
2 * Dissector for Allied Telesis Loop Detection Frames
4 * Copyright (c) 2021-2024 by Martin Mayer <martin.mayer@m2-it-solutions.de>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "config.h"
14 #include <epan/packet.h>
16 #define AT_LDF_LLC_CTRL 0xE3
18 #define AT_LDF_FRAME_LEN 79
20 void proto_register_at_ldf(void);
21 void proto_reg_handoff_at_ldf(void);
23 static dissector_handle_t at_ldf_handle;
25 static int proto_at_ldf;
27 /* Fields */
28 static int hf_at_ldf_version;
29 static int hf_at_ldf_src_vlan;
30 static int hf_at_ldf_src_port;
31 static int hf_at_ldf_ttl;
32 static int hf_at_ldf_id;
33 static int hf_at_ldf_text;
35 static int ett_at_ldf;
37 static int
38 dissect_at_ldf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
41 * Packet description
43 * The frame is an LLC frame (non-SNAP) with DSAP=0, SSAP=0, Control=0xE3.
44 * Ethernet destination address is the non-existing device address
45 * with Allied Telesis OUI (00:00:f4:27:71:01).
47 * The payload contains information about protocol version, source VLAN and port,
48 * TTL, random LDF identifier and an informational text.
52 /* Check if packet is destined to the Allied Telesis test address (00:00:F4:27:71:01) */
53 uint8_t dst_mac[6] = {0x00, 0x00, 0xF4, 0x27, 0x71, 0x01};
54 address dst_addr = ADDRESS_INIT_NONE;
55 set_address(&dst_addr, AT_ETHER, sizeof(dst_mac), &dst_mac);
57 if(!addresses_equal(&pinfo->dl_dst, &dst_addr))
58 return 0;
60 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AT LDF");
61 col_clear(pinfo->cinfo,COL_INFO);
62 col_add_fstr(pinfo->cinfo, COL_INFO, "Source VLAN: %u, Port: %u",
63 tvb_get_uint16(tvb, 1, ENC_BIG_ENDIAN),
64 tvb_get_uint16(tvb, 5, ENC_BIG_ENDIAN));
66 /* Frame has fixed length, so we can directly set tree and reported length */
67 tvb_set_reported_length(tvb, AT_LDF_FRAME_LEN);
69 proto_item *ti = proto_tree_add_item(tree, proto_at_ldf, tvb, 0, AT_LDF_FRAME_LEN, ENC_NA);
70 proto_tree *at_ldf_tree = proto_item_add_subtree(ti, ett_at_ldf);
72 int offset = 0;
73 proto_tree_add_item(at_ldf_tree, hf_at_ldf_version, tvb, offset, 1, ENC_BIG_ENDIAN);
74 offset += 1;
75 proto_tree_add_item(at_ldf_tree, hf_at_ldf_src_vlan, tvb, offset, 2, ENC_BIG_ENDIAN);
76 offset += 2;
77 proto_tree_add_item(at_ldf_tree, hf_at_ldf_src_port, tvb, offset, 4, ENC_BIG_ENDIAN);
78 offset += 4;
79 proto_tree_add_item(at_ldf_tree, hf_at_ldf_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
80 offset += 1;
81 proto_tree_add_item(at_ldf_tree, hf_at_ldf_id, tvb, offset, 7, ENC_NA);
82 offset += 7;
83 proto_tree_add_item(at_ldf_tree, hf_at_ldf_text, tvb, offset, 64, ENC_ASCII);
85 return AT_LDF_FRAME_LEN;
88 void
89 proto_register_at_ldf(void)
91 static hf_register_info hf[] = {
92 { &hf_at_ldf_version,
93 { "Version", "atldf.version",
94 FT_UINT8, BASE_DEC,
95 NULL, 0x0,
96 NULL, HFILL }
98 { &hf_at_ldf_src_vlan,
99 { "Source VLAN", "atldf.vlan",
100 FT_UINT16, BASE_DEC,
101 NULL, 0x0,
102 NULL, HFILL }
104 { &hf_at_ldf_src_port,
105 { "Source Port", "atldf.port",
106 FT_UINT32, BASE_DEC,
107 NULL, 0x0,
108 NULL, HFILL }
110 { &hf_at_ldf_ttl,
111 { "Time to Live", "atldf.ttl",
112 FT_UINT8, BASE_DEC,
113 NULL, 0x0,
114 NULL, HFILL }
116 { &hf_at_ldf_id,
117 { "Identifier", "atldf.id",
118 FT_UINT56, BASE_HEX,
119 NULL, 0x0,
120 NULL, HFILL }
122 { &hf_at_ldf_text,
123 { "Information", "atldf.info",
124 FT_STRINGZPAD, BASE_NONE,
125 NULL, 0x0,
126 NULL, HFILL }
130 static int *ett[] = {
131 &ett_at_ldf
134 proto_at_ldf = proto_register_protocol ("Allied Telesis Loop Detection", "AT LDF", "atldf");
136 proto_register_field_array(proto_at_ldf, hf, array_length(hf));
137 proto_register_subtree_array(ett, array_length(ett));
139 at_ldf_handle = register_dissector("atldf", dissect_at_ldf, proto_at_ldf);
142 void
143 proto_reg_handoff_at_ldf(void)
145 dissector_add_uint("llc.control", AT_LDF_LLC_CTRL, at_ldf_handle);
149 * Editor modelines - https://www.wireshark.org/tools/modelines.html
151 * Local variables:
152 * c-basic-offset: 4
153 * tab-width: 8
154 * indent-tabs-mode: nil
155 * End:
157 * vi: set shiftwidth=4 tabstop=8 expandtab:
158 * :indentSize=4:tabSize=8:noTabs=true: