Virgin import of tcpdump.org tcpdump v3.5

This commit is contained in:
Bill Fenner 2000-01-30 00:45:58 +00:00
parent 4644f044b2
commit b045338223
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/tcpdump/dist/; revision=56893
131 changed files with 23550 additions and 954 deletions

View File

@ -1,4 +1,48 @@
@(#) $Header: CHANGES,v 1.54 98/07/25 12:41:06 leres Exp $ (LBL)
v3.5 Fri Jan 28 18:00:00 PST 2000
Bill Fenner <fenner@research.att.com>
- switch to config.h for autoconf
- unify RCSID strings
- Updated PIMv1, PIMv2, DVMRP, IGMP parsers, add Cisco Auto-RP parser
- Really fix the RIP printer
- Fix MAC address -> name translation.
- some -Wall -Wformat fixes
- update makemib to parse much of SMIv2
- Print TCP sequence # with -vv even if you normally wouldn't
- Print as much of IP/TCP/UDP headers as possible even if truncated.
itojun@iijlab.net
- -X will make a ascii dump. from netbsd.
- telnet command sequence decoder (ff xx xx). from netbsd.
- print-bgp.c: improve options printing. ugly code exists for
unaligned option parsing (need some fix).
- const poisoning in SMB decoder.
- -Wall -Werror clean checks.
- bring in KAME IPv6/IPsec decoding code.
Assar Westerlund <assar@sics.se>
- SNMPv2 and SNMPv3 printer
- If compiled with libsmi, tcpdump can load MIBs on the fly to decode
SNMP packets.
- Incorporate NFS parsing code from NetBSD. Adds support for nfsv3.
- portability fixes
- permit building in different directories.
Ken Hornstein <kenh@cmf.nrl.navy.mil>
- bring in code at
/afs/transarc.com/public/afs-contrib/tools/tcpdump for parsing
AFS3 packets
Andrew Tridgell <tridge@linuxcare.com>
- SMB printing code
Love <lha@stacken.kth.se>
- print-rx.c: add code for printing MakeDir and StoreStatus. Also
change date format to the right one.
Michael C. Richardson <mcr@sandelman.ottawa.on.ca>
- Created tcpdump.org repository
v3.4 Sat Jul 25 12:40:55 PDT 1998
@ -513,3 +557,5 @@ v2.0.1 Sun Jan 26 21:10:10 PDT
v2.0 Sun Jan 13 12:20:40 PST 1991
- Initial public release.
@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.63.2.1 2000/01/27 23:18:19 fenner Exp $ (LBL)

View File

@ -1,4 +1,4 @@
@(#) $Header: INSTALL,v 1.36 98/07/12 13:12:26 leres Exp $ (LBL)
@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.36.1.1.2.2 2000/01/29 17:02:09 itojun Exp $ (LBL)
If you have not built libpcap, do so first. See the README
file in this directory for the ftp location.
@ -37,21 +37,25 @@ with the stock C compiler. The configure code fragments that detect if
the ether_header and ether_arp structs use the ether_addr struct
generates warnings instead of fatal errors (?!?!) This makes configure
think that the ether_arp struct is used when in fact it is not. To get
around this, delete:
around this, comment out:
-DETHER_HEADER_HAS_EA=1 -DETHER_ARP_HAS_EA=1
#define ETHER_HEADER_HAS_EA 1
and
#define ETHER_ARP_HAS_EA 1
from the Makefile after running configure (and before attempting to
compile tcpdump.
from config.h after running configure (and before attempting to
compile tcpdump).
Another workaround is to use gcc.
If your system is not one which we have tested tcpdump on, you may have
to modify the configure script and Makefile.in. Please send us patches
for any modifications you need to make. However, we are not interested
in ascii packet printer patches. We believe adding this feature would
make it too easy for crackers who do not have the programming skills
needed to write a password sniffer to grab clear text passwords.
for any modifications you need to make.
== Tested platforms ==
NetBSD 1.4.1/i386 (mcr)
RedHat Linux 6.1/i386 (assar)
FILES
-----
@ -60,20 +64,24 @@ FILES - list of files exported as part of the distribution
INSTALL - this file
Makefile.in - compilation rules (input to the configure script)
README - description of distribution
README-AFS -
VERSION - version of this release
acconfig.h - autoconf input
aclocal.m4 - autoconf macros
addrtoname.c - address to hostname routines
addrtoname.h - address to hostname definitions
appletalk.h - AppleTalk definitions
atime.awk - TCP ack awk script
bcopy.c - missing routine
bootp.h - BOOTP definitions
bpf_dump.c - bpf instruction pretty-printer routine
config.guess - autoconf support
config.h.in - autoconf input
config.sub - autoconf support
configure - configure script (run this first)
configure.in - configure script source
decnet.h - DECnet definitions
dhcp6.h - IPv6 DHCP definitions
dhcp6opt.h - IPv6 DHCP options
ethertype.h - ethernet definitions
extract.h - alignment definitions
fddi.h - Fiber Distributed Data Interface definitions
@ -82,7 +90,11 @@ gmt2local.h - time conversion prototypes
igrp.h - Interior Gateway Routing Protocol definitions
install-sh - BSD style install script
interface.h - globals, prototypes and definitions
ipsec_doi.h - ISAKMP packet definitions - RFC2407
ipx.h - IPX definitions
isakmp.h - ISAKMP packet definitions - RFC2408
l2tp.h -
lane.h -
lbl/gnuc.h - gcc macros and defines
lbl/os-*.h - os dependent defines and prototypes
linux-include/* - network include files missing on Linux
@ -91,53 +103,86 @@ machdep.c - machine dependent routines
machdep.h - machine dependent definitions
makemib - mib to header script
mib.h - mib definitions
missing/* - replacements for missing library functions
mkdep - construct Makefile dependency list
netbios.h - NETBIOS definitions
nfs.h - Network File System V2 definitions
nfsfh.h - Network File System file handle definitions
nfsv2.h - Network File System V2 definitions
ntp.h - Network Time Protocol definitions
oakley.h - ISAKMP packet definitions - RFC2409
ospf.h - Open Shortest Path First definitions
ospf6.h - IPv6 Open Shortest Path First definitions
packetdat.awk - TCP chunk summary awk script
parsenfsfh.c - Network File System file parser routines
ppp.h - Point to Point Protocol definitions
print-ah.c - IPSEC Authentication Header printer routines
print-arp.c - Address Resolution Protocol printer routines
print-ascii.c - ASCII packet dump routines
print-atalk.c - AppleTalk printer routines
print-atm.c - atm printer routines
print-bootp.c - BOOTP printer routines
print-bgp.c - Border Gateway Protocol printer routines
print-bootp.c - BOOTP and IPv4 DHCP printer routines
print-chdlc.c - CHDLC printer routines
print-cip.c -
print-decnet.c - DECnet printer routines
print-dhcp6.c - IPv6 DHCP printer routines
print-domain.c - Domain Name System printer routines
print-dvmrp.c - Distance Vector Multicast Routing Protocol printer routines
print-egp.c - External Gateway Protocol printer routines
print-esp.c - IPSEC Encapsulating Security Payload printer routines
print-ether.c - ethernet printer routines
print-fddi.c - Fiber Distributed Data Interface printer routines
print-frag6.c - IPv6 fragmentation header printer routines
print-gre.c - Generic Routing Encapsulation printer routines
print-icmp.c - Internet Control Message Protocol printer routines
print-icmp6.c - IPv6 Internet Control Message Protocol printer routines
print-igrp.c - Interior Gateway Routing Protocol printer routines
print-ip.c - ip printer routines
print-ip6.c - IPv6 printer routines
print-ip6opts.c - IPv6 header option printer routines
print-ipcomp.c - IP Payload Compression Protocol printer routines
print-ipx.c - IPX printer routines
print-isakmp.c - Internet Security Association and Key Management Protocol
print-isoclns.c - isoclns printer routines
print-krb.c - Kerberos printer routines
print-l2tp.c - Layer Two Tunneling Protocol printer routines
print-lane.c -
print-lcp.c -
print-llc.c - llc printer routines
print-mobile.c - IPv4 mobility printer routines
print-netbios.c - netbios printer routines
print-nfs.c - Network File System printer routines
print-ntp.c - Network Time Protocol printer routines
print-null.c - null printer routines
print-ospf.c - Open Shortest Path First printer routines
print-ospf6.c - IPv6 Open Shortest Path First printer routines
print-pim.c - Protocol Independent Multicast printer routines
print-ppp.c - Point to Point Protocol printer routines
print-pppoe.c -
print-raw.c - raw printer routines
print-rip.c - Routing Information Protocol printer routines
print-ripng.c - IPv6 Routing Information Protocol printer routines
print-rt6.c - IPv6 routing header printer routines
print-rx.c - AFS RX printer routines
print-sl.c - Compressed Serial Line Internet Protocol printer routines
print-smb.c - SMB (samba) printer routines
print-snmp.c - Simple Network Management Protocol printer routines
print-sunrpc.c - Sun Remote Procedure Call printer routines
print-tcp.c - TCP printer routines
print-telnet.c - Telnet option printer routines
print-tftp.c - Trivial File Transfer Protocol printer routines
print-udp.c - UDP printer routines
print-vjc.c - PPP Van Jacovson compression (RFC1144) printer routines
print-wb.c - white board printer routines
savestr.c - savestr prototypes
savestr.h - strdup() replacement
route6d.h - packet definition for IPv6 Routing Information Protocol
rx.h -
savestr.c - strdup() replacement
savestr.h - savestr prototypes
send-ack.awk - unidirectional tcp send/ack awk script
setsignal.c - os independent signal routines
setsignal.h - os independent signal prototypes
smb.h -
smbutil.c -
stime.awk - TCP send awk script
strcasecmp.c - missing routine
tcpdump.1 - manual entry

View File

@ -17,7 +17,7 @@
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#) $Header: Makefile.in,v 1.207 97/08/17 13:53:29 leres Exp $ (LBL)
# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.219 1999/12/22 15:44:09 itojun Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@ -43,7 +43,7 @@ CC = @CC@
PROG = tcpdump
CCOPT = @V_CCOPT@
INCLS = -I. @V_INCLS@
DEFS = @DEFS@ -DHAVE_FDDI
DEFS = @DEFS@
# Standard CFLAGS
CFLAGS = $(CCOPT) $(DEFS) $(INCLS)
@ -72,9 +72,14 @@ CSRC = tcpdump.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 print-rx.c \
print-lane.c print-cip.c print-pppoe.c print-lcp.c \
print-smb.c smbutil.c print-ascii.c print-telnet.c
LOCALSRC = @LOCALSRC@
GENSRC = version.c
LIBOBJS = @LIBOBJS@
SRC = $(CSRC) $(GENSRC) $(LOCALSRC)
@ -82,9 +87,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 \
@ -107,16 +114,31 @@ $(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
inet_pton.o: $(srcdir)/missing/inet_pton.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c
inet_ntop.o: $(srcdir)/missing/inet_ntop.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c
inet_aton.o: $(srcdir)/missing/inet_aton.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
version.o: version.c
$(CC) $(CFLAGS) -c version.c
version.c: $(srcdir)/VERSION
@rm -f $@
sed -e 's/.*/char version[] = "&";/' $(srcdir)/VERSION > $@
install: force
[ -d $(DESTDIR)$(BINDEST) ] || mkdir -p $(DESTDIR)$(BINDEST)
$(INSTALL) -m 550 -o bin -g @V_GROUP@ $(PROG) \
$(DESTDIR)$(BINDEST)/$(PROG)
install-man: force
[ -d $(DESTDIR)$(MANDEST)/man1 ] || mkdir -p $(DESTDIR)$(MANDEST)/man1
$(INSTALL) -m 444 -o bin -g bin $(srcdir)/$(PROG).1 \
$(DESTDIR)$(MANDEST)/man1/$(PROG).1
@ -130,7 +152,7 @@ clean:
distclean:
rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
gnuc.h os-proto.h
config.h gnuc.h os-proto.h
tags: $(TAGFILES)
ctags -wtd $(TAGFILES)

View File

@ -1,4 +1,4 @@
@(#) $Header: README,v 1.54 98/01/27 21:36:20 vern Exp $ (LBL)
@(#) $Header: /tcpdump/master/tcpdump/README,v 1.54.1.1 1999/10/07 23:47:09 mcr Exp $ (LBL)
TCPDUMP 3.4
Lawrence Berkeley National Laboratory

View File

@ -1 +1 @@
3.4
3.5

106
contrib/tcpdump/acconfig.h Normal file
View File

@ -0,0 +1,106 @@
/* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in --
* make them to acconfig.h and rerun autoheader */
@TOP@
/* Define if you have SSLeay XXX why isn't this HAVE_LIBCRYPTO? */
#undef CRYPTO
/* Define if you have SSLeay 0.9.0b with the buggy cast128. */
#undef HAVE_BUGGY_CAST128
/* Define both to enable IPv6 support XXX why 2? ENABLE_IPV6 is not used. */
#undef ENABLE_IPV6
#undef INET6
/* Define if you enable support for the libsmi. */
#undef LIBSMI
/* Define if you have the <smi.h> header file. */
#undef HAVE_SMI_H
/* Is T_AAAA predefined? */
#undef HAVE_AAAA
/* Fallback definition if not in headers */
/* XXX why is this not #ifndef HAVE_AAA #define T_AAAA ... ? */
/* XXX or even #ifndef T_AAAA ... */
#undef T_AAAA
/* define if you have struct __res_state_ext */
#undef HAVE_RES_STATE_EXT
/* define if your struct __res_state has the nsort member */
#undef HAVE_NEW_RES_STATE
/*
* define if struct ether_header.ether_dhost is a struct with ether_addr_octet
*/
#undef ETHER_HEADER_HAS_EA
/*
* define if struct ether_arp.arp_sha is a struct with ether_addr_octet
*/
#undef ETHER_ARP_HAS_EA
/* define if struct ether_arp contains arp_xsha */
#undef ETHER_ARP_HAS_X
/* define if you have the addrinfo function. */
#undef HAVE_ADDRINFO
/* define if you need to include missing/addrinfoh.h. */
#undef NEED_ADDRINFO_H
/* define ifyou have the h_errno variable. */
#undef HAVE_H_ERRNO
/* define if IN6ADDRSZ is defined (XXX not used!) */
#undef HAVE_IN6ADDRSZ
/* define if INADDRSZ is defined (XXX not used!) */
#undef HAVE_INADDRSZ
/* define if you have <net/slip.h> */
#undef HAVE_NET_SLIP_H
/* define if this is a development version, to use additional prototypes. */
#undef HAVE_OS_PROTO_H
/* define if <unistd.h> defines __P() */
#undef HAVE_PORTABLE_PROTOTYPE
/* define if RES_USE_INET6 is defined */
#undef HAVE_RES_USE_INET6
/* define if struct sockaddr has the sa_len member */
#undef HAVE_SOCKADDR_SA_LEN
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
/* The successful return value from signal (?)XXX */
#undef RETSIGVAL
/* Define this on IRIX */
#undef _BSD_SIGNALS
/* For HP/UX ANSI compiler? */
#undef _HPUX_SOURCE
/* AIX hack. */
#undef _SUN
/* OSF hack: "Workaround around ip_hl vs. ip_vhl problem in netinet/ip.h" */
#undef __STDC__
/* Workaround for missing sized types */
/* XXX this should move to the more standard uint*_t */
#undef int16_t
#undef int32_t
#undef u_int16_t
#undef u_int32_t
#undef u_int8_t

View File

@ -1,4 +1,4 @@
dnl @(#) $Header: aclocal.m4,v 1.63 98/06/12 03:44:50 leres Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.67.2.1 2000/01/25 18:39:02 itojun Exp $ (LBL)
dnl
dnl Copyright (c) 1995, 1996, 1997, 1998
dnl The Regents of the University of California. All rights reserved.
@ -51,7 +51,7 @@ AC_DEFUN(AC_LBL_C_INIT,
$1="-O"
$2=""
if test "${srcdir}" != "." ; then
$2="-I\$\(srcdir\)"
$2="-I\$(srcdir)"
fi
if test "${CFLAGS+set}" = set; then
LBL_CFLAGS="$CFLAGS"
@ -200,7 +200,7 @@ AC_DEFUN(AC_LBL_LIBPCAP,
continue;
fi
lastdir=$dir
if test -r $dir/pcap.c ; then
if test -r $dir/libpcap.a ; then
libpcap=$dir/libpcap.a
d=$dir
dnl continue and select the last one that exists
@ -214,7 +214,13 @@ AC_DEFUN(AC_LBL_LIBPCAP,
fi
else
$1=$libpcap
if test -r $d/pcap.h; then
$2="-I$d $$2"
elif test -r $srcdir/../libpcap/pcap.h; then
$2="-I$d -I$srcdir/../libpcap $$2"
else
AC_MSG_ERROR(cannot find pcap.h, see INSTALL)
fi
AC_MSG_RESULT($libpcap)
fi
LIBS="$libpcap $LIBS"
@ -704,3 +710,320 @@ 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)
else
AC_DEFINE(NEED_ADDRINFO_H)
fi
])
dnl
dnl Checks for NI_MAXSERV
AC_DEFUN(AC_NI_MAXSERV, [
AC_MSG_CHECKING(for NI_MAXSERV)
AC_CACHE_VAL($1,
AC_EGREP_CPP(yes, [#include <netdb.h>
#ifdef NI_MAXSERV
yes
#endif],
$1=yes,
$1=no))
AC_MSG_RESULT($$1)
if test $$1 != yes; then
AC_DEFINE(NEED_ADDRINFO_H)
fi
])
dnl
dnl Checks for NI_NAMEREQD
AC_DEFUN(AC_NI_NAMEREQD, [
AC_MSG_CHECKING(for NI_NAMEREQD)
AC_CACHE_VAL($1,
AC_EGREP_CPP(yes, [#include <netdb.h>
#ifdef NI_NOFQDN
yes
#endif],
$1=yes,
$1=no))
AC_MSG_RESULT($$1)
if test $$1 != yes; then
AC_DEFINE(NEED_ADDRINFO_H)
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 <sys/types.h>
# 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
])
dnl
dnl check for h_errno
AC_DEFUN(AC_VAR_H_ERRNO, [
AC_MSG_CHECKING(for h_errno)
AC_CACHE_VAL(ac_cv_var_h_errno,
AC_TRY_COMPILE([
# include <sys/types.h>
# include <netdb.h>],
[int foo = h_errno;],
ac_cv_var_h_errno=yes,
ac_cv_var_h_errno=no))
AC_MSG_RESULT($ac_cv_var_h_errno)
if test "$ac_cv_var_h_errno" = "yes"; then
AC_DEFINE(HAVE_H_ERRNO)
fi
])

View File

@ -23,7 +23,11 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: addrtoname.c,v 1.61 97/06/15 13:20:18 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.64 1999/11/21 09:36:44 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
@ -39,6 +43,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 +93,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 +189,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 +235,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[14] & (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 +815,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: addrtoname.h,v 1.15 97/01/01 21:01:16 leres 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

View File

@ -20,7 +20,7 @@
*
* AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
*
* @(#) $Header: appletalk.h,v 1.12 96/06/03 02:54:24 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.12.1.1 1999/10/07 23:47:09 mcr Exp $ (LBL)
*/
struct LAP {

View File

@ -1,4 +1,4 @@
/* @(#) $Header: bootp.h,v 1.7 95/05/04 17:52:46 mccanne Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.8 1999/10/17 23:35:46 mcr Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
@ -27,7 +27,7 @@ struct bootp {
unsigned char bp_hops; /* gateway hops */
u_int32_t bp_xid; /* transaction ID */
unsigned short bp_secs; /* seconds since boot began */
unsigned short bp_unused;
unsigned short bp_flags; /* flags: 0x8000 is broadcast */
struct in_addr bp_ciaddr; /* client IP address */
struct in_addr bp_yiaddr; /* 'your' IP address */
struct in_addr bp_siaddr; /* server IP address */
@ -86,7 +86,74 @@ struct bootp {
#define TAG_SWAP_SERVER ((unsigned char) 16)
#define TAG_ROOTPATH ((unsigned char) 17)
#define TAG_EXTPATH ((unsigned char) 18)
/* RFC2132 */
#define TAG_IP_FORWARD ((unsigned char) 19)
#define TAG_NL_SRCRT ((unsigned char) 20)
#define TAG_PFILTERS ((unsigned char) 21)
#define TAG_REASS_SIZE ((unsigned char) 22)
#define TAG_DEF_TTL ((unsigned char) 23)
#define TAG_MTU_TIMEOUT ((unsigned char) 24)
#define TAG_MTU_TABLE ((unsigned char) 25)
#define TAG_INT_MTU ((unsigned char) 26)
#define TAG_LOCAL_SUBNETS ((unsigned char) 27)
#define TAG_BROAD_ADDR ((unsigned char) 28)
#define TAG_DO_MASK_DISC ((unsigned char) 29)
#define TAG_SUPPLY_MASK ((unsigned char) 30)
#define TAG_DO_RDISC ((unsigned char) 31)
#define TAG_RTR_SOL_ADDR ((unsigned char) 32)
#define TAG_STATIC_ROUTE ((unsigned char) 33)
#define TAG_USE_TRAILERS ((unsigned char) 34)
#define TAG_ARP_TIMEOUT ((unsigned char) 35)
#define TAG_ETH_ENCAP ((unsigned char) 36)
#define TAG_TCP_TTL ((unsigned char) 37)
#define TAG_TCP_KEEPALIVE ((unsigned char) 38)
#define TAG_KEEPALIVE_GO ((unsigned char) 39)
#define TAG_NIS_DOMAIN ((unsigned char) 40)
#define TAG_NIS_SERVERS ((unsigned char) 41)
#define TAG_NTP_SERVERS ((unsigned char) 42)
#define TAG_VENDOR_OPTS ((unsigned char) 43)
#define TAG_NETBIOS_NS ((unsigned char) 44)
#define TAG_NETBIOS_DDS ((unsigned char) 45)
#define TAG_NETBIOS_NODE ((unsigned char) 46)
#define TAG_NETBIOS_SCOPE ((unsigned char) 47)
#define TAG_XWIN_FS ((unsigned char) 48)
#define TAG_XWIN_DM ((unsigned char) 49)
#define TAG_NIS_P_DOMAIN ((unsigned char) 64)
#define TAG_NIS_P_SERVERS ((unsigned char) 65)
#define TAG_MOBILE_HOME ((unsigned char) 68)
#define TAG_SMPT_SERVER ((unsigned char) 69)
#define TAG_POP3_SERVER ((unsigned char) 70)
#define TAG_NNTP_SERVER ((unsigned char) 71)
#define TAG_WWW_SERVER ((unsigned char) 72)
#define TAG_FINGER_SERVER ((unsigned char) 73)
#define TAG_IRC_SERVER ((unsigned char) 74)
#define TAG_STREETTALK_SRVR ((unsigned char) 75)
#define TAG_STREETTALK_STDA ((unsigned char) 76)
/* DHCP options */
#define TAG_REQUESTED_IP ((unsigned char) 50)
#define TAG_IP_LEASE ((unsigned char) 51)
#define TAG_OPT_OVERLOAD ((unsigned char) 52)
#define TAG_TFTP_SERVER ((unsigned char) 66)
#define TAG_BOOTFILENAME ((unsigned char) 67)
#define TAG_DHCP_MESSAGE ((unsigned char) 53)
#define TAG_SERVER_ID ((unsigned char) 54)
#define TAG_PARM_REQUEST ((unsigned char) 55)
#define TAG_MESSAGE ((unsigned char) 56)
#define TAG_MAX_MSG_SIZE ((unsigned char) 57)
#define TAG_RENEWAL_TIME ((unsigned char) 58)
#define TAG_REBIND_TIME ((unsigned char) 59)
#define TAG_VENDOR_CLASS ((unsigned char) 60)
#define TAG_CLIENT_ID ((unsigned char) 61)
/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
#define DHCPDISCOVER 1
#define DHCPOFFER 2
#define DHCPREQUEST 3
#define DHCPDECLINE 4
#define DHCPACK 5
#define DHCPNAK 6
#define DHCPRELEASE 7
#define DHCPINFORM 8
/*

View File

@ -20,7 +20,11 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: bpf_dump.c,v 1.9 96/09/26 23:11:04 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.10 1999/11/21 09:36:44 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>

220
contrib/tcpdump/config.h.in Normal file
View File

@ -0,0 +1,220 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in --
* make them to acconfig.h and rerun autoheader */
/* Define to empty if the keyword does not work. */
#undef const
/* Define as __inline if that's what the C compiler calls it. */
#undef inline
/* Define as the return type of signal handlers (int or void). */
#undef RETSIGTYPE
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define if your processor stores words with the most significant
byte first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define if you have SSLeay XXX why isn't this HAVE_LIBCRYPTO? */
#undef CRYPTO
/* Define if you have SSLeay 0.9.0b with the buggy cast128. */
#undef HAVE_BUGGY_CAST128
/* Define both to enable IPv6 support XXX why 2? ENABLE_IPV6 is not used. */
#undef ENABLE_IPV6
#undef INET6
/* Define if you enable support for the libsmi. */
#undef LIBSMI
/* Is T_AAAA predefined? */
#undef HAVE_AAAA
/* Fallback definition if not in headers */
/* XXX why is this not #ifndef HAVE_AAA #define T_AAAA ... ? */
/* XXX or even #ifndef T_AAAA ... */
#undef T_AAAA
/* define if you have struct __res_state_ext */
#undef HAVE_RES_STATE_EXT
/* define if your struct __res_state has the nsort member */
#undef HAVE_NEW_RES_STATE
/*
* define if struct ether_header.ether_dhost is a struct with ether_addr_octet
*/
#undef ETHER_HEADER_HAS_EA
/*
* define if struct ether_arp.arp_sha is a struct with ether_addr_octet
*/
#undef ETHER_ARP_HAS_EA
/* define if struct ether_arp contains arp_xsha */
#undef ETHER_ARP_HAS_X
/* define if you have the addrinfo function. */
#undef HAVE_ADDRINFO
/* define if you need to include missing/addrinfoh.h. */
#undef NEED_ADDRINFO_H
/* define ifyou have the h_errno variable. */
#undef HAVE_H_ERRNO
/* define if IN6ADDRSZ is defined (XXX not used!) */
#undef HAVE_IN6ADDRSZ
/* define if INADDRSZ is defined (XXX not used!) */
#undef HAVE_INADDRSZ
/* define if you have <net/slip.h> */
#undef HAVE_NET_SLIP_H
/* define if this is a development version, to use additional prototypes. */
#undef HAVE_OS_PROTO_H
/* define if <unistd.h> defines __P() */
#undef HAVE_PORTABLE_PROTOTYPE
/* define if RES_USE_INET6 is defined */
#undef HAVE_RES_USE_INET6
/* define if struct sockaddr has the sa_len member */
#undef HAVE_SOCKADDR_SA_LEN
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
/* The successful return value from signal (?)XXX */
#undef RETSIGVAL
/* Define this on IRIX */
#undef _BSD_SIGNALS
/* For HP/UX ANSI compiler? */
#undef _HPUX_SOURCE
/* AIX hack. */
#undef _SUN
/* OSF hack: "Workaround around ip_hl vs. ip_vhl problem in netinet/ip.h" */
#undef __STDC__
/* Workaround for missing sized types */
/* XXX this should move to the more standard uint*_t */
#undef int16_t
#undef int32_t
#undef u_int16_t
#undef u_int32_t
#undef u_int8_t
/* The number of bytes in a char. */
#undef SIZEOF_CHAR
/* The number of bytes in a int. */
#undef SIZEOF_INT
/* The number of bytes in a long. */
#undef SIZEOF_LONG
/* The number of bytes in a short. */
#undef SIZEOF_SHORT
/* Define if you have the ether_ntohost function. */
#undef HAVE_ETHER_NTOHOST
/* Define if you have the getaddrinfo function. */
#undef HAVE_GETADDRINFO
/* Define if you have the gethostbyname2 function. */
#undef HAVE_GETHOSTBYNAME2
/* Define if you have the getnameinfo function. */
#undef HAVE_GETNAMEINFO
/* Define if you have the inet_aton function. */
#undef HAVE_INET_ATON
/* Define if you have the inet_ntop function. */
#undef HAVE_INET_NTOP
/* Define if you have the inet_pton function. */
#undef HAVE_INET_PTON
/* Define if you have the pfopen function. */
#undef HAVE_PFOPEN
/* Define if you have the setlinebuf function. */
#undef HAVE_SETLINEBUF
/* Define if you have the sigaction function. */
#undef HAVE_SIGACTION
/* Define if you have the sigset function. */
#undef HAVE_SIGSET
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the vfprintf function. */
#undef HAVE_VFPRINTF
/* Define if you have the <cast.h> header file. */
#undef HAVE_CAST_H
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the <net/slip.h> header file. */
#undef HAVE_NET_SLIP_H
/* Define if you have the <rc5.h> header file. */
#undef HAVE_RC5_H
/* Define if you have the <rpc/rpcent.h> header file. */
#undef HAVE_RPC_RPCENT_H
/* Define if you have the <smi.h> header file. */
#undef HAVE_SMI_H
/* Define if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
/* Define if you have the crypto library (-lcrypto). */
#undef HAVE_LIBCRYPTO
/* Define if you have the dnet library (-ldnet). */
#undef HAVE_LIBDNET
/* Define if you have the resolv library (-lresolv). */
#undef HAVE_LIBRESOLV
/* Define if you have the rpc library (-lrpc). */
#undef HAVE_LIBRPC
/* Define if you have the smi library (-lsmi). */
#undef HAVE_LIBSMI
/* Define if you have the socket library (-lsocket). */
#undef HAVE_LIBSOCKET
/* Define if you have the str library (-lstr). */
#undef HAVE_LIBSTR
/* Define if you have the z library (-lz). */
#undef HAVE_LIBZ

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
dnl @(#) $Header: configure.in,v 1.71 97/07/27 22:17:59 leres Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.87.2.4 2000/01/25 18:39:02 itojun Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@ -17,6 +17,7 @@ if test -z "$PWD" ; then
fi
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_C_INLINE
AC_CHECK_HEADERS(fcntl.h malloc.h memory.h rpc/rpcent.h)
AC_HEADER_TIME
@ -40,14 +41,404 @@ linux*)
;;
esac
AC_CHECK_HEADERS(smi.h)
AC_CHECK_LIB(smi, main)
AC_MSG_CHECKING([whether to enable libsmi])
AC_TRY_RUN([ /* libsmi available check */
#include <smi.h>
main()
{
if (smiInit(""))
exit(1);
else
exit(0);
}
],
[ AC_MSG_RESULT(yes)
AC_DEFINE(LIBSMI)
libsmi=yes],
[ AC_MSG_RESULT(no)
libsmi=no]
)
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
yes) 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
;;
esac ],
AC_TRY_RUN([ /* AF_INET6 available check */
#include <sys/types.h>
#include <sys/socket.h>
main()
{
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
if test "$ipv6" = "yes"; then
AC_CHECK_FUNCS(getaddrinfo, [dnl
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;
}
}
}
/* supported family should be 2, unsupported family should be 0 */
if (!(inet4 == 0 || inet4 == 2))
goto bad;
if (!(inet6 == 0 || inet6 == 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)], [buggygetaddrinfo=yes])
if test "$buggygetaddrinfo" = "yes"; then
if test "$ipv6type" != "linux"; then
echo 'Fatal: You must get working getaddrinfo() function.'
echo ' or you can specify "--disable-ipv6"'.
exit 1
else
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)
fi
AC_REPLACE_FUNCS(inet_ntop inet_pton inet_aton)
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.
dnl They're very likely to be wrong for cross-compiling.
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
dnl
dnl Checks for u_intXX_t
dnl AC_CHECK_BITTYPES(ac_cv_bittypes)
dnl if test "$ac_cv_bittypes" = no; then
dnl missing_includes=yes
dnl 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 NI_MAXSERV
AC_NI_MAXSERV(ac_cv_maxserv)
if test "$ac_cv_maxserv" = no; then
missing_includes=yes
fi
dnl
dnl Checks for NI_NAMEREQD
AC_NI_NAMEREQD(ac_cv_namereqd)
if test "$ac_cv_namereqd" = 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\$(srcdir)/missing"
V_INCLS="$V_INCLS -I\$(srcdir)/missing"
fi
AC_REPLACE_FUNCS(vfprintf strcasecmp)
AC_CHECK_FUNCS(ether_ntoa setlinebuf)
AC_CHECK_FUNCS(ether_ntohost setlinebuf gethostbyname2)
dnl The following generates a warning from autoconf...
AC_C_BIGENDIAN
AC_CHECK_LIB(dnet, main)
AC_CHECK_LIB(rpc, main)
AC_CHECK_LIB(z, uncompress)
AC_CHECK_HEADERS(zlib.h)
AC_LBL_TYPE_SIGNAL
@ -69,7 +460,7 @@ irix*)
;;
linux*)
V_INCLS="$V_INCLS -Ilinux-include"
V_INCLS="$V_INCLS -I\$(srcdir)/linux-include"
;;
osf*)
@ -87,6 +478,9 @@ if test -f /dev/bpf0 ; then
V_GROUP=bpf
fi
AC_LBL_CHECK_TYPE(u_int8_t, u_char)
AC_LBL_CHECK_TYPE(int16_t, short)
AC_LBL_CHECK_TYPE(u_int16_t, u_short)
AC_LBL_CHECK_TYPE(int32_t, int)
AC_LBL_CHECK_TYPE(u_int32_t, u_int)
@ -170,24 +564,96 @@ fi
AC_LBL_UNALIGNED_ACCESS
if test "${srcdir}" = "." ; then
srcdirprefix=""
else
srcdirprefix="./"
AC_VAR_H_ERRNO
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"
if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
LIBS="$LIBS -lRSAglue"
fi
if test -f $ac_cv_ssleay_path/lib/librsaref.a; then
LIBS="$LIBS -lrsaref"
fi
AC_CHECK_LIB(crypto, des_cbc_encrypt)
AC_DEFINE(CRYPTO)
bak_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_HEADERS(cast.h rc5.h)
if test "$ac_cv_header_cast_h" = "yes"; then
AC_MSG_CHECKING(for buggy CAST128)
AC_TRY_RUN(dnl
[
#include <cast.h>
main()
{
unsigned char key[] = {0x01,0x23,0x45,0x67,0x12};
unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
unsigned char out[sizeof(in)];
unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E};
CAST_KEY ks;
CAST_set_key(&ks, sizeof(key), key);
CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT);
if (memcmp(out, ok, sizeof(ok)) != 0)
return 0;
else
return 1;
}],
[buggy_cast128=yes],
[buggy_cast128=no],
[buggy_cast128="cross-compiling, assume yes"])
AC_MSG_RESULT($buggy_cast128)
if test "$buggy_cast128" != no; then
echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine."
echo "disabling CAST128 support."
AC_DEFINE(HAVE_BUGGY_CAST128)
fi
fi
CPPFLAGS=$bak_CPPFLAGS
fi
if test -r ${srcdirprefix}lbl/gnuc.h ; then
if test -r ${srcdir}/lbl/gnuc.h ; then
rm -f gnuc.h
ln -s ${srcdirprefix}lbl/gnuc.h gnuc.h
ln -s ${srcdir}/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
AC_CONFIG_HEADER(config.h)
AC_OUTPUT(Makefile)
if test -f .devel ; then

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: decnet.h,v 1.6 96/07/15 18:15:19 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.6.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
*/
typedef unsigned char byte[1]; /* single byte field */

191
contrib/tcpdump/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*/

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: ethertype.h,v 1.6 96/07/14 18:21:49 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.7.2.1 2000/01/29 22:00:12 fenner Exp $ (LBL)
*/
/* Types missing from some systems */
@ -71,6 +71,18 @@
#ifndef ETHERTYPE_AARP
#define ETHERTYPE_AARP 0x80f3
#endif
#ifndef ETHERTYPE_8021Q
#define ETHERTYPE_8021Q 0x8100
#endif
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86dd
#endif
#ifndef ETHERTYPE_PPPOED
#define ETHERTYPE_PPPOED 0x8863
#endif
#ifndef ETHERTYPE_PPPOES
#define ETHERTYPE_PPPOES 0x8864
#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
#endif

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: extract.h,v 1.15 96/11/26 22:03:22 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.15.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
*/
/* Network to host order macros */

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: fddi.h,v 1.8 96/06/03 03:06:04 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.8.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
*/
/*

View File

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: gmt2local.c,v 1.2 97/01/23 22:31:25 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.3 1999/11/21 09:36:47 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: gmt2local.h,v 1.2 97/01/23 22:31:40 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
*/
#ifndef gmt2local_h
#define gmt2local_h

View File

@ -4,11 +4,11 @@
struct igrphdr {
#ifdef WORDS_BIGENDIAN
u_char ig_v:4; /* protocol version number */
u_char ig_op:4; /* opcode */
u_int ig_v:4; /* protocol version number */
u_int ig_op:4; /* opcode */
#else
u_char ig_op:4; /* opcode */
u_char ig_v:4; /* protocol version number */
u_int ig_op:4; /* opcode */
u_int ig_v:4; /* protocol version number */
#endif
u_char ig_ed; /* edition number */
u_short ig_as; /* autonomous system number */

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: interface.h,v 1.105 97/04/26 13:39:58 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.118 1999/12/22 15:44:09 itojun Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@ -41,10 +41,16 @@ 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; /* use the libsmi to translate OIDs */
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 int Xflag; /* print packet in hex/ascii */
extern char *ahsecret;
extern char *espsecret;
extern int packettype; /* as specified by -T */
#define PT_VAT 1 /* Visual Audio Tool */
@ -52,6 +58,7 @@ extern int packettype; /* as specified by -T */
#define PT_RPC 3 /* Remote Procedure Call */
#define PT_RTP 4 /* Real-Time Applications protocol */
#define PT_RTCP 5 /* Real-Time Applications control protocol */
#define PT_SNMP 6 /* Simple Network Management Protocol */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
@ -60,6 +67,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.
@ -67,6 +75,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
@ -132,6 +143,7 @@ struct timeval;
#endif
extern void ts_print(const struct timeval *);
extern void relts_print(int);
extern int fn_print(const u_char *, const u_char *);
extern int fn_printn(const u_char *, u_int, const u_char *);
@ -161,6 +173,11 @@ extern char *dnnum_string(u_short);
struct pcap_pkthdr;
#endif
extern void ascii_print_with_offset(const u_char *, u_int, u_int);
extern void ascii_print(const u_char *, u_int);
extern void hex_print_with_offset(const u_char *, u_int, u_int);
extern void telnet_print(const u_char *, u_int);
extern void hex_print(const u_char *, u_int);
extern int ether_encap_print(u_short, const u_char *, u_int, u_int);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
const u_char *);
@ -169,6 +186,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);
@ -178,7 +196,7 @@ extern void ether_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern void fddi_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void gre_print(const u_char *, u_int);
extern void icmp_print(const u_char *, const u_char *);
extern void icmp_print(const u_char *, u_int, const u_char *);
extern void igrp_print(const u_char *, u_int, const u_char *);
extern void ip_print(const u_char *, u_int);
extern void ipx_print(const u_char *, u_int);
@ -191,18 +209,55 @@ 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 pimv1_print(const u_char *, u_int);
extern void cisco_autorp_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 pppoe_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 lane_if_print(u_char *, const struct pcap_pkthdr *,const u_char *);
extern void cip_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 *);
extern void rx_print(register const u_char *, int, int, int, u_char *);
extern void netbeui_print(const u_char *, const u_char *);
extern void ipx_netbios_print(const u_char *, const u_char *);
extern void nbt_tcp_print(const u_char *, int);
extern void nbt_udp137_print(const u_char *data, int);
extern void nbt_udp138_print(const u_char *data, int);
extern char *smb_errstr(int, int);
extern void print_data(const unsigned char *, int);
extern void l2tp_print(const u_char *, u_int);
extern void lcp_print(const u_char *, u_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*/
extern u_short in_cksum(const u_short *addr, register int len, u_short csum);

164
contrib/tcpdump/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_) */

View File

@ -1,7 +1,7 @@
/*
* IPX protocol formats
*
* @(#) $Header: ipx.h,v 1.1 94/06/09 11:47:03 mccanne Exp $
* @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.1.1.1 1999/10/07 23:47:10 mcr Exp $
*/
/* well-known sockets */

447
contrib/tcpdump/isakmp.h Normal file
View File

@ -0,0 +1,447 @@
/*
* 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.4.2.1 2000/01/14 19:19:56 mcr 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 */
u_int8_t vers;
#define ISAKMP_VERS_MAJOR 0xf0
#define ISAKMP_VERS_MAJOR_SHIFT 4
#define ISAKMP_VERS_MINOR 0x0f
#define ISAKMP_VERS_MINOR_SHIFT 0
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
contrib/tcpdump/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;
};

34
contrib/tcpdump/lane.h Normal file
View File

@ -0,0 +1,34 @@
/*
* Marko Kiiskila carnil@cs.tut.fi
*
* Tampere University of Technology - Telecommunications Laboratory
*
* Permission to use, copy, modify and distribute this
* software and its documentation is hereby granted,
* provided that both the copyright notice and this
* permission notice appear in all copies of the software,
* derivative works or modified versions, and any portions
* thereof, that both notices appear in supporting
* documentation, and that the use of this software is
* acknowledged in any publications resulting from using
* the software.
*
* TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
* SOFTWARE.
*
*/
/* $Id: lane.h,v 1.2 1999/11/21 16:35:11 assar Exp $ */
#ifndef ETHER_ADDR_LEN
#define ETHER_ADDR_LEN 6
#endif
struct lecdatahdr_8023 {
u_short le_header;
u_char h_dest[ETHER_ADDR_LEN];
u_char h_source[ETHER_ADDR_LEN];
u_short h_type;
};

View File

@ -1,4 +1,4 @@
/* @(#) $Header: gnuc.h,v 1.3 95/10/09 02:47:01 leres Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/lbl/gnuc.h,v 1.3.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL) */
/* Define __P() macro, if necessary */
#ifndef __P

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: os-solaris2.h,v 1.18 97/10/01 01:10:22 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/lbl/os-solaris2.h,v 1.18.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL)
*/
/* Prototypes missing in SunOS 5 */

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: os-sunos4.h,v 1.32 96/11/29 15:18:18 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/lbl/os-sunos4.h,v 1.32.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL)
*/
/* Prototypes missing in SunOS 4 */

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: os-ultrix4.h,v 1.19 96/11/29 15:33:19 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/lbl/os-ultrix4.h,v 1.19.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL)
*/
/* Prototypes missing in Ultrix 4 */

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: llc.h,v 1.6 97/06/13 02:06:07 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.6.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
*/
/*

View File

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: machdep.c,v 1.4 97/09/30 15:03:53 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.5 1999/11/21 09:36:47 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: machdep.h,v 1.1 96/07/15 18:33:19 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.1.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
*/
#ifndef tcpdump_machdep_h
#define tcpdump_machdep_h

