2004-09-28 03:04:24 +04:00
|
|
|
/* $NetBSD: print-stp.c,v 1.4 2004/09/27 23:04:25 dyoung Exp $ */
|
2001-06-25 23:26:28 +04: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>
|
|
|
|
*/
|
|
|
|
|
2001-06-25 23:59:56 +04:00
|
|
|
#include <sys/cdefs.h>
|
2001-06-25 23:26:28 +04:00
|
|
|
#ifndef lint
|
2001-06-25 23:59:56 +04:00
|
|
|
#if 0
|
2004-09-28 03:04:24 +04:00
|
|
|
static const char rcsid[] _U_ =
|
|
|
|
"@(#) Header: /tcpdump/master/tcpdump/print-stp.c,v 1.11.2.2 2003/11/16 08:51:46 guy Exp";
|
2001-06-25 23:59:56 +04:00
|
|
|
#else
|
2004-09-28 03:04:24 +04:00
|
|
|
__RCSID("$NetBSD: print-stp.c,v 1.4 2004/09/27 23:04:25 dyoung Exp $");
|
2001-06-25 23:59:56 +04:00
|
|
|
#endif
|
2001-06-25 23:26:28 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2004-09-28 03:04:24 +04:00
|
|
|
#include <tcpdump-stdinc.h>
|
2001-06-25 23:26:28 +04: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-09-28 03:04:24 +04:00
|
|
|
stp_print_config_bpdu(const u_char *p)
|
2001-06-25 23:26:28 +04:00
|
|
|
{
|
|
|
|
printf("config ");
|
|
|
|
if (p[7] & 1)
|
|
|
|
printf("TOP_CHANGE ");
|
|
|
|
if (p[7] & 0x80)
|
|
|
|
printf("TOP_CHANGE_ACK ");
|
|
|
|
|
|
|
|
stp_print_bridge_id(p+20);
|
|
|
|
printf(".%.2x%.2x ", p[28], p[29]);
|
|
|
|
|
|
|
|
printf("root ");
|
|
|
|
stp_print_bridge_id(p+8);
|
|
|
|
|
|
|
|
printf(" pathcost %i ", (p[16] << 24) | (p[17] << 16) | (p[18] << 8) | p[19]);
|
|
|
|
|
|
|
|
printf("age %i ", p[30]);
|
|
|
|
printf("max %i ", p[32]);
|
|
|
|
printf("hello %i ", p[34]);
|
|
|
|
printf("fdelay %i ", p[36]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-09-28 03:04:24 +04:00
|
|
|
stp_print_tcn_bpdu(void)
|
2001-06-25 23:26:28 +04:00
|
|
|
{
|
|
|
|
printf("tcn");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print 802.1d packets.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
stp_print(const u_char *p, u_int length)
|
|
|
|
{
|
|
|
|
if (length < 7)
|
|
|
|
goto trunc;
|
|
|
|
|
|
|
|
printf("802.1d ");
|
|
|
|
if (p[2] != 0x03 || p[3] || p[4] || p[5]) {
|
|
|
|
printf("unknown version");
|
|
|
|
return;
|
|
|
|
}
|
2004-09-28 03:04:24 +04:00
|
|
|
|
2001-06-25 23:26:28 +04:00
|
|
|
switch (p[6])
|
|
|
|
{
|
2004-09-28 03:04:24 +04:00
|
|
|
case 0x00:
|
2001-06-25 23:26:28 +04:00
|
|
|
if (length < 10)
|
|
|
|
goto trunc;
|
2004-09-28 03:04:24 +04:00
|
|
|
stp_print_config_bpdu(p);
|
2001-06-25 23:26:28 +04:00
|
|
|
break;
|
|
|
|
|
2004-09-28 03:04:24 +04:00
|
|
|
case 0x80:
|
|
|
|
stp_print_tcn_bpdu();
|
2001-06-25 23:26:28 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-05-31 13:45:44 +04:00
|
|
|
printf("unknown type %i", p[6]);
|
2001-06-25 23:26:28 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
trunc:
|
|
|
|
printf("[|stp %d]", length);
|
|
|
|
}
|