diff options
author | lile <lile@FreeBSD.org> | 1999-08-28 15:14:15 +0000 |
---|---|---|
committer | lile <lile@FreeBSD.org> | 1999-08-28 15:14:15 +0000 |
commit | 9fd13149fc506d1eb6472d76b7fdfb600bf67762 (patch) | |
tree | 2b6e1a00dfea7773f4e093201146482fca996035 | |
parent | e696937c355e73a4790a8a1ba34595e8cf562414 (diff) | |
download | FreeBSD-src-9fd13149fc506d1eb6472d76b7fdfb600bf67762.zip FreeBSD-src-9fd13149fc506d1eb6472d76b7fdfb600bf67762.tar.gz |
Add source routing support.
-rw-r--r-- | contrib/tcpdump/print-token.c | 38 | ||||
-rw-r--r-- | contrib/tcpdump/token.h | 22 |
2 files changed, 49 insertions, 11 deletions
diff --git a/contrib/tcpdump/print-token.c b/contrib/tcpdump/print-token.c index e1dff5b..fed384f 100644 --- a/contrib/tcpdump/print-token.c +++ b/contrib/tcpdump/print-token.c @@ -22,7 +22,7 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header$"; + "@(#) $Header: /home/ncvs/src/contrib/tcpdump/print-token.c,v 1.1 1999/02/20 11:17:55 julian Exp $"; #endif #include <sys/param.h> @@ -67,8 +67,11 @@ token_print(register const u_char *bp, u_int length) tp = (const struct token_header *)bp; lp = (struct llc *)(bp + TOKEN_HDR_LEN); - if (IS_SOURCE_ROUTED) + + if (IS_SOURCE_ROUTED) { + tp->ether_shost[0] = tp->ether_shost[0] & 0x7f; lp = (struct llc *)(bp + TOKEN_HDR_LEN + RIF_LENGTH); + } /* * Ethertype on ethernet is a short, but ethertype in an llc-snap has @@ -105,7 +108,7 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) struct token_header *tp; u_short ether_type; extern u_short extracted_ethertype; - u_int route_len = 0; + u_int route_len = 0, seg; struct llc *lp; tp = (struct token_header *)p; @@ -117,9 +120,6 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) goto out; } - if (eflag) - token_print(p, length); - /* * Some printers want to get back at the ethernet addresses, * and/or check that they're not walking off the end of the packet. @@ -129,7 +129,31 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) /* Adjust for source routing information in the MAC header */ if (IS_SOURCE_ROUTED) { + + if (eflag) + token_print(p, length); + route_len = RIF_LENGTH; + if (vflag) { + if (vflag > 1) + printf("ac %x fc %x ", tp->ac, tp->fc); + ether_type = ntohs((int)lp->ethertype); + + printf("%s ", broadcast_indicator[BROADCAST]); + printf("%s", direction[DIRECTION]); + + for (seg = 0; seg < SEGMENT_COUNT; seg++) + printf(" [%d:%d]", RING_NUMBER(seg), BRIDGE_NUMBER(seg)); + } else { + printf("rt = %x", ntohs(tp->rcf)); + + for (seg = 0; seg < SEGMENT_COUNT; seg++) + printf(":%x", ntohs(tp->rseg[seg])); + } + printf(" (%s) ", largest_frame[LARGEST_FRAME]); + } else { + if (eflag) + token_print(p, length); } /* Set pointer to llc header, adjusted for routing information */ @@ -143,8 +167,6 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) caplen -= TOKEN_HDR_LEN + route_len; p += TOKEN_HDR_LEN + route_len; - ether_type = ntohs((int)lp->ethertype); - extracted_ethertype = 0; /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(tp), EDST(tp)) == 0) { diff --git a/contrib/tcpdump/token.h b/contrib/tcpdump/token.h index 6f28a1e..98d2c59 100644 --- a/contrib/tcpdump/token.h +++ b/contrib/tcpdump/token.h @@ -27,10 +27,27 @@ */ #define TOKEN_HDR_LEN 14 -#define IS_SOURCE_ROUTED (tp->ether_shost[0] & 0x80) -#define RIF_LENGTH ((ntohs(tp->rcf) & 0x1f00) >> 8) #define TOKEN_RING_MAC_LEN 6 #define ROUTING_SEGMENT_MAX 16 +#define IS_SOURCE_ROUTED (tp->ether_shost[0] & 0x80) +#define BROADCAST ((ntohs(tp->rcf) & 0xE000) >> 13) +#define RIF_LENGTH ((ntohs(tp->rcf) & 0x1f00) >> 8) +#define DIRECTION ((ntohs(tp->rcf) & 0x0080) >> 7) +#define LARGEST_FRAME ((ntohs(tp->rcf) & 0x0070) >> 4) +#define RING_NUMBER(x) ((ntohs(tp->rseg[x]) & 0xfff0) >> 4) +#define BRIDGE_NUMBER(x) ((ntohs(tp->rseg[x]) & 0x000f)) +#define SEGMENT_COUNT ((RIF_LENGTH - 2) / 2) + +char *broadcast_indicator[] = { "Non-Broadcast", "Non-Broadcast", + "Non-Broadcast", "Non-Broadcast", + "All-routes", "All-routes", + "Single-route", "Single-route"}; + +char *direction[] = { "Forward", "Backward"}; + +char *largest_frame[] = { "516", "1500", "2052", "4472", "8144", + "11407", "17800", ""}; + struct token_header { u_char ac; @@ -40,4 +57,3 @@ struct token_header { u_short rcf; u_short rseg[ROUTING_SEGMENT_MAX]; }; - |