View File

@ -2,6 +2,7 @@
#
# Copyright (c) 1990, 1996, by John Robert LoVerso.
# All rights reserved.
# SMIv2 parsing copyright (c) 1999 by William C. Fenner.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
@ -13,8 +14,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#) $Id: makemib,v 2.1 90/07/10 23:51:54 loverso Exp Locker: loverso $ (jlv
)
# @(#) $Id: makemib,v 1.2 1999/11/21 17:24:15 fenner Exp $ (jlv)
#
# This script will read either ASN.1-style MIB files or the ".defs" files
@ -42,15 +42,9 @@ cat << EOF
EOF
# use sed to make the ASN.1 easier to parse
# I should really just use a recursive descent parser in awk, but...
sed \
-e 's/--\*.*\*--//' \
-e 's/--.*//' \
-e 's/\([{}]\)/ \1 /g' \
$@ \
| gawk '
awk '
BEGIN {
debug=0;
# for sanity, we prep the namespace with objects from RFC-1155
# (we manually establish the root)
oid["iso"]=1
@ -59,10 +53,13 @@ BEGIN {
oidadd("internet", "dod", 1)
oidadd("directory", "internet", 1)
oidadd("mgmt", "internet", 2)
oidadd("mib", "mgmt", 1)
#XXX oidadd("mib", "mgmt", 1)
oidadd("mib-2", "mgmt", 1)
oidadd("experimental", "internet", 3)
oidadd("private", "internet", 4)
oidadd("enterprises", "private", 1)
oidadd("ip", "mib-2", 4)
oidadd("transmission", "mib-2", 10)
holddesc="none"
}
@ -72,30 +69,82 @@ BEGIN {
# its simple and straightforward output. It would not be too hard to make
# tcpdump directly read mosy output, but...
#
# Ignore these unless the current file is called something.defs; false
# positives are too common in DESCRIPTIONs.
NF > 1 && index($2,".")>0 {
NF > 1 && index($2,".")>0 && FILENAME ~ /\.defs/ {
# currently ignore items of the form "{ iso.3.6.1 }"
if (split($2, p, ".") == 2)
if (split($2, p, ".") == 2) {
oidadd($1, p[1], p[2])
}
next
}
#
# this next section is simple and naive, but does the job 100%
# Must be a MIB file
# Make it easier to parse - used to be done by sed
{ sub(/--\*.*\*--/, ""); sub(/--.*/, ""); gsub(/[{}]/, " & "); }
#
# this next section is simple and naive, but does the job ok
#
# foo OBJECT IDENTIFIER ::= { baz 17 }
# or
# foo OBJECT IDENTIFIER ::=
# { baz 17 }
$2$3$4 == "OBJECTIDENTIFIER::=" {
holddesc="none"
if (NF == 8)
oidadd($1, $6, $7)
if (NF == 4)
holddesc=$1
next
}
$2 == "OBJECT-TYPE" {
$1 == "{" && holddesc != "none" && NF == 4 {
oidadd(holddesc, $2, $3)
holddesc="none"
}
#
# foo OBJECT IDENTIFIER
# ::= { bar 1 }
$2$3 == "OBJECTIDENTIFIER" && $1 != "SYNTAX" && NF == 3 {
holddesc=$1
}
#
# foo
# OBJECT IDENTIFIER ::= { bar 1 }
# a couple of heuristics to exclude single words in e.g. long
# DESCRIPTION clauses
NF == 1 && $1 ~ "[a-z][a-z]*[A-Z]" && $1 !~ /[(){}.,]/ && holddesc == "none" {
holddesc=$1
}
$1$2$3 == "OBJECTIDENTIFIER::=" && holddesc != "none" {
oidadd(holddesc, $5, $6)
holddesc="none"
}
#
# "normal" style
# foo OBJECT-TYPE ...
# ...
# ::= { baz 5 }
$2 == "MODULE-IDENTITY" || $2 == "MODULE-COMPLIANCE" ||
$2 == "OBJECT-IDENTITY" || $2 == "OBJECT-TYPE" ||
$2 == "OBJECT-GROUP" ||
$2 == "NOTIFICATION-TYPE" || $2 == "NOTIFICATION-GROUP" {
holddesc=$1
}
$1 == "::=" && holddesc != "none" && NF == 5 {
oidadd(holddesc, $3, $4)
holddesc="none"
}
#
# foo ::= { baz 17 }
$2$3 == "::={" {
oidadd($1,$4,$5)
holddesc="none"
}
#
# End of the road - output the data.
@ -107,6 +156,12 @@ END {
print "*mibroot = &_iso_obj;"
}
function inn(file) {
if (file == "" || file == "-")
return ""
return " in " file
}
#
# add a new object to the tree
#
@ -114,28 +169,36 @@ END {
#
function oidadd(new, parent, value) {
# Ignore 0.0
if (parent == "0" && value == 0)
return
if (debug)
print "/* oidadd" inn(FILENAME) ":", new, "in", parent, "as", value, "line", $0, "*/"
# use safe C identifiers
gsub(/[-&\/]/,"",new)
gsub(/[-&\/]/,"",parent)
# check if parent missing
if (oid[parent] == 0) {
printf "/* parse problem: no parent for %s.%s(%d) */\n", \
parent, new, value
if (oid[parent] == "") {
printf "/* parse problem%s: no parent for %s.%s(%d) */\n", \
inn(FILENAME), parent, new, value
return
}
# check if parent.value already exists
if (oid[new] > 0 && oid[new] != value) {
printf "/* parse problem: dup %s.%s(%d) != old (%d) */\n", \
parent, new, value, oid[new]
printf "/* parse problem%s: dup %s.%s(%d) != old (%d) */\n", \
inn(FILENAME), parent, new, value, oid[new]
return
}
# check for new name for parent.value
if (child[parent] != "") {
for (sib = child[parent]; sib != ""; sib = sibling[sib])
if (oid[sib] == value) {
printf "/* parse problem: new name \"%s\"" \
" for %s.%s(%d) ignored */\n", \
new, parent, sib, value
if (new != sib)
printf "/* parse problem%s: new name" \
" \"%s\"" \
" for %s.%s(%d) ignored */\n", \
inn(FILENAME), new, parent, \
sib, value
return
}
}
@ -169,5 +232,5 @@ function dump(item, c, s) {
printf "_%s_obj = {\n\t\"%s\", %d, 0,\n\t%s, %s\n},\n", \
item, item, oid[item], c, s
}
'
' $@
exit 0

View File

@ -1217,6 +1217,202 @@ _snmp_obj = {
"snmp", 11, 0,
&_snmpEnableAuthTraps_obj, &_transmission_obj
},
_usmMIBCompliances_obj = {
"usmMIBCompliances", 1, 0,
NULL, NULL
},
_usmMIBGroups_obj = {
"usmMIBGroups", 2, 0,
NULL, &_usmMIBCompliances_obj
},
_usmUserEngineID_obj = {
"usmUserEngineID", 1, 0,
NULL, NULL
},
_usmUserName_obj = {
"usmUserName", 2, 0,
NULL, &_usmUserEngineID_obj
},
_usmUserSecurityName_obj = {
"usmUserSecurityName", 3, 0,
NULL, &_usmUserName_obj
},
_usmUserCloneFrom_obj = {
"usmUserCloneFrom", 4, 0,
NULL, &_usmUserSecurityName_obj
},
_usmUserAuthProtocol_obj = {
"usmUserAuthProtocol", 5, 0,
NULL, &_usmUserCloneFrom_obj
},
_usmUserAuthKeyChange_obj = {
"usmUserAuthKeyChange", 6, 0,
NULL, &_usmUserAuthProtocol_obj
},
_usmUserOwnAuthKeyChange_obj = {
"usmUserOwnAuthKeyChange", 7, 0,
NULL, &_usmUserAuthKeyChange_obj
},
_usmUserPrivProtocol_obj = {
"usmUserPrivProtocol", 8, 0,
NULL, &_usmUserOwnAuthKeyChange_obj
},
_usmUserPrivKeyChange_obj = {
"usmUserPrivKeyChange", 9, 0,
NULL, &_usmUserPrivProtocol_obj
},
_usmUserOwnPrivKeyChange_obj = {
"usmUserOwnPrivKeyChange", 10, 0,
NULL, &_usmUserPrivKeyChange_obj
},
_usmUserPublic_obj = {
"usmUserPublic", 11, 0,
NULL, &_usmUserOwnPrivKeyChange_obj
},
_usmUserStorageType_obj = {
"usmUserStorageType", 12, 0,
NULL, &_usmUserPublic_obj
},
_usmUserStatus_obj = {
"usmUserStatus", 13, 0,
NULL, &_usmUserStorageType_obj
},
_usmUserEntry_obj = {
"usmUserEntry", 1, 0,
&_usmUserStatus_obj, NULL
},
_usmUserSpinLock_obj = {
"usmUserSpinLock", 1, 0,
NULL, NULL
},
_usmUserTable_obj = {
"usmUserTable", 2, 0,
&_usmUserEntry_obj, &_usmUserSpinLock_obj
},
_usmStatsUnsupportedSecLevels_obj = {
"usmStatsUnsupportedSecLevels", 1, 0,
NULL, NULL
},
_usmStatsNotInTimeWindows_obj = {
"usmStatsNotInTimeWindows", 2, 0,
NULL, &_usmStatsUnsupportedSecLevels_obj
},
_usmStatsUnknownUserNames_obj = {
"usmStatsUnknownUserNames", 3, 0,
NULL, &_usmStatsNotInTimeWindows_obj
},
_usmStatsUnknownEngineIDs_obj = {
"usmStatsUnknownEngineIDs", 4, 0,
NULL, &_usmStatsUnknownUserNames_obj
},
_usmStatsWrongDigests_obj = {
"usmStatsWrongDigests", 5, 0,
NULL, &_usmStatsUnknownEngineIDs_obj
},
_usmStatsDecryptionErrors_obj = {
"usmStatsDecryptionErrors", 6, 0,
NULL, &_usmStatsWrongDigests_obj
},
_usmStats_obj = {
"usmStats", 1, 0,
&_usmStatsDecryptionErrors_obj, NULL
},
_usmUser_obj = {
"usmUser", 2, 0,
&_usmUserTable_obj, &_usmStats_obj
},
_usmMIBObjects_obj = {
"usmMIBObjects", 1, 0,
&_usmUser_obj, NULL
},
_usmMIBConformance_obj = {
"usmMIBConformance", 2, 0,
&_usmMIBGroups_obj, &_usmMIBObjects_obj
},
_snmpMPDMIBCompliances_obj = {
"snmpMPDMIBCompliances", 1, 0,
NULL, NULL
},
_snmpMPDMIBGroups_obj = {
"snmpMPDMIBGroups", 2, 0,
NULL, &_snmpMPDMIBCompliances_obj
},
_snmpUnknownSecurityModels_obj = {
"snmpUnknownSecurityModels", 1, 0,
NULL, NULL
},
_snmpInvalidMsgs_obj = {
"snmpInvalidMsgs", 2, 0,
NULL, &_snmpUnknownSecurityModels_obj
},
_snmpUnknownPDUHandlers_obj = {
"snmpUnknownPDUHandlers", 3, 0,
NULL, &_snmpInvalidMsgs_obj
},
_snmpMPDStats_obj = {
"snmpMPDStats", 1, 0,
&_snmpUnknownPDUHandlers_obj, NULL
},
_snmpMPDAdmin_obj = {
"snmpMPDAdmin", 1, 0,
NULL, NULL
},
_snmpMPDMIBObjects_obj = {
"snmpMPDMIBObjects", 2, 0,
&_snmpMPDStats_obj, &_snmpMPDAdmin_obj
},
_snmpMPDMIBConformance_obj = {
"snmpMPDMIBConformance", 3, 0,
&_snmpMPDMIBGroups_obj, &_snmpMPDMIBObjects_obj
},
_snmpEngineID_obj = {
"snmpEngineID", 1, 0,
NULL, NULL
},
_snmpEngineBoots_obj = {
"snmpEngineBoots", 2, 0,
NULL, &_snmpEngineID_obj
},
_snmpEngineTime_obj = {
"snmpEngineTime", 3, 0,
NULL, &_snmpEngineBoots_obj
},
_snmpEngineMaxMessageSize_obj = {
"snmpEngineMaxMessageSize", 4, 0,
NULL, &_snmpEngineTime_obj
},
_snmpEngine_obj = {
"snmpEngine", 1, 0,
&_snmpEngineMaxMessageSize_obj, NULL
},
_snmpFrameworkAdmin_obj = {
"snmpFrameworkAdmin", 1, 0,
NULL, NULL
},
_snmpFrameworkMIBObjects_obj = {
"snmpFrameworkMIBObjects", 2, 0,
&_snmpEngine_obj, &_snmpFrameworkAdmin_obj
},
_snmpFrameworkMIBConformance_obj = {
"snmpFrameworkMIBConformance", 3, 0,
NULL, &_snmpFrameworkMIBObjects_obj
},
_snmpFrameworkMIB_obj = {
"snmpFrameworkMIB", 10, 0,
&_snmpFrameworkMIBConformance_obj, NULL
},
_snmpMPDMIB_obj = {
"snmpMPDMIB", 11, 0,
&_snmpMPDMIBConformance_obj, &_snmpFrameworkMIB_obj
},
_snmpUsmMIB_obj = {
"snmpUsmMIB", 15, 0,
&_usmMIBConformance_obj, &_snmpMPDMIB_obj
},
_snmpModules_obj = {
"snmpModules", 3, 0,
&_snmpUsmMIB_obj, NULL
},
_mib_obj = {
"mib", 1, 0,
&_snmp_obj, NULL
@ -1237,9 +1433,17 @@ _private_obj = {
"private", 4, 0,
&_enterprises_obj, &_experimental_obj
},
_security_obj = {
"security", 5, 0,
NULL, &_private_obj
},
_snmpV2_obj = {
"snmpV2", 6, 0,
&_snmpModules_obj, &_security_obj
},
_internet_obj = {
"internet", 1, 0,
&_private_obj, NULL
&_snmpV2_obj, NULL
},
_dod_obj = {
"dod", 6, 0,

View File

@ -0,0 +1,122 @@
/*
* 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.
*/
/* $Id: addrinfo.h,v 1.2 1999/11/21 01:35:41 assar Exp $ */
#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)
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 */
/*
* Constants for getnameinfo()
*/
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
#ifndef NI_MAXSERV
#define NI_MAXSERV 32
#endif
/*
* Flag values for getnameinfo()
*/
#ifndef NI_NOFQDN
#define NI_NOFQDN 0x00000001
#endif
#ifndef NI_NUMERICHOST
#define NI_NUMERICHOST 0x00000002
#endif
#ifndef NI_NAMEREQD
#define NI_NAMEREQD 0x00000004
#endif
#ifndef NI_NUMERICSERV
#define NI_NUMERICSERV 0x00000008
#endif
#ifndef NI_DGRAM
#define NI_DGRAM 0x00000010
#endif

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

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

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,285 @@
/*
* 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().
* - RFC2553 says that we should raise error on short buffer. X/Open says
* we need to truncate the result. We obey RFC2553 (and X/Open should be
* modified).
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.3.2.2 2000/01/25 18:39:03 itojun Exp $";
#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>
#include <errno.h>
#ifndef HAVE_PORTABLE_PROTOTYPE
#include "cdecl_ext.h"
#endif
#ifdef NEED_ADDRINFO_H
#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_int32_t 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) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC2553 says that serv == NULL OR servlen == 0
* means that the caller does not want the result.
*/
} 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 {
sprintf(numserv, "%d", ntohs(port));
if (strlen(numserv) > servlen)
return ENI_MEMORY;
strcpy(serv, numserv);
}
}
switch (sa->sa_family) {
case AF_INET:
v4a = (u_int32_t)
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)
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) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC2553 says that host == NULL OR hostlen == 0
* means that the caller does not want the result.
*/
} 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);
#if defined(INET6) && defined(NI_WITHSCOPEID)
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);
#ifdef HAVE_H_ERRNO
h_error = h_errno;
#else
h_error = EINVAL;
#endif
#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;
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
*/
/* $Id: inet_aton.c,v 1.1.2.1 2000/01/11 06:58:29 fenner Exp $ */
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.1.2.1 2000/01/11 06:58:29 fenner Exp $";
#endif
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
/* Minimal implementation of inet_aton.
* Cannot distinguish between failure and a local broadcast address. */
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
int
inet_aton(const char *cp, struct in_addr *addr)
{
addr->s_addr = inet_addr(cp);
return (addr->s_addr == INADDR_NONE) ? 0 : 1;
}

View File

@ -0,0 +1,105 @@
/*
* Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
*/
/* $Id: inet_ntop.c,v 1.2.2.1 2000/01/11 06:58:30 fenner Exp $ */
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.2.2.1 2000/01/11 06:58:30 fenner Exp $";
#endif
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
/*
*
*/
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
static const char *
inet_ntop_v4 (const void *src, char *dst, size_t size)
{
const char digits[] = "0123456789";
int i;
struct in_addr *addr = (struct in_addr *)src;
u_long a = ntohl(addr->s_addr);
const char *orig_dst = dst;
if (size < INET_ADDRSTRLEN) {
errno = ENOSPC;
return NULL;
}
for (i = 0; i < 4; ++i) {
int n = (a >> (24 - i * 8)) & 0xFF;
int non_zerop = 0;
if (non_zerop || n / 100 > 0) {
*dst++ = digits[n / 100];
n %= 100;
non_zerop = 1;
}
if (non_zerop || n / 10 > 0) {
*dst++ = digits[n / 10];
n %= 10;
non_zerop = 1;
}
*dst++ = digits[n];
if (i != 3)
*dst++ = '.';
}
*dst++ = '\0';
return orig_dst;
}
const char *
inet_ntop(int af, const void *src, char *dst, size_t size)
{
switch (af) {
case AF_INET :
return inet_ntop_v4 (src, dst, size);
default :
errno = EAFNOSUPPORT;
return NULL;
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
*/
/* $Id: inet_pton.c,v 1.1.2.1 2000/01/11 06:58:30 fenner Exp $ */
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.1.2.1 2000/01/11 06:58:30 fenner Exp $";
#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int
inet_pton(int af, const char *src, void *dst)
{
if (af != AF_INET) {
errno = EAFNOSUPPORT;
return -1;
}
return inet_aton (src, dst);
}

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

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;

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

View File

@ -1,7 +1,7 @@
/*
* NETBIOS protocol formats
*
* @(#) $Header: netbios.h,v 1.1 94/06/09 11:47:15 mccanne Exp $
* @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.1.1.1 1999/10/07 23:47:10 mcr Exp $
*/
struct p8022Hdr {

452
contrib/tcpdump/nfs.h Normal file
View File

@ -0,0 +1,452 @@
/* $NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* 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 University of
* California, Berkeley and its contributors.
* 4. 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 BY THE REGENTS 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 REGENTS 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.
*
* @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
*/
/*
* nfs definitions as per the Version 2 and 3 specs
*/
/*
* Constants as defined in the Sun NFS Version 2 and 3 specs.
* "NFS: Network File System Protocol Specification" RFC1094
* and in the "NFS: Network File System Version 3 Protocol
* Specification"
*/
#define NFS_PORT 2049
#define NFS_PROG 100003
#define NFS_VER2 2
#define NFS_VER3 3
#define NFS_V2MAXDATA 8192
#define NFS_MAXDGRAMDATA 16384
#define NFS_MAXDATA 32768
#define NFS_MAXPATHLEN 1024
#define NFS_MAXNAMLEN 255
#define NFS_MAXPKTHDR 404
#define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA)
#define NFS_MINPACKET 20
#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
/* Stat numbers for rpc returns (version 2 and 3) */
#define NFS_OK 0
#define NFSERR_PERM 1
#define NFSERR_NOENT 2
#define NFSERR_IO 5
#define NFSERR_NXIO 6
#define NFSERR_ACCES 13
#define NFSERR_EXIST 17
#define NFSERR_XDEV 18 /* Version 3 only */
#define NFSERR_NODEV 19
#define NFSERR_NOTDIR 20
#define NFSERR_ISDIR 21
#define NFSERR_INVAL 22 /* Version 3 only */
#define NFSERR_FBIG 27
#define NFSERR_NOSPC 28
#define NFSERR_ROFS 30
#define NFSERR_MLINK 31 /* Version 3 only */
#define NFSERR_NAMETOL 63
#define NFSERR_NOTEMPTY 66
#define NFSERR_DQUOT 69
#define NFSERR_STALE 70
#define NFSERR_REMOTE 71 /* Version 3 only */
#define NFSERR_WFLUSH 99 /* Version 2 only */
#define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */
#define NFSERR_NOT_SYNC 10002
#define NFSERR_BAD_COOKIE 10003
#define NFSERR_NOTSUPP 10004
#define NFSERR_TOOSMALL 10005
#define NFSERR_SERVERFAULT 10006
#define NFSERR_BADTYPE 10007
#define NFSERR_JUKEBOX 10008
#define NFSERR_TRYLATER NFSERR_JUKEBOX
#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
#define NFSERR_RETVOID 0x20000000 /* Return void, not error */
#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */
#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
/* Sizes in bytes of various nfs rpc components */
#define NFSX_UNSIGNED 4
/* specific to NFS Version 2 */
#define NFSX_V2FH 32
#define NFSX_V2FATTR 68
#define NFSX_V2SATTR 32
#define NFSX_V2COOKIE 4
#define NFSX_V2STATFS 20
/* specific to NFS Version 3 */
#if 0
#define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */
#endif
#define NFSX_V3FHMAX 64 /* max. allowed by protocol */
#define NFSX_V3FATTR 84
#define NFSX_V3SATTR 60 /* max. all fields filled in */
#define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr))
#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
#define NFSX_V3COOKIEVERF 8
#define NFSX_V3WRITEVERF 8
#define NFSX_V3CREATEVERF 8
#define NFSX_V3STATFS 52
#define NFSX_V3FSINFO 48
#define NFSX_V3PATHCONF 24
/* variants for both versions */
#define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \
NFSX_V2FH)
#define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH)
#define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR)
#define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0)
#define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
#define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \
NFSX_V2FATTR)
#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0)
#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0)
#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0)
#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \
(2 * NFSX_UNSIGNED))
#define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
/* nfs rpc procedure numbers (before version mapping) */
#define NFSPROC_NULL 0
#define NFSPROC_GETATTR 1
#define NFSPROC_SETATTR 2
#define NFSPROC_LOOKUP 3
#define NFSPROC_ACCESS 4
#define NFSPROC_READLINK 5
#define NFSPROC_READ 6
#define NFSPROC_WRITE 7
#define NFSPROC_CREATE 8
#define NFSPROC_MKDIR 9
#define NFSPROC_SYMLINK 10
#define NFSPROC_MKNOD 11
#define NFSPROC_REMOVE 12
#define NFSPROC_RMDIR 13
#define NFSPROC_RENAME 14
#define NFSPROC_LINK 15
#define NFSPROC_READDIR 16
#define NFSPROC_READDIRPLUS 17
#define NFSPROC_FSSTAT 18
#define NFSPROC_FSINFO 19
#define NFSPROC_PATHCONF 20
#define NFSPROC_COMMIT 21
/* And leasing (nqnfs) procedure numbers (must be last) */
#define NQNFSPROC_GETLEASE 22
#define NQNFSPROC_VACATED 23
#define NQNFSPROC_EVICTED 24
#define NFSPROC_NOOP 25
#define NFS_NPROCS 26
/* Actual Version 2 procedure numbers */
#define NFSV2PROC_NULL 0
#define NFSV2PROC_GETATTR 1
#define NFSV2PROC_SETATTR 2
#define NFSV2PROC_NOOP 3
#define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */
#define NFSV2PROC_LOOKUP 4
#define NFSV2PROC_READLINK 5
#define NFSV2PROC_READ 6
#define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */
#define NFSV2PROC_WRITE 8
#define NFSV2PROC_CREATE 9
#define NFSV2PROC_REMOVE 10
#define NFSV2PROC_RENAME 11
#define NFSV2PROC_LINK 12
#define NFSV2PROC_SYMLINK 13
#define NFSV2PROC_MKDIR 14
#define NFSV2PROC_RMDIR 15
#define NFSV2PROC_READDIR 16
#define NFSV2PROC_STATFS 17
/*
* Constants used by the Version 3 protocol for various RPCs
*/
#define NFSV3SATTRTIME_DONTCHANGE 0
#define NFSV3SATTRTIME_TOSERVER 1
#define NFSV3SATTRTIME_TOCLIENT 2
#define NFSV3ATTRTIME_NMODES 3
#define NFSV3ACCESS_READ 0x01
#define NFSV3ACCESS_LOOKUP 0x02
#define NFSV3ACCESS_MODIFY 0x04
#define NFSV3ACCESS_EXTEND 0x08
#define NFSV3ACCESS_DELETE 0x10
#define NFSV3ACCESS_EXECUTE 0x20
#define NFSV3WRITE_UNSTABLE 0
#define NFSV3WRITE_DATASYNC 1
#define NFSV3WRITE_FILESYNC 2
#define NFSV3WRITE_NMODES 3
#define NFSV3CREATE_UNCHECKED 0
#define NFSV3CREATE_GUARDED 1
#define NFSV3CREATE_EXCLUSIVE 2
#define NFSV3CREATE_NMODES 3
#define NFSV3FSINFO_LINK 0x01
#define NFSV3FSINFO_SYMLINK 0x02
#define NFSV3FSINFO_HOMOGENEOUS 0x08
#define NFSV3FSINFO_CANSETTIME 0x10
/* Conversion macros */
#define vtonfsv2_mode(t,m) \
txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
MAKEIMODE((t), (m)))
#define vtonfsv3_mode(m) txdr_unsigned((m) & 07777)
#define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&07777)
#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))])
#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))])
#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
/* File types */
typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
NFSOCK=6, NFFIFO=7 } nfstype;
/* Structs for common parts of the rpc's */
/*
* File Handle (32 bytes for version 2), variable up to 64 for version 3.
* File Handles of up to NFS_SMALLFH in size are stored directly in the
* nfs node, whereas larger ones are malloc'd. (This never happens when
* NFS_SMALLFH is set to 64.)
* NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
*/
#ifndef NFS_SMALLFH
#define NFS_SMALLFH 64
#endif
union nfsfh {
/* fhandle_t fh_generic; */
u_char fh_bytes[NFS_SMALLFH];
};
typedef union nfsfh nfsfh_t;
struct nfsv2_time {
u_int32_t nfsv2_sec;
u_int32_t nfsv2_usec;
};
typedef struct nfsv2_time nfstime2;
struct nfsv3_time {
u_int32_t nfsv3_sec;
u_int32_t nfsv3_nsec;
};
typedef struct nfsv3_time nfstime3;
/*
* Quads are defined as arrays of 2 longs to ensure dense packing for the
* protocol and to facilitate xdr conversion.
*/
struct nfs_uquad {
u_int32_t nfsuquad[2];
};
typedef struct nfs_uquad nfsuint64;
#if 0 /* XXX - this doesn't seemed to be used and it doesn't work
* with non-gcc, so comment it out for now.
*/
/*
* Used to convert between two u_longs and a u_quad_t.
*/
union nfs_quadconvert {
u_int32_t lval[2];
u_quad_t qval;
};
typedef union nfs_quadconvert nfsquad_t;
#endif
/*
* NFS Version 3 special file number.
*/
struct nfsv3_spec {
u_int32_t specdata1;
u_int32_t specdata2;
};
typedef struct nfsv3_spec nfsv3spec;
/*
* File attributes and setable attributes. These structures cover both
* NFS version 2 and the version 3 protocol. Note that the union is only
* used so that one pointer can refer to both variants. These structures
* go out on the wire and must be densely packed, so no quad data types
* are used. (all fields are longs or u_longs or structures of same)
* NB: You can't do sizeof(struct nfs_fattr), you must use the
* NFSX_FATTR(v3) macro.
*/
struct nfs_fattr {
u_int32_t fa_type;
u_int32_t fa_mode;
u_int32_t fa_nlink;
u_int32_t fa_uid;
u_int32_t fa_gid;
union {
struct {
u_int32_t nfsv2fa_size;
u_int32_t nfsv2fa_blocksize;
u_int32_t nfsv2fa_rdev;
u_int32_t nfsv2fa_blocks;
u_int32_t nfsv2fa_fsid;
u_int32_t nfsv2fa_fileid;
nfstime2 nfsv2fa_atime;
nfstime2 nfsv2fa_mtime;
nfstime2 nfsv2fa_ctime;
} fa_nfsv2;
struct {
nfsuint64 nfsv3fa_size;
nfsuint64 nfsv3fa_used;
nfsv3spec nfsv3fa_rdev;
nfsuint64 nfsv3fa_fsid;
nfsuint64 nfsv3fa_fileid;
nfstime3 nfsv3fa_atime;
nfstime3 nfsv3fa_mtime;
nfstime3 nfsv3fa_ctime;
} fa_nfsv3;
} fa_un;
};
/* and some ugly defines for accessing union components */
#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size
#define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize
#define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev
#define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks
#define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid
#define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid
#define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime
#define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime
#define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime
#define fa3_size fa_un.fa_nfsv3.nfsv3fa_size
#define fa3_used fa_un.fa_nfsv3.nfsv3fa_used
#define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev
#define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid
#define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid
#define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime
#define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime
#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime
struct nfsv2_sattr {
u_int32_t sa_mode;
u_int32_t sa_uid;
u_int32_t sa_gid;
u_int32_t sa_size;
nfstime2 sa_atime;
nfstime2 sa_mtime;
};
/*
* NFS Version 3 sattr structure for the new node creation case.
*/
struct nfsv3_sattr {
u_int32_t sa_modeset;
u_int32_t sa_mode;
u_int32_t sa_uidset;
u_int32_t sa_uid;
u_int32_t sa_gidset;
u_int32_t sa_gid;
u_int32_t sa_sizeset;
u_int32_t sa_size;
u_int32_t sa_atimetype;
nfstime3 sa_atime;
u_int32_t sa_mtimetype;
nfstime3 sa_mtime;
};
struct nfs_statfs {
union {
struct {
u_int32_t nfsv2sf_tsize;
u_int32_t nfsv2sf_bsize;
u_int32_t nfsv2sf_blocks;
u_int32_t nfsv2sf_bfree;
u_int32_t nfsv2sf_bavail;
} sf_nfsv2;
struct {
nfsuint64 nfsv3sf_tbytes;
nfsuint64 nfsv3sf_fbytes;
nfsuint64 nfsv3sf_abytes;
nfsuint64 nfsv3sf_tfiles;
nfsuint64 nfsv3sf_ffiles;
nfsuint64 nfsv3sf_afiles;
u_int32_t nfsv3sf_invarsec;
} sf_nfsv3;
} sf_un;
};
#define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize
#define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize
#define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks
#define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree
#define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail
#define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes
#define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes
#define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes
#define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles
#define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles
#define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles
#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec
struct nfsv3_fsinfo {
u_int32_t fs_rtmax;
u_int32_t fs_rtpref;
u_int32_t fs_rtmult;
u_int32_t fs_wtmax;
u_int32_t fs_wtpref;
u_int32_t fs_wtmult;
u_int32_t fs_dtpref;
nfsuint64 fs_maxfilesize;
nfstime3 fs_timedelta;
u_int32_t fs_properties;
};
struct nfsv3_pathconf {
u_int32_t pc_linkmax;
u_int32_t pc_namemax;
u_int32_t pc_notrunc;
u_int32_t pc_chownrestricted;
u_int32_t pc_caseinsensitive;
u_int32_t pc_casepreserving;
};

View File

@ -1,12 +1,12 @@
/*
* $Header: nfsfh.h,v 1.6 96/12/16 03:40:31 leres Exp $
* $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.8 1999/12/15 06:49:05 fenner Exp $
*
* nfsfh.h - NFS file handle definitions (for portable use)
*
* Jeffrey C. Mogul
* Digital Equipment Corporation
* Western Research Laboratory
*/
* $NetBSD: nfsfh.h,v 1.1.1.2 1997/10/03 17:25:13 christos Exp $ */
/*
* Internal representation of dev_t, because different NFS servers
@ -31,4 +31,4 @@ typedef struct {
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
dev_eq(a.Fsid_dev, b.Fsid_dev))
extern void Parse_fh(caddr_t *, my_fsid *, ino_t *, char **, char **, int);
extern void Parse_fh(caddr_t *, int, my_fsid *, ino_t *, char **, char **, int);

View File

@ -1,4 +1,4 @@
/* $Header: ntp.h,v 1.3 95/05/04 17:52:49 mccanne Exp $ */
/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.3.1.1 1999/10/07 23:47:11 mcr Exp $ */
/*
* Based on ntp.h from the U of MD implementation

126
contrib/tcpdump/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
contrib/tcpdump/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

@ -9,7 +9,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: parsenfsfh.c,v 1.14 97/06/15 13:20:27 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.16 1999/11/21 09:36:47 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
@ -77,8 +81,9 @@ static const char rcsid[] =
static int is_UCX(unsigned char *);
void
Parse_fh(fh, fsidp, inop, osnamep, fsnamep, ourself)
Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself)
register caddr_t *fh;
int len;
my_fsid *fsidp;
ino_t *inop;
char **osnamep; /* if non-NULL, return OS name here */

View File

@ -1,4 +1,4 @@
/* @(#) $Header: ppp.h,v 1.7 95/05/04 17:52:46 mccanne Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.8 1999/11/21 03:43:56 assar Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
@ -48,3 +48,4 @@
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
#define PPP_LQM 0xc025 /* Link Quality Monitoring */
#define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */
extern struct tok ppptype2str[];

103
contrib/tcpdump/print-ah.c Normal file
View File

@ -0,0 +1,103 @@
/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
/*
* 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[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.5 1999/12/15 08:10:17 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#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>
/* 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"
int
ah_print(register const u_char *bp, register const u_char *bp2)
{
register const struct ah *ah;
register const u_char *ep;
int sumlen;
u_int32_t spi;
ah = (struct ah *)bp;
ep = snapend; /* 'ep' points to the end of avaible data. */
if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
goto trunc;
sumlen = ah->ah_len << 2;
spi = (u_int32_t)ntohl(ah->ah_spi);
printf("AH(spi=%u", spi);
if (vflag)
printf(",sumlen=%d", sumlen);
printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));
if (bp + sizeof(struct ah) + sumlen > ep)
fputs("[truncated]", stdout);
fputs("): ", stdout);
return sizeof(struct ah) + sumlen;
trunc:
fputs("[|AH]", stdout);
return 65535;
}

