From b8037ee9610ca42e2f6a9f4f71ccaa45f058475f Mon Sep 17 00:00:00 2001 From: itojun Date: Sat, 30 Oct 1999 07:36:34 +0000 Subject: [PATCH] - enable build outside of the tree - endian checks (use WORDS_BIGENDIAN) - fallback def for IPPROTO_{AH,ESP} - sa_len issues - do not use bittypes.h, respect AC_LBL_CHECK_TYPES --- Makefile.in | 4 +++- aclocal.m4 | 13 ++++++++++--- isakmp.h | 10 +++++----- missing/getaddrinfo.c | 2 ++ print-ip.c | 8 +++++++- print-isakmp.c | 14 +++++++++++++- print-pim.c | 4 ++-- tcpdump.c | 4 ++-- 8 files changed, 44 insertions(+), 15 deletions(-) diff --git a/Makefile.in b/Makefile.in index 8cadccf1..228f0820 100644 --- a/Makefile.in +++ b/Makefile.in @@ -17,7 +17,7 @@ # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # -# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.210 1999-10-30 05:11:06 itojun Exp $ (LBL) +# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.211 1999-10-30 07:36:34 itojun Exp $ (LBL) # # Various configurable paths (remember to edit Makefile.in, not Makefile) @@ -118,6 +118,8 @@ getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getaddrinfo.c version.o: version.c + $(CC) $(CFLAGS) -c version.c + version.c: $(srcdir)/VERSION @rm -f $@ sed -e 's/.*/char version[] = "&";/' $(srcdir)/VERSION > $@ diff --git a/aclocal.m4 b/aclocal.m4 index baec00c9..ff49c848 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.65 1999-10-30 05:11:06 itojun Exp $ (LBL) +dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.66 1999-10-30 07:36:35 itojun Exp $ (LBL) dnl dnl Copyright (c) 1995, 1996, 1997, 1998 dnl The Regents of the University of California. All rights reserved. @@ -51,7 +51,7 @@ AC_DEFUN(AC_LBL_C_INIT, $1="-O" $2="" if test "${srcdir}" != "." ; then - $2="-I\$\(srcdir\)" + $2="-I\$(srcdir)" fi if test "${CFLAGS+set}" = set; then LBL_CFLAGS="$CFLAGS" @@ -200,7 +200,7 @@ AC_DEFUN(AC_LBL_LIBPCAP, continue; fi lastdir=$dir - if test -r $dir/pcap.c ; then + if test -r $dir/libpcap.a ; then libpcap=$dir/libpcap.a d=$dir dnl continue and select the last one that exists @@ -214,7 +214,13 @@ AC_DEFUN(AC_LBL_LIBPCAP, fi else $1=$libpcap + if test -r $d/pcap.h; then $2="-I$d $$2" + elif test -r $srcdir/../libpcap/pcap.h; then + $2="-I$d -I$srcdir/../libpcap $$2" + else + AC_MSG_ERROR(cannot find pcap.h, see INSTALL) + fi AC_MSG_RESULT($libpcap) fi LIBS="$libpcap $LIBS" @@ -920,6 +926,7 @@ AC_DEFUN(AC_CHECK_AAAA, [ AC_MSG_CHECKING(for AAAA) AC_CACHE_VAL($1, AC_TRY_COMPILE([ +# include # include ], [int a = T_AAAA], $1=yes, diff --git a/isakmp.h b/isakmp.h index 1820b125..b989a233 100644 --- a/isakmp.h +++ b/isakmp.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* YIPS @(#)$Id: isakmp.h,v 1.1 1999-10-30 05:11:09 itojun Exp $ */ +/* YIPS @(#)$Id: isakmp.h,v 1.2 1999-10-30 07:36:36 itojun Exp $ */ /* refer to RFC 2408 */ @@ -101,12 +101,12 @@ struct isakmp { cookie_t i_ck; /* Initiator Cookie */ cookie_t r_ck; /* Responder Cookie */ u_int8_t np; /* Next Payload Type */ -#if BYTE_ORDER == LITTLE_ENDIAN - u_int8_t v_min:4, /* MnVer */ - v_maj:4; /* MjVer */ -#else +#if defined(WORDS_BIGENDIAN) || (defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)) u_int8_t v_maj:4, /* MnVer */ v_min:4; /* MjVer */ +#else + u_int8_t v_min:4, /* MnVer */ + v_maj:4; /* MjVer */ #endif u_int8_t etype; /* Exchange Type */ u_int8_t flags; /* Flags */ diff --git a/missing/getaddrinfo.c b/missing/getaddrinfo.c index 9da09cbb..59568c2c 100644 --- a/missing/getaddrinfo.c +++ b/missing/getaddrinfo.c @@ -65,9 +65,11 @@ #include "cdecl_ext.h" #endif +#if 0 #ifndef HAVE_U_INT32_T #include "bittypes.h" #endif +#endif #ifndef HAVE_SOCKADDR_STORAGE #include "sockstorage.h" diff --git a/print-ip.c b/print-ip.c index 93b64388..625095b6 100644 --- a/print-ip.c +++ b/print-ip.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.71 1999-10-30 05:30:20 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.72 1999-10-30 07:36:37 itojun Exp $ (LBL)"; #endif #include @@ -400,6 +400,9 @@ ip_print(register const u_char *bp, register u_int length) again: switch (nh) { +#ifndef IPPROTO_AH +#define IPPROTO_AH 51 +#endif case IPPROTO_AH: nh = *cp; advance = ah_print(cp, (const u_char *)ip); @@ -407,6 +410,9 @@ again: len -= advance; goto again; +#ifndef IPPROTO_ESP +#define IPPROTO_ESP 50 +#endif case IPPROTO_ESP: { int enh; diff --git a/print-isakmp.c b/print-isakmp.c index f82ae0ab..7acf8940 100644 --- a/print-isakmp.c +++ b/print-isakmp.c @@ -30,7 +30,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.5 1999-10-30 05:37:35 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.6 1999-10-30 07:36:37 itojun Exp $ (LBL)"; #endif #include @@ -206,11 +206,15 @@ cookie_record(cookie_t *in, const u_char *bp2) sizeof(cookiecache[ninitiator].raddr)); sin = (struct sockaddr_in *)&cookiecache[ninitiator].iaddr; +#ifdef HAVE_SOCKADDR_SA_LEN sin->sin_len = sizeof(struct sockaddr_in); +#endif sin->sin_family = AF_INET; memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src)); sin = (struct sockaddr_in *)&cookiecache[ninitiator].raddr; +#ifdef HAVE_SOCKADDR_SA_LEN sin->sin_len = sizeof(struct sockaddr_in); +#endif sin->sin_family = AF_INET; memcpy(&sin->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst)); break; @@ -223,11 +227,15 @@ cookie_record(cookie_t *in, const u_char *bp2) ip6 = (struct ip6_hdr *)bp2; sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].iaddr; +#ifdef HAVE_SOCKADDR_SA_LEN sin6->sin6_len = sizeof(struct sockaddr_in6); +#endif sin6->sin6_family = AF_INET6; memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src)); sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].raddr; +#ifdef HAVE_SOCKADDR_SA_LEN sin6->sin6_len = sizeof(struct sockaddr_in6); +#endif sin6->sin6_family = AF_INET6; memcpy(&sin6->sin6_addr, &ip6->ip6_dst, sizeof(ip6->ip6_dst)); break; @@ -259,7 +267,9 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator) switch (ip->ip_v) { case 4: sin = (struct sockaddr_in *)&ss; +#ifdef HAVE_SOCKADDR_SA_LEN sin->sin_len = sizeof(struct sockaddr_in); +#endif sin->sin_family = AF_INET; memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src)); break; @@ -267,7 +277,9 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator) case 6: ip6 = (struct ip6_hdr *)bp2; sin6 = (struct sockaddr_in6 *)&ss; +#ifdef HAVE_SOCKADDR_SA_LEN sin6->sin6_len = sizeof(struct sockaddr_in6); +#endif sin6->sin6_family = AF_INET6; memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src)); break; diff --git a/print-pim.c b/print-pim.c index 2eb795aa..29b32dfe 100644 --- a/print-pim.c +++ b/print-pim.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.9 1999-10-30 05:11:19 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.10 1999-10-30 07:36:38 itojun Exp $ (LBL)"; #endif #include @@ -44,7 +44,7 @@ static const char rcsid[] = #include #else struct pim { -#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN) +#if defined(WORDS_BIGENDIAN) || (defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)) u_char pim_type:4, /* the PIM message type, currently they are: * Hello, Register, Register-Stop, Join/Prune, * Bootstrap, Assert, Graft (PIM-DM only), diff --git a/tcpdump.c b/tcpdump.c index 1e8271a2..cdf30d75 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -24,7 +24,7 @@ static const char copyright[] = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\ The Regents of the University of California. All rights reserved.\n"; static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.132 1999-10-30 05:11:23 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.133 1999-10-30 07:36:39 itojun Exp $ (LBL)"; #endif /* @@ -430,7 +430,7 @@ default_print_unaligned(register const u_char *cp, register u_int length) putchar('\n'); while (nshorts >= 0) { - snprintf(line+20+i*5, 7, "%02x%02x ", cp[0], cp[1]); + sprintf(line+20+i*5, "%02x%02x ", cp[0], cp[1]); if(isprint(cp[0])) { line[62+i*2]=cp[0];