From dec54cc52ad3b5813fa1e8e0cc2044fd622d0c55 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 19 Mar 2002 09:17:54 +0000 Subject: Set the length for topology change BPDUs to 4, and leave the length of unknown BPDU types alone. Use the tvbuff's length in as the length of the top-level protocol tree item. svn path=/trunk/; revision=4978 --- packet-bpdu.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'packet-bpdu.c') diff --git a/packet-bpdu.c b/packet-bpdu.c index 7457d84755..f0e7a199a3 100644 --- a/packet-bpdu.c +++ b/packet-bpdu.c @@ -1,7 +1,7 @@ /* packet-bpdu.c * Routines for BPDU (Spanning Tree Protocol) disassembly * - * $Id: packet-bpdu.c,v 1.33 2002/03/19 09:00:44 guy Exp $ + * $Id: packet-bpdu.c,v 1.34 2002/03/19 09:17:54 guy Exp $ * * Copyright 1999 Christophe Tronche * @@ -60,7 +60,8 @@ #define BPDU_FORWARD_DELAY 33 #define BPDU_VERSION_1_LENGTH 35 -#define BPDU_SIZE 35 +#define CONF_BPDU_SIZE 35 +#define TC_BPDU_SIZE 4 #define RST_BPDU_SIZE 36 /* Flag bits */ @@ -270,12 +271,24 @@ dissect_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } - bpdu_size = (bpdu_type == BPDU_TYPE_RST) ? RST_BPDU_SIZE : BPDU_SIZE; - set_actual_length(tvb, bpdu_size); + switch (bpdu_type) { + + case BPDU_TYPE_CONF: + set_actual_length(tvb, CONF_BPDU_SIZE); + break; + + case BPDU_TYPE_TOPOLOGY_CHANGE: + set_actual_length(tvb, TC_BPDU_SIZE); + break; + + case BPDU_TYPE_RST: + set_actual_length(tvb, RST_BPDU_SIZE); + break; + } if (tree) { bpdu_item = proto_tree_add_protocol_format(tree, proto_bpdu, tvb, - 0, bpdu_size, "Spanning Tree Protocol"); + 0, -1, "Spanning Tree Protocol"); bpdu_tree = proto_item_add_subtree(bpdu_item, ett_bpdu); protocol_identifier = tvb_get_ntohs(tvb, BPDU_IDENTIFIER); -- cgit v1.2.3