View File

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-arp.c,v 1.43 97/06/15 13:20:27 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.44 1999/11/21 09:36:48 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>

View File

@ -0,0 +1,158 @@
/* $NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Alan Barrett and Simon J. Gerraty.
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.2.2.2 2000/01/11 06:58:23 fenner Exp $";
#endif
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
#include "interface.h"
#define HEXDUMP_BYTES_PER_LINE 16
#define HEXDUMP_SHORTS_PER_LINE (HEXDUMP_BYTES_PER_LINE / 2)
#define HEXDUMP_HEXSTUFF_PER_SHORT 5 /* 4 hex digits and a space */
#define HEXDUMP_HEXSTUFF_PER_LINE \
(HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
void
ascii_print_with_offset(register const u_char *cp, register u_int length,
register u_int oset)
{
register u_int i;
register int s1, s2;
register int nshorts;
char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
char asciistuff[HEXDUMP_BYTES_PER_LINE+1], *asp;
nshorts = length / sizeof(u_short);
i = 0;
hsp = hexstuff; asp = asciistuff;
while (--nshorts >= 0) {
s1 = *cp++;
s2 = *cp++;
(void)sprintf(hsp, " %02x%02x", s1, s2);
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
*(asp++) = (isgraph(s1) ? s1 : '.');
*(asp++) = (isgraph(s2) ? s2 : '.');
if (++i >= HEXDUMP_SHORTS_PER_LINE) {
*hsp = *asp = '\0';
(void)printf("\n0x%04x\t%-*s\t%s",
oset, HEXDUMP_HEXSTUFF_PER_LINE,
hexstuff, asciistuff);
i = 0; hsp = hexstuff; asp = asciistuff;
oset += HEXDUMP_BYTES_PER_LINE;
}
}
if (length & 1) {
s1 = *cp++;
(void)sprintf(hsp, " %02x", s1);
hsp += 3;
*(asp++) = (isgraph(s1) ? s1 : '.');
++i;
}
if (i > 0) {
*hsp = *asp = '\0';
(void)printf("\n0x%04x\t%-*s\t%s",
oset, HEXDUMP_HEXSTUFF_PER_LINE,
hexstuff, asciistuff);
}
}
void
ascii_print(register const u_char *cp, register u_int length)
{
ascii_print_with_offset(cp, length, 0);
}
/*
* telnet_print() wants this. It is essentially default_print_unaligned()
*/
void
hex_print_with_offset(register const u_char *cp, register u_int length,
register u_int oset)
{
register u_int i, s;
register int nshorts;
nshorts = (u_int) length / sizeof(u_short);
i = 0;
while (--nshorts >= 0) {
if ((i++ % 8) == 0) {
(void)printf("\n0x%04x\t", oset);
oset += HEXDUMP_BYTES_PER_LINE;
}
s = *cp++;
(void)printf(" %02x%02x", s, *cp++);
}
if (length & 1) {
if ((i % 8) == 0)
(void)printf("\n0x%04x\t", oset);
(void)printf(" %02x", *cp);
}
}
/*
* just for completeness
*/
void
hex_print(register const u_char *cp, register u_int length)
{
hex_print_with_offset(cp, length, 0);
}
#ifdef MAIN
int
main(int argc, char *argv[])
{
hex_print("Hello, World!\n", 14);
printf("\n");
ascii_print("Hello, World!\n", 14);
printf("\n");
#define TMSG "Now is the winter of our discontent...\n"
ascii_print_with_offset(TMSG, sizeof(TMSG) - 1, 0x100);
printf("\n");
exit(0);
}
#endif /* MAIN */

View File

@ -23,7 +23,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-atalk.c,v 1.48 97/05/28 12:50:58 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.51 1999/11/21 09:36:48 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -44,7 +48,6 @@ struct rtentry;
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -20,7 +20,11 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-atm.c,v 1.9 97/05/28 12:52:40 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.12 1999/11/21 09:36:48 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -41,7 +45,6 @@ struct rtentry;
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <stdio.h>
#include <pcap.h>
@ -106,6 +109,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:

727
contrib/tcpdump/print-bgp.c Normal file
View File

@ -0,0 +1,727 @@
/*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.9.2.2 2000/01/25 18:32:53 itojun Exp $";
#endif
#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 <string.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_opt {
u_int8_t bgpopt_type;
u_int8_t bgpopt_len;
/* variable length */
};
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_COMMUNITIES 8 /* RFC1997 */
#define BGPTYPE_ORIGINATOR_ID 9 /* RFC1998 */
#define BGPTYPE_CLUSTER_LIST 10 /* RFC1998 */
#define BGPTYPE_DPA 11 /* work in progress */
#define BGPTYPE_ADVERTISERS 12 /* RFC1863 */
#define BGPTYPE_RCID_PATH 13 /* RFC1863 */
#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 *bgpopt_type[] = {
NULL, "Authentication Information",
};
#define bgp_opttype(x) \
num_or_str(bgpopt_type, sizeof(bgpopt_type)/sizeof(bgpopt_type[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",
"COMMUNITIES", "ORIGINATOR_ID", "CLUSTER_LIST", "DPA",
"ADVERTISERS", "RCID_PATH", "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))
/* well-known community */
#define BGP_COMMUNITY_NO_EXPORT 0xffffff01
#define BGP_COMMUNITY_NO_ADVERT 0xffffff02
#define BGP_COMMUNITY_NO_EXPORT_SUBCONFED 0xffffff03
/* 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) {
sprintf(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) {
sprintf(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);
}
sprintf(buf, "%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);
}
sprintf(buf, "%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 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;
}
while (p < dat + len) {
/*
* under RFC1965, p[0] means:
* 1: AS_SET 2: AS_SEQUENCE
* 3: AS_CONFED_SET 4: AS_CONFED_SEQUENCE
*/
printf(" ");
if (p[0] == 3 || p[0] == 4)
printf("confed");
printf("%s", (p[0] & 1) ? "{" : "");
for (i = 0; i < p[1]; i += 2) {
printf("%s%u", i == 0 ? "" : " ",
ntohs(*(u_int16_t *)&p[2 + i]));
}
printf("%s", (p[0] & 1) ? "}" : "");
p += 2 + p[1] * 2;
}
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_COMMUNITIES:
if (len % 4) {
printf(" invalid len");
break;
}
for (i = 0; i < len; i += 4) {
u_int32_t comm;
comm = (u_int32_t)ntohl(*(u_int32_t *)&p[i]);
switch (comm) {
case BGP_COMMUNITY_NO_EXPORT:
printf(" NO_EXPORT");
break;
case BGP_COMMUNITY_NO_ADVERT:
printf(" NO_ADVERTISE");
break;
case BGP_COMMUNITY_NO_EXPORT_SUBCONFED:
printf(" NO_EXPORT_SUBCONFED");
break;
default:
printf(" (AS #%d value 0x%04x)",
(comm >> 16) & 0xffff, comm & 0xffff);
break;
}
}
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;
struct bgp_opt bgpopt;
int hlen;
const u_char *opt;
int i;
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);
/* ugly! */
opt = &((struct bgp_open *)dat)->bgpo_optlen;
opt++;
for (i = 0; i < bgpo.bgpo_optlen; i++) {
memcpy(&bgpopt, &opt[i], sizeof(bgpopt));
if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
printf(" [|opt %d %d]", bgpopt.bgpopt_len, bgpopt.bgpopt_type);
break;
}
printf(" (option %s, len=%d)", bgp_opttype(bgpopt.bgpopt_type),
bgpopt.bgpopt_len);
i += sizeof(bgpopt) + bgpopt.bgpopt_len;
}
}
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;
int newline;
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:"); /* ) */
newline = 0;
while (i < 2 + len) {
int alen, aoff;
memcpy(&bgpa, &p[i], sizeof(bgpa));
alen = bgp_attr_len(&bgpa);
aoff = bgp_attr_off(&bgpa);
if (vflag && newline)
printf("\n\t\t");
else
printf(" ");
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);
newline = 1;
/* ( */
printf(")");
i += aoff + alen;
}
/* ( */
printf(")");
}
p += 2 + len;
if (len && dat + length > p)
printf("\n\t\t");
if (dat + length > p) {
printf("(NLRI:"); /* ) */
while (dat + length > p) {
char buf[256];
i = decode_prefix4(p, buf, sizeof(buf));
printf(" %s", buf);
if (i < 0)
break;
p += i;
}
/* ( */
printf(")");
}
}
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)
{
struct bgp bgp;
memcpy(&bgp, dat, sizeof(bgp));
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 *start;
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;
start = p;
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));
if (start != p)
printf(" [|BGP]");
hlen = ntohs(bgp.bgp_len);
if (vflag && newline)
printf("\n\t");
else
printf(" ");
if (TTEST2(p[0], hlen)) {
bgp_header_print(p, hlen);
newline = 1;
p += hlen;
start = p;
} else {
printf("[|BGP %s]", bgp_type(bgp.bgp_type));
break;
}
}
return;
trunc:
printf(" [|BGP]");
}

