003 File Manager
Current Path:
/usr/src/contrib/tcpdump
usr
/
src
/
contrib
/
tcpdump
/
📁
..
📄
CHANGES
(57.87 KB)
📄
CONTRIBUTING
(5.93 KB)
📄
CREDITS
(14.57 KB)
📄
INSTALL.txt
(5.25 KB)
📄
LICENSE
(873 B)
📄
Makefile-devel-adds
(614 B)
📄
Makefile.in
(9.96 KB)
📄
PLATFORMS
(567 B)
📄
README
(9.04 KB)
📄
README.md
(9.04 KB)
📄
VERSION
(6 B)
📄
addrtoname.c
(33.19 KB)
📄
addrtoname.h
(2.78 KB)
📄
addrtostr.c
(5.64 KB)
📄
addrtostr.h
(2.03 KB)
📄
af.c
(1.96 KB)
📄
af.h
(1.81 KB)
📄
ah.h
(2.34 KB)
📄
appletalk.h
(4.06 KB)
📄
ascii_strcasecmp.c
(3.5 KB)
📄
ascii_strcasecmp.h
(1.49 KB)
📄
atime.awk
(529 B)
📄
atm.h
(1.14 KB)
📄
bpf_dump.c
(1.9 KB)
📄
chdlc.h
(1.31 KB)
📄
checksum.c
(5.25 KB)
📄
config.guess
(43.17 KB)
📄
config.h.in
(11.19 KB)
📄
config.sub
(34.93 KB)
📄
configure
(255.88 KB)
📄
configure.ac
(25.05 KB)
📄
configure.in
(25.66 KB)
📄
cpack.c
(3.92 KB)
📄
cpack.h
(2.37 KB)
📄
ether.h
(2.34 KB)
📄
ethertype.h
(5.58 KB)
📄
extract.h
(11.48 KB)
📄
funcattrs.h
(4.42 KB)
📄
getopt_long.h
(2.52 KB)
📄
gmpls.c
(5.82 KB)
📄
gmpls.h
(1.38 KB)
📄
gmt2local.c
(2.01 KB)
📄
gmt2local.h
(1.21 KB)
📄
in_cksum.c
(6.44 KB)
📄
install-sh
(5.45 KB)
📄
interface.h
(2.29 KB)
📄
ip.h
(5.75 KB)
📄
ip6.h
(7.6 KB)
📄
ipproto.c
(16.49 KB)
📄
ipproto.h
(4.72 KB)
📄
l2vpn.c
(3.36 KB)
📄
l2vpn.h
(781 B)
📁
lbl
📄
llc.h
(3.72 KB)
📄
machdep.c
(2.58 KB)
📄
machdep.h
(1.24 KB)
📄
makemib
(6.41 KB)
📄
mib.h
(26.33 KB)
📁
missing
📄
mkdep
(2.43 KB)
📄
mpls.h
(1.93 KB)
📄
nameser.h
(10.8 KB)
📄
netdissect-stdinc.h
(9.93 KB)
📄
netdissect.c
(3.38 KB)
📄
netdissect.h
(30.13 KB)
📄
nfs.h
(13.37 KB)
📄
nfsfh.h
(2.57 KB)
📄
nlpid.c
(1.27 KB)
📄
nlpid.h
(1.3 KB)
📄
openflow.h
(2.14 KB)
📄
ospf.h
(10.21 KB)
📄
oui.c
(3.83 KB)
📄
oui.h
(4.06 KB)
📄
packetdat.awk
(1.39 KB)
📄
parsenfsfh.c
(12.87 KB)
📄
pcap-missing.h
(1.8 KB)
📄
pcap_dump_ftell.c
(1.29 KB)
📄
ppp.h
(3.07 KB)
📄
print-802_11.c
(91.47 KB)
📄
print-802_15_4.c
(5.5 KB)
📄
print-ah.c
(2.02 KB)
📄
print-ahcp.c
(10.73 KB)
📄
print-aodv.c
(15.98 KB)
📄
print-aoe.c
(11.13 KB)
📄
print-ap1394.c
(4 KB)
📄
print-arcnet.c
(8.83 KB)
📄
print-arp.c
(14.57 KB)
📄
print-ascii.c
(6.23 KB)
📄
print-atalk.c
(16.76 KB)
📄
print-atm.c
(16.81 KB)
📄
print-babel.c
(23.79 KB)
📄
print-beep.c
(1.71 KB)
📄
print-bfd.c
(16.5 KB)
📄
print-bgp.c
(99.77 KB)
📄
print-bootp.c
(30.07 KB)
📄
print-bt.c
(2.21 KB)
📄
print-calm-fast.c
(1.81 KB)
📄
print-carp.c
(2.43 KB)
📄
print-cdp.c
(11.16 KB)
📄
print-cfm.c
(24.19 KB)
📄
print-chdlc.c
(5.88 KB)
📄
print-cip.c
(2.5 KB)
📄
print-cnfp.c
(13.69 KB)
📄
print-dccp.c
(17.75 KB)
📄
print-decnet.c
(37.63 KB)
📄
print-dhcp6.c
(23.22 KB)
📄
print-domain.c
(18.44 KB)
📄
print-dtp.c
(3.03 KB)
📄
print-dvmrp.c
(8.98 KB)
📄
print-eap.c
(9.26 KB)
📄
print-egp.c
(8.69 KB)
📄
print-eigrp.c
(19.49 KB)
📄
print-enc.c
(4.2 KB)
📄
print-esp.c
(21.46 KB)
📄
print-ether.c
(12.91 KB)
📄
print-fddi.c
(10.51 KB)
📄
print-forces.c
(45.01 KB)
📄
print-fr.c
(31.99 KB)
📄
print-frag6.c
(2.36 KB)
📄
print-ftp.c
(973 B)
📄
print-geneve.c
(6.13 KB)
📄
print-geonet.c
(6.72 KB)
📄
print-gre.c
(9.72 KB)
📄
print-hncp.c
(26.39 KB)
📄
print-hsrp.c
(4.57 KB)
📄
print-http.c
(1.51 KB)
📄
print-icmp.c
(22.7 KB)
📄
print-icmp6.c
(59.81 KB)
📄
print-igmp.c
(10.05 KB)
📄
print-igrp.c
(4.64 KB)
📄
print-ip.c
(17.04 KB)
📄
print-ip6.c
(10.57 KB)
📄
print-ip6opts.c
(5.53 KB)
📄
print-ipcomp.c
(2.32 KB)
📄
print-ipfc.c
(4.41 KB)
📄
print-ipnet.c
(2.78 KB)
📄
print-ipx.c
(6.42 KB)
📄
print-isakmp.c
(81.72 KB)
📄
print-isoclns.c
(107.61 KB)
📄
print-juniper.c
(48.42 KB)
📄
print-krb.c
(6.26 KB)
📄
print-l2tp.c
(23.94 KB)
📄
print-lane.c
(3.04 KB)
📄
print-ldp.c
(24.35 KB)
📄
print-lisp.c
(15.23 KB)
📄
print-llc.c
(16.68 KB)
📄
print-lldp.c
(57.26 KB)
📄
print-lmp.c
(38.11 KB)
📄
print-loopback.c
(3.63 KB)
📄
print-lspping.c
(51.64 KB)
📄
print-lwapp.c
(13.01 KB)
📄
print-lwres.c
(14.08 KB)
📄
print-m3ua.c
(10.92 KB)
📄
print-medsa.c
(5.57 KB)
📄
print-mobile.c
(3.28 KB)
📄
print-mobility.c
(9.74 KB)
📄
print-mpcp.c
(7.87 KB)
📄
print-mpls.c
(5.31 KB)
📄
print-mptcp.c
(13.68 KB)
📄
print-msdp.c
(2.69 KB)
📄
print-msnlb.c
(2.39 KB)
📄
print-nflog.c
(4.4 KB)
📄
print-nfs.c
(42.84 KB)
📄
print-nsh.c
(5.39 KB)
📄
print-ntp.c
(13.34 KB)
📄
print-null.c
(4.01 KB)
📄
print-olsr.c
(23.42 KB)
📄
print-openflow-1.0.c
(76.63 KB)
📄
print-openflow.c
(4.77 KB)
📄
print-ospf.c
(39.49 KB)
📄
print-ospf6.c
(29.86 KB)
📄
print-otv.c
(2.1 KB)
📄
print-pflog.c
(4.86 KB)
📄
print-pfsync.c
(12.53 KB)
📄
print-pgm.c
(22.17 KB)
📄
print-pim.c
(32.59 KB)
📄
print-pktap.c
(5.18 KB)
📄
print-ppi.c
(2.68 KB)
📄
print-ppp.c
(46.16 KB)
📄
print-pppoe.c
(5.65 KB)
📄
print-pptp.c
(25.9 KB)
📄
print-radius.c
(35.1 KB)
📄
print-raw.c
(1.52 KB)
📄
print-resp.c
(16.5 KB)
📄
print-rip.c
(9.19 KB)
📄
print-ripng.c
(6 KB)
📄
print-rpki-rtr.c
(10.83 KB)
📄
print-rrcp.c
(4.56 KB)
📄
print-rsvp.c
(78.61 KB)
📄
print-rt6.c
(2.66 KB)
📄
print-rtsp.c
(1.16 KB)
📄
print-rx.c
(66.92 KB)
📄
print-sctp.c
(23.13 KB)
📄
print-sflow.c
(31.91 KB)
📄
print-sip.c
(1.29 KB)
📄
print-sl.c
(6.95 KB)
📄
print-sll.c
(9.2 KB)
📄
print-slow.c
(25.17 KB)
📄
print-smb.c
(43.19 KB)
📄
print-smtp.c
(983 B)
📄
print-snmp.c
(43.17 KB)
📄
print-stp.c
(17.18 KB)
📄
print-sunatm.c
(3.27 KB)
📄
print-sunrpc.c
(7.85 KB)
📄
print-symantec.c
(3.78 KB)
📄
print-syslog.c
(3.96 KB)
📄
print-tcp.c
(35.84 KB)
📄
print-telnet.c
(15.02 KB)
📄
print-tftp.c
(5.2 KB)
📄
print-timed.c
(4.74 KB)
📄
print-tipc.c
(11.53 KB)
📄
print-token.c
(7.96 KB)
📄
print-udld.c
(5.47 KB)
📄
print-udp.c
(21.28 KB)
📄
print-usb.c
(4.18 KB)
📄
print-vjc.c
(4.45 KB)
📄
print-vqp.c
(6.8 KB)
📄
print-vrrp.c
(6.37 KB)
📄
print-vtp.c
(13.56 KB)
📄
print-vxlan-gpe.c
(3.46 KB)
📄
print-vxlan.c
(2.21 KB)
📄
print-wb.c
(10.93 KB)
📄
print-zephyr.c
(8.03 KB)
📄
print-zeromq.c
(7.5 KB)
📄
print.c
(11.54 KB)
📄
print.h
(1.78 KB)
📄
rpc_auth.h
(2.77 KB)
📄
rpc_msg.h
(3.19 KB)
📄
rpl.h
(4.88 KB)
📄
send-ack.awk
(1.56 KB)
📄
setsignal.c
(3.27 KB)
📄
setsignal.h
(1.24 KB)
📄
signature.c
(5.58 KB)
📄
signature.h
(1.12 KB)
📄
slcompress.h
(3.55 KB)
📄
smb.h
(5.38 KB)
📄
smbutil.c
(63.88 KB)
📄
stime.awk
(567 B)
📄
strtoaddr.c
(5.34 KB)
📄
strtoaddr.h
(992 B)
📄
tcp.h
(5.02 KB)
📄
tcpdump.1.in
(60.82 KB)
📄
tcpdump.c
(69.76 KB)
📄
timeval-operations.h
(3.19 KB)
📄
udp.h
(8.25 KB)
📄
util-print.c
(23.75 KB)
📄
vfprintf.c
(1.62 KB)
Editing: print-stp.c
/* * 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 * * Contributed by Lennert Buytenhek <buytenh@gnu.org> */ /* \summary: IEEE 802.1d Spanning Tree Protocol (STP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <netdissect-stdinc.h> #include <stdio.h> #include "netdissect.h" #include "extract.h" #define RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2) /* STP timers are expressed in multiples of 1/256th second */ #define STP_TIME_BASE 256 #define STP_BPDU_MSTP_MIN_LEN 102 struct stp_bpdu_ { uint8_t protocol_id[2]; uint8_t protocol_version; uint8_t bpdu_type; uint8_t flags; uint8_t root_id[8]; uint8_t root_path_cost[4]; uint8_t bridge_id[8]; uint8_t port_id[2]; uint8_t message_age[2]; uint8_t max_age[2]; uint8_t hello_time[2]; uint8_t forward_delay[2]; uint8_t v1_length; }; #define STP_PROTO_REGULAR 0x00 #define STP_PROTO_RAPID 0x02 #define STP_PROTO_MSTP 0x03 #define STP_PROTO_SPB 0x04 static const struct tok stp_proto_values[] = { { STP_PROTO_REGULAR, "802.1d" }, { STP_PROTO_RAPID, "802.1w" }, { STP_PROTO_MSTP, "802.1s" }, { STP_PROTO_SPB, "802.1aq" }, { 0, NULL} }; #define STP_BPDU_TYPE_CONFIG 0x00 #define STP_BPDU_TYPE_RSTP 0x02 #define STP_BPDU_TYPE_TOPO_CHANGE 0x80 static const struct tok stp_bpdu_flag_values[] = { { 0x01, "Topology change" }, { 0x02, "Proposal" }, { 0x10, "Learn" }, { 0x20, "Forward" }, { 0x40, "Agreement" }, { 0x80, "Topology change ACK" }, { 0, NULL} }; static const struct tok stp_bpdu_type_values[] = { { STP_BPDU_TYPE_CONFIG, "Config" }, { STP_BPDU_TYPE_RSTP, "Rapid STP" }, { STP_BPDU_TYPE_TOPO_CHANGE, "Topology Change" }, { 0, NULL} }; static const struct tok rstp_obj_port_role_values[] = { { 0x00, "Unknown" }, { 0x01, "Alternate" }, { 0x02, "Root" }, { 0x03, "Designated" }, { 0, NULL} }; #define ND_TCHECK_BRIDGE_ID(p) ND_TCHECK2(*(p), 8) static char * stp_print_bridge_id(const u_char *p) { static char bridge_id_str[sizeof("pppp.aa:bb:cc:dd:ee:ff")]; snprintf(bridge_id_str, sizeof(bridge_id_str), "%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); return bridge_id_str; } static int stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, u_int length) { ND_TCHECK(stp_bpdu->flags); ND_PRINT((ndo, ", Flags [%s]", bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags))); ND_TCHECK(stp_bpdu->port_id); ND_PRINT((ndo, ", bridge-id %s.%04x, length %u", stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id), EXTRACT_16BITS(&stp_bpdu->port_id), length)); /* in non-verbose mode just print the bridge-id */ if (!ndo->ndo_vflag) { return 1; } ND_TCHECK(stp_bpdu->forward_delay); ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs" ", hello-time %.2fs, forwarding-delay %.2fs", (float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE, (float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE, (float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE, (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE)); ND_PRINT((ndo, "\n\troot-id %s, root-pathcost %u", stp_print_bridge_id((const u_char *)&stp_bpdu->root_id), EXTRACT_32BITS(&stp_bpdu->root_path_cost))); /* Port role is only valid for 802.1w */ if (stp_bpdu->protocol_version == STP_PROTO_RAPID) { ND_PRINT((ndo, ", port-role %s", tok2str(rstp_obj_port_role_values, "Unknown", RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)))); } return 1; trunc: return 0; } /* * MSTP packet format * Ref. IEEE 802.1Q 2003 Ed. Section 14 * * MSTP BPDU * * 2 - bytes Protocol Id * 1 - byte Protocol Ver. * 1 - byte BPDU tye * 1 - byte Flags * 8 - bytes CIST Root Identifier * 4 - bytes CIST External Path Cost * 8 - bytes CIST Regional Root Identifier * 2 - bytes CIST Port Identifier * 2 - bytes Message Age * 2 - bytes Max age * 2 - bytes Hello Time * 2 - bytes Forward delay * 1 - byte Version 1 length. Must be 0 * 2 - bytes Version 3 length * 1 - byte Config Identifier * 32 - bytes Config Name * 2 - bytes Revision level * 16 - bytes Config Digest [MD5] * 4 - bytes CIST Internal Root Path Cost * 8 - bytes CIST Bridge Identifier * 1 - byte CIST Remaining Hops * 16 - bytes MSTI information [Max 64 MSTI, each 16 bytes] * * * SPB BPDU * Ref. IEEE 802.1aq. Section 14 * * 2 - bytes Version 4 length * 1 - byte Aux Config Identifier * 32 - bytes Aux Config Name * 2 - bytes Aux Revision level * 16 - bytes Aux Config Digest [MD5] * 1 - byte (1 - 2) Agreement Number * (3 - 4) Discarded Agreement Number * (5) Agreement Valid Flag * (6) Restricted Role Flag * (7 - 8) Unused sent zero * 1 - byte Unused * 1 - byte (1 - 4) Agreement Digest Format Identifier * (5 - 8) Agreement Digest Format Capabilities * 1 - byte (1 - 4) Agreement Digest Convention Identifier * (5 - 8) Agreement Digest Convention Capabilities * 2 - bytes Agreement Digest Edge Count * 8 - byte Reserved Set * 20 - bytes Computed Topology Digest * * * MSTI Payload * * 1 - byte MSTI flag * 8 - bytes MSTI Regional Root Identifier * 4 - bytes MSTI Regional Path Cost * 1 - byte MSTI Bridge Priority * 1 - byte MSTI Port Priority * 1 - byte MSTI Remaining Hops * */ #define MST_BPDU_MSTI_LENGTH 16 #define MST_BPDU_CONFIG_INFO_LENGTH 64 /* Offsets of fields from the begginning for the packet */ #define MST_BPDU_VER3_LEN_OFFSET 36 #define MST_BPDU_CONFIG_NAME_OFFSET 39 #define MST_BPDU_CONFIG_DIGEST_OFFSET 73 #define MST_BPDU_CIST_INT_PATH_COST_OFFSET 89 #define MST_BPDU_CIST_BRIDGE_ID_OFFSET 93 #define MST_BPDU_CIST_REMAIN_HOPS_OFFSET 101 #define MST_BPDU_MSTI_OFFSET 102 /* Offsets within an MSTI */ #define MST_BPDU_MSTI_ROOT_PRIO_OFFSET 1 #define MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET 9 #define MST_BPDU_MSTI_BRIDGE_PRIO_OFFSET 13 #define MST_BPDU_MSTI_PORT_PRIO_OFFSET 14 #define MST_BPDU_MSTI_REMAIN_HOPS_OFFSET 15 #define SPB_BPDU_MIN_LEN 87 #define SPB_BPDU_CONFIG_NAME_OFFSET 3 #define SPB_BPDU_CONFIG_REV_OFFSET SPB_BPDU_CONFIG_NAME_OFFSET + 32 #define SPB_BPDU_CONFIG_DIGEST_OFFSET SPB_BPDU_CONFIG_REV_OFFSET + 2 #define SPB_BPDU_AGREEMENT_OFFSET SPB_BPDU_CONFIG_DIGEST_OFFSET + 16 #define SPB_BPDU_AGREEMENT_UNUSED_OFFSET SPB_BPDU_AGREEMENT_OFFSET + 1 #define SPB_BPDU_AGREEMENT_FORMAT_OFFSET SPB_BPDU_AGREEMENT_UNUSED_OFFSET + 1 #define SPB_BPDU_AGREEMENT_CON_OFFSET SPB_BPDU_AGREEMENT_FORMAT_OFFSET + 1 #define SPB_BPDU_AGREEMENT_EDGE_OFFSET SPB_BPDU_AGREEMENT_CON_OFFSET + 1 #define SPB_BPDU_AGREEMENT_RES1_OFFSET SPB_BPDU_AGREEMENT_EDGE_OFFSET + 2 #define SPB_BPDU_AGREEMENT_RES2_OFFSET SPB_BPDU_AGREEMENT_RES1_OFFSET + 4 #define SPB_BPDU_AGREEMENT_DIGEST_OFFSET SPB_BPDU_AGREEMENT_RES2_OFFSET + 4 static int stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, u_int length) { const u_char *ptr; uint16_t v3len; uint16_t len; uint16_t msti; u_int offset; ptr = (const u_char *)stp_bpdu; ND_PRINT((ndo, ", CIST Flags [%s], length %u", bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags), length)); /* * in non-verbose mode just print the flags. */ if (!ndo->ndo_vflag) { return 1; } ND_TCHECK(stp_bpdu->flags); ND_PRINT((ndo, "\n\tport-role %s, ", tok2str(rstp_obj_port_role_values, "Unknown", RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)))); ND_TCHECK(stp_bpdu->root_path_cost); ND_PRINT((ndo, "CIST root-id %s, CIST ext-pathcost %u", stp_print_bridge_id((const u_char *)&stp_bpdu->root_id), EXTRACT_32BITS(&stp_bpdu->root_path_cost))); ND_TCHECK(stp_bpdu->bridge_id); ND_PRINT((ndo, "\n\tCIST regional-root-id %s, ", stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id))); ND_TCHECK(stp_bpdu->port_id); ND_PRINT((ndo, "CIST port-id %04x,", EXTRACT_16BITS(&stp_bpdu->port_id))); ND_TCHECK(stp_bpdu->forward_delay); ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs" ", hello-time %.2fs, forwarding-delay %.2fs", (float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE, (float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE, (float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE, (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE)); ND_TCHECK_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET); ND_PRINT((ndo, "\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET))); ND_TCHECK_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12); ND_PRINT((ndo, "MCID Name ")); if (fn_printzp(ndo, ptr + MST_BPDU_CONFIG_NAME_OFFSET, 32, ndo->ndo_snapend)) goto trunc; ND_PRINT((ndo, ", rev %u," "\n\t\tdigest %08x%08x%08x%08x, ", EXTRACT_16BITS(ptr + MST_BPDU_CONFIG_NAME_OFFSET + 32), EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET), EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 4), EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 8), EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12))); ND_TCHECK_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET); ND_PRINT((ndo, "CIST int-root-pathcost %u,", EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET))); ND_TCHECK_BRIDGE_ID(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET); ND_PRINT((ndo, "\n\tCIST bridge-id %s, ", stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET))); ND_TCHECK(ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]); ND_PRINT((ndo, "CIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET])); /* Dump all MSTI's */ ND_TCHECK_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET); v3len = EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET); if (v3len > MST_BPDU_CONFIG_INFO_LENGTH) { len = v3len - MST_BPDU_CONFIG_INFO_LENGTH; offset = MST_BPDU_MSTI_OFFSET; while (len >= MST_BPDU_MSTI_LENGTH) { ND_TCHECK2(*(ptr + offset), MST_BPDU_MSTI_LENGTH); msti = EXTRACT_16BITS(ptr + offset + MST_BPDU_MSTI_ROOT_PRIO_OFFSET); msti = msti & 0x0FFF; ND_PRINT((ndo, "\n\tMSTI %d, Flags [%s], port-role %s", msti, bittok2str(stp_bpdu_flag_values, "none", ptr[offset]), tok2str(rstp_obj_port_role_values, "Unknown", RSTP_EXTRACT_PORT_ROLE(ptr[offset])))); ND_PRINT((ndo, "\n\t\tMSTI regional-root-id %s, pathcost %u", stp_print_bridge_id(ptr + offset + MST_BPDU_MSTI_ROOT_PRIO_OFFSET), EXTRACT_32BITS(ptr + offset + MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET))); ND_PRINT((ndo, "\n\t\tMSTI bridge-prio %d, port-prio %d, hops %d", ptr[offset + MST_BPDU_MSTI_BRIDGE_PRIO_OFFSET] >> 4, ptr[offset + MST_BPDU_MSTI_PORT_PRIO_OFFSET] >> 4, ptr[offset + MST_BPDU_MSTI_REMAIN_HOPS_OFFSET])); len -= MST_BPDU_MSTI_LENGTH; offset += MST_BPDU_MSTI_LENGTH; } } return 1; trunc: return 0; } static int stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, u_int offset) { const u_char *ptr; /* * in non-verbose mode don't print anything. */ if (!ndo->ndo_vflag) { return 1; } ptr = (const u_char *)stp_bpdu; ND_TCHECK_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET + 16); ND_PRINT((ndo, "\n\tv4len %d, ", EXTRACT_16BITS (ptr + offset))); ND_PRINT((ndo, "AUXMCID Name ")); if (fn_printzp(ndo, ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET, 32, ndo->ndo_snapend)) goto trunc; ND_PRINT((ndo, ", Rev %u,\n\t\tdigest %08x%08x%08x%08x", EXTRACT_16BITS(ptr + offset + SPB_BPDU_CONFIG_REV_OFFSET), EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET), EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 4), EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 8), EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12))); ND_PRINT((ndo, "\n\tAgreement num %d, Discarded Agreement num %d, Agreement valid-" "flag %d,\n\tRestricted role-flag: %d, Format id %d cap %d, " "Convention id %d cap %d,\n\tEdge count %d, " "Agreement digest %08x%08x%08x%08x%08x\n", ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6, ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4 & 0x3, ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>3 & 0x1, ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>2 & 0x1, ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]>>4, ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]&0x00ff, ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]>>4, ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]&0x00ff, EXTRACT_16BITS(ptr + offset + SPB_BPDU_AGREEMENT_EDGE_OFFSET), EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET), EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+4), EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+8), EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+12), EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+16))); return 1; trunc: return 0; } /* * Print 802.1d / 802.1w / 802.1q (mstp) / 802.1aq (spb) packets. */ void stp_print(netdissect_options *ndo, const u_char *p, u_int length) { const struct stp_bpdu_ *stp_bpdu; u_int mstp_len; u_int spb_len; stp_bpdu = (const struct stp_bpdu_*)p; /* Minimum STP Frame size. */ if (length < 4) goto trunc; ND_TCHECK(stp_bpdu->protocol_id); if (EXTRACT_16BITS(&stp_bpdu->protocol_id)) { ND_PRINT((ndo, "unknown STP version, length %u", length)); return; } ND_TCHECK(stp_bpdu->protocol_version); ND_PRINT((ndo, "STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)", stp_bpdu->protocol_version))); switch (stp_bpdu->protocol_version) { case STP_PROTO_REGULAR: case STP_PROTO_RAPID: case STP_PROTO_MSTP: case STP_PROTO_SPB: break; default: return; } ND_TCHECK(stp_bpdu->bpdu_type); ND_PRINT((ndo, ", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)", stp_bpdu->bpdu_type))); switch (stp_bpdu->bpdu_type) { case STP_BPDU_TYPE_CONFIG: if (length < sizeof(struct stp_bpdu_) - 1) { goto trunc; } if (!stp_print_config_bpdu(ndo, stp_bpdu, length)) goto trunc; break; case STP_BPDU_TYPE_RSTP: if (stp_bpdu->protocol_version == STP_PROTO_RAPID) { if (length < sizeof(struct stp_bpdu_)) { goto trunc; } if (!stp_print_config_bpdu(ndo, stp_bpdu, length)) goto trunc; } else if (stp_bpdu->protocol_version == STP_PROTO_MSTP || stp_bpdu->protocol_version == STP_PROTO_SPB) { if (length < STP_BPDU_MSTP_MIN_LEN) { goto trunc; } ND_TCHECK(stp_bpdu->v1_length); if (stp_bpdu->v1_length != 0) { /* FIX ME: Emit a message here ? */ goto trunc; } /* Validate v3 length */ ND_TCHECK_16BITS(p + MST_BPDU_VER3_LEN_OFFSET); mstp_len = EXTRACT_16BITS(p + MST_BPDU_VER3_LEN_OFFSET); mstp_len += 2; /* length encoding itself is 2 bytes */ if (length < (sizeof(struct stp_bpdu_) + mstp_len)) { goto trunc; } if (!stp_print_mstp_bpdu(ndo, stp_bpdu, length)) goto trunc; if (stp_bpdu->protocol_version == STP_PROTO_SPB) { /* Validate v4 length */ ND_TCHECK_16BITS(p + MST_BPDU_VER3_LEN_OFFSET + mstp_len); spb_len = EXTRACT_16BITS (p + MST_BPDU_VER3_LEN_OFFSET + mstp_len); spb_len += 2; if (length < (sizeof(struct stp_bpdu_) + mstp_len + spb_len) || spb_len < SPB_BPDU_MIN_LEN) { goto trunc; } if (!stp_print_spb_bpdu(ndo, stp_bpdu, (sizeof(struct stp_bpdu_) + mstp_len))) goto trunc; } } break; case STP_BPDU_TYPE_TOPO_CHANGE: /* always empty message - just break out */ break; default: break; } return; trunc: ND_PRINT((ndo, "[|stp %d]", length)); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 4 * End: */
Upload File
Create Folder