Merge remote-tracking branch 'goog/tcpdump'

* goog/tcpdump: (3066 commits)
  Remove old version. Getting ready for new tcpdump 4.5
  Support -Q for setting the capture direction.
  Clean up the TLV processing loop.
  With -A and -AA, don't send CRs to the standard output.
  Use the new libpcap <pcap/nflog.h> for NFLOG definitions and declarations.
  Do our own isascii(), isprint(), isgraph(), and toascii().
  Fix a compiler warning.
  Don't use the __attribute__((packed)) on most platforms.
  The interval in an AODV HELLO extension is not aligned on a 4-byte boundary.
  As with memcpy, so with memcmp.
  More UNALIGNED_MEM{CPY,CMP} on IP addresses.
  Another case where UNALIGNED_MEMCPY() is probably necessary.
  No need for casting back and forth.
  Only do the unaligned_mem{cpy,cmp} hack if necessary.
  No need to declare unaligned_mem{cpy,cmp} in netdissect.h *and* interface.h.
  More possibly-unaligned memcpy()s and assignments - use unaligned_memcpy().
  Check for compiling for IPv6; don't check whether we can create an IPv6 socket.
  Use unaligned_memcmp() to compare with IPv{4,6} addresses in a packet.
  Use EXTRACT_nBITS even when just testing against zero.
  Fix some more unaligned accesses.
  ...

Change-Id: I9e98707d30c989b9e32dcd5af798bd0746ab4434
diff --git a/print-token.c b/print-token.c
index 47fcca6..4f8422b 100644
--- a/print-token.c
+++ b/print-token.c
@@ -25,7 +25,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.25.2.2 2005/11/13 12:13:01 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.27 2005-11-13 12:12:43 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -39,6 +39,7 @@
 #include <string.h>
 
 #include "interface.h"
+#include "extract.h"
 #include "addrtoname.h"
 #include "ethertype.h"
 
@@ -126,7 +127,16 @@
 		if (eflag)
 			token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
 
+		if (caplen < TOKEN_HDRLEN + 2) {
+			printf("[|token-ring]");
+			return hdr_len;
+		}
 		route_len = RIF_LENGTH(trp);
+		hdr_len += route_len;
+		if (caplen < hdr_len) {
+			printf("[|token-ring]");
+			return hdr_len;
+		}
 		if (vflag) {
 			printf("%s ", broadcast_indicator[BROADCAST(trp)]);
 			printf("%s", direction[DIRECTION(trp)]);
@@ -135,10 +145,10 @@
 				printf(" [%d:%d]", RING_NUMBER(trp, seg),
 				    BRIDGE_NUMBER(trp, seg));
 		} else {
-			printf("rt = %x", ntohs(trp->token_rcf));
+			printf("rt = %x", EXTRACT_16BITS(&trp->token_rcf));
 
 			for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
-				printf(":%x", ntohs(trp->token_rseg[seg]));
+				printf(":%x", EXTRACT_16BITS(&trp->token_rseg[seg]));
 		}
 		printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
 	} else {
@@ -147,7 +157,6 @@
 	}
 
 	/* Skip over token ring MAC header and routing information */
-	hdr_len += route_len;
 	length -= hdr_len;
 	p += hdr_len;
 	caplen -= hdr_len;