View File

@ -22,7 +22,11 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-bootp.c,v 1.46 98/07/18 13:33:58 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.48 1999/11/21 09:36:49 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -102,6 +106,8 @@ bootp_print(register const u_char *cp, u_int length,
printf(" xid:0x%x", (u_int32_t)ntohl(bp->bp_xid));
if (bp->bp_secs)
printf(" secs:%d", ntohs(bp->bp_secs));
if (bp->bp_flags)
printf(" flags:0x%x", ntohs(bp->bp_flags));
/* Client's ip address */
TCHECK(bp->bp_ciaddr);
@ -207,6 +213,63 @@ static struct tok tag2str[] = {
{ TAG_SWAP_SERVER, "iSS" },
{ TAG_ROOTPATH, "aRP" },
{ TAG_EXTPATH, "aEP" },
/* RFC2132 tags */
{ TAG_IP_FORWARD, "BIPF" },
{ TAG_NL_SRCRT, "BSRT" },
{ TAG_PFILTERS, "pPF" },
{ TAG_REASS_SIZE, "sRSZ" },
{ TAG_DEF_TTL, "bTTL" },
{ TAG_MTU_TIMEOUT, "lMA" },
{ TAG_MTU_TABLE, "sMT" },
{ TAG_INT_MTU, "sMTU" },
{ TAG_LOCAL_SUBNETS, "BLSN" },
{ TAG_BROAD_ADDR, "iBR" },
{ TAG_DO_MASK_DISC, "BMD" },
{ TAG_SUPPLY_MASK, "BMS" },
{ TAG_DO_RDISC, "BRD" },
{ TAG_RTR_SOL_ADDR, "iRSA" },
{ TAG_STATIC_ROUTE, "pSR" },
{ TAG_USE_TRAILERS, "BUT" },
{ TAG_ARP_TIMEOUT, "lAT" },
{ TAG_ETH_ENCAP, "BIE" },
{ TAG_TCP_TTL, "bTT" },
{ TAG_TCP_KEEPALIVE, "lKI" },
{ TAG_KEEPALIVE_GO, "BKG" },
{ TAG_NIS_DOMAIN, "aYD" },
{ TAG_NIS_SERVERS, "iYS" },
{ TAG_NTP_SERVERS, "iNTP" },
{ TAG_VENDOR_OPTS, "bVO" },
{ TAG_NETBIOS_NS, "iWNS" },
{ TAG_NETBIOS_DDS, "iWDD" },
{ TAG_NETBIOS_NODE, "bWNT" },
{ TAG_NETBIOS_SCOPE, "aWSC" },
{ TAG_XWIN_FS, "iXFS" },
{ TAG_XWIN_DM, "iXDM" },
{ TAG_NIS_P_DOMAIN, "sN+D" },
{ TAG_NIS_P_SERVERS, "iN+S" },
{ TAG_MOBILE_HOME, "iMH" },
{ TAG_SMPT_SERVER, "iSMTP" },
{ TAG_POP3_SERVER, "iPOP3" },
{ TAG_NNTP_SERVER, "iNNTP" },
{ TAG_WWW_SERVER, "iWWW" },
{ TAG_FINGER_SERVER, "iFG" },
{ TAG_IRC_SERVER, "iIRC" },
{ TAG_STREETTALK_SRVR, "iSTS" },
{ TAG_STREETTALK_STDA, "iSTDA" },
{ TAG_REQUESTED_IP, "iRQ" },
{ TAG_IP_LEASE, "lLT" },
{ TAG_OPT_OVERLOAD, "bOO" },
{ TAG_TFTP_SERVER, "aTFTP" },
{ TAG_BOOTFILENAME, "aBF" },
{ TAG_DHCP_MESSAGE, " DHCP" },
{ TAG_SERVER_ID, "iSID" },
{ TAG_PARM_REQUEST, "bPR" },
{ TAG_MESSAGE, "aMSG" },
{ TAG_MAX_MSG_SIZE, "sMSZ" },
{ TAG_RENEWAL_TIME, "lRN" },
{ TAG_REBIND_TIME, "lRB" },
{ TAG_VENDOR_CLASS, "bVC" },
{ TAG_CLIENT_ID, "bCID" },
{ 0, NULL }
};
@ -248,6 +311,35 @@ rfc1048_print(register const u_char *bp, register u_int length)
return;
}
if (tag == TAG_DHCP_MESSAGE && len == 1) {
c = *bp++;
switch (c) {
case DHCPDISCOVER: printf("DISCOVER"); break;
case DHCPOFFER: printf("OFFER"); break;
case DHCPREQUEST: printf("REQUEST"); break;
case DHCPDECLINE: printf("DECLINE"); break;
case DHCPACK: printf("ACK"); break;
case DHCPNAK: printf("NACK"); break;
case DHCPRELEASE: printf("RELEASE"); break;
case DHCPINFORM: printf("INFORM"); break;
default: printf("%u", c); break;
}
continue;
}
if (tag == TAG_PARM_REQUEST) {
first = 1;
while (len-- > 0) {
c = *bp++;
cp = tok2str(tag2str, "?%d", c);
if (!first)
putchar('+');
printf("%s", cp + 1);
first = 0;
}
continue;
}
/* Print data */
size = len;
if (c == '?') {
@ -288,6 +380,22 @@ rfc1048_print(register const u_char *bp, register u_int length)
}
break;
case 'p':
/* IP address pairs */
while (size >= 2*sizeof(ul)) {
if (!first)
putchar(',');
memcpy((char *)&ul, (char *)bp, sizeof(ul));
printf("(%s:", ipaddr_string(&ul));
bp += sizeof(ul);
memcpy((char *)&ul, (char *)bp, sizeof(ul));
printf("%s)", ipaddr_string(&ul));
bp += sizeof(ul);
size -= 2*sizeof(ul);
first = 0;
}
break;
case 's':
/* shorts */
while (size >= sizeof(us)) {
@ -301,6 +409,28 @@ rfc1048_print(register const u_char *bp, register u_int length)
}
break;
case 'B':
/* boolean */
while (size > 0) {
if (!first)
putchar(',');
switch (*bp) {
case 0:
putchar('N');
break;
case 1:
putchar('Y');
break;
default:
printf("%d?", *bp);
break;
}
++bp;
--size;
first = 0;
}
break;
case 'b':
default:
/* Bytes */

