summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoritojun <itojun>1999-10-30 05:11:06 +0000
committeritojun <itojun>1999-10-30 05:11:06 +0000
commitc9d84d15c5c4dc8eca7594101fe5026080ed641e (patch)
tree79e5976a7e801dfa189fd653936ab06481654f91
parentce751501abbddbe91d683d13b5cd845a5d551d8f (diff)
downloadtcpdump-c9d84d15c5c4dc8eca7594101fe5026080ed641e.tar.gz
Bring in KAME IPv6 tcpdump. replaces esp/ah/isakmp decoder.
Hope I did not break anything. Portability on IPv4-only node needs checking, I'll do this very soon. (sorry for rather jumbo commit) XXx what is _FAVOR_BSD?
-rw-r--r--.cvsignore5
-rw-r--r--Makefile.in25
-rw-r--r--aclocal.m4278
-rw-r--r--addrtoname.c136
-rw-r--r--addrtoname.h11
-rwxr-xr-xconfigure1788
-rw-r--r--configure.in434
-rw-r--r--dhcp6.h191
-rw-r--r--dhcp6opt.h80
-rw-r--r--interface.h31
-rw-r--r--ipsec_doi.h164
-rw-r--r--isakmp.h449
-rw-r--r--l2tp.h82
-rw-r--r--missing/addrinfo.h106
-rw-r--r--missing/addrsize.h36
-rw-r--r--missing/bittypes.h67
-rw-r--r--missing/cdecl_ext.h37
-rw-r--r--missing/getaddrinfo.c1012
-rw-r--r--missing/getnameinfo.c261
-rw-r--r--missing/resolv6.h36
-rw-r--r--missing/resolv_ext.h49
-rw-r--r--missing/sockstorage.h38
-rw-r--r--oakley.h126
-rw-r--r--ospf6.h280
-rw-r--r--print-ah.c105
-rw-r--r--print-atalk.c4
-rw-r--r--print-atm.c10
-rw-r--r--print-bgp.c615
-rw-r--r--print-chdlc.c192
-rw-r--r--print-dhcp6.c336
-rw-r--r--print-domain.c57
-rw-r--r--print-dvmrp.c4
-rw-r--r--print-esp.c305
-rw-r--r--print-ether.c14
-rw-r--r--print-frag6.c100
-rw-r--r--print-icmp.c8
-rw-r--r--print-icmp6.c570
-rw-r--r--print-igrp.c4
-rw-r--r--print-ip.c108
-rw-r--r--print-ip6.c224
-rw-r--r--print-ip6opts.c153
-rw-r--r--print-ipcomp.c111
-rw-r--r--print-ipx.c4
-rw-r--r--print-isakmp.c1115
-rw-r--r--print-krb.c4
-rw-r--r--print-l2tp.c703
-rw-r--r--print-mobile.c141
-rw-r--r--print-netbios.c5
-rw-r--r--print-null.c21
-rw-r--r--print-ospf.c5
-rw-r--r--print-ospf6.c664
-rw-r--r--print-pim.c492
-rw-r--r--print-ppp.c497
-rw-r--r--print-raw.c4
-rw-r--r--print-rip.c4
-rw-r--r--print-ripng.c123
-rw-r--r--print-rt6.c116
-rw-r--r--print-sunrpc.c3
-rw-r--r--print-tcp.c114
-rw-r--r--print-udp.c91
-rw-r--r--print-vjc.c100
-rw-r--r--route6d.h49
-rw-r--r--savestr.c3
-rw-r--r--tcpdump.181
-rw-r--r--tcpdump.c31
65 files changed, 12520 insertions, 492 deletions
diff --git a/.cvsignore b/.cvsignore
new file mode 100644
index 00000000..23285a5b
--- /dev/null
+++ b/.cvsignore
@@ -0,0 +1,5 @@
+version.c
+Makefile
+config.status
+config.log
+config.cache
diff --git a/Makefile.in b/Makefile.in
index a129aeba..8cadccf1 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.209 1999-10-17 21:56:53 mcr Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.210 1999-10-30 05:11:06 itojun Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -61,21 +61,23 @@ INSTALL = @INSTALL@
# problem if you don't own the file but can write to the directory.
.c.o:
@rm -f $@
- $(CC) $(CFLAGS) -c $<
+ $(CC) $(CFLAGS) -c $(srcdir)/$*.c
CSRC = tcpdump.c \
print-arp.c print-atalk.c print-atm.c print-bootp.c \
print-decnet.c print-domain.c print-dvmrp.c print-egp.c \
- print-ether.c print-fddi.c print-isakmp.c print-ah.c print-esp.c \
- print-gre.c print-icmp.c \
+ print-ether.c print-fddi.c print-gre.c print-icmp.c \
print-igrp.c print-ip.c print-ipx.c print-isoclns.c print-krb.c \
print-llc.c print-nfs.c print-ntp.c print-null.c print-ospf.c \
print-pim.c print-ppp.c print-raw.c print-rip.c print-sl.c \
print-snmp.c print-sunrpc.c print-tcp.c print-tftp.c print-udp.c \
print-wb.c addrtoname.c bpf_dump.c gmt2local.c machdep.c \
- parsenfsfh.c util.c savestr.c setsignal.c
-LOCALSRC =
+ parsenfsfh.c util.c savestr.c setsignal.c \
+ print-esp.c print-ah.c print-vjc.c print-isakmp.c print-chdlc.c \
+ print-ipcomp.c print-mobile.c print-l2tp.c print-bgp.c
+LOCALSRC = @LOCALSRC@
GENSRC = version.c
+LIBOBJS = @LIBOBJS@
SRC = $(CSRC) $(GENSRC) $(LOCALSRC)
@@ -83,9 +85,11 @@ SRC = $(CSRC) $(GENSRC) $(LOCALSRC)
# hack the extra indirection
OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LOCALSRC:.c=.o) @LIBOBJS@
HDR = addrtoname.h appletalk.h bootp.h decnet.h \
- ethertype.h extract.h fddi.h gmt2local.h interface.h igrp.h \
+ ethertype.h extract.h fddi.h gmt2local.h igrp.h interface.h \
ipx.h llc.h machdep.h mib.h nfsfh.h nfsv2.h ntp.h ospf.h \
- savestr.c setsignal.h
+ savestr.c setsignal.h \
+ gnuc.h ipsec_doi.h isakmp.h l2tp.h netbios.h oakley.h ospf6.h ppp.h \
+ route6d.h
TAGHDR = \
/usr/include/arpa/tftp.h \
@@ -108,6 +112,11 @@ $(PROG): $(OBJ) @V_PCAPDEP@
@rm -f $@
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
+getnameinfo.o: $(srcdir)/missing/getnameinfo.c
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
+getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getaddrinfo.c
+
version.o: version.c
version.c: $(srcdir)/VERSION
@rm -f $@
diff --git a/aclocal.m4 b/aclocal.m4
index c98383d7..baec00c9 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.64 1999-10-09 23:57:19 mcr Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.65 1999-10-30 05:11:06 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/libpcap.a ; then
+ if test -r $dir/pcap.c ; then
libpcap=$dir/libpcap.a
d=$dir
dnl continue and select the last one that exists
@@ -214,13 +214,7 @@ 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
+ $2="-I$d $$2"
AC_MSG_RESULT($libpcap)
fi
LIBS="$libpcap $LIBS"
@@ -710,3 +704,267 @@ AC_DEFUN(AC_LBL_LIBRARY_NET, [
# DLPI needs putmsg under HPUX so test for -lstr while we're at it
AC_CHECK_LIB(str, putmsg)
])
+
+dnl Copyright (c) 1999 WIDE Project. All rights reserved.
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are permitted provided that the following conditions
+dnl are met:
+dnl 1. Redistributions of source code must retain the above copyright
+dnl notice, this list of conditions and the following disclaimer.
+dnl 2. Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl 3. Neither the name of the project nor the names of its contributors
+dnl may be used to endorse or promote products derived from this software
+dnl without specific prior written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+dnl ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+dnl SUCH DAMAGE.
+
+dnl
+dnl Checks to see if AF_INET6 is defined
+AC_DEFUN(AC_CHECK_AF_INET6, [
+ AC_MSG_CHECKING(for AF_INET6)
+ AC_CACHE_VAL($1,
+ AC_TRY_COMPILE([
+# include <sys/types.h>
+# include <sys/socket.h>],
+ [int a = AF_INET6],
+ $1=yes,
+ $1=no))
+ AC_MSG_RESULT($$1)
+ if test $$1 = yes ; then
+ AC_DEFINE(HAVE_AF_INET6)
+ fi
+])
+
+dnl
+dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
+dnl borrowed from LBL libpcap
+AC_DEFUN(AC_CHECK_SA_LEN, [
+ AC_MSG_CHECKING(if sockaddr struct has sa_len member)
+ AC_CACHE_VAL($1,
+ AC_TRY_COMPILE([
+# include <sys/types.h>
+# include <sys/socket.h>],
+ [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
+ $1=yes,
+ $1=no))
+ AC_MSG_RESULT($$1)
+ if test $$1 = yes ; then
+ AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
+ fi
+])
+
+dnl
+dnl Checks for portable prototype declaration macro
+AC_DEFUN(AC_CHECK_PORTABLE_PROTO, [
+ AC_MSG_CHECKING(for __P)
+ AC_CACHE_VAL($1,
+ AC_TRY_COMPILE([
+# include <unistd.h>],
+ [int f __P(())],
+ $1=yes,
+ $1=no))
+ AC_MSG_RESULT($$1)
+ if test $$1 = yes; then
+ AC_DEFINE(HAVE_PORTABLE_PROTOTYPE)
+ fi
+])
+
+dnl checks for u_intXX_t
+AC_DEFUN(AC_CHECK_BITTYPES, [
+ $1=yes
+dnl check for u_int8_t
+ AC_MSG_CHECKING(for u_int8_t)
+ AC_CACHE_VAL(ac_cv_u_int8_t,
+ AC_TRY_COMPILE([
+# include <sys/types.h>],
+ [u_int8_t i],
+ ac_cv_u_int8_t=yes,
+ ac_cv_u_int8_t=no))
+ AC_MSG_RESULT($ac_cv_u_int8_t)
+ if test $ac_cv_u_int8_t = yes; then
+ AC_DEFINE(HAVE_U_INT8_T)
+ else
+ $1=no
+ fi
+dnl check for u_int16_t
+ AC_MSG_CHECKING(for u_int16_t)
+ AC_CACHE_VAL(ac_cv_u_int16_t,
+ AC_TRY_COMPILE([
+# include <sys/types.h>],
+ [u_int16_t i],
+ ac_cv_u_int16_t=yes,
+ ac_cv_u_int16_t=no))
+ AC_MSG_RESULT($ac_cv_u_int16_t)
+ if test $ac_cv_u_int16_t = yes; then
+ AC_DEFINE(HAVE_U_INT16_T)
+ else
+ $1=no
+ fi
+dnl check for u_int32_t
+ AC_MSG_CHECKING(for u_int32_t)
+ AC_CACHE_VAL(ac_cv_u_int32_t,
+ AC_TRY_COMPILE([
+# include <sys/types.h>],
+ [u_int32_t i],
+ ac_cv_u_int32_t=yes,
+ ac_cv_u_int32_t=no))
+ AC_MSG_RESULT($ac_cv_u_int32_t)
+ if test $ac_cv_u_int32_t = yes; then
+ AC_DEFINE(HAVE_U_INT32_T)
+ else
+ $1=no
+ fi
+])
+
+dnl
+dnl Checks for addrinfo structure
+AC_DEFUN(AC_STRUCT_ADDRINFO, [
+ AC_MSG_CHECKING(for addrinfo)
+ AC_CACHE_VAL($1,
+ AC_TRY_COMPILE([
+# include <netdb.h>],
+ [struct addrinfo a],
+ $1=yes,
+ $1=no))
+ AC_MSG_RESULT($$1)
+ if test $$1 = yes; then
+ AC_DEFINE(HAVE_ADDRINFO)
+ fi
+])
+
+dnl
+dnl Checks for sockaddr_storage structure
+AC_DEFUN(AC_STRUCT_SA_STORAGE, [
+ AC_MSG_CHECKING(for sockaddr_storage)
+ AC_CACHE_VAL($1,
+ AC_TRY_COMPILE([
+# include <sys/types.h>
+# include <sys/socket.h>],
+ [struct sockaddr_storage s],
+ $1=yes,
+ $1=no))
+ AC_MSG_RESULT($$1)
+ if test $$1 = yes; then
+ AC_DEFINE(HAVE_SOCKADDR_STORAGE)
+ fi
+])
+
+dnl
+dnl Checks for macro of IP address size
+AC_DEFUN(AC_CHECK_ADDRSZ, [
+ $1=yes
+dnl check for INADDRSZ
+ AC_MSG_CHECKING(for INADDRSZ)
+ AC_CACHE_VAL(ac_cv_inaddrsz,
+ AC_TRY_COMPILE([
+# include <arpa/nameser.h>],
+ [int a = INADDRSZ],
+ ac_cv_inaddrsz=yes,
+ ac_cv_inaddrsz=no))
+ AC_MSG_RESULT($ac_cv_inaddrsz)
+ if test $ac_cv_inaddrsz = yes; then
+ AC_DEFINE(HAVE_INADDRSZ)
+ else
+ $1=no
+ fi
+dnl check for IN6ADDRSZ
+ AC_MSG_CHECKING(for IN6ADDRSZ)
+ AC_CACHE_VAL(ac_cv_in6addrsz,
+ AC_TRY_COMPILE([
+# include <arpa/nameser.h>],
+ [int a = IN6ADDRSZ],
+ ac_cv_in6addrsz=yes,
+ ac_cv_in6addrsz=no))
+ AC_MSG_RESULT($ac_cv_in6addrsz)
+ if test $ac_cv_in6addrsz = yes; then
+ AC_DEFINE(HAVE_IN6ADDRSZ)
+ else
+ $1=no
+ fi
+])
+
+dnl
+dnl check for RES_USE_INET6
+AC_DEFUN(AC_CHECK_RES_USE_INET6, [
+ AC_MSG_CHECKING(for RES_USE_INET6)
+ AC_CACHE_VAL($1,
+ AC_TRY_COMPILE([
+# include <sys/types.h>
+# include <netinet/in.h>
+# include <resolv.h>],
+ [int a = RES_USE_INET6],
+ $1=yes,
+ $1=no))
+ AC_MSG_RESULT($$1)
+ if test $$1 = yes; then
+ AC_DEFINE(HAVE_RES_USE_INET6)
+ fi
+])
+
+dnl
+dnl check for AAAA
+AC_DEFUN(AC_CHECK_AAAA, [
+ AC_MSG_CHECKING(for AAAA)
+ AC_CACHE_VAL($1,
+ AC_TRY_COMPILE([
+# include <arpa/nameser.h>],
+ [int a = T_AAAA],
+ $1=yes,
+ $1=no))
+ AC_MSG_RESULT($$1)
+ if test $$1 = yes; then
+ AC_DEFINE(HAVE_AAAA)
+ fi
+])
+
+dnl
+dnl check for struct res_state_ext
+AC_DEFUN(AC_STRUCT_RES_STATE_EXT, [
+ AC_MSG_CHECKING(for res_state_ext)
+ AC_CACHE_VAL($1,
+ AC_TRY_COMPILE([
+# include <sys/types.h>
+# include <netinet/in.h>
+# include <netinet6/in6.h>
+# include <resolv.h>],
+ [struct __res_state_ext e],
+ $1=yes,
+ $1=no))
+ AC_MSG_RESULT($$1)
+ if test $$1 = yes; then
+ AC_DEFINE(HAVE_RES_STATE_EXT)
+ fi
+])
+
+dnl
+dnl check for struct res_state_ext
+AC_DEFUN(AC_STRUCT_RES_STATE, [
+ AC_MSG_CHECKING(for nsort in res_state)
+ AC_CACHE_VAL($1,
+ AC_TRY_COMPILE([
+# include <sys/types.h>
+# include <netinet/in.h>
+# include <netinet6/in6.h>
+# include <resolv.h>],
+ [struct __res_state e; e.nsort = 0],
+ $1=yes,
+ $1=no))
+ AC_MSG_RESULT($$1)
+ if test $$1 = yes; then
+ AC_DEFINE(HAVE_NEW_RES_STATE)
+ fi
+])
+
diff --git a/addrtoname.c b/addrtoname.c
index bc7c22bd..5af1275b 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -23,7 +23,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.61 1999-10-07 23:47:09 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.62 1999-10-30 05:11:06 itojun Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -39,6 +39,10 @@ struct rtentry;
#include <netinet/in.h>
#include <netinet/if_ether.h>
+#ifdef INET6
+#include <netinet6/ip6.h>
+#endif
+
#include <arpa/inet.h>
#include <ctype.h>
@@ -85,6 +89,16 @@ struct hnamemem eprototable[HASHNAMESIZE];
struct hnamemem dnaddrtable[HASHNAMESIZE];
struct hnamemem llcsaptable[HASHNAMESIZE];
+#ifdef INET6
+struct h6namemem {
+ struct in6_addr addr;
+ char *name;
+ struct h6namemem *nxt;
+};
+
+struct h6namemem h6nametable[HASHNAMESIZE];
+#endif /* INET6 */
+
struct enamemem {
u_short e_addr0;
u_short e_addr1;
@@ -171,39 +185,7 @@ getname(const u_char *ap)
#ifndef LBL_ALIGN
addr = *(const u_int32_t *)ap;
#else
- /*
- * Extract 32 bits in network order, dealing with alignment.
- */
- switch ((long)ap & 3) {
-
- case 0:
- addr = *(u_int32_t *)ap;
- break;
-
- case 2:
-#ifdef WORDS_BIGENDIAN
- addr = ((u_int32_t)*(u_short *)ap << 16) |
- (u_int32_t)*(u_short *)(ap + 2);
-#else
- addr = ((u_int32_t)*(u_short *)(ap + 2) << 16) |
- (u_int32_t)*(u_short *)ap;
-#endif
- break;
-
- default:
-#ifdef WORDS_BIGENDIAN
- addr = ((u_int32_t)ap[0] << 24) |
- ((u_int32_t)ap[1] << 16) |
- ((u_int32_t)ap[2] << 8) |
- (u_int32_t)ap[3];
-#else
- addr = ((u_int32_t)ap[3] << 24) |
- ((u_int32_t)ap[2] << 16) |
- ((u_int32_t)ap[1] << 8) |
- (u_int32_t)ap[0];
-#endif
- break;
- }
+ memcpy(&addr, ap, sizeof(addr));
#endif
p = &hnametable[addr & (HASHNAMESIZE-1)];
for (; p->nxt; p = p->nxt) {
@@ -249,6 +231,71 @@ getname(const u_char *ap)
return (p->name);
}
+#ifdef INET6
+/*
+ * Return a name for the IP6 address pointed to by ap. This address
+ * is assumed to be in network byte order.
+ */
+char *
+getname6(const u_char *ap)
+{
+ register struct hostent *hp;
+ struct in6_addr addr;
+ static struct h6namemem *p; /* static for longjmp() */
+ register char *cp;
+ char ntop_buf[INET6_ADDRSTRLEN];
+
+ memcpy(&addr, ap, sizeof(addr));
+ p = &h6nametable[*(u_int16_t *)&addr.s6_addr[15] & (HASHNAMESIZE-1)];
+ for (; p->nxt; p = p->nxt) {
+ if (memcmp(&p->addr, &addr, sizeof(addr)) == 0)
+ return (p->name);
+ }
+ p->addr = addr;
+ p->nxt = newh6namemem();
+
+ /*
+ * Only print names when:
+ * (1) -n was not given.
+ * (2) Address is foreign and -f was given. (If -f was not
+ * give, f_netmask and f_local are 0 and the test
+ * evaluates to true)
+ * (3) -a was given or the host portion is not all ones
+ * nor all zeros (i.e. not a network or broadcast address)
+ */
+ if (!nflag
+#if 0
+ &&
+ (addr & f_netmask) == f_localnet &&
+ (aflag ||
+ !((addr & ~netmask) == 0 || (addr | netmask) == 0xffffffff))
+#endif
+ ) {
+ if (!setjmp(getname_env)) {
+ (void)setsignal(SIGALRM, nohostname);
+ (void)alarm(20);
+ hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET6);
+ (void)alarm(0);
+ if (hp) {
+ char *dotp;
+
+ p->name = savestr(hp->h_name);
+ if (Nflag) {
+ /* Remove domain qualifications */
+ dotp = strchr(p->name, '.');
+ if (dotp)
+ *dotp = '\0';
+ }
+ return (p->name);
+ }
+ }
+ }
+ cp = (char *)inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
+ p->name = savestr(cp);
+ return (p->name);
+}
+#endif /* INET6 */
+
static char hex[] = "0123456789abcdef";
@@ -764,3 +811,24 @@ newhnamemem(void)
p = ptr++;
return (p);
}
+
+#ifdef INET6
+/* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
+struct h6namemem *
+newh6namemem(void)
+{
+ register struct h6namemem *p;
+ static struct h6namemem *ptr = NULL;
+ static u_int num = 0;
+
+ if (num <= 0) {
+ num = 64;
+ ptr = (struct h6namemem *)calloc(num, sizeof (*ptr));
+ if (ptr == NULL)
+ error("newh6namemem: calloc");
+ }
+ --num;
+ p = ptr++;
+ return (p);
+}
+#endif /* INET6 */
diff --git a/addrtoname.h b/addrtoname.h
index 2848a29d..33fc07fc 100644
--- a/addrtoname.h
+++ b/addrtoname.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.15 1999-10-07 23:47:09 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.16 1999-10-30 05:11:07 itojun Exp $ (LBL)
*/
/* Name to address translation routines. */
@@ -28,9 +28,18 @@ extern char *etherproto_string(u_short);
extern char *tcpport_string(u_short);
extern char *udpport_string(u_short);
extern char *getname(const u_char *);
+#ifdef INET6
+extern char *getname6(const u_char *);
+#endif
extern char *intoa(u_int32_t);
extern void init_addrtoname(u_int32_t, u_int32_t);
extern struct hnamemem *newhnamemem(void);
+#ifdef INET6
+extern struct h6namemem *newh6namemem(void);
+#endif
#define ipaddr_string(p) getname((const u_char *)(p))
+#ifdef INET6
+#define ip6addr_string(p) getname6((const u_char *)(p))
+#endif
diff --git a/configure b/configure
index 52d78aee..b78aeabf 100755
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12
+# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
@@ -13,6 +13,9 @@ ac_default_prefix=/usr/local
# Any additions from configure.in:
ac_help="$ac_help
--without-gcc don't use gcc"
+ac_help="$ac_help
+ --enable-ipv6 Enable ipv6 (with ipv4) support
+ --disable-ipv6 Disable ipv6 support"
# Initialize some variables set by options.
# The variables have the same names as the options, with
@@ -51,6 +54,7 @@ mandir='${prefix}/man'
# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12
@@ -334,7 +338,7 @@ EOF
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.12"
+ echo "configure generated by autoconf version 2.13"
exit 0 ;;
-with-* | --with-*)
@@ -504,9 +508,11 @@ ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
+ac_exeext=
+ac_objext=o
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
@@ -563,33 +569,33 @@ esac
# Make sure we can run config.sub.
-if $ac_config_sub sun4 >/dev/null 2>&1; then :
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:572: checking host system type" >&5
+echo "configure:578: checking host system type" >&5
host_alias=$host
case "$host_alias" in
NONE)
case $nonopt in
NONE)
- if host_alias=`$ac_config_guess`; then :
+ if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
fi ;;
*) host_alias=$nonopt ;;
esac ;;
esac
-host=`$ac_config_sub $host_alias`
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:593: checking target system type" >&5
+echo "configure:599: checking target system type" >&5
target_alias=$target
case "$target_alias" in
@@ -600,14 +606,14 @@ NONE)
esac ;;
esac
-target=`$ac_config_sub $target_alias`
+target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$target" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:611: checking build system type" >&5
+echo "configure:617: checking build system type" >&5
build_alias=$build
case "$build_alias" in
@@ -618,7 +624,7 @@ NONE)
esac ;;
esac
-build=`$ac_config_sub $build_alias`
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
@@ -649,7 +655,7 @@ fi
V_CCOPT="-O"
V_INCLS=""
if test "${srcdir}" != "." ; then
- V_INCLS="-I\$(srcdir)"
+ V_INCLS="-I\$\(srcdir\)"
fi
if test "${CFLAGS+set}" = set; then
LBL_CFLAGS="$CFLAGS"
@@ -661,15 +667,16 @@ fi
# Extract the first word of "shlicc2", so it can be a program name with args.
set dummy shlicc2; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:665: checking for $ac_word" >&5
+echo "configure:671: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_SHLICC2'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$SHLICC2"; then
ac_cv_prog_SHLICC2="$SHLICC2" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_SHLICC2="yes"
@@ -701,15 +708,16 @@ fi
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:705: checking for $ac_word" >&5
+echo "configure:712: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_CC="gcc"
@@ -730,16 +738,17 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:734: checking for $ac_word" >&5
+echo "configure:742: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_prog_rejected=no
- for ac_dir in $PATH; do
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -774,25 +783,61 @@ else
echo "$ac_t""no" 1>&6
fi
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:793: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:782: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:825: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
-cat > conftest.$ac_ext <<EOF
-#line 792 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 836 "configure"
#include "confdefs.h"
+
main(){return(0);}
EOF
-if { (eval echo configure:796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -806,18 +851,24 @@ else
ac_cv_prog_cc_works=no
fi
rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:816: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:867: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:821: checking whether we are using GNU C" >&5
+echo "configure:872: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -826,7 +877,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:830: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:881: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -837,11 +888,15 @@ echo "$ac_t""$ac_cv_prog_gcc" 1>&6
if test $ac_cv_prog_gcc = yes; then
GCC=yes
- ac_test_CFLAGS="${CFLAGS+set}"
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS=
- echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:845: checking whether ${CC-cc} accepts -g" >&5
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:900: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -856,16 +911,20 @@ rm -f conftest*
fi
echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
- if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
- elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
- CFLAGS="-O2"
+ CFLAGS="-g"
fi
else
- GCC=
- test "${CFLAGS+set}" = set || CFLAGS="-g"
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
fi
if test "$GCC" = yes ; then
@@ -874,7 +933,7 @@ fi
V_CCOPT="-O2"
else
echo $ac_n "checking gcc version""... $ac_c" 1>&6
-echo "configure:878: checking gcc version" >&5
+echo "configure:937: checking gcc version" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_gcc_vers'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -892,19 +951,19 @@ fi
fi
else
echo $ac_n "checking that $CC handles ansi prototypes""... $ac_c" 1>&6
-echo "configure:896: checking that $CC handles ansi prototypes" >&5
+echo "configure:955: checking that $CC handles ansi prototypes" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_cc_ansi_prototypes'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 901 "configure"
+#line 960 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
int frob(int, char *)
; return 0; }
EOF
-if { (eval echo configure:908: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:967: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_cc_ansi_prototypes=yes
else
@@ -922,21 +981,21 @@ fi
hpux*)
echo $ac_n "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)""... $ac_c" 1>&6
-echo "configure:926: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5
+echo "configure:985: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5
savedcflags="$CFLAGS"
CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
if eval "test \"`echo '$''{'ac_cv_lbl_cc_hpux_cc_aa'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 933 "configure"
+#line 992 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
int frob(int, char *)
; return 0; }
EOF
-if { (eval echo configure:940: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:999: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_cc_hpux_cc_aa=yes
else
@@ -980,12 +1039,12 @@ EOF
ultrix*)
echo $ac_n "checking that Ultrix $CC hacks const in prototypes""... $ac_c" 1>&6
-echo "configure:984: checking that Ultrix $CC hacks const in prototypes" >&5
+echo "configure:1043: checking that Ultrix $CC hacks const in prototypes" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_cc_const_proto'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 989 "configure"
+#line 1048 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
@@ -993,7 +1052,7 @@ struct a { int b; };
void c(const struct a *)
; return 0; }
EOF
-if { (eval echo configure:997: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_cc_const_proto=yes
else
@@ -1018,7 +1077,7 @@ EOF
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1022: checking how to run the C preprocessor" >&5
+echo "configure:1081: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1033,14 +1092,14 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1037 "configure"
+#line 1096 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1043: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1102: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
@@ -1050,14 +1109,31 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1054 "configure"
+#line 1113 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1060: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1119: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 1130 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1136: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
@@ -1070,6 +1146,8 @@ fi
rm -f conftest*
fi
rm -f conftest*
+fi
+rm -f conftest*
ac_cv_prog_CPP="$CPP"
fi
CPP="$ac_cv_prog_CPP"
@@ -1082,18 +1160,18 @@ for ac_hdr in fcntl.h malloc.h memory.h rpc/rpcent.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1086: checking for $ac_hdr" >&5
+echo "configure:1164: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1091 "configure"
+#line 1169 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1096: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1174: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
@@ -1119,12 +1197,12 @@ fi
done
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1123: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1201: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1128 "configure"
+#line 1206 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -1133,7 +1211,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:1137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1215: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -1158,7 +1236,7 @@ case "$target_os" in
linux*)
echo $ac_n "checking Linux kernel version""... $ac_c" 1>&6
-echo "configure:1162: checking Linux kernel version" >&5
+echo "configure:1240: checking Linux kernel version" >&5
if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1170,6 +1248,10 @@ fi
if test $ac_cv_linux_vers -lt 2 ; then
{ echo "configure: error: version 2 or higher required; see the INSTALL doc for more info" 1>&2; exit 1; }
fi
+ cat >> confdefs.h <<\EOF
+#define HAVE_NET_SLIP_H 1
+EOF
+
;;
*)
@@ -1177,18 +1259,18 @@ fi
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1181: checking for $ac_hdr" >&5
+echo "configure:1263: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1186 "configure"
+#line 1268 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1191: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1273: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
@@ -1216,15 +1298,1111 @@ done
;;
esac
+CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len"
+echo $ac_n "checking whether to enable ipv6""... $ac_c" 1>&6
+echo "configure:1304: checking whether to enable ipv6" >&5
+# Check whether --enable-ipv6 or --disable-ipv6 was given.
+if test "${enable_ipv6+set}" = set; then
+ enableval="$enable_ipv6"
+ case "$enableval" in
+ no)
+ echo "$ac_t""no" 1>&6
+ ipv6=no
+ ;;
+ *) echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define ENABLE_IPV6 1
+EOF
+
+ LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
+ cat >> confdefs.h <<\EOF
+#define INET6 1
+EOF
+
+ ipv6=yes
+ ;;
+ esac
+else
+ if test "$cross_compiling" = yes; then
+ echo "$ac_t""no" 1>&6
+ ipv6=no
+
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1333 "configure"
+#include "confdefs.h"
+ /* AF_INET6 avalable check */
+#include <sys/types.h>
+#include <sys/socket.h>
+main()
+{
+ exit(0);
+ if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
+ exit(1);
+ else
+ exit(0);
+}
+
+EOF
+if { (eval echo configure:1348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define ENABLE_IPV6 1
+EOF
+
+ LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
+ cat >> confdefs.h <<\EOF
+#define INET6 1
+EOF
+
+ ipv6=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ echo "$ac_t""no" 1>&6
+ ipv6=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+
+ipv6type=unknown
+ipv6lib=none
+ipv6trylibc=no
+
+if test "$ipv6" = "yes"; then
+ echo $ac_n "checking ipv6 stack type""... $ac_c" 1>&6
+echo "configure:1380: checking ipv6 stack type" >&5
+ for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
+ case $i in
+ inria)
+ cat > conftest.$ac_ext <<EOF
+#line 1385 "configure"
+#include "confdefs.h"
+dnl
+#include <netinet/in.h>
+#ifdef IPV6_INRIA_VERSION
+yes
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "yes" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ipv6type=$i;
+ CFLAGS="-DINET6 $CFLAGS"
+fi
+rm -f conftest*
+
+ ;;
+ kame)
+ cat > conftest.$ac_ext <<EOF
+#line 1404 "configure"
+#include "confdefs.h"
+dnl
+#include <netinet/in.h>
+#ifdef __KAME__
+yes
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "yes" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ipv6type=$i;
+ ipv6lib=inet6;
+ ipv6libdir=/usr/local/v6/lib;
+ ipv6trylibc=yes;
+ CFLAGS="-DINET6 $CFLAGS"
+fi
+rm -f conftest*
+
+ ;;
+ linux-glibc)
+ cat > conftest.$ac_ext <<EOF
+#line 1426 "configure"
+#include "confdefs.h"
+dnl
+#include <features.h>
+#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
+yes
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "yes" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ipv6type=$i;
+ CFLAGS="-DINET6 $CFLAGS"
+fi
+rm -f conftest*
+
+ ;;
+ linux-libinet6)
+ if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
+ ipv6type=$i
+ ipv6lib=inet6
+ ipv6libdir=/usr/inet6/lib
+ ipv6trylibc=yes;
+ CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
+ fi
+ ;;
+ toshiba)
+ cat > conftest.$ac_ext <<EOF
+#line 1454 "configure"
+#include "confdefs.h"
+dnl
+#include <sys/param.h>
+#ifdef _TOSHIBA_INET6
+yes
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "yes" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ipv6type=$i;
+ ipv6lib=inet6;
+ ipv6libdir=/usr/local/v6/lib;
+ CFLAGS="-DINET6 $CFLAGS"
+fi
+rm -f conftest*
+
+ ;;
+ v6d)
+ cat > conftest.$ac_ext <<EOF
+#line 1475 "configure"
+#include "confdefs.h"
+dnl
+#include </usr/local/v6/include/sys/v6config.h>
+#ifdef __V6D__
+yes
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "yes" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ipv6type=$i;
+ ipv6lib=v6;
+ ipv6libdir=/usr/local/v6/lib;
+ CFLAGS="-I/usr/local/v6/include $CFLAGS"
+fi
+rm -f conftest*
+
+ ;;
+ zeta)
+ cat > conftest.$ac_ext <<EOF
+#line 1496 "configure"
+#include "confdefs.h"
+dnl
+#include <sys/param.h>
+#ifdef _ZETA_MINAMI_INET6
+yes
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "yes" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ipv6type=$i;
+ ipv6lib=inet6;
+ ipv6libdir=/usr/local/v6/lib;
+ CFLAGS="-DINET6 $CFLAGS"
+fi
+rm -f conftest*
+
+ ;;
+ esac
+ if test "$ipv6type" != "unknown"; then
+ break
+ fi
+ done
+ echo "$ac_t""$ipv6type" 1>&6
+fi
+
+if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
+ if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
+ LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
+ echo "You have $ipv6lib library, using it"
+ else
+ if test "$ipv6trylibc" = "yes"; then
+ echo "You do not have $ipv6lib library, using libc"
+ else
+ echo 'Fatal: no $ipv6lib library found. cannot continue.'
+ echo "You need to fetch lib$ipv6lib.a from appropriate"
+ echo 'ipv6 kit and compile beforehand.'
+ exit 1
+ fi
+ fi
+fi
+
+
+echo $ac_n "checking getaddrinfo bug""... $ac_c" 1>&6
+echo "configure:1541: checking getaddrinfo bug" >&5
+if test "$cross_compiling" = yes; then
+ echo "$ac_t""buggy" 1>&6
+buggygetaddrinfo=yes
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1547 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <netdb.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+main()
+{
+ int passive, gaierr, inet4 = 0, inet6 = 0;
+ struct addrinfo hints, *ai, *aitop;
+ char straddr[INET6_ADDRSTRLEN], strport[16];
+
+ for (passive = 0; passive <= 1; passive++) {
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_flags = passive ? AI_PASSIVE : 0;
+ hints.ai_socktype = SOCK_STREAM;
+ if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
+ (void)gai_strerror(gaierr);
+ goto bad;
+ }
+ for (ai = aitop; ai; ai = ai->ai_next) {
+ if (ai->ai_addr == NULL ||
+ ai->ai_addrlen == 0 ||
+ getnameinfo(ai->ai_addr, ai->ai_addrlen,
+ straddr, sizeof(straddr), strport, sizeof(strport),
+ NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
+ goto bad;
+ }
+ switch (ai->ai_family) {
+ case AF_INET:
+ if (strcmp(strport, "54321") != 0) {
+ goto bad;
+ }
+ if (passive) {
+ if (strcmp(straddr, "0.0.0.0") != 0) {
+ goto bad;
+ }
+ } else {
+ if (strcmp(straddr, "127.0.0.1") != 0) {
+ goto bad;
+ }
+ }
+ inet4++;
+ break;
+ case AF_INET6:
+ if (strcmp(strport, "54321") != 0) {
+ goto bad;
+ }
+ if (passive) {
+ if (strcmp(straddr, "::") != 0) {
+ goto bad;
+ }
+ } else {
+ if (strcmp(straddr, "::1") != 0) {
+ goto bad;
+ }
+ }
+ inet6++;
+ break;
+ case AF_UNSPEC:
+ goto bad;
+ break;
+#ifdef AF_UNIX
+ case AF_UNIX:
+#else
+#ifdef AF_LOCAL
+ case AF_LOCAL:
+#endif
+#endif
+ default:
+ /* another family support? */
+ break;
+ }
+ }
+ }
+
+ if (inet6 != 2 || inet4 != 2)
+ goto bad;
+
+ if (aitop)
+ freeaddrinfo(aitop);
+ exit(0);
+
+ bad:
+ if (aitop)
+ freeaddrinfo(aitop);
+ exit(1);
+}
+
+EOF
+if { (eval echo configure:1641: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ echo "$ac_t""good" 1>&6
+buggygetaddrinfo=no
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ echo "$ac_t""buggy" 1>&6
+buggygetaddrinfo=yes
+fi
+rm -fr conftest*
+fi
+
+
+if test "$buggygetaddrinfo" = "yes"; then
+ if test "$ipv6" = "yes" -a "$ipv6type" != "linux"; then
+ echo 'Fatal: You must get working getaddrinfo() function.'
+ echo ' or you can specify "--disable-ipv6"'.
+ exit 1
+ elif test "$ipv6type" = "linux"; then
+ echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
+ echo ' Better upgreade your system library to newest version'
+ echo ' of GNU C library (aka glibc).'
+ fi
+fi
+for ac_func in getaddrinfo getnameinfo
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1670: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1675 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"
+fi
+done
+
+
+
+
+ echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
+echo "configure:1727: checking if sockaddr struct has sa_len member" >&5
+ if eval "test \"`echo '$''{'ac_cv_sockaddr_has_sa_len'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1732 "configure"
+#include "confdefs.h"
+
+# include <sys/types.h>
+# include <sys/socket.h>
+int main() {
+u_int i = sizeof(((struct sockaddr *)0)->sa_len)
+; return 0; }
+EOF
+if { (eval echo configure:1741: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_sockaddr_has_sa_len=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_sockaddr_has_sa_len=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_sockaddr_has_sa_len" 1>&6
+ if test $ac_cv_sockaddr_has_sa_len = yes ; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_SOCKADDR_SA_LEN 1
+EOF
+
+ fi
+
+if test "$ac_cv_sockaddr_has_sa_len" = no; then
+ missing_includes=yes
+fi
+
+
+ echo $ac_n "checking for __P""... $ac_c" 1>&6
+echo "configure:1767: checking for __P" >&5
+ if eval "test \"`echo '$''{'ac_cv_portable_proto'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1772 "configure"
+#include "confdefs.h"
+
+# include <unistd.h>
+int main() {
+int f __P(())
+; return 0; }
+EOF
+if { (eval echo configure:1780: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_portable_proto=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_portable_proto=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_portable_proto" 1>&6
+ if test $ac_cv_portable_proto = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_PORTABLE_PROTOTYPE 1
+EOF
+
+ fi
+
+if test "$ac_cv_portable_proto" = no; then
+ missing_includes=yes
+fi
+
+echo $ac_n "checking size of char""... $ac_c" 1>&6
+echo "configure:1805: checking size of char" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1813 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(char));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1824: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_char=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_char=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_char" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_CHAR $ac_cv_sizeof_char
+EOF
+
+
+echo $ac_n "checking size of short""... $ac_c" 1>&6
+echo "configure:1844: checking size of short" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1852 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(short));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_short=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_short=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_short" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+EOF
+
+
+echo $ac_n "checking size of int""... $ac_c" 1>&6
+echo "configure:1883: checking size of int" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1891 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(int));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_int=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_int=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_int" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+EOF
+
+
+echo $ac_n "checking size of long""... $ac_c" 1>&6
+echo "configure:1922: checking size of long" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1930 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(long));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_long=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_long=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_long" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+EOF
+
+
+
+
+ ac_cv_bittypes=yes
+ echo $ac_n "checking for u_int8_t""... $ac_c" 1>&6
+echo "configure:1964: checking for u_int8_t" >&5
+ if eval "test \"`echo '$''{'ac_cv_u_int8_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1969 "configure"
+#include "confdefs.h"
+
+# include <sys/types.h>
+int main() {
+u_int8_t i
+; return 0; }
+EOF
+if { (eval echo configure:1977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_u_int8_t=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_u_int8_t=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_u_int8_t" 1>&6
+ if test $ac_cv_u_int8_t = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_U_INT8_T 1
+EOF
+
+ else
+ ac_cv_bittypes=no
+ fi
+ echo $ac_n "checking for u_int16_t""... $ac_c" 1>&6
+echo "configure:1999: checking for u_int16_t" >&5
+ if eval "test \"`echo '$''{'ac_cv_u_int16_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2004 "configure"
+#include "confdefs.h"
+
+# include <sys/types.h>
+int main() {
+u_int16_t i
+; return 0; }
+EOF
+if { (eval echo configure:2012: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_u_int16_t=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_u_int16_t=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_u_int16_t" 1>&6
+ if test $ac_cv_u_int16_t = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_U_INT16_T 1
+EOF
+
+ else
+ ac_cv_bittypes=no
+ fi
+ echo $ac_n "checking for u_int32_t""... $ac_c" 1>&6
+echo "configure:2034: checking for u_int32_t" >&5
+ if eval "test \"`echo '$''{'ac_cv_u_int32_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2039 "configure"
+#include "confdefs.h"
+
+# include <sys/types.h>
+int main() {
+u_int32_t i
+; return 0; }
+EOF
+if { (eval echo configure:2047: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_u_int32_t=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_u_int32_t=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_u_int32_t" 1>&6
+ if test $ac_cv_u_int32_t = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_U_INT32_T 1
+EOF
+
+ else
+ ac_cv_bittypes=no
+ fi
+
+if test "$ac_cv_bittypes" = no; then
+ missing_includes=yes
+fi
+
+
+ echo $ac_n "checking for addrinfo""... $ac_c" 1>&6
+echo "configure:2075: checking for addrinfo" >&5
+ if eval "test \"`echo '$''{'ac_cv_addrinfo'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2080 "configure"
+#include "confdefs.h"
+
+# include <netdb.h>
+int main() {
+struct addrinfo a
+; return 0; }
+EOF
+if { (eval echo configure:2088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_addrinfo=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_addrinfo=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_addrinfo" 1>&6
+ if test $ac_cv_addrinfo = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_ADDRINFO 1
+EOF
+
+ fi
+
+if test "$ac_cv_addrinfo" = no; then
+ missing_includes=yes
+fi
+
+
+ echo $ac_n "checking for sockaddr_storage""... $ac_c" 1>&6
+echo "configure:2114: checking for sockaddr_storage" >&5
+ if eval "test \"`echo '$''{'ac_cv_sa_storage'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2119 "configure"
+#include "confdefs.h"
+
+# include <sys/types.h>
+# include <sys/socket.h>
+int main() {
+struct sockaddr_storage s
+; return 0; }
+EOF
+if { (eval echo configure:2128: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_sa_storage=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_sa_storage=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_sa_storage" 1>&6
+ if test $ac_cv_sa_storage = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_SOCKADDR_STORAGE 1
+EOF
+
+ fi
+
+if test "$ac_cv_sa_storage" = no; then
+ missing_includes=yes
+fi
+
+
+ ac_cv_addrsz=yes
+ echo $ac_n "checking for INADDRSZ""... $ac_c" 1>&6
+echo "configure:2155: checking for INADDRSZ" >&5
+ if eval "test \"`echo '$''{'ac_cv_inaddrsz'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2160 "configure"
+#include "confdefs.h"
+
+# include <arpa/nameser.h>
+int main() {
+int a = INADDRSZ
+; return 0; }
+EOF
+if { (eval echo configure:2168: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_inaddrsz=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_inaddrsz=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_inaddrsz" 1>&6
+ if test $ac_cv_inaddrsz = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_INADDRSZ 1
+EOF
+
+ else
+ ac_cv_addrsz=no
+ fi
+ echo $ac_n "checking for IN6ADDRSZ""... $ac_c" 1>&6
+echo "configure:2190: checking for IN6ADDRSZ" >&5
+ if eval "test \"`echo '$''{'ac_cv_in6addrsz'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2195 "configure"
+#include "confdefs.h"
+
+# include <arpa/nameser.h>
+int main() {
+int a = IN6ADDRSZ
+; return 0; }
+EOF
+if { (eval echo configure:2203: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_in6addrsz=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_in6addrsz=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_in6addrsz" 1>&6
+ if test $ac_cv_in6addrsz = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_IN6ADDRSZ 1
+EOF
+
+ else
+ ac_cv_addrsz=no
+ fi
+
+if test "$ac_cv_addrsz" = no; then
+ missing_includes=yes
+fi
+
+
+ echo $ac_n "checking for RES_USE_INET6""... $ac_c" 1>&6
+echo "configure:2231: checking for RES_USE_INET6" >&5
+ if eval "test \"`echo '$''{'ac_cv_res_inet6'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2236 "configure"
+#include "confdefs.h"
+
+# include <sys/types.h>
+# include <netinet/in.h>
+# include <resolv.h>
+int main() {
+int a = RES_USE_INET6
+; return 0; }
+EOF
+if { (eval echo configure:2246: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_res_inet6=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_res_inet6=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_res_inet6" 1>&6
+ if test $ac_cv_res_inet6 = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_RES_USE_INET6 1
+EOF
+
+ fi
+
+if test "$ac_cv_res_inet6" = no; then
+ missing_includes=yes
+fi
+
+
+ echo $ac_n "checking for AAAA""... $ac_c" 1>&6
+echo "configure:2272: checking for AAAA" >&5
+ if eval "test \"`echo '$''{'ac_cv_aaaa'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2277 "configure"
+#include "confdefs.h"
+
+# include <arpa/nameser.h>
+int main() {
+int a = T_AAAA
+; return 0; }
+EOF
+if { (eval echo configure:2285: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_aaaa=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_aaaa=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_aaaa" 1>&6
+ if test $ac_cv_aaaa = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_AAAA 1
+EOF
+
+ fi
+
+if test "$ac_cv_aaaa" = no; then
+ cat >> confdefs.h <<\EOF
+#define T_AAAA 28
+EOF
+
+fi
+
+
+ echo $ac_n "checking for res_state_ext""... $ac_c" 1>&6
+echo "configure:2314: checking for res_state_ext" >&5
+ if eval "test \"`echo '$''{'ac_cv_res_state_ext'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2319 "configure"
+#include "confdefs.h"
+
+# include <sys/types.h>
+# include <netinet/in.h>
+# include <netinet6/in6.h>
+# include <resolv.h>
+int main() {
+struct __res_state_ext e
+; return 0; }
+EOF
+if { (eval echo configure:2330: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_res_state_ext=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_res_state_ext=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_res_state_ext" 1>&6
+ if test $ac_cv_res_state_ext = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_RES_STATE_EXT 1
+EOF
+
+ fi
+
+if test "$ac_cv_res_state_ext" = no; then
+ missing_includes=yes
+fi
+
+
+ echo $ac_n "checking for nsort in res_state""... $ac_c" 1>&6
+echo "configure:2356: checking for nsort in res_state" >&5
+ if eval "test \"`echo '$''{'ac_cv_res_state'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2361 "configure"
+#include "confdefs.h"
+
+# include <sys/types.h>
+# include <netinet/in.h>
+# include <netinet6/in6.h>
+# include <resolv.h>
+int main() {
+struct __res_state e; e.nsort = 0
+; return 0; }
+EOF
+if { (eval echo configure:2372: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_res_state=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_res_state=no
+fi
+rm -f conftest*
+fi
+
+ echo "$ac_t""$ac_cv_res_state" 1>&6
+ if test $ac_cv_res_state = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_NEW_RES_STATE 1
+EOF
+
+ fi
+
+
+if test "$missing_includes" = "yes"; then
+ CPPFLAGS="$CPPFLAGS -I./missing"
+fi
+
+
for ac_func in vfprintf strcasecmp
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1223: checking for $ac_func" >&5
+echo "configure:2401: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1228 "configure"
+#line 2406 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1247,7 +2425,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1251: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1268,7 +2446,7 @@ EOF
else
echo "$ac_t""no" 1>&6
-LIBOBJS="$LIBOBJS ${ac_func}.o"
+LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"
fi
done
@@ -1276,12 +2454,12 @@ done
for ac_func in ether_ntoa setlinebuf
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1280: checking for $ac_func" >&5
+echo "configure:2458: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1285 "configure"
+#line 2463 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1304,7 +2482,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2486: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1330,14 +2508,14 @@ done
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:1334: checking whether byte ordering is bigendian" >&5
+echo "configure:2512: checking whether byte ordering is bigendian" >&5
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat > conftest.$ac_ext <<EOF
-#line 1341 "configure"
+#line 2519 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -1348,11 +2526,11 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:1352: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2530: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat > conftest.$ac_ext <<EOF
-#line 1356 "configure"
+#line 2534 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -1363,7 +2541,7 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:1367: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2545: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
@@ -1383,7 +2561,7 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1387 "configure"
+#line 2565 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
@@ -1396,7 +2574,7 @@ main () {
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
-if { (eval echo configure:1400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_bigendian=no
else
@@ -1421,7 +2599,7 @@ fi
echo $ac_n "checking for main in -ldnet""... $ac_c" 1>&6
-echo "configure:1425: checking for main in -ldnet" >&5
+echo "configure:2603: checking for main in -ldnet" >&5
ac_lib_var=`echo dnet'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1429,14 +2607,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldnet $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1433 "configure"
+#line 2611 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:1440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1464,7 +2642,7 @@ else
fi
echo $ac_n "checking for main in -lrpc""... $ac_c" 1>&6
-echo "configure:1468: checking for main in -lrpc" >&5
+echo "configure:2646: checking for main in -lrpc" >&5
ac_lib_var=`echo rpc'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1472,14 +2650,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lrpc $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1476 "configure"
+#line 2654 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:1483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1506,15 +2684,102 @@ else
echo "$ac_t""no" 1>&6
fi
+echo $ac_n "checking for uncompress in -lz""... $ac_c" 1>&6
+echo "configure:2689: checking for uncompress in -lz" >&5
+ac_lib_var=`echo z'_'uncompress | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lz $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2697 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char uncompress();
+
+int main() {
+uncompress()
+; return 0; }
+EOF
+if { (eval echo configure:2708: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo z | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lz $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+for ac_hdr in zlib.h netinet6/ipcomp.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:2739: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2744 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2749: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1513: checking return type of signal handlers" >&5
+echo "configure:2778: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1518 "configure"
+#line 2783 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -1531,7 +2796,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:1535: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2800: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -1573,12 +2838,12 @@ EOF
for ac_func in sigset
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1577: checking for $ac_func" >&5
+echo "configure:2842: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1582 "configure"
+#line 2847 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1601,7 +2866,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1629,12 +2894,12 @@ done
for ac_func in sigaction
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1633: checking for $ac_func" >&5
+echo "configure:2898: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1638 "configure"
+#line 2903 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1657,7 +2922,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1689,12 +2954,12 @@ done
# Most operating systems have gethostbyname() in the default searched
# libraries (i.e. libc):
echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:1693: checking for gethostbyname" >&5
+echo "configure:2958: checking for gethostbyname" >&5
if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1698 "configure"
+#line 2963 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char gethostbyname(); below. */
@@ -1717,7 +2982,7 @@ gethostbyname();
; return 0; }
EOF
-if { (eval echo configure:1721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_gethostbyname=yes"
else
@@ -1736,7 +3001,7 @@ else
echo "$ac_t""no" 1>&6
# Some OSes (eg. Solaris) place it in libnsl:
echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:1740: checking for gethostbyname in -lnsl" >&5
+echo "configure:3005: checking for gethostbyname in -lnsl" >&5
ac_lib_var=`echo nsl'_'gethostbyname'_' | sed 'y%./+- %__p__%'`
if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1744,7 +3009,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1748 "configure"
+#line 3013 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1755,7 +3020,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:1759: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lbl_lib_$ac_lib_var=yes"
else
@@ -1782,7 +3047,7 @@ else
echo "$ac_t""no" 1>&6
# Some strange OSes (SINIX) have it in libsocket:
echo $ac_n "checking for gethostbyname in -lsocket""... $ac_c" 1>&6
-echo "configure:1786: checking for gethostbyname in -lsocket" >&5
+echo "configure:3051: checking for gethostbyname in -lsocket" >&5
ac_lib_var=`echo socket'_'gethostbyname'_' | sed 'y%./+- %__p__%'`
if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1790,7 +3055,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1794 "configure"
+#line 3059 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1801,7 +3066,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:1805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lbl_lib_$ac_lib_var=yes"
else
@@ -1830,7 +3095,7 @@ else
# AC_CHECK_LIB's API is essentially broken so the
# following ugliness is necessary:
echo $ac_n "checking for gethostbyname in -lsocket""... $ac_c" 1>&6
-echo "configure:1834: checking for gethostbyname in -lsocket" >&5
+echo "configure:3099: checking for gethostbyname in -lsocket" >&5
ac_lib_var=`echo socket'_'gethostbyname'_'-lnsl | sed 'y%./+- %__p__%'`
if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1838,7 +3103,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket -lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1842 "configure"
+#line 3107 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1849,7 +3114,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:1853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lbl_lib_$ac_lib_var=yes"
else
@@ -1868,7 +3133,7 @@ if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for gethostbyname in -lresolv""... $ac_c" 1>&6
-echo "configure:1872: checking for gethostbyname in -lresolv" >&5
+echo "configure:3137: checking for gethostbyname in -lresolv" >&5
ac_lib_var=`echo resolv'_'gethostbyname | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1876,7 +3141,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lresolv $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1880 "configure"
+#line 3145 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1887,7 +3152,7 @@ int main() {
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:1891: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3156: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1923,12 +3188,12 @@ fi
fi
echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:1927: checking for socket" >&5
+echo "configure:3192: checking for socket" >&5
if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1932 "configure"
+#line 3197 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char socket(); below. */
@@ -1951,7 +3216,7 @@ socket();
; return 0; }
EOF
-if { (eval echo configure:1955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3220: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_socket=yes"
else
@@ -1969,7 +3234,7 @@ if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:1973: checking for socket in -lsocket" >&5
+echo "configure:3238: checking for socket in -lsocket" >&5
ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1977,7 +3242,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1981 "configure"
+#line 3246 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1988,7 +3253,7 @@ int main() {
socket()
; return 0; }
EOF
-if { (eval echo configure:1992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3257: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2014,7 +3279,7 @@ EOF
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:2018: checking for socket in -lsocket" >&5
+echo "configure:3283: checking for socket in -lsocket" >&5
ac_lib_var=`echo socket'_'socket'_'-lnsl | sed 'y%./+- %__p__%'`
if eval "test \"`echo '$''{'ac_cv_lbl_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2022,7 +3287,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket -lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2026 "configure"
+#line 3291 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2033,7 +3298,7 @@ int main() {
socket()
; return 0; }
EOF
-if { (eval echo configure:2037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lbl_lib_$ac_lib_var=yes"
else
@@ -2059,7 +3324,7 @@ fi
# DLPI needs putmsg under HPUX so test for -lstr while we're at it
echo $ac_n "checking for putmsg in -lstr""... $ac_c" 1>&6
-echo "configure:2063: checking for putmsg in -lstr" >&5
+echo "configure:3328: checking for putmsg in -lstr" >&5
ac_lib_var=`echo str'_'putmsg | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2067,7 +3332,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lstr $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2071 "configure"
+#line 3336 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2078,7 +3343,7 @@ int main() {
putmsg()
; return 0; }
EOF
-if { (eval echo configure:2082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3347: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2113,12 +3378,12 @@ fi
for ac_func in pfopen
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2117: checking for $ac_func" >&5
+echo "configure:3382: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2122 "configure"
+#line 3387 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2141,7 +3406,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2145: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2171,7 +3436,7 @@ done
fi
fi
echo $ac_n "checking for local pcap library""... $ac_c" 1>&6
-echo "configure:2175: checking for local pcap library" >&5
+echo "configure:3440: checking for local pcap library" >&5
libpcap=FAIL
lastdir=FAIL
places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
@@ -2182,7 +3447,7 @@ echo "configure:2175: checking for local pcap library" >&5
continue;
fi
lastdir=$dir
- if test -r $dir/libpcap.a ; then
+ if test -r $dir/pcap.c ; then
libpcap=$dir/libpcap.a
d=$dir
fi
@@ -2190,7 +3455,7 @@ echo "configure:2175: checking for local pcap library" >&5
if test $libpcap = FAIL ; then
echo "$ac_t""not found" 1>&6
echo $ac_n "checking for main in -lpcap""... $ac_c" 1>&6
-echo "configure:2194: checking for main in -lpcap" >&5
+echo "configure:3459: checking for main in -lpcap" >&5
ac_lib_var=`echo pcap'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2198,14 +3463,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpcap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2202 "configure"
+#line 3467 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
-if { (eval echo configure:2209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2230,13 +3495,7 @@ fi
fi
else
V_PCAPDEP=$libpcap
- if test -r $d/pcap.h; then
- V_INCLS="-I$d $V_INCLS"
- elif test -r $srcdir/../libpcap/pcap.h; then
- V_INCLS="-I$d -I$srcdir/../libpcap $V_INCLS"
- else
- { echo "configure: error: cannot find pcap.h" 1>&2; exit 1; }
- fi
+ V_INCLS="-I$d $V_INCLS"
echo "$ac_t""$libpcap" 1>&6
fi
LIBS="$libpcap $LIBS"
@@ -2245,7 +3504,7 @@ fi
aix*)
pseexe="/lib/pse.exp"
echo $ac_n "checking for $pseexe""... $ac_c" 1>&6
-echo "configure:2249: checking for $pseexe" >&5
+echo "configure:3508: checking for $pseexe" >&5
if test -f $pseexe ; then
echo "$ac_t""yes" 1>&6
LIBS="$LIBS -I:$pseexe"
@@ -2292,12 +3551,12 @@ if test -f /dev/bpf0 ; then
fi
echo $ac_n "checking for int32_t using $CC""... $ac_c" 1>&6
-echo "configure:2296: checking for int32_t using $CC" >&5
+echo "configure:3555: checking for int32_t using $CC" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_have_int32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2301 "configure"
+#line 3560 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -2310,7 +3569,7 @@ int main() {
int32_t i
; return 0; }
EOF
-if { (eval echo configure:2314: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3573: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_int32_t=yes
else
@@ -2330,12 +3589,12 @@ EOF
fi
echo $ac_n "checking for u_int32_t using $CC""... $ac_c" 1>&6
-echo "configure:2334: checking for u_int32_t using $CC" >&5
+echo "configure:3593: checking for u_int32_t using $CC" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2339 "configure"
+#line 3598 "configure"
#include "confdefs.h"
# include "confdefs.h"
@@ -2348,7 +3607,7 @@ int main() {
u_int32_t i
; return 0; }
EOF
-if { (eval echo configure:2352: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3611: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_have_u_int32_t=yes
else
@@ -2408,12 +3667,12 @@ EOF
fi
echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
-echo "configure:2412: checking if sockaddr struct has sa_len member" >&5
+echo "configure:3671: checking if sockaddr struct has sa_len member" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2417 "configure"
+#line 3676 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2422,7 +3681,7 @@ int main() {
u_int i = sizeof(((struct sockaddr *)0)->sa_len)
; return 0; }
EOF
-if { (eval echo configure:2426: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_lbl_sockaddr_has_sa_len=yes
else
@@ -2443,14 +3702,14 @@ EOF
fi
echo $ac_n "checking if ether_header uses ether_addr structs""... $ac_c" 1>&6
-echo "configure:2447: checking if ether_header uses ether_addr structs" >&5
+echo "configure:3706: checking if ether_header uses ether_addr structs" >&5
if eval "test \"`echo '$''{'ac_cv_ether_header_has_ea'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
LBL_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $V_INCLS"
cat > conftest.$ac_ext <<EOF
-#line 2454 "configure"
+#line 3713 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2468,7 +3727,7 @@ u_int i =
sizeof(((struct ether_header *)0)->ether_dhost.ether_addr_octet)
; return 0; }
EOF
-if { (eval echo configure:2472: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3731: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_ether_header_has_ea=yes
else
@@ -2490,14 +3749,14 @@ EOF
fi
echo $ac_n "checking if ether_arp uses ether_addr structs""... $ac_c" 1>&6
-echo "configure:2494: checking if ether_arp uses ether_addr structs" >&5
+echo "configure:3753: checking if ether_arp uses ether_addr structs" >&5
if eval "test \"`echo '$''{'ac_cv_ether_arp_has_ea'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
LBL_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $V_INCLS"
cat > conftest.$ac_ext <<EOF
-#line 2501 "configure"
+#line 3760 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2515,7 +3774,7 @@ u_int i =
sizeof(((struct ether_arp *)0)->arp_sha.ether_addr_octet)
; return 0; }
EOF
-if { (eval echo configure:2519: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3778: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_ether_arp_has_ea=yes
else
@@ -2537,14 +3796,14 @@ EOF
fi
echo $ac_n "checking if ether_arp uses erp_xsha member""... $ac_c" 1>&6
-echo "configure:2541: checking if ether_arp uses erp_xsha member" >&5
+echo "configure:3800: checking if ether_arp uses erp_xsha member" >&5
if eval "test \"`echo '$''{'ac_cv_struct_ether_arp_x'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
LBL_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $V_INCLS"
cat > conftest.$ac_ext <<EOF
-#line 2548 "configure"
+#line 3807 "configure"
#include "confdefs.h"
# include <sys/types.h>
@@ -2561,7 +3820,7 @@ int main() {
u_int i = sizeof( ((struct ether_arp *)0)->arp_xsha)
; return 0; }
EOF
-if { (eval echo configure:2565: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3824: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_ether_arp_x=yes
else
@@ -2583,7 +3842,7 @@ EOF
fi
echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
-echo "configure:2587: checking if unaligned accesses fail" >&5
+echo "configure:3846: checking if unaligned accesses fail" >&5
if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2645,15 +3904,192 @@ EOF
fi
-if test -r ${srcdir}/lbl/gnuc.h ; then
+echo $ac_n "checking for SSLeay""... $ac_c" 1>&6
+echo "configure:3909: checking for SSLeay" >&5
+ac_cv_ssleay_path=no
+incdir=no
+for dir in /usr/local /usr/local/ssl /usr/pkg; do
+ if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then
+ ac_cv_ssleay_path=$dir
+ fi
+ if test -d $dir/include -a -f $dir/include/des.h; then
+ incdir="-I$dir/include"
+ else
+ if test -d $dir/include/ssleay -a -f $dir/include/ssleay/des.h; then
+ incdir="-I$dir/include/ssleay"
+ elif test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
+ incdir="-I$dir/include -I$dir/include/openssl"
+ fi
+ fi
+ if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
+ break;
+ else
+ ac_cv_ssleay_path=no
+ incdir=no
+ fi
+done
+echo "$ac_t""$ac_cv_ssleay_path" 1>&6
+if test "$ac_cv_ssleay_path" != no; then
+ V_INCLS="$V_INCLS $incdir"
+ LIBS="$LIBS -L$dir/lib"
+ echo $ac_n "checking for des_cbc_encrypt in -lcrypto""... $ac_c" 1>&6
+echo "configure:3937: checking for des_cbc_encrypt in -lcrypto" >&5
+ac_lib_var=`echo crypto'_'des_cbc_encrypt | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lcrypto $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 3945 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char des_cbc_encrypt();
+
+int main() {
+des_cbc_encrypt()
+; return 0; }
+EOF
+if { (eval echo configure:3956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo crypto | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lcrypto $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ cat >> confdefs.h <<\EOF
+#define CRYPTO 1
+EOF
+
+
+ bak_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS $V_INCLS"
+ for ac_hdr in cast.h rc5.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:3994: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3999 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:4004: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+ if test "$ac_cv_header_cast_h" = "yes"; then
+ echo $ac_n "checking for buggy CAST128""... $ac_c" 1>&6
+echo "configure:4033: checking for buggy CAST128" >&5
+ if test "$cross_compiling" = yes; then
+ buggy_cast128="cross-compiling, assume yes"
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4038 "configure"
+#include "confdefs.h"
+
+#include <cast.h>
+main()
+{
+ unsigned char key[] = {0x01,0x23,0x45,0x67,0x12};
+ unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
+ unsigned char out[sizeof(in)];
+ unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E};
+ CAST_KEY ks;
+ CAST_set_key(&ks, sizeof(key), key);
+ CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT);
+ if (memcmp(out, ok, sizeof(ok)) != 0)
+ return 0;
+ else
+ return 1;
+}
+EOF
+if { (eval echo configure:4057: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ buggy_cast128=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ buggy_cast128=no
+fi
+rm -fr conftest*
+fi
+
+ echo "$ac_t""$buggy_cast128" 1>&6
+ if test "$buggy_cast128" != no; then
+ echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine."
+ echo "disabling CAST128 support."
+ cat >> confdefs.h <<\EOF
+#define HAVE_BUGGY_CAST128 1
+EOF
+
+ fi
+ fi
+
+ CPPFLAGS=$bak_CPPFLAGS
+fi
+
+if test "${srcdir}" = "." ; then
+ srcdirprefix=""
+else
+ srcdirprefix="./"
+fi
+
+if test -r ${srcdirprefix}lbl/gnuc.h ; then
rm -f gnuc.h
- ln -s ${srcdir}/lbl/gnuc.h gnuc.h
+ ln -s ${srcdirprefix}lbl/gnuc.h gnuc.h
fi
-rm -f bpf_filter.c
-ln -s ${srcdir}/bpf/net/bpf_filter.c bpf_filter.c
-rm -f net
-ln -s ${srcdir}/bpf/net net
@@ -2667,28 +4103,30 @@ ln -s ${srcdir}/bpf/net net
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:2675: checking for a BSD compatible install" >&5
+echo "configure:4112: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
for ac_dir in $PATH; do
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
- for ac_prog in ginstall installbsd scoinst install; do
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
- # OSF/1 installbsd also uses dspmsg, but is usable.
:
else
ac_cv_path_install="$ac_dir/$ac_prog -c"
@@ -2718,6 +4156,8 @@ echo "$ac_t""$INSTALL" 1>&6
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
@@ -2744,7 +4184,7 @@ EOF
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(set) 2>&1 |
- case `(ac_space=' '; set) 2>&1` in
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote substitution
# turns \\\\ into \\, and sed turns \\ into \).
@@ -2823,7 +4263,7 @@ do
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.12"
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
@@ -2843,9 +4283,11 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
$ac_vpsub
$extrasub
+s%@SHELL@%$SHELL%g
s%@CFLAGS@%$CFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
s%@DEFS@%$DEFS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@LIBS@%$LIBS%g
@@ -2887,7 +4329,9 @@ s%@V_CCOPT@%$V_CCOPT%g
s%@V_GROUP@%$V_GROUP%g
s%@V_INCLS@%$V_INCLS%g
s%@V_PCAPDEP@%$V_PCAPDEP%g
+s%@LOCALSRC@%$LOCALSRC%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
CEOF
diff --git a/configure.in b/configure.in
index 7aee6c5e..eb1694e3 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.73 1999-10-17 21:37:10 mcr Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.74 1999-10-30 05:11:08 itojun Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@@ -32,8 +32,7 @@ linux*)
if test $ac_cv_linux_vers -lt 2 ; then
AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
fi
-dnl AC_DEFINE(HAVE_NET_SLIP_H)
-dnl this is not the case on 2.2.x, we need a better way of figuring this out
+ AC_DEFINE(HAVE_NET_SLIP_H)
;;
*)
@@ -41,6 +40,350 @@ dnl this is not the case on 2.2.x, we need a better way of figuring this out
;;
esac
+CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len"
+AC_MSG_CHECKING([whether to enable ipv6])
+AC_ARG_ENABLE(ipv6,
+[ --enable-ipv6 Enable ipv6 (with ipv4) support
+ --disable-ipv6 Disable ipv6 support],
+[ case "$enableval" in
+ no)
+ AC_MSG_RESULT(no)
+ ipv6=no
+ ;;
+ *) AC_MSG_RESULT(yes)
+ AC_DEFINE(ENABLE_IPV6)
+ LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
+ AC_DEFINE(INET6)
+ ipv6=yes
+ ;;
+ esac ],
+
+ AC_TRY_RUN([ /* AF_INET6 avalable check */
+#include <sys/types.h>
+#include <sys/socket.h>
+main()
+{
+ exit(0);
+ if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
+ exit(1);
+ else
+ exit(0);
+}
+],
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(ENABLE_IPV6)
+ LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
+ AC_DEFINE(INET6)
+ ipv6=yes,
+ AC_MSG_RESULT(no)
+ ipv6=no,
+ AC_MSG_RESULT(no)
+ ipv6=no
+))
+
+ipv6type=unknown
+ipv6lib=none
+ipv6trylibc=no
+
+if test "$ipv6" = "yes"; then
+ AC_MSG_CHECKING([ipv6 stack type])
+ for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
+ case $i in
+ inria)
+ dnl http://www.kame.net/
+ AC_EGREP_CPP(yes, [dnl
+#include <netinet/in.h>
+#ifdef IPV6_INRIA_VERSION
+yes
+#endif],
+ [ipv6type=$i;
+ CFLAGS="-DINET6 $CFLAGS"])
+ ;;
+ kame)
+ dnl http://www.kame.net/
+ AC_EGREP_CPP(yes, [dnl
+#include <netinet/in.h>
+#ifdef __KAME__
+yes
+#endif],
+ [ipv6type=$i;
+ ipv6lib=inet6;
+ ipv6libdir=/usr/local/v6/lib;
+ ipv6trylibc=yes;
+ CFLAGS="-DINET6 $CFLAGS"])
+ ;;
+ linux-glibc)
+ dnl http://www.v6.linux.or.jp/
+ AC_EGREP_CPP(yes, [dnl
+#include <features.h>
+#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
+yes
+#endif],
+ [ipv6type=$i;
+ CFLAGS="-DINET6 $CFLAGS"])
+ ;;
+ linux-libinet6)
+ dnl http://www.v6.linux.or.jp/
+ if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
+ ipv6type=$i
+ ipv6lib=inet6
+ ipv6libdir=/usr/inet6/lib
+ ipv6trylibc=yes;
+ CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
+ fi
+ ;;
+ toshiba)
+ AC_EGREP_CPP(yes, [dnl
+#include <sys/param.h>
+#ifdef _TOSHIBA_INET6
+yes
+#endif],
+ [ipv6type=$i;
+ ipv6lib=inet6;
+ ipv6libdir=/usr/local/v6/lib;
+ CFLAGS="-DINET6 $CFLAGS"])
+ ;;
+ v6d)
+ AC_EGREP_CPP(yes, [dnl
+#include </usr/local/v6/include/sys/v6config.h>
+#ifdef __V6D__
+yes
+#endif],
+ [ipv6type=$i;
+ ipv6lib=v6;
+ ipv6libdir=/usr/local/v6/lib;
+ CFLAGS="-I/usr/local/v6/include $CFLAGS"])
+ ;;
+ zeta)
+ AC_EGREP_CPP(yes, [dnl
+#include <sys/param.h>
+#ifdef _ZETA_MINAMI_INET6
+yes
+#endif],
+ [ipv6type=$i;
+ ipv6lib=inet6;
+ ipv6libdir=/usr/local/v6/lib;
+ CFLAGS="-DINET6 $CFLAGS"])
+ ;;
+ esac
+ if test "$ipv6type" != "unknown"; then
+ break
+ fi
+ done
+ AC_MSG_RESULT($ipv6type)
+fi
+
+if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
+ if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
+ LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
+ echo "You have $ipv6lib library, using it"
+ else
+ if test "$ipv6trylibc" = "yes"; then
+ echo "You do not have $ipv6lib library, using libc"
+ else
+ echo 'Fatal: no $ipv6lib library found. cannot continue.'
+ echo "You need to fetch lib$ipv6lib.a from appropriate"
+ echo 'ipv6 kit and compile beforehand.'
+ exit 1
+ fi
+ fi
+fi
+
+
+AC_MSG_CHECKING(getaddrinfo bug)
+AC_TRY_RUN([
+#include <sys/types.h>
+#include <netdb.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+main()
+{
+ int passive, gaierr, inet4 = 0, inet6 = 0;
+ struct addrinfo hints, *ai, *aitop;
+ char straddr[INET6_ADDRSTRLEN], strport[16];
+
+ for (passive = 0; passive <= 1; passive++) {
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_flags = passive ? AI_PASSIVE : 0;
+ hints.ai_socktype = SOCK_STREAM;
+ if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
+ (void)gai_strerror(gaierr);
+ goto bad;
+ }
+ for (ai = aitop; ai; ai = ai->ai_next) {
+ if (ai->ai_addr == NULL ||
+ ai->ai_addrlen == 0 ||
+ getnameinfo(ai->ai_addr, ai->ai_addrlen,
+ straddr, sizeof(straddr), strport, sizeof(strport),
+ NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
+ goto bad;
+ }
+ switch (ai->ai_family) {
+ case AF_INET:
+ if (strcmp(strport, "54321") != 0) {
+ goto bad;
+ }
+ if (passive) {
+ if (strcmp(straddr, "0.0.0.0") != 0) {
+ goto bad;
+ }
+ } else {
+ if (strcmp(straddr, "127.0.0.1") != 0) {
+ goto bad;
+ }
+ }
+ inet4++;
+ break;
+ case AF_INET6:
+ if (strcmp(strport, "54321") != 0) {
+ goto bad;
+ }
+ if (passive) {
+ if (strcmp(straddr, "::") != 0) {
+ goto bad;
+ }
+ } else {
+ if (strcmp(straddr, "::1") != 0) {
+ goto bad;
+ }
+ }
+ inet6++;
+ break;
+ case AF_UNSPEC:
+ goto bad;
+ break;
+#ifdef AF_UNIX
+ case AF_UNIX:
+#else
+#ifdef AF_LOCAL
+ case AF_LOCAL:
+#endif
+#endif
+ default:
+ /* another family support? */
+ break;
+ }
+ }
+ }
+
+ if (inet6 != 2 || inet4 != 2)
+ goto bad;
+
+ if (aitop)
+ freeaddrinfo(aitop);
+ exit(0);
+
+ bad:
+ if (aitop)
+ freeaddrinfo(aitop);
+ exit(1);
+}
+],
+AC_MSG_RESULT(good)
+buggygetaddrinfo=no,
+AC_MSG_RESULT(buggy)
+buggygetaddrinfo=yes,
+AC_MSG_RESULT(buggy)
+buggygetaddrinfo=yes)
+
+if test "$buggygetaddrinfo" = "yes"; then
+ if test "$ipv6" = "yes" -a "$ipv6type" != "linux"; then
+ echo 'Fatal: You must get working getaddrinfo() function.'
+ echo ' or you can specify "--disable-ipv6"'.
+ exit 1
+ elif test "$ipv6type" = "linux"; then
+ echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
+ echo ' Better upgreade your system library to newest version'
+ echo ' of GNU C library (aka glibc).'
+ fi
+fi
+AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
+
+dnl portability macros for getaddrinfo/getnameinfo
+dnl
+dnl Check for sa_len
+AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
+if test "$ac_cv_sockaddr_has_sa_len" = no; then
+ missing_includes=yes
+fi
+
+dnl
+dnl check __P macro
+AC_CHECK_PORTABLE_PROTO(ac_cv_portable_proto)
+if test "$ac_cv_portable_proto" = no; then
+ missing_includes=yes
+fi
+
+dnl
+dnl check sizeof basic types
+AC_CHECK_SIZEOF(char)
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+
+dnl
+dnl Checks for u_intXX_t
+AC_CHECK_BITTYPES(ac_cv_bittypes)
+if test "$ac_cv_bittypes" = no; then
+ missing_includes=yes
+fi
+
+dnl
+dnl Checks for addrinfo structure
+AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
+if test "$ac_cv_addrinfo" = no; then
+ missing_includes=yes
+fi
+
+dnl
+dnl Checks for sockaddr_storage structure
+AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
+if test "$ac_cv_sa_storage" = no; then
+ missing_includes=yes
+fi
+
+dnl
+dnl Checks for IN[6]ADDRSZ
+AC_CHECK_ADDRSZ(ac_cv_addrsz)
+if test "$ac_cv_addrsz" = no; then
+ missing_includes=yes
+fi
+
+dnl
+dnl Checks for RES_USE_INET6
+AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
+if test "$ac_cv_res_inet6" = no; then
+ missing_includes=yes
+fi
+
+dnl
+dnl Checks for AAAA
+AC_CHECK_AAAA(ac_cv_aaaa)
+if test "$ac_cv_aaaa" = no; then
+ AC_DEFINE(T_AAAA, 28)
+fi
+
+dnl
+dnl Checks for res_state_ext structure
+AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
+if test "$ac_cv_res_state_ext" = no; then
+ missing_includes=yes
+fi
+
+dnl
+dnl Checks if res_state structure has nsort member.
+AC_STRUCT_RES_STATE(ac_cv_res_state)
+
+dnl
+dnl set additional include path if necessary
+if test "$missing_includes" = "yes"; then
+ CPPFLAGS="$CPPFLAGS -I./missing"
+fi
+
+
AC_REPLACE_FUNCS(vfprintf strcasecmp)
AC_CHECK_FUNCS(ether_ntoa setlinebuf)
@@ -49,6 +392,8 @@ AC_C_BIGENDIAN
AC_CHECK_LIB(dnet, main)
AC_CHECK_LIB(rpc, main)
+AC_CHECK_LIB(z, uncompress)
+AC_CHECK_HEADERS(zlib.h netinet6/ipcomp.h)
AC_LBL_TYPE_SIGNAL
@@ -171,20 +516,89 @@ fi
AC_LBL_UNALIGNED_ACCESS
-if test -r ${srcdir}/lbl/gnuc.h ; then
- rm -f gnuc.h
- ln -s ${srcdir}/lbl/gnuc.h gnuc.h
+AC_MSG_CHECKING(for SSLeay)
+ac_cv_ssleay_path=no
+incdir=no
+for dir in /usr/local /usr/local/ssl /usr/pkg; do
+ if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then
+ ac_cv_ssleay_path=$dir
+ fi
+ if test -d $dir/include -a -f $dir/include/des.h; then
+ incdir="-I$dir/include"
+ else
+ if test -d $dir/include/ssleay -a -f $dir/include/ssleay/des.h; then
+ incdir="-I$dir/include/ssleay"
+ elif test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
+ incdir="-I$dir/include -I$dir/include/openssl"
+ fi
+ fi
+ if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
+ break;
+ else
+ ac_cv_ssleay_path=no
+ incdir=no
+ fi
+done
+AC_MSG_RESULT($ac_cv_ssleay_path)
+if test "$ac_cv_ssleay_path" != no; then
+ V_INCLS="$V_INCLS $incdir"
+ LIBS="$LIBS -L$dir/lib"
+ AC_CHECK_LIB(crypto, des_cbc_encrypt)
+ AC_DEFINE(CRYPTO)
+
+ bak_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS $V_INCLS"
+ AC_CHECK_HEADERS(cast.h rc5.h)
+
+ if test "$ac_cv_header_cast_h" = "yes"; then
+ AC_MSG_CHECKING(for buggy CAST128)
+ AC_TRY_RUN(dnl
+[
+#include <cast.h>
+main()
+{
+ unsigned char key[] = {0x01,0x23,0x45,0x67,0x12};
+ unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
+ unsigned char out[sizeof(in)];
+ unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E};
+ CAST_KEY ks;
+ CAST_set_key(&ks, sizeof(key), key);
+ CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT);
+ if (memcmp(out, ok, sizeof(ok)) != 0)
+ return 0;
+ else
+ return 1;
+}],
+ [buggy_cast128=yes],
+ [buggy_cast128=no],
+ [buggy_cast128="cross-compiling, assume yes"])
+ AC_MSG_RESULT($buggy_cast128)
+ if test "$buggy_cast128" != no; then
+ echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine."
+ echo "disabling CAST128 support."
+ AC_DEFINE(HAVE_BUGGY_CAST128)
+ fi
+ fi
+
+ CPPFLAGS=$bak_CPPFLAGS
+fi
+
+if test "${srcdir}" = "." ; then
+ srcdirprefix=""
+else
+ srcdirprefix="./"
fi
-rm -f bpf_filter.c
-ln -s ${srcdir}/bpf/net/bpf_filter.c bpf_filter.c
-rm -f net
-ln -s ${srcdir}/bpf/net net
+if test -r ${srcdirprefix}lbl/gnuc.h ; then
+ rm -f gnuc.h
+ ln -s ${srcdirprefix}lbl/gnuc.h gnuc.h
+fi
AC_SUBST(V_CCOPT)
AC_SUBST(V_GROUP)
AC_SUBST(V_INCLS)
AC_SUBST(V_PCAPDEP)
+AC_SUBST(LOCALSRC)
AC_PROG_INSTALL
diff --git a/dhcp6.h b/dhcp6.h
new file mode 100644
index 00000000..161796f9
--- /dev/null
+++ b/dhcp6.h
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 1998 and 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * draft-ietf-dhc-dhcpv6-14
+ */
+
+#ifndef __DHCP6_H_DEFINED
+#define __DHCP6_H_DEFINED
+
+/* Error Values */
+#define DH6ERR_FAILURE 16
+#define DH6ERR_AUTHFAIL 17
+#define DH6ERR_POORLYFORMED 18
+#define DH6ERR_UNAVAIL 19
+#define DH6ERR_NOBINDING 20
+#define DH6ERR_INVALIDSOURCE 21
+#define DH6ERR_NOSERVER 23
+#define DH6ERR_ICMPERROR 64
+
+/* Message type */
+#define DH6_SOLICIT 1
+#define DH6_ADVERT 2
+#define DH6_REQUEST 3
+#define DH6_REPLY 4
+#define DH6_RELEASE 5
+#define DH6_RECONFIG 6
+
+/* Predefined addresses */
+#define DH6ADDR_ALLAGENT "ff02::1:2"
+#define DH6ADDR_ALLSERVER "ff05::1:3"
+#define DH6ADDR_ALLRELAY "ff05::1:4"
+#define DH6PORT_DOWNSTREAM "546"
+#define DH6PORT_UPSTREAM "547"
+
+/* Protocol constants */
+#define ADV_CLIENT_WAIT 2 /* sec */
+#define DEFAULT_SOLICIT_HOPCOUNT 4
+#define SERVER_MIN_ADV_DELAY 100 /* msec */
+#define SERVER_MAX_ADV_DELAY 1000 /* msec */
+#define REPLY_MSG_TIMEOUT 2 /* sec */
+#define REQUEST_MSG_MIN_RETRANS 10 /* retransmissions */
+#define RECONF_MSG_MIN_RETRANS 10 /* retransmissions */
+#define RECONF_MSG_RETRANS_INTERVAL 12 /* sec */
+#define RECONF_MMSG_MIN_RESP 2 /* sec */
+#define RECONF_MMSG_MAX_RESP 10 /* sec */
+#define RECONF_MULTICAST_REQUEST_WAIT 120 /* sec */
+#define MIN_SOLICIT_DELAY 1 /* sec */
+#define MAX_SOLICIT_DELAY 5 /* sec */
+#define XID_TIMEOUT 600 /* sec */
+
+/* DHCP6 base packet format */
+struct dhcp6_solicit {
+ u_int8_t dh6sol_msgtype; /* DH6_SOLICIT */
+ u_int8_t dh6sol_flags;
+#define DH6SOL_CLOSE 0x80
+ u_int8_t dh6sol_pad;
+ u_int8_t dh6sol_prefixsiz; /* prefix-size */
+ struct in6_addr dh6sol_cliaddr; /* client's lladdr */
+ struct in6_addr dh6sol_relayaddr; /* relay agent's lladdr */
+};
+
+/* NOTE: dhcpv6-12 and dhcpv6-13+n are not compatible at all */
+struct dhcp6_advert {
+ u_int8_t dh6adv_msgtype; /* DH6_ADVERT */
+ u_int8_t dh6adv_flags;
+#define DH6ADV_SERVPRESENT 0x80
+ u_int8_t dh6adv_pad;
+ u_int8_t dh6adv_pref;
+ struct in6_addr dh6adv_cliaddr; /* client's lladdr */
+ struct in6_addr dh6adv_relayaddr; /* relay agent's (non-ll) addr */
+ struct in6_addr dh6adv_serveraddr; /* server's addr */
+ /* extensions */
+};
+
+struct dhcp6_request {
+ u_int8_t dh6req_msgtype; /* DH6_REQUEST */
+ u_int8_t dh6req_flags;
+#define DH6REQ_CLOSE 0x80
+#define DH6REQ_SERVPRESENT 0x40
+#define DH6REQ_REBOOT 0x20
+ u_int16_t dh6req_xid; /* transaction-ID */
+ struct in6_addr dh6req_cliaddr; /* client's lladdr */
+ struct in6_addr dh6req_relayaddr; /* relay agent's (non-ll) addr */
+ /* struct in6_addr dh6req_serveraddr; optional: server's addr */
+ /* extensions */
+};
+
+struct dhcp6_reply {
+ u_int8_t dh6rep_msgtype; /* DH6_REPLY */
+ u_int8_t dh6rep_flagandstat;
+#define DH6REP_CLIPRESENT 0x80
+#define DH6REP_STATMASK 0x7f
+ u_int16_t dh6rep_xid; /* transaction-ID */
+ /* struct in6_addr dh6rep_cliaddr; optional: client's lladdr */
+ /* extensions */
+};
+
+struct dhcp6_release {
+ u_int8_t dh6rel_msgtype; /* DH6_RELEASE */
+ u_int8_t dh6rel_flags;
+#define DH6REL_DIRECT 0x80
+ u_int16_t dh6rel_xid; /* transaction-ID */
+ struct in6_addr dh6rel_cliaddr; /* client's lladdr */
+ struct in6_addr dh6rel_relayaddr; /* relay agent's (non-ll) addr */
+ struct in6_addr dh6rel_reladdr; /* server's addr to be released */
+ /* extensions */
+};
+
+struct dhcp6_reconfig {
+ u_int8_t dh6cfg_msgtype; /* DH6_RECONFIG */
+ u_int8_t dh6cfg_flags;
+#define DH6REP_NOREPLY 0x80
+ u_int16_t dh6cfg_xid; /* transaction-ID */
+ struct in6_addr dh6cfg_servaddr; /* server's addr */
+ /* extensions */
+};
+
+union dhcp6 {
+ u_int8_t dh6_msgtype;
+ struct dhcp6_solicit dh6_sol;
+ struct dhcp6_advert dh6_adv;
+ struct dhcp6_request dh6_req;
+ struct dhcp6_reply dh6_rep;
+ struct dhcp6_release dh6_rel;
+ struct dhcp6_reconfig dh6_cfg;
+};
+
+/* DHCP6 extension */
+struct dhcp6e_ipaddr {
+ u_int16_t dh6eip_type;
+ u_int16_t dh6eip_len;
+ u_int8_t dh6eip_status;
+#define DH6EX_IP_SUCCESS 0 /* request granted, no errors */
+#define DH6EX_IP_SECFAIL 18 /* Security parameters failed */
+#define DH6EX_IP_AAAAFAIL 20 /* AAAA Record Parameter Problem */
+#define DH6EX_IP_PTRFAIL 21 /* PTR Record Parameter Problem */
+#define DH6EX_IP_PARAMFAIL 22 /* Unable to honor required params */
+#define DH6EX_IP_DNSNAMEFAIL 23 /* DNS name string error */
+#define DH6EX_IP_NODYNDNS 24 /* dynDNS Not Implemented */
+#define DH6EX_IP_NOAUTHDNS 25 /* Authoritative DNS Server not found */
+#define DH6EX_IP_DNSFORMFAIL 33 /* DNS format error */
+#define DH6EX_IP_SERVFAIL 34 /* dynDNS unavailable at this time */
+#define DH6EX_IP_NXDOMAIN 35 /* name does not exist */
+#define DH6EX_IP_NOTIMP 36 /* DNS does not support the Opcode */
+#define DH6EX_IP_REFUSED 37 /* DNS refuses specified operation */
+#define DH6EX_IP_YXDOMAIN 38 /* name does not exist */
+#define DH6EX_IP_YXRRSET 39 /* RRset does not exist */
+#define DH6EX_IP_NXRRSET 40 /* RRset does not exist */
+#define DH6EX_IP_NOTAUTH 41 /* non authoritative name server */
+#define DH6EX_IP_NOTZONE 42 /* prerequisite out of zone */
+ u_int8_t dh6eip_flags;
+#define DH6EX_IP_CLIANTADDR 0x80 /* C: cliant's addr */
+#define DH6EX_IP_LIFETIME 0x40 /* L: preferred/valid lifetime */
+#define DH6EX_IP_FORCEOPTS 0x20 /* Q: options are mandatory */
+#define DH6EX_IP_AAAA 0x10 /* A: DNS dynamic update for AAAA */
+#define DH6EX_IP_PTR 0x08 /* P: DNS dynamic update for PTR*/
+ u_int8_t dh6eip_pad;
+ u_int8_t dh6eip_prefixlen;
+ /* struct in6_addr: client's address (if C bit = 1) */
+ /* u_int: preferred lifetime (if L bit = 1) */
+ /* u_int: valid lifetime (if L bit = 1) */
+ /* string: DNS name */
+};
+
+#endif /*__DHCP6_H_DEFINED*/
diff --git a/dhcp6opt.h b/dhcp6opt.h
new file mode 100644
index 00000000..a9177c64
--- /dev/null
+++ b/dhcp6opt.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 1998 and 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * draft-ietf-dhc-v6exts-11
+ */
+
+#ifndef __DHCP6OPT_H_DEFINED
+#define __DHCP6OPT_H_DEFINED
+
+#define OL6_N -1
+#define OL6_16N -2
+#define OL6_Z -3
+
+#define OT6_NONE 0
+#define OT6_V6 1
+#define OT6_STR 2
+#define OT6_NUM 3
+
+struct dhcp6_opt {
+ u_int code;
+ int len;
+ char *name;
+ int type;
+};
+
+/* index to parameters */
+#define DH6T_CLIENT_ADV_WAIT 1 /* milliseconds */
+#define DH6T_DEFAULT_SOLICIT_HOPCOUNT 2 /* times */
+#define DH6T_SERVER_MIN_ADV_DELAY 3 /* milliseconds */
+#define DH6T_SERVER_MAX_ADV_DELAY 4 /* milliseconds */
+#define DH6T_REQUEST_MSG_MIN_RETRANS 5 /* retransmissions */
+#define DH6T_REPLY_MSG_TIMEOUT 6 /* milliseconds */
+#define DH6T_REPLY_MSG_RETRANS_INTERVAL 7 /* milliseconds */
+#define DH6T_RECONF_MSG_TIMEOUT 8 /* milliseconds */
+#define DH6T_RECONF_MSG_MIN_RETRANS 9 /* retransmissions */
+#define DH6T_RECONF_MSG_RETRANS_INTERVAL 10 /* milliseconds */
+#define DH6T_RECONF_MMSG_MIN_RESP 11 /* milliseconds */
+#define DH6T_RECONF_MMSG_MAX_RESP 12 /* milliseconds */
+#define DH6T_MIN_SOLICIT_DELAY 13 /* milliseconds */
+#define DH6T_MAX_SOLICIT_DELAY 14 /* milliseconds */
+#define DH6T_XID_TIMEOUT 15 /* milliseconds */
+#define DH6T_RECONF_MULTICAST_REQUEST_WAIT 16 /* milliseconds */
+
+#if 0
+extern struct dhcp6_opt *dh6o_pad;
+extern struct dhcp6_opt *dh6o_end;
+extern int dhcp6_param[];
+extern void dhcp6opttab_init __P((void));
+extern struct dhcp6_opt *dhcp6opttab_byname __P((char *));
+extern struct dhcp6_opt *dhcp6opttab_bycode __P((u_int));
+#endif
+
+#endif /*__DHCP6OPT_H_DEFINED*/
diff --git a/interface.h b/interface.h
index e4534625..658f5918 100644
--- a/interface.h
+++ b/interface.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.108 1999-10-17 22:18:00 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.109 1999-10-30 05:11:09 itojun Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -41,11 +41,14 @@ extern int fflag; /* don't translate "foreign" IP address */
extern int nflag; /* leave addresses as numbers */
extern int Nflag; /* remove domains from printed host names */
extern int qflag; /* quick (shorter) output */
+extern int Rflag; /* print sequence # field in AH/ESP*/
extern int Sflag; /* print raw TCP sequence numbers */
extern int tflag; /* print packet arrival time */
extern int vflag; /* verbose */
extern int xflag; /* print packet in hex */
+extern char *espsecret;
+
extern int packettype; /* as specified by -T */
#define PT_VAT 1 /* Visual Audio Tool */
#define PT_WB 2 /* distributed White Board */
@@ -61,6 +64,7 @@ extern int packettype; /* as specified by -T */
#define max(a,b) ((b)>(a)?(b):(a))
#endif
+#ifndef INET6
/*
* The default snapshot length. This value allows most printers to print
* useful information while keeping the amount of unwanted data down.
@@ -68,6 +72,9 @@ extern int packettype; /* as specified by -T */
* 14 bytes of data (assuming no ip options).
*/
#define DEFAULT_SNAPLEN 68
+#else
+#define DEFAULT_SNAPLEN 96
+#endif
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
@@ -170,6 +177,7 @@ extern void arp_print(const u_char *, u_int, u_int);
extern void atalk_print(const u_char *, u_int);
extern void atm_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void bootp_print(const u_char *, u_int, u_short, u_short);
+extern void bgp_print(const u_char *, int);
extern void decnet_print(const u_char *, u_int, u_int);
extern void default_print(const u_char *, u_int);
extern void default_print_unaligned(const u_char *, u_int);
@@ -192,18 +200,39 @@ extern void ns_print(const u_char *, u_int);
extern void ntp_print(const u_char *, u_int);
extern void null_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void ospf_print(const u_char *, u_int, const u_char *);
+extern void igmp_pim_print(const u_char *, u_int);
+extern void mobile_print(const u_char *, u_int);
extern void pim_print(const u_char *, u_int);
extern void ppp_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void ppp_bsdos_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
+extern int vjc_print(register const char *, register u_int, u_short);
extern void raw_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void rip_print(const u_char *, u_int);
extern void sl_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void sl_bsdos_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
+extern void chdlc_if_print(u_char *, const struct pcap_pkthdr *,
+ const u_char *);
extern void snmp_print(const u_char *, u_int);
extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
extern void tcp_print(const u_char *, u_int, const u_char *);
extern void tftp_print(const u_char *, u_int);
extern void udp_print(const u_char *, u_int, const u_char *);
extern void wb_print(const void *, u_int);
+extern int ah_print(register const u_char *, register const u_char *);
+extern int esp_print(register const u_char *, register const u_char *, int *);
+extern void isakmp_print(const u_char *, u_int, const u_char *);
+extern int ipcomp_print(register const u_char *, register const u_char *, int *);
+#ifdef INET6
+extern void ip6_print(const u_char *, int);
+extern void ip6_opt_print(const u_char *, int);
+extern int hbhopt_print(const u_char *);
+extern int dstopt_print(const u_char *);
+extern int frag6_print(const u_char *, const u_char *);
+extern void icmp6_print(const u_char *, const u_char *);
+extern void ripng_print(const u_char *, int);
+extern int rt6_print(const u_char *, const u_char *);
+extern void ospf6_print(const u_char *, u_int);
+extern void dhcp6_print(const u_char *, u_int, u_short, u_short);
+#endif /*INET6*/
diff --git a/ipsec_doi.h b/ipsec_doi.h
new file mode 100644
index 00000000..55392a4d
--- /dev/null
+++ b/ipsec_doi.h
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/* YIPS @(#)$Id: ipsec_doi.h,v 1.1 1999-10-30 05:11:09 itojun Exp $ */
+
+/* refer to RFC 2407 */
+
+#if !defined(_IPSEC_DOI_H_)
+#define _IPSEC_DOI_H_
+
+#define IPSEC_DOI 1
+
+/* 4.2 IPSEC Situation Definition */
+#define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001
+#define IPSECDOI_SIT_SECRECY 0x00000002
+#define IPSECDOI_SIT_INTEGRITY 0x00000004
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+ /* 4.4.2 IPSEC ISAKMP Transform Values */
+#define IPSECDOI_PROTO_ISAKMP 1
+#define IPSECDOI_KEY_IKE 1
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPSEC_AH 2
+ /* 4.4.3 IPSEC AH Transform Values */
+#define IPSECDOI_AH_MD5 2
+#define IPSECDOI_AH_SHA 3
+#define IPSECDOI_AH_DES 4
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPSEC_ESP 3
+ /* 4.4.4 IPSEC ESP Transform Identifiers */
+#define IPSECDOI_ESP_DES_IV64 1
+#define IPSECDOI_ESP_DES 2
+#define IPSECDOI_ESP_3DES 3
+#define IPSECDOI_ESP_RC5 4
+#define IPSECDOI_ESP_IDEA 5
+#define IPSECDOI_ESP_CAST 6
+#define IPSECDOI_ESP_BLOWFISH 7
+#define IPSECDOI_ESP_3IDEA 8
+#define IPSECDOI_ESP_DES_IV32 9
+#define IPSECDOI_ESP_RC4 10
+#define IPSECDOI_ESP_NULL 11
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPCOMP 4
+ /* 4.4.5 IPSEC IPCOMP Transform Identifiers */
+#define IPSECDOI_IPCOMP_OUI 1
+#define IPSECDOI_IPCOMP_DEFLATE 2
+#define IPSECDOI_IPCOMP_LZS 3
+#define IPSECDOI_IPCOMP_V42BIS 4
+
+/* 4.5 IPSEC Security Association Attributes */
+#define IPSECDOI_ATTR_SA_LTYPE 1 /* B */
+#define IPSECDOI_ATTR_SA_LTYPE_DEFAULT 1
+#define IPSECDOI_ATTR_SA_LTYPE_SEC 1
+#define IPSECDOI_ATTR_SA_LTYPE_KB 2
+#define IPSECDOI_ATTR_SA_LDUR 2 /* V */
+#define IPSECDOI_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
+#define IPSECDOI_ATTR_GRP_DESC 3 /* B */
+#define IPSECDOI_ATTR_ENC_MODE 4 /* B */
+ /* default value: host dependent */
+#define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1
+#define IPSECDOI_ATTR_ENC_MODE_TRNS 2
+#define IPSECDOI_ATTR_AUTH 5 /* B */
+#define IPSECDOI_ATTR_AUTH_HMAC_MD5 1
+#define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2
+#define IPSECDOI_ATTR_AUTH_DES_MAC 3
+#define IPSECDOI_ATTR_AUTH_KPDK 4
+ /*
+ When negotiating ESP without authentication, the Auth
+ Algorithm attribute MUST NOT be included in the proposal.
+ When negotiating ESP without confidentiality, the Auth
+ Algorithm attribute MUST be included in the proposal and
+ the ESP transform ID must be ESP_NULL.
+ */
+#define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */
+#define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */
+#define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */
+#define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */
+
+/* 4.6.1 Security Association Payload */
+struct ipsecdoi_sa {
+ struct isakmp_gen h;
+ u_int32_t doi; /* Domain of Interpretation */
+ u_int32_t sit; /* Situation */
+};
+
+struct ipsecdoi_secrecy_h {
+ u_int16_t len;
+ u_int16_t reserved;
+};
+
+/* 4.6.2.1 Identification Type Values */
+struct ipsecdoi_id {
+ struct isakmp_gen h;
+ u_int8_t type; /* ID Type */
+ u_int8_t proto_id; /* Protocol ID */
+ u_int16_t port; /* Port */
+ /* Identification Data */
+};
+
+#define IPSECDOI_ID_IPV4_ADDR 1
+#define IPSECDOI_ID_FQDN 2
+#define IPSECDOI_ID_USER_FQDN 3
+#define IPSECDOI_ID_IPV4_ADDR_SUBNET 4
+#define IPSECDOI_ID_IPV6_ADDR 5
+#define IPSECDOI_ID_IPV6_ADDR_SUBNET 6
+#define IPSECDOI_ID_IPV4_ADDR_RANGE 7
+#define IPSECDOI_ID_IPV6_ADDR_RANGE 8
+#define IPSECDOI_ID_DER_ASN1_DN 9
+#define IPSECDOI_ID_DER_ASN1_GN 10
+#define IPSECDOI_ID_KEY_ID 11
+
+/* 4.6.3 IPSEC DOI Notify Message Types */
+/* Notify Messages - Status Types */
+#define IPSECDOI_NTYPE_RESPONDER_LIFETIME 24576
+#define IPSECDOI_NTYPE_REPLAY_STATUS 24577
+#define IPSECDOI_NTYPE_INITIAL_CONTACT 24578
+
+#if 0
+/* ipsec sa structure */
+struct ipsec_sa {
+ u_int8_t proto_id; /* Protocol id */
+ vchar_t *spi; /* spi to receive, network byte order */
+ vchar_t *spi_p; /* spi to send, network byte order */
+ vchar_t *keymat; /* KEYMAT */
+ u_int8_t t_id; /* transform id */
+ u_int8_t enc_t; /* type of cipher */
+ u_int8_t mode_t; /* tunnel or transport */
+ u_int8_t hash_t; /* type of hash */
+ u_int8_t life_t; /* type of duration of lifetime */
+ u_int32_t ldur; /* life duration */
+ u_int8_t dhgrp; /* DH; group */
+ struct ipsec_sa *next;
+};
+#endif
+
+#endif /* !defined(_IPSEC_DOI_H_) */
diff --git a/isakmp.h b/isakmp.h
new file mode 100644
index 00000000..1820b125
--- /dev/null
+++ b/isakmp.h
@@ -0,0 +1,449 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * 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 $ */
+
+/* refer to RFC 2408 */
+
+/* must include <netinet/in.h> */
+
+#if !defined(_ISAKMP_H_)
+#define _ISAKMP_H_
+
+typedef u_char cookie_t[8];
+typedef u_char msgid_t[4];
+
+typedef struct { /* i_cookie + r_cookie */
+ cookie_t i_ck;
+ cookie_t r_ck;
+} isakmp_index;
+
+#define INITIATOR 1
+#define RESPONDER 2
+
+#define PORT_ISAKMP 500
+
+#define GENERATE 1
+#define VALIDATE 0
+
+/* Phase of oakley definition */
+/*
+ 0000 0000 0000 0000
+ | |||| ||||
+ | |||| ++++--> negosiation number in phase
+ | ++++-------> phase number
+ +---------------> expire ?
+ */
+#define ISAKMP_PH1 0x0010
+#define ISAKMP_PH2 0x0020
+#define ISAKMP_EXPIRED 0x0100
+
+#define ISAKMP_NGP_0 0x0000
+#define ISAKMP_NGP_1 0x0001
+#define ISAKMP_NGP_2 0x0002
+#define ISAKMP_NGP_3 0x0003
+#define ISAKMP_NGP_4 0x0004
+
+#define ISAKMP_PH1_N (ISAKMP_PH1 | ISAKMP_NGP_0) /* i.e. spawn */
+#define ISAKMP_PH1_1 (ISAKMP_PH1 | ISAKMP_NGP_1)
+#define ISAKMP_PH1_2 (ISAKMP_PH1 | ISAKMP_NGP_2)
+#define ISAKMP_PH1_3 (ISAKMP_PH1 | ISAKMP_NGP_3)
+#define ISAKMP_PH2_N (ISAKMP_PH2 | ISAKMP_NGP_0)
+#define ISAKMP_PH2_1 (ISAKMP_PH2 | ISAKMP_NGP_1)
+#define ISAKMP_PH2_2 (ISAKMP_PH2 | ISAKMP_NGP_2)
+#define ISAKMP_PH2_3 (ISAKMP_PH2 | ISAKMP_NGP_3)
+
+#define ISAKMP_TIMER_DEFAULT 10 /* seconds */
+#define ISAKMP_TRY_DEFAULT 3 /* times */
+
+/* 3.1 ISAKMP Header Format
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Initiator !
+ ! Cookie !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Responder !
+ ! Cookie !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Message ID !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Length !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+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
+ u_int8_t v_maj:4, /* MnVer */
+ v_min:4; /* MjVer */
+#endif
+ u_int8_t etype; /* Exchange Type */
+ u_int8_t flags; /* Flags */
+ msgid_t msgid;
+ u_int32_t len; /* Length */
+};
+
+/* Next Payload Type */
+#define ISAKMP_NPTYPE_NONE 0 /* NONE*/
+#define ISAKMP_NPTYPE_SA 1 /* Security Association */
+#define ISAKMP_NPTYPE_P 2 /* Proposal */
+#define ISAKMP_NPTYPE_T 3 /* Transform */
+#define ISAKMP_NPTYPE_KE 4 /* Key Exchange */
+#define ISAKMP_NPTYPE_ID 5 /* Identification */
+#define ISAKMP_NPTYPE_CERT 6 /* Certificate */
+#define ISAKMP_NPTYPE_CR 7 /* Certificate Request */
+#define ISAKMP_NPTYPE_HASH 8 /* Hash */
+#define ISAKMP_NPTYPE_SIG 9 /* Signature */
+#define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
+#define ISAKMP_NPTYPE_N 11 /* Notification */
+#define ISAKMP_NPTYPE_D 12 /* Delete */
+#define ISAKMP_NPTYPE_VID 13 /* Vendor ID */
+
+#define ISAKMP_MAJOR_VERSION 1
+#define ISAKMP_MINOR_VERSION 0
+
+/* Exchange Type */
+#define ISAKMP_ETYPE_NONE 0 /* NONE */
+#define ISAKMP_ETYPE_BASE 1 /* Base */
+#define ISAKMP_ETYPE_IDENT 2 /* Identity Proteciton */
+#define ISAKMP_ETYPE_AUTH 3 /* Authentication Only */
+#define ISAKMP_ETYPE_AGG 4 /* Aggressive */
+#define ISAKMP_ETYPE_INF 5 /* Informational */
+
+/* Flags */
+#define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
+#define ISAKMP_FLAG_C 0x02 /* Commit Bit */
+
+/* 3.2 Payload Generic Header
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Next Payload ! RESERVED ! Payload Length !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp_gen {
+ u_int8_t np; /* Next Payload */
+ u_int8_t reserved; /* RESERVED, unused, must set to 0 */
+ u_int16_t len; /* Payload Length */
+};
+
+/* 3.3 Data Attributes
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ !A! Attribute Type ! AF=0 Attribute Length !
+ !F! ! AF=1 Attribute Value !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ . AF=0 Attribute Value .
+ . AF=1 Not Transmitted .
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp_data {
+ u_int16_t type; /* defined by DOI-spec, and Attribute Format */
+ u_int16_t lorv; /* if f equal 1, Attribute Length */
+ /* if f equal 0, Attribute Value */
+ /* if f equal 1, Attribute Value */
+};
+#define ISAKMP_GEN_TLV 0x0000
+#define ISAKMP_GEN_TV 0x8000
+ /* mask for type of attribute format */
+#define ISAKMP_GEN_MASK 0x8000
+
+/* 3.4 Security Association Payload */
+ /* MAY NOT be used, because of being defined in ipsec-doi. */
+ /*
+ If the current payload is the last in the message,
+ then the value of the next payload field will be 0.
+ This field MUST NOT contain the
+ values for the Proposal or Transform payloads as they are considered
+ part of the security association negotiation. For example, this
+ field would contain the value "10" (Nonce payload) in the first
+ message of a Base Exchange (see Section 4.4) and the value "0" in the
+ first message of an Identity Protect Exchange (see Section 4.5).
+ */
+struct isakmp_pl_sa {
+ struct isakmp_gen h;
+ u_int32_t doi; /* Domain of Interpretation */
+ u_int32_t sit; /* Situation */
+};
+
+/* 3.5 Proposal Payload */
+ /*
+ The value of the next payload field MUST only contain the value "2"
+ or "0". If there are additional Proposal payloads in the message,
+ then this field will be 2. If the current Proposal payload is the
+ last within the security association proposal, then this field will
+ be 0.
+ */
+struct isakmp_pl_p {
+ struct isakmp_gen h;
+ u_int8_t p_no; /* Proposal # */
+ u_int8_t prot_id; /* Protocol */
+ u_int8_t spi_size; /* SPI Size */
+ u_int8_t num_t; /* Number of Transforms */
+ /* SPI */
+};
+
+/* 3.6 Transform Payload */
+ /*
+ The value of the next payload field MUST only contain the value "3"
+ or "0". If there are additional Transform payloads in the proposal,
+ then this field will be 3. If the current Transform payload is the
+ last within the proposal, then this field will be 0.
+ */
+struct isakmp_pl_t {
+ struct isakmp_gen h;
+ u_int8_t t_no; /* Transform # */
+ u_int8_t t_id; /* Transform-Id */
+ u_int16_t reserved; /* RESERVED2 */
+ /* SA Attributes */
+};
+
+/* 3.7 Key Exchange Payload */
+struct isakmp_pl_ke {
+ struct isakmp_gen h;
+ /* Key Exchange Data */
+};
+
+/* 3.8 Identification Payload */
+ /* MUST NOT to be used, because of being defined in ipsec-doi. */
+struct isakmp_pl_id {
+ struct isakmp_gen h;
+ union {
+ u_int8_t id_type; /* ID Type */
+ u_int32_t doi_data; /* DOI Specific ID Data */
+ } d;
+ /* Identification Data */
+};
+
+/* 3.9 Certificate Payload */
+struct isakmp_pl_cert {
+ struct isakmp_gen h;
+ u_int8_t encode; /* Cert Encoding */
+ char cert; /* Certificate Data */
+ /*
+ This field indicates the type of
+ certificate or certificate-related information contained in the
+ Certificate Data field.
+ */
+};
+
+/* Certificate Type */
+#define ISAKMP_CERT_NONE 0
+#define ISAKMP_CERT_PKCS 1
+#define ISAKMP_CERT_PGP 2
+#define ISAKMP_CERT_DNS 3
+#define ISAKMP_CERT_SIGN 4
+#define ISAKMP_CERT_KE 5
+#define ISAKMP_CERT_KT 6
+#define ISAKMP_CERT_CRL 7
+#define ISAKMP_CERT_ARL 8
+#define ISAKMP_CERT_SPKI 9
+
+/* 3.10 Certificate Request Payload */
+struct isakmp_pl_cr {
+ struct isakmp_gen h;
+ u_int8_t num_cert; /* # Cert. Types */
+ /*
+ Certificate Types (variable length)
+ -- Contains a list of the types of certificates requested,
+ sorted in order of preference. Each individual certificate
+ type is 1 octet. This field is NOT requiredo
+ */
+ /* # Certificate Authorities (1 octet) */
+ /* Certificate Authorities (variable length) */
+};
+
+/* 3.11 Hash Payload */
+ /* may not be used, because of having only data. */
+struct isakmp_pl_hash {
+ struct isakmp_gen h;
+ /* Hash Data */
+};
+
+/* 3.12 Signature Payload */
+ /* may not be used, because of having only data. */
+struct isakmp_pl_sig {
+ struct isakmp_gen h;
+ /* Signature Data */
+};
+
+/* 3.13 Nonce Payload */
+ /* may not be used, because of having only data. */
+struct isakmp_pl_nonce {
+ struct isakmp_gen h;
+ /* Nonce Data */
+};
+
+/* 3.14 Notification Payload */
+struct isakmp_pl_n {
+ struct isakmp_gen h;
+ u_int32_t doi; /* Domain of Interpretation */
+ u_int8_t prot_id; /* Protocol-ID */
+ u_int8_t spi_size; /* SPI Size */
+ u_int16_t type; /* Notify Message Type */
+ /* SPI */
+ /* Notification Data */
+};
+
+/* 3.14.1 Notify Message Types */
+/* NOTIFY MESSAGES - ERROR TYPES */
+#define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1
+#define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2
+#define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3
+#define ISAKMP_NTYPE_INVALID_COOKIE 4
+#define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5
+#define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6
+#define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7
+#define ISAKMP_NTYPE_INVALID_FLAGS 8
+#define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9
+#define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10
+#define ISAKMP_NTYPE_INVALID_SPI 11
+#define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12
+#define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13
+#define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14
+#define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15
+#define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16
+#define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17
+#define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18
+#define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19
+#define ISAKMP_NTYPE_INVALID_CERTIFICATE 20
+#define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21
+#define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22
+#define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23
+#define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24
+#define ISAKMP_NTYPE_INVALID_SIGNATURE 25
+#define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26
+/* NOTIFY MESSAGES - STATUS TYPES */
+#define ISAKMP_NTYPE_CONNECTED 16384
+/* using only to log */
+#define ISAKMP_LOG_RETRY_LIMIT_REACHED 65530
+
+/* 3.15 Delete Payload */
+struct isakmp_pl_d {
+ struct isakmp_gen h;
+ u_int32_t doi; /* Domain of Interpretation */
+ u_int8_t prot_id; /* Protocol-Id */
+ u_int8_t spi_size; /* SPI Size */
+ u_int16_t num_spi; /* # of SPIs */
+ /* SPI(es) */
+};
+
+
+struct isakmp_ph1tab {
+ struct isakmp_ph1 *head;
+ struct isakmp_ph1 *tail;
+ int len;
+};
+
+struct isakmp_ph2tab {
+ struct isakmp_ph2 *head;
+ struct isakmp_ph2 *tail;
+ int len;
+};
+
+#if 0
+/* isakmp status structure */
+struct isakmp_ph1 {
+ isakmp_index index;
+ u_int8_t dir; /* INITIATOR or RESPONDER */
+ u_int16_t status; /* status of this SA */
+ u_int16_t etype;
+ u_int32_t doi;
+ u_int32_t sit;
+ vchar_t *dhp; /* DH; prime, static value */
+ vchar_t *dhpriv; /* DH; private value */
+ vchar_t *dhpub; /* DH; public value */
+ vchar_t *dhpub_p; /* DH; partner's public value */
+ vchar_t *dhgxy; /* DH; shared secret */
+ vchar_t *nonce; /* nonce value */
+ vchar_t *nonce_p; /* partner's nonce value */
+ vchar_t *skeyid; /* SKEYID */
+ vchar_t *skeyid_d; /* SKEYID_d */
+ vchar_t *skeyid_a; /* SKEYID_a, i.e. hash */
+ vchar_t *skeyid_e; /* SKEYID_e, i.e. encryption */
+ vchar_t *key; /* cipher key */
+ vchar_t *hash; /* HASH minus general header */
+ vchar_t *iv; /* IV */
+ vchar_t *ive; /* new IV to encrypt next packet */
+ vchar_t *ivd; /* new IV to decrypt next packet */
+ vchar_t *sa; /* SA minus general header including p,t.*/
+ vchar_t *id; /* ID minus general header */
+ vchar_t *id_p; /* partner's ID minus general header */
+ struct sockaddr *local; /* pointer to the my sockaddr */
+ struct sockaddr *remote; /* partner's sockaddr */
+ struct oakley_sa *isa; /* Is it good that caddr_t ? */
+ struct sched *sc; /* back pointer to the record in schedule
+ used to resend. */
+ struct isakmp_ph1 *next;
+ struct isakmp_ph1 *prev;
+ struct isakmp_conf *cfp; /* pointer to isakmp configuration */
+ struct isakmp_ph2tab ph2tab; /* list on negotiating Phase 2 */
+ u_int32_t msgid2; /* XXX: msgid counter for Phase 2 */
+};
+
+struct isakmp_ph2 {
+ msgid_t msgid;
+ u_int8_t dir; /* INITIATOR or RESPONDER */
+ u_int16_t status; /* status of this SA */
+ vchar_t *dhp; /* DH; prime, static value */
+ vchar_t *dhpriv; /* DH; private value */
+ vchar_t *dhpub; /* DH; public value */
+ vchar_t *dhpub_p; /* DH; partner's public value */
+ vchar_t *dhgxy; /* DH; shared secret */
+ vchar_t *id; /* ID */
+ vchar_t *id_p; /* ID for peer */
+ vchar_t *nonce; /* nonce value in phase 2 */
+ vchar_t *nonce_p; /* partner's nonce value in phase 2 */
+ vchar_t *hash; /* HASH2 minus general header */
+ vchar_t *iv; /* IV for Phase 2 */
+ vchar_t *ive; /* new IV to encrypt next packet */
+ vchar_t *ivd; /* new IV to decrypt next packet */
+ struct isakmp_ph1 *ph1; /* back pointer to isakmp status */
+ struct sched *sc; /* back pointer to the schedule using resend */
+ struct pfkey_st *pst; /* pointer to the pfkey status record.
+ is only used by initiator. */
+ u_int8_t proxy; /* is proxy or not ?. */
+ vchar_t *sa; /* SA payload */
+ struct ipsec_sa *isa; /* values of SA to use, same SA in use. */
+ struct isakmp_ph2 *next;
+ struct isakmp_ph2 *prev;
+};
+#endif
+
+#define EXCHANGE_PROXY 1
+#define EXCHANGE_MYSELF 0
+
+#define PFS_NEED 1
+#define PFS_NONEED 0
+
+#endif /* !defined(_ISAKMP_H_) */
diff --git a/l2tp.h b/l2tp.h
new file mode 100644
index 00000000..008491e7
--- /dev/null
+++ b/l2tp.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * L2TP support contributed by Motonori Shindo (mshindo@ascend.co.jp)
+ */
+
+
+#define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */
+#define L2TP_FLAG_LENGTH 0x4000 /* Length */
+#define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */
+#define L2TP_FLAG_OFFSET 0x0200 /* Offset */
+#define L2TP_FLAG_PRIORITY 0x0100 /* Priority */
+
+#define L2TP_VERSION_MASK 0x000f /* Version Mask */
+#define L2TP_VERSION_L2F 0x0001 /* L2F */
+#define L2TP_VERSION_L2TP 0x0002 /* L2TP */
+
+#define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */
+#define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */
+#define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */
+
+#define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */
+#define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */
+
+#define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */
+#define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */
+
+#define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */
+#define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */
+
+#define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */
+#define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */
+
+/* Authen Type */
+#define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */
+#define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */
+#define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */
+#define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */
+#define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */
+#define L2TP_AUTHEN_TYPE_MSCHAP 0x0005 /* MSCHAPv1 */
+
+#define L2TP_PROXY_AUTH_ID_MASK 0x00ff
+
+
+struct l2tp_avp_vec {
+ const char *name;
+ void (*print)(const u_char *, u_int);
+};
+
+struct l2tp_call_errors {
+ u_short reserved;
+ u_int crc_errs;
+ u_int framing_errs;
+ u_int hardware_overruns;
+ u_int buffer_overruns;
+ u_int timeout_errs;
+ u_int alignment_errs;
+};
+
+struct l2tp_accm {
+ u_short reserved;
+ u_int send_accm;
+ u_int recv_accm;
+};
+
diff --git a/missing/addrinfo.h b/missing/addrinfo.h
new file mode 100644
index 00000000..f4d3bceb
--- /dev/null
+++ b/missing/addrinfo.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef HAVE_ADDRINFO
+
+/*
+ * Error return codes from getaddrinfo()
+ */
+#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
+#define EAI_AGAIN 2 /* temporary failure in name resolution */
+#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
+#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
+#define EAI_FAMILY 5 /* ai_family not supported */
+#define EAI_MEMORY 6 /* memory allocation failure */
+#define EAI_NODATA 7 /* no address associated with hostname */
+#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
+#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
+#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
+#define EAI_SYSTEM 11 /* system error returned in errno */
+#define EAI_BADHINTS 12
+#define EAI_PROTOCOL 13
+#define EAI_MAX 14
+
+/* internal error */
+#define NETDB_INTERNAL -1 /* see errno */
+
+/*
+ * Flag values for getaddrinfo()
+ */
+#define AI_PASSIVE 0x00000001 /* get address to use bind() */
+#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
+#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
+/* valid flags for addrinfo */
+#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
+
+#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
+#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
+#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
+#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
+/* special recommended flags for getipnodebyname */
+#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
+
+/*
+ * Constants for getnameinfo()
+ */
+#define NI_MAXHOST 1025
+#define NI_MAXSERV 32
+
+/*
+ * Flag values for getnameinfo()
+ */
+#define NI_NOFQDN 0x00000001
+#define NI_NUMERICHOST 0x00000002
+#define NI_NAMEREQD 0x00000004
+#define NI_NUMERICSERV 0x00000008
+#define NI_DGRAM 0x00000010
+
+struct addrinfo {
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+ size_t ai_addrlen; /* length of ai_addr */
+ char *ai_canonname; /* canonical name for hostname */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
+};
+
+extern void freeaddrinfo __P((struct addrinfo *));
+extern void freehostent __P((struct hostent *));
+extern char *gai_strerror __P((int));
+extern int getaddrinfo __P((const char *, const char *,
+ const struct addrinfo *, struct addrinfo **));
+extern int getnameinfo __P((const struct sockaddr *, size_t, char *,
+ size_t, char *, size_t, int));
+extern struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *));
+extern struct hostent *getipnodebyname __P((const char *, int, int, int *));
+extern int inet_pton __P((int, const char *, void *));
+extern const char *inet_ntop __P((int, const void *, char *, size_t));
+#endif /* HAVE_ADDRINFO */
diff --git a/missing/addrsize.h b/missing/addrsize.h
new file mode 100644
index 00000000..2880956f
--- /dev/null
+++ b/missing/addrsize.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef INADDRSZ
+#define INADDRSZ 4 /* IPv4 T_A */
+#endif
+
+#ifndef IN6ADDRSZ
+#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
+#endif
+
diff --git a/missing/bittypes.h b/missing/bittypes.h
new file mode 100644
index 00000000..500f39fd
--- /dev/null
+++ b/missing/bittypes.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef HAVE_U_INT8_T
+
+#if SIZEOF_CHAR == 1
+typedef unsigned char u_int8_t;
+#elif SIZEOF_INT == 1
+typedef unsigned int u_int8_t;
+#else /* XXX */
+#error "there's no appropriate type for u_int8_t"
+#endif
+
+#endif /* HAVE_U_INT8_T */
+
+#ifndef HAVE_U_INT16_T
+
+#if SIZEOF_SHORT == 2
+typedef unsigned short u_int16_t;
+#elif SIZEOF_INT == 2
+typedef unsigned int u_int16_t;
+#elif SIZEOF_CHAR == 2
+typedef unsigned char u_int16_t;
+#else /* XXX */
+#error "there's no appropriate type for u_int16_t"
+#endif
+
+#endif /* HAVE_U_INT16_T */
+
+#ifndef HAVE_U_INT32_T
+
+#if SIZEOF_INT == 4
+typedef unsigned int u_int32_t;
+#elif SIZEOF_LONG == 4
+typedef unsigned long u_int32_t;
+#elif SIZEOF_SHORT == 4
+typedef unsigned short u_int32_t;
+#else /* XXX */
+#error "there's no appropriate type for u_int32_t"
+#endif
+
+#endif /* HAVE_U_INT32_T */
diff --git a/missing/cdecl_ext.h b/missing/cdecl_ext.h
new file mode 100644
index 00000000..9591db26
--- /dev/null
+++ b/missing/cdecl_ext.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef HAVE_PORTABLE_PROTOTYPE
+
+#if defined(__STDC__) || defined(__cplusplus)
+#define __P(protos) protos /* full-blown ANSI C */
+#else
+#define __P(protos) () /* traditional C preprocessor */
+#endif
+
+#endif /* !HAVE_PORTABLE_PROTOTYPE */
diff --git a/missing/getaddrinfo.c b/missing/getaddrinfo.c
new file mode 100644
index 00000000..d57c308d
--- /dev/null
+++ b/missing/getaddrinfo.c
@@ -0,0 +1,1012 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator.
+ *
+ * Issues to be discussed:
+ * - Thread safe-ness must be checked.
+ * - Return values. There are nonstandard return values defined and used
+ * in the source code. This is because RFC2553 is silent about which error
+ * code must be returned for which situation.
+ * - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/param.h>
+#if 0
+#include <sys/sysctl.h>
+#endif
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+#include <netdb.h>
+#include <resolv.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#ifndef HAVE_PORTABLE_PROTOTYPE
+#include "cdecl_ext.h"
+#endif
+
+#ifndef HAVE_U_INT32_T
+#include "bittypes.h"
+#endif
+
+#ifndef HAVE_SOCKADDR_STORAGE
+#include "sockstorage.h"
+#endif
+
+#ifndef HAVE_ADDRINFO
+#include "addrinfo.h"
+#endif
+
+#if defined(__KAME__) && defined(INET6)
+# define FAITH
+#endif
+
+#define SUCCESS 0
+#define ANY 0
+#define YES 1
+#define NO 0
+
+#ifdef FAITH
+static int translate = NO;
+static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT;
+#endif
+
+static const char in_addrany[] = { 0, 0, 0, 0 };
+static const char in6_addrany[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+static const char in_loopback[] = { 127, 0, 0, 1 };
+static const char in6_loopback[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
+};
+
+struct sockinet {
+ u_char si_len;
+ u_char si_family;
+ u_short si_port;
+ u_int32_t si_scope_id;
+};
+
+static const struct afd {
+ int a_af;
+ int a_addrlen;
+ int a_socklen;
+ int a_off;
+ const char *a_addrany;
+ const char *a_loopback;
+ int a_scoped;
+} afdl [] = {
+#ifdef INET6
+ {PF_INET6, sizeof(struct in6_addr),
+ sizeof(struct sockaddr_in6),
+ offsetof(struct sockaddr_in6, sin6_addr),
+ in6_addrany, in6_loopback, 1},
+#endif
+ {PF_INET, sizeof(struct in_addr),
+ sizeof(struct sockaddr_in),
+ offsetof(struct sockaddr_in, sin_addr),
+ in_addrany, in_loopback, 0},
+ {0, 0, 0, 0, NULL, NULL, 0},
+};
+
+struct explore {
+ int e_af;
+ int e_socktype;
+ int e_protocol;
+ const char *e_protostr;
+ int e_wild;
+#define WILD_AF(ex) ((ex)->e_wild & 0x01)
+#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02)
+#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04)
+};
+
+static const struct explore explore[] = {
+#if 0
+ { PF_LOCAL, 0, ANY, ANY, NULL, 0x01 },
+#endif
+#ifdef INET6
+ { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
+ { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
+ { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
+#endif
+ { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
+ { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
+ { PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
+ { -1, 0, 0, NULL, 0 },
+};
+
+#ifdef INET6
+#define PTON_MAX 16
+#else
+#define PTON_MAX 4
+#endif
+
+
+static int str_isnumber __P((const char *));
+static int explore_fqdn __P((const struct addrinfo *, const char *,
+ const char *, struct addrinfo **));
+static int explore_null __P((const struct addrinfo *, const char *,
+ const char *, struct addrinfo **));
+static int explore_numeric __P((const struct addrinfo *, const char *,
+ const char *, struct addrinfo **));
+static int explore_numeric_scope __P((const struct addrinfo *, const char *,
+ const char *, struct addrinfo **));
+static int get_name __P((const char *, const struct afd *, struct addrinfo **,
+ char *, const struct addrinfo *, const char *));
+static int get_canonname __P((const struct addrinfo *,
+ struct addrinfo *, const char *));
+static struct addrinfo *get_ai __P((const struct addrinfo *,
+ const struct afd *, const char *));
+static int get_portmatch __P((const struct addrinfo *, const char *));
+static int get_port __P((struct addrinfo *, const char *, int));
+static const struct afd *find_afd __P((int));
+
+static char *ai_errlist[] = {
+ "Success",
+ "Address family for hostname not supported", /* EAI_ADDRFAMILY */
+ "Temporary failure in name resolution", /* EAI_AGAIN */
+ "Invalid value for ai_flags", /* EAI_BADFLAGS */
+ "Non-recoverable failure in name resolution", /* EAI_FAIL */
+ "ai_family not supported", /* EAI_FAMILY */
+ "Memory allocation failure", /* EAI_MEMORY */
+ "No address associated with hostname", /* EAI_NODATA */
+ "hostname nor servname provided, or not known", /* EAI_NONAME */
+ "servname not supported for ai_socktype", /* EAI_SERVICE */
+ "ai_socktype not supported", /* EAI_SOCKTYPE */
+ "System error returned in errno", /* EAI_SYSTEM */
+ "Invalid value for hints", /* EAI_BADHINTS */
+ "Resolved protocol is unknown", /* EAI_PROTOCOL */
+ "Unknown error", /* EAI_MAX */
+};
+
+/* XXX macros that make external reference is BAD. */
+
+#define GET_AI(ai, afd, addr) \
+do { \
+ /* external reference: pai, error, and label free */ \
+ (ai) = get_ai(pai, (afd), (addr)); \
+ if ((ai) == NULL) { \
+ error = EAI_MEMORY; \
+ goto free; \
+ } \
+} while (0)
+
+#define GET_PORT(ai, serv) \
+do { \
+ /* external reference: error and label free */ \
+ error = get_port((ai), (serv), 0); \
+ if (error != 0) \
+ goto free; \
+} while (0)
+
+#define GET_CANONNAME(ai, str) \
+do { \
+ /* external reference: pai, error and label free */ \
+ error = get_canonname(pai, (ai), (str)); \
+ if (error != 0) \
+ goto free; \
+} while (0)
+
+#define ERR(err) \
+do { \
+ /* external reference: error, and label bad */ \
+ error = (err); \
+ goto bad; \
+} while (0)
+
+#define MATCH_FAMILY(x, y, w) \
+ ((x) == (y) || ((w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
+#define MATCH(x, y, w) \
+ ((x) == (y) || ((w) && ((x) == ANY || (y) == ANY)))
+
+char *
+gai_strerror(ecode)
+ int ecode;
+{
+ if (ecode < 0 || ecode > EAI_MAX)
+ ecode = EAI_MAX;
+ return ai_errlist[ecode];
+}
+
+void
+freeaddrinfo(ai)
+ struct addrinfo *ai;
+{
+ struct addrinfo *next;
+
+ do {
+ next = ai->ai_next;
+ if (ai->ai_canonname)
+ free(ai->ai_canonname);
+ /* no need to free(ai->ai_addr) */
+ free(ai);
+ } while ((ai = next) != NULL);
+}
+
+static int
+str_isnumber(p)
+ const char *p;
+{
+ char *q = (char *)p;
+ while (*q) {
+ if (! isdigit(*q))
+ return NO;
+ q++;
+ }
+ return YES;
+}
+
+int
+getaddrinfo(hostname, servname, hints, res)
+ const char *hostname, *servname;
+ const struct addrinfo *hints;
+ struct addrinfo **res;
+{
+ struct addrinfo sentinel;
+ struct addrinfo *cur;
+ int error = 0;
+ struct addrinfo ai;
+ struct addrinfo ai0;
+ struct addrinfo *pai;
+ const struct afd *afd;
+ const struct explore *ex;
+
+#ifdef FAITH
+ static int firsttime = 1;
+
+ if (firsttime) {
+ /* translator hack */
+ char *q = getenv("GAI");
+ if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
+ translate = YES;
+ firsttime = 0;
+ }
+#endif
+
+ sentinel.ai_next = NULL;
+ cur = &sentinel;
+ pai = &ai;
+ pai->ai_flags = 0;
+ pai->ai_family = PF_UNSPEC;
+ pai->ai_socktype = ANY;
+ pai->ai_protocol = ANY;
+ pai->ai_addrlen = 0;
+ pai->ai_canonname = NULL;
+ pai->ai_addr = NULL;
+ pai->ai_next = NULL;
+
+ if (hostname == NULL && servname == NULL)
+ return EAI_NONAME;
+ if (hints) {
+ /* error check for hints */
+ if (hints->ai_addrlen || hints->ai_canonname ||
+ hints->ai_addr || hints->ai_next)
+ ERR(EAI_BADHINTS); /* xxx */
+ if (hints->ai_flags & ~AI_MASK)
+ ERR(EAI_BADFLAGS);
+ switch (hints->ai_family) {
+ case PF_UNSPEC:
+ case PF_INET:
+#ifdef INET6
+ case PF_INET6:
+#endif
+ break;
+ default:
+ ERR(EAI_FAMILY);
+ }
+ memcpy(pai, hints, sizeof(*pai));
+
+ /*
+ * if both socktype/protocol are specified, check if they
+ * are meaningful combination.
+ */
+ if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) {
+ for (ex = explore; ex->e_af >= 0; ex++) {
+ if (pai->ai_family != ex->e_af)
+ continue;
+ if (ex->e_socktype == ANY)
+ continue;
+ if (ex->e_protocol == ANY)
+ continue;
+ if (pai->ai_socktype == ex->e_socktype
+ && pai->ai_protocol != ex->e_protocol) {
+ ERR(EAI_BADHINTS);
+ }
+ }
+ }
+ }
+
+ /*
+ * check for special cases. (1) numeric servname is disallowed if
+ * socktype/protocol are left unspecified. (2) servname is disallowed
+ * for raw and other inet{,6} sockets.
+ */
+ if (MATCH_FAMILY(pai->ai_family, PF_INET, 1)
+ || MATCH_FAMILY(pai->ai_family, PF_INET6, 1)) {
+ ai0 = *pai;
+
+ if (pai->ai_family == PF_UNSPEC)
+ pai->ai_family = PF_INET6;
+ error = get_portmatch(pai, servname);
+ if (error)
+ ERR(error);
+
+ *pai = ai0;
+ }
+
+ ai0 = *pai;
+
+ /* NULL hostname, or numeric hostname */
+ for (ex = explore; ex->e_af >= 0; ex++) {
+ *pai = ai0;
+
+ if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex)))
+ continue;
+ if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex)))
+ continue;
+ if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex)))
+ continue;
+
+ if (pai->ai_family == PF_UNSPEC)
+ pai->ai_family = ex->e_af;
+ if (pai->ai_socktype == ANY && ex->e_socktype != ANY)
+ pai->ai_socktype = ex->e_socktype;
+ if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
+ pai->ai_protocol = ex->e_protocol;
+
+ if (hostname == NULL)
+ error = explore_null(pai, hostname, servname, &cur->ai_next);
+ else
+ error = explore_numeric_scope(pai, hostname, servname, &cur->ai_next);
+
+ if (error)
+ goto free;
+
+ while (cur && cur->ai_next)
+ cur = cur->ai_next;
+ }
+
+ /*
+ * XXX
+ * If numreic representation of AF1 can be interpreted as FQDN
+ * representation of AF2, we need to think again about the code below.
+ */
+ if (sentinel.ai_next)
+ goto good;
+
+ if (pai->ai_flags & AI_NUMERICHOST)
+ ERR(EAI_NONAME);
+ if (hostname == NULL)
+ ERR(EAI_NONAME);
+
+ /*
+ * hostname as alphabetical name.
+ * we would like to prefer AF_INET6 than AF_INET, so we'll make a
+ * outer loop by AFs.
+ */
+ for (afd = afdl; afd->a_af; afd++) {
+ *pai = ai0;
+
+ if (!MATCH_FAMILY(pai->ai_family, afd->a_af, 1))
+ continue;
+
+ for (ex = explore; ex->e_af >= 0; ex++) {
+ *pai = ai0;
+
+ if (pai->ai_family == PF_UNSPEC)
+ pai->ai_family = afd->a_af;
+
+ if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex)))
+ continue;
+ if (!MATCH(pai->ai_socktype, ex->e_socktype,
+ WILD_SOCKTYPE(ex))) {
+ continue;
+ }
+ if (!MATCH(pai->ai_protocol, ex->e_protocol,
+ WILD_PROTOCOL(ex))) {
+ continue;
+ }
+
+ if (pai->ai_family == PF_UNSPEC)
+ pai->ai_family = ex->e_af;
+ if (pai->ai_socktype == ANY && ex->e_socktype != ANY)
+ pai->ai_socktype = ex->e_socktype;
+ if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
+ pai->ai_protocol = ex->e_protocol;
+
+ error = explore_fqdn(pai, hostname, servname,
+ &cur->ai_next);
+
+ while (cur && cur->ai_next)
+ cur = cur->ai_next;
+ }
+ }
+
+ /* XXX */
+ if (sentinel.ai_next)
+ error = 0;
+
+ if (error)
+ goto free;
+ if (error == 0) {
+ if (sentinel.ai_next) {
+ good:
+ *res = sentinel.ai_next;
+ return SUCCESS;
+ } else
+ error = EAI_FAIL;
+ }
+ free:
+ bad:
+ if (sentinel.ai_next)
+ freeaddrinfo(sentinel.ai_next);
+ *res = NULL;
+ return error;
+}
+
+/*
+ * FQDN hostname, DNS lookup
+ */
+static int
+explore_fqdn(pai, hostname, servname, res)
+ const struct addrinfo *pai;
+ const char *hostname;
+ const char *servname;
+ struct addrinfo **res;
+{
+ int s;
+ struct hostent *hp;
+ int h_error;
+ int af;
+ char *ap;
+ struct addrinfo sentinel, *cur;
+ int i;
+ const struct afd *afd;
+ int error;
+
+ *res = NULL;
+ sentinel.ai_next = NULL;
+ cur = &sentinel;
+
+ /*
+ * filter out AFs that are not supported by the kernel
+ * XXX errno?
+ */
+ s = socket(pai->ai_family, SOCK_DGRAM, 0);
+ if (s < 0)
+ return 0;
+ close(s);
+
+ /*
+ * if the servname does not match socktype/protocol, ignore it.
+ */
+ if (get_portmatch(pai, servname) != 0)
+ return 0;
+
+ afd = find_afd(pai->ai_family);
+
+#ifdef USE_GETIPNODEBY
+ hp = getipnodebyname(hostname, pai->ai_family, AI_ADDRCONFIG, &h_error);
+#else
+ hp = gethostbyname2(hostname, pai->ai_family);
+ h_error = h_errno;
+#endif
+
+ if (hp == NULL) {
+ switch (h_error) {
+ case HOST_NOT_FOUND:
+ case NO_DATA:
+ error = EAI_NODATA;
+ break;
+ case TRY_AGAIN:
+ error = EAI_AGAIN;
+ break;
+ case NO_RECOVERY:
+ case NETDB_INTERNAL:
+ default:
+ error = EAI_FAIL;
+ break;
+ }
+ } else if ((hp->h_name == NULL) || (hp->h_name[0] == 0)
+ || (hp->h_addr_list[0] == NULL)) {
+#ifdef USE_GETIPNODEBY
+ freehostent(hp);
+#endif
+ hp = NULL;
+ error = EAI_FAIL;
+ }
+
+ if (hp == NULL)
+ goto free;
+
+ for (i = 0; hp->h_addr_list[i] != NULL; i++) {
+ af = hp->h_addrtype;
+ ap = hp->h_addr_list[i];
+ if (af == AF_INET6
+ && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
+ af = AF_INET;
+ ap = ap + sizeof(struct in6_addr)
+ - sizeof(struct in_addr);
+ }
+
+ if (af != pai->ai_family)
+ continue;
+
+ if ((pai->ai_flags & AI_CANONNAME) == 0) {
+ GET_AI(cur->ai_next, afd, ap);
+ GET_PORT(cur->ai_next, servname);
+ } else {
+ /*
+ * if AI_CANONNAME and if reverse lookup
+ * fail, return ai anyway to pacify
+ * calling application.
+ *
+ * XXX getaddrinfo() is a name->address
+ * translation function, and it looks
+ * strange that we do addr->name
+ * translation here.
+ */
+ get_name(ap, afd, &cur->ai_next,
+ ap, pai, servname);
+ }
+
+ while (cur && cur->ai_next)
+ cur = cur->ai_next;
+ }
+
+ *res = sentinel.ai_next;
+ return 0;
+
+free:
+#ifdef USE_GETIPNODEBY
+ if (hp)
+ freehostent(hp);
+#endif
+ if (sentinel.ai_next)
+ freeaddrinfo(sentinel.ai_next);
+ return error;
+}
+
+/*
+ * hostname == NULL.
+ * passive socket -> anyaddr (0.0.0.0 or ::)
+ * non-passive socket -> localhost (127.0.0.1 or ::1)
+ */
+static int
+explore_null(pai, hostname, servname, res)
+ const struct addrinfo *pai;
+ const char *hostname;
+ const char *servname;
+ struct addrinfo **res;
+{
+ int s;
+ const struct afd *afd;
+ struct addrinfo *cur;
+ struct addrinfo sentinel;
+ int error;
+
+ *res = NULL;
+ sentinel.ai_next = NULL;
+ cur = &sentinel;
+
+ /*
+ * filter out AFs that are not supported by the kernel
+ * XXX errno?
+ */
+ s = socket(pai->ai_family, SOCK_DGRAM, 0);
+ if (s < 0)
+ return 0;
+ close(s);
+
+ /*
+ * if the servname does not match socktype/protocol, ignore it.
+ */
+ if (get_portmatch(pai, servname) != 0)
+ return 0;
+
+ afd = find_afd(pai->ai_family);
+
+ if (pai->ai_flags & AI_PASSIVE) {
+ GET_AI(cur->ai_next, afd, afd->a_addrany);
+ /* xxx meaningless?
+ * GET_CANONNAME(cur->ai_next, "anyaddr");
+ */
+ GET_PORT(cur->ai_next, servname);
+ } else {
+ GET_AI(cur->ai_next, afd, afd->a_loopback);
+ /* xxx meaningless?
+ * GET_CANONNAME(cur->ai_next, "localhost");
+ */
+ GET_PORT(cur->ai_next, servname);
+ }
+ cur = cur->ai_next;
+
+ *res = sentinel.ai_next;
+ return 0;
+
+free:
+ if (sentinel.ai_next)
+ freeaddrinfo(sentinel.ai_next);
+ return error;
+}
+
+/*
+ * numeric hostname
+ */
+static int
+explore_numeric(pai, hostname, servname, res)
+ const struct addrinfo *pai;
+ const char *hostname;
+ const char *servname;
+ struct addrinfo **res;
+{
+ const struct afd *afd;
+ struct addrinfo *cur;
+ struct addrinfo sentinel;
+ int error;
+ char pton[PTON_MAX];
+ int flags;
+
+ *res = NULL;
+ sentinel.ai_next = NULL;
+ cur = &sentinel;
+
+ /*
+ * if the servname does not match socktype/protocol, ignore it.
+ */
+ if (get_portmatch(pai, servname) != 0)
+ return 0;
+
+ afd = find_afd(pai->ai_family);
+ flags = pai->ai_flags;
+
+ if (inet_pton(afd->a_af, hostname, pton) == 1) {
+ u_int32_t v4a;
+#ifdef INET6
+ u_char pfx;
+#endif
+
+ switch (afd->a_af) {
+ case AF_INET:
+ v4a = (u_int32_t)ntohl(((struct in_addr *)pton)->s_addr);
+ if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
+ flags &= ~AI_CANONNAME;
+ v4a >>= IN_CLASSA_NSHIFT;
+ if (v4a == 0 || v4a == IN_LOOPBACKNET)
+ flags &= ~AI_CANONNAME;
+ break;
+#ifdef INET6
+ case AF_INET6:
+ pfx = ((struct in6_addr *)pton)->s6_addr[0];
+ if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
+ flags &= ~AI_CANONNAME;
+ break;
+#endif
+ }
+
+ if (pai->ai_family == afd->a_af ||
+ pai->ai_family == PF_UNSPEC /*?*/) {
+ if ((flags & AI_CANONNAME) == 0) {
+ GET_AI(cur->ai_next, afd, pton);
+ GET_PORT(cur->ai_next, servname);
+ } else {
+ /*
+ * if AI_CANONNAME and if reverse lookup
+ * fail, return ai anyway to pacify
+ * calling application.
+ *
+ * XXX getaddrinfo() is a name->address
+ * translation function, and it looks
+ * strange that we do addr->name
+ * translation here.
+ */
+ get_name(pton, afd, &cur->ai_next,
+ pton, pai, servname);
+ }
+ while (cur && cur->ai_next)
+ cur = cur->ai_next;
+ } else
+ ERR(EAI_FAMILY); /*xxx*/
+ }
+
+ *res = sentinel.ai_next;
+ return 0;
+
+free:
+bad:
+ if (sentinel.ai_next)
+ freeaddrinfo(sentinel.ai_next);
+ return error;
+}
+
+/*
+ * numeric hostname with scope
+ */
+static int
+explore_numeric_scope(pai, hostname, servname, res)
+ const struct addrinfo *pai;
+ const char *hostname;
+ const char *servname;
+ struct addrinfo **res;
+{
+#ifndef SCOPE_DELIMITER
+ return explore_numeric(pai, hostname, servname, res);
+#else
+ const struct afd *afd;
+ struct addrinfo *cur;
+ int error;
+ char *cp, *hostname2 = NULL;
+ int scope;
+ struct sockaddr_in6 *sin6;
+
+ /*
+ * if the servname does not match socktype/protocol, ignore it.
+ */
+ if (get_portmatch(pai, servname) != 0)
+ return 0;
+
+ afd = find_afd(pai->ai_family);
+ if (!afd->a_scoped)
+ return explore_numeric(pai, hostname, servname, res);
+
+ cp = strchr(hostname, SCOPE_DELIMITER);
+ if (cp == NULL)
+ return explore_numeric(pai, hostname, servname, res);
+
+ /*
+ * Handle special case of <scoped_address><delimiter><scope id>
+ */
+ hostname2 = strdup(hostname);
+ if (hostname2 == NULL)
+ return EAI_MEMORY;
+ /* terminate at the delimiter */
+ hostname2[cp - hostname] = '\0';
+
+ cp++;
+ switch (pai->ai_family) {
+#ifdef INET6
+ case AF_INET6:
+ scope = if_nametoindex(cp);
+ break;
+#endif
+ }
+
+ error = explore_numeric(pai, hostname2, servname, res);
+ if (error == 0) {
+ for (cur = *res; cur; cur = cur->ai_next) {
+ if (cur->ai_family != AF_INET6)
+ continue;
+ sin6 = (struct sockaddr_in6 *)cur->ai_addr;
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr))
+ sin6->sin6_scope_id = scope;
+ }
+ }
+
+ free(hostname2);
+
+ return error;
+#endif
+}
+
+static int
+get_name(addr, afd, res, numaddr, pai, servname)
+ const char *addr;
+ const struct afd *afd;
+ struct addrinfo **res;
+ char *numaddr;
+ const struct addrinfo *pai;
+ const char *servname;
+{
+ struct hostent *hp;
+ struct addrinfo *cur;
+ int error = 0;
+#ifdef USE_GETIPNODEBY
+ int h_error;
+
+ hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
+#else
+ hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
+#endif
+ if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
+ GET_AI(cur, afd, hp->h_addr_list[0]);
+ GET_PORT(cur, servname);
+ GET_CANONNAME(cur, hp->h_name);
+ } else {
+ GET_AI(cur, afd, numaddr);
+ GET_PORT(cur, servname);
+ }
+
+#ifdef USE_GETIPNODEBY
+ if (hp)
+ freehostent(hp);
+#endif
+ *res = cur;
+ return SUCCESS;
+ free:
+ if (cur)
+ freeaddrinfo(cur);
+#ifdef USE_GETIPNODEBY
+ if (hp)
+ freehostent(hp);
+#endif
+ /* bad: */
+ *res = NULL;
+ return error;
+}
+
+static int
+get_canonname(pai, ai, str)
+ const struct addrinfo *pai;
+ struct addrinfo *ai;
+ const char *str;
+{
+ if ((pai->ai_flags & AI_CANONNAME) != 0) {
+ ai->ai_canonname = (char *)malloc(strlen(str) + 1);
+ if (ai->ai_canonname == NULL)
+ return EAI_MEMORY;
+ strcpy(ai->ai_canonname, str);
+ }
+ return 0;
+}
+
+static struct addrinfo *
+get_ai(pai, afd, addr)
+ const struct addrinfo *pai;
+ const struct afd *afd;
+ const char *addr;
+{
+ char *p;
+ struct addrinfo *ai;
+
+ ai = (struct addrinfo *)malloc(sizeof(struct addrinfo)
+ + (afd->a_socklen));
+ if (ai == NULL)
+ return NULL;
+
+ memcpy(ai, pai, sizeof(struct addrinfo));
+ ai->ai_addr = (struct sockaddr *)(ai + 1);
+ memset(ai->ai_addr, 0, afd->a_socklen);
+#ifdef HAVE_SOCKADDR_SA_LEN
+ ai->ai_addr->sa_len = afd->a_socklen;
+#endif
+ ai->ai_addrlen = afd->a_socklen;
+ ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
+ p = (char *)(ai->ai_addr);
+ memcpy(p + afd->a_off, addr, afd->a_addrlen);
+ return ai;
+}
+
+static int
+get_portmatch(ai, servname)
+ const struct addrinfo *ai;
+ const char *servname;
+{
+ /* get_port does not touch first argument. when matchonly == 1. */
+ return get_port((struct addrinfo *)ai, servname, 1);
+}
+
+static int
+get_port(ai, servname, matchonly)
+ struct addrinfo *ai;
+ const char *servname;
+ int matchonly;
+{
+ const char *proto;
+ struct servent *sp;
+ int port;
+ int allownumeric;
+
+ if (servname == NULL)
+ return 0;
+ if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
+ return 0;
+
+ switch (ai->ai_socktype) {
+ case SOCK_RAW:
+ return EAI_SERVICE;
+ case SOCK_DGRAM:
+ case SOCK_STREAM:
+ allownumeric = 1;
+ break;
+ case ANY:
+ allownumeric = 0;
+ break;
+ default:
+ return EAI_SOCKTYPE;
+ }
+
+ if (str_isnumber(servname)) {
+ if (!allownumeric)
+ return EAI_SERVICE;
+ port = htons(atoi(servname));
+ if (port < 0 || port > 65535)
+ return EAI_SERVICE;
+ } else {
+ switch (ai->ai_socktype) {
+ case SOCK_DGRAM:
+ proto = "udp";
+ break;
+ case SOCK_STREAM:
+ proto = "tcp";
+ break;
+ default:
+ proto = NULL;
+ break;
+ }
+
+ if ((sp = getservbyname(servname, proto)) == NULL)
+ return EAI_SERVICE;
+ port = sp->s_port;
+ }
+
+ if (!matchonly) {
+ switch (ai->ai_family) {
+ case AF_INET:
+ ((struct sockaddr_in *)ai->ai_addr)->sin_port = port;
+ break;
+#ifdef INET6
+ case AF_INET6:
+ ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = port;
+ break;
+#endif
+ }
+ }
+
+ return 0;
+}
+
+static const struct afd *
+find_afd(af)
+ int af;
+{
+ const struct afd *afd;
+
+ if (af == PF_UNSPEC)
+ return NULL;
+ for (afd = afdl; afd->a_af; afd++) {
+ if (afd->a_af == af)
+ return afd;
+ }
+ return NULL;
+}
diff --git a/missing/getnameinfo.c b/missing/getnameinfo.c
new file mode 100644
index 00000000..19545e58
--- /dev/null
+++ b/missing/getnameinfo.c
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Issues to be discussed:
+ * - Thread safe-ness must be checked
+ * - Return values. There seems to be no standard for return value (RFC2553)
+ * but INRIA implementation returns EAI_xxx defined for getaddrinfo().
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+#include <netdb.h>
+#include <resolv.h>
+#include <string.h>
+#include <stddef.h>
+
+#ifndef HAVE_PORTABLE_PROTOTYPE
+#include "cdecl_ext.h"
+#endif
+
+#ifndef HAVE_ADDRINFO
+#include "addrinfo.h"
+#endif
+
+#define SUCCESS 0
+#define ANY 0
+#define YES 1
+#define NO 0
+
+static struct afd {
+ int a_af;
+ int a_addrlen;
+ int a_socklen;
+ int a_off;
+} afdl [] = {
+#ifdef INET6
+ {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
+ offsetof(struct sockaddr_in6, sin6_addr)},
+#endif
+ {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
+ offsetof(struct sockaddr_in, sin_addr)},
+ {0, 0, 0},
+};
+
+struct sockinet {
+ u_char si_len;
+ u_char si_family;
+ u_short si_port;
+};
+
+#define ENI_NOSOCKET 0
+#define ENI_NOSERVNAME 1
+#define ENI_NOHOSTNAME 2
+#define ENI_MEMORY 3
+#define ENI_SYSTEM 4
+#define ENI_FAMILY 5
+#define ENI_SALEN 6
+
+int
+getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
+ const struct sockaddr *sa;
+ size_t salen;
+ char *host;
+ size_t hostlen;
+ char *serv;
+ size_t servlen;
+ int flags;
+{
+ struct afd *afd;
+ struct servent *sp;
+ struct hostent *hp;
+ u_short port;
+ int family, i;
+ char *addr, *p;
+ u_long v4a;
+ int h_error;
+ char numserv[512];
+ char numaddr[512];
+
+ if (sa == NULL)
+ return ENI_NOSOCKET;
+
+#ifdef HAVE_SA_LEN /*XXX*/
+ if (sa->sa_len != salen)
+ return ENI_SALEN;
+#endif
+
+ family = sa->sa_family;
+ for (i = 0; afdl[i].a_af; i++)
+ if (afdl[i].a_af == family) {
+ afd = &afdl[i];
+ goto found;
+ }
+ return ENI_FAMILY;
+
+ found:
+ if (salen != afd->a_socklen)
+ return ENI_SALEN;
+
+ port = ((struct sockinet *)sa)->si_port; /* network byte order */
+ addr = (char *)sa + afd->a_off;
+
+ if (serv == NULL || servlen == 0) {
+ /* what we should do? */
+ } else {
+ if (flags & NI_NUMERICSERV)
+ sp = NULL;
+ else {
+ sp = getservbyport(port,
+ (flags & NI_DGRAM) ? "udp" : "tcp");
+ }
+ if (sp) {
+ if (strlen(sp->s_name) > servlen)
+ return ENI_MEMORY;
+ strcpy(serv, sp->s_name);
+ } else {
+ snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
+ if (strlen(numserv) > servlen)
+ return ENI_MEMORY;
+ strcpy(serv, numserv);
+ }
+ }
+
+ switch (sa->sa_family) {
+ case AF_INET:
+ v4a = ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
+ if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
+ flags |= NI_NUMERICHOST;
+ v4a >>= IN_CLASSA_NSHIFT;
+ if (v4a == 0 || v4a == IN_LOOPBACKNET)
+ flags |= NI_NUMERICHOST;
+ break;
+#ifdef INET6
+ case AF_INET6:
+ {
+ struct sockaddr_in6 *sin6;
+ sin6 = (struct sockaddr_in6 *)sa;
+ switch (sin6->sin6_addr.s6_addr[0]) {
+ case 0x00:
+ if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
+ ;
+ else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
+ ;
+ else
+ flags |= NI_NUMERICHOST;
+ break;
+ default:
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
+ flags |= NI_NUMERICHOST;
+ }
+ else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
+ flags |= NI_NUMERICHOST;
+ break;
+ }
+ }
+ break;
+#endif
+ }
+ if (host == NULL || hostlen == 0) {
+ /* what should we do? */
+ } else if (flags & NI_NUMERICHOST) {
+ /* NUMERICHOST and NAMEREQD conflicts with each other */
+ if (flags & NI_NAMEREQD)
+ return ENI_NOHOSTNAME;
+ if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
+ == NULL)
+ return ENI_SYSTEM;
+ if (strlen(numaddr) > hostlen)
+ return ENI_MEMORY;
+ strcpy(host, numaddr);
+#ifdef INET6
+ if (afd->a_af == AF_INET6 &&
+ (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) ||
+ IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) &&
+ ((struct sockaddr_in6 *)sa)->sin6_scope_id) {
+#ifndef ALWAYS_WITHSCOPE
+ if (flags & NI_WITHSCOPEID)
+#endif /* !ALWAYS_WITHSCOPE */
+ {
+ char *ep = strchr(host, '\0');
+ unsigned int ifindex =
+ ((struct sockaddr_in6 *)sa)->sin6_scope_id;
+
+ *ep = SCOPE_DELIMITER;
+ if ((if_indextoname(ifindex, ep + 1)) == NULL)
+ /* XXX what should we do? */
+ strncpy(ep + 1, "???", 3);
+ }
+ }
+#endif /* INET6 */
+ } else {
+#ifdef USE_GETIPNODEBY
+ hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
+#else
+ hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
+ h_error = h_errno;
+#endif
+
+ if (hp) {
+ if (flags & NI_NOFQDN) {
+ p = strchr(hp->h_name, '.');
+ if (p) *p = '\0';
+ }
+ if (strlen(hp->h_name) > hostlen) {
+#ifdef USE_GETIPNODEBY
+ freehostent(hp);
+#endif
+ return ENI_MEMORY;
+ }
+ strcpy(host, hp->h_name);
+#ifdef USE_GETIPNODEBY
+ freehostent(hp);
+#endif
+ } else {
+ if (flags & NI_NAMEREQD)
+ return ENI_NOHOSTNAME;
+ if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
+ == NULL)
+ return ENI_NOHOSTNAME;
+ if (strlen(numaddr) > hostlen)
+ return ENI_MEMORY;
+ strcpy(host, numaddr);
+ }
+ }
+ return SUCCESS;
+}
diff --git a/missing/resolv6.h b/missing/resolv6.h
new file mode 100644
index 00000000..b1d45c0c
--- /dev/null
+++ b/missing/resolv6.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Resolver options for IPv6.
+ * XXX: this should be in an offical include file. There may be conflicts...
+ */
+#ifndef HAVE_RES_USE_INET6
+#define RES_USE_INET6 0x80000000 /* use/map IPv6 in gethostbyname() */
+#endif
diff --git a/missing/resolv_ext.h b/missing/resolv_ext.h
new file mode 100644
index 00000000..c33ed7e1
--- /dev/null
+++ b/missing/resolv_ext.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef MAXRESOLVSORT /* XXX */
+#define MAXRESOLVSORT 10 /* number of net to sort on */
+#endif
+
+#ifndef HAVE_RES_STATE_EXT
+struct __res_state_ext {
+ struct sockaddr_storage nsaddr_list[MAXNS];
+ struct {
+ int af; /* address family for addr, mask */
+ union {
+ struct in_addr ina;
+#ifdef INET6
+ struct in6_addr in6a;
+#endif
+ } addr, mask;
+ } sort_list[MAXRESOLVSORT];
+};
+#endif
+
+extern struct __res_state_ext _res_ext;
diff --git a/missing/sockstorage.h b/missing/sockstorage.h
new file mode 100644
index 00000000..557eb4df
--- /dev/null
+++ b/missing/sockstorage.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+struct sockaddr_storage {
+#ifdef HAVE_SOCKADDR_SA_LEN
+ u_int8_t __ss_len;
+ u_int8_t __ss_family;
+ u_int8_t fill[126];
+#else
+ u_int8_t __ss_family;
+ u_int8_t fill[127];
+#endif /* HAVE_SOCKADDR_SA_LEN */
+};
diff --git a/oakley.h b/oakley.h
new file mode 100644
index 00000000..27178e0a
--- /dev/null
+++ b/oakley.h
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/* YIPS @(#)$Id: oakley.h,v 1.1 1999-10-30 05:11:10 itojun Exp $ */
+
+/* refer to RFC 2409 */
+
+#if !defined(_ISAKMP_OAKLEY_H_)
+#define _ISAKMP_OAKLEY_H_
+
+/* Attribute Classes */
+#define OAKLEY_ATTR_ENC_ALG 1 /* B */
+#define OAKLEY_ATTR_ENC_ALG_DES 1
+#define OAKLEY_ATTR_ENC_ALG_IDEA 2
+#define OAKLEY_ATTR_ENC_ALG_BL 3
+#define OAKLEY_ATTR_ENC_ALG_RC5 4
+#define OAKLEY_ATTR_ENC_ALG_3DES 5
+#define OAKLEY_ATTR_ENC_ALG_CAST 6
+#define OAKLEY_ATTR_HASH_ALG 2 /* B */
+#define OAKLEY_ATTR_HASH_ALG_MD5 1
+#define OAKLEY_ATTR_HASH_ALG_SHA 2
+#define OAKLEY_ATTR_HASH_ALG_TIGER 3
+#define OAKLEY_ATTR_AUTH_METHOD 3 /* B */
+#define OAKLEY_ATTR_AUTH_METHOD_PSKEY 1
+#define OAKLEY_ATTR_AUTH_METHOD_DSS 2
+#define OAKLEY_ATTR_AUTH_METHOD_RSA 3
+#define OAKLEY_ATTR_AUTH_METHOD_RSAENC 4
+#define OAKLEY_ATTR_AUTH_METHOD_RSAREV 5
+#define OAKLEY_ATTR_GRP_DESC 4 /* B */
+#define OAKLEY_ATTR_GRP_DESC_MODP768 1
+#define OAKLEY_ATTR_GRP_DESC_MODP1024 2
+#define OAKLEY_ATTR_GRP_DESC_EC2N155 3
+#define OAKLEY_ATTR_GRP_DESC_EC2N185 4
+#define OAKLEY_ATTR_GRP_TYPE 5 /* B */
+#define OAKLEY_ATTR_GRP_TYPE_MODP 1
+#define OAKLEY_ATTR_GRP_TYPE_ECP 2
+#define OAKLEY_ATTR_GRP_TYPE_EC2N 3
+#define OAKLEY_ATTR_GRP_PI 6 /* V */
+#define OAKLEY_ATTR_GRP_GEN_ONE 7 /* V */
+#define OAKLEY_ATTR_GRP_GEN_TWO 8 /* V */
+#define OAKLEY_ATTR_GRP_CURVE_A 9 /* V */
+#define OAKLEY_ATTR_GRP_CURVE_B 10 /* V */
+#define OAKLEY_ATTR_SA_LTYPE 11 /* B */
+#define OAKLEY_ATTR_SA_LTYPE_DEFAULT 1
+#define OAKLEY_ATTR_SA_LTYPE_SEC 1
+#define OAKLEY_ATTR_SA_LTYPE_KB 2
+#define OAKLEY_ATTR_SA_LDUR 12 /* V */
+#define OAKLEY_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
+#define OAKLEY_ATTR_PRF 13 /* B */
+#define OAKLEY_ATTR_KEY_LEN 14 /* B */
+#define OAKLEY_ATTR_FIELD_SIZE 15 /* B */
+#define OAKLEY_ATTR_GRP_ORDER 16 /* V */
+
+#define OAKLEY_ID_IPV4_ADDR 0
+#define OAKLEY_ID_IPV4_ADDR_SUBNET 1
+#define OAKLEY_ID_IPV6_ADDR 2
+#define OAKLEY_ID_IPV6_ADDR_SUBNET 3
+
+/* Additional Exchange Type */
+#define ISAKMP_ETYPE_QUICK 32
+#define ISAKMP_ETYPE_NEWGRP 33
+
+/* The use for checking proposal payload. This is not exchange type. */
+#define OAKLEY_MAIN_MODE 0
+#define OAKLEY_QUICK_MODE 1
+
+#define OAKLEY_PRIME_MODP768 "\
+ FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
+ 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
+ EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
+ E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF"
+
+#define OAKLEY_PRIME_MODP1024 "\
+ FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
+ 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
+ EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
+ E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED \
+ EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 \
+ FFFFFFFF FFFFFFFF"
+
+#define DEFAULTSECRETSIZE ( 128 / 8 ) /* 128 bits */
+#define DEFAULTNONCESIZE ( 128 / 8 ) /* 128 bits */
+
+#define MAXPADLWORD 20
+
+#if 0
+/* isakmp sa structure */
+struct oakley_sa {
+ u_int8_t proto_id; /* OAKLEY */
+ vchar_t *spi; /* spi */
+ u_int8_t dhgrp; /* DH; group */
+ u_int8_t auth_t; /* method of authentication */
+ u_int8_t prf_t; /* type of prf */
+ u_int8_t hash_t; /* type of hash */
+ u_int8_t enc_t; /* type of cipher */
+ u_int8_t life_t; /* type of duration of lifetime */
+ u_int32_t ldur; /* life duration */
+};
+#endif
+
+#endif /* !defined(_ISAKMP_OAKLEY_H_) */
diff --git a/ospf6.h b/ospf6.h
new file mode 100644
index 00000000..85e81d7f
--- /dev/null
+++ b/ospf6.h
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
+ */
+#define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */
+#define OSPF_TYPE_HELLO 1 /* Hello */
+#define OSPF_TYPE_DB 2 /* Database Description */
+#define OSPF_TYPE_LSR 3 /* Link State Request */
+#define OSPF_TYPE_LSU 4 /* Link State Update */
+#define OSPF_TYPE_LSA 5 /* Link State Ack */
+#define OSPF_TYPE_MAX 6
+
+/* Options *_options */
+#define OSPF6_OPTION_V6 0x01 /* V6 bit: A bit for peeping tom */
+#define OSPF6_OPTION_E 0x02 /* E bit: External routes advertised */
+#define OSPF6_OPTION_MC 0x04 /* MC bit: Multicast capable */
+#define OSPF6_OPTION_N 0x08 /* N bit: For type-7 LSA */
+#define OSPF6_OPTION_R 0x10 /* R bit: Router bit */
+#define OSPF6_OPTION_DC 0x20 /* DC bit: Demand circuits */
+
+
+/* db_flags */
+#define OSPF6_DB_INIT 0x04 /* */
+#define OSPF6_DB_MORE 0x02
+#define OSPF6_DB_MASTER 0x01
+
+/* ls_type */
+#define LS_TYPE_ROUTER 1 /* router link */
+#define LS_TYPE_NETWORK 2 /* network link */
+#define LS_TYPE_INTER_AP 3 /* Inter-Area-Prefix */
+#define LS_TYPE_INTER_AR 4 /* Inter-Area-Router */
+#define LS_TYPE_ASE 5 /* ASE */
+#define LS_TYPE_GROUP 6 /* Group membership */
+#define LS_TYPE_TYPE7 7 /* Type 7 LSA */
+#define LS_TYPE_LINK 8 /* Link LSA */
+#define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */
+#define LS_TYPE_MAX 10
+#define LS_TYPE_MASK 0x1fff
+
+#define LS_SCOPE_LINKLOCAL 0x0000
+#define LS_SCOPE_AREA 0x2000
+#define LS_SCOPE_AS 0x4000
+#define LS_SCOPE_MASK 0x6000
+
+/*************************************************
+ *
+ * is the above a bug in the documentation?
+ *
+ *************************************************/
+
+
+/* rla_link.link_type */
+#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */
+#define RLA_TYPE_TRANSIT 2 /* connection to transit network */
+#define RLA_TYPE_VIRTUAL 4 /* virtual link */
+
+/* rla_flags */
+#define RLA_FLAG_B 0x01
+#define RLA_FLAG_E 0x02
+#define RLA_FLAG_V 0x04
+#define RLA_FLAG_W 0x08
+
+/* sla_tosmetric breakdown */
+#define SLA_MASK_TOS 0x7f000000
+#define SLA_MASK_METRIC 0x00ffffff
+#define SLA_SHIFT_TOS 24
+
+/* asla_tosmetric breakdown */
+#define ASLA_FLAG_EXTERNAL 0x80000000
+#define ASLA_MASK_TOS 0x7f000000
+#define ASLA_SHIFT_TOS 24
+#define ASLA_MASK_METRIC 0x00ffffff
+
+/* multicast vertex type */
+#define MCLA_VERTEX_ROUTER 1
+#define MCLA_VERTEX_NETWORK 2
+
+typedef u_int32_t rtrid_t;
+
+/* link state advertisement header */
+struct lsa_hdr {
+ u_int16_t ls_age;
+ u_int16_t ls_type;
+ rtrid_t ls_stateid;
+ rtrid_t ls_router;
+ u_int32_t ls_seq;
+ u_int16_t ls_chksum;
+ u_int16_t ls_length;
+} ;
+
+struct lsa_prefix {
+ u_int8_t lsa_p_len;
+ u_int8_t lsa_p_opt;
+ u_int16_t lsa_p_mbz;
+ u_int8_t lsa_p_prefix[4];
+};
+
+/* link state advertisement */
+struct lsa {
+ struct lsa_hdr ls_hdr;
+
+ /* Link state types */
+ union {
+ /* Router links advertisements */
+ struct {
+ union {
+ u_int8_t flg;
+ u_int32_t opt;
+ } rla_flgandopt;
+#define rla_flags rla_flgandopt.flg
+#define rla_options rla_flgandopt.opt
+ struct rlalink {
+ u_int8_t link_type;
+ u_int8_t link_zero[1];
+ u_int16_t link_metric;
+ u_int32_t link_ifid;
+ u_int32_t link_nifid;
+ rtrid_t link_nrtid;
+ } rla_link[1]; /* may repeat */
+ } un_rla;
+
+ /* Network links advertisements */
+ struct {
+ u_int32_t nla_options;
+ rtrid_t nla_router[1]; /* may repeat */
+ } un_nla;
+
+ /* Inter Area Prefix LSA */
+ struct {
+ u_int32_t inter_ap_metric;
+ struct lsa_prefix inter_ap_prefix[1];
+ } un_inter_ap;
+
+#if 0
+ /* Summary links advertisements */
+ struct {
+ struct in_addr sla_mask;
+ u_int32_t sla_tosmetric[1]; /* may repeat */
+ } un_sla;
+
+ /* AS external links advertisements */
+ struct {
+ struct in_addr asla_mask;
+ struct aslametric {
+ u_int32_t asla_tosmetric;
+ struct in_addr asla_forward;
+ struct in_addr asla_tag;
+ } asla_metric[1]; /* may repeat */
+ } un_asla;
+
+ /* Multicast group membership */
+ struct mcla {
+ u_int32_t mcla_vtype;
+ struct in_addr mcla_vid;
+ } un_mcla[1];
+#endif
+
+ /* Type 7 LSA */
+
+ /* Link LSA */
+ struct llsa {
+ union {
+ u_int8_t pri;
+ u_int32_t opt;
+ } llsa_priandopt;
+#define llsa_priority llsa_priandopt.pri
+#define llsa_options llsa_priandopt.opt
+ struct in6_addr llsa_lladdr;
+ u_int32_t llsa_nprefix;
+ struct lsa_prefix llsa_prefix[1];
+ } un_llsa;
+
+ /* Intra-Area-Prefix */
+ struct {
+ u_int16_t intra_ap_nprefix;
+ u_int16_t intra_ap_lstype;
+ rtrid_t intra_ap_lsid;
+ rtrid_t intra_ap_rtid;
+ struct lsa_prefix intra_ap_prefix[1];
+ } un_intra_ap;
+ } lsa_un;
+} ;
+
+
+/*
+ * TOS metric struct (will be 0 or more in router links update)
+ */
+struct tos_metric {
+ u_int8_t tos_type;
+ u_int8_t tos_zero;
+ u_int16_t tos_metric;
+} ;
+
+#define OSPF_AUTH_SIZE 8
+
+/*
+ * the main header
+ */
+struct ospf6hdr {
+ u_int8_t ospf6_version;
+ u_int8_t ospf6_type;
+ u_int16_t ospf6_len;
+ rtrid_t ospf6_routerid;
+ rtrid_t ospf6_areaid;
+ u_int16_t ospf6_chksum;
+ u_int8_t ospf6_instanceid;
+ u_int8_t ospf6_rsvd;
+ union {
+
+ /* Hello packet */
+ struct {
+ u_int32_t hello_ifid;
+ union {
+ u_int8_t pri;
+ u_int32_t opt;
+ } hello_priandopt;
+#define hello_priority hello_priandopt.pri
+#define hello_options hello_priandopt.opt
+ u_int16_t hello_helloint;
+ u_int16_t hello_deadint;
+ rtrid_t hello_dr;
+ rtrid_t hello_bdr;
+ rtrid_t hello_neighbor[1]; /* may repeat */
+ } un_hello;
+
+ /* Database Description packet */
+ struct {
+ u_int32_t db_options;
+ u_int16_t db_mtu;
+ u_int8_t db_mbz;
+ u_int8_t db_flags;
+ u_int32_t db_seq;
+ struct lsa_hdr db_lshdr[1]; /* may repeat */
+ } un_db;
+
+ /* Link State Request */
+ struct lsr {
+ u_int16_t ls_mbz;
+ u_int16_t ls_type;
+ rtrid_t ls_stateid;
+ rtrid_t ls_router;
+ } un_lsr[1]; /* may repeat */
+
+ /* Link State Update */
+ struct {
+ u_int32_t lsu_count;
+ struct lsa lsu_lsa[1]; /* may repeat */
+ } un_lsu;
+
+ /* Link State Acknowledgement */
+ struct {
+ struct lsa_hdr lsa_lshdr[1]; /* may repeat */
+ } un_lsa ;
+ } ospf6_un ;
+} ;
+
+#define ospf6_hello ospf6_un.un_hello
+#define ospf6_db ospf6_un.un_db
+#define ospf6_lsr ospf6_un.un_lsr
+#define ospf6_lsu ospf6_un.un_lsu
+#define ospf6_lsa ospf6_un.un_lsa
+
diff --git a/print-ah.c b/print-ah.c
index b4fae2eb..525e32a0 100644
--- a/print-ah.c
+++ b/print-ah.c
@@ -31,70 +31,69 @@ static char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
+#include <net/route.h>
+#include <net/if.h>
+
#include <netinet/in.h>
+#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
-#undef NOERROR /* Solaris sucks */
-#include <arpa/nameser.h>
-#include <arpa/tftp.h>
-
-#ifdef SOLARIS
-#include <tiuser.h>
-#endif
-#include <rpc/rpc.h>
-
-#include <errno.h>
#include <stdio.h>
+/* there's no standard definition so we are on our own */
+struct ah {
+ u_int8_t ah_nxt; /* Next Header */
+ u_int8_t ah_len; /* Length of data, in 32bit */
+ u_int16_t ah_reserve; /* Reserved for future use */
+ u_int32_t ah_spi; /* Security parameter index */
+ /* variable size, 32bit bound*/ /* Authentication data */
+};
+
+struct newah {
+ u_int8_t ah_nxt; /* Next Header */
+ u_int8_t ah_len; /* Length of data + 1, in 32bit */
+ u_int16_t ah_reserve; /* Reserved for future use */
+ u_int32_t ah_spi; /* Security parameter index */
+ u_int32_t ah_seq; /* Sequence number field */
+ /* variable size, 32bit bound*/ /* Authentication data */
+};
+
#include "interface.h"
#include "addrtoname.h"
-extern int packettype;
-
-
-void
-ah_print(register const u_char *bp, int length, register const u_char *bp2)
+int
+ah_print(register const u_char *bp, register const u_char *bp2)
{
- register const struct ip *ip;
- register const u_char *cp, *nh;
- u_short nextheader;
- u_short ahlen, authlen;
- u_long spi, seqno;
-
- ip = (struct ip *)bp2;
-
- (void)printf("AH %s > %s\n\t\t",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
-
- if (length < 8) {
- (void)printf(" [|ah] truncated-ah %d", length);
- return;
- }
-
- nextheader = bp[0];
- ahlen = bp[1];
- spi = ntohl(*((u_long *)(bp+4)));
- seqno = ntohl(*((u_long *)(bp+8)));
- authlen = ahlen - 12;
-
- nh = bp+ahlen;
-
- if(authlen > length || authlen == 0)
- {
- authlen = length;
- }
-
- (void)printf("spi:%08x seqno:%d authlen: %d authdata: ", spi,
- seqno, authlen);
- (void)default_print_unaligned(bp+12, authlen);
-
- /* PRINT rest of packet, requires some reorg of print-ip.c */
-#if XXX
- (void)ip_print(nextheader, ip, nh, length-authlen);
-#endif
+ register const struct ah *ah;
+ register const u_char *ep;
+ int sumlen;
+ u_int32_t spi;
+
+ ah = (struct ah *)bp;
+ ep = snapend; /* 'ep' points to the end of avaible data. */
+
+ if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
+ goto trunc;
+
+ sumlen = ah->ah_len << 2;
+ spi = (u_int32_t)ntohl(ah->ah_spi);
+
+ printf("AH(spi=%u", spi);
+ if (vflag)
+ printf(",sumlen=%d", sumlen);
+ printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));
+ if (bp + sizeof(struct ah) + sumlen > ep)
+ fputs("[truncated]", stdout);
+ fputs("): ", stdout);
+
+ return sizeof(struct ah) + sumlen;
+ trunc:
+ fputs("[|AH]", stdout);
+ return 65535;
}
diff --git a/print-atalk.c b/print-atalk.c
index e6782c01..0a5a3f67 100644
--- a/print-atalk.c
+++ b/print-atalk.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.49 1999-10-17 21:37:11 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.50 1999-10-30 05:11:10 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -39,8 +39,10 @@ struct rtentry;
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/if_ether.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
diff --git a/print-atm.c b/print-atm.c
index 13f5369f..74dc4c74 100644
--- a/print-atm.c
+++ b/print-atm.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.10 1999-10-17 21:37:11 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.11 1999-10-30 05:11:11 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -37,7 +37,9 @@ struct rtentry;
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
@@ -103,6 +105,12 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
ip_print(p, length);
break;
+#ifdef INET6
+ case ETHERTYPE_IPV6:
+ ip6_print(p, length);
+ break;
+#endif /*INET6*/
+
/*XXX this probably isn't right */
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
diff --git a/print-bgp.c b/print-bgp.c
new file mode 100644
index 00000000..dde15baf
--- /dev/null
+++ b/print-bgp.c
@@ -0,0 +1,615 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#include <errno.h>
+#include <stdio.h>
+
+#include <netinet/ip6.h>
+
+#include "route6d.h"
+#include "interface.h"
+#include "addrtoname.h"
+
+struct bgp {
+ u_int8_t bgp_marker[16];
+ u_int16_t bgp_len;
+ u_int8_t bgp_type;
+};
+#define BGP_SIZE 19 /* unaligned */
+
+#define BGP_OPEN 1
+#define BGP_UPDATE 2
+#define BGP_NOTIFICATION 3
+#define BGP_KEEPALIVE 4
+
+struct bgp_open {
+ u_int8_t bgpo_marker[16];
+ u_int16_t bgpo_len;
+ u_int8_t bgpo_type;
+ u_int8_t bgpo_version;
+ u_int16_t bgpo_myas;
+ u_int16_t bgpo_holdtime;
+ u_int32_t bgpo_id;
+ u_int8_t bgpo_optlen;
+ /* options should follow */
+};
+
+struct bgp_notification {
+ u_int8_t bgpn_marker[16];
+ u_int16_t bgpn_len;
+ u_int8_t bgpn_type;
+ u_int8_t bgpn_major;
+ u_int8_t bgpn_minor;
+ /* data should follow */
+};
+
+struct bgp_attr {
+ u_int8_t bgpa_flags;
+ u_int8_t bgpa_type;
+ union {
+ u_int8_t len;
+ u_int16_t elen;
+ } bgpa_len;
+#define bgp_attr_len(p) \
+ (((p)->bgpa_flags & 0x10) ? \
+ ntohs((p)->bgpa_len.elen) : (p)->bgpa_len.len)
+#define bgp_attr_off(p) \
+ (((p)->bgpa_flags & 0x10) ? 4 : 3)
+};
+
+#define BGPTYPE_ORIGIN 1
+#define BGPTYPE_AS_PATH 2
+#define BGPTYPE_NEXT_HOP 3
+#define BGPTYPE_MULTI_EXIT_DISC 4
+#define BGPTYPE_LOCAL_PREF 5
+#define BGPTYPE_ATOMIC_AGGREGATE 6
+#define BGPTYPE_AGGREGATOR 7
+#define BGPTYPE_MP_REACH_NLRI 14 /* RFC2283 */
+#define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2283 */
+
+
+static const char *bgptype[] = {
+ NULL, "OPEN", "UPDATE", "NOTIFICATION", "KEEPALIVE",
+};
+#define bgp_type(x) num_or_str(bgptype, sizeof(bgptype)/sizeof(bgptype[0]), (x))
+
+static const char *bgpnotify_major[] = {
+ NULL, "Message Header Error",
+ "OPEN Message Error", "UPDATE Message Error",
+ "Hold Timer Expired", "Finite State Machine Error",
+ "Cease",
+};
+#define bgp_notify_major(x) \
+ num_or_str(bgpnotify_major, \
+ sizeof(bgpnotify_major)/sizeof(bgpnotify_major[0]), (x))
+
+static const char *bgpnotify_minor_1[] = {
+ NULL, "Connection Not Synchronized",
+ "Bad Message Length", "Bad Message Type",
+};
+
+static const char *bgpnotify_minor_2[] = {
+ NULL, "Unsupported Version Number",
+ "Bad Peer AS", "Bad BGP Identifier",
+ "Unsupported Optional Parameter", "Authentication Failure",
+ "Unacceptable Hold Time",
+};
+
+static const char *bgpnotify_minor_3[] = {
+ NULL, "Malformed Attribute List",
+ "Unrecognized Well-known Attribute", "Missing Well-known Attribute",
+ "Attribute Flags Error", "Attribute Length Error",
+ "Invalid ORIGIN Attribute", "AS Routing Loop",
+ "Invalid NEXT_HOP Attribute", "Optional Attribute Error",
+ "Invalid Network Field", "Malformed AS_PATH",
+};
+
+static const char **bgpnotify_minor[] = {
+ NULL, bgpnotify_minor_1, bgpnotify_minor_2, bgpnotify_minor_3,
+};
+static const int bgpnotify_minor_siz[] = {
+ 0, sizeof(bgpnotify_minor_1)/sizeof(bgpnotify_minor_1[0]),
+ sizeof(bgpnotify_minor_2)/sizeof(bgpnotify_minor_2[0]),
+ sizeof(bgpnotify_minor_3)/sizeof(bgpnotify_minor_3[0]),
+};
+
+static const char *bgpattr_origin[] = {
+ "IGP", "EGP", "INCOMPLETE",
+};
+#define bgp_attr_origin(x) \
+ num_or_str(bgpattr_origin, \
+ sizeof(bgpattr_origin)/sizeof(bgpattr_origin[0]), (x))
+
+static const char *bgpattr_type[] = {
+ NULL, "ORIGIN", "AS_PATH", "NEXT_HOP",
+ "MULTI_EXIT_DISC", "LOCAL_PREF", "ATOMIC_AGGREGATE", "AGGREGATOR",
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, "MP_REACH_NLRI", "MP_UNREACH_NLRI",
+};
+#define bgp_attr_type(x) \
+ num_or_str(bgpattr_type, \
+ sizeof(bgpattr_type)/sizeof(bgpattr_type[0]), (x))
+
+/* Subsequent address family identifier, RFC2283 section 7 */
+static const char *bgpattr_nlri_safi[] = {
+ "Reserved", "Unicast", "Multicast", "Unicast+Multicast",
+};
+#define bgp_attr_nlri_safi(x) \
+ num_or_str(bgpattr_nlri_safi, \
+ sizeof(bgpattr_nlri_safi)/sizeof(bgpattr_nlri_safi[0]), (x))
+
+/* RFC1700 address family numbers */
+#define AFNUM_INET 1
+#define AFNUM_INET6 2
+#define AFNUM_NSAP 3
+#define AFNUM_HDLC 4
+#define AFNUM_BBN1822 5
+#define AFNUM_802 6
+#define AFNUM_E163 7
+#define AFNUM_E164 8
+#define AFNUM_F69 9
+#define AFNUM_X121 10
+#define AFNUM_IPX 11
+#define AFNUM_ATALK 12
+#define AFNUM_DECNET 13
+#define AFNUM_BANYAN 14
+#define AFNUM_E164NSAP 15
+
+static const char *afnumber[] = {
+ "Reserved", "IPv4", "IPv6", "NSAP", "HDLC",
+ "BBN 1822", "802", "E.163", "E.164", "F.69",
+ "X.121", "IPX", "Appletalk", "Decnet IV", "Banyan Vines",
+ "E.164 with NSAP subaddress",
+};
+#define af_name(x) \
+ (((x) == 65535) ? afnumber[0] : \
+ num_or_str(afnumber, \
+ sizeof(afnumber)/sizeof(afnumber[0]), (x)))
+
+
+static const char *
+num_or_str(const char **table, size_t siz, int value)
+{
+ static char buf[20];
+ if (value < 0 || siz <= value || table[value] == NULL) {
+ snprintf(buf, sizeof(buf), "#%d", value);
+ return buf;
+ } else
+ return table[value];
+}
+
+static const char *
+bgp_notify_minor(int major, int minor)
+{
+ static const char **table;
+ int siz;
+ static char buf[20];
+ const char *p;
+
+ if (0 <= major
+ && major < sizeof(bgpnotify_minor)/sizeof(bgpnotify_minor[0])
+ && bgpnotify_minor[major]) {
+ table = bgpnotify_minor[major];
+ siz = bgpnotify_minor_siz[major];
+ if (0 <= minor && minor < siz && table[minor])
+ p = table[minor];
+ else
+ p = NULL;
+ } else
+ p = NULL;
+ if (p == NULL) {
+ snprintf(buf, sizeof(buf), "#%d", minor);
+ return buf;
+ } else
+ return p;
+}
+
+static int
+decode_prefix4(const u_char *pd, char *buf, int buflen)
+{
+ struct in_addr addr;
+ int plen;
+
+ plen = pd[0];
+ if (plen < 0 || 32 < plen)
+ return -1;
+
+ memset(&addr, 0, sizeof(addr));
+ memcpy(&addr, &pd[1], (plen + 7) / 8);
+ if (plen % 8) {
+ ((u_char *)&addr)[(plen + 7) / 8 - 1] &=
+ ((0xff00 >> (plen % 8)) & 0xff);
+ }
+ snprintf(buf, buflen, "%s/%d", getname((char *)&addr), plen);
+ return 1 + (plen + 7) / 8;
+}
+
+#ifdef INET6
+static int
+decode_prefix6(const u_char *pd, char *buf, int buflen)
+{
+ struct in6_addr addr;
+ int plen;
+
+ plen = pd[0];
+ if (plen < 0 || 128 < plen)
+ return -1;
+
+ memset(&addr, 0, sizeof(addr));
+ memcpy(&addr, &pd[1], (plen + 7) / 8);
+ if (plen % 8) {
+ addr.s6_addr[(plen + 7) / 8 - 1] &=
+ ((0xff00 >> (plen % 8)) & 0xff);
+ }
+ snprintf(buf, buflen, "%s/%d", getname6((char *)&addr), plen);
+ return 1 + (plen + 7) / 8;
+}
+#endif
+
+static void
+bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
+{
+ int i;
+ u_int16_t af;
+ u_int8_t safi, snpa;
+ int advance;
+ int tlen;
+ const char *s;
+ const u_char *p;
+ char buf[256];
+
+ p = dat;
+
+ switch (attr->bgpa_type) {
+ case BGPTYPE_ORIGIN:
+ if (len != 1)
+ printf(" invalid len");
+ else
+ printf(" %s", bgp_attr_origin(p[0]));
+ break;
+ case BGPTYPE_AS_PATH:
+ if (len % 2) {
+ printf(" invalid len");
+ break;
+ }
+ for (i = 0; i < len; i += 2)
+ printf(" %u", ntohs(*(u_int16_t *)&p[i]));
+ break;
+ case BGPTYPE_NEXT_HOP:
+ if (len != 4)
+ printf(" invalid len");
+ else
+ printf(" %s", getname(p));
+ break;
+ case BGPTYPE_MULTI_EXIT_DISC:
+ case BGPTYPE_LOCAL_PREF:
+ if (len != 4)
+ printf(" invalid len");
+ else
+ printf(" %u", (u_int32_t)ntohl(*(u_int32_t *)p));
+ break;
+ case BGPTYPE_ATOMIC_AGGREGATE:
+ if (len != 0)
+ printf(" invalid len");
+ break;
+ case BGPTYPE_AGGREGATOR:
+ if (len != 6) {
+ printf(" invalid len");
+ break;
+ }
+ printf(" AS #%u, origin %s", ntohs(*(u_int16_t *)p),
+ getname(p + 2));
+ break;
+ case BGPTYPE_MP_REACH_NLRI:
+ af = ntohs(*(u_int16_t *)p);
+ safi = p[2];
+ if (safi >= 128)
+ printf(" %s vendor specific,", af_name(af));
+ else {
+ printf(" %s %s,", af_name(af),
+ bgp_attr_nlri_safi(safi));
+ }
+ p += 3;
+
+ if (af == AFNUM_INET)
+ ;
+#ifdef INET6
+ else if (af == AFNUM_INET6)
+ ;
+#endif
+ else
+ break;
+
+ tlen = p[0];
+ if (tlen) {
+ printf(" nexthop");
+ if (af == AFNUM_INET)
+ advance = 4;
+#ifdef INET6
+ else if (af == AFNUM_INET6)
+ advance = 16;
+#endif
+
+ for (i = 0; i < tlen; i += advance) {
+ if (af == AFNUM_INET)
+ printf(" %s", getname(p + 1 + i));
+#ifdef INET6
+ else if (af == AFNUM_INET6)
+ printf(" %s", getname6(p + 1 + i));
+#endif
+ }
+ printf(",");
+ }
+ p += 1 + tlen;
+
+ snpa = p[0];
+ p++;
+ if (snpa) {
+ printf(" %u snpa", snpa);
+ for (/*nothing*/; snpa > 0; snpa--) {
+ printf("(%d bytes)", p[0]);
+ p += p[0] + 1;
+ }
+ printf(",");
+ }
+
+ printf(" NLRI");
+ while (len - (p - dat) > 0) {
+ if (af == AFNUM_INET)
+ advance = decode_prefix4(p, buf, sizeof(buf));
+#ifdef INET6
+ else if (af == AFNUM_INET6)
+ advance = decode_prefix6(p, buf, sizeof(buf));
+#endif
+ printf(" %s", buf);
+
+ p += advance;
+ }
+
+ break;
+
+ case BGPTYPE_MP_UNREACH_NLRI:
+ af = ntohs(*(u_int16_t *)p);
+ safi = p[2];
+ if (safi >= 128)
+ printf(" %s vendor specific,", af_name(af));
+ else {
+ printf(" %s %s,", af_name(af),
+ bgp_attr_nlri_safi(safi));
+ }
+ p += 3;
+
+ printf(" Withdraw");
+ while (len - (p - dat) > 0) {
+ if (af == AFNUM_INET)
+ advance = decode_prefix4(p, buf, sizeof(buf));
+#ifdef INET6
+ else if (af == AFNUM_INET6)
+ advance = decode_prefix6(p, buf, sizeof(buf));
+#endif
+ printf(" %s", buf);
+
+ p += advance;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+bgp_open_print(const u_char *dat, int length)
+{
+ struct bgp_open bgpo;
+ int hlen;
+
+ memcpy(&bgpo, dat, sizeof(bgpo));
+ hlen = ntohs(bgpo.bgpo_len);
+
+ printf(": Version %d,", bgpo.bgpo_version);
+ printf(" AS #%u,", ntohs(bgpo.bgpo_myas));
+ printf(" Holdtime %u,", ntohs(bgpo.bgpo_holdtime));
+ printf(" ID %s,", getname((char *)&bgpo.bgpo_id));
+ printf(" Option length %u", bgpo.bgpo_optlen);
+}
+
+static void
+bgp_update_print(const u_char *dat, int length)
+{
+ struct bgp bgp;
+ struct bgp_attr bgpa;
+ int hlen;
+ const u_char *p;
+ int len;
+ int i, j;
+
+ memcpy(&bgp, dat, sizeof(bgp));
+ hlen = ntohs(bgp.bgp_len);
+ p = dat + BGP_SIZE; /*XXX*/
+ printf(":");
+
+ /* Unfeasible routes */
+ len = ntohs(*(u_int16_t *)p);
+ if (len) {
+ printf(" (Withdrawn routes: %d bytes)", len);
+ }
+ p += 2 + len;
+
+ len = ntohs(*(u_int16_t *)p);
+ if (len) {
+ /* do something more useful!*/
+ i = 2;
+ printf(" (Path attributes:"); /* ) */
+ while (i < 2 + len) {
+ int alen, aoff;
+
+ memcpy(&bgpa, &p[i], sizeof(bgpa));
+ alen = bgp_attr_len(&bgpa);
+ aoff = bgp_attr_off(&bgpa);
+
+ printf(" ("); /* ) */
+ printf("%s", bgp_attr_type(bgpa.bgpa_type));
+ if (bgpa.bgpa_flags) {
+ printf("[%s%s%s%s]",
+ bgpa.bgpa_flags & 0x80 ? "O" : "",
+ bgpa.bgpa_flags & 0x40 ? "T" : "",
+ bgpa.bgpa_flags & 0x20 ? "P" : "",
+ bgpa.bgpa_flags & 0x00 ? "E" : "");
+ }
+
+ bgp_attr_print(&bgpa, &p[i + aoff], alen);
+
+#if 0
+ default:
+ proto_tree_add_text(subtree2, p - pd + i + aoff, alen,
+ "Unknown (%d bytes)", alen);
+ break;
+ }
+#endif
+
+ /* ( */
+ printf(")");
+
+ i += aoff + alen;
+ }
+
+ /* ( */
+ printf(")");
+ }
+ p += 2 + len;
+
+}
+
+static void
+bgp_notification_print(const u_char *dat, int length)
+{
+ struct bgp_notification bgpn;
+ int hlen;
+
+ memcpy(&bgpn, dat, sizeof(bgpn));
+ hlen = ntohs(bgpn.bgpn_len);
+
+ printf(": error %s,", bgp_notify_major(bgpn.bgpn_major));
+ printf(" subcode %s",
+ bgp_notify_minor(bgpn.bgpn_major, bgpn.bgpn_minor));
+}
+
+static void
+bgp_header_print(const u_char *dat, int length, int newline)
+{
+ struct bgp bgp;
+
+ memcpy(&bgp, dat, sizeof(bgp));
+ printf(newline ? "\n\t" : " ");
+ printf("(%s", bgp_type(bgp.bgp_type)); /* ) */
+
+ switch (bgp.bgp_type) {
+ case BGP_OPEN:
+ bgp_open_print(dat, length);
+ break;
+ case BGP_UPDATE:
+ bgp_update_print(dat, length);
+ break;
+ case BGP_NOTIFICATION:
+ bgp_notification_print(dat, length);
+ break;
+ }
+
+ /* ( */
+ printf(")");
+}
+
+void
+bgp_print(const u_char *dat, int length)
+{
+ const u_char *p;
+ const u_char *ep;
+ const u_char marker[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ struct bgp bgp;
+ u_int16_t hlen;
+ int newline;
+
+ ep = dat + length;
+ if (snapend < dat + length)
+ ep = snapend;
+
+ printf(": BGP");
+
+ p = dat;
+ newline = 0;
+ while (p < snapend) {
+ if (!TTEST2(p[0], 1))
+ break;
+ if (p[0] != 0xff) {
+ p++;
+ continue;
+ }
+
+ if (!TTEST2(p[0], sizeof(marker)))
+ break;
+ if (memcmp(p, marker, sizeof(marker)) != 0) {
+ p++;
+ continue;
+ }
+
+ /* found BGP header */
+ TCHECK2(p[0], BGP_SIZE); /*XXX*/
+ memcpy(&bgp, p, sizeof(bgp));
+
+ hlen = ntohs(bgp.bgp_len);
+ if (TTEST2(p[0], hlen)) {
+ bgp_header_print(p, hlen, vflag ? newline : 0);
+ newline = 1;
+ p += hlen;
+ } else {
+ printf(" [|BGP %s]", bgp_type(bgp.bgp_type));
+ break;
+ }
+ }
+
+ return;
+
+trunc:
+ printf(" [|BGP]");
+}
diff --git a/print-chdlc.c b/print-chdlc.c
new file mode 100644
index 00000000..88903a50
--- /dev/null
+++ b/print-chdlc.c
@@ -0,0 +1,192 @@
+/* maybe it should be merged into print-ppp.c */
+/*
+ * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.1 1999-10-30 05:11:11 itojun Exp $ (LBL)";
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
+
+#include <ctype.h>
+#include <netdb.h>
+#include <pcap.h>
+#include <stdio.h>
+#ifdef __bsdi__
+#include <net/slcompress.h>
+#include <net/if_ppp.h>
+#endif
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "ppp.h"
+
+/* XXX This goes somewhere else. */
+#define CHDLC_HDRLEN 4
+#define CHDLC_UNICAST 0x0f
+#define CHDLC_BCAST 0x8f
+#define CHDLC_TYPE_SLARP 0x8035
+#define CHDLC_TYPE_CDP 0x2000
+
+static void chdlc_slarp_print(const u_char *, u_int);
+
+/* Standard CHDLC printer */
+void
+chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
+ register const u_char *p)
+{
+ register u_int length = h->len;
+ register u_int caplen = h->caplen;
+ const struct ip *ip;
+ u_int proto;
+
+ ts_print(&h->ts);
+
+ if (caplen < CHDLC_HDRLEN) {
+ printf("[|chdlc]");
+ goto out;
+ }
+
+ /*
+ * Some printers want to get back at the link level addresses,
+ * and/or check that they're not walking off the end of the packet.
+ * Rather than pass them all the way down, we set these globals.
+ */
+ proto = ntohs(*(u_short *)&p[2]);
+ packetp = p;
+ snapend = p + caplen;
+
+ if (eflag) {
+ switch (p[0]) {
+ case CHDLC_UNICAST:
+ printf("unicast ");
+ break;
+ case CHDLC_BCAST:
+ printf("bcast ");
+ break;
+ default:
+ printf("0x%02x ", p[0]);
+ break;
+ }
+ printf("%d %04x: ", length, proto);
+ }
+
+ length -= CHDLC_HDRLEN;
+ ip = (struct ip *)(p + CHDLC_HDRLEN);
+ switch(proto) {
+ case ETHERTYPE_IP:
+ ip_print((const u_char *)ip, length);
+ break;
+#ifdef INET6
+ case ETHERTYPE_IPV6:
+ ip6_print((const u_char *)ip, length);
+ break;
+#endif
+ case CHDLC_TYPE_SLARP:
+ chdlc_slarp_print((const u_char *)ip, length);
+ break;
+#if 0
+ case CHDLC_TYPE_CDP:
+ chdlc_cdp_print((const u_char *)ip, length);
+ break;
+#endif
+ }
+ if (xflag)
+ default_print((const u_char *)ip, caplen - CHDLC_HDRLEN);
+out:
+ putchar('\n');
+}
+
+struct cisco_slarp {
+ long code;
+#define SLARP_REQUEST 0
+#define SLARP_REPLY 1
+#define SLARP_KEEPALIVE 2
+ union {
+ struct {
+ struct in_addr addr;
+ struct in_addr mask;
+ u_short unused[3];
+ } addr;
+ struct {
+ long myseq;
+ long yourseq;
+ short rel;
+ short t1;
+ short t2;
+ } keep;
+ } un;
+};
+
+#define SLARP_LEN 18
+
+static void
+chdlc_slarp_print(const u_char *cp, u_int length)
+{
+ struct cisco_slarp *slarp;
+
+ if (length < SLARP_LEN) {
+ printf("[|slarp]");
+ return;
+ }
+
+ slarp = (struct cisco_slarp *)cp;
+ switch (ntohl(slarp->code)) {
+ case SLARP_REQUEST:
+ printf("slarp-request");
+ break;
+ case SLARP_REPLY:
+ printf("slarp-reply %s/%s",
+ ipaddr_string(&slarp->un.addr.addr),
+ ipaddr_string(&slarp->un.addr.mask));
+ break;
+ case SLARP_KEEPALIVE:
+ printf("slarp-keepalive my=0x%x your=0x%x ",
+ (u_int32_t)ntohl(slarp->un.keep.myseq),
+ (u_int32_t)ntohl(slarp->un.keep.yourseq));
+ printf("reliability=0x%04x t1=%d.%d",
+ ntohs(slarp->un.keep.rel), ntohs(slarp->un.keep.t1),
+ ntohs(slarp->un.keep.t2));
+ break;
+ default:
+ printf("slarp-0x%x unknown", (u_int32_t)ntohl(slarp->code));
+ break;
+ }
+
+ if (SLARP_LEN < length && vflag)
+ printf("(trailing junk: %d bytes)", length - SLARP_LEN);
+}
diff --git a/print-dhcp6.c b/print-dhcp6.c
new file mode 100644
index 00000000..c5268a90
--- /dev/null
+++ b/print-dhcp6.c
@@ -0,0 +1,336 @@
+/*
+ * Copyright (C) 1998 and 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.1 1999-10-30 05:11:12 itojun Exp $";
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+
+#include <netinet/in.h>
+
+#include <ctype.h>
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "dhcp6.h"
+#include "dhcp6opt.h"
+
+#if 0
+static void dhcp6opttab_init __P((void));
+#endif
+static struct dhcp6_opt *dhcp6opttab_byname __P((char *));
+static struct dhcp6_opt *dhcp6opttab_bycode __P((u_int));
+
+static char tstr[] = " [|dhcp6]";
+
+static struct dhcp6_opt dh6opttab[] = {
+ /* IP Address Extension */
+ { 1, OL6_N, "IP Address", OT6_NONE, },
+
+ /* General Extension */
+ { 2, 4, "Time Offset", OT6_NUM, },
+ { 3, OL6_N, "IEEE 1003.1 POSIX Timezone", OT6_STR, },
+ { 6, OL6_16N, "Domain Name Server", OT6_V6, },
+ { 10, OL6_N, "Domain Name", OT6_STR, },
+
+ /* Application and Service Parameters */
+ { 16, OL6_N, "Directory Agent", OT6_NONE, },
+ { 17, OL6_N, "Service Scope" , OT6_NONE, },
+ { 18, OL6_16N, "Network Time Protocol Servers", OT6_V6, },
+ { 19, OL6_N, "NIS Domain", OT6_STR, },
+ { 20, OL6_16N, "NIS Servers", OT6_V6, },
+ { 21, OL6_N, "NIS+ Domain", OT6_STR, },
+ { 22, OL6_16N, "NIS+ Servers", OT6_V6, },
+
+ /* TCP Parameters */
+ { 32, 4, "TCP Keepalive Interval", OT6_NUM, },
+
+ /* DHCPv6 Extensions */
+ { 40, 4, "Maximum DHCPv6 Message Size", OT6_NUM, },
+ { 41, OL6_N, "DHCP Retransmission and Configuration Parameter",
+ OT6_NONE, },
+ { 48, OL6_N, "Platform Specific Information", OT6_NONE, },
+ { 49, OL6_N, "Platform Class Identifier", OT6_STR, },
+ { 64, OL6_N, "Class Identifier", OT6_STR, },
+ { 66, 16, "Reconfigure Multicast Address", OT6_V6, },
+ { 67, 16, "Renumber DHCPv6 Server Address",
+ OT6_V6, },
+ { 68, OL6_N, "DHCP Relay ICMP Error Message", OT6_NONE, },
+ { 84, OL6_N, "Client-Server Authentication", OT6_NONE, },
+ { 85, 4, "Client Key Selection", OT6_NUM, },
+
+ /* End Extension */
+ { 65536, OL6_Z, "End", OT6_NONE, },
+
+ { 0 },
+};
+
+#if 0
+static struct dhcp6_opt *dh6o_pad;
+static struct dhcp6_opt *dh6o_end;
+
+static void
+dhcp6opttab_init()
+{
+ dh6o_pad = dhcp6opttab_bycode(0);
+ dh6o_end = dhcp6opttab_bycode(65536);
+}
+#endif
+
+static struct dhcp6_opt *
+dhcp6opttab_byname(name)
+ char *name;
+{
+ struct dhcp6_opt *p;
+
+ for (p = dh6opttab; p->code; p++)
+ if (strcmp(name, p->name) == 0)
+ return p;
+ return NULL;
+}
+
+static struct dhcp6_opt *
+dhcp6opttab_bycode(code)
+ u_int code;
+{
+ struct dhcp6_opt *p;
+
+ for (p = dh6opttab; p->code; p++)
+ if (p->code == code)
+ return p;
+ return NULL;
+}
+
+static void
+dhcp6ext_print(u_char *cp, u_char *ep)
+{
+ u_int16_t code, len;
+ struct dhcp6_opt *p;
+ char *q;
+ char buf[BUFSIZ];
+ int i;
+
+ if (cp == ep)
+ return;
+ printf(" ");
+ while (cp < ep) {
+ code = ntohs(*(u_int16_t *)&cp[0]);
+ if (code != 65535)
+ len = ntohs(*(u_int16_t *)&cp[2]);
+ else
+ len = 0;
+ p = dhcp6opttab_bycode(code);
+ if (p == NULL) {
+ printf("(unknown, len=%d)", len);
+ cp += len + 4;
+ continue;
+ }
+
+ /* sanity check on length */
+ switch (p->len) {
+ case OL6_N:
+ break;
+ case OL6_16N:
+ if (len % 16 != 0)
+ goto trunc;
+ break;
+ case OL6_Z:
+ if (len != 0)
+ goto trunc;
+ break;
+ default:
+ if (len != p->len)
+ goto trunc;
+ break;
+ }
+ if (cp + 4 + len > ep) {
+ printf("[|%s]", p->name);
+ return;
+ }
+
+ printf("(%s, ", p->name);
+ switch (p->type) {
+ case OT6_V6:
+ for (i = 0; i < len; i += 16) {
+ inet_ntop(AF_INET6, &cp[4 + i], buf,
+ sizeof(buf));
+ if (i != 0)
+ printf(",");
+ printf("%s", buf);
+ }
+ break;
+ case OT6_STR:
+ memset(&buf, 0, sizeof(buf));
+ strncpy(buf, &cp[4], len);
+ printf("%s", buf);
+ break;
+ case OT6_NUM:
+ printf("%d", (u_int32_t)ntohl(*(u_int32_t *)&cp[4]));
+ break;
+ default:
+ for (i = 0; i < len; i++)
+ printf("%02x", cp[4 + i] & 0xff);
+ }
+ printf(")");
+ cp += len + 4;
+ }
+ return;
+
+trunc:
+ printf("[|dhcp6ext]");
+}
+
+/*
+ * Print dhcp6 requests
+ */
+void
+dhcp6_print(register const u_char *cp, u_int length,
+ u_short sport, u_short dport)
+{
+ union dhcp6 *dh6;
+ u_char *ep;
+ u_char *extp;
+
+ printf("dhcp6");
+
+ ep = (u_char *)snapend;
+
+ dh6 = (union dhcp6 *)cp;
+ TCHECK(dh6->dh6_msgtype);
+ switch (dh6->dh6_msgtype) {
+ case DH6_SOLICIT:
+ if (vflag && TTEST(dh6->dh6_sol.dh6sol_relayaddr)) {
+ printf(" solicit(");
+ if ((dh6->dh6_sol.dh6sol_flags & DH6SOL_CLOSE) != 0)
+ printf("C");
+ if (dh6->dh6_sol.dh6sol_flags != 0)
+ printf(" ");
+ printf("cliaddr=%s",
+ ip6addr_string(&dh6->dh6_sol.dh6sol_cliaddr));
+ printf(" relayaddr=%s",
+ ip6addr_string(&dh6->dh6_sol.dh6sol_relayaddr));
+ printf(")");
+ } else
+ printf(" solicit");
+ break;
+ case DH6_ADVERT:
+ if (!(vflag && TTEST(dh6->dh6_adv.dh6adv_serveraddr))) {
+ printf(" advert");
+ break;
+ }
+ printf(" advert(");
+ if ((dh6->dh6_adv.dh6adv_flags & DH6ADV_SERVPRESENT) != 0)
+ printf("S");
+ if (dh6->dh6_adv.dh6adv_flags != 0)
+ printf(" ");
+ printf("pref=%u", dh6->dh6_adv.dh6adv_pref);
+ printf(" cliaddr=%s",
+ ip6addr_string(&dh6->dh6_adv.dh6adv_cliaddr));
+ printf(" relayaddr=%s",
+ ip6addr_string(&dh6->dh6_adv.dh6adv_relayaddr));
+ printf(" servaddr=%s",
+ ip6addr_string(&dh6->dh6_adv.dh6adv_serveraddr));
+ extp = (u_char *)((&dh6->dh6_adv) + 1);
+ dhcp6ext_print(extp, ep);
+ printf(")");
+ break;
+ case DH6_REQUEST:
+ if (!(vflag && TTEST(dh6->dh6_req.dh6req_relayaddr))) {
+ printf(" request");
+ break;
+ }
+ printf(" request(");
+ if ((dh6->dh6_req.dh6req_flags & DH6REQ_CLOSE) != 0)
+ printf("C");
+ if ((dh6->dh6_req.dh6req_flags & DH6REQ_SERVPRESENT) != 0)
+ printf("S");
+ if ((dh6->dh6_req.dh6req_flags & DH6REQ_REBOOT) != 0)
+ printf("R");
+ if (dh6->dh6_req.dh6req_flags != 0)
+ printf(" ");
+ printf("xid=0x%04x", dh6->dh6_req.dh6req_xid);
+ printf(" cliaddr=%s",
+ ip6addr_string(&dh6->dh6_req.dh6req_cliaddr));
+ printf(" relayaddr=%s",
+ ip6addr_string(&dh6->dh6_req.dh6req_relayaddr));
+ extp = (char *)((&dh6->dh6_req) + 1);
+ if ((dh6->dh6_req.dh6req_flags & DH6REQ_SERVPRESENT) != 0) {
+ printf(" servaddr=%s", ip6addr_string(extp));
+ extp += 16;
+ }
+ dhcp6ext_print(extp, ep);
+ printf(")");
+ break;
+ case DH6_REPLY:
+ if (!(vflag && TTEST(dh6->dh6_rep.dh6rep_xid))) {
+ printf(" reply");
+ break;
+ }
+ printf(" reply(");
+ if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_CLIPRESENT) != 0)
+ printf("C");
+ if (dh6->dh6_rep.dh6rep_flagandstat != 0)
+ printf(" ");
+ printf("stat=0x%02x",
+ dh6->dh6_rep.dh6rep_flagandstat & DH6REP_STATMASK);
+ extp = (u_char *)((&dh6->dh6_rep) + 1);
+ if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_CLIPRESENT) != 0) {
+ printf(" cliaddr=%s", ip6addr_string(extp));
+ extp += 16;
+ }
+ dhcp6ext_print(extp, ep);
+ printf(")");
+ break;
+ case DH6_RELEASE:
+ printf(" release");
+ break;
+ case DH6_RECONFIG:
+ printf(" reconfig");
+ break;
+ }
+ return;
+
+trunc:
+ printf("%s", tstr);
+}
diff --git a/print-domain.c b/print-domain.c
index 498e9bc8..e251df88 100644
--- a/print-domain.c
+++ b/print-domain.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.40 1999-10-17 21:37:11 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.41 1999-10-30 05:11:12 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -38,7 +38,9 @@ struct rtentry;
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#ifdef NOERROR
@@ -50,6 +52,7 @@ struct rtentry;
#include <arpa/nameser.h>
#include <stdio.h>
+#include <string.h>
#include "interface.h"
#include "addrtoname.h"
@@ -98,6 +101,27 @@ struct rtentry;
#ifndef T_LOC
#define T_LOC 29 /* Location Information */
#endif
+#ifndef T_NXT
+#define T_NXT 30 /* Next Valid Name in Zone */
+#endif
+#ifndef T_EID
+#define T_EID 31 /* Endpoint identifier */
+#endif
+#ifndef T_NIMLOC
+#define T_NIMLOC 32 /* Nimrod locator */
+#endif
+#ifndef T_SRV
+#define T_SRV 33 /* Server selection */
+#endif
+#ifndef T_ATMA
+#define T_ATMA 34 /* ATM Address */
+#endif
+#ifndef T_NAPTR
+#define T_NAPTR 35 /* Naming Authority PoinTeR */
+#endif
+#ifndef T_A6
+#define T_A6 38 /* IP6 address (ipngwg-dns-lookups) */
+#endif
#ifndef T_UNSPEC
#define T_UNSPEC 103 /* Unspecified format (binary data) */
@@ -216,7 +240,14 @@ static struct tok type2str[] = {
{ T_PX, "PX" },
{ T_GPOS, "GPOS" },
{ T_AAAA, "AAAA" },
- { T_LOC , "LOC " },
+ { T_LOC, "LOC " },
+ { T_NXT, "NXT " },
+ { T_EID, "EID " },
+ { T_NIMLOC, "NIMLOC " },
+ { T_SRV, "SRV " },
+ { T_ATMA, "ATMA " },
+ { T_NAPTR, "NAPTR " },
+ { T_A6, "A6 " },
#ifndef T_UINFO
#define T_UINFO 100
#endif
@@ -314,6 +345,9 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
case T_NS:
case T_CNAME:
case T_PTR:
+#ifdef T_DNAME
+ case T_DNAME: /*XXX not checked as there's no server support yet*/
+#endif
putchar(' ');
(void)ns_nprint(cp, bp);
break;
@@ -329,6 +363,25 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
(void)ns_cprint(cp, bp);
break;
+#ifdef INET6
+ case T_AAAA:
+ printf(" %s", ip6addr_string(cp));
+ break;
+
+ case T_A6: /*XXX not checked as there's no server support yet*/
+ {
+ struct in6_addr a;
+ int pbyte;
+
+ pbyte = (*cp + 7) / 8;
+ memset(&a, 0, sizeof(a));
+ memcpy(&a, cp + 1, pbyte);
+ printf(" %u %s ", *cp, ip6addr_string(&a));
+ (void)ns_nprint(cp + 1 + pbyte, bp);
+ break;
+ }
+#endif /*INET6*/
+
case T_UNSPECA: /* One long string */
printf(" %.*s", len, cp);
break;
diff --git a/print-dvmrp.c b/print-dvmrp.c
index a538405d..41c5183b 100644
--- a/print-dvmrp.c
+++ b/print-dvmrp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.14 1999-10-17 21:37:12 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.15 1999-10-30 05:11:12 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -31,7 +31,9 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
diff --git a/print-esp.c b/print-esp.c
index 07d192cb..2be2fdc7 100644
--- a/print-esp.c
+++ b/print-esp.c
@@ -26,62 +26,307 @@ static char rcsid[] =
"@(#) Header: print-ah.c,v 1.37 94/06/10 17:01:42 mccanne Exp (LBL)";
#endif
+#include <string.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <net/route.h>
+#include <net/if.h>
+
#include <netinet/in.h>
+#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
-#undef NOERROR /* Solaris sucks */
-#include <arpa/nameser.h>
-#include <arpa/tftp.h>
-
-#ifdef SOLARIS
-#include <tiuser.h>
+#ifdef CRYPTO
+#include <des.h>
+#include <blowfish.h>
+#ifdef HAVE_RC5_H
+#include <rc5.h>
+#endif
+#ifdef HAVE_CAST_H
+#include <cast.h>
+#endif
#endif
-#include <rpc/rpc.h>
-#include <errno.h>
#include <stdio.h>
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
+
+/* there's no standard definition so we are on our own */
+struct esp {
+ u_int32_t esp_spi; /* ESP */
+ /*variable size, 32bit bound*/ /* Initialization Vector */
+ /*variable size*/ /* Payload data */
+ /*variable size*/ /* padding */
+ /*8bit*/ /* pad size */
+ /*8bit*/ /* next header */
+ /*8bit*/ /* next header */
+ /*variable size, 32bit bound*/ /* Authentication data (new IPsec) */
+};
+
+struct newesp {
+ u_int32_t esp_spi; /* ESP */
+ u_int32_t esp_seq; /* Sequence number */
+ /*variable size*/ /* (IV and) Payload data */
+ /*variable size*/ /* padding */
+ /*8bit*/ /* pad size */
+ /*8bit*/ /* next header */
+ /*8bit*/ /* next header */
+ /*variable size, 32bit bound*/ /* Authentication data */
+};
+
#include "interface.h"
#include "addrtoname.h"
-extern int packettype;
+int
+esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
+{
+ register const struct esp *esp;
+ register const u_char *ep;
+ u_int32_t spi;
+ enum { NONE, DESCBC, BLOWFISH, RC5, CAST128, DES3CBC } algo = NONE;
+ struct ip *ip = NULL;
+#ifdef INET6
+ struct ip6_hdr *ip6 = NULL;
+#endif
+ int advance;
+ int len;
+ char *secret = NULL;
+ int ivlen = 0;
+ u_char *ivoff;
+ esp = (struct esp *)bp;
+ spi = (u_int32_t)ntohl(esp->esp_spi);
-void
-esp_print(register const u_char *bp, int length, register const u_char *bp2)
-{
- register const struct ip *ip;
- register const u_char *cp, *nh;
- u_short ahlen, authlen;
- u_long spi, seqno;
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+
+ if ((u_char *)(esp + 1) >= ep - sizeof(struct esp)) {
+ fputs("[|ESP]", stdout);
+ goto fail;
+ }
+ printf("ESP(spi=%u", spi);
+ printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(esp + 1)));
+ printf(")");
+
+ /* if we don't have decryption key, we can't decrypt this packet. */
+ if (!espsecret)
+ goto fail;
+
+ if (strncmp(espsecret, "des-cbc:", 8) == 0
+ && strlen(espsecret + 8) == 8) {
+ algo = DESCBC;
+ ivlen = 8;
+ secret = espsecret + 8;
+ } else if (strncmp(espsecret, "blowfish-cbc:", 13) == 0) {
+ algo = BLOWFISH;
+ ivlen = 8;
+ secret = espsecret + 13;
+ } else if (strncmp(espsecret, "rc5-cbc:", 8) == 0) {
+ algo = RC5;
+ ivlen = 8;
+ secret = espsecret + 8;
+ } else if (strncmp(espsecret, "cast128-cbc:", 12) == 0) {
+ algo = CAST128;
+ ivlen = 8;
+ secret = espsecret + 12;
+ } else if (strncmp(espsecret, "3des-cbc:", 9) == 0
+ && strlen(espsecret + 9) == 24) {
+ algo = DES3CBC;
+ ivlen = 8;
+ secret = espsecret + 9;
+ } else if (strncmp(espsecret, "none:", 5) == 0) {
+ algo = NONE;
+ ivlen = 0;
+ secret = espsecret + 5;
+ } else if (strlen(espsecret) == 8) {
+ algo = DESCBC;
+ ivlen = 8;
+ secret = espsecret;
+ } else {
+ algo = NONE;
+ ivlen = 0;
+ secret = espsecret;
+ }
+
+ ip = (struct ip *)bp2;
+ switch (ip->ip_v) {
+#ifdef INET6
+ case 6:
+ ip6 = (struct ip6_hdr *)bp2;
+ ip = NULL;
+ /* we do not attempt to decrypt jumbograms */
+ if (!ntohs(ip6->ip6_plen))
+ goto fail;
+ /* if we can't get nexthdr, we do not need to decrypt it */
+ len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen);
+ break;
+#endif /*INET6*/
+ case 4:
+#ifdef INET6
+ ip6 = NULL;
+#endif
+ len = ntohs(ip->ip_len);
+ break;
+ default:
+ goto fail;
+ }
+
+ /* if we can't get nexthdr, we do not need to decrypt it */
+ if (ep - bp2 < len)
+ goto fail;
+
+ if (Rflag)
+ ivoff = (u_char *)(esp + 1) + sizeof(u_int32_t);
+ else
+ ivoff = (u_char *)(esp + 1);
+
+ switch (algo) {
+ case DESCBC:
+#ifdef CRYPTO
+ {
+ u_char iv[8];
+ des_key_schedule schedule;
+ u_char *p;
+
+ switch (ivlen) {
+ case 4:
+ memcpy(iv, ivoff, 4);
+ memcpy(&iv[4], ivoff, 4);
+ p = &iv[4];
+ *p++ ^= 0xff;
+ *p++ ^= 0xff;
+ *p++ ^= 0xff;
+ *p++ ^= 0xff;
+ break;
+ case 8:
+ memcpy(iv, ivoff, 8);
+ break;
+ default:
+ goto fail;
+ }
+
+ des_check_key = 0;
+ des_set_key((void *)secret, schedule);
+
+ p = ivoff + ivlen;
+ des_cbc_encrypt((void *)p, (void *)p,
+ (long)(ep - p), schedule, (void *)iv,
+ DES_DECRYPT);
+ advance = ivoff - (u_char *)esp + ivlen;
+ break;
+ }
+#else
+ goto fail;
+#endif /*CRYPTO*/
+
+ case BLOWFISH:
+#ifdef CRYPTO
+ {
+ BF_KEY schedule;
+ u_char *p;
+
+ BF_set_key(&schedule, strlen(secret), secret);
+
+ p = ivoff + ivlen;
+ BF_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff,
+ BF_DECRYPT);
+ advance = ivoff - (u_char *)esp + ivlen;
+ break;
+ }
+#else
+ goto fail;
+#endif /*CRYPTO*/
+
+ case RC5:
+#if defined(CRYPTO) && defined(HAVE_RC5_H)
+ {
+ RC5_32_KEY schedule;
+ u_char *p;
+
+ RC5_32_set_key(&schedule, strlen(secret), secret,
+ RC5_16_ROUNDS);
+
+ p = ivoff + ivlen;
+ RC5_32_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff,
+ RC5_DECRYPT);
+ advance = ivoff - (u_char *)esp + ivlen;
+ break;
+ }
+#else
+ goto fail;
+#endif /*CRYPTO*/
+
+ case CAST128:
+#if defined(CRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128)
+ {
+ CAST_KEY schedule;
+ u_char *p;
+
+ CAST_set_key(&schedule, strlen(secret), secret);
+
+ p = ivoff + ivlen;
+ CAST_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff,
+ CAST_DECRYPT);
+ advance = ivoff - (u_char *)esp + ivlen;
+ break;
+ }
+#else
+ goto fail;
+#endif /*CRYPTO*/
+
+ case DES3CBC:
+#if defined(CRYPTO)
+ {
+ des_key_schedule s1, s2, s3;
+ u_char *p;
- ip = (struct ip *)bp2;
+ des_check_key = 0;
+ des_set_key((void *)secret, s1);
+ des_set_key((void *)(secret + 8), s2);
+ des_set_key((void *)(secret + 16), s3);
- (void)printf("ESP %s > %s\n\t\t",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ p = ivoff + ivlen;
+ des_ede3_cbc_encrypt((void *)p, (void *)p,
+ (long)(ep - p), s1, s2, s3, (void *)ivoff, DES_DECRYPT);
+ advance = ivoff - (u_char *)esp + ivlen;
+ break;
+ }
+#else
+ goto fail;
+#endif /*CRYPTO*/
- if (length < 8) {
- (void)printf(" [|esp] truncated-esp %d", length);
- return;
- }
+ case NONE:
+ default:
+ if (Rflag)
+ advance = sizeof(struct esp) + sizeof(u_int32_t);
+ else
+ advance = sizeof(struct esp);
+ break;
+ }
- spi = ntohl(*((u_long *)(bp)));
- seqno = ntohl(*((u_long *)(bp+4)));
+ /* sanity check for pad length */
+ if (ep - bp < *(ep - 2))
+ goto fail;
- nh = bp+ahlen;
+ if (nhdr)
+ *nhdr = *(ep - 1);
- (void)printf("spi:%08x seqno:%d ciphertext: ", spi, seqno);
- (void)default_print_unaligned(bp+8, length-8);
+ printf(": ");
+ return advance;
- /* XXX it would be nice to decrypt! */
+fail:
+ if (nhdr)
+ *nhdr = -1;
+ return 65536;
}
diff --git a/print-ether.c b/print-ether.c
index 6c1c621c..4ce1e736 100644
--- a/print-ether.c
+++ b/print-ether.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.45 1999-10-17 21:37:12 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.46 1999-10-30 05:11:13 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -37,12 +37,18 @@ struct rtentry;
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <pcap.h>
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
+
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -163,6 +169,12 @@ ether_encap_print(u_short ethertype, const u_char *p,
ip_print(p, length);
return (1);
+#ifdef INET6
+ case ETHERTYPE_IPV6:
+ ip6_print(p, length);
+ return (1);
+#endif /*INET6*/
+
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
arp_print(p, length, caplen);
diff --git a/print-frag6.c b/print-frag6.c
new file mode 100644
index 00000000..6a85cfe2
--- /dev/null
+++ b/print-frag6.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) /master/usr.sbin/tcpdump/tcpdump/print-icmp.c,v 2.1 1995/02/03 18:14:42 polk Exp (LBL)";
+#endif
+
+#ifdef INET6
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+
+#include <stdio.h>
+
+#include <netinet/ip6.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+int
+frag6_print(register const u_char *bp, register const u_char *bp2)
+{
+ register const struct ip6_frag *dp;
+ register const struct ip6_hdr *ip6;
+ register const u_char *ep;
+
+#if 0
+#define TCHECK(var) if ((u_char *)&(var) >= ep - sizeof(var)) goto trunc
+#endif
+
+ dp = (struct ip6_frag *)bp;
+ ip6 = (struct ip6_hdr *)bp2;
+
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+
+ TCHECK(dp->ip6f_offlg);
+
+ if (vflag) {
+ printf("frag (0x%08x:%d|%d)",
+ ntohl(dp->ip6f_ident),
+ ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
+ sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
+ (bp - bp2) - sizeof(struct ip6_frag));
+ } else {
+ printf("frag (%d|%d)",
+ ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
+ sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
+ (bp - bp2) - sizeof(struct ip6_frag));
+ }
+
+#if 0
+ /* it is meaningless to decode non-first fragment */
+ if (ntohs(dp->ip6f_offlg & IP6F_OFF_MASK) != 0)
+ return 65535;
+ else
+#endif
+ {
+ fputs(" ", stdout);
+ return sizeof(struct ip6_frag);
+ }
+trunc:
+ fputs("[|frag]", stdout);
+ return 65535;
+#undef TCHECK
+}
+#endif /* INET6 */
diff --git a/print-icmp.c b/print-icmp.c
index 5eaddc30..5e50f3ac 100644
--- a/print-icmp.c
+++ b/print-icmp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.39 1999-10-17 21:37:12 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.40 1999-10-30 05:11:13 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -34,14 +34,14 @@ struct rtentry;
#endif
#include <net/if.h>
-#define __FAVOR_BSD
-
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
@@ -177,9 +177,11 @@ icmp_print(register const u_char *bp, register const u_char *bp2)
ip = (struct ip *)bp2;
str = buf;
+#if 0
(void)printf("%s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
+#endif
TCHECK(dp->icmp_code);
switch (dp->icmp_type) {
diff --git a/print-icmp6.c b/print-icmp6.c
new file mode 100644
index 00000000..b2ddfe80
--- /dev/null
+++ b/print-icmp6.c
@@ -0,0 +1,570 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) /master/usr.sbin/tcpdump/tcpdump/print-icmp.c,v 2.1 1995/02/03 18:14:42 polk Exp (LBL)";
+#endif
+
+#ifdef INET6
+
+#include <ctype.h>
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+
+#include <arpa/inet.h>
+
+#include <stdio.h>
+
+#include <netinet/ip6.h>
+#include <netinet/icmp6.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+void icmp6_opt_print(const u_char *, int);
+void mld6_print(const u_char *);
+
+void
+icmp6_print(register const u_char *bp, register const u_char *bp2)
+{
+ register const struct icmp6_hdr *dp;
+ register const struct ip6_hdr *ip;
+ register const char *str;
+ register const struct ip6_hdr *oip;
+ register const struct udphdr *ouh;
+ register int hlen, dport;
+ register const u_char *ep;
+ char buf[256];
+ int icmp6len;
+
+#if 0
+#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
+#endif
+
+ dp = (struct icmp6_hdr *)bp;
+ ip = (struct ip6_hdr *)bp2;
+ oip = (struct ip6_hdr *)(dp + 1);
+ str = buf;
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+ if (ip->ip6_plen)
+ icmp6len = (ntohs(ip->ip6_plen) + sizeof(struct ip6_hdr) -
+ (bp - bp2));
+ else /* XXX: jumbo payload case... */
+ icmp6len = snapend - bp;
+
+#if 0
+ (void)printf("%s > %s: ",
+ ip6addr_string(&ip->ip6_src),
+ ip6addr_string(&ip->ip6_dst));
+#endif
+
+ TCHECK(dp->icmp6_code);
+ switch(dp->icmp6_type) {
+ case ICMP6_DST_UNREACH:
+ TCHECK(oip->ip6_dst);
+ switch (dp->icmp6_code) {
+ case ICMP6_DST_UNREACH_NOROUTE:
+ printf("icmp6: %s unreachable route",
+ ip6addr_string(&oip->ip6_dst));
+ break;
+ case ICMP6_DST_UNREACH_ADMIN:
+ printf("icmp6: %s unreachable prohibited",
+ ip6addr_string(&oip->ip6_dst));
+ break;
+#ifdef ICMP6_DST_UNREACH_BEYONDSCOPE
+ case ICMP6_DST_UNREACH_BEYONDSCOPE:
+#else
+ case ICMP6_DST_UNREACH_NOTNEIGHBOR:
+#endif
+ printf("icmp6: %s beyond scope of source address %s",
+ ip6addr_string(&oip->ip6_dst),
+ ip6addr_string(&oip->ip6_src));
+ break;
+ case ICMP6_DST_UNREACH_ADDR:
+ printf("icmp6: %s unreachable address",
+ ip6addr_string(&oip->ip6_dst));
+ break;
+ case ICMP6_DST_UNREACH_NOPORT:
+ TCHECK(oip->ip6_nxt);
+ hlen = sizeof(struct ip6_hdr);
+ ouh = (struct udphdr *)(((u_char *)oip) + hlen);
+ dport = ntohs(ouh->uh_dport);
+ switch (oip->ip6_nxt) {
+ case IPPROTO_TCP:
+ printf("icmp6: %s tcp port %s unreachable",
+ ip6addr_string(&oip->ip6_dst),
+ tcpport_string(dport));
+ break;
+ case IPPROTO_UDP:
+ printf("icmp6: %s udp port %s unreachable",
+ ip6addr_string(&oip->ip6_dst),
+ udpport_string(dport));
+ break;
+ default:
+ printf("icmp6: %s protocol %d port %d unreachable",
+ ip6addr_string(&oip->ip6_dst),
+ oip->ip6_nxt, dport);
+ break;
+ }
+ break;
+ default:
+ printf("icmp6: %s unreachable code-#%d",
+ ip6addr_string(&oip->ip6_dst),
+ dp->icmp6_code);
+ break;
+ }
+ break;
+ case ICMP6_PACKET_TOO_BIG:
+ TCHECK(dp->icmp6_mtu);
+ printf("icmp6: too big %u\n", (u_int32_t)ntohl(dp->icmp6_mtu));
+ break;
+ case ICMP6_TIME_EXCEEDED:
+ TCHECK(oip->ip6_dst);
+ switch (dp->icmp6_code) {
+ case ICMP6_TIME_EXCEED_TRANSIT:
+ printf("icmp6: time exceeded in-transit for %s",
+ ip6addr_string(&oip->ip6_dst));
+ break;
+ case ICMP6_TIME_EXCEED_REASSEMBLY:
+ printf("icmp6: ip6 reassembly time exceeded");
+ break;
+ default:
+ printf("icmp6: time exceeded code-#%d",
+ dp->icmp6_code);
+ break;
+ }
+ break;
+ case ICMP6_PARAM_PROB:
+ TCHECK(oip->ip6_dst);
+ switch (dp->icmp6_code) {
+ case ICMP6_PARAMPROB_HEADER:
+ printf("icmp6: parameter problem errorneous - octet %u\n",
+ (u_int32_t)ntohl(dp->icmp6_pptr));
+ break;
+ case ICMP6_PARAMPROB_NEXTHEADER:
+ printf("icmp6: parameter problem next header - octet %u\n",
+ (u_int32_t)ntohl(dp->icmp6_pptr));
+ break;
+ case ICMP6_PARAMPROB_OPTION:
+ printf("icmp6: parameter problem option - octet %u\n",
+ (u_int32_t)ntohl(dp->icmp6_pptr));
+ break;
+ default:
+ printf("icmp6: parameter problem code-#%d",
+ dp->icmp6_code);
+ break;
+ }
+ break;
+ case ICMP6_ECHO_REQUEST:
+ printf("icmp6: echo request");
+ break;
+ case ICMP6_ECHO_REPLY:
+ printf("icmp6: echo reply");
+ break;
+ case ICMP6_MEMBERSHIP_QUERY:
+ printf("icmp6: multicast listener query ");
+ mld6_print((const u_char *)dp);
+ break;
+ case ICMP6_MEMBERSHIP_REPORT:
+ printf("icmp6: multicast listener report ");
+ mld6_print((const u_char *)dp);
+ break;
+ case ICMP6_MEMBERSHIP_REDUCTION:
+ printf("icmp6: multicast listener done ");
+ mld6_print((const u_char *)dp);
+ break;
+ case ND_ROUTER_SOLICIT:
+ printf("icmp6: router solicitation ");
+ if (vflag) {
+#define RTSOLLEN 8
+ icmp6_opt_print((const u_char *)dp + RTSOLLEN,
+ icmp6len - RTSOLLEN);
+ }
+ break;
+ case ND_ROUTER_ADVERT:
+ printf("icmp6: router advertisement");
+ if (vflag) {
+ struct nd_router_advert *p;
+
+ p = (struct nd_router_advert *)dp;
+ TCHECK(p->nd_ra_retransmit);
+ printf("(chlim=%d, ", (int)p->nd_ra_curhoplimit);
+ if (p->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED)
+ printf("M");
+ if (p->nd_ra_flags_reserved & ND_RA_FLAG_OTHER)
+ printf("O");
+ if (p->nd_ra_flags_reserved != 0)
+ printf(" ");
+ printf("router_ltime=%d, ", ntohs(p->nd_ra_router_lifetime));
+ printf("reachable_time=%u, ",
+ (u_int32_t)ntohl(p->nd_ra_reachable));
+ printf("retrans_time=%u)",
+ (u_int32_t)ntohl(p->nd_ra_retransmit));
+#define RTADVLEN 16
+ icmp6_opt_print((const u_char *)dp + RTADVLEN,
+ icmp6len - RTADVLEN);
+ }
+ break;
+ case ND_NEIGHBOR_SOLICIT:
+ {
+ struct nd_neighbor_solicit *p;
+ p = (struct nd_neighbor_solicit *)dp;
+ TCHECK(p->nd_ns_target);
+ printf("icmp6: neighbor sol: who has %s",
+ ip6addr_string(&p->nd_ns_target));
+ if (vflag) {
+#define NDSOLLEN 24
+ icmp6_opt_print((const u_char *)dp + NDSOLLEN,
+ icmp6len - NDSOLLEN);
+ }
+ }
+ break;
+ case ND_NEIGHBOR_ADVERT:
+ {
+ struct nd_neighbor_advert *p;
+
+ p = (struct nd_neighbor_advert *)dp;
+ TCHECK(p->nd_na_target);
+ printf("icmp6: neighbor adv: tgt is %s",
+ ip6addr_string(&p->nd_na_target));
+ if (vflag) {
+#define ND_NA_FLAG_ALL \
+ (ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
+ /* we don't need ntohl() here. see advanced-api-04. */
+ if (p->nd_na_flags_reserved & ND_NA_FLAG_ALL) {
+#undef ND_NA_FLAG_ALL
+ u_int32_t flags;
+
+ flags = p->nd_na_flags_reserved;
+ printf("(");
+ if (flags & ND_NA_FLAG_ROUTER)
+ printf("R");
+ if (flags & ND_NA_FLAG_SOLICITED)
+ printf("S");
+ if (flags & ND_NA_FLAG_OVERRIDE)
+ printf("O");
+ printf(")");
+ }
+#define NDADVLEN 24
+ icmp6_opt_print((const u_char *)dp + NDADVLEN,
+ icmp6len - NDADVLEN);
+ }
+ }
+ break;
+ case ND_REDIRECT:
+ {
+#define RDR(i) ((struct nd_redirect *)(i))
+ char tgtbuf[INET6_ADDRSTRLEN], dstbuf[INET6_ADDRSTRLEN];
+
+ TCHECK(RDR(dp)->nd_rd_dst);
+ inet_ntop(AF_INET6, &RDR(dp)->nd_rd_target,
+ tgtbuf, INET6_ADDRSTRLEN);
+ inet_ntop(AF_INET6, &RDR(dp)->nd_rd_dst,
+ dstbuf, INET6_ADDRSTRLEN);
+ printf("icmp6: redirect %s to %s", dstbuf, tgtbuf);
+#define REDIRECTLEN 40
+ if (vflag) {
+ icmp6_opt_print((const u_char *)dp + REDIRECTLEN,
+ icmp6len - REDIRECTLEN);
+ }
+ break;
+ }
+ case ICMP6_ROUTER_RENUMBERING:
+ switch (dp->icmp6_code) {
+ case ICMP6_ROUTER_RENUMBERING_COMMAND:
+ printf("icmp6: router renum command");
+ break;
+ case ICMP6_ROUTER_RENUMBERING_RESULT:
+ printf("icmp6: router renum result");
+ break;
+ default:
+ printf("icmp6: router renum code-#%d", dp->icmp6_code);
+ break;
+ }
+ break;
+#ifdef ICMP6_WRUREQUEST
+ case ICMP6_WRUREQUEST: /*ICMP6_FQDN_QUERY*/
+ {
+ int siz;
+ siz = ep - (u_char *)(dp + 1);
+ if (siz == 4)
+ printf("icmp6: who-are-you request");
+ else {
+ printf("icmp6: FQDN request");
+ if (vflag) {
+ if (siz < 8)
+ printf("?(icmp6_data %d bytes)", siz);
+ else if (8 < siz)
+ printf("?(extra %d bytes)", siz - 8);
+ }
+ }
+ break;
+ }
+#endif /*ICMP6_WRUREQUEST*/
+#ifdef ICMP6_WRUREPLY
+ case ICMP6_WRUREPLY: /*ICMP6_FQDN_REPLY*/
+ {
+ enum { UNKNOWN, WRU, FQDN } mode = UNKNOWN;
+ u_char const *buf;
+ u_char const *cp = NULL;
+
+ buf = (u_char *)(dp + 1);
+
+ /* fair guess */
+ if (buf[12] == ep - buf - 13)
+ mode = FQDN;
+ else if (dp->icmp6_code == 1)
+ mode = FQDN;
+
+ /* wild guess */
+ if (mode == UNKNOWN) {
+ cp = buf + 4;
+ while (cp < ep) {
+ if (!isprint(*cp++))
+ mode = FQDN;
+ }
+ }
+#ifndef abs
+#define abs(a) ((0 < (a)) ? (a) : -(a))
+#endif
+ if (mode == UNKNOWN && 2 < abs(buf[12] - (ep - buf - 13)))
+ mode = WRU;
+ if (mode == UNKNOWN)
+ mode = FQDN;
+
+ if (mode == WRU) {
+ cp = buf + 4;
+ printf("icmp6: who-are-you reply(\"");
+ } else if (mode == FQDN) {
+ cp = buf + 13;
+ printf("icmp6: FQDN reply(\"");
+ }
+ for (; cp < ep; cp++)
+ printf((isprint(*cp) ? "%c" : "\\%03o"), *cp);
+ printf("\"");
+ if (vflag) {
+ printf(",%s", mode == FQDN ? "FQDN" : "WRU");
+ if (mode == FQDN) {
+ long ttl;
+ ttl = (long)ntohl(*(u_long *)&buf[8]);
+ if (dp->icmp6_code == 1)
+ printf(",TTL=unknown");
+ else if (ttl < 0)
+ printf(",TTL=%ld:invalid", ttl);
+ else
+ printf(",TTL=%ld", ttl);
+ if (buf[12] != ep - buf - 13) {
+ (void)printf(",invalid namelen:%d/%u",
+ buf[12],
+ (unsigned int)(ep - buf - 13));
+ }
+ }
+ }
+ printf(")");
+ break;
+ }
+#endif /*ICMP6_WRUREPLY*/
+ default:
+ printf("icmp6: type-#%d", dp->icmp6_type);
+ break;
+ }
+ return;
+trunc:
+ fputs("[|icmp6]", stdout);
+#if 0
+#undef TCHECK
+#endif
+}
+
+void
+icmp6_opt_print(register const u_char *bp, int resid)
+{
+ register const struct nd_opt_hdr *op;
+ register const struct nd_opt_hdr *opl; /* why there's no struct? */
+ register const struct nd_opt_prefix_info *opp;
+ register const struct icmp6_opts_redirect *opr;
+ register const struct nd_opt_mtu *opm;
+ register const u_char *ep;
+ int opts_len;
+#if 0
+ register const struct ip6_hdr *ip;
+ register const char *str;
+ register const struct ip6_hdr *oip;
+ register const struct udphdr *ouh;
+ register int hlen, dport;
+ char buf[256];
+#endif
+
+#if 0
+#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
+#endif
+#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
+
+ op = (struct nd_opt_hdr *)bp;
+#if 0
+ ip = (struct ip6_hdr *)bp2;
+ oip = &dp->icmp6_ip6;
+ str = buf;
+#endif
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+
+ ECHECK(op->nd_opt_len);
+ if (resid <= 0)
+ return;
+ switch(op->nd_opt_type) {
+ case ND_OPT_SOURCE_LINKADDR:
+ opl = (struct nd_opt_hdr *)op;
+#if 1
+ if ((u_char *)opl + (opl->nd_opt_len << 3) > ep)
+ goto trunc;
+#else
+ TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
+#endif
+ printf("(src lladdr: %s",
+ etheraddr_string((u_char *)(opl + 1)));
+ if (opl->nd_opt_len != 1)
+ printf("!");
+ printf(")");
+ icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
+ resid - (op->nd_opt_len << 3));
+ break;
+ case ND_OPT_TARGET_LINKADDR:
+ opl = (struct nd_opt_hdr *)op;
+#if 1
+ if ((u_char *)opl + (opl->nd_opt_len << 3) > ep)
+ goto trunc;
+#else
+ TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
+#endif
+ printf("(tgt lladdr: %s",
+ etheraddr_string((u_char *)(opl + 1)));
+ if (opl->nd_opt_len != 1)
+ printf("!");
+ printf(")");
+ icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
+ resid - (op->nd_opt_len << 3));
+ break;
+ case ND_OPT_PREFIX_INFORMATION:
+ opp = (struct nd_opt_prefix_info *)op;
+ TCHECK(opp->nd_opt_pi_prefix);
+ printf("(prefix info: ");
+ if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)
+ printf("L");
+ if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)
+ printf("A");
+ if (opp->nd_opt_pi_flags_reserved)
+ printf(" ");
+ printf("valid_ltime=");
+ if ((u_int32_t)ntohl(opp->nd_opt_pi_valid_time) == ~0U)
+ printf("infinity");
+ else {
+ printf("%u", (u_int32_t)ntohl(opp->nd_opt_pi_valid_time));
+ }
+ printf(", ");
+ printf("preffered_ltime=");
+ if ((u_int32_t)ntohl(opp->nd_opt_pi_preferred_time) == ~0U)
+ printf("infinity");
+ else {
+ printf("%u", (u_int32_t)ntohl(opp->nd_opt_pi_preferred_time));
+ }
+ printf(", ");
+ printf("prefix=%s/%d", ip6addr_string(&opp->nd_opt_pi_prefix),
+ opp->nd_opt_pi_prefix_len);
+ if (opp->nd_opt_pi_len != 4)
+ printf("!");
+ printf(")");
+ icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
+ resid - (op->nd_opt_len << 3));
+ break;
+ case ND_OPT_REDIRECTED_HEADER:
+ opr = (struct icmp6_opts_redirect *)op;
+ printf("(redirect)");
+ /* xxx */
+ icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
+ resid - (op->nd_opt_len << 3));
+ break;
+ case ND_OPT_MTU:
+ opm = (struct nd_opt_mtu *)op;
+ TCHECK(opm->nd_opt_mtu_mtu);
+ printf("(mtu: ");
+ printf("mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu));
+ if (opm->nd_opt_mtu_len != 1)
+ printf("!");
+ printf(")");
+ icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
+ resid - (op->nd_opt_len << 3));
+ break;
+ default:
+ opts_len = op->nd_opt_len;
+ printf("(unknwon opt_type=%d, opt_len=%d)",
+ op->nd_opt_type, opts_len);
+ if (opts_len == 0)
+ opts_len = 1; /* XXX */
+ icmp6_opt_print((const u_char *)op + (opts_len << 3),
+ resid - (opts_len << 3));
+ break;
+ }
+ return;
+ trunc:
+ fputs("[ndp opt]", stdout);
+ return;
+#if 0
+#undef TCHECK
+#endif
+#undef ECHECK
+}
+
+void
+mld6_print(register const u_char *bp)
+{
+ register struct mld6_hdr *mp = (struct mld6_hdr *)bp;
+ register const u_char *ep;
+
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+
+ if ((u_char *)mp + sizeof(*mp) > ep)
+ return;
+
+ printf("max resp delay: %d ", ntohs(mp->mld6_maxdelay));
+ printf("addr: %s", ip6addr_string(&mp->mld6_addr));
+
+ return;
+}
+#endif /* INET6 */
diff --git a/print-igrp.c b/print-igrp.c
index 3eaa40ef..16dfc801 100644
--- a/print-igrp.c
+++ b/print-igrp.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.9 1999-10-17 21:37:12 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.10 1999-10-30 05:11:14 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -33,7 +33,9 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <errno.h>
#include <stdio.h>
diff --git a/print-ip.c b/print-ip.c
index 0d8f9308..9ae000e7 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.69 1999-10-17 22:18:01 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.70 1999-10-30 05:11:14 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -31,7 +31,9 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#ifdef HAVE_MALLOC_H
@@ -64,7 +66,7 @@ struct tr_query {
u_int tr_src; /* traceroute source */
u_int tr_dst; /* traceroute destination */
u_int tr_raddr; /* traceroute response address */
-#ifdef WORDS_BIGENDIAN
+#if defined(WORDS_BIGENDIAN) || (defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN))
struct {
u_int ttl : 8; /* traceroute response ttl */
u_int qid : 24; /* traceroute query id */
@@ -181,7 +183,7 @@ igmp_print(register const u_char *bp, register u_int len,
break;
case 0x14:
(void)printf("igmp pim");
- pim_print(bp, len);
+ igmp_pim_print(bp, len);
break;
case 0x1e:
print_mresp(bp, len);
@@ -333,8 +335,10 @@ void
ip_print(register const u_char *bp, register u_int length)
{
register const struct ip *ip;
- register u_int hlen, len, off;
+ register u_int hlen, len, len0, off;
register const u_char *cp;
+ u_char nh;
+ int advance;
ip = (const struct ip *)bp;
#ifdef LBL_ALIGN
@@ -378,6 +382,7 @@ ip_print(register const u_char *bp, register u_int length)
(void)printf("truncated-ip - %d bytes missing!",
len - length);
len -= hlen;
+ len0 = len;
/*
* If this is fragment zero, hand it to the next higher
@@ -386,7 +391,48 @@ ip_print(register const u_char *bp, register u_int length)
off = ntohs(ip->ip_off);
if ((off & 0x1fff) == 0) {
cp = (const u_char *)ip + hlen;
- switch (ip->ip_p) {
+ nh = ip->ip_p;
+
+ if (nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
+ (void)printf("%s > %s: ", ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
+ }
+again:
+ switch (nh) {
+
+ case IPPROTO_AH:
+ nh = *cp;
+ advance = ah_print(cp, (const u_char *)ip);
+ cp += advance;
+ len -= advance;
+ goto again;
+
+ case IPPROTO_ESP:
+ {
+ int enh;
+ advance = esp_print(cp, (const u_char *)ip, &enh);
+ cp += advance;
+ len -= advance;
+ if (enh < 0)
+ break;
+ nh = enh & 0xff;
+ goto again;
+ }
+
+#ifndef IPPROTO_IPCOMP
+#define IPPROTO_IPCOMP 108
+#endif
+ case IPPROTO_IPCOMP:
+ {
+ int enh;
+ advance = ipcomp_print(cp, (const u_char *)ip, &enh);
+ cp += advance;
+ len -= advance;
+ if (enh < 0)
+ break;
+ nh = enh & 0xff;
+ goto again;
+ }
case IPPROTO_TCP:
tcp_print(cp, len, (const u_char *)ip);
@@ -408,8 +454,10 @@ ip_print(register const u_char *bp, register u_int length)
break;
case IPPROTO_ND:
+#if 0
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
+#endif
(void)printf(" nd %d", len);
break;
@@ -433,10 +481,12 @@ ip_print(register const u_char *bp, register u_int length)
case 4:
/* DVMRP multicast tunnel (ip-in-ip encapsulation) */
+#if 0
if (vflag)
(void)printf("%s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
+#endif
ip_print(cp, len);
if (! vflag) {
printf(" (ipip)");
@@ -444,6 +494,27 @@ ip_print(register const u_char *bp, register u_int length)
}
break;
+#ifdef INET6
+#ifndef IP6PROTO_ENCAP
+#define IP6PROTO_ENCAP 41
+#endif
+ case IP6PROTO_ENCAP:
+ /* ip6-in-ip encapsulation */
+#if 0
+ if (vflag)
+ (void)printf("%s > %s: ",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
+#endif
+ ip6_print(cp, len);
+ if (! vflag) {
+ printf(" (encap)");
+ return;
+ }
+ break;
+#endif /*INET6*/
+
+
#ifndef IPPROTO_GRE
#define IPPROTO_GRE 47
#endif
@@ -460,18 +531,41 @@ ip_print(register const u_char *bp, register u_int length)
}
break;
+#ifndef IPPROTO_MOBILE
+#define IPPROTO_MOBILE 55
+#endif
+ case IPPROTO_MOBILE:
+ if (vflag)
+ (void)printf("mobile %s > %s: ",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
+ mobile_print(cp, len);
+ if (! vflag) {
+ printf(" (mobile encap)");
+ return;
+ }
+ break;
+
+ case IPPROTO_PIM:
+ pim_print(cp, len);
+ break;
+
default:
+#if 0
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
- (void)printf(" ip-proto-%d %d", ip->ip_p, len);
+#endif
+ (void)printf(" ip-proto-%d %d", nh, len);
break;
}
}
+
/*
* for fragmented datagrams, print id:size@offset. On all
* but the last stick a "+". For unfragmented datagrams, note
* the don't fragment flag.
*/
+ len = len0; /* get the original length */
if (off & 0x3fff) {
/*
* if this isn't the first frag, we're missing the
@@ -480,7 +574,7 @@ ip_print(register const u_char *bp, register u_int length)
if (off & 0x1fff)
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
- (void)printf(" (frag %d:%d@%d%s)", ntohs(ip->ip_id), len,
+ (void)printf(" (frag %d:%u@%d%s)", ntohs(ip->ip_id), len,
(off & 0x1fff) * 8,
(off & IP_MF)? "+" : "");
} else if (off & IP_DF)
diff --git a/print-ip6.c b/print-ip6.c
new file mode 100644
index 00000000..0ace74ef
--- /dev/null
+++ b/print-ip6.c
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) /master/usr.sbin/tcpdump/tcpdump/print-ip.c,v 2.1 1995/02/03 18:14:45 polk Exp (LBL)";
+#endif
+
+#ifdef INET6
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+
+#include <stdio.h>
+#ifdef __STDC__
+#include <stdlib.h>
+#endif
+#include <unistd.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+#include <netinet/ip6.h>
+
+/*
+ * print an IP6 datagram.
+ */
+void
+ip6_print(register const u_char *bp, register int length)
+{
+ register const struct ip6_hdr *ip6;
+ register int hlen;
+ register int len;
+ register const u_char *cp;
+ int nh;
+ u_int flow;
+
+ ip6 = (const struct ip6_hdr *)bp;
+
+#ifdef TCPDUMP_ALIGN
+ /*
+ * The IP header is not word aligned, so copy into abuf.
+ * This will never happen with BPF. It does happen raw packet
+ * dumps from -r.
+ */
+ if ((int)ip & (sizeof(long)-1)) {
+ static u_char *abuf;
+
+ if (abuf == 0)
+ abuf = (u_char *)malloc(snaplen);
+ bcopy((char *)ip, (char *)abuf, min(length, snaplen));
+ snapend += abuf - (u_char *)ip;
+ packetp = abuf;
+ ip = (struct ip6_hdr *)abuf;
+ }
+#endif
+ if ((u_char *)(ip6 + 1) > snapend) {
+ printf("[|ip6]");
+ return;
+ }
+ if (length < sizeof (struct ip6_hdr)) {
+ (void)printf("truncated-ip6 %d", length);
+ return;
+ }
+ hlen = sizeof(struct ip6_hdr);
+
+ len = ntohs(ip6->ip6_plen);
+ if (length < len + hlen)
+ (void)printf("truncated-ip6 - %d bytes missing!",
+ len + hlen - length);
+
+ cp = (const u_char *)ip6;
+ nh = ip6->ip6_nxt;
+ while (cp < snapend) {
+ cp += hlen;
+
+ if (cp == (u_char *)(ip6 + 1)
+ && nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
+ (void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src),
+ ip6addr_string(&ip6->ip6_dst));
+ }
+
+ switch (nh) {
+ case IPPROTO_HOPOPTS:
+ hlen = hbhopt_print(cp);
+ nh = *cp;
+ break;
+ case IPPROTO_DSTOPTS:
+ hlen = dstopt_print(cp);
+ nh = *cp;
+ break;
+ case IPPROTO_FRAGMENT:
+ hlen = frag6_print(cp, (const u_char *)ip6);
+ if (snapend <= cp + hlen)
+ goto end;
+ nh = *cp;
+ break;
+ case IPPROTO_ROUTING:
+ hlen = rt6_print(cp, (const u_char *)ip6);
+ nh = *cp;
+ break;
+ case IPPROTO_TCP:
+ tcp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
+ (const u_char *)ip6);
+ goto end;
+ case IPPROTO_UDP:
+ udp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
+ (const u_char *)ip6);
+ goto end;
+ case IPPROTO_ICMPV6:
+ icmp6_print(cp, (const u_char *)ip6);
+ goto end;
+ case IPPROTO_AH:
+ hlen = ah_print(cp, (const u_char *)ip6);
+ nh = *cp;
+ break;
+ case IPPROTO_ESP:
+ {
+ int enh;
+ cp += esp_print(cp, (const u_char *)ip6, &enh);
+ if (enh < 0)
+ goto end;
+ nh = enh & 0xff;
+ break;
+ }
+#ifndef IPPROTO_IPCOMP
+#define IPPROTO_IPCOMP 108
+#endif
+ case IPPROTO_IPCOMP:
+ {
+ int enh;
+ cp += ipcomp_print(cp, (const u_char *)ip6, &enh);
+ if (enh < 0)
+ goto end;
+ nh = enh & 0xff;
+ break;
+ }
+ case IPPROTO_PIM:
+ (void)printf("PIM");
+ pim_print(cp, len);
+ goto end;
+#ifndef IPPROTO_OSPF
+#define IPPROTO_OSPF 89
+#endif
+ case IPPROTO_OSPF:
+ ospf6_print(cp, len);
+ goto end;
+ case IPPROTO_IPV6:
+ ip6_print(cp, len);
+ goto end;
+#ifndef IPPROTO_IPV4
+#define IPPROTO_IPV4 4
+#endif
+ case IPPROTO_IPV4:
+ ip_print(cp, len);
+ goto end;
+ case IPPROTO_NONE:
+ (void)printf("no next header");
+ goto end;
+
+ default:
+ (void)printf("ip-proto-%d %d", ip6->ip6_nxt, len);
+ goto end;
+ }
+ }
+
+ end:
+
+ flow = ntohl(ip6->ip6_flow);
+#if 0
+ /* rfc1883 */
+ if (flow & 0x0f000000)
+ (void)printf(" [pri 0x%x]", (flow & 0x0f000000) >> 24);
+ if (flow & 0x00ffffff)
+ (void)printf(" [flowlabel 0x%x]", flow & 0x00ffffff);
+#else
+ /* RFC 2460 */
+ if (flow & 0x0ff00000)
+ (void)printf(" [class 0x%x]", (flow & 0x0ff00000) >> 20);
+ if (flow & 0x000fffff)
+ (void)printf(" [flowlabel 0x%x]", flow & 0x000fffff);
+#endif
+
+ if (ip6->ip6_hlim <= 1)
+ (void)printf(" [hlim %d]", (int)ip6->ip6_hlim);
+
+ if (vflag) {
+ printf(" (");
+ (void)printf("len %d", len);
+ if (ip6->ip6_hlim > 1)
+ (void)printf(", hlim %d", (int)ip6->ip6_hlim);
+ printf(")");
+ }
+}
+
+#endif /* INET6 */
diff --git a/print-ip6opts.c b/print-ip6opts.c
new file mode 100644
index 00000000..fe715b79
--- /dev/null
+++ b/print-ip6opts.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef INET6
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <netinet/ip6.h>
+
+#include <stdio.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+void
+ip6_opt_print(const u_char *bp, int len)
+{
+ int i;
+ int optlen;
+
+ for (i = 0; i < len; i += optlen) {
+ switch (bp[i]) {
+ case IP6OPT_PAD1:
+ optlen = 1;
+ break;
+ case IP6OPT_PADN:
+ if (len - i < IP6OPT_MINLEN) {
+ printf("(padn: trunc)");
+ goto trunc;
+ }
+ optlen = bp[i + 1] + 2;
+ break;
+ case IP6OPT_RTALERT:
+ if (len - i < IP6OPT_RTALERT_LEN) {
+ printf("(rtalert: trunc)");
+ goto trunc;
+ }
+ if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) {
+ printf("(rtalert: invalid len %d)", bp[i + 1]);
+ goto trunc;
+ }
+ printf("(rtalert: 0x%04x) ", ntohs(*(u_short *)&bp[i + 2]));
+ optlen = IP6OPT_RTALERT_LEN;
+ break;
+ case IP6OPT_JUMBO:
+ if (len - i < IP6OPT_JUMBO_LEN) {
+ printf("(jumbo: trunc)");
+ goto trunc;
+ }
+ if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) {
+ printf("(jumbo: invalid len %d)", bp[i + 1]);
+ goto trunc;
+ }
+ printf("(jumbo: %u) ", (u_int32_t)ntohl(*(u_int *)&bp[i + 2]));
+ optlen = IP6OPT_JUMBO_LEN;
+ break;
+ default:
+ if (len - i < IP6OPT_MINLEN) {
+ printf("(type %d: trunc)", bp[i]);
+ goto trunc;
+ }
+ printf("(type 0x%02x: len=%d) ", bp[i], bp[i + 1]);
+ optlen = bp[i + 1] + 2;
+ break;
+ }
+ }
+
+#if 0
+end:
+#endif
+ return;
+
+trunc:
+ printf("[trunc] ");
+}
+
+int
+hbhopt_print(register const u_char *bp)
+{
+ const struct ip6_hbh *dp = (struct ip6_hbh *)bp;
+ register const u_char *ep;
+ int hbhlen = 0;
+
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+ TCHECK(dp->ip6h_len);
+ hbhlen = (int)((dp->ip6h_len + 1) << 3);
+ TCHECK2(dp, hbhlen);
+ printf("HBH ");
+ if (vflag)
+ ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
+
+ return(hbhlen);
+
+ trunc:
+ fputs("[|HBH]", stdout);
+ return(hbhlen);
+}
+
+int
+dstopt_print(register const u_char *bp)
+{
+ const struct ip6_dest *dp = (struct ip6_dest *)bp;
+ register const u_char *ep;
+ int dstoptlen = 0;
+
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+ TCHECK(dp->ip6d_len);
+ dstoptlen = (int)((dp->ip6d_len + 1) << 3);
+ TCHECK2(dp, dstoptlen);
+ printf("DSTOPT ");
+ if (vflag) {
+ ip6_opt_print((const u_char *)dp + sizeof(*dp),
+ dstoptlen - sizeof(*dp));
+ }
+
+ return(dstoptlen);
+
+ trunc:
+ fputs("[|DSTOPT]", stdout);
+ return(dstoptlen);
+}
+#endif /* INET6 */
diff --git a/print-ipcomp.c b/print-ipcomp.c
new file mode 100644
index 00000000..ed2f49d0
--- /dev/null
+++ b/print-ipcomp.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) /master/usr.sbin/tcpdump/tcpdump/print-icmp.c,v 2.1 1995/02/03 18:14:42 polk Exp (LBL)";
+#endif
+
+#include <string.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/route.h>
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+
+#include <stdio.h>
+
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
+#ifdef HAVE_NETINET6_IPCOMP_H
+#include <netinet6/ipcomp.h>
+#else
+struct ipcomp {
+ u_int8_t comp_nxt; /* Next Header */
+ u_int8_t comp_flags; /* Length of data, in 32bit */
+ u_int16_t comp_cpi; /* Compression parameter index */
+};
+#endif
+
+#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
+#include <zlib.h>
+#endif
+
+#include "interface.h"
+#include "addrtoname.h"
+
+int
+ipcomp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
+{
+ register const struct ipcomp *ipcomp;
+ register const u_char *ep;
+ u_int16_t cpi;
+#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
+ int advance;
+#endif
+
+ ipcomp = (struct ipcomp *)bp;
+ cpi = (u_int16_t)ntohs(ipcomp->comp_cpi);
+
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+
+ if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
+ fputs("[|IPCOMP]", stdout);
+ goto fail;
+ }
+ printf("IPComp(cpi=%u)", cpi);
+
+#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
+ if (1)
+ goto fail;
+
+ /*
+ * We may want to decompress the packet here. Packet buffer
+ * management is a headache (if we decompress, packet will become
+ * larger).
+ */
+ if (nhdr)
+ *nhdr = ipcomp->comp_nxt;
+ advance = sizeof(struct ipcomp);
+
+ printf(": ");
+ return advance;
+
+#endif
+fail:
+ if (nhdr)
+ *nhdr = -1;
+ return 65536;
+}
diff --git a/print-ipx.c b/print-ipx.c
index dafd8409..4e9c3e14 100644
--- a/print-ipx.c
+++ b/print-ipx.c
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.20 1999-10-17 21:37:13 mcr Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.21 1999-10-30 05:11:15 itojun Exp $";
#endif
#include <sys/param.h>
@@ -34,7 +34,9 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#ifdef __STDC__
diff --git a/print-isakmp.c b/print-isakmp.c
index b4a6f8fd..ff8a066e 100644
--- a/print-isakmp.c
+++ b/print-isakmp.c
@@ -1,134 +1,1053 @@
-/* $NetBSD: print-ntp.c,v 1.3 1997/03/15 18:37:55 is Exp $ */
-
/*
- * Copyright (c) 1990, 1991, 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*
- * Format and print ntp packets.
- * By Jeffrey Mogul/DECWRL
- * loosely based on print-bootp.c
*/
#ifndef lint
-static char rcsid[] =
- "@(#) Header: print-ntp.c,v 1.14 94/06/14 20:18:46 leres Exp (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.3 1999-10-30 05:11:17 itojun Exp $ (LBL)";
#endif
+#include <string.h>
+#include <ctype.h>
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/types.h>
#include <sys/socket.h>
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
#include <net/if.h>
#include <netinet/in.h>
-#ifdef __NetBSD__
-#include <net/if_ether.h>
-#else
#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+
+#ifdef INET6
+#include <netinet/ip6.h>
#endif
-#include <ctype.h>
-#include <pcap.h>
#include <stdio.h>
-#include <string.h>
+#include <netdb.h>
+#include "isakmp.h"
+#include "ipsec_doi.h"
+#include "oakley.h"
#include "interface.h"
#include "addrtoname.h"
-#undef MODEMASK /* Solaris sucks */
-#include "ntp.h"
-
-struct isakmp_header {
- u_char init_cookie[4];
- u_char resp_cookie[4];
- u_char nextpayload;
-#if BYTE_ORDER == LITTLE_ENDIAN
- u_char mnver:4;
- u_char mjver:4;
+#include "extract.h" /* must come after interface.h */
+
+static u_char *isakmp_sa_print __P((struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t));
+static u_char *isakmp_p_print __P((struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t));
+static u_char *isakmp_t_print __P((struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t));
+static u_char *isakmp_ke_print __P((struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t));
+static u_char *isakmp_id_print __P((struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t));
+static u_char *isakmp_hash_print __P((struct isakmp_gen *, u_char *,
+ u_int32_t, u_int32_t, u_int32_t));
+static u_char *isakmp_nonce_print __P((struct isakmp_gen *, u_char *,
+ u_int32_t, u_int32_t, u_int32_t));
+static u_char *isakmp_n_print __P((struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t));
+static u_char *isakmp_d_print __P((struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t));
+static u_char *isakmp_vid_print __P((struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t));
+static u_char *isakmp_sub0_print __P((u_char, struct isakmp_gen *, u_char *,
+ u_int32_t, u_int32_t, u_int32_t));
+static u_char *isakmp_sub_print __P((u_char, struct isakmp_gen *, u_char *,
+ u_int32_t, u_int32_t, u_int32_t));
+static char *numstr __P((int));
+
+#define MAXINITIATORS 20
+int ninitiator = 0;
+struct {
+ cookie_t initiator;
+ struct sockaddr_storage iaddr;
+ struct sockaddr_storage raddr;
+} cookiecache[MAXINITIATORS];
+
+/* protocol id */
+static char *protoidstr[] = {
+ NULL, "isakmp", "ipsec-ah", "ipsec-esp", "ipcomp",
+};
+
+/* isakmp->np */
+static char *npstr[] = {
+ "none", "sa", "p", "t", "ke", "id", "cert", "cr", "hash",
+ "sig", "nonce", "n", "d", "vid"
+};
+
+/* isakmp->np */
+static u_char *(*npfunc[]) __P((struct isakmp_gen *, u_char *, u_int32_t,
+ u_int32_t, u_int32_t)) = {
+ NULL,
+ isakmp_sa_print,
+ isakmp_p_print,
+ isakmp_t_print,
+ isakmp_ke_print,
+ isakmp_id_print,
+ NULL,
+ NULL,
+ isakmp_hash_print,
+ NULL,
+ isakmp_nonce_print,
+ isakmp_n_print,
+ isakmp_d_print,
+ isakmp_vid_print,
+};
+
+/* isakmp->etype */
+static char *etypestr[] = {
+ "none", "base", "ident", "auth", "agg", "inf", NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ "oakley-quick", "oakley-newgroup",
+};
+
+#define STR_OR_ID(x, tab) \
+ (((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x))
+#define PROTOIDSTR(x) STR_OR_ID(x, protoidstr)
+#define NPSTR(x) STR_OR_ID(x, npstr)
+#define ETYPESTR(x) STR_OR_ID(x, etypestr)
+
+#define NPFUNC(x) \
+ (((x) < sizeof(npfunc)/sizeof(npfunc[0]) && npfunc[(x)]) \
+ ? npfunc[(x)] : NULL)
+
+static int
+iszero(u_char *p, size_t l)
+{
+ while (l--) {
+ if (*p++)
+ return 0;
+ }
+ return 1;
+}
+
+/* find cookie from initiator cache */
+static int
+cookie_find(cookie_t *in)
+{
+ int i;
+
+ for (i = 0; i < MAXINITIATORS; i++) {
+ if (memcmp(in, &cookiecache[i].initiator, sizeof(*in)) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+/* record initiator */
+static void
+cookie_record(cookie_t *in, const u_char *bp2)
+{
+ int i;
+ struct ip *ip;
+ struct sockaddr_in *sin;
+#ifdef INET6
+ struct ip6_hdr *ip6;
+ struct sockaddr_in6 *sin6;
#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_char mjver:4;
- u_char mnver:4;
-#endif
- u_char exgtype;
- u_char flags;
- u_char msgid[4];
- u_int32_t length;
+
+ i = cookie_find(in);
+ if (0 <= i) {
+ ninitiator = (i + 1) % MAXINITIATORS;
+ return;
+ }
+
+ ip = (struct ip *)bp2;
+ switch (ip->ip_v) {
+ case 4:
+ memset(&cookiecache[ninitiator].iaddr, 0,
+ sizeof(cookiecache[ninitiator].iaddr));
+ memset(&cookiecache[ninitiator].raddr, 0,
+ sizeof(cookiecache[ninitiator].raddr));
+
+ sin = (struct sockaddr_in *)&cookiecache[ninitiator].iaddr;
+ sin->sin_len = sizeof(struct sockaddr_in);
+ sin->sin_family = AF_INET;
+ memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
+ sin = (struct sockaddr_in *)&cookiecache[ninitiator].raddr;
+ sin->sin_len = sizeof(struct sockaddr_in);
+ sin->sin_family = AF_INET;
+ memcpy(&sin->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst));
+ break;
+#ifdef INET6
+ case 6:
+ memset(&cookiecache[ninitiator].iaddr, 0,
+ sizeof(cookiecache[ninitiator].iaddr));
+ memset(&cookiecache[ninitiator].raddr, 0,
+ sizeof(cookiecache[ninitiator].raddr));
+
+ ip6 = (struct ip6_hdr *)bp2;
+ sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].iaddr;
+ sin6->sin6_len = sizeof(struct sockaddr_in6);
+ sin6->sin6_family = AF_INET6;
+ memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
+ sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].raddr;
+ sin6->sin6_len = sizeof(struct sockaddr_in6);
+ sin6->sin6_family = AF_INET6;
+ memcpy(&sin6->sin6_addr, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
+ break;
+#endif
+ default:
+ return;
+ }
+ memcpy(&cookiecache[ninitiator].initiator, in, sizeof(*in));
+ ninitiator = (ninitiator + 1) % MAXINITIATORS;
+}
+
+#define cookie_isinitiator(x, y) cookie_sidecheck((x), (y), 1)
+#define cookie_isresponder(x, y) cookie_sidecheck((x), (y), 0)
+static int
+cookie_sidecheck(int i, const u_char *bp2, int initiator)
+{
+ struct sockaddr_storage ss;
+ struct ip *ip;
+ struct sockaddr_in *sin;
+#ifdef INET6
+ struct ip6_hdr *ip6;
+ struct sockaddr_in6 *sin6;
+#endif
+
+ memset(&ss, 0, sizeof(ss));
+ ip = (struct ip *)bp2;
+ switch (ip->ip_v) {
+ case 4:
+ sin = (struct sockaddr_in *)&ss;
+ sin->sin_len = sizeof(struct sockaddr_in);
+ sin->sin_family = AF_INET;
+ memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
+ break;
+#ifdef INET6
+ case 6:
+ ip6 = (struct ip6_hdr *)bp2;
+ sin6 = (struct sockaddr_in6 *)&ss;
+ sin6->sin6_len = sizeof(struct sockaddr_in6);
+ sin6->sin6_family = AF_INET6;
+ memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
+ break;
+#endif
+ default:
+ return 0;
+ }
+
+ if (initiator) {
+ if (ss.__ss_family != cookiecache[i].iaddr.__ss_family)
+ return 0;
+ if (ss.__ss_len != cookiecache[i].iaddr.__ss_len)
+ return 0;
+ if (memcmp(&ss, &cookiecache[i].iaddr, ss.__ss_len) == 0)
+ return 1;
+ } else {
+ if (ss.__ss_family != cookiecache[i].raddr.__ss_family)
+ return 0;
+ if (ss.__ss_len != cookiecache[i].raddr.__ss_len)
+ return 0;
+ if (memcmp(&ss, &cookiecache[i].raddr, ss.__ss_len) == 0)
+ return 1;
+ }
+ return 0;
+}
+
+static void
+rawprint(caddr_t loc, size_t len)
+{
+ static u_char *p;
+ int i;
+
+ p = (u_char *)loc;
+ for (i = 0; i < len; i++)
+ printf("%02x", p[i] & 0xff);
+}
+
+struct attrmap {
+ char *type;
+ int nvalue;
+ char *value[30]; /*XXX*/
};
-#define FLAGS_ENCRYPTION 1
-#define FLAGS_COMMIT 2
+static u_char *
+isakmp_attrmap_print(u_char *p, u_char *ep, struct attrmap *map, size_t nmap)
+{
+ u_short *q;
+ int totlen;
+ u_int32_t t, v;
+
+ q = (u_short *)p;
+ if (p[0] & 0x80)
+ totlen = 4;
+ else
+ totlen = 4 + ntohs(q[1]);
+ if (ep < p + totlen) {
+ printf("[|attr]");
+ return ep + 1;
+ }
+
+ printf("(");
+ t = ntohs(q[0]) & 0x7fff;
+ if (map && t < nmap && map[t].type)
+ printf("type=%s ", map[t].type);
+ else
+ printf("type=#%d ", t);
+ if (p[0] & 0x80) {
+ printf("value=");
+ v = ntohs(q[1]);
+ if (map && t < nmap && v < map[t].nvalue && map[t].value[v])
+ printf("%s", map[t].value[v]);
+ else
+ rawprint((caddr_t)&q[1], 2);
+ } else {
+ printf("len=%d value=", ntohs(q[1]));
+ rawprint((caddr_t)&p[4], ntohs(q[1]));
+ }
+ printf(")");
+ return p + totlen;
+}
+
+static u_char *
+isakmp_attr_print(u_char *p, u_char *ep)
+{
+ u_short *q;
+ int totlen;
+ u_int32_t t;
+
+ q = (u_short *)p;
+ if (p[0] & 0x80)
+ totlen = 4;
+ else
+ totlen = 4 + ntohs(q[1]);
+ if (ep < p + totlen) {
+ printf("[|attr]");
+ return ep + 1;
+ }
+
+ printf("(");
+ t = ntohs(q[0]) & 0x7fff;
+ printf("type=#%d ", t);
+ if (p[0] & 0x80) {
+ printf("value=");
+ t = q[1];
+ rawprint((caddr_t)&q[1], 2);
+ } else {
+ printf("len=%d value=", ntohs(q[1]));
+ rawprint((caddr_t)&p[2], ntohs(q[1]));
+ }
+ printf(")");
+ return p + totlen;
+}
+
+static u_char *
+isakmp_sa_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi0, u_int32_t proto0)
+{
+ struct isakmp_pl_sa *p;
+ u_int32_t *q;
+ u_int32_t doi;
+ u_int32_t sit;
+ u_char *cp;
+ int t;
+
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_SA));
+
+ p = (struct isakmp_pl_sa *)ext;
+ doi = ntohl(p->doi);
+ if (doi != 1) {
+ printf(" doi=%d", doi);
+ printf(" situation=%u", (u_int32_t)ntohl(p->sit));
+ return (u_char *)(p + 1);
+ }
+
+ printf(" doi=ipsec");
+ q = (u_int32_t *)&p->sit;
+ printf(" situation=");
+ t = 0;
+ if (ntohl(*q) & 0x01) {
+ printf("identity");
+ t++;
+ }
+ if (ntohl(*q) & 0x02) {
+ printf("%ssecrecy", t ? "+" : "");
+ t++;
+ }
+ if (ntohl(*q) & 0x04)
+ printf("%sintegrity", t ? "+" : "");
+ sit = htonl(*q++);
+
+ if (sit != 0x01)
+ printf(" ident=%u", (u_int32_t)ntohl(*q++));
+
+ ext = (struct isakmp_gen *)q;
+
+ cp = isakmp_sub_print(ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0);
+
+ return cp;
+}
+
+static u_char *
+isakmp_p_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi0, u_int32_t proto0)
+{
+ struct isakmp_pl_p *p;
+ u_char *cp;
+
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_P));
+
+ p = (struct isakmp_pl_p *)ext;
+ printf(" #%d protoid=%s transform=%d",
+ p->p_no, PROTOIDSTR(p->prot_id), p->num_t);
+ if (p->spi_size) {
+ printf(" spi=");
+ rawprint((caddr_t)(p + 1), p->spi_size);
+ }
+
+ ext = (struct isakmp_gen *)((u_char *)(p + 1) + p->spi_size);
+
+ cp = isakmp_sub_print(ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
+ p->prot_id);
+
+ return cp;
+}
+
+static char *isakmp_p_map[] = {
+ NULL, "ike",
+};
+
+static char *ah_p_map[] = {
+ NULL, "md5", "sha", "1des",
+};
+
+static char *esp_p_map[] = {
+ NULL, "1des-iv64", "1des", "3des", "rc5", "idea", "cast",
+ "blowfish", "3idea", "1des-iv32", "rc4", "null"
+};
+
+static char *ipcomp_p_map[] = {
+ NULL, "oui", "deflate", "lzs",
+};
+
+struct attrmap ipsec_t_map[] = {
+ { NULL, 0, },
+ { "lifetype", 3, { NULL, "sec", "kb", }, },
+ { "life", 0, },
+ { "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155",
+ "EC2N 2^185", }, },
+ { "enc mode", 3, { NULL, "tunnel", "transport", }, },
+ { "auth", 5, { NULL, "hmac-md5", "hmac-sha1", "1des-mac", "keyed", }, },
+ { "keylen", 0, },
+ { "rounds", 0, },
+ { "dictsize", 0, },
+ { "privalg", 0, },
+};
+
+struct attrmap oakley_t_map[] = {
+ { NULL, 0 },
+ { "enc", 7, { NULL, "1des", "idea", "blowfish", "rc5",
+ "3des", "cast"}, },
+ { "hash", 4, { NULL, "md5", "sha1", "tiger", }, },
+ { "auth", 6, { NULL, "preshared", "dss", "rsa sig", "rsa enc",
+ "rsa enc revised", }, },
+ { "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155",
+ "EC2N 2^185", }, },
+ { "group type", 4, { NULL, "MODP", "ECP", "EC2N", }, },
+ { "group prime", 0, },
+ { "group gen1", 0, },
+ { "group gen2", 0, },
+ { "group curve A", 0, },
+ { "group curve B", 0, },
+ { "lifetype", 3, { NULL, "sec", "kb", }, },
+ { "lifeduration", 0, },
+ { "prf", 0, },
+ { "keylen", 0, },
+ { "field", 0, },
+ { "order", 0, },
+};
+
+static u_char *
+isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi, u_int32_t proto)
+{
+ struct isakmp_pl_t *p;
+ u_char *cp;
+ char *idstr;
+ struct attrmap *map;
+ size_t nmap;
+ u_char *ep2;
+
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_T));
+
+ p = (struct isakmp_pl_t *)ext;
+
+ switch (proto) {
+ case 1:
+ idstr = STR_OR_ID(p->t_id, isakmp_p_map);
+ map = oakley_t_map;
+ nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]);
+ break;
+ case 2:
+ idstr = STR_OR_ID(p->t_id, ah_p_map);
+ map = ipsec_t_map;
+ nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
+ break;
+ case 3:
+ idstr = STR_OR_ID(p->t_id, esp_p_map);
+ map = ipsec_t_map;
+ nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
+ break;
+ case 4:
+ idstr = STR_OR_ID(p->t_id, ipcomp_p_map);
+ map = ipsec_t_map;
+ nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
+ break;
+ default:
+ idstr = NULL;
+ map = NULL;
+ nmap = 0;
+ break;
+ }
+
+ if (idstr)
+ printf(" #%d id=%s ", p->t_no, idstr);
+ else
+ printf(" #%d id=%d ", p->t_no, p->t_id);
+ cp = (u_char *)(p + 1);
+ ep2 = (u_char *)p + ntohs(ext->len);
+ while (cp < ep && cp < ep2) {
+ if (map && nmap) {
+ cp = isakmp_attrmap_print(cp, (ep < ep2) ? ep : ep2,
+ map, nmap);
+ } else
+ cp = isakmp_attr_print(cp, (ep < ep2) ? ep : ep2);
+ }
+ if (ep < ep2)
+ printf("...");
+ return cp;
+}
+
+static u_char *
+isakmp_ke_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi, u_int32_t proto)
+{
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_KE));
+
+ printf(" key len=%d", ntohs(ext->len) - 4);
+ if (2 < vflag && 4 < ntohs(ext->len)) {
+ printf(" ");
+ rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
+ }
+ return (u_char *)ext + ntohs(ext->len);
+}
+
+static u_char *
+isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi, u_int32_t proto)
+{
+#define USE_IPSECDOI_IN_PHASE1 1
+ struct isakmp_pl_id *p;
+ static char *idtypestr[] = {
+ "IPv4", "IPv4net", "IPv6", "IPv6net",
+ };
+ static char *ipsecidtypestr[] = {
+ NULL, "IPv4", "FQDN", "user FQDN", "IPv4net", "IPv6",
+ "IPv6net", "IPv4range", "IPv6range", "ASN1 DN", "ASN1 GN",
+ "keyid",
+ };
+ int len;
+ u_char *data;
+
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_ID));
+
+ p = (struct isakmp_pl_id *)ext;
+ if (sizeof(*p) < ext->len)
+ data = (u_char *)(p + 1);
+ else
+ data = NULL;
+ len = ntohs(ext->len) - sizeof(*p);
+
+#if 0 /*debug*/
+ printf(" [phase=%d doi=%d proto=%d]", phase, doi, proto);
+#endif
+ switch (phase) {
+#ifndef USE_IPSECDOI_IN_PHASE1
+ case 1:
+#endif
+ default:
+ printf(" idtype=%s", STR_OR_ID(p->d.id_type, idtypestr));
+ printf(" doi_data=%u",
+ (u_int32_t)(ntohl(p->d.doi_data) & 0xffffff));
+ break;
+
+#ifdef USE_IPSECDOI_IN_PHASE1
+ case 1:
+#endif
+ case 2:
+ {
+ struct ipsecdoi_id *p;
+ struct protoent *pe;
+
+ p = (struct ipsecdoi_id *)ext;
+ printf(" idtype=%s", STR_OR_ID(p->type, ipsecidtypestr));
+ setprotoent(1);
+ pe = getprotobynumber(p->proto_id);
+ if (pe)
+ printf(" protoid=%s", pe->p_name);
+ else
+ printf(" protoid=%s", PROTOIDSTR(p->proto_id));
+ endprotoent();
+ printf(" port=%d", ntohs(p->port));
+ if (!len)
+ break;
+ switch (p->type) {
+ case IPSECDOI_ID_IPV4_ADDR:
+ printf(" len=%d %s", len, ipaddr_string(data));
+ len = 0;
+ break;
+ case IPSECDOI_ID_FQDN:
+ case IPSECDOI_ID_USER_FQDN:
+ {
+ int i;
+ printf(" len=%d ", len);
+ for (i = 0; i < len; i++) {
+ if (isprint(data[i]))
+ printf("%c", data[i]);
+ else
+ printf("\\%03o", data[i]);
+ }
+ len = 0;
+ break;
+ }
+ case IPSECDOI_ID_IPV4_ADDR_SUBNET:
+ {
+ u_char *mask;
+ mask = data + sizeof(struct in_addr);
+ printf(" len=%d %s/%u.%u.%u.%u", len,
+ ipaddr_string(data),
+ mask[0], mask[1], mask[2], mask[3]);
+ len = 0;
+ break;
+ }
+#ifdef INET6
+ case IPSECDOI_ID_IPV6_ADDR:
+ printf(" len=%d %s", len, ip6addr_string(data));
+ len = 0;
+ break;
+ case IPSECDOI_ID_IPV6_ADDR_SUBNET:
+ {
+ u_int32_t *mask;
+ mask = (u_int32_t *)(data + sizeof(struct in6_addr));
+ /*XXX*/
+ printf(" len=%d %s/0x%08x%08x%08x%08x", len,
+ ip6addr_string(data),
+ mask[0], mask[1], mask[2], mask[3]);
+ len = 0;
+ break;
+ }
+#endif /*INET6*/
+ case IPSECDOI_ID_IPV4_ADDR_RANGE:
+ printf(" len=%d %s-%s", len, ipaddr_string(data),
+ ipaddr_string(data + sizeof(struct in_addr)));
+ len = 0;
+ break;
+#ifdef INET6
+ case IPSECDOI_ID_IPV6_ADDR_RANGE:
+ printf(" len=%d %s-%s", len, ip6addr_string(data),
+ ip6addr_string(data + sizeof(struct in6_addr)));
+ len = 0;
+ break;
+#endif /*INET6*/
+ case IPSECDOI_ID_DER_ASN1_DN:
+ case IPSECDOI_ID_DER_ASN1_GN:
+ case IPSECDOI_ID_KEY_ID:
+ break;
+ }
+ break;
+ }
+ }
+ if (data && len) {
+ len -= sizeof(*p);
+ printf(" len=%d", len);
+ if (2 < vflag) {
+ printf(" ");
+ rawprint((caddr_t)data, len);
+ }
+ }
+ return (u_char *)ext + ntohs(ext->len);
+}
+
+static u_char *
+isakmp_hash_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi, u_int32_t proto)
+{
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_HASH));
+
+ printf(" len=%d", ntohs(ext->len) - 4);
+ if (2 < vflag && 4 < ntohs(ext->len)) {
+ printf(" ");
+ rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
+ }
+ return (u_char *)ext + ntohs(ext->len);
+}
+
+static u_char *
+isakmp_nonce_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi, u_int32_t proto)
+{
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_NONCE));
+
+ printf(" n len=%d", ntohs(ext->len) - 4);
+ if (2 < vflag && 4 < ntohs(ext->len)) {
+ printf(" ");
+ rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
+ }
+ return (u_char *)ext + ntohs(ext->len);
+}
+
+static u_char *
+isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi0, u_int32_t proto0)
+{
+ struct isakmp_pl_n *p;
+ u_char *cp;
+ u_char *ep2;
+ u_int32_t doi;
+ u_int32_t proto;
+ static char *notifystr[] = {
+ NULL, "INVALID-PAYLOAD-TYPE",
+ "DOI-NOT-SUPPORTED", "SITUATION-NOT-SUPPORTED",
+ "INVALID-COOKIE", "INVALID-MAJOR-VERSION",
+ "INVALID-MINOR-VERSION", "INVALID-EXCHANGE-TYPE",
+ "INVALID-FLAGS", "INVALID-MESSAGE-ID",
+ "INVALID-PROTOCOL-ID", "INVALID-SPI",
+ "INVALID-TRANSFORM-ID", "ATTRIBUTES-NOT-SUPPORTED",
+ "NO-PROPOSAL-CHOSEN", "BAD-PROPOSAL-SYNTAX",
+ "PAYLOAD-MALFORMED", "INVALID-KEY-INFORMATION",
+ "INVALID-ID-INFORMATION", "INVALID-CERT-ENCODING",
+ "INVALID-CERTIFICATE", "CERT-TYPE-UNSUPPORTED",
+ "INVALID-CERT-AUTHORITY", "INVALID-HASH-INFORMATION",
+ "AUTHENTICATION-FAILED", "INVALID-SIGNATURE",
+ "ADDRESS-NOTIFICATION", "NOTIFY-SA-LIFETIME",
+ "CERTIFICATE-UNAVAILABLE", "UNSUPPORTED-EXCHANGE-TYPE",
+ "UNEQUAL-PAYLOAD-LENGTHS",
+ };
+ static char *ipsecnotifystr[] = {
+ "RESPONDER-LIFETIME", "REPLAY-STATUS",
+ "INITIAL-CONTACT",
+ };
+/* NOTE: these macro must be called with x in proper range */
+#define NOTIFYSTR(x) \
+ (((x) == 16384) ? "CONNECTED" : STR_OR_ID((x), notifystr))
+#define IPSECNOTIFYSTR(x) \
+ (((x) == 8192) ? "RESERVED" : STR_OR_ID(((x) - 24576), ipsecnotifystr))
+
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_N));
+
+ p = (struct isakmp_pl_n *)ext;
+ doi = ntohl(p->doi);
+ proto = p->prot_id;
+ if (doi != 1) {
+ printf(" doi=%d", doi);
+ printf(" proto=%d", proto);
+ printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
+ if (p->spi_size) {
+ printf(" spi=");
+ rawprint((caddr_t)(p + 1), p->spi_size);
+ }
+ return (u_char *)(p + 1) + p->spi_size;
+ }
+
+ printf(" doi=ipsec");
+ printf(" proto=%s", PROTOIDSTR(proto));
+ if (ntohs(p->type) < 8192)
+ printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
+ else if (ntohs(p->type) < 16384)
+ printf(" type=%s", IPSECNOTIFYSTR(ntohs(p->type)));
+ else if (ntohs(p->type) < 24576)
+ printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
+ else if (ntohs(p->type) < 40960)
+ printf(" type=%s", IPSECNOTIFYSTR(ntohs(p->type)));
+ else
+ printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
+ if (p->spi_size) {
+ printf(" spi=");
+ rawprint((caddr_t)(p + 1), p->spi_size);
+ }
+
+ cp = (u_char *)(p + 1) + p->spi_size;
+ ep2 = (u_char *)p + ntohs(ext->len);
+
+ if (cp < ep) {
+ printf(" orig=(");
+ switch (ntohs(p->type)) {
+ case IPSECDOI_NTYPE_RESPONDER_LIFETIME:
+ {
+ struct attrmap *map = oakley_t_map;
+ size_t nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]);
+ while (cp < ep && cp < ep2) {
+ cp = isakmp_attrmap_print(cp,
+ (ep < ep2) ? ep : ep2, map, nmap);
+ }
+ break;
+ }
+ case IPSECDOI_NTYPE_REPLAY_STATUS:
+ printf("replay detection %sabled",
+ (*(u_int32_t *)cp) ? "en" : "dis");
+ break;
+ case ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN:
+ isakmp_sub_print(ISAKMP_NPTYPE_SA,
+ (struct isakmp_gen *)cp, ep, phase, doi, proto);
+ break;
+ default:
+ /* NULL is dummy */
+ isakmp_print(cp,
+ ntohs(ext->len) - sizeof(*p) - p->spi_size,
+ NULL);
+ }
+ printf(")");
+ }
+ return (u_char *)ext + ntohs(ext->len);
+}
+
+static u_char *
+isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi0, u_int32_t proto0)
+{
+ struct isakmp_pl_d *p;
+ u_int8_t *q;
+ u_int32_t doi;
+ u_int32_t proto;
+ int i;
+
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_D));
+
+ p = (struct isakmp_pl_d *)ext;
+ doi = ntohl(p->doi);
+ proto = p->prot_id;
+ if (doi != 1) {
+ printf(" doi=%u", doi);
+ printf(" proto=%u", proto);
+ } else {
+ printf(" doi=ipsec");
+ printf(" proto=%s", PROTOIDSTR(proto));
+ }
+ printf(" spilen=%u", p->spi_size);
+ printf(" nspi=%u", ntohs(p->num_spi));
+ printf(" spi=");
+ q = (u_int8_t *)(p + 1);
+ for (i = 0; i < ntohs(p->num_spi); i++) {
+ if (i != 0)
+ printf(",");
+ rawprint((caddr_t)q, p->spi_size);
+ q += p->spi_size;
+ }
+ return q;
+}
+
+static u_char *
+isakmp_vid_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
+ u_int32_t doi, u_int32_t proto)
+{
+ printf("%s:", NPSTR(ISAKMP_NPTYPE_VID));
+
+ printf(" len=%d", ntohs(ext->len) - 4);
+ if (2 < vflag && 4 < ntohs(ext->len)) {
+ printf(" ");
+ rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
+ }
+ return (u_char *)ext + ntohs(ext->len);
+}
+
+static u_char *
+isakmp_sub0_print(u_char np, struct isakmp_gen *ext, u_char *ep,
+ u_int32_t phase, u_int32_t doi, u_int32_t proto)
+{
+ u_char *cp;
+
+ cp = (u_char *)ext;
+
+ if (NPFUNC(np))
+ cp = (*NPFUNC(np))(ext, ep, phase, doi, proto);
+ else {
+ printf("%s", NPSTR(np));
+ cp += ntohs(ext->len);
+ }
+ return cp;
+}
+
+static u_char *
+isakmp_sub_print(u_char np, struct isakmp_gen *ext, u_char *ep,
+ u_int32_t phase, u_int32_t doi, u_int32_t proto)
+{
+ u_char *cp;
+ static int depth = 0;
+ int i;
+
+ cp = (u_char *)ext;
+
+ while (np) {
+ if (ep < (u_char *)ext + ntohs(ext->len)) {
+ printf(" [|%s]", NPSTR(np));
+ cp = ep + 1;
+ break;
+ }
+ depth++;
+ printf("\n");
+ for (i = 0; i < depth; i++)
+ printf(" ");
+ printf("(");
+ cp = isakmp_sub0_print(np, ext, ep, phase, doi, proto);
+ printf(")");
+ depth--;
+
+ np = ext->np;
+ ext = (struct isakmp_gen *)cp;
+ }
+ return cp;
+}
+
+static char *
+numstr(int x)
+{
+ static char buf[20];
+ snprintf(buf, sizeof(buf), "#%d", x);
+ return buf;
+}
-/*
- * Print isakmp requests
- */
void
-isakmp_print(register const u_char *cp, int length)
-{
- struct isakmp_header *ih;
- register const u_char *ep;
- int mode, version, leapind;
-
- ih = (struct isakmp_header *)cp;
- /* Note funny sized packets */
- if (length < 20)
- {
- (void)printf(" [len=%d]", length);
- }
+isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
+{
+ struct isakmp *base;
+ u_char *ep;
+ u_char np;
+ int i;
+ int phase;
- /* 'ep' points to the end of avaible data. */
- ep = snapend;
+ base = (struct isakmp *)bp;
+ ep = (u_char *)snapend;
- printf(" isakmp");
+ if ((struct isakmp *)ep < base + 1) {
+ printf("[|isakmp]");
+ return;
+ }
- printf(" v%d.%d\n\t", ih->mjver, ih->mnver);
+ printf("isakmp");
+ if (vflag)
+ printf(" %d.%d", base->v_maj, base->v_min);
- if(ih->flags & FLAGS_ENCRYPTION)
- {
- printf(" encrypted");
- }
-
- if(ih->flags & FLAGS_COMMIT)
- {
- printf(" commit");
- }
+ if (vflag) {
+ printf(" msgid ");
+ rawprint((caddr_t)&base->msgid, sizeof(base->msgid));
+ }
+
+ if (1 < vflag) {
+ printf(" cookie ");
+ rawprint((caddr_t)&base->i_ck, sizeof(base->i_ck));
+ printf("->");
+ rawprint((caddr_t)&base->r_ck, sizeof(base->r_ck));
+ }
+ printf(":");
+
+ phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2;
+ if (phase == 1)
+ printf(" phase %d", phase);
+ else
+ printf(" phase %d/others", phase);
+
+ i = cookie_find(&base->i_ck);
+ if (i < 0) {
+ if (iszero((u_char *)&base->r_ck, sizeof(base->r_ck))) {
+ /* the first packet */
+ printf(" I");
+ if (bp2)
+ cookie_record(&base->i_ck, bp2);
+ } else
+ printf(" ?");
+ } else {
+ if (bp2 && cookie_isinitiator(i, bp2))
+ printf(" I");
+ else if (bp2 && cookie_isresponder(i, bp2))
+ printf(" R");
+ else
+ printf(" ?");
+ }
+
+ printf(" %s", ETYPESTR(base->etype));
+ if (base->flags) {
+ printf("[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "",
+ base->flags & ISAKMP_FLAG_C ? "C" : "");
+ }
+ printf(":");
- printf(" from:%02x%02x%02x%02x to: %02x%02x%02x%02x",
- ih->init_cookie[0], ih->init_cookie[1],
- ih->init_cookie[2], ih->init_cookie[3],
- ih->resp_cookie[0], ih->resp_cookie[1],
- ih->resp_cookie[2], ih->resp_cookie[3]);
-
- TCHECK(ih->msgid);
- printf(" msgid:%02x%02x%02x%02x",
- ih->msgid[0], ih->msgid[1],
- ih->msgid[2], ih->msgid[3]);
-
- TCHECK(ih->length);
- printf(" length %d", ntohl(ih->length));
-
- if(ih->mjver > 1)
{
- printf(" new version");
- return;
+ struct isakmp_gen *ext;
+ int nparen;
+
+#define CHECKLEN(p, np) \
+ if (ep < (u_char *)(p)) { \
+ printf(" [|%s]", NPSTR(np)); \
+ goto done; \
+ }
+
+ /* regardless of phase... */
+ if (base->flags & ISAKMP_FLAG_E) {
+ /*
+ * encrypted, nothing we can do right now.
+ * we hope to decrypt the packet in the future...
+ */
+ printf(" [|%s]", NPSTR(base->np));
+ goto done;
+ }
+
+ nparen = 0;
+ CHECKLEN(base + 1, base->np)
+
+ np = base->np;
+ ext = (struct isakmp_gen *)(base + 1);
+ isakmp_sub_print(np, ext, ep, phase, 0, 0);
}
-trunc:
- fputs(" [|isakmp]", stdout);
+done:
+ if (vflag) {
+ if (ntohl(base->len) != length) {
+ printf(" (len mismatch: isakmp %u/ip %d)",
+ (u_int32_t)ntohl(base->len), length);
+ }
+ }
}
diff --git a/print-krb.c b/print-krb.c
index 8e24b3a1..63bfc863 100644
--- a/print-krb.c
+++ b/print-krb.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.10 1999-10-17 21:37:13 mcr Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.11 1999-10-30 05:11:17 itojun Exp $";
#endif
#include <sys/param.h>
@@ -33,7 +33,9 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <ctype.h>
#include <errno.h>
diff --git a/print-l2tp.c b/print-l2tp.c
new file mode 100644
index 00000000..3d71fcf4
--- /dev/null
+++ b/print-l2tp.c
@@ -0,0 +1,703 @@
+/*
+ * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * L2TP support contributed by Motonori Shindo (mshindo@ascend.co.jp)
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.1 1999-10-30 05:11:18 itojun Exp $";
+#endif
+
+#include <sys/types.h>
+#include <sys/param.h>
+
+#include "l2tp.h"
+#include "interface.h"
+
+static char tstr[] = " [|l2tp]";
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+static u_char *l2tp_message_type_string[] = {
+ "RESERVED_0", /* 0 Reserved */
+ "SCCRQ", /* 1 Start-Control-Connection-Request */
+ "SCCRP", /* 2 Start-Control-Connection-Reply */
+ "SCCCN", /* 3 Start-Control-Connection-Connected */
+ "StopCCN", /* 4 Stop-Control-Connection-Notification */
+ "RESERVED_5", /* 5 Reserved */
+ "HELLO", /* 6 Hello */
+ "OCRQ", /* 7 Outgoing-Call-Request */
+ "OCRP", /* 8 Outgoing-Call-Reply */
+ "OCCN", /* 9 Outgoing-Call-Connected */
+ "ICRQ", /* 10 Incoming-Call-Request */
+ "ICRP", /* 11 Incoming-Call-Reply */
+ "ICCN", /* 12 Incoming-Call-Connected */
+ "RESERVED_13", /* 13 Reserved */
+ "CDN", /* 14 Call-Disconnect-Notify */
+ "WEN", /* 15 WAN-Error-Notify */
+ "SLI" /* 16 Set-Link-Info */
+#define L2TP_MAX_MSGTYPE_INDEX 17
+};
+
+static void l2tp_msgtype_print(const u_char *dat, u_int length);
+static void l2tp_result_code_print(const u_char *dat, u_int length);
+static void l2tp_proto_ver_print(const u_char *dat, u_int length);
+static void l2tp_framing_cap_print(const u_char *dat, u_int length);
+static void l2tp_bearer_cap_print(const u_char *dat, u_int length);
+static void l2tp_tie_breaker_print(const u_char *dat, u_int length);
+static void l2tp_firm_ver_print(const u_char *dat, u_int length);
+static void l2tp_host_name_print(const u_char *dat, u_int length);
+static void l2tp_vendor_name_print(const u_char *dat, u_int length);
+static void l2tp_assnd_tun_id_print(const u_char *dat, u_int length);
+static void l2tp_recv_win_size_print(const u_char *dat, u_int length);
+static void l2tp_challenge_print(const u_char *dat, u_int length);
+static void l2tp_q931_cc_print(const u_char *dat, u_int length);
+static void l2tp_challenge_resp_print(const u_char *dat, u_int length);
+static void l2tp_assnd_sess_id_print(const u_char *dat, u_int length);
+static void l2tp_call_ser_num_print(const u_char *dat, u_int length);
+static void l2tp_minimum_bps_print(const u_char *dat, u_int length);
+static void l2tp_maximum_bps_print(const u_char *dat, u_int length);
+static void l2tp_bearer_type_print(const u_char *dat, u_int length);
+static void l2tp_framing_type_print(const u_char *dat, u_int length);
+static void l2tp_packet_proc_delay_print(const u_char *dat, u_int length);
+static void l2tp_called_number_print(const u_char *dat, u_int length);
+static void l2tp_calling_number_print(const u_char *dat, u_int length);
+static void l2tp_sub_address_print(const u_char *dat, u_int length);
+static void l2tp_tx_conn_speed_print(const u_char *dat, u_int length);
+static void l2tp_phy_channel_id_print(const u_char *dat, u_int length);
+static void l2tp_ini_recv_lcp_print(const u_char *dat, u_int length);
+static void l2tp_last_sent_lcp_print(const u_char *dat, u_int length);
+static void l2tp_last_recv_lcp_print(const u_char *dat, u_int length);
+static void l2tp_proxy_auth_type_print(const u_char *dat, u_int length);
+static void l2tp_proxy_auth_name_print(const u_char *dat, u_int length);
+static void l2tp_proxy_auth_chal_print(const u_char *dat, u_int length);
+static void l2tp_proxy_auth_id_print(const u_char *dat, u_int length);
+static void l2tp_proxy_auth_resp_print(const u_char *dat, u_int length);
+static void l2tp_call_errors_print(const u_char *dat, u_int length);
+static void l2tp_accm_print(const u_char *dat, u_int length);
+static void l2tp_random_vector_print(const u_char *dat, u_int length);
+static void l2tp_private_grp_id_print(const u_char *dat, u_int length);
+static void l2tp_rx_conn_speed_print(const u_char *dat, u_int length);
+static void l2tp_seq_required_print(const u_char *dat, u_int length);
+static void l2tp_avp_print(const u_char *dat, u_int length);
+
+static struct l2tp_avp_vec l2tp_avp[] = {
+ {"MSGTYPE", l2tp_msgtype_print}, /* 0 Message Type */
+ {"RESULT_CODE", l2tp_result_code_print}, /* 1 Result Code */
+ {"PROTO_VER", l2tp_proto_ver_print}, /* 2 Protocol Version */
+ {"FRAMING_CAP", l2tp_framing_cap_print}, /* 3 Framing Capabilities */
+ {"BEARER_CAP", l2tp_bearer_cap_print}, /* 4 Bearer Capabilities */
+ {"TIE_BREAKER", l2tp_tie_breaker_print}, /* 5 Tie Breaker */
+ {"FIRM_VER", l2tp_firm_ver_print}, /* 6 Firmware Revision */
+ {"HOST_NAME", l2tp_host_name_print}, /* 7 Host Name */
+ {"VENDOR_NAME", l2tp_vendor_name_print}, /* 8 Vendor Name */
+ {"ASSND_TUN_ID", l2tp_assnd_tun_id_print}, /* 9 Assigned Tunnel ID */
+ {"RECV_WIN_SIZE", l2tp_recv_win_size_print}, /* 10 Receive Window Size */
+ {"CHALLENGE", l2tp_challenge_print}, /* 11 Challenge */
+ {"Q931_CC", l2tp_q931_cc_print}, /* 12 Q.931 Cause Code */
+ {"CHALLENGE_RESP", l2tp_challenge_resp_print},/* 13 Challenge Response */
+ {"ASSND_SESS_ID", l2tp_assnd_sess_id_print}, /* 14 Assigned Session ID */
+ {"CALL_SER_NUM", l2tp_call_ser_num_print}, /* 15 Call Serial Number */
+ {"MINIMUM_BPS", l2tp_minimum_bps_print},/* 16 Minimum BPS */
+ {"MAXIMUM_BPS", l2tp_maximum_bps_print}, /* 17 Maximum BPS */
+ {"BEARER_TYPE", l2tp_bearer_type_print},/* 18 Bearer Type */
+ {"FRAMING_TYPE", l2tp_framing_type_print}, /* 19 Framing Type */
+ {"PACKET_PROC_DELAY", l2tp_packet_proc_delay_print}, /* 20 Packet Processing Delay (OBSOLETE) */
+ {"CALLED_NUMBER", l2tp_called_number_print}, /* 21 Called Number */
+ {"CALLING_NUMBER", l2tp_calling_number_print},/* 22 Calling Number */
+ {"SUB_ADDRESS", l2tp_sub_address_print},/* 23 Sub-Address */
+ {"TX_CONN_SPEED", l2tp_tx_conn_speed_print}, /* 24 (Tx) Connect Speed */
+ {"PHY_CHANNEL_ID", l2tp_phy_channel_id_print},/* 25 Physical Channel ID */
+ {"INI_RECV_LCP", l2tp_ini_recv_lcp_print}, /* 26 Initial Received LCP CONFREQ */
+ {"LAST_SENT_LCP", l2tp_last_sent_lcp_print}, /* 27 Last Sent LCP CONFREQ */
+ {"LAST_RECV_LCP", l2tp_last_recv_lcp_print}, /* 28 Last Received LCP CONFREQ */
+ {"PROXY_AUTH_TYPE", l2tp_proxy_auth_type_print},/* 29 Proxy Authen Type */
+ {"PROXY_AUTH_NAME", l2tp_proxy_auth_name_print},/* 30 Proxy Authen Name */
+ {"PROXY_AUTH_CHAL", l2tp_proxy_auth_chal_print},/* 31 Proxy Authen Challenge */
+ {"PROXY_AUTH_ID", l2tp_proxy_auth_id_print}, /* 32 Proxy Authen ID */
+ {"PROXY_AUTH_RESP", l2tp_proxy_auth_resp_print},/* 33 Proxy Authen Response */
+ {"CALL_ERRORS", l2tp_call_errors_print}, /* 34 Call Errors */
+ {"ACCM", l2tp_accm_print}, /* 35 ACCM */
+ {"RANDOM_VECTOR", l2tp_random_vector_print}, /* 36 Random Vector */
+ {"PRIVATE_GRP_ID", l2tp_private_grp_id_print},/* 37 Private Group ID */
+ {"RX_CONN_SPEED", l2tp_rx_conn_speed_print}, /* 38 (Rx) Connect Speed */
+ {"SEQ_REQUIRED", l2tp_seq_required_print}, /* 39 Sequencing Required */
+#define L2TP_MAX_AVP_INDEX 40
+};
+
+static char *l2tp_result_code_StopCCN[] = {
+ "Reserved",
+ "General request to clear control connection",
+ "General error--Error Code indicates the problem",
+ "Control channel already exists",
+ "Requester is not authorized to establish a control channel",
+ "The protocol version of the requester is not supported",
+ "Requester is being shut down",
+ "Finite State Machine error"
+#define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8
+};
+
+static char *l2tp_result_code_CDN[] = {
+ "Reserved",
+ "Call disconnected due to loss of carrier",
+ "Call disconnected for the reason indicated in error code",
+ "Call disconnected for administrative reasons",
+ "Call failed due to lack of appropriate facilities being " \
+ "available (temporary condition)",
+ "Call failed due to lack of appropriate facilities being " \
+ "available (permanent condition)",
+ "Invalid destination",
+ "Call failed due to no carrier detected",
+ "Call failed due to detection of a busy signal",
+ "Call failed due to lack of a dial tone",
+ "Call was not established within time allotted by LAC",
+ "Call was connected but no appropriate framing was detected"
+#define L2TP_MAX_RESULT_CODE_CDN_INDEX 12
+};
+
+static char *l2tp_error_code_general[] = {
+ "No general error",
+ "No control connection exists yet for this LAC-LNS pair",
+ "Length is wrong",
+ "One of the field values was out of range or " \
+ "reserved field was non-zero"
+ "Insufficient resources to handle this operation now",
+ "The Session ID is invalid in this context",
+ "A generic vendor-specific error occurred in the LAC",
+ "Try another"
+#define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8
+};
+
+/******************************/
+/* generic print out routines */
+/******************************/
+static void
+print_string(const u_char *dat, u_int length)
+{
+ int i;
+ for (i=0; i<length; i++) {
+ printf("%c", *dat++);
+ }
+}
+
+static void
+print_octets(const u_char *dat, u_int length)
+{
+ int i;
+ for (i=0; i<length; i++) {
+ printf("%02x", *dat++);
+ }
+}
+
+static void
+print_short(const u_short *dat)
+{
+ printf("%d", ntohs(*dat));
+}
+
+static void
+print_int(const u_int *dat)
+{
+ printf("%d", ntohl(*dat));
+}
+
+/**********************************/
+/* AVP-specific print out routines*/
+/**********************************/
+static void
+l2tp_msgtype_print(const u_char *dat, u_int length)
+{
+ u_short *ptr = (u_short *)dat;
+
+ if (ntohs(*ptr) < L2TP_MAX_MSGTYPE_INDEX) {
+ printf("%s", l2tp_message_type_string[ntohs(*ptr)]);
+ }
+}
+
+static void
+l2tp_result_code_print(const u_char *dat, u_int length)
+{
+ /* we just print out the result and error code number */
+ u_short *ptr = (u_short *)dat;
+
+ if (length == 2) { /* result code */
+ printf("%d", ntohs(*ptr));
+ } else if (length == 4) { /* result & error code */
+ printf("%d/%d", ntohs(*ptr), ntohs(*(ptr+1)));
+ } else if (length > 4) { /* result & error code & msg */
+ printf("%d/%d %s", ntohs(*ptr), ntohs(*(ptr+1)));
+ print_string((u_char *)(ptr+2), length - 4);
+ }
+}
+
+static void
+l2tp_proto_ver_print(const u_char *dat, u_int length)
+{
+ printf("%d.%d", *dat, *(dat+1));
+}
+
+
+static void
+l2tp_framing_cap_print(const u_char *dat, u_int length)
+{
+ u_int *ptr = (u_int *)dat;
+
+ if (ntohl(*ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) {
+ printf("A");
+ }
+ if (ntohl(*ptr) & L2TP_FRAMING_CAP_SYNC_MASK) {
+ printf("S");
+ }
+}
+
+static void
+l2tp_bearer_cap_print(const u_char *dat, u_int length)
+{
+ u_int *ptr = (u_int *)dat;
+
+ if (ntohl(*ptr) & L2TP_BEARER_CAP_ANALOG_MASK) {
+ printf("A");
+ }
+ if (ntohl(*ptr) & L2TP_BEARER_CAP_DIGITAL_MASK) {
+ printf("D");
+ }
+}
+
+static void
+l2tp_tie_breaker_print(const u_char *dat, u_int length)
+{
+ printf("%lx", *(u_long *)dat); /* XXX */
+}
+
+static void
+l2tp_firm_ver_print(const u_char *dat, u_int length)
+{
+ print_short((u_short *)dat);
+}
+
+static void
+l2tp_host_name_print(const u_char *dat, u_int length)
+{
+ print_string(dat, length);
+}
+
+static void
+l2tp_vendor_name_print(const u_char *dat, u_int length)
+{
+ print_string(dat, length);
+}
+
+static void
+l2tp_assnd_tun_id_print(const u_char *dat, u_int length)
+{
+ print_short((u_short *)dat);
+}
+
+static void
+l2tp_recv_win_size_print(const u_char *dat, u_int length)
+{
+ print_short((u_short *)dat);
+}
+
+static void
+l2tp_challenge_print(const u_char *dat, u_int length)
+{
+ print_octets(dat, length);
+}
+
+static void
+l2tp_q931_cc_print(const u_char *dat, u_int length)
+{
+ print_short((u_short *)dat);
+ printf(",%02x", dat+2);
+ if (length > 3) {
+ printf(" ");
+ print_string(dat+3, length-3);
+ }
+}
+
+static void
+l2tp_challenge_resp_print(const u_char *dat, u_int length)
+{
+ print_octets(dat, 16); /* XXX length should be 16? */
+}
+
+static void
+l2tp_assnd_sess_id_print(const u_char *dat, u_int length)
+{
+ print_short((u_short *)dat);
+}
+
+static void
+l2tp_call_ser_num_print(const u_char *dat, u_int length)
+{
+ print_int((u_int *)dat);
+}
+
+static void
+l2tp_minimum_bps_print(const u_char *dat, u_int length)
+{
+ print_int((u_int *)dat);
+}
+
+static void
+l2tp_maximum_bps_print(const u_char *dat, u_int length)
+{
+ print_int((u_int *)dat);
+}
+
+static void
+l2tp_bearer_type_print(const u_char *dat, u_int length)
+{
+ u_int *ptr = (u_int *)dat;
+
+ if (ntohl(*ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) {
+ printf("A");
+ }
+ if (ntohl(*ptr) & L2TP_BEARER_TYPE_DIGITAL_MASK) {
+ printf("D");
+ }
+}
+
+static void
+l2tp_framing_type_print(const u_char *dat, u_int length)
+{
+ u_int *ptr = (u_int *)dat;
+
+ if (ntohl(*ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
+ printf("A");
+ }
+ if (ntohl(*ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) {
+ printf("S");
+ }
+}
+
+static void
+l2tp_packet_proc_delay_print(const u_char *dat, u_int length)
+{
+ printf("obsolete");
+}
+
+static void
+l2tp_called_number_print(const u_char *dat, u_int length)
+{
+ print_string(dat, length);
+}
+
+static void
+l2tp_calling_number_print(const u_char *dat, u_int length)
+{
+ print_string(dat, length);
+}
+
+static void
+l2tp_sub_address_print(const u_char *dat, u_int length)
+{
+ print_string(dat, length);
+}
+
+static void
+l2tp_tx_conn_speed_print(const u_char *dat, u_int length)
+{
+ print_int((u_int *)dat);
+}
+
+static void
+l2tp_phy_channel_id_print(const u_char *dat, u_int length)
+{
+ print_int((u_int *)dat);
+}
+
+static void
+l2tp_ini_recv_lcp_print(const u_char *dat, u_int length)
+{
+ print_octets(dat, length);
+}
+
+static void
+l2tp_last_sent_lcp_print(const u_char *dat, u_int length)
+{
+ print_octets(dat, length);
+}
+
+static void
+l2tp_last_recv_lcp_print(const u_char *dat, u_int length)
+{
+ print_octets(dat, length);
+}
+
+static void
+l2tp_proxy_auth_type_print(const u_char *dat, u_int length)
+{
+ u_short *ptr = (u_short *)dat;
+
+ switch (ntohs(*ptr)) {
+ case L2TP_AUTHEN_TYPE_RESERVED:
+ printf("Reserved");
+ break;
+ case L2TP_AUTHEN_TYPE_TEXTUAL:
+ printf("Textual");
+ break;
+ case L2TP_AUTHEN_TYPE_CHAP:
+ printf("CHAP");
+ break;
+ case L2TP_AUTHEN_TYPE_PAP:
+ printf("PAP");
+ break;
+ case L2TP_AUTHEN_TYPE_NO_AUTH:
+ printf("No Auth");
+ break;
+ case L2TP_AUTHEN_TYPE_MSCHAP:
+ printf("MS-CHAP");
+ break;
+ default:
+ printf("unknown");
+ }
+}
+
+static void
+l2tp_proxy_auth_name_print(const u_char *dat, u_int length)
+{
+ print_octets(dat, length);
+}
+
+static void
+l2tp_proxy_auth_chal_print(const u_char *dat, u_int length)
+{
+ print_octets(dat, length);
+}
+
+static void
+l2tp_proxy_auth_id_print(const u_char *dat, u_int length)
+{
+ u_short *ptr = (u_short *)dat;
+
+ printf("%d", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);
+}
+
+static void
+l2tp_proxy_auth_resp_print(const u_char *dat, u_int length)
+{
+ print_octets(dat, length);
+}
+
+static void
+l2tp_call_errors_print(const u_char *dat, u_int length)
+{
+ struct l2tp_call_errors *ptr = (struct l2tp_call_errors *)dat;
+
+ printf("CRCErr=%d FrameErr=%d HardOver=%d BufOver=%d ",
+ ptr->crc_errs,
+ ptr->framing_errs,
+ ptr->hardware_overruns,
+ ptr->buffer_overruns);
+ printf("Timeout=%d AlingErr=%d",
+ ptr->timeout_errs,
+ ptr->alignment_errs);
+}
+
+static void
+l2tp_accm_print(const u_char *dat, u_int length)
+{
+ struct l2tp_accm *ptr = (struct l2tp_accm *)dat;
+
+ printf("send=%x recv=%x", ptr->send_accm, ptr->recv_accm);
+}
+
+static void
+l2tp_random_vector_print(const u_char *dat, u_int length)
+{
+ print_octets(dat, length);
+}
+
+static void
+l2tp_private_grp_id_print(const u_char *dat, u_int length)
+{
+ print_string(dat, length);
+ /* XXX print_octets is more appropriate?? */
+}
+
+static void
+l2tp_rx_conn_speed_print(const u_char *dat, u_int length)
+{
+ print_int((u_int *)dat);
+}
+
+static void
+l2tp_seq_required_print(const u_char *dat, u_int length)
+{
+ return;
+}
+
+static void
+l2tp_avp_print(const u_char *dat, u_int length)
+{
+ u_int len;
+ const u_short *ptr = (u_short *)dat;
+ int hidden = FALSE;
+
+ printf(" ");
+ if (length > 0 && (snapend - dat) >= 2) {
+ /* there must be at least two octets for the length
+ to be decoded */
+ if ((len = (ntohs(*ptr) & L2TP_AVP_HDR_LEN_MASK)) <=
+ (snapend - dat)) {
+ if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
+ printf("*");
+ }
+ if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
+ hidden = TRUE;
+ printf("?");
+ }
+ } else {
+ printf("|...");
+ return;
+ }
+ ptr++;
+
+ if (ntohs(*ptr)) { /* IETF == 0 */
+ printf("vendor=%04x", ntohs(*ptr));
+ }
+ ptr++;
+
+ if (ntohs(*ptr) < L2TP_MAX_AVP_INDEX) {
+ printf("%s", l2tp_avp[ntohs(*ptr)].name);
+ printf("(");
+ if (!hidden) {
+ (l2tp_avp[ntohs(*ptr)].print)
+ ((u_char *)ptr+2, len-6);
+ } else {
+ printf("???");
+ }
+ printf(")");
+ } else {
+ printf(" invalid AVP %s", ntohs(*ptr));
+ }
+
+ l2tp_avp_print(dat + len, length - len);
+ } else if (length == 0) {
+ return;
+ } else {
+ printf("|...");
+ }
+}
+
+
+void
+l2tp_print(const u_char *dat, u_int length)
+{
+ const u_short *ptr = (u_short *)dat;
+ u_int cnt = 0; /* total octets consumed */
+ u_short pad;
+ int flag_t, flag_l, flag_s, flag_o, flag_p;
+ u_short l2tp_len;
+
+ flag_t = flag_l = flag_s = flag_o = flag_p = FALSE;
+
+ if (min(length, snapend - dat) - 6 < 0) {
+ /* flag/ver, tunnel_id, session_id must be present for
+ this packet to be properly decoded */
+ printf("%s", tstr);
+ return;
+ }
+
+ if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
+ printf(" l2tp:");
+ } else if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
+ printf(" l2f:");
+ return; /* nothing to do */
+ } else {
+ printf(" Unknown Version, neither L2F(1) nor L2TP(2)");
+ return; /* nothing we can do */
+ }
+
+ printf("[");
+ if (ntohs(*ptr) & L2TP_FLAG_TYPE) {
+ flag_t = TRUE;
+ printf("T");
+ }
+ if (ntohs(*ptr) & L2TP_FLAG_LENGTH) {
+ flag_l = TRUE;
+ printf("L");
+ }
+ if (ntohs(*ptr) & L2TP_FLAG_SEQUENCE) {
+ flag_s = TRUE;
+ printf("S");
+ }
+ if (ntohs(*ptr) & L2TP_FLAG_OFFSET) {
+ flag_o = TRUE;
+ printf("O");
+ }
+ if (ntohs(*ptr) & L2TP_FLAG_PRIORITY) {
+ flag_p = TRUE;
+ printf("P");
+ }
+ printf("]");
+
+ ptr++;
+ cnt += 2;
+
+ if (flag_l) {
+ l2tp_len = ntohs(*ptr++); /* XXX need to consider
+ truncation ?? */
+ cnt += 2;
+ } else {
+ l2tp_len = 0;
+ }
+
+ printf("(%d/", ntohs(*ptr++)); /* Tunnel ID */
+ printf("%d)", ntohs(*ptr++)); /* Session ID */
+ cnt += 4;
+
+ if (flag_s) {
+ printf("Ns=%d,", ntohs(*ptr++));
+ printf("Nr=%d", ntohs(*ptr++));
+ cnt += 4;
+ }
+
+ if (flag_o) {
+ pad = ntohs(*ptr++);
+ (u_char *)ptr += pad;
+ cnt += (2 + pad);
+ }
+
+ if (flag_t) {
+ if (length - cnt == 0) {
+ printf(" ZLB");
+ } else {
+ l2tp_avp_print((u_char *)ptr, length - cnt);
+ }
+ } else {
+#if 0
+ printf(" {");
+ ppp_hdlc_print((u_char *)ptr, length - cnt);
+ printf("}");
+#else
+ printf("[hdlc|]");
+#endif
+ }
+}
diff --git a/print-mobile.c b/print-mobile.c
new file mode 100644
index 00000000..4cbbc918
--- /dev/null
+++ b/print-mobile.c
@@ -0,0 +1,141 @@
+/* $NetBSD: print-mobile.c,v 1.2 1998/09/30 08:57:01 hwr Exp $ */
+
+/*
+ * (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Heiko W.Rupp <hwr@pilhuhn.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if 0
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: print-mobile.c,v 1.2 1998/09/30 08:57:01 hwr Exp $");
+#endif
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+
+#include <netdb.h>
+#include <stdio.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h" /* must come after interface.h */
+
+#define MOBILE_SIZE (8)
+
+struct mobile_ip {
+ u_int16_t proto;
+ u_int16_t hcheck;
+ u_int32_t odst;
+ u_int32_t osrc;
+};
+
+#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
+ */
+void
+mobile_print(const u_char *bp, u_int length)
+{
+ const u_char *cp = bp +8 ;
+ const struct mobile_ip *mob;
+ u_short proto,crc;
+ u_char osp =0; /* old source address present */
+
+ mob = (const struct mobile_ip *)bp;
+
+ if (length < MOBILE_SIZE) {
+ fputs("[|mobile]", stdout);
+ return;
+ }
+
+ proto = EXTRACT_16BITS(&mob->proto);
+ crc = EXTRACT_16BITS(&mob->hcheck);
+ if (proto & OSRC_PRES) {
+ osp=1;
+ cp +=4 ;
+ }
+
+ if (osp) {
+ fputs("[S] ",stdout);
+ if (vflag)
+ (void)printf("%s ",ipaddr_string(&mob->osrc));
+ } else {
+ fputs("[] ",stdout);
+ }
+ if (vflag) {
+ (void)printf("> %s ",ipaddr_string(&mob->odst));
+ (void)printf("(oproto=%d)",proto>>8);
+ }
+ if (mob_in_cksum((u_short *)mob, osp ? 12 : 8)!=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);
+}
+
diff --git a/print-netbios.c b/print-netbios.c
index 2de7e21e..b2fd6223 100644
--- a/print-netbios.c
+++ b/print-netbios.c
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.11 1999-10-17 21:37:13 mcr Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.12 1999-10-30 05:11:18 itojun Exp $";
#endif
#include <sys/param.h>
@@ -33,8 +33,11 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
+#include <netinet/tcpip.h>
#ifdef __STDC__
#include <stdlib.h>
diff --git a/print-null.c b/print-null.c
index 13035720..f5b03227 100644
--- a/print-null.c
+++ b/print-null.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.25 1999-10-17 21:37:14 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.26 1999-10-30 05:11:18 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -40,13 +40,19 @@ struct rtentry;
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/if_ether.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <pcap.h>
#include <stdio.h>
#include <string.h>
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
+
#include "interface.h"
#include "addrtoname.h"
@@ -77,6 +83,12 @@ null_print(const u_char *p, const struct ip *ip, u_int length)
printf("ip: ");
break;
+#ifdef INET6
+ case AF_INET6:
+ printf("ip6: ");
+ break;
+#endif
+
case AF_NS:
printf("ns: ");
break;
@@ -111,7 +123,14 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (eflag)
null_print(p, ip, length);
+#ifndef INET6
ip_print((const u_char *)ip, length);
+#else
+ if (ip->ip_v == IPVERSION)
+ ip_print((const u_char *)ip, length);
+ else if (ip->ip_v == 6)
+ ip6_print((const u_char *)ip, length);
+#endif /*INET6*/
if (xflag)
default_print((const u_char *)ip, caplen - NULL_HDRLEN);
diff --git a/print-ospf.c b/print-ospf.c
index 92945b39..4d247556 100644
--- a/print-ospf.c
+++ b/print-ospf.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.25 1999-10-17 21:37:14 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.26 1999-10-30 05:11:19 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -33,6 +33,7 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <ctype.h>
#include <stdio.h>
@@ -506,9 +507,11 @@ ospf_print(register const u_char *bp, register u_int length,
op = (struct ospfhdr *)bp;
ip = (struct ip *)bp2;
/* Print the source and destination address */
+#if 0
(void) printf("%s > %s:",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
+#endif
/* XXX Before we do anything else, strip off the MD5 trailer */
TCHECK(op->ospf_authtype);
diff --git a/print-ospf6.c b/print-ospf6.c
new file mode 100644
index 00000000..61ab381e
--- /dev/null
+++ b/print-ospf6.c
@@ -0,0 +1,664 @@
+/*
+ * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.1 1999-10-30 05:11:19 itojun Exp $ (LBL)";
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+#include "ospf6.h"
+
+struct bits {
+ u_int32_t bit;
+ const char *str;
+};
+
+static const struct bits ospf6_option_bits[] = {
+ { OSPF6_OPTION_V6, "V6" },
+ { OSPF6_OPTION_E, "E" },
+ { OSPF6_OPTION_MC, "MC" },
+ { OSPF6_OPTION_N, "N" },
+ { OSPF6_OPTION_R, "R" },
+ { OSPF6_OPTION_DC, "DC" },
+ { 0, NULL }
+};
+
+static const struct bits ospf6_rla_flag_bits[] = {
+ { RLA_FLAG_B, "B" },
+ { RLA_FLAG_E, "E" },
+ { RLA_FLAG_V, "V" },
+ { RLA_FLAG_W, "W" },
+ { 0, NULL }
+};
+
+static struct tok type2str[] = {
+ { OSPF_TYPE_UMD, "umd" },
+ { OSPF_TYPE_HELLO, "hello" },
+ { OSPF_TYPE_DB, "dd" },
+ { OSPF_TYPE_LSR, "ls_req" },
+ { OSPF_TYPE_LSU, "ls_upd" },
+ { OSPF_TYPE_LSA, "ls_ack" },
+ { 0, NULL }
+};
+
+static char tstr[] = " [|ospf]";
+
+/* Forwards */
+static inline void ospf6_print_seqage(u_int32_t, time_t);
+static inline void ospf6_print_bits(const struct bits *, u_char);
+static void ospf6_print_ls_type(u_int, const rtrid_t *,
+ const rtrid_t *, const char *);
+static int ospf6_print_lshdr(const struct lsa_hdr *);
+static int ospf6_print_lsa(const struct lsa *);
+static int ospf6_decode_v3(const struct ospf6hdr *, const u_char *);
+
+static inline void
+ospf6_print_seqage(register u_int32_t seq, register time_t us)
+{
+ register time_t sec = us % 60;
+ register time_t mins = (us / 60) % 60;
+ register time_t hour = us / 3600;
+
+ printf(" S %X age ", seq);
+ if (hour)
+ printf("%u:%02u:%02u",
+ (u_int32_t) hour, (u_int32_t) mins, (u_int32_t) sec);
+ else if (mins)
+ printf("%u:%02u", (u_int32_t) mins, (u_int32_t) sec);
+ else
+ printf("%u", (u_int32_t) sec);
+}
+
+
+static inline void
+ospf6_print_bits(register const struct bits *bp, register u_char options)
+{
+ register char sep = ' ';
+
+ do {
+ if (options & bp->bit) {
+ printf("%c%s", sep, bp->str);
+ sep = '/';
+ }
+ } while ((++bp)->bit);
+}
+
+static void
+ospf6_print_ls_type(register u_int ls_type,
+ register const rtrid_t *ls_stateid,
+ register const rtrid_t *ls_router, register const char *fmt)
+{
+ char *scope;
+
+ switch (ls_type & LS_SCOPE_MASK) {
+ case LS_SCOPE_LINKLOCAL:
+ scope = "linklocal-";
+ break;
+ case LS_SCOPE_AREA:
+ scope = "area-";
+ break;
+ case LS_SCOPE_AS:
+ scope = "AS-";
+ break;
+ default:
+ scope = "";
+ break;
+ }
+
+ switch (ls_type & LS_TYPE_MASK) {
+ case LS_TYPE_ROUTER:
+ printf(" %srtr %s", scope, ipaddr_string(ls_router));
+ break;
+
+ case LS_TYPE_NETWORK:
+ printf(" %snet dr %s if %s", scope,
+ ipaddr_string(ls_router),
+ ipaddr_string(ls_stateid));
+ break;
+
+ case LS_TYPE_INTER_AP:
+ printf(" %sinter-area-prefix %s abr %s", scope,
+ ipaddr_string(ls_stateid),
+ ipaddr_string(ls_router));
+ break;
+
+ case LS_TYPE_INTER_AR:
+ printf(" %sinter-area-router %s rtr %s", scope,
+ ipaddr_string(ls_router),
+ ipaddr_string(ls_stateid));
+ break;
+
+ case LS_TYPE_ASE:
+ printf(" %sase %s asbr %s", scope,
+ ipaddr_string(ls_stateid),
+ ipaddr_string(ls_router));
+ break;
+
+ case LS_TYPE_GROUP:
+ printf(" %sgroup %s rtr %s", scope,
+ ipaddr_string(ls_stateid),
+ ipaddr_string(ls_router));
+ break;
+
+ case LS_TYPE_TYPE7:
+ printf(" %stype7 %s rtr %s", scope,
+ ipaddr_string(ls_stateid),
+ ipaddr_string(ls_router));
+ break;
+
+ case LS_TYPE_LINK:
+ printf(" %slink %s rtr %s", scope,
+ ipaddr_string(ls_stateid),
+ ipaddr_string(ls_router));
+ break;
+
+ case LS_TYPE_INTRA_AP:
+ printf(" %sintra-area-prefix %s rtr %s", scope,
+ ipaddr_string(ls_stateid),
+ ipaddr_string(ls_router));
+ break;
+
+ default:
+ printf(" %s", scope);
+ printf(fmt, ls_type);
+ break;
+ }
+
+}
+
+static int
+ospf6_print_lshdr(register const struct lsa_hdr *lshp)
+{
+
+ TCHECK(lshp->ls_type);
+ printf(" {"); /* } (ctags) */
+
+ TCHECK(lshp->ls_seq);
+ ospf6_print_seqage(ntohl(lshp->ls_seq), ntohs(lshp->ls_age));
+ ospf6_print_ls_type(ntohs(lshp->ls_type), &lshp->ls_stateid,
+ &lshp->ls_router, "ls_type %d");
+
+ return (0);
+trunc:
+ return (1);
+}
+
+static int
+ospf6_print_lsaprefix(register const struct lsa_prefix *lsapp)
+{
+ int k;
+ struct in6_addr prefix;
+
+ TCHECK(*lsapp);
+ k = (lsapp->lsa_p_len + 31) / 32;
+ if (k * 4 > sizeof(struct in6_addr)) {
+ printf("??prefixlen %d??", lsapp->lsa_p_len);
+ goto trunc;
+ }
+ memset(&prefix, 0, sizeof(prefix));
+ memcpy(&prefix, lsapp->lsa_p_prefix, k * 4);
+ printf(" %s/%d", ip6addr_string(&prefix),
+ lsapp->lsa_p_len);
+ if (lsapp->lsa_p_opt)
+ printf("(opt=%x)", lsapp->lsa_p_opt);
+ return sizeof(*lsapp) - 4 + k * 4;
+
+trunc:
+ return -1;
+}
+
+
+/*
+ * Print a single link state advertisement. If truncated return 1, else 0.
+ */
+static int
+ospf6_print_lsa(register const struct lsa *lsap)
+{
+ register const u_char *ls_end;
+ register const struct rlalink *rlp;
+#if 0
+ register const struct tos_metric *tosp;
+#endif
+ register const rtrid_t *ap;
+#if 0
+ register const struct aslametric *almp;
+ register const struct mcla *mcp;
+#endif
+ register const struct llsa *llsap;
+ register const struct lsa_prefix *lsapp;
+#if 0
+ register const u_int32_t *lp;
+#endif
+ register int j, k;
+
+ if (ospf6_print_lshdr(&lsap->ls_hdr))
+ return (1);
+ TCHECK(lsap->ls_hdr.ls_length);
+ ls_end = (u_char *)lsap + ntohs(lsap->ls_hdr.ls_length);
+ switch (ntohs(lsap->ls_hdr.ls_type)) {
+ case LS_TYPE_ROUTER | LS_SCOPE_AREA:
+ TCHECK(lsap->lsa_un.un_rla.rla_flags);
+ ospf6_print_bits(ospf6_rla_flag_bits,
+ lsap->lsa_un.un_rla.rla_flags);
+ TCHECK(lsap->lsa_un.un_rla.rla_options);
+ ospf6_print_bits(ospf6_option_bits,
+ ntohl(lsap->lsa_un.un_rla.rla_options));
+
+ TCHECK(lsap->lsa_un.un_rla.rla_link);
+ rlp = lsap->lsa_un.un_rla.rla_link;
+ while (rlp + sizeof(*rlp) <= (struct rlalink *)ls_end) {
+ TCHECK(*rlp);
+ printf(" {"); /* } (ctags) */
+ switch (rlp->link_type) {
+
+ case RLA_TYPE_VIRTUAL:
+ printf(" virt");
+ /* Fall through */
+
+ case RLA_TYPE_ROUTER:
+ printf(" nbrid %s nbrif %s if %s",
+ ipaddr_string(&rlp->link_nrtid),
+ ipaddr_string(&rlp->link_nifid),
+ ipaddr_string(&rlp->link_ifid));
+ break;
+
+ case RLA_TYPE_TRANSIT:
+ printf(" dr %s drif %s if %s",
+ ipaddr_string(&rlp->link_nrtid),
+ ipaddr_string(&rlp->link_nifid),
+ ipaddr_string(&rlp->link_ifid));
+ break;
+
+ default:
+ /* { (ctags) */
+ printf(" ??RouterLinksType 0x%02x?? }",
+ rlp->link_type);
+ return (0);
+ }
+ printf(" metric %d", ntohs(rlp->link_metric));
+ /* { (ctags) */
+ printf(" }");
+ rlp++;
+ }
+ break;
+
+ case LS_TYPE_NETWORK | LS_SCOPE_AREA:
+ TCHECK(lsap->lsa_un.un_nla.nla_options);
+ ospf6_print_bits(ospf6_option_bits,
+ ntohl(lsap->lsa_un.un_nla.nla_options));
+ printf(" rtrs");
+ ap = lsap->lsa_un.un_nla.nla_router;
+ while ((u_char *)ap < ls_end) {
+ TCHECK(*ap);
+ printf(" %s", ipaddr_string(ap));
+ ++ap;
+ }
+ break;
+
+ case LS_TYPE_INTER_AP | LS_SCOPE_AREA:
+ TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
+ printf(" metric %u",
+ (u_int32_t)ntohl(lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC);
+ lsapp = lsap->lsa_un.un_inter_ap.inter_ap_prefix;
+ while (lsapp + sizeof(lsapp) <= (struct lsa_prefix *)ls_end) {
+ k = ospf6_print_lsaprefix(lsapp);
+ if (k < 0)
+ goto trunc;
+ lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
+ }
+ break;
+
+#if 0
+ case LS_TYPE_SUM_ABR:
+ TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+ lp = lsap->lsa_un.un_sla.sla_tosmetric;
+ while ((u_char *)lp < ls_end) {
+ register u_int32_t ul;
+
+ TCHECK(*lp);
+ ul = ntohl(*lp);
+ printf(" tos %d metric %d",
+ (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS,
+ ul & SLA_MASK_METRIC);
+ ++lp;
+ }
+ break;
+
+ case LS_TYPE_ASE:
+ TCHECK(lsap->lsa_un.un_nla.nla_mask);
+ printf(" mask %s",
+ ipaddr_string(&lsap->lsa_un.un_asla.asla_mask));
+
+ TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+ almp = lsap->lsa_un.un_asla.asla_metric;
+ while ((u_char *)almp < ls_end) {
+ register u_int32_t ul;
+
+ TCHECK(almp->asla_tosmetric);
+ ul = ntohl(almp->asla_tosmetric);
+ printf(" type %d tos %d metric %d",
+ (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1,
+ (ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS,
+ (ul & ASLA_MASK_METRIC));
+ TCHECK(almp->asla_forward);
+ if (almp->asla_forward.s_addr) {
+ printf(" forward %s",
+ ipaddr_string(&almp->asla_forward));
+ }
+ TCHECK(almp->asla_tag);
+ if (almp->asla_tag.s_addr) {
+ printf(" tag %s",
+ ipaddr_string(&almp->asla_tag));
+ }
+ ++almp;
+ }
+ break;
+
+ case LS_TYPE_GROUP:
+ /* Multicast extensions as of 23 July 1991 */
+ mcp = lsap->lsa_un.un_mcla;
+ while ((u_char *)mcp < ls_end) {
+ TCHECK(mcp->mcla_vid);
+ switch (ntohl(mcp->mcla_vtype)) {
+
+ case MCLA_VERTEX_ROUTER:
+ printf(" rtr rtrid %s",
+ ipaddr_string(&mcp->mcla_vid));
+ break;
+
+ case MCLA_VERTEX_NETWORK:
+ printf(" net dr %s",
+ ipaddr_string(&mcp->mcla_vid));
+ break;
+
+ default:
+ printf(" ??VertexType %u??",
+ (u_int32_t)ntohl(mcp->mcla_vtype));
+ break;
+ }
+ ++mcp;
+ }
+#endif
+
+ case LS_TYPE_LINK:
+ /* Link LSA */
+ llsap = &lsap->lsa_un.un_llsa;
+ TCHECK(llsap->llsa_options);
+ ospf6_print_bits(ospf6_option_bits, ntohl(llsap->llsa_options));
+ TCHECK(llsap->llsa_nprefix);
+ printf(" pri %d lladdr %s npref %d", llsap->llsa_priority,
+ ip6addr_string(&llsap->llsa_lladdr),
+ (u_int32_t)ntohl(llsap->llsa_nprefix));
+ lsapp = llsap->llsa_prefix;
+ for (j = 0; j < ntohl(llsap->llsa_nprefix); j++) {
+ k = ospf6_print_lsaprefix(lsapp);
+ if (k < 0)
+ goto trunc;
+ lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
+ }
+ break;
+
+ case LS_TYPE_INTRA_AP | LS_SCOPE_AREA:
+ /* Intra-Area-Prefix LSA */
+ TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
+ ospf6_print_ls_type(
+ ntohs(lsap->lsa_un.un_intra_ap.intra_ap_lstype),
+ &lsap->lsa_un.un_intra_ap.intra_ap_lsid,
+ &lsap->lsa_un.un_intra_ap.intra_ap_rtid,
+ "LinkStateType %d");
+ TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
+ printf(" npref %d",
+ ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix));
+
+ lsapp = lsap->lsa_un.un_intra_ap.intra_ap_prefix;
+ for (j = 0;
+ j < ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
+ j++) {
+ k = ospf6_print_lsaprefix(lsapp);
+ if (k < 0)
+ goto trunc;
+ lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
+ }
+ break;
+
+ default:
+ printf(" ??LinkStateType 0x%04x??",
+ ntohs(lsap->ls_hdr.ls_type));
+ }
+
+ /* { (ctags) */
+ fputs(" }", stdout);
+ return (0);
+trunc:
+ fputs(" }", stdout);
+ return (1);
+}
+
+static int
+ospf6_decode_v3(register const struct ospf6hdr *op,
+ register const u_char *dataend)
+{
+ register const rtrid_t *ap;
+ register const struct lsr *lsrp;
+ register const struct lsa_hdr *lshp;
+ register const struct lsa *lsap;
+ register char sep;
+ register int i;
+
+ switch (op->ospf6_type) {
+
+ case OSPF_TYPE_UMD:
+ /*
+ * Rob Coltun's special monitoring packets;
+ * do nothing
+ */
+ break;
+
+ case OSPF_TYPE_HELLO:
+ if (vflag) {
+ TCHECK(op->ospf6_hello.hello_deadint);
+ ospf6_print_bits(ospf6_option_bits,
+ ntohl(op->ospf6_hello.hello_options));
+ printf(" ifid %s pri %d int %d dead %u",
+ ipaddr_string(&op->ospf6_hello.hello_ifid),
+ op->ospf6_hello.hello_priority,
+ ntohs(op->ospf6_hello.hello_helloint),
+ ntohs(op->ospf6_hello.hello_deadint));
+ }
+ TCHECK(op->ospf6_hello.hello_dr);
+ if (op->ospf6_hello.hello_dr != 0)
+ printf(" dr %s",
+ ipaddr_string(&op->ospf6_hello.hello_dr));
+ TCHECK(op->ospf6_hello.hello_bdr);
+ if (op->ospf6_hello.hello_bdr != 0)
+ printf(" bdr %s",
+ ipaddr_string(&op->ospf6_hello.hello_bdr));
+ if (vflag) {
+ printf(" nbrs");
+ ap = op->ospf6_hello.hello_neighbor;
+ while ((u_char *)ap < dataend) {
+ TCHECK(*ap);
+ printf(" %s", ipaddr_string(ap));
+ ++ap;
+ }
+ }
+ break; /* HELLO */
+
+ case OSPF_TYPE_DB:
+ TCHECK(op->ospf6_db.db_options);
+ ospf6_print_bits(ospf6_option_bits,
+ ntohl(op->ospf6_db.db_options));
+ sep = ' ';
+ TCHECK(op->ospf6_db.db_flags);
+ if (op->ospf6_db.db_flags & OSPF6_DB_INIT) {
+ printf("%cI", sep);
+ sep = '/';
+ }
+ if (op->ospf6_db.db_flags & OSPF6_DB_MORE) {
+ printf("%cM", sep);
+ sep = '/';
+ }
+ if (op->ospf6_db.db_flags & OSPF6_DB_MASTER) {
+ printf("%cMS", sep);
+ sep = '/';
+ }
+ TCHECK(op->ospf6_db.db_seq);
+ printf(" mtu %u S %X", ntohs(op->ospf6_db.db_mtu),
+ (u_int32_t)ntohl(op->ospf6_db.db_seq));
+
+ if (vflag) {
+ /* Print all the LS adv's */
+ lshp = op->ospf6_db.db_lshdr;
+
+ while (!ospf6_print_lshdr(lshp)) {
+ /* { (ctags) */
+ printf(" }");
+ ++lshp;
+ }
+ }
+ break;
+
+ case OSPF_TYPE_LSR:
+ if (vflag) {
+ lsrp = op->ospf6_lsr;
+ while ((u_char *)lsrp < dataend) {
+ TCHECK(*lsrp);
+ printf(" {"); /* } (ctags) */
+ ospf6_print_ls_type(ntohs(lsrp->ls_type),
+ &lsrp->ls_stateid,
+ &lsrp->ls_router,
+ "LinkStateType %d");
+ /* { (ctags) */
+ printf(" }");
+ ++lsrp;
+ }
+ }
+ break;
+
+ case OSPF_TYPE_LSU:
+ if (vflag) {
+ lsap = op->ospf6_lsu.lsu_lsa;
+ TCHECK(op->ospf6_lsu.lsu_count);
+ i = ntohl(op->ospf6_lsu.lsu_count);
+ while (i--) {
+ if (ospf6_print_lsa(lsap))
+ goto trunc;
+ lsap = (struct lsa *)((u_char *)lsap +
+ ntohs(lsap->ls_hdr.ls_length));
+ }
+ }
+ break;
+
+
+ case OSPF_TYPE_LSA:
+ if (vflag) {
+ lshp = op->ospf6_lsa.lsa_lshdr;
+
+ while (!ospf6_print_lshdr(lshp)) {
+ /* { (ctags) */
+ printf(" }");
+ ++lshp;
+ }
+ }
+ break;
+
+ default:
+ printf("v3 type %d", op->ospf6_type);
+ break;
+ }
+ return (0);
+trunc:
+ return (1);
+}
+
+void
+ospf6_print(register const u_char *bp, register u_int length)
+{
+ register const struct ospf6hdr *op;
+ register const u_char *dataend;
+ register const char *cp;
+
+ op = (struct ospf6hdr *)bp;
+
+ /* If the type is valid translate it, or just print the type */
+ /* value. If it's not valid, say so and return */
+ TCHECK(op->ospf6_type);
+ cp = tok2str(type2str, "type%d", op->ospf6_type);
+ printf(" OSPFv%d-%s %d:", op->ospf6_version, cp, length);
+ if (*cp == 't')
+ return;
+
+ TCHECK(op->ospf6_len);
+ if (length != ntohs(op->ospf6_len)) {
+ printf(" [len %d]", ntohs(op->ospf6_len));
+ return;
+ }
+ dataend = bp + length;
+
+ /* Print the routerid if it is not the same as the source */
+ TCHECK(op->ospf6_routerid);
+ printf(" rtrid %s", ipaddr_string(&op->ospf6_routerid));
+
+ TCHECK(op->ospf6_areaid);
+ if (op->ospf6_areaid != 0)
+ printf(" area %s", ipaddr_string(&op->ospf6_areaid));
+ else
+ printf(" backbone");
+ TCHECK(op->ospf6_instanceid);
+ if (op->ospf6_instanceid)
+ printf(" instance %u", op->ospf6_instanceid);
+
+ /* Do rest according to version. */
+ switch (op->ospf6_version) {
+
+ case 3:
+ /* ospf version 3 */
+ if (ospf6_decode_v3(op, dataend))
+ goto trunc;
+ break;
+
+ default:
+ printf(" ospf [version %d]", op->ospf6_version);
+ break;
+ } /* end switch on version */
+
+ return;
+trunc:
+ fputs(tstr, stdout);
+}
diff --git a/print-pim.c b/print-pim.c
index 529e1aaa..2eb795aa 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.8 1999-10-17 21:37:14 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.9 1999-10-30 05:11:19 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -31,9 +31,36 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
+/*
+ * XXX: We consider a case where IPv6 is not ready yet for portability,
+ * but PIM dependent defintions should be independent of IPv6...
+ */
+#ifdef INET6
+#include <netinet6/pim6.h>
+#else
+struct pim {
+#if 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),
+ * Graft-Ack (PIM-DM only), C-RP-Adv
+ */
+ pim_ver:4; /* PIM version number; 2 for PIMv2 */
+#else
+ u_char pim_ver:4, /* PIM version */
+ pim_type:4; /* PIM type */
+#endif
+ u_char pim_rsv; /* Reserved */
+ u_short pim_cksum; /* IP style check sum */
+};
+#endif
+
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -41,8 +68,10 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+static void pimv2_print(register const u_char *bp, register u_int len);
+
void
-pim_print(register const u_char *bp, register u_int len)
+igmp_pim_print(register const u_char *bp, register u_int len)
{
register const u_char *ep;
register u_char type;
@@ -95,3 +124,462 @@ pim_print(register const u_char *bp, register u_int len)
break;
}
}
+
+void
+pim_print(register const u_char *bp, register u_int len)
+{
+ register const u_char *ep;
+ register struct pim *pim = (struct pim *)bp;
+
+ ep = (const u_char *)snapend;
+ if (bp >= ep)
+ return;
+#ifdef notyet /* currently we see only version and type */
+ TCHECK(pim->pim_rsv);
+#endif
+
+ switch(pim->pim_ver) {
+ case 2: /* avoid hardcoding? */
+ (void)printf("v2");
+ pimv2_print(bp, len);
+ break;
+ default:
+ (void)printf("v%d", pim->pim_ver);
+ break;
+ }
+ return;
+}
+
+enum pimv2_addrtype {
+ pimv2_unicast, pimv2_group, pimv2_source
+};
+#if 0
+static char *addrtypestr[] = {
+ "unicast", "group", "source"
+};
+#endif
+
+static int
+pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
+{
+ const u_char *ep;
+ int af;
+ char *afstr;
+ int len;
+
+ ep = (const u_char *)snapend;
+ if (bp >= ep)
+ return -1;
+
+ switch (bp[0]) {
+ case 1:
+ af = AF_INET;
+ afstr = "IPv4";
+ break;
+#ifdef INET6
+ case 2:
+ af = AF_INET6;
+ afstr = "IPv6";
+ break;
+#endif
+ default:
+ return -1;
+ }
+
+ if (bp[1] != 0)
+ return -1;
+
+ switch (at) {
+ case pimv2_unicast:
+ if (af == AF_INET) {
+ len = 4;
+ if (bp + 2 + len > ep)
+ return -1;
+ if (!silent)
+ (void)printf("%s", ipaddr_string(bp + 2));
+ }
+#ifdef INET6
+ else if (af == AF_INET6) {
+ len = 16;
+ if (bp + 2 + len > ep)
+ return -1;
+ if (!silent)
+ (void)printf("%s", ip6addr_string(bp + 2));
+ }
+#endif
+ return 2 + len;
+ case pimv2_group:
+ if (af == AF_INET) {
+ len = 4;
+ if (bp + 4 + len > ep)
+ return -1;
+ if (!silent)
+ (void)printf("%s/%u", ipaddr_string(bp + 4), bp[3]);
+ }
+#ifdef INET6
+ else if (af == AF_INET6) {
+ len = 16;
+ if (bp + 4 + len > ep)
+ return -1;
+ if (!silent)
+ (void)printf("%s/%u", ip6addr_string(bp + 4), bp[3]);
+ }
+#endif
+ return 4 + len;
+ case pimv2_source:
+ if (af == AF_INET) {
+ len = 4;
+ if (bp + 4 + len > ep)
+ return -1;
+ if (!silent)
+ (void)printf("%s/%u", ipaddr_string(bp + 4), bp[3]);
+ }
+#ifdef INET6
+ else if (af == AF_INET6) {
+ len = 16;
+ if (bp + 4 + len > ep)
+ return -1;
+ if (!silent)
+ (void)printf("%s/%u", ip6addr_string(bp + 4), bp[3]);
+ }
+#endif
+ if (vflag && bp[2] && !silent) {
+ (void)printf("(%s%s%s)",
+ bp[2] & 0x04 ? "S" : "",
+ bp[2] & 0x02 ? "W" : "",
+ bp[2] & 0x01 ? "R" : "");
+ }
+ return 4 + len;
+ default:
+ return -1;
+ }
+}
+
+static void
+pimv2_print(register const u_char *bp, register u_int len)
+{
+ register const u_char *ep;
+ register struct pim *pim = (struct pim *)bp;
+ int advance;
+
+ ep = (const u_char *)snapend;
+ if (bp >= ep)
+ return;
+#ifdef notyet /* currently we see only version and type */
+ TCHECK(pim->pim_rsv);
+#endif
+
+ switch (pim->pim_type) {
+ case 0:
+ {
+ u_int16_t otype, olen;
+ (void)printf(" Hello");
+ bp += 4;
+ while (bp < ep) {
+ otype = ntohs(*(u_int16_t *)(bp + 0));
+ olen = ntohs(*(u_int16_t *)(bp + 2));
+ if (otype == 1 && olen == 2 && bp + 4 + olen <= ep) {
+ u_int16_t value;
+ (void)printf(" holdtime=");
+ value = ntohs(*(u_int16_t *)(bp + 4));
+ if (value == 0xffff)
+ (void)printf("infty");
+ else
+ (void)printf("%u", value);
+ bp += 4 + olen;
+ } else
+ break;
+ }
+ break;
+ }
+
+ case 1:
+ {
+ struct ip *ip;
+
+ (void)printf(" Register");
+ if (vflag && bp + 8 <= ep) {
+ (void)printf(" %s%s", bp[4] & 0x80 ? "B" : "",
+ bp[4] & 0x40 ? "N" : "");
+ }
+ bp += 8; len -= 8;
+
+ /* encapsulated multicast packet */
+ if (bp >= ep)
+ break;
+ ip = (struct ip *)bp;
+ switch(ip->ip_v) {
+ case 4: /* IPv4 */
+ printf(" ");
+ ip_print(bp, len);
+ break;
+#ifdef INET6
+ case 6: /* IPv6 */
+ printf(" ");
+ ip6_print(bp, len);
+ break;
+#endif
+ default:
+ (void)printf(" IP ver %d", ip->ip_v);
+ break;
+ }
+ break;
+ }
+
+ case 2:
+ (void)printf(" Register-Stop");
+ bp += 4; len -= 4;
+ if (bp >= ep)
+ break;
+ (void)printf(" group=");
+ if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
+ (void)printf("...");
+ break;
+ }
+ bp += advance; len -= advance;
+ if (bp >= ep)
+ break;
+ (void)printf(" source=");
+ if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
+ (void)printf("...");
+ break;
+ }
+ bp += advance; len -= advance;
+ break;
+
+ case 3:
+ case 6:
+ case 7:
+ {
+ u_int8_t ngroup;
+ u_int16_t holdtime;
+ u_int16_t njoin;
+ u_int16_t nprune;
+ int i, j;
+
+ switch (pim->pim_type) {
+ case 3:
+ (void)printf(" Join/Prune");
+ break;
+ case 6:
+ (void)printf(" Graft");
+ break;
+ case 7:
+ (void)printf(" Graft-ACK");
+ break;
+ }
+ bp += 4; len -= 4;
+ if (pim->pim_type != 7) { /*not for Graft-ACK*/
+ if (bp >= ep)
+ break;
+ (void)printf(" upstream-neighbor=");
+ if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
+ (void)printf("...");
+ break;
+ }
+ bp += advance; len -= advance;
+ }
+ if (bp + 4 > ep)
+ break;
+ ngroup = bp[1];
+ holdtime = ntohs(*(u_int16_t *)(bp + 2));
+ (void)printf(" groups=%u", ngroup);
+ if (pim->pim_type != 7) { /*not for Graft-ACK*/
+ (void)printf(" holdtime=");
+ if (holdtime == 0xffff)
+ (void)printf("infty");
+ else
+ (void)printf("%u", holdtime);
+ }
+ bp += 4; len -= 4;
+ for (i = 0; i < ngroup; i++) {
+ if (bp >= ep)
+ goto jp_done;
+ (void)printf(" (group%d: ", i);
+ if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
+ (void)printf("...)");
+ goto jp_done;
+ }
+ bp += advance; len -= advance;
+ if (bp + 4 > ep) {
+ (void)printf("...)");
+ goto jp_done;
+ }
+ njoin = ntohs(*(u_int16_t *)(bp + 0));
+ nprune = ntohs(*(u_int16_t *)(bp + 2));
+ (void)printf(" join=%u", njoin);
+ bp += 4; len -= 4;
+ for (j = 0; j < njoin; j++) {
+ (void)printf(" ");
+ if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
+ (void)printf("...)");
+ goto jp_done;
+ }
+ bp += advance; len -= advance;
+ }
+ (void)printf(" prune=%u", nprune);
+ for (j = 0; j < nprune; j++) {
+ (void)printf(" ");
+ if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
+ (void)printf("...)");
+ goto jp_done;
+ }
+ bp += advance; len -= advance;
+ }
+ (void)printf(")");
+ }
+ jp_done:
+ break;
+ }
+
+ case 4:
+ {
+ int i, j, frpcnt;
+
+ (void)printf(" Bootstrap");
+ bp += 4;
+
+ /* Fragment Tag, Hash Mask len, and BSR-priority */
+ if (bp + sizeof(u_int16_t) >= ep) break;
+ (void)printf(" tag=%x", ntohs(*(u_int16_t *)bp));
+ bp += sizeof(u_int16_t);
+ if (bp >= ep) break;
+ (void)printf(" hashmlen=%d", bp[0]);
+ if (bp + 1 >= ep) break;
+ (void)printf(" BSRprio=%d", bp[1]);
+ bp += 2;
+
+ /* Encoded-Unicast-BSR-Address */
+ if (bp >= ep) break;
+ (void)printf(" BSR=");
+ if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
+ (void)printf("...");
+ break;
+ }
+ bp += advance;
+
+ for (i = 0; bp < ep; i++) {
+ /* Encoded-Group Address */
+ (void)printf(" (group%d: ", i);
+ if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
+ < 0) {
+ (void)printf("...)");
+ goto bs_done;
+ }
+ bp += advance;
+
+ /* RP-Count, Frag RP-Cnt, and rsvd */
+ if (bp >= ep) {
+ (void)printf("...)");
+ goto bs_done;
+ }
+ (void)printf(" RPcnt=%d", frpcnt = bp[0]);
+ if (bp + 1 >= ep) {
+ (void)printf("...)");
+ goto bs_done;
+ }
+ (void)printf(" FRPcnt=%d", bp[1]);
+ bp += 4;
+
+ for (j = 0; j < frpcnt && bp < ep; j++) {
+ /* each RP info */
+ (void)printf(" RP%d=", j);
+ if ((advance = pimv2_addr_print(bp,
+ pimv2_unicast,
+ 0)) < 0) {
+ (void)printf("...)");
+ goto bs_done;
+ }
+ bp += advance;
+
+ if (bp + 2 >= ep) {
+ (void)printf("...)");
+ goto bs_done;
+ }
+ (void)printf(",holdtime=%d",
+ ntohs(*(u_int16_t *)bp));
+ if (bp + 3 >= ep) {
+ (void)printf("...)");
+ goto bs_done;
+ }
+ (void)printf(",prio=%d", bp[3]);
+ bp += 4;
+ }
+ (void)printf(")");
+ }
+ bs_done:
+ break;
+ }
+ case 5:
+ (void)printf(" Assert");
+ bp += 4; len -= 4;
+ if (bp >= ep)
+ break;
+ (void)printf(" group=");
+ if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
+ (void)printf("...");
+ break;
+ }
+ bp += advance; len -= advance;
+ if (bp >= ep)
+ break;
+ (void)printf(" src=");
+ if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
+ (void)printf("...");
+ break;
+ }
+ bp += advance; len -= advance;
+ if (bp + 8 > ep)
+ break;
+ if (ntohl(*(u_int32_t *)bp) & 0x80000000)
+ (void)printf(" RPT");
+ (void)printf(" pref=%u", ntohl(*(u_int32_t *)bp & 0x7fffffff));
+ (void)printf(" metric=%u", ntohl(*(u_int32_t *)(bp + 4)));
+ break;
+
+ case 8:
+ {
+ int i, pfxcnt;
+
+ (void)printf(" Candidate-RP-Advertisement");
+ bp += 4;
+
+ /* Prefix-Cnt, Priority, and Holdtime */
+ if (bp >= ep) break;
+ (void)printf(" prefix-cnt=%d", bp[0]);
+ pfxcnt = bp[0];
+ if (bp + 1 >= ep) break;
+ (void)printf(" prio=%d", bp[1]);
+ if (bp + 3 >= ep) break;
+ (void)printf(" holdtime=%d", ntohs(*(u_int16_t *)(bp + 2)));
+ bp += 4;
+
+ /* Encoded-Unicast-RP-Address */
+ if (bp >= ep) break;
+ (void)printf(" RP=");
+ if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
+ (void)printf("...");
+ break;
+ }
+ bp += advance;
+
+ /* Encoded-Group Addresses */
+ for (i = 0; i < pfxcnt && bp < ep; i++) {
+ (void)printf(" Group%d=", i);
+ if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
+ < 0) {
+ (void)printf("...");
+ break;
+ }
+ bp += advance;
+ }
+ break;
+ }
+
+ default:
+ (void)printf(" [type %d]", pim->pim_type);
+ break;
+ }
+
+ return;
+}
diff --git a/print-ppp.c b/print-ppp.c
index 4a84fc95..89ab24dc 100644
--- a/print-ppp.c
+++ b/print-ppp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.26 1999-10-07 23:47:12 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.27 1999-10-30 05:11:19 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -39,11 +39,16 @@ struct rtentry;
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/if_ether.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <stdio.h>
+#ifdef __bsdi__
+#include <net/slcompress.h>
+#include <net/if_ppp.h>
+#endif
#include "interface.h"
#include "addrtoname.h"
@@ -52,6 +57,390 @@ struct rtentry;
/* XXX This goes somewhere else. */
#define PPP_HDRLEN 4
+/* LCP */
+
+#define LCP_CONF_REQ 1
+#define LCP_CONF_ACK 2
+#define LCP_CONF_NAK 3
+#define LCP_CONF_REJ 4
+#define LCP_TERM_REQ 5
+#define LCP_TERM_ACK 6
+#define LCP_CODE_REJ 7
+#define LCP_PROT_REJ 8
+#define LCP_ECHO_REQ 9
+#define LCP_ECHO_RPL 10
+#define LCP_DISC_REQ 11
+
+#define LCP_MIN LCP_CONF_REQ
+#define LCP_MAX LCP_DISC_REQ
+
+static char *lcpcodes[] = {
+ /*
+ * LCP code values (RFC1661, pp26)
+ */
+ "Configure-Request",
+ "Configure-Ack",
+ "Configure-Nak",
+ "Configure-Reject",
+ "Terminate-Request",
+ "Terminate-Ack",
+ "Code-Reject",
+ "Protocol-Reject",
+ "Echo-Request",
+ "Echo-Reply",
+ "Discard-Request",
+};
+
+#define LCPOPT_VEXT 0
+#define LCPOPT_MRU 1
+#define LCPOPT_ACCM 2
+#define LCPOPT_AP 3
+#define LCPOPT_QP 4
+#define LCPOPT_MN 5
+#define LCPOPT_PFC 7
+#define LCPOPT_ACFC 8
+
+#define LCPOPT_MIN 0
+#define LCPOPT_MAX 24
+
+static char *lcpconfopts[] = {
+ "Vendor-Ext",
+ "Max-Rx-Unit",
+ "Async-Ctrl-Char-Map",
+ "Auth-Prot",
+ "Quality-Prot",
+ "Magic-Number",
+ "unassigned (6)",
+ "Prot-Field-Compr",
+ "Add-Ctrl-Field-Compr",
+ "FCS-Alternatives",
+ "Self-Describing-Pad",
+ "Numbered-Mode",
+ "Multi-Link-Procedure",
+ "Call-Back",
+ "Connect-Time"
+ "Compund-Frames",
+ "Nominal-Data-Encap",
+ "Multilink-MRRU",
+ "Multilink-SSNHF",
+ "Multilink-ED",
+ "Proprietary",
+ "DCE-Identifier",
+ "Multilink-Plus-Proc",
+ "Link-Discriminator",
+ "LCP-Auth-Option",
+};
+
+/* CHAP */
+
+#define CHAP_CHAL 1
+#define CHAP_RESP 2
+#define CHAP_SUCC 3
+#define CHAP_FAIL 4
+
+#define CHAP_CODEMIN 1
+#define CHAP_CODEMAX 4
+
+static char *chapcode[] = {
+ "Challenge",
+ "Response",
+ "Success",
+ "Failure",
+};
+
+/* PAP */
+
+#define PAP_AREQ 1
+#define PAP_AACK 2
+#define PAP_ANAK 3
+
+#define PAP_CODEMIN 1
+#define PAP_CODEMAX 3
+
+static char *papcode[] = {
+ "Authenticate-Request",
+ "Authenticate-Ack",
+ "Authenticate-Nak",
+};
+
+/* IPCP */
+
+#define IPCP_2ADDR 1
+#define IPCP_CP 2
+#define IPCP_ADDR 3
+
+static const char *ppp_protoname __P((int proto));
+static void handle_lcp __P((const u_char *p, int length));
+static int print_lcp_config_options __P((const u_char *p));
+static void handle_chap __P((const u_char *p, int length));
+static void handle_ipcp __P((const u_char *p, int length));
+static void handle_pap __P((const u_char *p, int length));
+
+static const char *
+ppp_protoname(int proto)
+{
+ static char buf[20];
+
+ switch (proto) {
+ case PPP_IP: return "IP";
+#ifdef PPP_XNS
+ case PPP_XNS: return "XNS";
+#endif
+#ifdef PPP_IPX
+ case PPP_IPX: return "IPX";
+#endif
+#ifdef PPP_COMP
+ case PPP_COMP: return "COMP";
+#endif
+#ifdef PPP_IPCP
+ case PPP_IPCP: return "IPCP";
+#endif
+#ifdef PPP_IPV6CP
+ case PPP_IPV6CP: return "IPV6CP";
+#endif
+#ifdef PPP_IPXCP
+ case PPP_IPXCP: return "IPXCP";
+#endif
+#ifdef PPP_CCP
+ case PPP_CCP: return "CCP";
+#endif
+#ifdef PPP_LCP
+ case PPP_LCP: return "LCP";
+#endif
+#ifdef PPP_PAP
+ case PPP_PAP: return "PAP";
+#endif
+#ifdef PPP_LQR
+ case PPP_LQR: return "LQR";
+#endif
+#ifdef PPP_CHAP
+ case PPP_CHAP: return "CHAP";
+#endif
+ default:
+ snprintf(buf, sizeof(buf), "unknown-0x%04x\n", proto);
+ return buf;
+ }
+}
+
+/* print LCP frame */
+static void
+handle_lcp(const u_char *p, int length)
+{
+ int x, j;
+ const u_char *ptr;
+
+ x = p[4];
+
+ if ((x >= LCP_MIN) && (x <= LCP_MAX))
+ printf("%s", lcpcodes[x - 1]);
+ else {
+ printf("0x%02x", x);
+ return;
+ }
+
+ length -= 4;
+
+ switch (x) {
+ case LCP_CONF_REQ:
+ case LCP_CONF_ACK:
+ case LCP_CONF_NAK:
+ case LCP_CONF_REJ:
+ x = length;
+ ptr = p + 8;
+ do {
+ if ((j = print_lcp_config_options(ptr)) == 0)
+ break;
+ x -= j;
+ ptr += j;
+ } while (x > 0);
+ break;
+
+ case LCP_ECHO_REQ:
+ case LCP_ECHO_RPL:
+ printf(", Magic-Number=%u",
+ (u_int32_t)ntohl(*(u_int32_t *)(p + 8)));
+ break;
+ case LCP_TERM_REQ:
+ case LCP_TERM_ACK:
+ case LCP_CODE_REJ:
+ case LCP_PROT_REJ:
+ case LCP_DISC_REQ:
+ default:
+ break;
+ }
+}
+
+/* LCP config options */
+static int
+print_lcp_config_options(const u_char *p)
+{
+ int len = p[1];
+ int opt = p[0];
+
+ if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
+ printf(", %s", lcpconfopts[opt]);
+
+ switch (opt) {
+ case LCPOPT_MRU:
+ if (len == 4)
+ printf("=%d", (*(p+2) << 8) + *(p+3));
+ break;
+ case LCPOPT_AP:
+ if (len >= 4) {
+ if (p[2] == 0xc0 && p[3] == 0x23)
+ printf(" PAP");
+ else if (p[2] == 0xc2 && p[3] == 0x23) {
+ printf(" CHAP/");
+ switch (p[4]) {
+ default:
+ printf("unknown-algorithm-%u", p[4]);
+ break;
+ case 5:
+ printf("MD5");
+ break;
+ case 0x80:
+ printf("Microsoft");
+ break;
+ }
+ }
+ else if (p[2] == 0xc2 && p[3] == 0x27)
+ printf(" EAP");
+ else if (p[2] == 0xc0 && p[3] == 0x27)
+ printf(" SPAP");
+ else if (p[2] == 0xc1 && p[3] == 0x23)
+ printf(" Old-SPAP");
+ else
+ printf("unknown");
+ }
+ break;
+ case LCPOPT_QP:
+ if (len >= 4) {
+ if (p[2] == 0xc0 && p[3] == 0x25)
+ printf(" LQR");
+ else
+ printf(" unknown");
+ }
+ break;
+ case LCPOPT_MN:
+ if (len == 6)
+ printf("=%u", (u_int32_t)ntohl(*(u_int32_t *)(p + 2)));
+ break;
+ case LCPOPT_PFC:
+ printf(" PFC");
+ break;
+ case LCPOPT_ACFC:
+ printf(" ACFC");
+ break;
+ }
+ return len;
+}
+
+/* CHAP */
+static void
+handle_chap(const u_char *p, int length)
+{
+ int x;
+ const u_char *ptr;
+
+ if ((x >= CHAP_CODEMIN) && (x <= CHAP_CODEMAX))
+ printf("%s", chapcode[x - 1]);
+ else {
+ printf("0x%02x", x);
+ return;
+ }
+
+ length -= 4;
+
+ switch (p[4]) {
+ case CHAP_CHAL:
+ case CHAP_RESP:
+ printf(", Value=");
+ x = p[8]; /* value size */
+ ptr = p + 9;
+ while (--x >= 0)
+ printf("%02x", *ptr++);
+ x = length - p[8] - 1;
+ printf(", Name=");
+ while (--x >= 0) {
+ if (isprint(*ptr))
+ printf("%c", *ptr);
+ else
+ printf("\%03o", *ptr);
+ ptr++;
+ }
+ break;
+ }
+}
+
+/* PAP */
+static void
+handle_pap(const u_char *p, int length)
+{
+ int x;
+ const u_char *ptr;
+
+ x = p[4];
+
+ if ((x >= PAP_CODEMIN) && (x <= PAP_CODEMAX))
+ printf("%s", papcode[x - 1]);
+ else {
+ printf("0x%02x", x);
+ return;
+ }
+
+ length -= 4;
+
+ switch (x) {
+ case PAP_AREQ:
+ printf(", Peer-Id=");
+ x = p[8]; /* peerid size */
+ ptr = p + 9;
+ while (--x >= 0) {
+ if (isprint(*ptr))
+ printf("%c", *ptr);
+ else
+ printf("\%03o", *ptr);
+ ptr++;
+ }
+ x = *ptr++;
+ printf(", Passwd=");
+ while (--x >= 0) {
+ if (isprint(*ptr))
+ printf("%c", *ptr);
+ else
+ printf("\%03o", *ptr);
+ ptr++;
+ }
+ break;
+ case PAP_AACK:
+ case PAP_ANAK:
+ break;
+ }
+}
+
+/* IPCP */
+static void
+handle_ipcp(const u_char *p, int length)
+{
+ length -= 4;
+
+ switch (p[8]) {
+ case IPCP_2ADDR:
+ printf("IP-Addresses");
+ printf(", src=%s", ipaddr_string(p + 10));
+ printf(", drc=%s", ipaddr_string(p + 14));
+ break;
+
+ case IPCP_CP:
+ printf("IP-Compression-Protocol");
+ break;
+
+ case IPCP_ADDR:
+ printf("IP-Address=%s", ipaddr_string(p + 10));
+ break;
+ }
+}
+
/* Standard PPP printer */
void
ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
@@ -60,6 +449,7 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
register u_int length = h->len;
register u_int caplen = h->caplen;
const struct ip *ip;
+ u_int proto;
ts_print(&h->ts);
@@ -73,23 +463,49 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
* and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
+ proto = ntohs(*(u_short *)&p[2]);
packetp = p;
snapend = p + caplen;
if (eflag)
- printf("%c %4d %02x %04x: ", p[0] ? 'O' : 'I', length,
- p[1], ntohs(*(u_short *)&p[2]));
+ printf("%c %4d %02x %s: ", p[0] ? 'O' : 'I', length,
+ p[1], ppp_protoname(proto));
length -= PPP_HDRLEN;
ip = (struct ip *)(p + PPP_HDRLEN);
- ip_print((const u_char *)ip, length);
-
+ switch (proto) {
+ case PPP_LCP:
+ handle_lcp(p, length);
+ break;
+ case PPP_CHAP:
+ handle_chap(p, length);
+ break;
+ case PPP_PAP:
+ handle_pap(p, length);
+ break;
+ case PPP_IPCP:
+ handle_ipcp(p, length);
+ break;
+ case ETHERTYPE_IP: /*XXX*/
+ case PPP_IP:
+ ip_print((const u_char *)ip, length);
+ break;
+#ifdef INET6
+ case ETHERTYPE_IPV6: /*XXX*/
+#ifdef PPP_IPV6
+ case PPP_IPV6:
+#endif
+ ip6_print((const u_char *)ip, length);
+ break;
+#endif
+ }
if (xflag)
default_print((const u_char *)ip, caplen - PPP_HDRLEN);
out:
putchar('\n');
}
+#ifdef __bsdi__
/* proto type to string mapping */
static struct tok ptype2str[] = {
{ PPP_VJC, "VJC" },
@@ -99,6 +515,7 @@ static struct tok ptype2str[] = {
{ PPP_IPCP, "IPCP" },
{ 0, NULL }
};
+#endif
#define PPP_BSDI_HDRLEN 24
@@ -107,10 +524,13 @@ void
ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
register const u_char *p)
{
+#ifdef __bsdi__
register u_int length = h->len;
register u_int caplen = h->caplen;
register int hdrlength;
u_short ptype;
+ const u_char *q;
+ int i;
ts_print(&h->ts);
@@ -128,6 +548,7 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
snapend = p + caplen;
hdrlength = 0;
+#if 0
if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
if (eflag)
printf("%02x %02x ", p[0], p[1]);
@@ -153,16 +574,80 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
p += 2;
hdrlength += 2;
}
-
+#else
+ ptype = 0; /*XXX*/
+ if (eflag)
+ printf("%c ", p[SLC_DIR] ? 'O' : 'I');
+ if (p[SLC_LLHL]) {
+ /* link level header */
+ struct ppp_header *ph;
+
+ q = p + SLC_BPFHDRLEN;
+ ph = (struct ppp_header *)q;
+ if (ph->phdr_addr == PPP_ADDRESS
+ && ph->phdr_ctl == PPP_CONTROL) {
+ if (eflag)
+ printf("%02x %02x ", q[0], q[1]);
+ ptype = ntohs(ph->phdr_type);
+ if (eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
+ printf("%s ", tok2str(ptype2str,
+ "proto-#%d", ptype));
+ }
+ } else {
+ if (eflag) {
+ printf("LLH=[");
+ for (i = 0; i < p[SLC_LLHL]; i++)
+ printf("%02x", q[i]);
+ printf("] ");
+ }
+ }
+ if (eflag)
+ printf("%d ", length);
+ }
+ if (p[SLC_CHL]) {
+ q = p + SLC_BPFHDRLEN + p[SLC_LLHL];
+
+ switch (ptype) {
+ case PPP_VJC:
+ ptype = vjc_print(q, length - (q - p), ptype);
+ hdrlength = PPP_BSDI_HDRLEN;
+ p += hdrlength;
+ if (ptype == PPP_IP)
+ ip_print(p, length);
+ goto printx;
+ case PPP_VJNC:
+ ptype = vjc_print(q, length - (q - p), ptype);
+ hdrlength = PPP_BSDI_HDRLEN;
+ p += hdrlength;
+ if (ptype == PPP_IP)
+ ip_print(p, length);
+ goto printx;
+ default:
+ if (eflag) {
+ printf("CH=[");
+ for (i = 0; i < p[SLC_LLHL]; i++)
+ printf("%02x", q[i]);
+ printf("] ");
+ }
+ break;
+ }
+ }
+
+ hdrlength = PPP_BSDI_HDRLEN;
+#endif
+
length -= hdrlength;
+ p += hdrlength;
if (ptype == PPP_IP)
ip_print(p, length);
else
printf("%s ", tok2str(ptype2str, "proto-#%d", ptype));
+printx:
if (xflag)
default_print((const u_char *)p, caplen - hdrlength);
out:
putchar('\n');
+#endif /* __bsdi__ */
}
diff --git a/print-raw.c b/print-raw.c
index 932252ba..91dc575b 100644
--- a/print-raw.c
+++ b/print-raw.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.23 1999-10-17 21:37:15 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.24 1999-10-30 05:11:20 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -40,7 +40,9 @@ struct rtentry;
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/if_ether.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <pcap.h>
diff --git a/print-rip.c b/print-rip.c
index 7fcc5aa0..be601712 100644
--- a/print-rip.c
+++ b/print-rip.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.37 1999-10-17 21:37:15 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.38 1999-10-30 05:11:20 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -31,7 +31,9 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#include <stdio.h>
diff --git a/print-ripng.c b/print-ripng.c
new file mode 100644
index 00000000..69864b3a
--- /dev/null
+++ b/print-ripng.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 1989, 1990, 1991, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) /master/usr.sbin/tcpdump/tcpdump/print-rip.c,v 2.1 1995/02/03 18:15:05 polk Exp (LBL)";
+#endif
+
+#ifdef INET6
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#include <errno.h>
+#include <stdio.h>
+
+#include <netinet/ip6.h>
+
+#include "route6d.h"
+#include "interface.h"
+#include "addrtoname.h"
+
+static int
+rip6_entry_print(register const struct netinfo6 *ni, int metric)
+{
+ int l;
+ l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen);
+ if (ni->rip6_tag)
+ l += printf(" [%d]", ntohs(ni->rip6_tag));
+ if (metric)
+ l += printf(" (%d)", ni->rip6_metric);
+ return l;
+}
+
+void
+ripng_print(const u_char *dat, int length)
+{
+ register const struct rip6 *rp = (struct rip6 *)dat;
+ register const struct netinfo6 *ni;
+ register int amt = snapend - dat;
+ register int i = min(length, amt) -
+ (sizeof(struct rip6) - sizeof(struct netinfo6));
+ int j;
+ int trunc;
+
+ if (i < 0)
+ return;
+
+ switch (rp->rip6_cmd) {
+
+ case RIP6_REQUEST:
+ j = length / sizeof(*ni);
+ if (j == 1
+ && rp->rip6_nets->rip6_metric == HOPCNT_INFINITY6
+ && IN6_IS_ADDR_UNSPECIFIED(&rp->rip6_nets->rip6_dest)) {
+ printf(" ripng-req dump");
+ break;
+ }
+ if (j * sizeof(*ni) != length - 4)
+ printf(" ripng-req %d[%d]:", j, length);
+ else
+ printf(" ripng-req %d:", j);
+ trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
+ for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
+ if (vflag)
+ printf("\n\t");
+ else
+ printf(" ");
+ rip6_entry_print(ni, 0);
+ }
+ break;
+ case RIP6_RESPONSE:
+ j = length / sizeof(*ni);
+ if (j * sizeof(*ni) != length - 4)
+ printf(" ripng-resp %d[%d]:", j, length);
+ else
+ printf(" ripng-resp %d:", j);
+ trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
+ for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
+ if (vflag)
+ printf("\n\t");
+ else
+ printf(" ");
+ rip6_entry_print(ni, ni->rip6_metric);
+ }
+ if (trunc)
+ printf("[|rip]");
+ break;
+ default:
+ printf(" ripng-%d ?? %d", rp->rip6_cmd, length);
+ break;
+ }
+ if (rp->rip6_vers != RIP6_VERSION)
+ printf(" [vers %d]", rp->rip6_vers);
+}
+#endif /* INET6 */
diff --git a/print-rt6.c b/print-rt6.c
new file mode 100644
index 00000000..39c09b3d
--- /dev/null
+++ b/print-rt6.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) /master/usr.sbin/tcpdump/tcpdump/print-icmp.c,v 2.1 1995/02/03 18:14:42 polk Exp (LBL)";
+#endif
+
+#ifdef INET6
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+
+#include <stdio.h>
+
+#include <netinet/ip6.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+int
+rt6_print(register const u_char *bp, register const u_char *bp2)
+{
+ register const struct ip6_rthdr0 *dp;
+ register const struct ip6_hdr *ip;
+ register const u_char *ep;
+ u_long bitmap = 0x0800;
+ u_long slmap;
+ int i, len;
+
+#if 0
+#define TCHECK(var) if ((u_char *)&(var) >= ep - sizeof(var)) goto trunc
+#endif
+
+ dp = (struct ip6_rthdr0 *)bp;
+ ip = (struct ip6_hdr *)bp2;
+ len = dp->ip6r0_len;
+
+ /* 'ep' points to the end of avaible data. */
+ ep = snapend;
+
+ printf("%s > %s: ",
+ ip6addr_string(&ip->ip6_src),
+ ip6addr_string(&ip->ip6_dst));
+
+ TCHECK(dp->ip6r0_slmap[2]);
+ printf("srcrt (len=%d, ", dp->ip6r0_len);
+ printf("type=%d, ", dp->ip6r0_type);
+ printf("segleft=%d, ", dp->ip6r0_segleft);
+ if (dp->ip6r0_type != 0)
+ goto trunc;
+ slmap = (dp->ip6r0_slmap[0] << 16)
+ | (dp->ip6r0_slmap[1] << 8)
+ | (dp->ip6r0_slmap[2]);
+ printf("bitmap=");
+ for (i = 24; i > 0; i--) {
+ if (slmap & bitmap)
+ printf("S");
+ else
+ printf("L");
+ bitmap >>= 1;
+ }
+ if (len % 2 == 1)
+ goto trunc;
+ len >>= 1;
+ printf(", ");
+ for (i = 0; i < len; i++) {
+ if ((((u_char *)&(dp->ip6r0_reserved)) + sizeof(u_long)
+ + (i<<4)) > ep) goto trunc;
+ printf(" [%d]%s", i,
+ ip6addr_string(((u_char *)&(dp->ip6r0_reserved)) +
+ sizeof(u_long) + (i<<4)));
+ if (i != len - 1)
+ printf(", ");
+
+ }
+ printf(")");
+ return((dp->ip6r0_len + 1) << 3);
+ trunc:
+ fputs("[|srcrt]", stdout);
+ return 65535;
+#undef TCHECK
+}
+#endif /* INET6 */
diff --git a/print-sunrpc.c b/print-sunrpc.c
index 30f7d2a4..adb1fa6d 100644
--- a/print-sunrpc.c
+++ b/print-sunrpc.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.27 1999-10-17 21:37:16 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.28 1999-10-30 05:11:21 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -38,6 +38,7 @@ struct rtentry;
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <rpc/rpc.h>
#ifdef HAVE_RPC_RPCENT_H
diff --git a/print-tcp.c b/print-tcp.c
index ffce8b95..80335c1d 100644
--- a/print-tcp.c
+++ b/print-tcp.c
@@ -21,17 +21,16 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.56 1999-10-17 21:37:16 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.57 1999-10-30 05:11:21 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
#include <sys/time.h>
-#define __FAVOR_BSD
-
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#ifdef HAVE_MEMORY_H
@@ -42,6 +41,10 @@ static const char rcsid[] =
#include <string.h>
#include <unistd.h>
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
+
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
@@ -76,8 +79,13 @@ static const char rcsid[] =
#endif
struct tha {
+#ifndef INET6
struct in_addr src;
struct in_addr dst;
+#else
+ struct in6_addr src;
+ struct in6_addr dst;
+#endif /*INET6*/
u_int port;
};
@@ -107,9 +115,18 @@ tcp_print(register const u_char *bp, register u_int length,
register char ch;
u_short sport, dport, win, urp;
u_int32_t seq, ack;
+#ifdef INET6
+ register const struct ip6_hdr *ip6;
+#endif
tp = (struct tcphdr *)bp;
ip = (struct ip *)bp2;
+#ifdef INET6
+ if (ip->ip_v == 6)
+ ip6 = (struct ip6_hdr *)bp2;
+ else
+ ip6 = NULL;
+#endif /*INET6*/
ch = '\0';
TCHECK(*tp);
if (length < sizeof(*tp)) {
@@ -124,15 +141,42 @@ tcp_print(register const u_char *bp, register u_int length,
win = ntohs(tp->th_win);
urp = ntohs(tp->th_urp);
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src), tcpport_string(sport),
- ipaddr_string(&ip->ip_dst), tcpport_string(dport));
+#ifdef INET6
+ if (ip6) {
+ if (ip6->ip6_nxt == IPPROTO_TCP) {
+ (void)printf("%s.%s > %s.%s: ",
+ ip6addr_string(&ip6->ip6_src),
+ tcpport_string(sport),
+ ip6addr_string(&ip6->ip6_dst),
+ tcpport_string(dport));
+ } else {
+ (void)printf("%s > %s: ",
+ tcpport_string(sport), tcpport_string(dport));
+ }
+ } else
+#endif /*INET6*/
+ {
+ if (ip->ip_p == IPPROTO_TCP) {
+ (void)printf("%s.%s > %s.%s: ",
+ ipaddr_string(&ip->ip_src),
+ tcpport_string(sport),
+ ipaddr_string(&ip->ip_dst),
+ tcpport_string(dport));
+ } else {
+ (void)printf("%s > %s: ",
+ tcpport_string(sport), tcpport_string(dport));
+ }
+ }
if (qflag) {
(void)printf("tcp %d", length - tp->th_off * 4);
return;
}
+#ifdef TH_ECN
+ if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH|TH_ECN)) {
+#else
if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH)) {
+#endif
if (flags & TH_SYN)
putchar('S');
if (flags & TH_FIN)
@@ -141,6 +185,10 @@ tcp_print(register const u_char *bp, register u_int length,
putchar('R');
if (flags & TH_PUSH)
putchar('P');
+#ifdef TH_ECN
+ if (flags & TH_ECN)
+ putchar('C');
+#endif
} else
putchar('.');
@@ -154,6 +202,49 @@ tcp_print(register const u_char *bp, register u_int length,
* collating order so there's only one entry for
* both directions).
*/
+#ifdef INET6
+ bzero(&tha, sizeof(tha));
+ rev = 0;
+ if (ip6) {
+ if (sport > dport) {
+ rev = 1;
+ } else if (sport == dport) {
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (((u_int32_t *)(&ip6->ip6_src))[i] >
+ ((u_int32_t *)(&ip6->ip6_dst))[i]) {
+ rev = 1;
+ break;
+ }
+ }
+ }
+ if (rev) {
+ tha.src = ip6->ip6_dst;
+ tha.dst = ip6->ip6_src;
+ tha.port = dport << 16 | sport;
+ } else {
+ tha.dst = ip6->ip6_dst;
+ tha.src = ip6->ip6_src;
+ tha.port = sport << 16 | dport;
+ }
+ } else {
+ if (sport > dport ||
+ (sport == dport &&
+ ip->ip_src.s_addr > ip->ip_dst.s_addr)) {
+ rev = 1;
+ }
+ if (rev) {
+ *(struct in_addr *)&tha.src = ip->ip_dst;
+ *(struct in_addr *)&tha.dst = ip->ip_src;
+ tha.port = dport << 16 | sport;
+ } else {
+ *(struct in_addr *)&tha.dst = ip->ip_dst;
+ *(struct in_addr *)&tha.src = ip->ip_src;
+ tha.port = sport << 16 | dport;
+ }
+ }
+#else
if (sport < dport ||
(sport == dport &&
ip->ip_src.s_addr < ip->ip_dst.s_addr)) {
@@ -165,6 +256,7 @@ tcp_print(register const u_char *bp, register u_int length,
tha.port = dport << 16 | sport;
rev = 1;
}
+#endif
for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE];
th->nxt; th = th->nxt)
@@ -349,6 +441,16 @@ tcp_print(register const u_char *bp, register u_int length,
}
putchar('>');
}
+
+ if (length <= 0)
+ return;
+
+ /*
+ * Decode payload if necessary.
+ */
+ bp += (tp->th_off * 4);
+ if (sport == 179 || dport == 179)
+ bgp_print(bp, length);
return;
bad:
fputs("[bad opt]", stdout);
diff --git a/print-udp.c b/print-udp.c
index 869f54e9..a7af8eba 100644
--- a/print-udp.c
+++ b/print-udp.c
@@ -21,19 +21,19 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.62 1999-10-17 21:56:54 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.63 1999-10-30 05:11:21 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
-#define __FAVOR_BSD
-
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <netinet/udp.h>
+#include <netinet/udp_var.h>
#ifdef NOERROR
#undef NOERROR /* Solaris sucks */
@@ -51,6 +51,10 @@ static const char rcsid[] =
#include <stdio.h>
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
+
#include "interface.h"
#include "addrtoname.h"
#include "appletalk.h"
@@ -291,12 +295,18 @@ rtcp_print(const u_char *hdr, const u_char *ep)
#define SNMP_PORT 161 /*XXX*/
#define NTP_PORT 123 /*XXX*/
#define SNMPTRAP_PORT 162 /*XXX*/
+#define ISAKMP_PORT 500 /*XXX*/
#define RIP_PORT 520 /*XXX*/
#define KERBEROS_SEC_PORT 750 /*XXX*/
-
-#define ISAKMP_PORT 500
-#define ISAKMP_UPORT1 7500
-#define ISAKMP_UPORT2 8500
+#define L2TP_PORT 1701 /*XXX*/
+#define ISAKMP_PORT_USER1 7500 /*??? - nonstandard*/
+#define ISAKMP_PORT_USER2 8500 /*??? - nonstandard*/
+
+#ifdef INET6
+#define RIPNG_PORT 521 /*XXX*/
+#define DHCP6_SERV_PORT 546 /*XXX*/
+#define DHCP6_CLI_PORT 547 /*XXX*/
+#endif
void
udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
@@ -306,11 +316,20 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
register const u_char *cp;
register const u_char *ep = bp + length;
u_short sport, dport, ulen;
+#ifdef INET6
+ register const struct ip6_hdr *ip6;
+#endif
if (ep > snapend)
ep = snapend;
up = (struct udphdr *)bp;
ip = (struct ip *)bp2;
+#ifdef INET6
+ if (ip->ip_v == 6)
+ ip6 = (struct ip6_hdr *)bp2;
+ else
+ ip6 = NULL;
+#endif /*INET6*/
cp = (u_char *)(up + 1);
if (cp > snapend) {
printf("[|udp]");
@@ -381,10 +400,10 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
case PT_SNMP:
(void)printf("%s.%s > %s.%s:",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
+ ipaddr_string(&ip->ip_src),
+ udpport_string(sport),
+ ipaddr_string(&ip->ip_dst),
+ udpport_string(dport));
snmp_print((const u_char *)(up + 1), length);
break;
}
@@ -424,9 +443,38 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
return;
}
}
+#if 0
(void)printf("%s.%s > %s.%s:",
ipaddr_string(&ip->ip_src), udpport_string(sport),
ipaddr_string(&ip->ip_dst), udpport_string(dport));
+#else
+#ifdef INET6
+ if (ip6) {
+ if (ip6->ip6_nxt == IPPROTO_UDP) {
+ (void)printf("%s.%s > %s.%s: ",
+ ip6addr_string(&ip6->ip6_src),
+ udpport_string(sport),
+ ip6addr_string(&ip6->ip6_dst),
+ udpport_string(dport));
+ } else {
+ (void)printf("%s > %s: ",
+ udpport_string(sport), udpport_string(dport));
+ }
+ } else
+#endif /*INET6*/
+ {
+ if (ip->ip_p == IPPROTO_UDP) {
+ (void)printf("%s.%s > %s.%s: ",
+ ipaddr_string(&ip->ip_src),
+ udpport_string(sport),
+ ipaddr_string(&ip->ip_dst),
+ udpport_string(dport));
+ } else {
+ (void)printf("%s > %s: ",
+ udpport_string(sport), udpport_string(dport));
+ }
+ }
+#endif
if (!qflag) {
#define ISPORT(p) (dport == (p) || sport == (p))
@@ -439,19 +487,30 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
sport, dport);
else if (ISPORT(RIP_PORT))
rip_print((const u_char *)(up + 1), length);
+ else if (ISPORT(ISAKMP_PORT))
+ isakmp_print((const u_char *)(up + 1), length, bp2);
+#if 1 /*???*/
+ else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
+ isakmp_print((const u_char *)(up + 1), length, bp2);
+#endif
else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
snmp_print((const u_char *)(up + 1), length);
else if (ISPORT(NTP_PORT))
ntp_print((const u_char *)(up + 1), length);
else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
krb_print((const void *)(up + 1), length);
- else if (ISPORT(ISAKMP_PORT) ||
- ISPORT(ISAKMP_UPORT1) ||
- ISPORT(ISAKMP_UPORT2)) {
- isakmp_print((const u_char *)(up + 1), length);
- }
+ else if (ISPORT(L2TP_PORT))
+ l2tp_print((const u_char *)(up + 1), length);
else if (dport == 3456)
vat_print((const void *)(up + 1), length, up);
+#ifdef INET6
+ else if (ISPORT(RIPNG_PORT))
+ ripng_print((const u_char *)(up + 1), length);
+ else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT)) {
+ dhcp6_print((const u_char *)(up + 1), length,
+ sport, dport);
+ }
+#endif /*INET6*/
/*
* Kludge in test for whiteboard packets.
*/
diff --git a/print-vjc.c b/print-vjc.c
new file mode 100644
index 00000000..31ee13fa
--- /dev/null
+++ b/print-vjc.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(__bsdi__)
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) print-vjc.c,v 1.1.2.2 1998/08/31 05:44:21 onoe Exp (LBL)";
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
+
+#include <ctype.h>
+#include <netdb.h>
+#include <pcap.h>
+#include <stdio.h>
+
+#if defined(__NetBSD__)
+#include <sys/mbuf.h>
+#include <net/ppp_defs.h>
+#endif
+
+#if defined(__bsdi__) || defined(__NetBSD__)
+#include <net/if_ppp.h>
+#include <net/slcompress.h>
+#endif
+
+#include "interface.h"
+#include "addrtoname.h"
+
+int
+vjc_print(register const char *bp, register u_int length, u_short proto)
+{
+ int i;
+
+ switch (bp[0] & 0xf0) {
+ case TYPE_IP:
+ if (eflag)
+ printf("(vjc type=IP) ");
+ return PPP_IP;
+ case TYPE_UNCOMPRESSED_TCP:
+ if (eflag)
+ printf("(vjc type=raw TCP) ");
+ return PPP_IP;
+ case TYPE_COMPRESSED_TCP:
+ if (eflag)
+ printf("(vjc type=compressed TCP) ");
+ for (i = 0; i < 8; i++) {
+ if (bp[1] & (0x80 >> i))
+ printf("%c", "?CI?SAWU"[i]);
+ }
+ if (bp[1])
+ printf(" ");
+ printf("C=0x%02x ", bp[2]);
+ printf("sum=0x%04x ", *(u_short *)&bp[3]);
+ return -1;
+ case TYPE_ERROR:
+ if (eflag)
+ printf("(vjc type=error) ");
+ return -1;
+ default:
+ if (eflag)
+ printf("(vjc type=0x%02x) ", bp[0] & 0xf0);
+ return -1;
+ }
+}
+#endif /* defined(__bsdi__) || defined(__NetBSD__) */
diff --git a/route6d.h b/route6d.h
new file mode 100644
index 00000000..2289deed
--- /dev/null
+++ b/route6d.h
@@ -0,0 +1,49 @@
+/*
+ * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.1 1999-10-30 05:11:22 itojun Exp $
+ */
+
+#define RIP6_VERSION 1
+
+#define RIP6_REQUEST 1
+#define RIP6_RESPONSE 2
+
+struct netinfo6 {
+ struct in6_addr rip6_dest;
+ u_short rip6_tag;
+ u_char rip6_plen;
+ u_char rip6_metric;
+};
+
+struct rip6 {
+ u_char rip6_cmd;
+ u_char rip6_vers;
+ u_char rip6_res1[2];
+ union {
+ struct netinfo6 ru6_nets[1];
+ char ru6_tracefile[1];
+ } rip6un;
+#define rip6_nets rip6un.ru6_nets
+#define rip6_tracefile rip6un.ru6_tracefile
+};
+
+#define HOPCNT_INFINITY6 16
+#define MAXRTE 24
+#define NEXTHOP_METRIC 0xff
+
+#ifndef DEBUG
+#define SUPPLY_INTERVAL6 30
+#define RIP_LIFETIME 180
+#define RIP_HOLDDOWN 120
+#define RIP_TRIG_INTERVAL6 5
+#define RIP_TRIG_INTERVAL6_MIN 1
+#else
+/* only for debugging; can not wait for 30sec to appear a bug */
+#define SUPPLY_INTERVAL6 10
+#define RIP_LIFETIME 60
+#define RIP_HOLDDOWN 40
+#define RIP_TRIG_INTERVAL6 5
+#define RIP_TRIG_INTERVAL6_MIN 1
+#endif
+
+#define RIP6_PORT 521
+#define RIP6_DEST "ff02::9"
diff --git a/savestr.c b/savestr.c
index 09c75d8b..99842ccf 100644
--- a/savestr.c
+++ b/savestr.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/Attic/savestr.c,v 1.2 1999-10-07 23:47:12 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/Attic/savestr.c,v 1.3 1999-10-30 05:11:22 itojun Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -31,6 +31,7 @@ static const char rcsid[] =
#endif
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
diff --git a/tcpdump.1 b/tcpdump.1
index 09a6ecb1..da72158b 100644
--- a/tcpdump.1
+++ b/tcpdump.1
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.68 1999-10-17 21:37:16 mcr Exp $ (LBL)
+.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.69 1999-10-30 05:11:22 itojun Exp $ (LBL)
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
@@ -27,7 +27,7 @@ tcpdump \- dump traffic on a network
.na
.B tcpdump
[
-.B \-adeflnNOpqStvx
+.B \-adeflnNOpqRStvx
] [
.B \-c
.I count
@@ -185,9 +185,14 @@ specified \fItype\fR. Currently known types are
\fBrtp\fR (Real-Time Applications protocol),
\fBrtcp\fR (Real-Time Applications control protocol),
\fBvat\fR (Visual Audio Tool),
-\fBwb\fR (distributed White Board),
and
-\fBsnmp\fR (Simple Network Management Protocol).
+\fBwb\fR (distributed White Board).
+.TP
+.B \-R
+Assume ESP/AH packets to be based on old specification (RFC1825 to RFC1829).
+If specified, \fItcpdump\fP will not print replay prevention field.
+Since there is no protocol version field in ESP/AH specification,
+\fItcpdump\fP cannot deduce the version of ESP/AH protocol.
.TP
.B \-S
Print absolute, rather than relative, TCP sequence numbers.
@@ -264,6 +269,7 @@ protos are:
.BR ether ,
.BR fddi ,
.BR ip ,
+.BR ip6 ,
.BR arp ,
.BR rarp ,
.BR decnet ,
@@ -271,6 +277,8 @@ protos are:
.BR sca ,
.BR moprc ,
.BR mopdl ,
+.BR icmp ,
+.BR icmp6 ,
.B tcp
and
.BR udp .
@@ -308,14 +316,14 @@ To save typing, identical qualifier lists can be omitted. E.g.,
.LP
Allowable primitives are:
.IP "\fBdst host \fIhost\fR"
-True if the IP destination field of the packet is \fIhost\fP,
+True if the IPv4/v6 destination field of the packet is \fIhost\fP,
which may be either an address or a name.
.IP "\fBsrc host \fIhost\fR"
-True if the IP source field of the packet is \fIhost\fP.
+True if the IPv4/v6 source field of the packet is \fIhost\fP.
.IP "\fBhost \fIhost\fP
-True if either the IP source or destination of the packet is \fIhost\fP.
+True if either the IPv4/v6 source or destination of the packet is \fIhost\fP.
Any of the above host expressions can be prepended with the keywords,
-\fBip\fP, \fBarp\fP, or \fBrarp\fP as in:
+\fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in:
.in +.5i
.nf
\fBip host \fIhost\fR
@@ -350,24 +358,26 @@ expression is
.fi
.in -.5i
which can be used with either names or numbers for \fIhost / ehost\fP.)
+This syntax does not work in IPv6-enabled configuration at this moment.
.IP "\fBdst net \fInet\fR"
-True if the IP destination address of the packet has a network
+True if the IPv4/v6 destination address of the packet has a network
number of \fInet\fP. \fINet\fP may be either a name from /etc/networks
or a network number (see \fInetworks(4)\fP for details).
.IP "\fBsrc net \fInet\fR"
-True if the IP source address of the packet has a network
+True if the IPv4/v6 source address of the packet has a network
number of \fInet\fP.
.IP "\fBnet \fInet\fR"
-True if either the IP source or destination address of the packet has a network
+True if either the IPv4/v6 source or destination address of the packet has a network
number of \fInet\fP.
.IP "\fBnet \fInet\fR \fBmask \fImask\fR"
True if the IP address matches \fInet\fR with the specific netmask.
May be qualified with \fBsrc\fR or \fBdst\fR.
+Note that this syntax is not valid for IPv6 \fInet\fR.
.IP "\fBnet \fInet\fR/\fIlen\fR"
-True if the IP address matches \fInet\fR a netmask \fIlen\fR bits wide.
+True if the IPv4/v6 address matches \fInet\fR a netmask \fIlen\fR bits wide.
May be qualified with \fBsrc\fR or \fBdst\fR.
.IP "\fBdst port \fIport\fR"
-True if the packet is ip/tcp or ip/udp and has a
+True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a
destination port value of \fIport\fP.
The \fIport\fP can be a number or a name used in /etc/services (see
.IR tcp (4P)
@@ -414,6 +424,29 @@ of protocol type \fIprotocol\fP.
\fIicmp\fP, \fIigrp\fP, \fIudp\fP, \fInd\fP, or \fItcp\fP.
Note that the identifiers \fItcp\fP, \fIudp\fP, and \fIicmp\fP are also
keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell.
+Note that this primitive does not chase protocol header chain.
+.IP "\fBip6 proto \fIprotocol\fR"
+True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
+Note that this primitive does not chase protocol header chain.
+.IP "\fBip6 protochain \fIprotocol\fR"
+True if the packet is IPv6 packet,
+and contains protocol header with type \fIprotocol\fR
+in its protocol header chain.
+For example,
+.in +.5i
+.nf
+\fBip6 protochain 6\fR
+.fi
+.in -.5i
+matches any IPv6 packet with TCP protocol header in the protocol header chain.
+The packet may contain, for example,
+authentication header, routing header, or hop-by-hop option header,
+between IPv6 header and TCP header.
+The BPF code emitted by this primitive is complex and
+cannot be optimized by BPF optimizer code in \fItcpdump\fP,
+so this can be somewhat slow.
+.IP "\fBip protochain \fIprotocol\fR"
+Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
.IP "\fBether broadcast\fR"
True if the packet is an ethernet broadcast packet. The \fIether\fP
keyword is optional.
@@ -427,10 +460,12 @@ keyword is optional.
This is shorthand for `\fBether[0] & 1 != 0\fP'.
.IP "\fBip multicast\fR"
True if the packet is an IP multicast packet.
+.IP "\fBip6 multicast\fR"
+True if the packet is an IPv6 multicast packet.
.IP "\fBether proto \fIprotocol\fR"
True if the packet is of ether type \fIprotocol\fR.
\fIProtocol\fP can be a number or a name like
-\fIip\fP, \fIarp\fP, or \fIrarp\fP.
+\fIip\fP, \fIip6\fP, \fIarp\fP, or \fIrarp\fP.
Note these identifiers are also keywords
and must be escaped via backslash (\\).
[In the case of FDDI (e.g., `\fBfddi protocol arp\fR'), the
@@ -451,7 +486,7 @@ True if the DECNET destination address is
.IP "\fBdecnet host \fIhost\fR"
True if either the DECNET source or destination address is
.IR host .
-.IP "\fBip\fR, \fBarp\fR, \fBrarp\fR, \fBdecnet\fR"
+.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBdecnet\fR"
Abbreviations for:
.in +.5i
.nf
@@ -473,7 +508,7 @@ Note that
Abbreviations for:
.in +.5i
.nf
-\fBip proto \fIp\fR
+\fBip proto \fIp\fR\fB or ip6 proto \fIp\fR
.fi
.in -.5i
where \fIp\fR is one of the above protocols.
@@ -490,8 +525,10 @@ data inside the packet, use the following syntax:
.fi
.in -.5i
\fIProto\fR is one of \fBether, fddi,
-ip, arp, rarp, tcp, udp, \fRor \fBicmp\fR, and
+ip, arp, rarp, tcp, udp, icmp\fR or \fBip6\fR, and
indicates the protocol layer for the index operation.
+Note that \fItcp, udp\fR and other upper-layer protocol types only
+apply to IPv4, not IPv6 (this will be fixed in the future).
The byte offset, relative to the indicated protocol layer, is
given by \fIexpr\fR.
\fISize\fR is optional and indicates the number of bytes in the
@@ -1191,6 +1228,9 @@ The current version is available via anonymous ftp:
.RS
.I ftp://ftp.ee.lbl.gov/tcpdump.tar.Z
.RE
+.LP
+IPv6/IPsec support is added by WIDE/KAME project.
+This program uses Eric Young's SSLeay library, under specific configuration.
.SH BUGS
Please send bug reports to tcpdump@ee.lbl.gov.
.LP
@@ -1219,3 +1259,10 @@ packets are encapsulated Ethernet packets. This is true for IP, ARP,
and DECNET Phase IV, but is not true for protocols such as ISO CLNS.
Therefore, the filter may inadvertently accept certain packets that
do not properly match the filter expression.
+.LP
+.BR "ip6 proto"
+should chase header chain, but at this moment it does not.
+.BR tcp
+or
+.BR udp
+should chase header chain too.
diff --git a/tcpdump.c b/tcpdump.c
index 27ceb1d5..1e8271a2 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.131 1999-10-17 21:56:54 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.132 1999-10-30 05:11:23 itojun Exp $ (LBL)";
#endif
/*
@@ -65,11 +65,15 @@ int Nflag; /* remove domains from printed host names */
int Oflag = 1; /* run filter code optimizer */
int pflag; /* don't go promiscuous */
int qflag; /* quick (shorter) output */
+int Rflag = 1; /* print sequence # field in AH/ESP*/
int Sflag; /* print raw TCP sequence numbers */
int tflag = 1; /* print packet arrival time */
int vflag; /* verbose */
int xflag; /* print packet in hex */
+char *ahsecret = NULL; /* AH secret key */
+char *espsecret = NULL; /* ESP secret key */
+
int packettype;
@@ -103,6 +107,9 @@ static struct printer printers[] = {
{ null_if_print, DLT_NULL },
{ raw_if_print, DLT_RAW },
{ atm_if_print, DLT_ATM_RFC1483 },
+#ifdef DLT_CHDLC
+ { chdlc_if_print, DLT_CHDLC },
+#endif
{ NULL, 0 },
};
@@ -152,13 +159,22 @@ main(int argc, char **argv)
opterr = 0;
while (
- (op = getopt(argc, argv, "ac:defF:i:lnNOpqr:s:StT:vw:xY")) != EOF)
+ (op = getopt(argc, argv, "ac:deE:fF:i:lnNOpqr:Rs:StT:vw:xY")) != EOF)
switch (op) {
case 'a':
++aflag;
break;
+#if 0
+ case 'A':
+#ifndef CRYPTO
+ warning("crypto code not compiled in");
+#endif
+ ahsecret = optarg;
+ break;
+#endif
+
case 'c':
cnt = atoi(optarg);
if (cnt <= 0)
@@ -173,6 +189,13 @@ main(int argc, char **argv)
++eflag;
break;
+ case 'E':
+#ifndef CRYPTO
+ warning("crypto code not compiled in");
+#endif
+ espsecret = optarg;
+ break;
+
case 'f':
++fflag;
break;
@@ -217,6 +240,10 @@ main(int argc, char **argv)
RFileName = optarg;
break;
+ case 'R':
+ Rflag = 0;
+ break;
+
case 's':
snaplen = atoi(optarg);
if (snaplen <= 0)