2001-04-03 07:45:48 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000 Lennert Buytenhek
|
|
|
|
*
|
|
|
|
* This software may be distributed either under the terms of the
|
|
|
|
* BSD-style license that accompanies tcpdump or the GNU General
|
|
|
|
* Public License
|
|
|
|
*
|
|
|
|
* Format and print IEEE 802.1d spanning tree protocol packets.
|
|
|
|
* Contributed by Lennert Buytenhek <buytenh@gnu.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef lint
|
2004-03-31 09:17:26 +00:00
|
|
|
static const char rcsid[] _U_ =
|
2005-07-11 03:54:22 +00:00
|
|
|
"@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.13.2.1 2005/04/26 07:27:17 guy Exp $";
|
2001-04-03 07:45:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2004-03-31 09:17:26 +00:00
|
|
|
#include <tcpdump-stdinc.h>
|
2001-04-03 07:45:48 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "interface.h"
|
|
|
|
#include "addrtoname.h"
|
|
|
|
#include "extract.h"
|
|
|
|
|
|
|
|
static void
|
|
|
|
stp_print_bridge_id(const u_char *p)
|
|
|
|
{
|
|
|
|
printf("%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
|
|
|
|
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-31 09:17:26 +00:00
|
|
|
stp_print_config_bpdu(const u_char *p)
|
2001-04-03 07:45:48 +00:00
|
|
|
{
|
|
|
|
printf("config ");
|
2005-07-11 03:54:22 +00:00
|
|
|
if (p[4] & 1)
|
2001-04-03 07:45:48 +00:00
|
|
|
printf("TOP_CHANGE ");
|
2005-07-11 03:54:22 +00:00
|
|
|
if (p[4] & 0x80)
|
2001-04-03 07:45:48 +00:00
|
|
|
printf("TOP_CHANGE_ACK ");
|
|
|
|
|
2005-07-11 03:54:22 +00:00
|
|
|
stp_print_bridge_id(p+17);
|
|
|
|
printf(".%.2x%.2x ", p[25], p[26]);
|
2001-04-03 07:45:48 +00:00
|
|
|
|
|
|
|
printf("root ");
|
2005-07-11 03:54:22 +00:00
|
|
|
stp_print_bridge_id(p+5);
|
2001-04-03 07:45:48 +00:00
|
|
|
|
2005-07-11 03:54:22 +00:00
|
|
|
printf(" pathcost %i ", (p[13] << 24) | (p[14] << 16) | (p[15] << 8) | p[16]);
|
2001-04-03 07:45:48 +00:00
|
|
|
|
2005-07-11 03:54:22 +00:00
|
|
|
printf("age %i ", p[27]);
|
|
|
|
printf("max %i ", p[29]);
|
|
|
|
printf("hello %i ", p[31]);
|
|
|
|
printf("fdelay %i ", p[33]);
|
2001-04-03 07:45:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-31 09:17:26 +00:00
|
|
|
stp_print_tcn_bpdu(void)
|
2001-04-03 07:45:48 +00:00
|
|
|
{
|
|
|
|
printf("tcn");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print 802.1d packets.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
stp_print(const u_char *p, u_int length)
|
|
|
|
{
|
2005-07-11 03:54:22 +00:00
|
|
|
if (length < 4)
|
2001-04-03 07:45:48 +00:00
|
|
|
goto trunc;
|
|
|
|
|
|
|
|
printf("802.1d ");
|
2005-07-11 03:54:22 +00:00
|
|
|
if (p[0] || p[1] || p[2]) {
|
2001-04-03 07:45:48 +00:00
|
|
|
printf("unknown version");
|
|
|
|
return;
|
|
|
|
}
|
2004-03-31 09:17:26 +00:00
|
|
|
|
2005-07-11 03:54:22 +00:00
|
|
|
switch (p[3])
|
2001-04-03 07:45:48 +00:00
|
|
|
{
|
2004-03-31 09:17:26 +00:00
|
|
|
case 0x00:
|
2001-04-03 07:45:48 +00:00
|
|
|
if (length < 10)
|
|
|
|
goto trunc;
|
2004-03-31 09:17:26 +00:00
|
|
|
stp_print_config_bpdu(p);
|
2001-04-03 07:45:48 +00:00
|
|
|
break;
|
|
|
|
|
2004-03-31 09:17:26 +00:00
|
|
|
case 0x80:
|
|
|
|
stp_print_tcn_bpdu();
|
2001-04-03 07:45:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-07-11 03:54:22 +00:00
|
|
|
printf("unknown type %i", p[3]);
|
2001-04-03 07:45:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
trunc:
|
|
|
|
printf("[|stp %d]", length);
|
|
|
|
}
|