View File

@ -0,0 +1,196 @@
/* 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.2 1999/11/21 09:36:49 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#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);
}

162
contrib/tcpdump/print-cip.c Normal file
View File

@ -0,0 +1,162 @@
/*
* Marko Kiiskila carnil@cs.tut.fi
*
* Tampere University of Technology - Telecommunications Laboratory
*
* Permission to use, copy, modify and distribute this
* software and its documentation is hereby granted,
* provided that both the copyright notice and this
* permission notice appear in all copies of the software,
* derivative works or modified versions, and any portions
* thereof, that both notices appear in supporting
* documentation, and that the use of this software is
* acknowledged in any publications resulting from using
* the software.
*
* TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
* SOFTWARE.
*
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.2 1999/11/21 09:36:49 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#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_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <stdio.h>
#include <pcap.h>
#include "interface.h"
#include "addrtoname.h"
const u_char *packetp;
const u_char *snapend;
#define RFC1483LLC_LEN 8
static unsigned char rfcllc[] = {
0xaa, /* DSAP: non-ISO */
0xaa, /* SSAP: non-ISO */
0x03, /* Ctrl: Unnumbered Information Command PDU */
0x00, /* OUI: EtherType */
0x00,
0x00 };
static inline void
cip_print(register const u_char *bp, int length)
{
int i;
if (memcmp(rfcllc, bp, sizeof(rfcllc))) {
if (qflag) {
for(i=0;i<RFC1483LLC_LEN;i++)
(void)printf("%2.2x ",bp[i]);
} else {
for(i=0;i<RFC1483LLC_LEN-2;i++)
(void)printf("%2.2x ",bp[i]);
etherproto_string(((u_short*)bp)[3]);
}
} else {
if (qflag)
(void)printf("(null encapsulation)");
else {
(void)printf("(null encap)");
etherproto_string(ETHERTYPE_IP);
}
}
}
/*
* This is the top level routine of the printer. 'p' is the points
* to the raw header of the packet, 'tvp' is the timestamp,
* 'length' is the length of the packet off the wire, and 'caplen'
* is the number of bytes actually captured.
*/
void
cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
int caplen = h->caplen;
int length = h->len;
u_short ether_type;
u_short extracted_ethertype;
u_short *bp;
ts_print(&h->ts);
if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
printf("[|cip]");
goto out;
}
if (eflag)
cip_print(p, length);
/*
* Some printers want to get back at the ethernet 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.
*/
packetp = p;
snapend = p + caplen;
if (memcmp(rfcllc, p, sizeof(rfcllc))==0) {
length -= RFC1483LLC_LEN;
caplen -= RFC1483LLC_LEN;
bp = (u_short*)p;
p += RFC1483LLC_LEN;
ether_type = ntohs(bp[3]);
} else
ether_type = ETHERTYPE_IP;
/*
* Is it (gag) an 802.3 encapsulation?
*/
extracted_ethertype = 0;
if (ether_type < ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, NULL, NULL)==0) {
/* ether_type not known, print raw packet */
if (!eflag)
cip_print((u_char *)bp, length);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
}
if (!xflag && !qflag)
default_print(p, caplen);
}
} else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
cip_print((u_char *)bp, length + RFC1483LLC_LEN);
if (!xflag && !qflag)
default_print(p, caplen);
}
if (xflag)
default_print(p, caplen);
out:
putchar('\n');
}

