X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3cd171317f54bc968808d49e3ca87b6c49ccdcdd..4fe64c9d253007f06b52c6d8be2c99bfc28f989b:/print-stp.c diff --git a/print-stp.c b/print-stp.c index 43bf9288..6ec2c097 100644 --- a/print-stp.c +++ b/print-stp.c @@ -10,26 +10,15 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.3 2000-07-01 03:39:10 assar Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.14 2005-04-26 07:26:34 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include @@ -47,30 +36,30 @@ stp_print_bridge_id(const u_char *p) } static void -stp_print_config_bpdu(const u_char *p, u_int length) +stp_print_config_bpdu(const u_char *p) { printf("config "); - if (p[7] & 1) + if (p[4] & 1) printf("TOP_CHANGE "); - if (p[7] & 0x80) + if (p[4] & 0x80) printf("TOP_CHANGE_ACK "); - stp_print_bridge_id(p+20); - printf(".%.2x%.2x ", p[28], p[29]); + stp_print_bridge_id(p+17); + printf(".%.2x%.2x ", p[25], p[26]); printf("root "); - stp_print_bridge_id(p+8); + stp_print_bridge_id(p+5); - printf(" pathcost %i ", (p[16] << 24) | (p[17] << 16) | (p[18] << 8) | p[19]); + printf(" pathcost %i ", (p[13] << 24) | (p[14] << 16) | (p[15] << 8) | p[16]); - printf("age %i ", p[30]); - printf("max %i ", p[32]); - printf("hello %i ", p[34]); - printf("fdelay %i ", p[36]); + printf("age %i ", p[27]); + printf("max %i ", p[29]); + printf("hello %i ", p[31]); + printf("fdelay %i ", p[33]); } static void -stp_print_tcn_bpdu(const u_char *p, u_int length) +stp_print_tcn_bpdu(void) { printf("tcn"); } @@ -81,29 +70,29 @@ stp_print_tcn_bpdu(const u_char *p, u_int length) void stp_print(const u_char *p, u_int length) { - if (length < 7) + if (length < 4) goto trunc; printf("802.1d "); - if (p[2] != 0x03 || p[3] || p[4] || p[5]) { + if (p[0] || p[1] || p[2]) { printf("unknown version"); return; } - - switch (p[6]) + + switch (p[3]) { - case 0: + case 0x00: if (length < 10) goto trunc; - stp_print_config_bpdu(p, length); + stp_print_config_bpdu(p); break; - case 1: - stp_print_tcn_bpdu(p, length); + case 0x80: + stp_print_tcn_bpdu(); break; default: - printf("unknown type %i\n", p[6]); + printf("unknown type %i", p[3]); break; }