]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-mobile.c
When checking for pcap_if_t, add $V_INCLS to CFLAGS, so we look at the
[tcpdump] / print-mobile.c
index 8d93bbf9cd247a9a636b868da389524ef4deb47b..816ffd6e65859917f76da3960b47629d2557a6c7 100644 (file)
 #endif
 
 #ifndef lint
-static const char rcsid[] =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.6 2001-06-15 22:17:33 fenner Exp $";
+static const char rcsid[] _U_ =
+     "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.15 2004-03-24 01:58:14 guy Exp $";
 #endif
 
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/uio.h>
-#include <sys/socket.h>
+#include <tcpdump-stdinc.h>
 
-#include <netinet/in.h>
-
-#include <netdb.h>
 #include <stdio.h>
 
 #include "interface.h"
@@ -70,8 +64,6 @@ struct mobile_ip {
 
 #define OSRC_PRES      0x0080  /* old source is present */
 
-static u_int16_t mob_in_cksum(u_short *p, int len);
-
 /*
  * Deencapsulate and print a mobile-tunneled IP datagram
  */
@@ -85,7 +77,7 @@ mobile_print(const u_char *bp, u_int length)
 
        mob = (const struct mobile_ip *)bp;
 
-       if (length < MOBILE_SIZE) {
+       if (length < MOBILE_SIZE || !TTEST(*mob)) {
                fputs("[|mobile]", stdout);
                return;
        }
@@ -97,7 +89,7 @@ mobile_print(const u_char *bp, u_int length)
                osp=1;
                cp +=4 ;
        }
-       
+
        if (osp)  {
                fputs("[S] ",stdout);
                if (vflag)
@@ -109,34 +101,9 @@ mobile_print(const u_char *bp, u_int length)
                (void)printf("> %s ",ipaddr_string(&mob->odst));
                (void)printf("(oproto=%d)",proto>>8);
        }
-       if (mob_in_cksum((u_short *)mob, osp ? 12 : 8)!=0) {
+       if (in_cksum((u_short *)mob, osp ? 12 : 8, 0)!=0) {
                (void)printf(" (bad checksum %d)",crc);
        }
 
        return;
 }
-
-static u_int16_t mob_in_cksum(u_short *p, int len)
-{
-       u_int32_t sum = 0; 
-       int nwords = len >> 1;
-  
-       while (nwords-- != 0)
-               sum += *p++;
-  
-       if (len & 1) {
-               union {
-                       u_int16_t w;
-                       u_int8_t c[2]; 
-               } u;
-               u.c[0] = *(u_char *)p;
-               u.c[1] = 0;
-               sum += u.w;
-       } 
-
-       /* end-around-carry */
-       sum = (sum >> 16) + (sum & 0xffff);
-       sum += (sum >> 16);
-       return (~sum);
-}
-