View File

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-decnet.c,v 1.26 97/05/28 12:51:29 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.27 1999/11/21 09:36:50 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>

View File

@ -0,0 +1,342 @@
/*
* 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.3 1999/12/22 06:27:20 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#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 <arpa/inet.h>
#include "interface.h"
#include "addrtoname.h"
#include "dhcp6.h"
#include "dhcp6opt.h"
#if 0
static void dhcp6opttab_init __P((void));
static struct dhcp6_opt *dhcp6opttab_byname __P((char *));
#endif
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
#if 0
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;
}
#endif
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 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,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-domain.c,v 1.39 97/06/13 12:56:28 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.42 1999/11/21 09:36:50 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -42,7 +46,6 @@ struct rtentry;
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#ifdef NOERROR
#undef NOERROR /* Solaris sucks */
@ -53,6 +56,7 @@ struct rtentry;
#include <arpa/nameser.h>
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
@ -101,6 +105,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) */
@ -219,7 +244,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
@ -317,6 +349,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;
@ -332,6 +367,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,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-dvmrp.c,v 1.13 96/12/10 23:16:30 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.17 1999/11/22 04:30:34 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -35,7 +39,6 @@ static const char rcsid[] =
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <stdio.h>
#include <string.h>
@ -43,6 +46,7 @@ static const char rcsid[] =
#include <unistd.h>
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
/*
@ -209,15 +213,13 @@ print_report(register const u_char *bp, register const u_char *ep,
}
}
#define GET_ADDR(to) (memcpy((char *)to, (char *)bp, 4), bp += 4)
static void
print_probe(register const u_char *bp, register const u_char *ep,
register u_int len)
{
register u_int32_t genid;
u_char neighbor[4];
TCHECK2(bp[0], 4);
if ((len < 4) || ((bp + 4) > ep)) {
/* { (ctags) */
printf(" [|}");
@ -229,50 +231,51 @@ print_probe(register const u_char *bp, register const u_char *ep,
printf("\n\tgenid %u", genid);
while ((len > 0) && (bp < ep)) {
if ((len < 4) || ((bp + 4) > ep)) {
printf(" [|]");
return;
}
GET_ADDR(neighbor);
len -= 4;
printf("\n\tneighbor %s", ipaddr_string(neighbor));
TCHECK2(bp[0], 4);
printf("\n\tneighbor %s", ipaddr_string(bp));
bp += 4; len -= 4;
}
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_neighbors(register const u_char *bp, register const u_char *ep,
register u_int len)
{
u_char laddr[4], neighbor[4];
const u_char *laddr;
register u_char metric;
register u_char thresh;
register int ncount;
while (len > 0 && bp < ep) {
if (len < 7 || (bp + 7) >= ep) {
printf(" [|]");
return;
}
GET_ADDR(laddr);
TCHECK2(bp[0], 7);
laddr = bp;
bp += 4;
metric = *bp++;
thresh = *bp++;
ncount = *bp++;
len -= 7;
while (--ncount >= 0 && (len >= 4) && (bp + 4) < ep) {
GET_ADDR(neighbor);
while (--ncount >= 0) {
TCHECK2(bp[0], 4);
printf(" [%s ->", ipaddr_string(laddr));
printf(" %s, (%d/%d)]",
ipaddr_string(neighbor), metric, thresh);
ipaddr_string(bp), metric, thresh);
bp += 4;
len -= 4;
}
}
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_neighbors2(register const u_char *bp, register const u_char *ep,
register u_int len)
{
u_char laddr[4], neighbor[4];
const u_char *laddr;
register u_char metric, thresh, flags;
register int ncount;
@ -281,20 +284,17 @@ print_neighbors2(register const u_char *bp, register const u_char *ep,
(int)(target_level >> 8) & 0xff);
while (len > 0 && bp < ep) {
if (len < 8 || (bp + 8) >= ep) {
printf(" [|]");
return;
}
GET_ADDR(laddr);
TCHECK2(bp[0], 8);
laddr = bp;
bp += 4;
metric = *bp++;
thresh = *bp++;
flags = *bp++;
ncount = *bp++;
len -= 8;
while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) {
GET_ADDR(neighbor);
printf(" [%s -> ", ipaddr_string(laddr));
printf("%s (%d/%d", ipaddr_string(neighbor),
printf("%s (%d/%d", ipaddr_string(bp),
metric, thresh);
if (flags & DVMRP_NF_TUNNEL)
printf("/tunnel");
@ -307,6 +307,7 @@ print_neighbors2(register const u_char *bp, register const u_char *ep,
if (flags & DVMRP_NF_DOWN)
printf("/down");
printf(")]");
bp += 4;
len -= 4;
}
if (ncount != -1) {
@ -314,47 +315,43 @@ print_neighbors2(register const u_char *bp, register const u_char *ep,
return;
}
}
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_prune(register const u_char *bp, register const u_char *ep,
register u_int len)
{
union a {
u_char b[4];
u_int32_t i;
} prune_timer;
if (len < 12 || (bp + 12) > ep) {
printf(" [|]");
return;
}
TCHECK2(bp[0], 12);
printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
bp += 8;
GET_ADDR(prune_timer.b);
printf(" timer %d", (int)ntohl(prune_timer.i));
(void)printf(" timer ");
relts_print(EXTRACT_32BITS(bp));
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_graft(register const u_char *bp, register const u_char *ep,
register u_int len)
{
if (len < 8 || (bp + 8) > ep) {
printf(" [|]");
return;
}
TCHECK2(bp[0], 8);
printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_graft_ack(register const u_char *bp, register const u_char *ep,
register u_int len)
{
if (len < 8 || (bp + 8) > ep) {
printf(" [|]");
return;
}
TCHECK2(bp[0], 8);
printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
return;
trunc:
(void)printf("[|dvmrp]");
}

View File

@ -20,7 +20,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-egp.c,v 1.23 96/11/05 13:30:35 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.24 1999/11/21 09:36:51 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>

336
contrib/tcpdump/print-esp.c Normal file
View File

@ -0,0 +1,336 @@
/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
/*
* 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[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.5 1999/12/15 08:10:18 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#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>
#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 <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"
int
esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
{
register const struct esp *esp;
register const u_char *ep;
u_int32_t spi;
enum { NONE, DESCBC, BLOWFISH, RC5, CAST128, DES3CBC } algo = NONE;
struct ip *ip = NULL;
#ifdef INET6
struct ip6_hdr *ip6 = NULL;
#endif
int advance;
int len;
char *secret = NULL;
int ivlen = 0;
u_char *ivoff;
esp = (struct esp *)bp;
spi = (u_int32_t)ntohl(esp->esp_spi);
/* 'ep' points to the end of avaible data. */
ep = snapend;
if ((u_char *)(esp + 1) >= ep - sizeof(struct esp)) {
fputs("[|ESP]", stdout);
goto fail;
}
printf("ESP(spi=%u", spi);
printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(esp + 1)));
printf(")");
/* if we don't have decryption key, we can't decrypt this packet. */
if (!espsecret)
goto fail;
if (strncmp(espsecret, "des-cbc:", 8) == 0
&& strlen(espsecret + 8) == 8) {
algo = DESCBC;
ivlen = 8;
secret = espsecret + 8;
} else if (strncmp(espsecret, "blowfish-cbc:", 13) == 0) {
algo = BLOWFISH;
ivlen = 8;
secret = espsecret + 13;
} else if (strncmp(espsecret, "rc5-cbc:", 8) == 0) {
algo = RC5;
ivlen = 8;
secret = espsecret + 8;
} else if (strncmp(espsecret, "cast128-cbc:", 12) == 0) {
algo = CAST128;
ivlen = 8;
secret = espsecret + 12;
} else if (strncmp(espsecret, "3des-cbc:", 9) == 0
&& strlen(espsecret + 9) == 24) {
algo = DES3CBC;
ivlen = 8;
secret = espsecret + 9;
} else if (strncmp(espsecret, "none:", 5) == 0) {
algo = NONE;
ivlen = 0;
secret = espsecret + 5;
} else if (strlen(espsecret) == 8) {
algo = DESCBC;
ivlen = 8;
secret = espsecret;
} else {
algo = NONE;
ivlen = 0;
secret = espsecret;
}
ip = (struct ip *)bp2;
switch (ip->ip_v) {
#ifdef INET6
case 6:
ip6 = (struct ip6_hdr *)bp2;
ip = NULL;
/* we do not attempt to decrypt jumbograms */
if (!ntohs(ip6->ip6_plen))
goto fail;
/* if we can't get nexthdr, we do not need to decrypt it */
len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen);
break;
#endif /*INET6*/
case 4:
#ifdef INET6
ip6 = NULL;
#endif
len = ntohs(ip->ip_len);
break;
default:
goto fail;
}
/* if we can't get nexthdr, we do not need to decrypt it */
if (ep - bp2 < len)
goto fail;
if (Rflag)
ivoff = (u_char *)(esp + 1) + sizeof(u_int32_t);
else
ivoff = (u_char *)(esp + 1);
switch (algo) {
case DESCBC:
#ifdef CRYPTO
{
u_char iv[8];
des_key_schedule schedule;
u_char *p;
switch (ivlen) {
case 4:
memcpy(iv, ivoff, 4);
memcpy(&iv[4], ivoff, 4);
p = &iv[4];
*p++ ^= 0xff;
*p++ ^= 0xff;
*p++ ^= 0xff;
*p++ ^= 0xff;
break;
case 8:
memcpy(iv, ivoff, 8);
break;
default:
goto fail;
}
des_check_key = 0;
des_set_key((void *)secret, schedule);
p = ivoff + ivlen;
des_cbc_encrypt((void *)p, (void *)p,
(long)(ep - p), schedule, (void *)iv,
DES_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
#else
goto fail;
#endif /*CRYPTO*/
case BLOWFISH:
#ifdef CRYPTO
{
BF_KEY schedule;
u_char *p;
BF_set_key(&schedule, strlen(secret), secret);
p = ivoff + ivlen;
BF_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff,
BF_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
#else
goto fail;
#endif /*CRYPTO*/
case RC5:
#if defined(CRYPTO) && defined(HAVE_RC5_H)
{
RC5_32_KEY schedule;
u_char *p;
RC5_32_set_key(&schedule, strlen(secret), secret,
RC5_16_ROUNDS);
p = ivoff + ivlen;
RC5_32_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff,
RC5_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
#else
goto fail;
#endif /*CRYPTO*/
case CAST128:
#if defined(CRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128)
{
CAST_KEY schedule;
u_char *p;
CAST_set_key(&schedule, strlen(secret), secret);
p = ivoff + ivlen;
CAST_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff,
CAST_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
#else
goto fail;
#endif /*CRYPTO*/
case DES3CBC:
#if defined(CRYPTO)
{
des_key_schedule s1, s2, s3;
u_char *p;
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,11 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-ether.c,v 1.44 97/05/26 17:18:13 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.48 1999/11/21 09:36:51 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -41,11 +45,14 @@ struct rtentry;
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <stdio.h>
#include <pcap.h>
#ifdef INET6
#include <netinet/ip6.h>
#endif
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
@ -72,10 +79,12 @@ ether_print(register const u_char *bp, u_int length)
length);
}
static u_short extracted_ethertype;
/*
* This is the top level routine of the printer. 'p' is the points
* to the ether header of the packet, 'tvp' is the timestamp,
* 'length' is the length of the packet off the wire, and 'caplen'
* to the ether header of the packet, 'h->tv' is the timestamp,
* 'h->length' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
void
@ -85,7 +94,6 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_int length = h->len;
struct ether_header *ep;
u_short ether_type;
extern u_short extracted_ethertype;
ts_print(&h->ts);
@ -152,12 +160,11 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
* that might want to know what it is.
*/
u_short extracted_ethertype;
int
ether_encap_print(u_short ethertype, const u_char *p,
u_int length, u_int caplen)
{
recurse:
extracted_ethertype = ethertype;
switch (ethertype) {
@ -166,6 +173,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);
@ -185,6 +198,38 @@ ether_encap_print(u_short ethertype, const u_char *p,
aarp_print(p, length);
return (1);
case ETHERTYPE_8021Q:
printf("802.1Q vlan#%d P%d%s",
ntohs(*(unsigned short*)p)&0xFFF,
ntohs(*(unsigned short*)p)>>13,
(ntohs(*(unsigned short*)p)&0x1000) ? " CFI" : "");
ethertype = ntohs(*(unsigned short*)(p+2));
p += 4;
length -= 4;
caplen -= 4;
if (ethertype > ETHERMTU)
goto recurse;
extracted_ethertype = 0;
if (llc_print(p, length, caplen, p-18, p-12) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
ether_print(p-18, length+4);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
}
if (!xflag && !qflag)
default_print(p-18, caplen+4);
}
return (1);
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
pppoe_print(p, length);
return (1);
case ETHERTYPE_LAT:
case ETHERTYPE_SCA:
case ETHERTYPE_MOPRC:

View File

@ -21,10 +21,13 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-fddi.c,v 1.36 97/05/26 17:13:35 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.40 1999/12/14 16:49:02 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_FDDI
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
@ -57,7 +60,7 @@ struct rtentry;
/*
* Some FDDI interfaces use bit-swapped addresses.
*/
#if defined(ultrix) || defined(__alpha) || defined(__bsdi)
#if defined(ultrix) || defined(__alpha) || defined(__bsdi) || defined(__NetBSD__)
int fddi_bitswap = 0;
#else
int fddi_bitswap = 1;
@ -266,8 +269,8 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
u_int caplen = h->caplen;
u_int length = h->len;
const struct fddi_header *fddip = (struct fddi_header *)p;
extern u_short extracted_ethertype;
struct ether_header ehdr;
u_short extracted_ethertype;
ts_print(&h->ts);
@ -335,19 +338,3 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
out:
putchar('\n');
}
#else
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include "interface.h"
void
fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
register const u_char *p)
{
error("not configured for fddi");
/* NOTREACHED */
}
#endif

View File

@ -0,0 +1,104 @@
/*
* 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[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.3.2.1 2000/01/11 06:58:24 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#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|%ld)",
(u_int32_t)ntohl(dp->ip6f_ident),
ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
(long)(bp - bp2) - sizeof(struct ip6_frag));
} else {
printf("frag (%d|%ld)",
ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
(long)(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

@ -24,7 +24,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-gre.c,v 1.4 96/12/10 23:28:23 leres Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.6 1999/11/21 09:36:52 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -76,9 +80,6 @@ struct gre {
#define GRE_SP 0x1000 /* Sequence Present */
#define GREPROTO_IP 0x0800
/*
* Deencapsulate and print a GRE-tunneled IP datagram
*/
@ -123,16 +124,9 @@ gre_print(const u_char *bp, u_int length)
if (flags & GRE_SP)
cp += 4;
switch (proto) {
case GREPROTO_IP:
ip_print(cp, length - ((cp - bp) / sizeof(u_char)));
break;
default:
printf("gre-proto-0x%04X", proto);
break;
}
length -= cp - bp;
if (ether_encap_print(proto, cp, length, length) == 0)
printf("gre-proto-0x%04X", proto);
return;
trunc:

View File

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-icmp.c,v 1.38 96/09/26 23:36:44 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.43 1999/11/22 04:28:21 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -43,7 +47,6 @@ struct rtentry;
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <stdio.h>
#include <string.h>
@ -163,7 +166,7 @@ struct id_rdiscovery {
};
void
icmp_print(register const u_char *bp, register const u_char *bp2)
icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
{
register char *cp;
register const struct icmp *dp;
@ -178,9 +181,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) {
@ -348,6 +353,19 @@ icmp_print(register const u_char *bp, register const u_char *bp2)
break;
}
(void)printf("icmp: %s", str);
if (vflag) {
if (TTEST2(*bp, plen)) {
if (in_cksum((u_short*)dp, plen, 0))
printf(" (wrong icmp csum)");
}
}
if (vflag > 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
bp += 8;
(void)printf(" for ");
ip = (struct ip *)bp;
snaplen = snapend - bp;
ip_print(bp, ntohs(ip->ip_len));
}
return;
trunc:
fputs("[|icmp]", stdout);

View File

@ -0,0 +1,574 @@
/*
* 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[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.2.2.1 2000/01/11 06:58:24 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#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,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-igrp.c,v 1.8 97/05/28 12:52:47 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.11 1999/11/21 09:36:53 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>

View File

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-ip.c,v 1.66 97/05/28 12:51:43 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.79 1999/12/22 06:27:21 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -35,7 +39,6 @@ static const char rcsid[] =
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
@ -67,21 +70,11 @@ 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
struct {
u_int ttl : 8; /* traceroute response ttl */
u_int qid : 24; /* traceroute query id */
} q;
#else
struct {
u_int qid : 24; /* traceroute query id */
u_int ttl : 8; /* traceroute response ttl */
} q;
#endif
u_int tr_rttlqid; /* response ttl and qid */
};
#define tr_rttl q.ttl
#define tr_qid q.qid
#define TR_GETTTL(x) (int)(((x) >> 24) & 0xff)
#define TR_GETQID(x) ((x) & 0x00ffffff)
/*
* Traceroute response format. A traceroute response has a tr_query at the
@ -126,22 +119,24 @@ static void print_mtrace(register const u_char *bp, register u_int len)
{
register struct tr_query *tr = (struct tr_query *)(bp + 8);
printf("mtrace %d: %s to %s reply-to %s", tr->tr_qid,
printf("mtrace %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
ipaddr_string(&tr->tr_raddr));
if (IN_CLASSD(ntohl(tr->tr_raddr)))
printf(" with-ttl %d", tr->tr_rttl);
printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
}
static void print_mresp(register const u_char *bp, register u_int len)
{
register struct tr_query *tr = (struct tr_query *)(bp + 8);
printf("mresp %d: %s to %s reply-to %s", tr->tr_qid,
printf("mresp %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
ipaddr_string(&tr->tr_raddr));
if (IN_CLASSD(ntohl(tr->tr_raddr)))
printf(" with-ttl %d", tr->tr_rttl);
printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
}
static void
@ -155,22 +150,27 @@ igmp_print(register const u_char *bp, register u_int len,
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
if (qflag) {
(void)printf("igmp");
return;
}
TCHECK2(bp[0], 8);
switch (bp[0]) {
case 0x11:
(void)printf("igmp query");
if (*(int *)&bp[4])
if (EXTRACT_32BITS(&bp[4]))
(void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
if (len != 8)
(void)printf(" [len %d]", len);
break;
case 0x12:
(void)printf("igmp report %s", ipaddr_string(&bp[4]));
(void)printf("igmp v1 report %s", ipaddr_string(&bp[4]));
if (len != 8)
(void)printf(" [len %d]", len);
break;
case 0x16:
(void)printf("igmp nreport %s", ipaddr_string(&bp[4]));
(void)printf("igmp v2 report %s", ipaddr_string(&bp[4]));
break;
case 0x17:
(void)printf("igmp leave %s", ipaddr_string(&bp[4]));
@ -183,8 +183,8 @@ igmp_print(register const u_char *bp, register u_int len,
dvmrp_print(bp, len);
break;
case 0x14:
(void)printf("igmp pim");
pim_print(bp, len);
(void)printf("igmp pimv1");
pimv1_print(bp, len);
break;
case 0x1e:
print_mresp(bp, len);
@ -193,27 +193,13 @@ igmp_print(register const u_char *bp, register u_int len,
print_mtrace(bp, len);
break;
default:
(void)printf("igmp-%d", bp[0] & 0xf);
(void)printf("igmp-%d", bp[0]);
break;
}
if ((bp[0] >> 4) != 1)
(void)printf(" [v%d]", bp[0] >> 4);
TCHECK2(bp[0], len);
if (vflag) {
if (vflag && TTEST2(bp[0], len)) {
/* Check the IGMP checksum */
u_int32_t sum = 0;
int count;
const u_short *sp = (u_short *)bp;
for (count = len / 2; --count >= 0; )
sum += *sp++;
if (len & 1)
sum += ntohs(*(u_char *) sp << 8);
while (sum >> 16)
sum = (sum & 0xffff) + (sum >> 16);
sum = 0xffff & ~sum;
if (sum != 0)
if (in_cksum((const u_short*)bp, len, 0))
printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
}
return;
@ -246,6 +232,62 @@ ip_printroute(const char *type, register const u_char *cp, u_int length)
printf("%s}", ptr == len? "#" : "");
}
static void
ip_printts(register const u_char *cp, u_int length)
{
register u_int ptr = cp[2] - 1;
register u_int len = 0;
int hoplen;
char *type;
printf(" TS{");
hoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4;
if ((length - 4) & (hoplen-1))
printf("[bad length %d]", length);
if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)
printf("[bad ptr %d]", cp[2]);
switch (cp[3]&0xF) {
case IPOPT_TS_TSONLY:
printf("TSONLY");
break;
case IPOPT_TS_TSANDADDR:
printf("TS+ADDR");
break;
/*
* prespecified should really be 3, but some ones might send 2
* instead, and the IPOPT_TS_PRESPEC constant can apparently
* have both values, so we have to hard-code it here.
*/
case 2:
printf("PRESPEC2.0");
break;
case 3: /* IPOPT_TS_PRESPEC */
printf("PRESPEC");
break;
default:
printf("[bad ts type %d]", cp[3]&0xF);
goto done;
}
type = " ";
for (len = 4; len < length; len += hoplen) {
if (ptr == len)
type = " ^ ";
printf("%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]),
hoplen!=8 ? "" : ipaddr_string(&cp[len]));
type = " ";
}
done:
printf("%s", ptr == len ? " ^ " : "");
if (cp[3]>>4)
printf(" [%d hops not recorded]} ", cp[3]>>4);
else
printf("}");
}
/*
* print IP options.
*/
@ -279,15 +321,17 @@ ip_optprint(register const u_char *cp, u_int length)
break;
case IPOPT_TS:
printf(" TS{%d}", len);
ip_printts(cp, len);
break;
#ifndef IPOPT_SECURITY
#define IPOPT_SECURITY 130
#endif /* IPOPT_SECURITY */
case IPOPT_SECURITY:
printf(" SECURITY{%d}", len);
break;
case IPOPT_RR:
printf(" RR{%d}=", len);
ip_printroute("RR", cp, len);
break;
@ -299,6 +343,17 @@ ip_optprint(register const u_char *cp, u_int length)
ip_printroute("LSRR", cp, len);
break;
#ifndef IPOPT_RA
#define IPOPT_RA 148 /* router alert */
#endif
case IPOPT_RA:
printf(" RA");
if (len != 4)
printf("{%d}", len);
else if (cp[2] || cp[3])
printf("%d.%d", cp[2], cp[3]);
break;
default:
printf(" IPOPT-%d{%d}", cp[0], len);
break;
@ -310,23 +365,34 @@ ip_optprint(register const u_char *cp, u_int length)
* compute an IP header checksum.
* don't modifiy the packet.
*/
static int
in_cksum(const struct ip *ip)
u_short
in_cksum(const u_short *addr, register int len, u_short csum)
{
register const u_short *sp = (u_short *)ip;
register u_int32_t sum = 0;
register int count;
int nleft = len;
const u_short *w = addr;
u_short answer;
int sum = csum;
/*
* Our algorithm is simple, using a 32 bit accumulator (sum),
* we add sequential 16 bit words to it, and at the end, fold
* back all the carry bits from the top 16 bits into the lower
* 16 bits.
*/
while (nleft > 1) {
sum += *w++;
nleft -= 2;
}
if (nleft == 1)
sum += htons(*(u_char *)w<<8);
/*
* No need for endian conversions.
* add back carry outs from top 16 bits to low 16 bits
*/
for (count = ip->ip_hl * 2; --count >= 0; )
sum += *sp++;
while (sum > 0xffff)
sum = (sum & 0xffff) + (sum >> 16);
sum = ~sum & 0xffff;
return (sum);
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
sum += (sum >> 16); /* add carry */
answer = ~sum; /* truncate to 16 bits */
return (answer);
}
/*
@ -336,8 +402,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
@ -381,6 +449,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
@ -389,7 +458,54 @@ 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) {
#ifndef IPPROTO_AH
#define IPPROTO_AH 51
#endif
case IPPROTO_AH:
nh = *cp;
advance = ah_print(cp, (const u_char *)ip);
cp += advance;
len -= advance;
goto again;
#ifndef IPPROTO_ESP
#define IPPROTO_ESP 50
#endif
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);
@ -400,7 +516,7 @@ ip_print(register const u_char *bp, register u_int length)
break;
case IPPROTO_ICMP:
icmp_print(cp, (const u_char *)ip);
icmp_print(cp, len, (const u_char *)ip);
break;
#ifndef IPPROTO_IGRP
@ -411,8 +527,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;
@ -436,10 +554,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)");
@ -447,6 +567,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
@ -463,18 +604,49 @@ 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;
#ifndef IPPROTO_PIM
#define IPPROTO_PIM 103
#endif
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;
}
}
/* Ultra quiet now means that all this stuff should be suppressed */
/* res 3-Nov-98 */
if (qflag > 1) return;
/*
* 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
@ -483,14 +655,30 @@ 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,
#ifndef IP_MF
#define IP_MF 0x2000
#endif /* IP_MF */
#ifndef IP_DF
#define IP_DF 0x4000
#endif /* IP_DF */
(void)printf(" (frag %d:%u@%d%s)", ntohs(ip->ip_id), len,
(off & 0x1fff) * 8,
(off & IP_MF)? "+" : "");
} else if (off & IP_DF)
(void)printf(" (DF)");
if (ip->ip_tos)
(void)printf(" [tos 0x%x]", (int)ip->ip_tos);
if (ip->ip_tos) {
(void)printf(" [tos 0x%x", (int)ip->ip_tos);
/* ECN bits */
if (ip->ip_tos&0x02) {
(void)printf(",ECT");
if (ip->ip_tos&0x01)
(void)printf(",CE");
}
(void)printf("] ");
}
if (ip->ip_ttl <= 1)
(void)printf(" [ttl %d]", (int)ip->ip_ttl);
@ -508,7 +696,7 @@ ip_print(register const u_char *bp, register u_int length)
sep = ", ";
}
if ((u_char *)ip + hlen <= snapend) {
sum = in_cksum(ip);
sum = in_cksum((const u_short *)ip, hlen, 0);
if (sum != 0) {
(void)printf("%sbad cksum %x!", sep,
ntohs(ip->ip_sum));

228
contrib/tcpdump/print-ip6.c Normal file
View File

@ -0,0 +1,228 @@
/*
* 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[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.2.2.1 2000/01/11 06:58:25 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#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 */

View File

@ -0,0 +1,162 @@
/*
* 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 HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.2.2.1 2000/01/11 06:58:25 fenner Exp $";
#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/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 */

View File

@ -0,0 +1,112 @@
/*
* 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[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.2.2.2 2000/01/25 18:31:10 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#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
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 */
};
#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,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-ipx.c,v 1.19 96/12/10 23:23:52 leres Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.22 1999/11/21 09:36:54 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -38,7 +42,6 @@ static const char rcsid[] =
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#ifdef __STDC__
#include <stdlib.h>

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-isoclns.c,v 1.15 96/12/31 21:27:41 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.16 1999/11/21 09:36:55 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>

View File

@ -23,7 +23,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-krb.c,v 1.9 97/04/26 14:01:45 leres Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.12 1999/11/21 09:36:55 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>

View File

@ -0,0 +1,716 @@
/*
* 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.6 1999/12/22 06:27:21 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "l2tp.h"
#include "interface.h"
static char tstr[] = " [|l2tp]";
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
static 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
};
#if 0
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
};
#endif
#if 0
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
};
#endif
#if 0
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
};
#endif
/******************************/
/* 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("%u", ntohs(*dat));
}
static void
print_int(const u_int *dat)
{
printf("%lu", (u_long)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("%u", ntohs(*ptr));
} else if (length == 4) { /* result & error code */
printf("%u/%u", ntohs(*ptr), ntohs(*(ptr+1)));
} else if (length > 4) { /* result & error code & msg */
printf("%u/%u ", 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("%u", 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 %u", 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("(%u/", ntohs(*ptr++)); /* Tunnel ID */
printf("%u)", ntohs(*ptr++)); /* Session ID */
cnt += 4;
if (flag_s) {
printf("Ns=%u,", ntohs(*ptr++));
printf("Nr=%u", ntohs(*ptr++));
cnt += 4;
}
if (flag_o) {
pad = ntohs(*ptr++);
ptr += pad / sizeof(*ptr);
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
}
}

View File

@ -0,0 +1,148 @@
/*
* Marko Kiiskila carnil@cs.tut.fi
*
* Tampere University of Technology - Telecommunications Laboratory
*
* Permission to use, copy, modify and distribute this
* software and its documentation is hereby granted,
* provided that both the copyright notice and this
* permission notice appear in all copies of the software,
* derivative works or modified versions, and any portions
* thereof, that both notices appear in supporting
* documentation, and that the use of this software is
* acknowledged in any publications resulting from using
* the software.
*
* TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
* SOFTWARE.
*
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.2 1999/11/21 09:36:56 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#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_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <stdio.h>
#include <pcap.h>
#include "interface.h"
#include "addrtoname.h"
#include "lane.h"
static const u_char *packetp;
static const u_char *snapend;
static inline void
lane_print(register const u_char *bp, int length)
{
register const struct lecdatahdr_8023 *ep;
ep = (const struct lecdatahdr_8023 *)bp;
if (qflag)
(void)printf("lecid:%d %s %s %d: ",
ntohs(ep->le_header),
etheraddr_string(ep->h_source),
etheraddr_string(ep->h_dest),
length);
else
(void)printf("lecid:%d %s %s %s %d: ",
ntohs(ep->le_header),
etheraddr_string(ep->h_source),
etheraddr_string(ep->h_dest),
etherproto_string(ep->h_type),
length);
}
/*
* This is the top level routine of the printer. 'p' is the points
* to the ether header of the packet, 'h->tv' is the timestamp,
* 'h->length' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
void
lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
int caplen = h->caplen;
int length = h->len;
struct lecdatahdr_8023 *ep;
u_short ether_type;
u_short extracted_ethertype;
ts_print(&h->ts);
if (caplen < sizeof(struct lecdatahdr_8023)) {
printf("[|lane]");
goto out;
}
if (eflag)
lane_print(p, length);
/*
* Some printers want to get back at the ethernet 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.
*/
packetp = p;
snapend = p + caplen;
length -= sizeof(struct lecdatahdr_8023);
caplen -= sizeof(struct lecdatahdr_8023);
ep = (struct lecdatahdr_8023 *)p;
p += sizeof(struct lecdatahdr_8023);
ether_type = ntohs(ep->h_type);
/*
* Is it (gag) an 802.3 encapsulation?
*/
extracted_ethertype = 0;
if (ether_type < ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, ep->h_source,ep->h_dest)==0) {
/* ether_type not known, print raw packet */
if (!eflag)
lane_print((u_char *)ep, length);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
}
if (!xflag && !qflag)
default_print(p, caplen);
}
} else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
lane_print((u_char *)ep, length + sizeof(*ep));
if (!xflag && !qflag)
default_print(p, caplen);
}
if (xflag)
default_print(p, caplen);
out:
putchar('\n');
}

