- dissect data if type unknown

- add display filters

svn path=/trunk/; revision=793
This commit is contained in:
Laurent Deniel 1999-10-09 13:05:55 +00:00
parent bedd4c9d82
commit 30a10446da
1 changed files with 103 additions and 20 deletions

View File

@ -1,7 +1,7 @@
/* packet-bpdu.c
* Routines for BPDU (Spanning Tree Protocol) disassembly
*
* $Id: packet-bpdu.c,v 1.2 1999/10/08 21:20:23 guy Exp $
* $Id: packet-bpdu.c,v 1.3 1999/10/09 13:05:55 deniel Exp $
*
* Copyright 1999 Christophe Tronche <ch.tronche@computer.org>
*
@ -64,6 +64,18 @@
#define BPDU_FORWARD_DELAY 33
static int proto_bpdu = -1;
static int hf_bpdu_proto_id = -1;
static int hf_bpdu_version_id = -1;
static int hf_bpdu_type = -1;
static int hf_bpdu_flags = -1;
static int hf_bpdu_root_mac = -1;
static int hf_bpdu_root_cost = -1;
static int hf_bpdu_bridge_mac = -1;
static int hf_bpdu_port_id = -1;
static int hf_bpdu_msg_age = -1;
static int hf_bpdu_max_age = -1;
static int hf_bpdu_hello_time = -1;
static int hf_bpdu_forward_delay = -1;
void dissect_bpdu(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
guint16 protocol_identifier;
@ -113,19 +125,31 @@ void dissect_bpdu(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
ti = proto_tree_add_item_format(tree, proto_bpdu, offset, 35, NULL, "Spanning Tree Protocol");
bpdu_tree = proto_item_add_subtree(ti, ETT_BPDU);
proto_tree_add_text(bpdu_tree, offset + BPDU_IDENTIFIER, 2, "Protocol Identifier: 0x%04x (%s)",
protocol_identifier,
protocol_identifier == 0 ? "Spanning Tree" : "Unknown Protocol");
proto_tree_add_item_format(bpdu_tree, hf_bpdu_proto_id,
offset + BPDU_IDENTIFIER, 2,
protocol_identifier,
"Protocol Identifier: 0x%04x (%s)",
protocol_identifier,
protocol_identifier == 0 ?
"Spanning Tree" : "Unknown Protocol");
proto_tree_add_text(bpdu_tree, offset + BPDU_VERSION_IDENTIFIER, 1, "Protocol Version Identifier: %d", protocol_version_identifier);
proto_tree_add_item(bpdu_tree, hf_bpdu_version_id,
offset + BPDU_VERSION_IDENTIFIER, 1,
protocol_version_identifier);
if (protocol_version_identifier != 0)
proto_tree_add_text(bpdu_tree, offset + BPDU_VERSION_IDENTIFIER, 1, " (Warning: this version of packet-bpdu only knows about version = 0)");
proto_tree_add_text(bpdu_tree, offset + BPDU_TYPE, 1, "BPDU Type: 0x%02x (%s)",
bpdu_type,
bpdu_type == 0 ? "Configuration" :
bpdu_type == 0x80 ? "Topology Change Notification" : "Unknown");
proto_tree_add_item_format(bpdu_tree, hf_bpdu_type,
offset + BPDU_TYPE, 1,
bpdu_type,
"BPDU Type: 0x%02x (%s)",
bpdu_type,
bpdu_type == 0 ? "Configuration" :
bpdu_type == 0x80 ? "Topology Change Notification" : "Unknown");
if (bpdu_type != 0) return;
if (bpdu_type != 0) {
dissect_data(pd, offset + BPDU_TYPE + 1, fd, tree);
return;
}
bridge_identifier_bridge_priority = pntohs(bpdu + BPDU_BRIDGE_IDENTIFIER);
bridge_identifier_mac = ether_to_str(bpdu + BPDU_BRIDGE_IDENTIFIER + 2);
@ -134,27 +158,86 @@ void dissect_bpdu(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
hello_time = pntohs(bpdu + BPDU_HELLO_TIME) / 256.0;
forward_delay = pntohs(bpdu + BPDU_FORWARD_DELAY) / 256.0;
proto_tree_add_text(bpdu_tree, offset + BPDU_FLAGS, 1, "Flags: 0x%02x", flags);
proto_tree_add_item_format(bpdu_tree, hf_bpdu_flags,
offset + BPDU_FLAGS, 1,
flags,
"Flags: 0x%02x", flags);
if (flags & 0x80)
proto_tree_add_text(bpdu_tree, offset + BPDU_FLAGS, 1, " 1... .... Topology Change Acknowledgment");
if (flags & 0x01)
proto_tree_add_text(bpdu_tree, offset + BPDU_FLAGS, 1, " .... ...1 Topology Change");
proto_tree_add_text(bpdu_tree, offset + BPDU_ROOT_IDENTIFIER, 8, "Root Identifier: %d / %s", root_identifier_bridge_priority, root_identifier_mac);
proto_tree_add_text(bpdu_tree, offset + BPDU_ROOT_PATH_COST, 4, "Root Path Cost: %d", root_path_cost);
proto_tree_add_text(bpdu_tree, offset + BPDU_BRIDGE_IDENTIFIER, 8, "Bridge Identifier: %d / %s",
proto_tree_add_item_hidden(bpdu_tree, hf_bpdu_root_mac,
offset + BPDU_ROOT_IDENTIFIER + 2, 6,
bpdu + BPDU_ROOT_IDENTIFIER + 2);
proto_tree_add_text(bpdu_tree,
offset + BPDU_ROOT_IDENTIFIER, 8,
"Root Identifier: %d / %s",
root_identifier_bridge_priority,
root_identifier_mac);
proto_tree_add_item(bpdu_tree, hf_bpdu_root_cost,
offset + BPDU_ROOT_PATH_COST, 4,
root_path_cost);
proto_tree_add_text(bpdu_tree,
offset + BPDU_BRIDGE_IDENTIFIER, 8,
"Bridge Identifier: %d / %s",
bridge_identifier_bridge_priority,
bridge_identifier_mac);
proto_tree_add_text(bpdu_tree, offset + BPDU_PORT_IDENTIFIER, 2, "Port identifier: 0x%04x", port_identifier);
proto_tree_add_text(bpdu_tree, offset + BPDU_MESSAGE_AGE, 2, "Message Age: %f", message_age);
proto_tree_add_text(bpdu_tree, offset + BPDU_MAX_AGE, 2, "Max Age: %f", max_age);
proto_tree_add_text(bpdu_tree, offset + BPDU_HELLO_TIME, 2, "Hello Time: %f", hello_time);
proto_tree_add_text(bpdu_tree, offset + BPDU_FORWARD_DELAY, 2, "Forward Delay: %f", forward_delay);
proto_tree_add_item_hidden(bpdu_tree, hf_bpdu_bridge_mac,
offset + BPDU_BRIDGE_IDENTIFIER + 2, 6,
bpdu + BPDU_BRIDGE_IDENTIFIER + 2);
proto_tree_add_item_format(bpdu_tree, hf_bpdu_port_id,
offset + BPDU_PORT_IDENTIFIER, 2,
port_identifier,
"Port identifier: 0x%04x",
port_identifier);
proto_tree_add_item(bpdu_tree, hf_bpdu_msg_age,
offset + BPDU_MESSAGE_AGE, 2,
message_age);
proto_tree_add_item(bpdu_tree, hf_bpdu_max_age,
offset + BPDU_MAX_AGE, 2,
max_age);
proto_tree_add_item(bpdu_tree, hf_bpdu_hello_time,
offset + BPDU_HELLO_TIME, 2,
hello_time);
proto_tree_add_item(bpdu_tree, hf_bpdu_forward_delay,
offset + BPDU_FORWARD_DELAY, 2,
forward_delay);
}
}
void
proto_register_bpdu(void)
{
proto_bpdu = proto_register_protocol("Spanning Tree Protocol", "stp");
static hf_register_info hf[] = {
{ &hf_bpdu_proto_id,
{ "Protocol Identifier", "stp.protocol", FT_UINT16, NULL }},
{ &hf_bpdu_version_id,
{ "Protocol Version Identifier", "stp.version", FT_UINT8, NULL }},
{ &hf_bpdu_type,
{ "BPDU type", "stp.type", FT_UINT8, NULL }},
{ &hf_bpdu_flags,
{ "BPDU flags", "stp.flags", FT_UINT8, NULL }},
{ &hf_bpdu_root_mac,
{ "Root Identifier", "stp.root.hw", FT_ETHER, NULL }},
{ &hf_bpdu_root_cost,
{ "Root Path Cost", "stp.root.cost", FT_UINT32, NULL }},
{ &hf_bpdu_bridge_mac,
{ "Bridge Identifier", "stp.bridge.hw", FT_ETHER, NULL }},
{ &hf_bpdu_port_id,
{ "Port identifier", "stp.port", FT_UINT16, NULL }},
{ &hf_bpdu_msg_age,
{ "Message Age", "stp.msg_age", FT_DOUBLE, NULL }},
{ &hf_bpdu_max_age,
{ "Max Age", "stp.max_age", FT_DOUBLE, NULL }},
{ &hf_bpdu_hello_time,
{ "Hello Time", "stp.hello", FT_DOUBLE, NULL }},
{ &hf_bpdu_forward_delay,
{ "Forward Delay", "stp.forward", FT_DOUBLE, NULL }}
};
proto_bpdu = proto_register_protocol("Spanning Tree Protocol", "stp");
proto_register_field_array(proto_bpdu, hf, array_length(hf));
}