aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am5
-rw-r--r--packet-cdp.c492
-rw-r--r--packet-cdp.h30
-rw-r--r--packet-cgmp.c52
-rw-r--r--packet-cgmp.h30
-rw-r--r--packet-eth.c16
-rw-r--r--packet-isl.c147
-rw-r--r--packet-isl.h3
-rw-r--r--packet-llc.c35
-rw-r--r--packet-vtp.c277
-rw-r--r--packet-vtp.h30
11 files changed, 522 insertions, 595 deletions
diff --git a/Makefile.am b/Makefile.am
index 259078f988..896e681064 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.263 2000/12/27 12:48:25 guy Exp $
+# $Id: Makefile.am,v 1.264 2000/12/28 09:49:09 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -191,8 +191,6 @@ noinst_HEADERS = \
packet-atalk.h \
packet-bgp.h \
packet-bootparams.h \
- packet-cdp.h \
- packet-cgmp.h \
packet-clip.h \
packet-ddtp.h \
packet-diameter.h \
@@ -251,7 +249,6 @@ noinst_HEADERS = \
packet-udp.h \
packet-vines.h \
packet-vlan.h \
- packet-vtp.h \
packet-wap.h \
packet-wccp.h \
packet-wsp.h \
diff --git a/packet-cdp.c b/packet-cdp.c
index f33b7424af..2b55293d57 100644
--- a/packet-cdp.c
+++ b/packet-cdp.c
@@ -2,7 +2,7 @@
* Routines for the disassembly of the "Cisco Discovery Protocol"
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
- * $Id: packet-cdp.c,v 1.27 2000/11/19 08:53:56 guy Exp $
+ * $Id: packet-cdp.c,v 1.28 2000/12/28 09:49:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -52,7 +52,7 @@
static int proto_cdp = -1;
static int hf_cdp_version = -1;
-static int hf_cdp_flags = -1;
+static int hf_cdp_checksum = -1;
static int hf_cdp_ttl = -1;
static int hf_cdp_tlvtype = -1;
static int hf_cdp_tlvlength = -1;
@@ -63,12 +63,12 @@ static gint ett_cdp_address = -1;
static gint ett_cdp_capabilities = -1;
static int
-dissect_address_tlv(const u_char *pd, int offset, int length, proto_tree *tree);
+dissect_address_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree);
static void
-dissect_capabilities(const u_char *pd, int offset, int length, proto_tree *tree);
+dissect_capabilities(tvbuff_t *tvb, int offset, int length, proto_tree *tree);
static void
-add_multi_line_string_to_tree(proto_tree *tree, gint start, gint len,
- const gchar *prefix, const gchar *string);
+add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
+ gint len, const gchar *prefix);
#define TYPE_DEVICE_ID 0x0001
#define TYPE_ADDRESS 0x0002
@@ -87,193 +87,190 @@ static const value_string type_vals[] = {
{ 0, NULL },
};
-void
-dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+static void
+dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *cdp_tree = NULL;
+ int offset = 0;
guint16 type;
guint16 length;
- char *type_str;
- char *stringmem;
proto_item *tlvi;
proto_tree *tlv_tree;
int real_length;
guint32 naddresses;
int addr_length;
- OLD_CHECK_DISPLAY_AS_DATA(proto_cdp, pd, offset, fd, tree);
+ CHECK_DISPLAY_AS_DATA(proto_cdp, tvb, pinfo, tree);
- if (check_col(fd, COL_PROTOCOL))
- col_set_str(fd, COL_PROTOCOL, "CDP");
- if (check_col(fd, COL_INFO))
- col_set_str(fd, COL_INFO, "Cisco Discovery Protocol");
+ pinfo->current_proto = "CDP";
- if(tree){
- ti = proto_tree_add_item(tree, proto_cdp, NullTVB, offset, END_OF_FRAME, FALSE);
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_set_str(pinfo->fd, COL_PROTOCOL, "CDP");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_set_str(pinfo->fd, COL_INFO, "Cisco Discovery Protocol");
+
+ if (tree){
+ ti = proto_tree_add_item(tree, proto_cdp, tvb, offset,
+ tvb_length_remaining(tvb, offset), FALSE);
cdp_tree = proto_item_add_subtree(ti, ett_cdp);
/* CDP header */
- proto_tree_add_uint(cdp_tree, hf_cdp_version, NullTVB, offset, 1, pd[offset]);
+ proto_tree_add_item(cdp_tree, hf_cdp_version, tvb, offset, 1, FALSE);
offset += 1;
- proto_tree_add_uint_format(cdp_tree, hf_cdp_ttl, NullTVB, offset, 1,
- pntohs(&pd[offset]),
- "TTL: %u seconds", pd[offset]);
+ proto_tree_add_uint_format(cdp_tree, hf_cdp_ttl, tvb, offset, 1,
+ tvb_get_guint8(tvb, offset),
+ "TTL: %u seconds",
+ tvb_get_guint8(tvb, offset));
offset += 1;
- proto_tree_add_uint_format(cdp_tree, hf_cdp_flags, NullTVB, offset, 2,
- pd[offset],
- "Checksum: 0x%04x", pntohs(&pd[offset]));
+ proto_tree_add_item(cdp_tree, hf_cdp_checksum, tvb, offset, 2, FALSE);
offset += 2;
- while( IS_DATA_IN_FRAME(offset) ){
- type = pntohs(&pd[offset + TLV_TYPE]);
- length = pntohs(&pd[offset + TLV_LENGTH]);
- type_str = val_to_str(type, type_vals,
- "Unknown (0x%04x)");
-
- switch( type ){
- case TYPE_DEVICE_ID:
- /* Device ID */
- tlvi = proto_tree_add_text(cdp_tree, NullTVB, offset,
- length, "Device ID: %s",
- &pd[offset+4]);
- tlv_tree = proto_item_add_subtree(tlvi,
- ett_cdp_tlv);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, NullTVB,
- offset + TLV_TYPE, 2, type);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, NullTVB,
- offset + TLV_LENGTH, 2, length);
- proto_tree_add_text(tlv_tree, NullTVB, offset + 4,
- length - 4, "Device ID: %s",
- &pd[offset+4]);
- offset+=length;
- break;
- case TYPE_ADDRESS:
- /* Addresses */
- tlvi = proto_tree_add_text(cdp_tree, NullTVB, offset,
- length, "Addresses");
- tlv_tree = proto_item_add_subtree(tlvi,
- ett_cdp_tlv);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, NullTVB,
- offset + TLV_TYPE, 2, type);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, NullTVB,
- offset + TLV_LENGTH, 2, length);
- offset += 4;
- length -= 4;
- naddresses = pntohl(&pd[offset]);
- proto_tree_add_text(tlv_tree, NullTVB, offset, 4,
- "Number of addresses: %u", naddresses);
- offset += 4;
- length -= 4;
- while (naddresses != 0) {
- addr_length = dissect_address_tlv(pd,
- offset, length, tlv_tree);
- if (addr_length < 0)
- break;
- offset += addr_length;
- length -= addr_length;
-
- naddresses--;
- }
- offset += length;
- break;
- case TYPE_PORT_ID:
- real_length = length;
- if (pd[offset + real_length] != 0x00) {
- /* The length in the TLV doesn't
- appear to be the length of the
- TLV, as the byte just past it
- isn't the first byte of a 2-byte
- big-endian small integer; make
- the length of the TLV the length
- in the TLV, plus 4 bytes for the
- TLV type and length, minus 1
- because that's what makes one
- capture work. */
- real_length = length + 3;
- }
- tlvi = proto_tree_add_text(cdp_tree, NullTVB, offset,
- real_length, "Port ID: %s",
- &pd[offset+4]);
- tlv_tree = proto_item_add_subtree(tlvi,
- ett_cdp_tlv);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, NullTVB,
- offset + TLV_TYPE, 2, type);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, NullTVB,
- offset + TLV_LENGTH, 2, length);
- proto_tree_add_text(tlv_tree, NullTVB, offset + 4,
- real_length - 4,
- "Sent through Interface: %s",
- &pd[offset+4]);
- offset += real_length;
- break;
- case TYPE_CAPABILITIES:
- tlvi = proto_tree_add_text(cdp_tree, NullTVB, offset,
- length, "Capabilities");
- tlv_tree = proto_item_add_subtree(tlvi,
- ett_cdp_tlv);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, NullTVB,
- offset + TLV_TYPE, 2, type);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, NullTVB,
- offset + TLV_LENGTH, 2, length);
- offset += 4;
- length -= 4;
- dissect_capabilities(pd, offset, length,
- tlv_tree);
- offset += length;
- break;
- case TYPE_IOS_VERSION:
- tlvi = proto_tree_add_text(cdp_tree, NullTVB, offset,
- length, "Software Version");
- tlv_tree = proto_item_add_subtree(tlvi,
- ett_cdp_tlv);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, NullTVB,
- offset + TLV_TYPE, 2, type);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, NullTVB,
- offset + TLV_LENGTH, 2, length);
- add_multi_line_string_to_tree(tlv_tree,
- offset + 4, length - 4, "Software Version: ",
- &pd[offset+4] );
- offset += length;
- break;
- case TYPE_PLATFORM:
- /* ??? platform */
- stringmem = malloc(length);
- memset(stringmem, '\0', length);
- memcpy(stringmem, &pd[offset+4], length - 4 );
- tlvi = proto_tree_add_text(cdp_tree, NullTVB,
- offset, length, "Platform: %s",
- stringmem);
- tlv_tree = proto_item_add_subtree(tlvi,
- ett_cdp_tlv);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, NullTVB,
- offset + TLV_TYPE, 2, type);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, NullTVB,
- offset + TLV_LENGTH, 2, length);
- proto_tree_add_text(tlv_tree, NullTVB, offset + 4,
- length - 4, "Platform: %s", stringmem);
- free(stringmem);
- offset+=length;
- break;
- default:
- tlvi = proto_tree_add_text(cdp_tree, NullTVB, offset,
- length, "Type: %s, length: %u",
- type_str, length);
- tlv_tree = proto_item_add_subtree(tlvi,
- ett_cdp_tlv);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, NullTVB,
- offset + TLV_TYPE, 2, type);
- proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, NullTVB,
- offset + TLV_LENGTH, 2, length);
- if (length > 4) {
- proto_tree_add_text(tlv_tree, NullTVB,
- offset + 4, length - 4, "Data");
- } else
- return;
- offset+=length;
+ while (tvb_reported_length_remaining(tvb, offset) != 0) {
+ type = tvb_get_ntohs(tvb, offset + TLV_TYPE);
+ length = tvb_get_ntohs(tvb, offset + TLV_LENGTH);
+
+ switch (type) {
+
+ case TYPE_DEVICE_ID:
+ /* Device ID */
+ tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
+ length, "Device ID: %.*s",
+ length - 4,
+ tvb_get_ptr(tvb, offset + 4, length - 4));
+ tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, tvb,
+ offset + TLV_TYPE, 2, type);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, tvb,
+ offset + TLV_LENGTH, 2, length);
+ proto_tree_add_text(tlv_tree, tvb, offset + 4,
+ length - 4, "Device ID: %.*s",
+ length - 4,
+ tvb_get_ptr(tvb, offset + 4, length - 4));
+ offset += length;
+ break;
+
+ case TYPE_ADDRESS:
+ /* Addresses */
+ tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
+ length, "Addresses");
+ tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, tvb,
+ offset + TLV_TYPE, 2, type);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, tvb,
+ offset + TLV_LENGTH, 2, length);
+ offset += 4;
+ length -= 4;
+ naddresses = tvb_get_ntohl(tvb, offset);
+ proto_tree_add_text(tlv_tree, tvb, offset, 4,
+ "Number of addresses: %u", naddresses);
+ offset += 4;
+ length -= 4;
+ while (naddresses != 0) {
+ addr_length = dissect_address_tlv(tvb, offset, length,
+ tlv_tree);
+ if (addr_length < 0)
+ break;
+ offset += addr_length;
+ length -= addr_length;
+
+ naddresses--;
+ }
+ offset += length;
+ break;
+
+ case TYPE_PORT_ID:
+ real_length = length;
+ if (tvb_get_guint8(tvb, offset + real_length) != 0x00) {
+ /* The length in the TLV doesn't appear to be the
+ length of the TLV, as the byte just past it
+ isn't the first byte of a 2-byte big-endian
+ small integer; make the length of the TLV the length
+ in the TLV, plus 4 bytes for the TLV type and length,
+ minus 1 because that's what makes one capture work. */
+ real_length = length + 3;
}
+ tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
+ real_length, "Port ID: %.*s",
+ real_length - 4,
+ tvb_get_ptr(tvb, offset + 4, real_length - 4));
+ tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, tvb,
+ offset + TLV_TYPE, 2, type);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, tvb,
+ offset + TLV_LENGTH, 2, length);
+ proto_tree_add_text(tlv_tree, tvb, offset + 4,
+ real_length - 4,
+ "Sent through Interface: %.*s",
+ real_length - 4,
+ tvb_get_ptr(tvb, offset + 4, real_length - 4));
+ offset += real_length;
+ break;
+
+ case TYPE_CAPABILITIES:
+ tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
+ length, "Capabilities");
+ tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, tvb,
+ offset + TLV_TYPE, 2, type);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, tvb,
+ offset + TLV_LENGTH, 2, length);
+ offset += 4;
+ length -= 4;
+ dissect_capabilities(tvb, offset, length, tlv_tree);
+ offset += length;
+ break;
+
+ case TYPE_IOS_VERSION:
+ tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
+ length, "Software Version");
+ tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, tvb,
+ offset + TLV_TYPE, 2, type);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, tvb,
+ offset + TLV_LENGTH, 2, length);
+ add_multi_line_string_to_tree(tlv_tree, tvb, offset + 4,
+ length - 4, "Software Version: ");
+ offset += length;
+ break;
+
+ case TYPE_PLATFORM:
+ /* ??? platform */
+ tlvi = proto_tree_add_text(cdp_tree, tvb,
+ offset, length, "Platform: %.*s",
+ length - 4,
+ tvb_get_ptr(tvb, offset + 4, length - 4));
+ tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, tvb,
+ offset + TLV_TYPE, 2, type);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, tvb,
+ offset + TLV_LENGTH, 2, length);
+ proto_tree_add_text(tlv_tree, tvb, offset + 4,
+ length - 4, "Platform: %.*s",
+ length - 4,
+ tvb_get_ptr(tvb, offset + 4, length - 4));
+ offset += length;
+ break;
+
+ default:
+ tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
+ length, "Type: %s, length: %u",
+ val_to_str(type, type_vals, "Unknown (0x%04x)"),
+ length);
+ tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, tvb,
+ offset + TLV_TYPE, 2, type);
+ proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, tvb,
+ offset + TLV_LENGTH, 2, length);
+ if (length > 4) {
+ proto_tree_add_text(tlv_tree, tvb, offset + 4,
+ length - 4, "Data");
+ } else
+ return;
+ offset += length;
+ }
}
- old_dissect_data(pd, offset, fd, cdp_tree);
+ dissect_data(tvb, offset, pinfo, cdp_tree);
}
}
@@ -287,7 +284,7 @@ static const value_string proto_type_vals[] = {
};
static int
-dissect_address_tlv(const u_char *pd, int offset, int length, proto_tree *tree)
+dissect_address_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree)
{
proto_item *ti;
proto_tree *address_tree;
@@ -301,10 +298,10 @@ dissect_address_tlv(const u_char *pd, int offset, int length, proto_tree *tree)
if (length < 1)
return -1;
- ti = proto_tree_add_notext(tree, NullTVB, offset, length);
+ ti = proto_tree_add_notext(tree, tvb, offset, length);
address_tree = proto_item_add_subtree(ti, ett_cdp_address);
- protocol_type = pd[offset];
- proto_tree_add_text(address_tree, NullTVB, offset, 1, "Protocol type: %s",
+ protocol_type = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(address_tree, tvb, offset, 1, "Protocol type: %s",
val_to_str(protocol_type, proto_type_vals, "Unknown (0x%02x)"));
offset += 1;
length -= 1;
@@ -313,8 +310,8 @@ dissect_address_tlv(const u_char *pd, int offset, int length, proto_tree *tree)
proto_item_set_text(ti, "Truncated address");
return -1;
}
- protocol_length = pd[offset];
- proto_tree_add_text(address_tree, NullTVB, offset, 1, "Protocol length: %u",
+ protocol_length = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(address_tree, tvb, offset, 1, "Protocol length: %u",
protocol_length);
offset += 1;
length -= 1;
@@ -322,20 +319,21 @@ dissect_address_tlv(const u_char *pd, int offset, int length, proto_tree *tree)
if (length < protocol_length) {
proto_item_set_text(ti, "Truncated address");
if (length != 0) {
- proto_tree_add_text(address_tree, NullTVB, offset, length,
- "Protocol: %s (truncated)", bytes_to_str(&pd[offset], length));
+ proto_tree_add_text(address_tree, tvb, offset, length,
+ "Protocol: %s (truncated)",
+ tvb_bytes_to_str(tvb, offset, length));
}
return -1;
}
protocol_str = NULL;
if (protocol_type == PROTO_TYPE_NLPID && protocol_length == 1) {
- nlpid = pd[offset];
+ nlpid = tvb_get_guint8(tvb, offset);
protocol_str = val_to_str(nlpid, nlpid_vals, "Unknown (0x%02x)");
} else
nlpid = -1;
if (protocol_str == NULL)
- protocol_str = bytes_to_str(&pd[offset], protocol_length);
- proto_tree_add_text(address_tree, NullTVB, offset, protocol_length,
+ protocol_str = tvb_bytes_to_str(tvb, offset, protocol_length);
+ proto_tree_add_text(address_tree, tvb, offset, protocol_length,
"Protocol: %s", protocol_str);
offset += protocol_length;
length -= protocol_length;
@@ -344,8 +342,8 @@ dissect_address_tlv(const u_char *pd, int offset, int length, proto_tree *tree)
proto_item_set_text(ti, "Truncated address");
return -1;
}
- address_length = pntohs(&pd[offset]);
- proto_tree_add_text(address_tree, NullTVB, offset, 2, "Address length: %u",
+ address_length = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_text(address_tree, tvb, offset, 2, "Address length: %u",
address_length);
offset += 2;
length -= 2;
@@ -353,8 +351,9 @@ dissect_address_tlv(const u_char *pd, int offset, int length, proto_tree *tree)
if (length < address_length) {
proto_item_set_text(ti, "Truncated address");
if (length != 0) {
- proto_tree_add_text(address_tree, NullTVB, offset, length,
- "Address: %s (truncated)", bytes_to_str(&pd[offset], length));
+ proto_tree_add_text(address_tree, tvb, offset, length,
+ "Address: %s (truncated)",
+ tvb_bytes_to_str(tvb, offset, length));
}
return -1;
}
@@ -373,7 +372,7 @@ dissect_address_tlv(const u_char *pd, int offset, int length, proto_tree *tree)
if (address_length == 4) {
/* The address is an IP address. */
address_type_str = "IP address";
- address_str = ip_to_str(&pd[offset]);
+ address_str = ip_to_str(tvb_get_ptr(tvb, offset, 4));
}
break;
}
@@ -381,16 +380,16 @@ dissect_address_tlv(const u_char *pd, int offset, int length, proto_tree *tree)
if (address_type_str == NULL)
address_type_str = "Address";
if (address_str == NULL) {
- address_str = bytes_to_str(&pd[offset], address_length);
+ address_str = tvb_bytes_to_str(tvb, offset, address_length);
}
proto_item_set_text(ti, "%s: %s", address_type_str, address_str);
- proto_tree_add_text(address_tree, NullTVB, offset, address_length, "%s: %s",
+ proto_tree_add_text(address_tree, tvb, offset, address_length, "%s: %s",
address_type_str, address_str);
return 2 + protocol_length + 2 + address_length;
}
static void
-dissect_capabilities(const u_char *pd, int offset, int length, proto_tree *tree)
+dissect_capabilities(tvbuff_t *tvb, int offset, int length, proto_tree *tree)
{
proto_item *ti;
proto_tree *capabilities_tree;
@@ -398,48 +397,48 @@ dissect_capabilities(const u_char *pd, int offset, int length, proto_tree *tree)
if (length < 4)
return;
- capabilities = pntohl(&pd[offset]);
- ti = proto_tree_add_text(tree, NullTVB, offset, length, "Capabilities: 0x%08x",
+ capabilities = tvb_get_ntohl(tvb, offset);
+ ti = proto_tree_add_text(tree, tvb, offset, length, "Capabilities: 0x%08x",
capabilities);
capabilities_tree = proto_item_add_subtree(ti, ett_cdp_capabilities);
- proto_tree_add_text(capabilities_tree, NullTVB, offset, 4,
+ proto_tree_add_text(capabilities_tree, tvb, offset, 4,
decode_boolean_bitfield(capabilities, 0x01, 4*8,
"Performs level 3 routing",
"Doesn't perform level 3 routing"));
- proto_tree_add_text(capabilities_tree, NullTVB, offset, 4,
+ proto_tree_add_text(capabilities_tree, tvb, offset, 4,
decode_boolean_bitfield(capabilities, 0x02, 4*8,
"Performs level 2 transparent bridging",
"Doesn't perform level 2 transparent bridging"));
- proto_tree_add_text(capabilities_tree, NullTVB, offset, 4,
+ proto_tree_add_text(capabilities_tree, tvb, offset, 4,
decode_boolean_bitfield(capabilities, 0x04, 4*8,
"Performs level 2 source-route bridging",
"Doesn't perform level 2 source-route bridging"));
- proto_tree_add_text(capabilities_tree, NullTVB, offset, 4,
+ proto_tree_add_text(capabilities_tree, tvb, offset, 4,
decode_boolean_bitfield(capabilities, 0x08, 4*8,
"Performs level 2 switching",
"Doesn't perform level 2 switching"));
- proto_tree_add_text(capabilities_tree, NullTVB, offset, 4,
+ proto_tree_add_text(capabilities_tree, tvb, offset, 4,
decode_boolean_bitfield(capabilities, 0x10, 4*8,
"Sends and receives packets for network-layer protocols",
"Doesn't send or receive packets for network-layer protocols"));
- proto_tree_add_text(capabilities_tree, NullTVB, offset, 4,
+ proto_tree_add_text(capabilities_tree, tvb, offset, 4,
decode_boolean_bitfield(capabilities, 0x20, 4*8,
"Doesn't forward IGMP Report packets on nonrouter ports",
"Forwards IGMP Report packets on nonrouter ports"));
- proto_tree_add_text(capabilities_tree, NullTVB, offset, 4,
+ proto_tree_add_text(capabilities_tree, tvb, offset, 4,
decode_boolean_bitfield(capabilities, 0x40, 4*8,
"Provides level 1 functionality",
"Doesn't provide level 1 functionality"));
}
static void
-add_multi_line_string_to_tree(proto_tree *tree, gint start, gint len,
- const gchar *prefix, const gchar *string)
+add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
+ gint len, const gchar *prefix)
{
int prefix_len;
int i;
char blanks[64+1];
- const gchar *p, *q;
+ gint next;
int line_len;
int data_len;
@@ -449,22 +448,13 @@ add_multi_line_string_to_tree(proto_tree *tree, gint start, gint len,
for (i = 0; i < prefix_len; i++)
blanks[i] = ' ';
blanks[i] = '\0';
- p = string;
- for (;;) {
- q = strchr(p, '\n');
- if (q != NULL) {
- line_len = q - p;
- data_len = line_len + 1;
- } else {
- line_len = strlen(p);
- data_len = line_len;
- }
- proto_tree_add_text(tree, NullTVB, start, data_len, "%s%.*s", prefix,
- line_len, p);
- if (q == NULL)
- break;
- p += data_len;
+ while (len > 0) {
+ line_len = tvb_find_line_end(tvb, start, len, &next);
+ data_len = next - start;
+ proto_tree_add_text(tree, tvb, start, data_len, "%s%.*s", prefix,
+ line_len, tvb_get_ptr(tvb, start, line_len));
start += data_len;
+ len -= data_len;
prefix = blanks;
}
}
@@ -472,35 +462,41 @@ add_multi_line_string_to_tree(proto_tree *tree, gint start, gint len,
void
proto_register_cdp(void)
{
- static hf_register_info hf[] = {
- { &hf_cdp_version,
- { "Version", "cdp.version", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
-
- { &hf_cdp_flags,
- { "Flags", "cdp.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
- "" }},
-
- { &hf_cdp_ttl,
- { "TTL", "cdp.ttl", FT_UINT16, BASE_DEC, NULL, 0x0,
- "" }},
-
- { &hf_cdp_tlvtype,
- { "Type", "cdp.tlv.type", FT_UINT16, BASE_HEX, VALS(type_vals), 0x0,
- "" }},
-
- { &hf_cdp_tlvlength,
- { "Length", "cdp.tlv.len", FT_UINT16, BASE_DEC, NULL, 0x0,
- "" }},
- };
- static gint *ett[] = {
- &ett_cdp,
- &ett_cdp_tlv,
- &ett_cdp_address,
- &ett_cdp_capabilities,
- };
-
- proto_cdp = proto_register_protocol("Cisco Discovery Protocol", "cdp");
- proto_register_field_array(proto_cdp, hf, array_length(hf));
- proto_register_subtree_array(ett, array_length(ett));
+ static hf_register_info hf[] = {
+ { &hf_cdp_version,
+ { "Version", "cdp.version", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
+ { &hf_cdp_ttl,
+ { "TTL", "cdp.ttl", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
+ { &hf_cdp_checksum,
+ { "Checksum", "cdp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_cdp_tlvtype,
+ { "Type", "cdp.tlv.type", FT_UINT16, BASE_HEX, VALS(type_vals), 0x0,
+ "" }},
+
+ { &hf_cdp_tlvlength,
+ { "Length", "cdp.tlv.len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+ };
+ static gint *ett[] = {
+ &ett_cdp,
+ &ett_cdp_tlv,
+ &ett_cdp_address,
+ &ett_cdp_capabilities,
+ };
+
+ proto_cdp = proto_register_protocol("Cisco Discovery Protocol", "cdp");
+ proto_register_field_array(proto_cdp, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+}
+
+void
+proto_reg_handoff_cdp(void)
+{
+ dissector_add("llc.cisco_pid", 0x2000, dissect_cdp);
}
diff --git a/packet-cdp.h b/packet-cdp.h
deleted file mode 100644
index ec8185ebe4..0000000000
--- a/packet-cdp.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* packet-cdp.h
- *
- * $Id: packet-cdp.h,v 1.2 2000/08/11 13:34:16 deniel Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
- * 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
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __PACKET_CDP_H__
-#define __PACKET_CDP_H__
-
-void dissect_cdp(const u_char *, int, frame_data *, proto_tree *);
-
-#endif
diff --git a/packet-cgmp.c b/packet-cgmp.c
index 8674e97f8b..8485208b17 100644
--- a/packet-cgmp.c
+++ b/packet-cgmp.c
@@ -1,7 +1,7 @@
/* packet-cgmp.c
* Routines for the disassembly of the Cisco Group Management Protocol
*
- * $Id: packet-cgmp.c,v 1.5 2000/11/19 08:53:56 guy Exp $
+ * $Id: packet-cgmp.c,v 1.6 2000/12/28 09:49:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -58,48 +58,48 @@ static const value_string type_vals[] = {
{ 0, NULL },
};
-void
-dissect_cgmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+static void
+dissect_cgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *cgmp_tree = NULL;
+ int offset = 0;
guint8 count;
- OLD_CHECK_DISPLAY_AS_DATA(proto_cgmp, pd, offset, fd, tree);
+ CHECK_DISPLAY_AS_DATA(proto_cgmp, tvb, pinfo, tree);
- if (check_col(fd, COL_PROTOCOL))
- col_set_str(fd, COL_PROTOCOL, "CGMP");
- if (check_col(fd, COL_INFO))
- col_set_str(fd, COL_INFO, "Cisco Group Management Protocol");
+ pinfo->current_proto = "CGMP";
+
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_set_str(pinfo->fd, COL_PROTOCOL, "CGMP");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_set_str(pinfo->fd, COL_INFO, "Cisco Group Management Protocol");
if (tree) {
- ti = proto_tree_add_item(tree, proto_cgmp, NullTVB, offset, END_OF_FRAME, FALSE);
+ ti = proto_tree_add_item(tree, proto_cgmp, tvb, offset,
+ tvb_length_remaining(tvb, offset), FALSE);
cgmp_tree = proto_item_add_subtree(ti, ett_cgmp);
- proto_tree_add_uint(cgmp_tree, hf_cgmp_version, NullTVB, offset, 1,
- pd[offset]);
- proto_tree_add_uint(cgmp_tree, hf_cgmp_type, NullTVB, offset, 1,
- pd[offset]);
+ proto_tree_add_item(cgmp_tree, hf_cgmp_version, tvb, offset, 1,
+ FALSE);
+ proto_tree_add_item(cgmp_tree, hf_cgmp_type, tvb, offset, 1,
+ FALSE);
offset += 1;
offset += 2; /* skip reserved field */
- count = pd[offset];
- proto_tree_add_uint(cgmp_tree, hf_cgmp_count, NullTVB, offset, 1,
+ count = tvb_get_guint8(tvb, offset);
+ proto_tree_add_uint(cgmp_tree, hf_cgmp_count, tvb, offset, 1,
count);
offset += 1;
while (count != 0) {
- if (!BYTES_ARE_IN_FRAME(offset, 6))
- break;
- proto_tree_add_ether(cgmp_tree, hf_cgmp_gda, NullTVB, offset, 6,
- &pd[offset]);
+ proto_tree_add_item(cgmp_tree, hf_cgmp_gda, tvb, offset, 6,
+ FALSE);
offset += 6;
- if (!BYTES_ARE_IN_FRAME(offset, 6))
- break;
- proto_tree_add_ether(cgmp_tree, hf_cgmp_usa, NullTVB, offset, 6,
- &pd[offset]);
+ proto_tree_add_item(cgmp_tree, hf_cgmp_usa, tvb, offset, 6,
+ FALSE);
offset += 6;
count--;
@@ -139,3 +139,9 @@ proto_register_cgmp(void)
proto_register_field_array(proto_cgmp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
+
+void
+proto_reg_handoff_cgmp(void)
+{
+ dissector_add("llc.cisco_pid", 0x2001, dissect_cgmp);
+}
diff --git a/packet-cgmp.h b/packet-cgmp.h
deleted file mode 100644
index de20ba38b6..0000000000
--- a/packet-cgmp.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* packet-cgmp.h
- *
- * $Id: packet-cgmp.h,v 1.2 2000/08/11 13:34:15 deniel Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
- * 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
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __PACKET_CGMP_H__
-#define __PACKET_CGMP_H__
-
-void dissect_cgmp(const u_char *, int, frame_data *, proto_tree *);
-
-#endif
diff --git a/packet-eth.c b/packet-eth.c
index 8e2b802a76..a8adf5706d 100644
--- a/packet-eth.c
+++ b/packet-eth.c
@@ -1,7 +1,7 @@
/* packet-eth.c
* Routines for ethernet packet disassembly
*
- * $Id: packet-eth.c,v 1.50 2000/11/29 05:16:15 gram Exp $
+ * $Id: packet-eth.c,v 1.51 2000/12/28 09:49:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -54,6 +54,8 @@ static int hf_eth_trailer = -1;
static gint ett_ieee8023 = -1;
static gint ett_ether2 = -1;
+static dissector_handle_t isl_handle;
+
#define ETH_HEADER_SIZE 14
/* These are the Netware-ish names for the different Ethernet frame types.
@@ -205,7 +207,7 @@ dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
tvb_get_guint8(tvb, 2) == 0x0C &&
tvb_get_guint8(tvb, 3) == 0x00 &&
tvb_get_guint8(tvb, 4) == 0x00 ) {
- dissect_isl(pd, eth_offset, pinfo->fd, tree);
+ call_dissector(isl_handle, tvb, pinfo, tree);
return;
}
@@ -234,7 +236,10 @@ dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
frame length, by adding in the size of any data that preceded
the Ethernet header, and adding in the Ethernet header size,
and set the payload and captured-payload lengths to the minima
- of the total length and the frame lengths. */
+ of the total length and the frame lengths.
+
+ XXX - when all dissectors are tvbuffified we shouldn't have to
+ do this any more. */
length += eth_offset + ETH_HEADER_SIZE;
if (pinfo->len > length)
pinfo->len = length;
@@ -380,5 +385,10 @@ proto_register_eth(void)
void
proto_reg_handoff_eth(void)
{
+ /*
+ * Get a handle for the ISL dissector.
+ */
+ isl_handle = find_dissector("isl");
+
dissector_add("wtap_encap", WTAP_ENCAP_ETHERNET, dissect_eth);
}
diff --git a/packet-isl.c b/packet-isl.c
index 34353d6cdc..468174dc45 100644
--- a/packet-isl.c
+++ b/packet-isl.c
@@ -1,7 +1,7 @@
/* packet-isl.c
* Routines for Cisco ISL Ethernet header disassembly
*
- * $Id: packet-isl.c,v 1.17 2000/11/19 08:53:58 guy Exp $
+ * $Id: packet-isl.c,v 1.18 2000/12/28 09:49:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -37,6 +37,7 @@
#include <glib.h>
#include "packet.h"
+#include "packet-isl.h"
#include "packet-eth.h"
#include "packet-tr.h"
#include "etypes.h"
@@ -137,104 +138,128 @@ static const true_false_string explorer_tfs = {
"Data frame"
};
-void
-dissect_isl(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+static void
+dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *fh_tree = NULL;
proto_item *ti;
guint8 type;
guint16 length;
+ gint crc_offset;
+ gint captured_length;
tvbuff_t *next_tvb;
- OLD_CHECK_DISPLAY_AS_DATA(proto_isl, pd, offset, fd, tree);
-
- if (!BYTES_ARE_IN_FRAME(offset, ISL_HEADER_SIZE)) {
- old_dissect_data(pd, offset, fd, tree);
- return;
- }
+ CHECK_DISPLAY_AS_DATA(proto_isl, tvb, pinfo, tree);
- if (check_col(fd, COL_PROTOCOL))
- col_set_str(fd, COL_PROTOCOL, "ISL");
- if (check_col(fd, COL_INFO))
- col_add_fstr(fd, COL_INFO, "VLAN ID: 0x%04X", pntohs(&pd[offset+20]) >> 1);
+ pinfo->current_proto = "ISL";
+
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_set_str(pinfo->fd, COL_PROTOCOL, "ISL");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_clear(pinfo->fd, COL_INFO);
- type = (pd[offset+5] >> 4)&0x0F;
+ type = (tvb_get_guint8(tvb, 5) >> 4)&0x0F;
if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_isl, NullTVB, offset, ISL_HEADER_SIZE,
+ ti = proto_tree_add_protocol_format(tree, proto_isl, tvb, 0, ISL_HEADER_SIZE,
"ISL");
fh_tree = proto_item_add_subtree(ti, ett_isl);
- proto_tree_add_ether(fh_tree, hf_isl_dst, NullTVB, offset+0, 6, &pd[offset+0]);
- proto_tree_add_ether_hidden(fh_tree, hf_isl_addr, NullTVB, offset+0, 6, &pd[offset+0]);
- proto_tree_add_uint(fh_tree, hf_isl_type, NullTVB, offset+5, 1, pd[offset+5]);
+ proto_tree_add_item(fh_tree, hf_isl_dst, tvb, 0, 6, FALSE);
+ proto_tree_add_item_hidden(fh_tree, hf_isl_addr, tvb, 0, 6, FALSE);
+ proto_tree_add_item(fh_tree, hf_isl_type, tvb, 5, 1, FALSE);
switch (type) {
case TYPE_ETHER:
- proto_tree_add_uint(fh_tree, hf_isl_user_eth, NullTVB, offset+5, 1,
- pd[offset+5]&0x03);
+ proto_tree_add_item(fh_tree, hf_isl_user_eth, tvb, 5, 1, FALSE);
break;
default:
/* XXX - the spec appears to indicate that the "User" field is
used for TYPE_TR to distinguish between types of packets. */
- proto_tree_add_uint(fh_tree, hf_isl_user, NullTVB, offset+5, 1, pd[offset+5]);
+ proto_tree_add_item(fh_tree, hf_isl_user, tvb, 5, 1, FALSE);
break;
}
- proto_tree_add_ether(fh_tree, hf_isl_src, NullTVB, offset+6, 6, &pd[offset+6]);
- proto_tree_add_ether_hidden(fh_tree, hf_isl_addr, NullTVB, offset+6, 6, &pd[offset+6]);
- length = pntohs(&pd[offset+12]);
- proto_tree_add_uint(fh_tree, hf_isl_len, NullTVB, offset+12, 2, length);
+ proto_tree_add_item(fh_tree, hf_isl_src, tvb, 6, 6, FALSE);
+ proto_tree_add_item_hidden(fh_tree, hf_isl_addr, tvb, 6, 6, FALSE);
+ }
+ length = tvb_get_ntohs(tvb, 12);
+ if (tree) {
+ proto_tree_add_uint(fh_tree, hf_isl_len, tvb, 12, 2, length);
/* This part looks sort of like a SNAP-encapsulated LLC header... */
- proto_tree_add_text(fh_tree, NullTVB, offset+14, 1, "DSAP: 0x%X", pd[offset+14]);
- proto_tree_add_text(fh_tree, NullTVB, offset+15, 1, "SSAP: 0x%X", pd[offset+15]);
- proto_tree_add_text(fh_tree, NullTVB, offset+16, 1, "Control: 0x%X", pd[offset+16]);
+ proto_tree_add_text(fh_tree, tvb, 14, 1, "DSAP: 0x%X", tvb_get_guint8(tvb, 14));
+ proto_tree_add_text(fh_tree, tvb, 15, 1, "SSAP: 0x%X", tvb_get_guint8(tvb, 15));
+ proto_tree_add_text(fh_tree, tvb, 16, 1, "Control: 0x%X", tvb_get_guint8(tvb, 16));
/* ...but this is the manufacturer's ID portion of the source address
field (which is, admittedly, an OUI). */
- proto_tree_add_uint(fh_tree, hf_isl_hsa, NullTVB, offset+17, 3,
- pd[offset+17] << 16 | pd[offset+18] << 8 | pd[offset+19]);
- proto_tree_add_uint(fh_tree, hf_isl_vlan_id, NullTVB, offset+20, 2,
- pntohs(&pd[offset+20]));
- proto_tree_add_boolean(fh_tree, hf_isl_bpdu, NullTVB, offset+20, 2,
- pntohs(&pd[offset+20]));
- proto_tree_add_uint(fh_tree, hf_isl_index, NullTVB, offset+22, 2,
- pntohs(&pd[offset+22]));
-
- /* Now for the CRC, which is at the *end* of the packet. */
- if (BYTES_ARE_IN_FRAME(pi.len - 4, 4)) {
- proto_tree_add_uint(fh_tree, hf_isl_crc, NullTVB, pi.len - 4, 4,
- pntohl(&pd[END_OF_FRAME - 4]));
- }
+ proto_tree_add_item(fh_tree, hf_isl_hsa, tvb, 17, 3, FALSE);
+ }
+ if (check_col(pinfo->fd, COL_INFO))
+ col_add_fstr(pinfo->fd, COL_INFO, "VLAN ID: 0x%04X",
+ tvb_get_ntohs(tvb, 20) >> 1);
+ if (tree) {
+ proto_tree_add_item(fh_tree, hf_isl_vlan_id, tvb, 20, 2, FALSE);
+ proto_tree_add_item(fh_tree, hf_isl_bpdu, tvb, 20, 2, FALSE);
+ proto_tree_add_item(fh_tree, hf_isl_index, tvb, 22, 2, FALSE);
+
+ /* Now for the encapsulated frame's CRC, which is at the *end* of the
+ packet; "length" is the length of the frame, not including the
+ first 14 bytes of the frame, but including the encapsulated
+ frame's CRC, which is 4 bytes long, so the offset of the
+ encapsulated CRC is "length + 14 - 4".
+
+ We check for the CRC and display it only if we have that data,
+ rather than throwing an exception before we've dissected any
+ of the rest of the frame. */
+ crc_offset = length + 14 - 4;
+ if (tvb_bytes_exist(tvb, crc_offset, 4))
+ proto_tree_add_item(fh_tree, hf_isl_crc, tvb, crc_offset, 4, FALSE);
}
switch (type) {
case TYPE_ETHER:
- next_tvb = tvb_create_from_top(offset+26);
- dissect_eth(next_tvb, &pi, tree);
+ /* The length of the encapsulated frame is the length from the
+ header, minus 12 bytes for the part of the ISL header that
+ follows the length and 4 bytes for the encapsulated frame
+ CRC. */
+ if (length >= 12+4) {
+ /* Well, we at least had that much data in the frame. Try
+ dissecting what's left as an Ethernet frame. */
+ length -= 12+4;
+
+ /* Trim the captured length. */
+ captured_length = tvb_length_remaining(tvb, ISL_HEADER_SIZE);
+ if (captured_length > 4) {
+ /* Subtract the encapsulated frame CRC. */
+ captured_length -= 4;
+
+ /* Make sure it's not bigger than the actual length. */
+ if (captured_length > length)
+ captured_length = length;
+ next_tvb = tvb_new_subset(tvb, ISL_HEADER_SIZE, captured_length, length);
+ dissect_eth(next_tvb, pinfo, tree);
+ }
+ }
break;
case TYPE_TR:
- proto_tree_add_uint(fh_tree, hf_isl_src_vlan_id, NullTVB, offset+24, 2,
- pntohs(&pd[offset+24]));
- proto_tree_add_boolean(fh_tree, hf_isl_explorer, NullTVB, offset+24, 2,
- pntohs(&pd[offset+24]));
- proto_tree_add_uint(fh_tree, hf_isl_dst_route_descriptor, NullTVB, offset+26, 2,
- pntohs(&pd[offset+26]));
- proto_tree_add_uint(fh_tree, hf_isl_src_route_descriptor, NullTVB, offset+28, 2,
- pntohs(&pd[offset+28]));
- proto_tree_add_boolean(fh_tree, hf_isl_fcs_not_incl, NullTVB, offset+30, 1,
- pd[offset+30]);
- proto_tree_add_uint(fh_tree, hf_isl_esize, NullTVB, offset+16, 1,
- pd[offset+30]);
- next_tvb = tvb_create_from_top(offset+31);
- dissect_tr(next_tvb, &pi, tree);
+ if (tree) {
+ proto_tree_add_item(fh_tree, hf_isl_src_vlan_id, tvb, 24, 2, FALSE);
+ proto_tree_add_item(fh_tree, hf_isl_explorer, tvb, 24, 2, FALSE);
+ proto_tree_add_item(fh_tree, hf_isl_dst_route_descriptor, tvb, 26, 2, FALSE);
+ proto_tree_add_item(fh_tree, hf_isl_src_route_descriptor, tvb, 28, 2, FALSE);
+ proto_tree_add_item(fh_tree, hf_isl_fcs_not_incl, tvb, 30, 1, FALSE);
+ proto_tree_add_item(fh_tree, hf_isl_esize, tvb, 30, 1, FALSE);
+ }
+ next_tvb = tvb_new_subset(tvb, 31, -1, -1);
+ dissect_tr(next_tvb, pinfo, tree);
break;
default:
- next_tvb = tvb_create_from_top(offset+26);
- dissect_data(next_tvb, 0, &pi, tree);
+ next_tvb = tvb_new_subset(tvb, ISL_HEADER_SIZE, -1, -1);
+ dissect_data(next_tvb, 0, pinfo, tree);
break;
}
}
@@ -307,4 +332,6 @@ proto_register_isl(void)
proto_isl = proto_register_protocol("Cisco ISL", "isl");
proto_register_field_array(proto_isl, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+
+ register_dissector("isl", dissect_isl);
}
diff --git a/packet-isl.h b/packet-isl.h
index 844da04095..102e15f616 100644
--- a/packet-isl.h
+++ b/packet-isl.h
@@ -1,6 +1,6 @@
/* packet-isl.h
*
- * $Id: packet-isl.h,v 1.2 2000/08/11 13:34:10 deniel Exp $
+ * $Id: packet-isl.h,v 1.3 2000/12/28 09:49:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -26,6 +26,5 @@
#define __PACKET_ISL_H__
void capture_isl(const u_char *, int, packet_counts *);
-void dissect_isl(const u_char *, int, frame_data *, proto_tree *);
#endif
diff --git a/packet-llc.c b/packet-llc.c
index 3a98eb0d6d..5e0ed63b04 100644
--- a/packet-llc.c
+++ b/packet-llc.c
@@ -2,7 +2,7 @@
* Routines for IEEE 802.2 LLC layer
* Gilbert Ramirez <gram@xiexie.org>
*
- * $Id: packet-llc.c,v 1.72 2000/11/29 05:16:15 gram Exp $
+ * $Id: packet-llc.c,v 1.73 2000/12/28 09:49:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -38,14 +38,11 @@
#include "xdlc.h"
#include "etypes.h"
#include "llcsaps.h"
-#include "packet-cdp.h"
-#include "packet-cgmp.h"
#include "packet-ip.h"
#include "packet-ipx.h"
#include "packet-netbios.h"
#include "packet-osi.h"
#include "packet-sna.h"
-#include "packet-vtp.h"
static int proto_llc = -1;
static int hf_llc_dsap = -1;
@@ -61,6 +58,7 @@ static gint ett_llc = -1;
static gint ett_llc_ctrl = -1;
static dissector_table_t subdissector_table;
+static dissector_table_t cisco_subdissector_table;
static dissector_handle_t bpdu_handle;
@@ -372,30 +370,11 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
hf_llc_pid, tvb, 6, 2, etype);
}
if (XDLC_IS_INFORMATION(control)) {
- switch (etype) {
-
-#if 0
- case 0x0102:
- dissect_drip(pd, offset, pinfo->fd, tree);
- break;
-#endif
-
- case 0x2000:
- dissect_cdp(pd, offset, pinfo->fd, tree);
- break;
-
- case 0x2001:
- dissect_cgmp(pd, offset, pinfo->fd, tree);
- break;
-
- case 0x2003:
- dissect_vtp(pd, offset, pinfo->fd, tree);
- break;
-
- default:
+ /* do lookup with the subdissector table */
+ /* for future reference, 0x0102 is Cisco DRIP */
+ if (!dissector_try_port(cisco_subdissector_table,
+ etype, next_tvb, pinfo, tree))
dissect_data(next_tvb, 0, pinfo, tree);
- break;
- }
} else
dissect_data(next_tvb, 0, pinfo, tree);
break;
@@ -495,6 +474,7 @@ proto_register_llc(void)
/* subdissector code */
subdissector_table = register_dissector_table("llc.dsap");
+ cisco_subdissector_table = register_dissector_table("llc.cisco_pid");
}
void
@@ -504,5 +484,6 @@ proto_reg_handoff_llc(void)
* Get a handle for the BPDU dissector.
*/
bpdu_handle = find_dissector("bpdu");
+
dissector_add("wtap_encap", WTAP_ENCAP_ATM_RFC1483, dissect_llc);
}
diff --git a/packet-vtp.c b/packet-vtp.c
index 08c06a4d93..07c5128597 100644
--- a/packet-vtp.c
+++ b/packet-vtp.c
@@ -1,7 +1,7 @@
/* packet-vtp.c
* Routines for the disassembly of Cisco's Virtual Trunking Protocol
*
- * $Id: packet-vtp.c,v 1.7 2000/11/19 08:54:10 guy Exp $
+ * $Id: packet-vtp.c,v 1.8 2000/12/28 09:49:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -75,9 +75,9 @@ static gint ett_vtp_vlan_status = -1;
static gint ett_vtp_tlv = -1;
static int
-dissect_vlan_info(const u_char *pd, int offset, proto_tree *tree);
+dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree);
static void
-dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
+dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
proto_tree *tree, proto_item *ti, guint8 type);
#define SUMMARY_ADVERT 0x01
@@ -91,96 +91,97 @@ static const value_string type_vals[] = {
{ 0, NULL },
};
-void
-dissect_vtp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+static void
+dissect_vtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *vtp_tree = NULL;
+ int offset = 0;
guint8 code;
guint8 md_len;
+ guint8 *upd_timestamp;
int vlan_info_len;
- guint32 upd_id;
- OLD_CHECK_DISPLAY_AS_DATA(proto_vtp, pd, offset, fd, tree);
+ CHECK_DISPLAY_AS_DATA(proto_vtp, tvb, pinfo, tree);
- if (check_col(fd, COL_PROTOCOL))
- col_set_str(fd, COL_PROTOCOL, "VTP");
- if (check_col(fd, COL_INFO))
- col_set_str(fd, COL_INFO, "Virtual Trunking Protocol");
+ pinfo->current_proto = "VTP";
+
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_set_str(pinfo->fd, COL_PROTOCOL, "VTP");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_set_str(pinfo->fd, COL_INFO, "Virtual Trunking Protocol");
if (tree) {
- ti = proto_tree_add_item(tree, proto_vtp, NullTVB, offset, END_OF_FRAME,
- FALSE);
+ ti = proto_tree_add_item(tree, proto_vtp, tvb, offset,
+ tvb_length_remaining(tvb, offset), FALSE);
vtp_tree = proto_item_add_subtree(ti, ett_vtp);
- proto_tree_add_uint(vtp_tree, hf_vtp_version, NullTVB, offset, 1,
- pd[offset]);
+ proto_tree_add_item(vtp_tree, hf_vtp_version, tvb, offset, 1,
+ FALSE);
offset += 1;
- code = pd[offset];
- proto_tree_add_uint(vtp_tree, hf_vtp_code, NullTVB, offset, 1,
+ code = tvb_get_guint8(tvb, offset);
+ proto_tree_add_uint(vtp_tree, hf_vtp_code, tvb, offset, 1,
code);
offset += 1;
switch (code) {
case SUMMARY_ADVERT:
- proto_tree_add_uint(vtp_tree, hf_vtp_followers, NullTVB, offset,
- 1, pd[offset]);
+ proto_tree_add_item(vtp_tree, hf_vtp_followers, tvb, offset,
+ 1, FALSE);
offset += 1;
- md_len = pd[offset];
- proto_tree_add_uint(vtp_tree, hf_vtp_md_len, NullTVB, offset,
+ md_len = tvb_get_guint8(tvb, offset);
+ proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
1, md_len);
offset += 1;
- proto_tree_add_string_format(vtp_tree, hf_vtp_md, NullTVB, offset,
- 32, &pd[offset], "Management Domain: %.32s",
- &pd[offset]);
+ proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
+ 32, FALSE);
offset += 32;
- proto_tree_add_uint(vtp_tree, hf_vtp_conf_rev_num, NullTVB,
- offset, 4, pntohl(&pd[offset]));
+ proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
+ offset, 4, FALSE);
offset += 4;
- memcpy(&upd_id, &pd[offset], sizeof upd_id);
- proto_tree_add_ipv4(vtp_tree, hf_vtp_upd_id, NullTVB,
- offset, 4, upd_id);
+ proto_tree_add_item(vtp_tree, hf_vtp_upd_id, tvb,
+ offset, 4, FALSE);
offset += 4;
- proto_tree_add_string_format(vtp_tree, hf_vtp_upd_ts, NullTVB,
- offset, 12, &pd[offset],
+ upd_timestamp = tvb_get_ptr(tvb, offset, 12);
+ proto_tree_add_string_format(vtp_tree, hf_vtp_upd_ts, tvb,
+ offset, 12, upd_timestamp,
"Update Timestamp: %.2s-%.2s-%.2s %.2s:%.2s:%.2s",
- &pd[offset], &pd[offset+2], &pd[offset+4],
- &pd[offset+6], &pd[offset+8], &pd[offset+10]);
+ &upd_timestamp[0], &upd_timestamp[2], &upd_timestamp[4],
+ &upd_timestamp[6], &upd_timestamp[8], &upd_timestamp[10]);
offset += 12;
- proto_tree_add_bytes(vtp_tree, hf_vtp_md5_digest, NullTVB,
- offset, 16, &pd[offset]);
+ proto_tree_add_item(vtp_tree, hf_vtp_md5_digest, tvb,
+ offset, 16, FALSE);
break;
case SUBSET_ADVERT:
- proto_tree_add_uint(vtp_tree, hf_vtp_seq_num, NullTVB, offset,
- 1, pd[offset]);
+ proto_tree_add_item(vtp_tree, hf_vtp_seq_num, tvb, offset,
+ 1, FALSE);
offset += 1;
- md_len = pd[offset];
- proto_tree_add_uint(vtp_tree, hf_vtp_md_len, NullTVB, offset,
+ md_len = tvb_get_guint8(tvb, offset);
+ proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
1, md_len);
offset += 1;
- proto_tree_add_string_format(vtp_tree, hf_vtp_md, NullTVB, offset,
- 32, &pd[offset], "Management Domain: %.32s",
- &pd[offset]);
+ proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
+ 32, FALSE);
offset += 32;
- proto_tree_add_uint(vtp_tree, hf_vtp_conf_rev_num, NullTVB,
- offset, 4, pntohl(&pd[offset]));
+ proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
+ offset, 4, FALSE);
offset += 4;
- for (;;) {
+ while (tvb_reported_length_remaining(tvb, offset) > 0) {
vlan_info_len =
- dissect_vlan_info(pd, offset, vtp_tree);
+ dissect_vlan_info(tvb, offset, vtp_tree);
if (vlan_info_len < 0)
break;
offset += vlan_info_len;
@@ -190,13 +191,13 @@ dissect_vtp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case ADVERT_REQUEST:
offset += 1; /* skip reserved field */
- md_len = pd[offset];
- proto_tree_add_uint(vtp_tree, hf_vtp_md_len, NullTVB, offset,
+ md_len = tvb_get_guint8(tvb, offset);
+ proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
1, md_len);
offset += 1;
- proto_tree_add_uint(vtp_tree, hf_vtp_start_value, NullTVB,
- offset, 2, pntohs(&pd[offset]));
+ proto_tree_add_item(vtp_tree, hf_vtp_start_value, tvb,
+ offset, 2, FALSE);
break;
case 0x04:
@@ -206,21 +207,20 @@ dissect_vtp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
*/
offset += 1; /* skip unknown field */
- md_len = pd[offset];
- proto_tree_add_uint(vtp_tree, hf_vtp_md_len, NullTVB, offset,
+ md_len = tvb_get_guint8(tvb, offset);
+ proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
1, md_len);
offset += 1;
- proto_tree_add_string_format(vtp_tree, hf_vtp_md, NullTVB, offset,
- 32, &pd[offset], "Management Domain: %.32s",
- &pd[offset]);
+ proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
+ 32, FALSE);
offset += 32;
offset += 2; /* skip unknown field */
- proto_tree_add_text(vtp_tree, NullTVB, offset, 2,
+ proto_tree_add_text(vtp_tree, tvb, offset, 2,
"VLAN ID of some sort: 0x%04x",
- pntohs(&pd[offset]));
+ tvb_get_ntohs(tvb, offset));
offset += 2;
break;
}
@@ -264,7 +264,7 @@ static const value_string vlan_tlv_type_vals[] = {
};
static int
-dissect_vlan_info(const u_char *pd, int offset, proto_tree *tree)
+dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree)
{
proto_item *ti;
proto_tree *vlan_info_tree;
@@ -278,96 +278,91 @@ dissect_vlan_info(const u_char *pd, int offset, proto_tree *tree)
char *type_str;
proto_tree *tlv_tree;
- if (!BYTES_ARE_IN_FRAME(offset, 1))
- return -1;
- vlan_info_len = pd[offset];
- ti = proto_tree_add_text(tree, NullTVB, offset, vlan_info_len,
+ vlan_info_len = tvb_get_guint8(tvb, offset);
+ ti = proto_tree_add_text(tree, tvb, offset, vlan_info_len,
"VLAN Information");
vlan_info_tree = proto_item_add_subtree(ti, ett_vtp_vlan_info);
vlan_info_left = vlan_info_len;
- proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_info_len, NullTVB, offset, 1,
+ proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_info_len, tvb, offset, 1,
vlan_info_len);
offset += 1;
vlan_info_left -= 1;
- if (!BYTES_ARE_IN_FRAME(offset, 1) || vlan_info_left < 1)
+ if (vlan_info_left < 1)
return -1;
- status = pd[offset];
- ti = proto_tree_add_text(vlan_info_tree, NullTVB, offset, 1,
+ status = tvb_get_guint8(tvb, offset);
+ ti = proto_tree_add_text(vlan_info_tree, tvb, offset, 1,
"Status: 0x%02x%s", status,
(status & VLAN_SUSPENDED) ? "(VLAN suspended)" : "");
status_tree = proto_item_add_subtree(ti, ett_vtp_vlan_status);
- proto_tree_add_boolean(status_tree, hf_vtp_vlan_status_vlan_susp, NullTVB, offset, 1,
+ proto_tree_add_boolean(status_tree, hf_vtp_vlan_status_vlan_susp, tvb, offset, 1,
status);
offset += 1;
vlan_info_left -= 1;
- if (!BYTES_ARE_IN_FRAME(offset, 1) || vlan_info_left < 1)
+ if (vlan_info_left < 1)
return -1;
- proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_type, NullTVB, offset, 1,
- pd[offset]);
+ proto_tree_add_item(vlan_info_tree, hf_vtp_vlan_type, tvb, offset, 1,
+ FALSE);
offset += 1;
vlan_info_left -= 1;
- if (!BYTES_ARE_IN_FRAME(offset, 1) || vlan_info_left < 1)
+ if (vlan_info_left < 1)
return -1;
- vlan_name_len = pd[offset];
- proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_name_len, NullTVB, offset, 1,
+ vlan_name_len = tvb_get_guint8(tvb, offset);
+ proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_name_len, tvb, offset, 1,
vlan_name_len);
offset += 1;
vlan_info_left -= 1;
- if (!BYTES_ARE_IN_FRAME(offset, 2) || vlan_info_left < 2)
+ if (vlan_info_left < 2)
return -1;
- proto_tree_add_uint(vlan_info_tree, hf_vtp_isl_vlan_id, NullTVB, offset, 2,
- pntohs(&pd[offset]));
+ proto_tree_add_item(vlan_info_tree, hf_vtp_isl_vlan_id, tvb, offset, 2,
+ FALSE);
offset += 2;
vlan_info_left -= 2;
- if (!BYTES_ARE_IN_FRAME(offset, 2) || vlan_info_left < 2)
+ if (vlan_info_left < 2)
return -1;
- proto_tree_add_uint(vlan_info_tree, hf_vtp_mtu_size, NullTVB, offset, 2,
- pntohs(&pd[offset]));
+ proto_tree_add_item(vlan_info_tree, hf_vtp_mtu_size, tvb, offset, 2,
+ FALSE);
offset += 2;
vlan_info_left -= 2;
- if (!BYTES_ARE_IN_FRAME(offset, 4) || vlan_info_left < 4)
+ if (vlan_info_left < 4)
return -1;
- proto_tree_add_uint(vlan_info_tree, hf_vtp_802_10_index, NullTVB, offset, 4,
- pntohl(&pd[offset]));
+ proto_tree_add_item(vlan_info_tree, hf_vtp_802_10_index, tvb, offset, 4,
+ FALSE);
offset += 4;
vlan_info_left -= 4;
- /* VLAN name length appears to be rounded up to a multiple of
- 4. */
+ /* VLAN name length appears to be rounded up to a multiple of 4. */
vlan_name_len = 4*((vlan_name_len + 3)/4);
- if (!BYTES_ARE_IN_FRAME(offset, vlan_name_len)
- || vlan_info_left < vlan_name_len)
+ if (vlan_info_left < vlan_name_len)
return -1;
- proto_tree_add_string_format(vlan_info_tree, hf_vtp_vlan_name, NullTVB, offset,
- vlan_name_len, &pd[offset], "VLAN Name: %.*s", vlan_name_len,
- &pd[offset]);
+ proto_tree_add_item(vlan_info_tree, hf_vtp_vlan_name, tvb, offset,
+ vlan_name_len, FALSE);
offset += vlan_name_len;
vlan_info_left -= vlan_name_len;
- while (IS_DATA_IN_FRAME(offset) && vlan_info_left > 0) {
- type = pd[offset + 0];
- length = pd[offset + 1];
+ while (vlan_info_left > 0) {
+ type = tvb_get_guint8(tvb, offset + 0);
+ length = tvb_get_guint8(tvb, offset + 1);
type_str = val_to_str(type, vlan_tlv_type_vals,
"Unknown (0x%04x)");
- ti = proto_tree_add_notext(vlan_info_tree, NullTVB, offset,
+ ti = proto_tree_add_notext(vlan_info_tree, tvb, offset,
2 + length*2);
tlv_tree = proto_item_add_subtree(ti, ett_vtp_tlv);
- proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvtype, NullTVB, offset,
+ proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvtype, tvb, offset,
1, type);
- proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvlength, NullTVB, offset+1,
+ proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvlength, tvb, offset+1,
1, length);
offset += 2;
vlan_info_left -= 2;
if (length > 0) {
- dissect_vlan_info_tlv(pd, offset, length*2, tlv_tree,
+ dissect_vlan_info_tlv(tvb, offset, length*2, tlv_tree,
ti, type);
}
offset += length*2;
@@ -403,7 +398,7 @@ static const value_string backup_crf_mode_vals[] = {
};
static void
-dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
+dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
proto_tree *tree, proto_item *ti, guint8 type)
{
switch (type) {
@@ -412,15 +407,15 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Source-Routing Ring Number: 0x%04x",
- pntohs(&pd[offset]));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ tvb_get_ntohs(tvb, offset));
+ proto_tree_add_text(tree, tvb, offset, 2,
"Source-Routing Ring Number: 0x%04x",
- pntohs(&pd[offset]));
+ tvb_get_ntohs(tvb, offset));
} else {
proto_item_set_text(ti,
"Source-Routing Ring Number: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Source-Routing Ring Number: Bad length %u",
length);
}
@@ -430,15 +425,15 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Source-Routing Bridge Number: 0x%04x",
- pntohs(&pd[offset]));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ tvb_get_ntohs(tvb, offset));
+ proto_tree_add_text(tree, tvb, offset, 2,
"Source-Routing Bridge Number: 0x%04x",
- pntohs(&pd[offset]));
+ tvb_get_ntohs(tvb, offset));
} else {
proto_item_set_text(ti,
"Source-Routing Bridge Number: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Source-Routing Bridge Number: Bad length %u",
length);
}
@@ -448,17 +443,17 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Spanning-Tree Protocol Type: %s",
- val_to_str(pntohs(&pd[offset]), stp_type_vals,
+ val_to_str(tvb_get_ntohs(tvb, offset), stp_type_vals,
"Unknown (0x%04x)"));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ proto_tree_add_text(tree, tvb, offset, 2,
"Spanning-Tree Protocol Type: %s",
- val_to_str(pntohs(&pd[offset]), stp_type_vals,
+ val_to_str(tvb_get_ntohs(tvb, offset), stp_type_vals,
"Unknown (0x%04x)"));
} else {
proto_item_set_text(ti,
"Spanning-Tree Protocol Type: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Spanning-Tree Protocol Type: Bad length %u",
length);
}
@@ -468,15 +463,15 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Parent VLAN: 0x%04x",
- pntohs(&pd[offset]));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ tvb_get_ntohs(tvb, offset));
+ proto_tree_add_text(tree, tvb, offset, 2,
"Parent VLAN: 0x%04x",
- pntohs(&pd[offset]));
+ tvb_get_ntohs(tvb, offset));
} else {
proto_item_set_text(ti,
"Parent VLAN: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Parent VLAN: Bad length %u",
length);
}
@@ -486,15 +481,15 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Translationally Bridged VLANs: 0x%04x",
- pntohs(&pd[offset]));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ tvb_get_ntohs(tvb, offset));
+ proto_tree_add_text(tree, tvb, offset, 2,
"Translationally Bridged VLANs: 0x%04x",
- pntohs(&pd[offset]));
+ tvb_get_ntohs(tvb, offset));
} else {
proto_item_set_text(ti,
"Translationally Bridged VLANs: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Translationally Bridged VLANs: Bad length %u",
length);
}
@@ -504,17 +499,17 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Pruning: %s",
- val_to_str(pntohs(&pd[offset]), pruning_vals,
+ val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
"Unknown (0x%04x)"));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ proto_tree_add_text(tree, tvb, offset, 2,
"Pruning: %s",
- val_to_str(pntohs(&pd[offset]), pruning_vals,
+ val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
"Unknown (0x%04x)"));
} else {
proto_item_set_text(ti,
"Pruning: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Pruning: Bad length %u",
length);
}
@@ -524,17 +519,17 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Bridge Type: %s",
- val_to_str(pntohs(&pd[offset]), bridge_type_vals,
+ val_to_str(tvb_get_ntohs(tvb, offset), bridge_type_vals,
"Unknown (0x%04x)"));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ proto_tree_add_text(tree, tvb, offset, 2,
"Bridge Type: %s",
- val_to_str(pntohs(&pd[offset]), bridge_type_vals,
+ val_to_str(tvb_get_ntohs(tvb, offset), bridge_type_vals,
"Unknown (0x%04x)"));
} else {
proto_item_set_text(ti,
"Bridge Type: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Bridge Type: Bad length %u",
length);
}
@@ -544,15 +539,15 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Max ARE Hop Count: %u",
- pntohs(&pd[offset]));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ tvb_get_ntohs(tvb, offset));
+ proto_tree_add_text(tree, tvb, offset, 2,
"Max ARE Hop Count: %u",
- pntohs(&pd[offset]));
+ tvb_get_ntohs(tvb, offset));
} else {
proto_item_set_text(ti,
"Max ARE Hop Count: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Max ARE Hop Count: Bad length %u",
length);
}
@@ -562,15 +557,15 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Max STE Hop Count: %u",
- pntohs(&pd[offset]));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ tvb_get_ntohs(tvb, offset));
+ proto_tree_add_text(tree, tvb, offset, 2,
"Max STE Hop Count: %u",
- pntohs(&pd[offset]));
+ tvb_get_ntohs(tvb, offset));
} else {
proto_item_set_text(ti,
"Max STE Hop Count: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Max STE Hop Count: Bad length %u",
length);
}
@@ -580,17 +575,17 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
if (length == 2) {
proto_item_set_text(ti,
"Backup CRF Mode: %s",
- val_to_str(pntohs(&pd[offset]), backup_crf_mode_vals,
+ val_to_str(tvb_get_ntohs(tvb, offset), backup_crf_mode_vals,
"Unknown (0x%04x)"));
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ proto_tree_add_text(tree, tvb, offset, 2,
"Backup CRF Mode: %s",
- val_to_str(pntohs(&pd[offset]), backup_crf_mode_vals,
+ val_to_str(tvb_get_ntohs(tvb, offset), backup_crf_mode_vals,
"Unknown (0x%04x)"));
} else {
proto_item_set_text(ti,
"Backup CRF Mode: Bad length %u",
length);
- proto_tree_add_text(tree, NullTVB, offset, length,
+ proto_tree_add_text(tree, tvb, offset, length,
"Backup CRF Mode: Bad length %u",
length);
}
@@ -598,7 +593,7 @@ dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
default:
proto_item_set_text(ti, "Unknown TLV type: 0x%02x", type);
- proto_tree_add_text(tree, NullTVB, offset, length, "Data");
+ proto_tree_add_text(tree, tvb, offset, length, "Data");
break;
}
}
@@ -702,3 +697,9 @@ proto_register_vtp(void)
proto_register_field_array(proto_vtp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
+
+void
+proto_reg_handoff_vtp(void)
+{
+ dissector_add("llc.cisco_pid", 0x2003, dissect_vtp);
+}
diff --git a/packet-vtp.h b/packet-vtp.h
deleted file mode 100644
index 21a9155abf..0000000000
--- a/packet-vtp.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* packet-vtp.h
- *
- * $Id: packet-vtp.h,v 1.2 2000/08/11 13:33:57 deniel Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
- * 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
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __PACKET_VTP_H__
-#define __PACKET_VTP_H__
-
-void dissect_vtp(const u_char *, int, frame_data *, proto_tree *);
-
-#endif