226
contrib/tcpdump/print-lcp.c Normal file
View File

@ -0,0 +1,226 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 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.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-lcp.c,v 1.3 1999/12/15 07:55:42 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#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 <netinet/if_ether.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#include "ppp.h"
/* Codes */
enum {
LCP_CONFREQ = 1,
LCP_CONFACK = 2,
LCP_CONFNAK = 3,
LCP_CONFREJ = 4,
LCP_TERMREQ = 5,
LCP_TERMACK = 6,
LCP_CODEREJ = 7,
LCP_PROTREJ = 8,
LCP_ECHOREQ = 9,
LCP_ECHOREP = 10,
LCP_DISCARD = 11
};
static struct tok lcpcode2str[] = {
{ LCP_CONFREQ, "ConfReq" },
{ LCP_CONFACK, "ConfAck" },
{ LCP_CONFNAK, "ConfNak" },
{ LCP_CONFREJ, "ConfRej" },
{ LCP_TERMREQ, "TermReq" },
{ LCP_TERMACK, "TermAck" },
{ LCP_CODEREJ, "CodeRej" },
{ LCP_PROTREJ, "ProtRej" },
{ LCP_ECHOREQ, "EchoReq" },
{ LCP_ECHOREP, "EchoRep" },
{ LCP_DISCARD, "Discard" },
{ 0, NULL }
};
enum {
LCP_RESERVED = 0,
LCP_MRU = 1,
LCP_ASYNCMAP = 2,
LCP_AUTHPROTO = 3,
LCP_QUALPROTO = 4,
LCP_MAGICNUM = 5,
LCP_PCOMP = 7,
LCP_ACFCOMP = 8,
LCP_CALLBACK = 13
};
static struct tok lcpoption2str[] = {
{ LCP_RESERVED, "reserved"},
{ LCP_MRU, "mru"},
{ LCP_ASYNCMAP, "asyncmap"},
{ LCP_AUTHPROTO, "auth"},
{ LCP_QUALPROTO, "qual"},
{ LCP_MAGICNUM, "magic"},
{ LCP_PCOMP, "pcomp"},
{ LCP_ACFCOMP, "acfcomp"},
{ LCP_CALLBACK, "callback"},
{ 0, NULL }
};
static struct tok lcpauth2str[] = {
{0xc023, "PAP"},
{0xc223, "CHAP"},
{ 0, NULL }
};
static struct tok lcpqual2str[] = {
{0xc025, "LQR"},
{ 0, NULL }
};
static struct tok lcpchap2str[] = {
{0x05, "MD5"},
{0x80, "MS"},
{ 0, NULL }
};
void
lcp_print(register const u_char *bp, u_int length)
{
u_short lcp_code, lcp_id, lcp_length;
const u_char *lcp_data;
lcp_data = bp+4;
if (snapend < lcp_data) {
printf(" [LCP|]");
return;
}
lcp_code = bp[0];
lcp_id = bp[1];
lcp_length = EXTRACT_16BITS(bp+2);
printf("LCP %s id=0x%x", tok2str(lcpcode2str, "LCP-#%d", lcp_code), lcp_id);
switch(lcp_code) {
case LCP_CONFREQ:
case LCP_CONFACK:
case LCP_CONFNAK:
case LCP_CONFREJ:
/* Print Options */
{
u_char lcpopt_type, lcpopt_length;
const u_char *p=lcp_data;
while (p+2 < lcp_data+lcp_length && p+2 < snapend) {
lcpopt_type = p[0];
lcpopt_length = p[1];
p+=2;
printf(" <%s ",tok2str(lcpoption2str, "option-#%d", lcpopt_type));
if (lcpopt_length)
switch (lcpopt_type) {
case LCP_MRU:
if (snapend < p+2) return;
printf("%d",ntohs(*(u_short*)p));
if (lcpopt_length != 4) printf(" len=%d!",lcpopt_length);
break;
case LCP_AUTHPROTO:
if (snapend < p+2) return;
printf("%s",tok2str(lcpauth2str, "AUTH-%#x", ntohs(*(u_short*)p)));
if (lcpopt_length < 4) printf(" len=%d!",lcpopt_length);
if (lcpopt_length >= 5 && p < snapend)
printf(" %s",tok2str(lcpchap2str, "%#x", p[0]));
break;
case LCP_QUALPROTO:
if (snapend < p+2) return;
printf("%s",tok2str(lcpqual2str, "QUAL-%#x", ntohs(*(u_short*)p)));
if (lcpopt_length < 4) printf(" len=%d!",lcpopt_length);
/* Print data field of auth? */
break;
case LCP_ASYNCMAP:
case LCP_MAGICNUM:
if (snapend < p+4) return;
printf("%#x",ntohl(*(u_long*)p));
if (lcpopt_length != 6) printf(" len=%d!",lcpopt_length);
break;
case LCP_PCOMP:
case LCP_ACFCOMP:
case LCP_RESERVED:
if (lcpopt_length != 2) printf(" len=%d!",lcpopt_length);
break;
default:
if (lcpopt_length != 2) printf(" len=%d",lcpopt_length);
break;
}
printf(">");
p+=lcpopt_length-2;
}
}
break;
case LCP_ECHOREQ:
case LCP_ECHOREP:
case LCP_DISCARD:
if (snapend < lcp_data+4) return;
printf(" magic=%#x", ntohl(*(u_long *) lcp_data));
lcp_data +=4;
break;
case LCP_PROTREJ:
if (snapend < lcp_data+2) return;
printf(" prot=%s", tok2str(ppptype2str, "PROT-%#x", ntohs(*(u_short *) lcp_data)));
/* TODO print rejected packet too ? */
break;
case LCP_CODEREJ:
if (snapend < lcp_data+4) return;
printf(" ");
lcp_print(lcp_data, (lcp_length+lcp_data > snapend ? snapend-lcp_data : lcp_length));
break;
case LCP_TERMREQ:
case LCP_TERMACK:
break;
default:
break;
}
return;
}

