2005-04-01 09:43:19 +00:00
|
|
|
/* packet-hpsw.c
|
|
|
|
* Routines for HP Switch Config protocol
|
|
|
|
* Charlie Lenahan <clenahan@fortresstech.com>
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2005-04-01 09:43:19 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-11-05 18:26:21 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-04-01 09:43:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <epan/packet.h>
|
2005-09-17 00:02:31 +00:00
|
|
|
#include <epan/etypes.h>
|
2005-04-01 09:43:19 +00:00
|
|
|
|
|
|
|
#include "packet-hpext.h"
|
|
|
|
|
|
|
|
static void dissect_hpsw_tlv(tvbuff_t *tvb, int offset, int length,
|
|
|
|
proto_tree *tree, proto_item *ti, guint8 type);
|
|
|
|
|
|
|
|
static int proto_hpsw = -1;
|
|
|
|
|
|
|
|
static int hf_hpsw_version = -1;
|
|
|
|
static int hf_hpsw_type = -1;
|
|
|
|
static int hf_hpsw_tlvtype = -1;
|
|
|
|
static int hf_hpsw_tlvlength = -1;
|
|
|
|
|
|
|
|
|
|
|
|
static gint ett_hpsw = -1;
|
|
|
|
static gint ett_hpsw_tlv = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define HPFOO_DEVICE_NAME 0x1
|
|
|
|
#define HPFOO_DEVICE_VERSION 0x2
|
|
|
|
#define HPFOO_CONFIG_NAME 0x3
|
|
|
|
#define HPFOO_IP_ADDR 0x5
|
|
|
|
#define HPFOO_FIELD_7 0x7
|
|
|
|
#define HPFOO_FIELD_8 0x8
|
|
|
|
#define HPFOO_FIELD_9 0x9
|
|
|
|
#define HPFOO_FIELD_10 0xa
|
2006-11-09 12:27:52 +00:00
|
|
|
#define HPFOO_FIELD_12 0xc
|
|
|
|
#define HPFOO_DEVICE_ID 0xd /* Interpretation of this field is an educated guess */
|
2005-05-09 11:21:16 +00:00
|
|
|
#define HPFOO_MAC_ADDR 0xe
|
2005-04-01 09:43:19 +00:00
|
|
|
|
|
|
|
static const value_string hpsw_tlv_type_vals[] = {
|
|
|
|
{ HPFOO_DEVICE_NAME, "Device Name" },
|
|
|
|
{ HPFOO_DEVICE_VERSION, "Version" },
|
|
|
|
{ HPFOO_CONFIG_NAME, "Config" },
|
|
|
|
{ HPFOO_IP_ADDR, "IP Addr" },
|
|
|
|
{ HPFOO_FIELD_7, "Field 7" },
|
|
|
|
{ HPFOO_FIELD_8, "Field 8" },
|
|
|
|
{ HPFOO_FIELD_9, "Field 9" },
|
|
|
|
{ HPFOO_FIELD_10, "Field 10" },
|
2006-11-09 12:27:52 +00:00
|
|
|
{ HPFOO_FIELD_12, "Field 12" },
|
|
|
|
{ HPFOO_DEVICE_ID, "Device ID" },
|
2005-05-09 11:21:16 +00:00
|
|
|
{ HPFOO_MAC_ADDR, "MAC Addr" },
|
2005-04-01 09:43:19 +00:00
|
|
|
{ 0x00, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_hpsw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree *hp_tree = NULL;
|
|
|
|
proto_tree *tlv_tree = NULL;
|
|
|
|
proto_item *ti = NULL;
|
|
|
|
guint8 version;
|
|
|
|
|
2009-08-09 07:59:51 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "HP");
|
2005-04-01 09:43:19 +00:00
|
|
|
|
2009-08-09 07:59:51 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "HP Switch Protocol");
|
2005-04-01 09:43:19 +00:00
|
|
|
|
|
|
|
version = tvb_get_guint8(tvb, 0);
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
guint16 offset =0;
|
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_hpsw, tvb, 0, -1, ENC_NA);
|
2005-04-01 09:43:19 +00:00
|
|
|
hp_tree = proto_item_add_subtree(ti, ett_hpsw);
|
|
|
|
proto_tree_add_uint(hp_tree, hf_hpsw_version, tvb, 0, 1, version);
|
|
|
|
offset++;
|
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(hp_tree, hf_hpsw_type, tvb, 1, 1, ENC_BIG_ENDIAN);
|
2005-04-01 09:43:19 +00:00
|
|
|
offset++;
|
|
|
|
|
|
|
|
while ( tvb_reported_length_remaining(tvb, offset) > 0 )
|
|
|
|
{
|
|
|
|
guint8 type,length;
|
2011-03-03 02:24:44 +00:00
|
|
|
|
2005-04-01 09:43:19 +00:00
|
|
|
type = tvb_get_guint8(tvb, offset);
|
|
|
|
length = tvb_get_guint8(tvb, offset+1);
|
|
|
|
|
2011-03-03 02:24:44 +00:00
|
|
|
/* make sure still in valid tlv */
|
2005-04-01 09:43:19 +00:00
|
|
|
if (( length < 1 ) || ( length > tvb_length_remaining(tvb,offset+2)))
|
|
|
|
break;
|
2011-03-03 02:24:44 +00:00
|
|
|
|
2005-04-01 09:43:19 +00:00
|
|
|
ti = proto_tree_add_text(hp_tree,tvb,offset,length+2,"%s",
|
|
|
|
val_to_str(type,hpsw_tlv_type_vals,"Unknown TLV type: 0x%02x"));
|
|
|
|
|
|
|
|
tlv_tree=proto_item_add_subtree(ti,ett_hpsw_tlv);
|
|
|
|
|
|
|
|
/* type */
|
|
|
|
proto_tree_add_uint(tlv_tree, hf_hpsw_tlvtype, tvb, offset, 1, type);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* LENGTH (not inclusive of type and length bytes) */
|
|
|
|
proto_tree_add_uint(tlv_tree, hf_hpsw_tlvlength, tvb, offset, 1, length);
|
2011-03-03 02:24:44 +00:00
|
|
|
offset++;
|
|
|
|
|
2005-04-01 09:43:19 +00:00
|
|
|
dissect_hpsw_tlv(tvb,offset,length,tlv_tree,ti,type);
|
2011-03-03 02:24:44 +00:00
|
|
|
|
|
|
|
offset += length;
|
2005-04-01 09:43:19 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_hpsw_tlv(tvbuff_t *tvb, int offset, int length,
|
|
|
|
proto_tree *tree, proto_item *ti, guint8 type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
|
|
|
|
case HPFOO_DEVICE_NAME:
|
|
|
|
if (length > 0) {
|
|
|
|
proto_item_set_text(ti, "Device Name: %s", tvb_format_text(tvb, offset, length - 1));
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Device Name: %s", tvb_format_text(tvb, offset, length - 1));
|
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "Device Name: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Device Name: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HPFOO_DEVICE_VERSION:
|
|
|
|
if (length > 0) {
|
|
|
|
proto_item_set_text(ti, "Version: %s", tvb_format_text(tvb, offset, length - 1));
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Version: %s", tvb_format_text(tvb, offset, length - 1));
|
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "Version: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Version: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HPFOO_CONFIG_NAME:
|
|
|
|
if (length > 0) {
|
|
|
|
proto_item_set_text(ti, "Config: %s", tvb_format_text(tvb, offset, length - 1));
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Config: %s", tvb_format_text(tvb, offset, length - 1));
|
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "Config: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Config: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HPFOO_IP_ADDR:
|
|
|
|
if (length == 4) {
|
2011-01-16 03:46:16 +00:00
|
|
|
const char *ipstr = tvb_ip_to_str(tvb, offset);
|
|
|
|
proto_item_set_text(ti, "IP Addr: %s", ipstr);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "IP Addr: %s", ipstr);
|
2005-04-01 09:43:19 +00:00
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "IP Addr: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "IP Addr: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HPFOO_FIELD_7:
|
|
|
|
if (length == 1) {
|
|
|
|
proto_item_set_text(ti, "Field 7: 0x%02x", tvb_get_guint8(tvb,offset));
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 7: 0x%02x", tvb_get_guint8(tvb,offset));
|
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "Field 7: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 7: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HPFOO_FIELD_8:
|
|
|
|
if (length == 2) {
|
2006-11-09 12:27:52 +00:00
|
|
|
proto_item_set_text(ti, "Field 8: 0x%04x", tvb_get_ntohs(tvb,offset));
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 8: 0x%04x", tvb_get_ntohs(tvb,offset));
|
2005-04-01 09:43:19 +00:00
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "Field 8: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 8: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HPFOO_FIELD_9:
|
|
|
|
if (length == 2) {
|
2006-11-09 12:27:52 +00:00
|
|
|
proto_item_set_text(ti, "Field 9: 0x%04x", tvb_get_ntohs(tvb,offset));
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 9: 0x%04x", tvb_get_ntohs(tvb,offset));
|
2005-04-01 09:43:19 +00:00
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "Field 9: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 9: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HPFOO_FIELD_10:
|
|
|
|
if (length == 4) {
|
2006-11-09 12:27:52 +00:00
|
|
|
proto_item_set_text(ti, "Field 10: 0x%08x", tvb_get_ntohl(tvb,offset));
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 10: 0x%08x", tvb_get_ntohl(tvb,offset));
|
2005-04-01 09:43:19 +00:00
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "Field 10: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 10: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-11-09 12:27:52 +00:00
|
|
|
case HPFOO_FIELD_12:
|
|
|
|
if (length == 1) {
|
|
|
|
proto_item_set_text(ti, "Field 12: 0x%02x", tvb_get_guint8(tvb,offset));
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 12: 0x%02x", tvb_get_guint8(tvb,offset));
|
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "Field 12: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Field 12: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HPFOO_DEVICE_ID:
|
|
|
|
if (length == 10) {
|
2011-03-03 02:24:44 +00:00
|
|
|
const gchar *macstr = tvb_ether_to_str(tvb, offset);
|
2006-11-09 12:27:52 +00:00
|
|
|
guint32 id=tvb_get_ntohl(tvb, offset+6);
|
2011-03-03 02:24:44 +00:00
|
|
|
proto_item_set_text(ti, "Device ID: %s / %u", macstr, id);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 10, "Device ID: %s / %u", macstr, id);
|
2006-11-09 12:27:52 +00:00
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "Device ID: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Device ID: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-05-09 11:21:16 +00:00
|
|
|
case HPFOO_MAC_ADDR:
|
|
|
|
if (length == 6) {
|
2011-03-03 02:24:44 +00:00
|
|
|
const gchar *macstr = tvb_ether_to_str(tvb, offset);
|
|
|
|
proto_item_set_text(ti, "MAC Addr: %s", macstr);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "MAC Addr: %s", macstr);
|
2005-05-09 11:21:16 +00:00
|
|
|
} else {
|
|
|
|
proto_item_set_text(ti, "MAC Addr: Bad length %u", length);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "MAC Addr: Bad length %u", length);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-04-01 09:43:19 +00:00
|
|
|
default:
|
|
|
|
proto_tree_add_text(tree, tvb, offset, length, "Data");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_hpsw(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_hpsw_version,
|
|
|
|
{ "Version", "hpsw.version", FT_UINT8, BASE_HEX,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2005-04-01 09:43:19 +00:00
|
|
|
{ &hf_hpsw_type,
|
|
|
|
{ "Type", "hpsw.type", FT_UINT8, BASE_HEX,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }},
|
2005-04-01 09:43:19 +00:00
|
|
|
{ &hf_hpsw_tlvtype,
|
|
|
|
{ "Type", "hpsw.tlv_type", FT_UINT8, BASE_HEX,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
VALS(hpsw_tlv_type_vals), 0x0, NULL, HFILL }},
|
2005-04-01 09:43:19 +00:00
|
|
|
{ &hf_hpsw_tlvlength,
|
|
|
|
{ "Length", "hpsw.tlv_len", FT_UINT8, BASE_DEC,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, 0x0, NULL, HFILL }}
|
2005-04-01 09:43:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_hpsw,
|
2006-11-05 18:26:21 +00:00
|
|
|
&ett_hpsw_tlv
|
2005-04-01 09:43:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
proto_hpsw = proto_register_protocol( "HP Switch Protocol", "HPSW", "hpsw");
|
|
|
|
proto_register_field_array(proto_hpsw, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
register_dissector("hpsw", dissect_hpsw, proto_hpsw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_hpsw(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t hpsw_handle;
|
|
|
|
|
|
|
|
hpsw_handle = find_dissector("hpsw");
|
|
|
|
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("hpext.dxsap", HPEXT_HPSW, hpsw_handle);
|
2005-04-01 09:43:19 +00:00
|
|
|
}
|