Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-aruba-adp.c
blob71fc6bad17cfdb58b20dd1eb482317671ed4afec
1 /* packet-aruba-adp.c
2 * Routines for Aruba ADP header disassembly
4 * Giles Scott < gscott <at> arubanetworks dot com>
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"
15 #include <epan/packet.h>
16 #include <epan/addr_resolv.h>
18 #define UDP_PORT_ADP 8200 /* Not IANA registered */
19 #define ADP_REQUEST 1
20 #define ADP_RESPONSE 2
22 void proto_register_aruba_adp(void);
23 void proto_reg_handoff_aruba_adp(void);
25 static dissector_handle_t adp_handle;
27 static int proto_aruba_adp;
28 static int ett_aruba_adp;
30 static int hf_adp_version;
31 static int hf_adp_type;
32 static int hf_adp_id;
33 static int hf_adp_mac;
34 static int hf_adp_switchip;
36 static const value_string adp_type_val[] =
38 {1, "Request"},
39 {2, "Response"},
40 {0, NULL},
43 static int
44 dissect_aruba_adp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
46 proto_tree *ti = NULL;
47 proto_tree *aruba_adp_tree = NULL;
48 uint16_t type;
49 const char *mac_str;
50 const char *switchip;
53 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ADP");
54 col_clear(pinfo->cinfo, COL_INFO);
57 if (tree) {
58 ti = proto_tree_add_item(tree, proto_aruba_adp, tvb, 0, -1, ENC_NA);
59 aruba_adp_tree = proto_item_add_subtree(ti, ett_aruba_adp);
62 proto_tree_add_item(aruba_adp_tree, hf_adp_version, tvb, 0, 2, ENC_BIG_ENDIAN);
65 proto_tree_add_item(aruba_adp_tree, hf_adp_type, tvb, 2, 2, ENC_BIG_ENDIAN);
66 type = tvb_get_ntohs(tvb, 2);
68 proto_tree_add_item(aruba_adp_tree, hf_adp_id, tvb, 4, 2, ENC_BIG_ENDIAN);
70 switch(type){
71 case ADP_REQUEST:
73 proto_tree_add_item(aruba_adp_tree, hf_adp_mac, tvb, 6, 6, ENC_NA);
74 mac_str = tvb_ether_to_str(pinfo->pool, tvb, 6);
76 col_add_fstr(pinfo->cinfo, COL_INFO, "ADP Request Src MAC: %s", mac_str);
78 proto_item_append_text(ti, ", Request Src MAC: %s", mac_str);
79 break;
81 case ADP_RESPONSE:
83 proto_tree_add_item(aruba_adp_tree, hf_adp_switchip, tvb, 6, 4, ENC_BIG_ENDIAN);
84 switchip = tvb_ip_to_str(pinfo->pool, tvb, 6);
86 col_add_fstr(pinfo->cinfo, COL_INFO, "ADP Response Switch IP: %s", switchip);
88 proto_item_append_text(ti, ", Response Switch IP: %s", switchip);
89 break;
91 default:
92 break;
95 return tvb_captured_length(tvb);
98 void
99 proto_register_aruba_adp(void)
101 static hf_register_info hf[] = {
102 { &hf_adp_version,
103 { "Version", "adp.version", FT_UINT16, BASE_DEC, NULL,0x0,
104 "ADP version", HFILL}},
106 { &hf_adp_type,
107 { "Type", "adp.type", FT_UINT16, BASE_DEC, VALS(adp_type_val), 0x0,
108 "ADP type", HFILL}},
110 { &hf_adp_id,
111 { "Transaction ID", "adp.id", FT_UINT16, BASE_DEC, NULL, 0x0,
112 "ADP transaction ID", HFILL}},
114 { &hf_adp_mac,
115 { "MAC address", "adp.mac", FT_ETHER, BASE_NONE, NULL, 0x0,
116 NULL, HFILL}},
118 { &hf_adp_switchip,
119 { "Switch IP", "adp.switch", FT_IPv4, BASE_NONE, NULL, 0x0,
120 "Switch IP address", HFILL}},
124 static int *ett[] = {
125 &ett_aruba_adp,
128 proto_aruba_adp = proto_register_protocol("Aruba Discovery Protocol",
129 "ADP", "adp");
130 proto_register_field_array(proto_aruba_adp, hf, array_length(hf));
131 proto_register_subtree_array(ett, array_length(ett));
133 adp_handle = register_dissector("adp", dissect_aruba_adp, proto_aruba_adp);
137 void
138 proto_reg_handoff_aruba_adp(void)
140 dissector_add_uint_with_preference("udp.port", UDP_PORT_ADP, adp_handle);
144 * Editor modelines - https://www.wireshark.org/tools/modelines.html
146 * Local variables:
147 * c-basic-offset: 4
148 * tab-width: 8
149 * indent-tabs-mode: nil
150 * End:
152 * vi: set shiftwidth=4 tabstop=8 expandtab:
153 * :indentSize=4:tabSize=8:noTabs=true: