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?
This commit is contained in:
itojun 1999-10-30 05:11:06 +00:00
parent ce751501ab
commit c9d84d15c5
65 changed files with 12527 additions and 499 deletions

5
.cvsignore Normal file
View File

@ -0,0 +1,5 @@
version.c
Makefile
config.status
config.log
config.cache

View File

@ -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 $@

278
aclocal.m4 vendored
View File

@ -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
])

View File

@ -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 */

View File

@ -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

1794
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -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
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 "${srcdir}" = "." ; then
srcdirprefix=""
else
srcdirprefix="./"
fi
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

191
dhcp6.h Normal file
View File

@ -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*/

80
dhcp6opt.h Normal file
View File

@ -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*/

View File

@ -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*/

164
ipsec_doi.h Normal file
View File

@ -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_) */

449
isakmp.h Normal file
View File

@ -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_) */

82
l2tp.h Normal file
View File

@ -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;
};

106
missing/addrinfo.h Normal file
View File

@ -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 */

36
missing/addrsize.h Normal file
View File

@ -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

67
missing/bittypes.h Normal file
View File

@ -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 */

37
missing/cdecl_ext.h Normal file
View File

@ -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 */

1012
missing/getaddrinfo.c Normal file

File diff suppressed because it is too large Load Diff

261
missing/getnameinfo.c Normal file
View File

@ -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;
}

36
missing/resolv6.h Normal file
View File

@ -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

49
missing/resolv_ext.h Normal file
View File

@ -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;

38
missing/sockstorage.h Normal file
View File

@ -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 */
};

126
oakley.h Normal file
View File

@ -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_) */

280
ospf6.h Normal file
View File

@ -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

View File

@ -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;
register const struct ah *ah;
register const u_char *ep;
int sumlen;
u_int32_t spi;
ip = (struct ip *)bp2;
ah = (struct ah *)bp;
ep = snapend; /* 'ep' points to the end of avaible data. */
(void)printf("AH %s > %s\n\t\t",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
goto trunc;
if (length < 8) {
(void)printf(" [|ah] truncated-ah %d", length);
return;
}
sumlen = ah->ah_len << 2;
spi = (u_int32_t)ntohl(ah->ah_spi);
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
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;
}

View File

@ -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>

View File

@ -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:

615
print-bgp.c Normal file
View File

@ -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]");
}

192
print-chdlc.c Normal file
View File

@ -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);
}

336
print-dhcp6.c Normal file
View File

@ -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);
}

View File

@ -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;

View File

@ -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>

View File

@ -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;
void
esp_print(register const u_char *bp, int length, register const u_char *bp2)
int
esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
{
register const struct ip *ip;
register const u_char *cp, *nh;
u_short ahlen, authlen;
u_long spi, seqno;
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;
ip = (struct ip *)bp2;
esp = (struct esp *)bp;
spi = (u_int32_t)ntohl(esp->esp_spi);
(void)printf("ESP %s > %s\n\t\t",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
/* 'ep' points to the end of avaible data. */
ep = snapend;
if (length < 8) {
(void)printf(" [|esp] truncated-esp %d", length);
return;
}
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(")");
spi = ntohl(*((u_long *)(bp)));
seqno = ntohl(*((u_long *)(bp+4)));
/* if we don't have decryption key, we can't decrypt this packet. */
if (!espsecret)
goto fail;
nh = bp+ahlen;
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;
}
(void)printf("spi:%08x seqno:%d ciphertext: ", spi, seqno);
(void)default_print_unaligned(bp+8, length-8);
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;
}
/* XXX it would be nice to decrypt! */
/* 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;
des_check_key = 0;
des_set_key((void *)secret, s1);
des_set_key((void *)(secret + 8), s2);
des_set_key((void *)(secret + 16), s3);
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*/
case NONE:
default:
if (Rflag)
advance = sizeof(struct esp) + sizeof(u_int32_t);
else
advance = sizeof(struct esp);
break;
}
/* sanity check for pad length */
if (ep - bp < *(ep - 2))
goto fail;
if (nhdr)
*nhdr = *(ep - 1);
printf(": ");
return advance;
fail:
if (nhdr)
*nhdr = -1;
return 65536;
}

View File

@ -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);

100
print-frag6.c Normal file
View File

@ -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 */

View File

@ -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) {

570
print-icmp6.c Normal file
View File

@ -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 */

View File

@ -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>

View File

@ -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)

224
print-ip6.c Normal file
View File

@ -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 */

153
print-ip6opts.c Normal file
View File

@ -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 */

111
print-ipcomp.c Normal file
View File

@ -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;
}

View File

@ -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__

File diff suppressed because it is too large Load Diff

View File

@ -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>

703
print-l2tp.c Normal file
View File

@ -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
}
}

141
print-mobile.c Normal file
View File

@ -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);
}

View File

@ -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>

View File

@ -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);

View File

@ -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);

664
print-ospf6.c Normal file
View File

@ -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);
}

View File

@ -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;
}

View File

@ -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__ */
}

View File

@ -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>

View File

@ -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>

123
print-ripng.c Normal file
View File

@ -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 */

116
print-rt6.c Normal file
View File

@ -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 */

View File

@ -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

View File

@ -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);

View File

@ -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 L2TP_PORT 1701 /*XXX*/
#define ISAKMP_PORT_USER1 7500 /*??? - nonstandard*/
#define ISAKMP_PORT_USER2 8500 /*??? - nonstandard*/
#define ISAKMP_PORT 500
#define ISAKMP_UPORT1 7500
#define ISAKMP_UPORT2 8500
#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.
*/

100
print-vjc.c Normal file
View File

@ -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__) */

49
route6d.h Normal file
View File

@ -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"

View File

@ -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

View File

@ -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.

View File

@ -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)