View File

@ -24,7 +24,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-llc.c,v 1.24 97/01/01 20:56:48 leres Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.27 1999/12/22 06:27:21 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -79,10 +83,15 @@ llc_print(const u_char *p, u_int length, u_int caplen,
ipx_print(p, length);
return (1);
}
#ifdef notyet
else if (p[0] == 0xf0 && p[1] == 0xf0)
netbios_print(p, length);
#endif
if (llc.ssap == 0xf0 && llc.dsap == 0xf0) {
/*
* we don't actually have a full netbeui parser yet, but the
* smb parser can handle many smb-in-netbeui packets, which
* is very useful, so we call that
*/
netbeui_print(p + 2, p + min(caplen, length));
return (1);
}
if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS
&& llc.llcui == LLC_UI) {
isoclns_print(p + 3, length - 3, caplen - 3, esrc, edst);
@ -92,9 +101,9 @@ llc_print(const u_char *p, u_int length, u_int caplen,
if (llc.ssap == LLCSAP_SNAP && llc.dsap == LLCSAP_SNAP
&& llc.llcui == LLC_UI) {
if (caplen < sizeof(llc)) {
(void)printf("[|llc-snap]");
default_print((u_char *)p, caplen);
return (0);
(void)printf("[|llc-snap]");
default_print((u_char *)p, caplen);
return (0);
}
if (vflag)
(void)printf("snap %s ", protoid_string(llc.llcpi));
@ -136,11 +145,11 @@ llc_print(const u_char *p, u_int length, u_int caplen,
char f;
m = tok2str(cmd2str, "%02x", LLC_U_CMD(llc.llcu));
switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) {
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
case LLC_U_POLL: f = 'P'; break;
case LLC_GSAP|LLC_U_POLL: f = 'F'; break;
default: f = '?'; break;
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
case LLC_U_POLL: f = 'P'; break;
case LLC_GSAP|LLC_U_POLL: f = 'F'; break;
default: f = '?'; break;
}
printf("%s/%c", m, f);
@ -150,22 +159,31 @@ llc_print(const u_char *p, u_int length, u_int caplen,
caplen -= 3;
if ((llc.llcu & ~LLC_U_POLL) == LLC_XID) {
if (*p == LLC_XID_FI) {
printf(": %02x %02x", p[1], p[2]);
p += 3;
length -= 3;
caplen -= 3;
}
if (*p == LLC_XID_FI) {
printf(": %02x %02x", p[1], p[2]);
p += 3;
length -= 3;
caplen -= 3;
}
}
if (!strcmp(m,"ui") && f=='C') {
/*
* we don't have a proper ipx decoder yet, but there
* is a partial one in the smb code
*/
ipx_netbios_print(p,p+min(caplen,length));
}
} else {
char f;
llc.llcis = ntohs(llc.llcis);
switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) {
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
case LLC_U_POLL: f = 'P'; break;
case LLC_GSAP|LLC_U_POLL: f = 'F'; break;
default: f = '?'; break;
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
case LLC_U_POLL: f = 'P'; break;
case LLC_GSAP|LLC_U_POLL: f = 'F'; break;
default: f = '?'; break;
}
if ((llc.llcu & LLC_S_FMT) == LLC_S_FMT) {
@ -185,8 +203,5 @@ llc_print(const u_char *p, u_int length, u_int caplen,
caplen -= 4;
}
(void)printf(" len=%d", length);
if (caplen > 0) {
default_print_unaligned(p, caplen);
}
return(1);
}

View File

@ -0,0 +1,143 @@
/* $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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.2.2.1 2000/01/11 06:58:26 fenner Exp $";
#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,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-netbios.c,v 1.10 96/12/10 23:25:12 leres Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.13 1999/11/21 09:36:57 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-ntp.c,v 1.26 97/06/13 12:56:37 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.27 1999/11/21 09:36:57 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>

View File

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-null.c,v 1.24 97/05/28 12:52:47 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.30 1999/12/22 06:27:21 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -44,12 +48,15 @@ struct rtentry;
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <pcap.h>
#include <stdio.h>
#include <string.h>
#ifdef INET6
#include <netinet/ip6.h>
#endif
#include "interface.h"
#include "addrtoname.h"
@ -80,6 +87,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;
@ -114,7 +127,19 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (eflag)
null_print(p, ip, length);
ip_print((const u_char *)ip, length);
switch (ip->ip_v) {
case 4:
ip_print((const u_char *)ip, length);
break;
#ifdef INET6
case 6:
ip6_print((const u_char *)ip, length);
break;
#endif /* INET6 */
default:
printf("ip v%d", ip->ip_v);
break;
}
if (xflag)
default_print((const u_char *)ip, caplen - NULL_HDRLEN);

View File

@ -23,7 +23,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-ospf.c,v 1.24 97/04/26 13:31:46 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.27 1999/11/21 09:36:58 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -507,9 +511,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);

View File

@ -0,0 +1,668 @@
/*
* 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.2 1999/11/21 09:36:58 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#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);
}

Some files were not shown because too many files have changed in this diff Show More