X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/c9d84d15c5c4dc8eca7594101fe5026080ed641e..ad6df73f5a6c46a409c7629f5588b1b81dff6357:/print-mobile.c diff --git a/print-mobile.c b/print-mobile.c index 4cbbc918..e767beb3 100644 --- a/print-mobile.c +++ b/print-mobile.c @@ -36,21 +36,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if 0 -#include -#ifndef lint -__RCSID("$NetBSD: print-mobile.c,v 1.2 1998/09/30 08:57:01 hwr Exp $"); +#ifdef HAVE_CONFIG_H +#include "config.h" #endif + +#ifndef lint +static const char rcsid[] = + "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.8 2002-06-01 23:50:32 guy Exp $"; #endif #include #include -#include #include #include -#include -#include #include #include @@ -70,8 +69,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 */ @@ -89,6 +86,7 @@ mobile_print(const u_char *bp, u_int length) fputs("[|mobile]", stdout); return; } + fputs("mobile: ", stdout); proto = EXTRACT_16BITS(&mob->proto); crc = EXTRACT_16BITS(&mob->hcheck); @@ -108,34 +106,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); -} -