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-pim.c b/print-pim.c
index 39c4e4d..7136083 100644
--- a/print-pim.c
+++ b/print-pim.c
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45.2.4 2006/02/13 01:32:34 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.49 2006-02-13 01:31:35 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -29,7 +29,15 @@
 #endif
 
 #include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
 #include "interface.h"
+#include "addrtoname.h"
+#include "extract.h"
+
+#include "ip.h"
 
 #define PIMV2_TYPE_HELLO         0
 #define PIMV2_TYPE_REGISTER      1
@@ -42,7 +50,7 @@
 #define PIMV2_TYPE_CANDIDATE_RP  8
 #define PIMV2_TYPE_PRUNE_REFRESH 9
 
-static struct tok pimv2_type_values[] = {
+static const struct tok pimv2_type_values[] = {
     { PIMV2_TYPE_HELLO,         "Hello" },
     { PIMV2_TYPE_REGISTER,      "Register" },
     { PIMV2_TYPE_REGISTER_STOP, "Register Stop" },
@@ -66,7 +74,7 @@
 #define PIMV2_HELLO_OPTION_ADDRESS_LIST        24
 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
 
-static struct tok pimv2_hello_option_values[] = {
+static const struct tok pimv2_hello_option_values[] = {
     { PIMV2_HELLO_OPTION_HOLDTIME,         "Hold Time" },
     { PIMV2_HELLO_OPTION_LANPRUNEDELAY,    "LAN Prune Delay" },
     { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD,  "DR Priority (Old)" },
@@ -83,7 +91,7 @@
 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
 #define PIMV2_REGISTER_FLAG_NULL   0x40000000
 
-static struct tok pimv2_register_flag_values[] = {
+static const struct tok pimv2_register_flag_values[] = {
     { PIMV2_REGISTER_FLAG_BORDER, "Border" },
     { PIMV2_REGISTER_FLAG_NULL, "Null" },
     { 0, NULL}
@@ -108,22 +116,12 @@
 	u_short	pim_cksum;	/* IP style check sum */
 };
 
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "interface.h"
-#include "addrtoname.h"
-#include "extract.h"
-
-#include "ip.h"
-
-static void pimv2_print(register const u_char *bp, register u_int len);
+static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
 
 static void
 pimv1_join_prune_print(register const u_char *bp, register u_int len)
 {
-	int maddrlen, addrlen, ngroups, njoin, nprune;
+	int ngroups, njoin, nprune;
 	int njp;
 
 	/* If it's a single group and a single source, use 1-line output. */
@@ -164,8 +162,6 @@
 	len -= 8;
 
 	TCHECK2(bp[0], 4);
-	maddrlen = bp[1];
-	addrlen = bp[2];
 	ngroups = bp[3];
 	bp += 4;
 	len -= 4;
@@ -399,8 +395,12 @@
 			TCHECK2(bp[0], 6);
 			(void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
 			    ipaddr_string(&bp[2]), bp[1]);
-			if (bp[0] & 0xfe)
-				(void)printf("[rsvd=0x%02x]", bp[0] & 0xfe);
+			if (bp[0] & 0x02) {
+			    (void)printf(" bidir");
+			}
+			if (bp[0] & 0xfc) {
+			    (void)printf("[rsvd=0x%02x]", bp[0] & 0xfc);
+			}
 			s = ',';
 			bp += 6; len -= 6;
 		}
@@ -413,7 +413,7 @@
 }
 
 void
-pim_print(register const u_char *bp, register u_int len)
+pim_print(register const u_char *bp, register u_int len, u_int cksum)
 {
 	register const u_char *ep;
 	register struct pim *pim = (struct pim *)bp;
@@ -438,7 +438,7 @@
                        PIM_VER(pim->pim_typever),
                        len,
                        tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
-                pimv2_print(bp, len);
+                pimv2_print(bp, len, cksum);
             }
             break;
 	default:
@@ -618,7 +618,7 @@
 }
 
 static void
-pimv2_print(register const u_char *bp, register u_int len)
+pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
 {
 	register const u_char *ep;
 	register struct pim *pim = (struct pim *)bp;
@@ -638,9 +638,7 @@
         if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
                 printf("(unverified)");
         } else {
-                printf("(%scorrect)",
-                       TTEST2(bp[0], len) &&
-                       in_cksum((const u_short*)bp, len, 0) ? "in" : "" );
+                printf("(%scorrect)", TTEST2(bp[0], len) && cksum ? "in" : "" );
         }
 
 	switch (PIM_TYPE(pim->pim_typever)) {
@@ -667,7 +665,7 @@
 
 			case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
 				if (olen != 4) {
-					(void)printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
+					(void)printf("ERROR: Option Length != 4 Bytes (%u)", olen);
 				} else {
 					char t_bit;
 					u_int16_t lan_delay, override_interval;
@@ -690,7 +688,7 @@
                                     printf("%u", EXTRACT_32BITS(bp));
                                     break;
                                 default:
-                                    printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
+                                    printf("ERROR: Option Length != 4 Bytes (%u)", olen);
                                     break;
                                 }
                                 break;
@@ -770,7 +768,7 @@
 			break;
 #ifdef INET6
 		case 6:	/* IPv6 */
-			ip6_print(bp, len);
+			ip6_print(gndo, bp, len);
 			break;
 #endif
                 default: