HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-aruba-adp.c
blob8ced3a5e4579ee060ae655c10f02ce39db992b9e
1 /* packet-aruba-adp.c
2 * Routines for Aruba ADP header disassembly
4 * $Id$
6 * Giles Scott < gscott <at> arubanetworks dot com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "config.h"
29 #include <glib.h>
30 #include <epan/packet.h>
31 #include <epan/addr_resolv.h>
33 #define UDP_PORT_ADP 8200
34 #define ADP_REQUEST 1
35 #define ADP_RESPONSE 2
37 void proto_register_aruba_adp(void);
38 void proto_reg_handoff_aruba_adp(void);
40 static int proto_aruba_adp = -1;
41 static gint ett_aruba_adp = -1;
43 static int hf_adp_version = -1;
44 static int hf_adp_type = -1;
45 static int hf_adp_id = -1;
46 static int hf_adp_mac = -1;
47 static int hf_adp_switchip = -1;
49 static const value_string adp_type_val[] =
51 {1, "Request"},
52 {2, "Response"},
53 {0, NULL},
56 static void
57 dissect_aruba_adp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
59 proto_tree *ti = NULL;
60 proto_tree *aruba_adp_tree = NULL;
61 guint16 type;
62 const gchar *mac_str;
63 const gchar *switchip;
66 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ADP");
67 col_clear(pinfo->cinfo, COL_INFO);
70 if (tree) {
71 ti = proto_tree_add_item(tree, proto_aruba_adp, tvb, 0, 0, ENC_NA);
72 aruba_adp_tree = proto_item_add_subtree(ti, ett_aruba_adp);
74 proto_tree_add_item(aruba_adp_tree, hf_adp_version, tvb, 0, 2, ENC_BIG_ENDIAN);
76 type = tvb_get_ntohs(tvb, 2);
78 if (tree) {
79 proto_tree_add_item(aruba_adp_tree, hf_adp_type, tvb, 2, 2, ENC_BIG_ENDIAN);
81 proto_tree_add_item(aruba_adp_tree, hf_adp_id, tvb, 4, 2, ENC_BIG_ENDIAN);
84 switch(type){
85 case ADP_REQUEST:
87 proto_tree_add_item(aruba_adp_tree, hf_adp_mac, tvb, 6, 6, ENC_NA);
88 mac_str = tvb_ether_to_str(tvb, 6);
90 col_add_fstr(pinfo->cinfo, COL_INFO, "ADP Request Src MAC: %s", mac_str);
92 proto_item_append_text(ti, ", Request Src MAC: %s", mac_str);
93 break;
95 case ADP_RESPONSE:
97 proto_tree_add_item(aruba_adp_tree, hf_adp_switchip, tvb, 6, 4, ENC_BIG_ENDIAN);
98 switchip = tvb_ip_to_str(tvb, 6);
100 col_add_fstr(pinfo->cinfo, COL_INFO, "ADP Response Switch IP: %s", switchip);
102 proto_item_append_text(ti, ", Response Switch IP: %s", switchip);
103 break;
105 default:
106 break;
111 void
112 proto_register_aruba_adp(void)
114 static hf_register_info hf[] = {
115 { &hf_adp_version,
116 { "Version", "adp.version", FT_UINT16, BASE_DEC, NULL,0x0,
117 "ADP version", HFILL}},
119 { &hf_adp_type,
120 { "Type", "adp.type", FT_UINT16, BASE_DEC, VALS(adp_type_val), 0x0,
121 "ADP type", HFILL}},
123 { &hf_adp_id,
124 { "Transaction ID", "adp.id", FT_UINT16, BASE_DEC, NULL, 0x0,
125 "ADP transaction ID", HFILL}},
127 { &hf_adp_mac,
128 { "MAC address", "adp.mac", FT_ETHER, BASE_NONE, NULL, 0x0,
129 NULL, HFILL}},
131 { &hf_adp_switchip,
132 { "Switch IP", "adp.switch", FT_IPv4, BASE_NONE, NULL, 0x0,
133 "Switch IP address", HFILL}},
137 static gint *ett[] = {
138 &ett_aruba_adp,
141 proto_aruba_adp = proto_register_protocol("Aruba Discovery Protocol",
142 "ADP", "adp");
143 proto_register_field_array(proto_aruba_adp, hf, array_length(hf));
144 proto_register_subtree_array(ett, array_length(ett));
148 void
149 proto_reg_handoff_aruba_adp(void)
151 dissector_handle_t adp_handle;
153 adp_handle = create_dissector_handle(dissect_aruba_adp, proto_aruba_adp);
154 dissector_add_uint("udp.port", UDP_PORT_ADP, adp_handle);
158 * Editor modelines
160 * Local Variables:
161 * c-basic-offset: 2
162 * tab-width: 8
163 * indent-tabs-mode: nil
164 * End:
166 * ex: set shiftwidth=2 tabstop=8 expandtab:
167 * :indentSize=2:tabSize=8:noTabs=true: