Virgin import of tcpdump.org tcpdump v3.6.2

This commit is contained in:
Bill Fenner 2001-04-03 07:45:48 +00:00
parent b045338223
commit 685295f4d7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/tcpdump/dist/; revision=75115
151 changed files with 14193 additions and 4376 deletions

View File

@ -0,0 +1,11 @@
version.c
Makefile
Makefile-devel.in
config.status
config.log
config.cache
config.h
.devel
stamp-h
stamp-h.in
tcpdump

View File

@ -1,3 +1,41 @@
$Header: /tcpdump/master/tcpdump/CHANGES,v 1.79 2001/01/10 20:13:58 mcr Exp $
Tuesday January 9, 2001. mcr@sandelman.ottawa.on.ca. Summary for 3.6 release
Cleaned up documentation.
Promisc mode fixes for Linux
IPsec changes/cleanups.
Alignment fixes for picky architectures
Removed dependency on native headers for packet dissectors.
Removed Linux specific headers that were shipped
libpcap changes provide for exchanging capture files between
systems. Save files now have well known PACKET_ values instead of
depending upon system dependant mappings of DLT_* types.
Support for computing/checking IP and UDP/TCP checksums.
Updated autoconf stock files.
IPv6 improvements: dhcp (draft-15), mobile-ip6, ppp, ospf6,
Added dissector support for: ISOCLNS, Token Ring, IGMPv3, bxxp,
timed, vrrp, radius, chdlc, cnfp, cdp, IEEE802.1d, raw-AppleTalk
Added filtering support for: VLANs, ESIS, ISIS
Improvements to: print-telnet, IPTalk, bootp/dhcp, ECN, PPP,
L2TP, PPPoE
HP-UX 11.0 -- find the right dlpi device.
Solaris 8 - IPv6 works
Linux - Added support for an "any" device to capture on all interfaces
Security fixes: buffer overrun audit done. Strcpy replaced with
strlcpy, sprintf replaced with snprintf.
Look for lex problems, and warn about them.
v3.5 Fri Jan 28 18:00:00 PST 2000
Bill Fenner <fenner@research.att.com>
@ -43,7 +81,6 @@ Love <lha@stacken.kth.se>
Michael C. Richardson <mcr@sandelman.ottawa.on.ca>
- Created tcpdump.org repository
v3.4 Sat Jul 25 12:40:55 PDT 1998
- Hardwire Linux slip support since it's too hard to detect.
@ -558,4 +595,4 @@ 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)
@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.79 2001/01/10 20:13:58 mcr Exp $ (LBL)

59
contrib/tcpdump/CREDITS Normal file
View File

@ -0,0 +1,59 @@
This file lists people who have contributed to tcpdump:
The current maintainers:
Bill Fenner <fenner@research.att.com>
Assar Westerlund <assar@sics.se>
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Jun-ichiro itojun Hagino <itojun@iijlab.net>
Guy Harris <guy@alum.mit.edu>
Torsten Landschoff <t.landschoff@gmx.net>
Michael Richardson <mcr@sandelman.ottawa.on.ca>
Ken Hornstein <kenh@cmf.nrl.navy.mil>
Additional people who have contributed patches:
Alfredo Andres <aandres@s21sec.com>
Andrew Tridgell <tridge@linuxcare.com>
Arkadiusz Miskiewicz <misiek@pld.org.pl>
Chris G. Demetriou <cgd@netbsd.org>
Craig Rodrigues <rodrigc@mediaone.net>
Daniel Hagerty <hag@ai.mit.edu>
Francisco Matias Cuenca-Acuna <mcuenca@george.rutgers.edu>
Frank Volf <volf@oasis.IAEhv.nl>
Gert Doering <gert@greenie.muc.de>
Gilbert Ramirez Jr. <gram@xiexie.org>
Gisle Vanem <gvanem@eunet.no>
JINMEI Tatuya <jinmei@kame.net>
Jefferson Ogata <jogata@nodc.noaa.gov>
Jeffrey Hutzelman <jhutz@cmu.edu>
Juergen Schoenwaelder <schoenw@ibr.cs.tu-bs.de>
Ken Hornstein <kenh@cmf.nrl.navy.mil>
Kevin Steves <stevesk@sweden.hp.com>
Larry Lile <lile@stdio.com>
Lennert Buytenhek <buytenh@gnu.org>
Love Hörnquist-Åstrand <lha@stacken.kth.se>
Marko Kiiskila <carnil@cs.tut.fi>
Michael Shalayeff <mickey@openbsd.org>
Michael T. Stolarchuk <mts@off.to>
Monroe Williams <monroe@pobox.com>
Motonori Shindo <mshindo@mshindo.net>
Olaf Kirch <okir@caldera.de>
Onno van der Linden <onno@simplex.nl>
Pascal Hennequin <pascal.hennequin@int-evry.fr>
Pasvorn Boonmark <boonmark@juniper.net>
Pekka Savola <pekkas@netcore.fi>
Peter Jeremy <peter.jeremy@alcatel.com.au>
Rafal Maszkowski <rzm@icm.edu.pl>
Rick Jones <raj@cup.hp.com>
Roderick Schertler <roderick@argon.org>
Sebastian Krahmer <krahmer@cs.uni-potsdam.de>
Timo Koskiahde
Tony Li <tli@jnx.com>
Wilbert de Graaf <wilbertdg@hetnet.nl>
Kris Kennaway <kris@freebsd.org>
Ben Smithurst <ben@scientia.demon.co.uk>
The original LBL crew:
Steve McCanne
Craig Leres
Van Jacobson

View File

@ -1,21 +1,30 @@
CHANGES
CREDITS
FILES
INSTALL
LICENSE
Makefile.in
README
VERSION
acconfig.h
aclocal.m4
addrtoname.c
addrtoname.h
ah.h
appletalk.h
atime.awk
bootp.h
bpf_dump.c
chdlc.h
config.guess
config.h.in
config.sub
configure
configure.in
decnet.h
dhcp6.h
dhcp6opt.h
esp.h
ether.h
ethertype.h
extract.h
fddi.h
@ -24,80 +33,134 @@ gmt2local.h
igrp.h
install-sh
interface.h
ip.h
ipsec_doi.h
ipx.h
lbl/gnuc.h
isakmp.h
l2tp.h
lane.h
lbl/os-solaris2.h
lbl/os-sunos4.h
lbl/os-ultrix4.h
linux-include/net/slcompress.h
linux-include/net/slip.h
linux-include/netinet/if_ether.h
linux-include/netinet/in_systm.h
linux-include/netinet/ip.h
linux-include/netinet/ip_icmp.h
linux-include/netinet/ip_var.h
linux-include/netinet/tcp.h
linux-include/netinet/tcp_var.h
linux-include/netinet/tcpip.h
linux-include/netinet/udp.h
linux-include/netinet/udp_var.h
linux-include/sys/mbuf.h
llc.h
machdep.c
machdep.h
makemib
mib.h
missing/addrinfo.h
missing/addrsize.h
missing/bittypes.h
missing/getaddrinfo.c
missing/getnameinfo.c
missing/inet_aton.c
missing/inet_ntop.c
missing/inet_pton.c
missing/resolv6.h
missing/resolv_ext.h
missing/snprintf.c
missing/sockstorage.h
missing/strlcat.c
missing/strlcpy.c
mkdep
nameser.h
netbios.h
nfs.h
nfsfh.h
nfsv2.h
ntp.h
oakley.h
ospf.h
ospf6.h
packetdat.awk
parsenfsfh.c
ppp.h
print-ah.c
print-arp.c
print-ascii.c
print-atalk.c
print-atm.c
print-bgp.c
print-bootp.c
print-bxxp.c
print-cdp.c
print-chdlc.c
print-cip.c
print-cnfp.c
print-decnet.c
print-dhcp6.c
print-domain.c
print-dvmrp.c
print-egp.c
print-esp.c
print-ether.c
print-fddi.c
print-frag6.c
print-gre.c
print-icmp.c
print-icmp6.c
print-igmp.c
print-igrp.c
print-ip.c
print-ip6.c
print-ip6opts.c
print-ipcomp.c
print-ipx.c
print-isakmp.c
print-isoclns.c
print-krb.c
print-l2tp.c
print-lane.c
print-lcp.c
print-llc.c
print-mobile.c
print-netbios.c
print-nfs.c
print-ntp.c
print-null.c
print-ospf.c
print-ospf6.c
print-pim.c
print-ppp.c
print-pppoe.c
print-radius.c
print-raw.c
print-rip.c
print-ripng.c
print-rt6.c
print-rx.c
print-sl.c
print-sll.c
print-smb.c
print-snmp.c
print-stp.c
print-sunrpc.c
print-tcp.c
print-telnet.c
print-tftp.c
print-timed.c
print-token.c
print-udp.c
print-vjc.c
print-vrrp.c
print-wb.c
route6d.h
rx.h
savestr.c
savestr.h
send-ack.awk
setsignal.c
setsignal.h
slip.h
slcompress.h
sll.h
smb.h
smbutil.c
stime.awk
strcasecmp.c
tcp.h
tcpdump.1
tcpdump.c
timed.h
token.h
udp.h
util.c
vfprintf.c

View File

@ -1,4 +1,4 @@
@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.36.1.1.2.2 2000/01/29 17:02:09 itojun Exp $ (LBL)
@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.47 2000/12/16 09:07:45 guy Exp $ (LBL)
If you have not built libpcap, do so first. See the README
file in this directory for the ftp location.
@ -7,64 +7,44 @@ You will need an ANSI C compiler to build tcpdump. The configure script
will abort if your compiler is not ANSI compliant. If this happens, use
the GNU C compiler, available via anonymous ftp:
ftp://prep.ai.mit.edu/pub/gnu/gcc.tar.gz
ftp://ftp.gnu.org/pub/gnu/gcc/
After libpcap has been built (either install it with "make install" and
"make install-incl" or make sure both the libpcap and tcpdump source
trees are in the same directory), edit the BINDEST and MANDEST paths in
Makefile.in and run ./configure (a shell script). "configure" will
After libpcap has been built (either install it with "make install" or
make sure both the libpcap and tcpdump source trees are in the same
directory), run ./configure (a shell script). "configure" will
determine your system attributes and generate an appropriate Makefile
from Makefile.in. Now build tcpdump by running "make".
If everything builds ok, su and type "make install" (and optionally
"make install-man). This will install tcpdump and the manual entry. By
default, tcpdump is installed with group execute permissions. The group
used depends on your os. In addition, BPF packet access is controlled
by permissions to /dev/bpf0. In any case, DO NOT give untrusted users
the capability of running tcpdump. Tcpdump can capture any traffic on
your net, including passwords.
If everything builds ok, su and type "make install". This will install
tcpdump and the manual entry. By default, tcpdump is installed with
group execute permissions. The group used depends on your os. In
addition, BPF packet access is controlled by permissions to
/dev/bpf0. In any case, DO NOT give untrusted users the capability of
running tcpdump. Tcpdump can capture any traffic on your net,
including passwords.
Note that tcpdump is shipped with some systems, for example, DEC/OSF
and BSD/386. Remember to remove or rename the installed binary
when upgrading.
Note that most systems ship tcpdump, but usually an older version.
Remember to remove or rename the installed binary when upgrading.
If you use Linux, this version of libpcap is known to compile and run
under Red Hat 4.0 with the 2.0.25 kernel. It may work with earlier 2.X
versions but is guaranteed not to work with 1.X kernels.
If you use OSF 4, note that that there appears to be some serious bugs
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, comment out:
#define ETHER_HEADER_HAS_EA 1
and
#define ETHER_ARP_HAS_EA 1
from config.h after running configure (and before attempting to
compile tcpdump).
Another workaround is to use gcc.
with 2.0.25 and more modern, and 2.2.x kernels. It is guaranteed not
to work with 1.X kernels.
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.
== Tested platforms ==
NetBSD 1.4.1/i386 (mcr)
RedHat Linux 6.1/i386 (assar)
Please see "PLATFORMS" for notes about tested platforms.
FILES
-----
CHANGES - description of differences between releases
CREDITS - people that have helped tcpdump along
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
@ -73,7 +53,6 @@ addrtoname.h - address to hostname definitions
appletalk.h - AppleTalk definitions
atime.awk - TCP ack awk script
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
@ -97,7 +76,6 @@ 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
llc.h - LLC definitions
machdep.c - machine dependent routines
machdep.h - machine dependent definitions
@ -105,6 +83,7 @@ makemib - mib to header script
mib.h - mib definitions
missing/* - replacements for missing library functions
mkdep - construct Makefile dependency list
nameser.h - DNS definitions
netbios.h - NETBIOS definitions
nfs.h - Network File System V2 definitions
nfsfh.h - Network File System file handle definitions
@ -123,7 +102,8 @@ print-atm.c - atm 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-cip.c - Classical-IP over ATM routines
print-cnfp.c - Cisco NetFlow printer routines
print-decnet.c - DECnet printer routines
print-dhcp6.c - IPv6 DHCP printer routines
print-domain.c - Domain Name System printer routines
@ -167,12 +147,15 @@ 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-stp.c - IEEE 802.1d spanning tree 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-token.c - Token Ring printer routines
print-udp.c - UDP printer routines
print-vjc.c - PPP Van Jacovson compression (RFC1144) printer routines
print-vrrp.c - Virtual Router Redundancy Protocol
print-wb.c - white board printer routines
route6d.h - packet definition for IPv6 Routing Information Protocol
rx.h -

19
contrib/tcpdump/LICENSE Normal file
View File

@ -0,0 +1,19 @@
License: BSD
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. The names of the authors may not 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.

View File

@ -0,0 +1,22 @@
#
# Auto-regenerate configure script or Makefile when things change.
# From autoconf.info . Works best with GNU Make.
#
${srcdir}/configure: configure.in
cd ${srcdir} && autoconf
# autoheader might not change config.h.in, so touch a stamp file.
${srcdir}/config.h.in: ${srcdir}/stamp-h.in
${srcdir}/stamp-h.in: configure.in acconfig.h
cd ${srcdir} && autoheader
echo timestamp > ${srcdir}/stamp-h.in
config.h: stamp-h
stamp-h: ${srcdir}/config.h.in config.status
./config.status
Makefile: Makefile.in config.status
./config.status
config.status: ${srcdir}/configure
./config.status --recheck

View File

@ -17,7 +17,7 @@
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.219 1999/12/22 15:44:09 itojun Exp $ (LBL)
# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.244 2000/12/21 10:43:20 guy Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@ -27,9 +27,9 @@
prefix = @prefix@
exec_prefix = @exec_prefix@
# Pathname of directory to install the binary
BINDEST = @sbindir@
sbindir = @sbindir@
# Pathname of directory to install the man page
MANDEST = @mandir@
mandir = @mandir@
# VPATH
srcdir = @srcdir@
@ -55,6 +55,8 @@ LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
# Also, gcc does not remove the .o before forking 'as', which can be a
@ -66,17 +68,20 @@ INSTALL = @INSTALL@
CSRC = tcpdump.c \
print-arp.c print-atalk.c print-atm.c print-bootp.c \
print-decnet.c print-domain.c print-dvmrp.c print-egp.c \
print-ether.c print-fddi.c print-gre.c print-icmp.c \
print-ether.c print-fddi.c print-gre.c print-icmp.c print-igmp.c \
print-igrp.c print-ip.c print-ipx.c print-isoclns.c print-krb.c \
print-llc.c print-nfs.c print-ntp.c print-null.c print-ospf.c \
print-pim.c print-ppp.c print-raw.c print-rip.c print-sl.c \
print-snmp.c print-sunrpc.c print-tcp.c print-tftp.c print-udp.c \
print-wb.c addrtoname.c bpf_dump.c gmt2local.c machdep.c \
print-snmp.c print-stp.c print-sunrpc.c print-tcp.c print-tftp.c \
print-udp.c print-wb.c addrtoname.c gmt2local.c machdep.c \
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
print-smb.c smbutil.c print-ascii.c print-telnet.c print-cnfp.c \
print-vrrp.c print-cdp.c print-token.c print-bxxp.c print-timed.c \
print-radius.c print-sll.c
LOCALSRC = @LOCALSRC@
GENSRC = version.c
LIBOBJS = @LIBOBJS@
@ -85,13 +90,13 @@ SRC = $(CSRC) $(GENSRC) $(LOCALSRC)
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
# hack the extra indirection
OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LOCALSRC:.c=.o) @LIBOBJS@
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 igrp.h interface.h \
ipx.h llc.h machdep.h mib.h nfsfh.h nfsv2.h ntp.h ospf.h \
savestr.c setsignal.h \
gnuc.h ipsec_doi.h isakmp.h l2tp.h netbios.h oakley.h ospf6.h ppp.h \
route6d.h
gnuc.h ipsec_doi.h isakmp.h l2tp.h nameser.h \
netbios.h oakley.h ospf6.h ppp.h route6d.h
TAGHDR = \
/usr/include/arpa/tftp.h \
@ -124,6 +129,12 @@ 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
snprintf.o: $(srcdir)/missing/snprintf.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
strlcat.o: $(srcdir)/missing/strlcat.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
strlcpy.o: $(srcdir)/missing/strlcpy.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
version.o: version.c
$(CC) $(CFLAGS) -c version.c
@ -132,17 +143,19 @@ 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:
[ -d $(DESTDIR)$(sbindir) ] || \
(mkdir -p $(DESTDIR)$(sbindir); chmod 755 $(DESTDIR)$(sbindir))
$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG)
[ -d $(DESTDIR)$(mandir)/man1 ] || \
(mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
$(INSTALL_DATA) $(srcdir)/$(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1
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
uninstall:
rm -f $(DESTDIR)$(sbindir)/$(PROG)
rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1
lint: $(GENSRC) force
lint: $(GENSRC)
lint -hbxn $(SRC) | \
grep -v 'struct/union .* never defined' | \
grep -v 'possible pointer alignment problem'
@ -152,14 +165,14 @@ clean:
distclean:
rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
config.h gnuc.h os-proto.h
config.h gnuc.h os-proto.h stamp-h stamp-h.in
tags: $(TAGFILES)
ctags -wtd $(TAGFILES)
tar: force
tar:
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
list="" ; tar="tar chFFf" ; \
list="" ; tar="tar chf" ; \
for i in `cat FILES` ; do list="$$list $$name/$$i" ; done; \
echo \
"rm -f ../$$name; ln -s $$dir ../$$name" ; \
@ -171,6 +184,5 @@ tar: force
"rm -f ../$$name" ; \
rm -f ../$$name
force: /tmp
depend: $(GENSRC) force
./mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
depend: $(GENSRC)
${srcdir}/mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)

View File

@ -0,0 +1,8 @@
== Tested platforms ==
NetBSD 1.5/i386 (mcr - 2000/12/8)
---
RedHat Linux 6.1/i386 (assar)
FreeBSD 2.2.8/i386 (itojun)

View File

@ -1,20 +1,36 @@
@(#) $Header: /tcpdump/master/tcpdump/README,v 1.54.1.1 1999/10/07 23:47:09 mcr Exp $ (LBL)
@(#) $Header: /tcpdump/master/tcpdump/README,v 1.58 2000/12/08 06:59:11 mcr Exp $ (LBL)
TCPDUMP 3.4
Lawrence Berkeley National Laboratory
Network Research Group
tcpdump@ee.lbl.gov
ftp://ftp.ee.lbl.gov/tcpdump.tar.Z
TCPDUMP 3.6
Now maintained by "The Tcpdump Group"
See www.tcpdump.org
Please send inquiries/comments/reports to tcpdump-workers@tcpdump.org
Anonymous CVS is available via:
cvs -d cvs.tcpdump.org:/tcpdump/master login
(password "anoncvs")
cvs -d cvs.tcpdump.org:/tcpdump/master checkout tcpdump
Version 3.6 of TCPDUMP can be retrived with the CVS tag "tcpdump_3_6":
cvs -d cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_6 tcpdump
Please send patches against the master copy to patches@tcpdump.org.
formerly from Lawrence Berkeley National Laboratory
Network Research Group <tcpdump@ee.lbl.gov>
ftp://ftp.ee.lbl.gov/tcpdump.tar.Z (3.4)
This directory contains source code for tcpdump, a tool for network
monitoring and data acquisition. The original distribution is
available via anonymous ftp to ftp.ee.lbl.gov, in tcpdump.tar.Z.
monitoring and data acquisition. This software was originally
developed by the Network Research Group at the Lawrence Berkeley
National Laboratory. The original distribution is available via
anonymous ftp to ftp.ee.lbl.gov, in tcpdump.tar.Z. More recent
development is performed at tcpdump.org, http://www.tcpdump.org/
Tcpdump now uses libpcap, a system-independent interface for user-level
Tcpdump uses libpcap, a system-independent interface for user-level
packet capture. Before building tcpdump, you must first retrieve and
build libpcap, also from LBL, in:
ftp://ftp.ee.lbl.gov/libpcap.tar.Z
build libpcap, also originally from LBL and now being maintained by
tcpdump.org; see http://www.tcpdump.org/ .
Once libpcap is built (either install it or make sure it's in
../libpcap), you can build tcpdump using the procedure in the INSTALL
@ -50,13 +66,18 @@ It is a program that can be used to extract portions of tcpdump binary
trace files. See the above distribution for further details and
documentation.
Problems, bugs, questions, desirable enhancements, source code
contributions, etc., should be sent to the email address
"tcpdump@ee.lbl.gov".
Problems, bugs, questions, desirable enhancements, etc.
should be sent to the address "tcpdump-workers@tcpdump.org".
Source code contributions, etc. should be sent to the email address
"patches@tcpdump.org".
Current versions can be found at www.tcpdump.org
- The TCPdump team
original text by: Steve McCanne, Craig Leres, Van Jacobson
- Steve McCanne
Craig Leres
Van Jacobson
-------------------------------------
This directory also contains some short awk programs intended as
examples of ways to reduce tcpdump data when you're tracking
@ -205,4 +226,3 @@ The method was:
- Once a week, tell your funding agent that you're discovering
wonderful things and you'll write up that research report
"real soon now".

6
contrib/tcpdump/TODO Normal file
View File

@ -0,0 +1,6 @@
1. update credits
2. review "FILES"
3. search for version info
4. get PLATFORMS filled in
5. update CHANGES file
6. do same for libpcap

View File

@ -1 +1 @@
3.5
3.6

View File

@ -2,14 +2,10 @@
* 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
/* Define if you enable IPv6 support */
#undef INET6
/* Define if you enable support for the libsmi. */
@ -18,14 +14,6 @@
/* 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
@ -38,11 +26,6 @@
*/
#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
@ -61,9 +44,6 @@
/* 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
@ -79,6 +59,9 @@
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
/* define if you have both getipnodebyname() and getipnodebyaddr() */
#undef USE_GETIPNODEBY
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
@ -94,9 +77,6 @@
/* 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

View File

@ -1,4 +1,4 @@
dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.67.2.1 2000/01/25 18:39:02 itojun Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.73 2001/01/02 22:18:27 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1995, 1996, 1997, 1998
dnl The Regents of the University of California. All rights reserved.
@ -192,7 +192,7 @@ AC_DEFUN(AC_LBL_LIBPCAP,
libpcap=FAIL
lastdir=FAIL
places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
for dir in $places ../libpcap libpcap ; do
basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`
if test $lastdir = $basedir ; then
@ -215,7 +215,7 @@ AC_DEFUN(AC_LBL_LIBPCAP,
else
$1=$libpcap
if test -r $d/pcap.h; then
$2="-I$d $$2"
$2="-I$d $$2"
elif test -r $srcdir/../libpcap/pcap.h; then
$2="-I$d -I$srcdir/../libpcap $$2"
else
@ -491,7 +491,8 @@ AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
[case "$target_cpu" in
alpha|hp*|mips|sparc)
# XXX: should also check that they don't do weird things (like on arm)
alpha*|arm*|hp*|mips|sparc)
ac_cv_lbl_unaligned_fail=yes
;;
@ -1027,3 +1028,30 @@ AC_DEFUN(AC_VAR_H_ERRNO, [
AC_DEFINE(HAVE_H_ERRNO)
fi
])
dnl
dnl Test for __attribute__
dnl
AC_DEFUN(AC_C___ATTRIBUTE__, [
AC_MSG_CHECKING(for __attribute__)
AC_CACHE_VAL(ac_cv___attribute__, [
AC_TRY_COMPILE([
#include <stdlib.h>
],
[
static void foo(void) __attribute__ ((noreturn));
static void
foo(void)
{
exit(1);
}
],
ac_cv___attribute__=yes,
ac_cv___attribute__=no)])
if test "$ac_cv___attribute__" = "yes"; then
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
fi
AC_MSG_RESULT($ac_cv___attribute__)
])

View File

@ -23,7 +23,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.64 1999/11/21 09:36:44 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.69.2.1 2001/01/17 18:29:58 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -34,17 +34,13 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <sys/time.h>
#if __STDC__
struct mbuf;
struct rtentry;
#endif
#include <net/if.h>
#include <netinet/in.h>
#ifdef HAVE_NETINET_IF_ETHER_H
#include <netinet/if_ether.h>
#ifdef INET6
#include <netinet6/ip6.h>
#endif
#include <arpa/inet.h>
@ -53,12 +49,6 @@ struct rtentry;
#include <netdb.h>
#include <pcap.h>
#include <pcap-namedb.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <signal.h>
#include <stdio.h>
#include <string.h>
@ -495,7 +485,6 @@ protoid_string(register const u_char *pi)
char *
llcsap_string(u_char sap)
{
register char *cp;
register struct hnamemem *tp;
register u_int32_t i = sap;
char buf[sizeof("sap 00")];
@ -507,12 +496,7 @@ llcsap_string(u_char sap)
tp->addr = i;
tp->nxt = newhnamemem();
cp = buf;
(void)strcpy(cp, "sap ");
cp += strlen(cp);
*cp++ = hex[sap >> 4 & 0xf];
*cp++ = hex[sap & 0xf];
*cp++ = '\0';
snprintf(buf, sizeof(buf), "sap %02x", sap & 0xff);
tp->name = savestr(buf);
return (tp->name);
}
@ -556,7 +540,7 @@ tcpport_string(u_short port)
tp->addr = i;
tp->nxt = newhnamemem();
(void)sprintf(buf, "%u", i);
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = savestr(buf);
return (tp->name);
}
@ -575,7 +559,7 @@ udpport_string(register u_short port)
tp->addr = i;
tp->nxt = newhnamemem();
(void)sprintf(buf, "%u", i);
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = savestr(buf);
return (tp->name);
}
@ -601,7 +585,7 @@ init_servarray(void)
while (table->name)
table = table->nxt;
if (nflag) {
(void)sprintf(buf, "%d", port);
(void)snprintf(buf, sizeof(buf), "%d", port);
table->name = savestr(buf);
} else
table->name = savestr(sv->s_name);

57
contrib/tcpdump/ah.h Normal file
View File

@ -0,0 +1,57 @@
/* $NetBSD: ah.h,v 1.12 2000/07/23 05:23:04 itojun Exp $ */
/* $KAME: ah.h,v 1.12 2000/07/20 17:41:01 itojun Exp $ */
/*
* 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.
*/
/*
* RFC1826/2402 authentication header.
*/
#ifndef _NETINET6_AH_H_
#define _NETINET6_AH_H_
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 */
};
#endif /*_NETINET6_AH_H_*/

View File

@ -20,13 +20,13 @@
*
* AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
*
* @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.12.1.1 1999/10/07 23:47:09 mcr Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.13 2000/10/03 02:54:54 itojun Exp $ (LBL)
*/
struct LAP {
u_char dst;
u_char src;
u_char type;
u_int8_t dst;
u_int8_t src;
u_int8_t type;
};
#define lapShortDDP 1 /* short DDP type */
#define lapDDP 2 /* DDP type */
@ -35,22 +35,22 @@ struct LAP {
/* Datagram Delivery Protocol */
struct atDDP {
u_short length;
u_short checksum;
u_short dstNet;
u_short srcNet;
u_char dstNode;
u_char srcNode;
u_char dstSkt;
u_char srcSkt;
u_char type;
u_int16_t length;
u_int16_t checksum;
u_int16_t dstNet;
u_int16_t srcNet;
u_int8_t dstNode;
u_int8_t srcNode;
u_int8_t dstSkt;
u_int8_t srcSkt;
u_int8_t type;
};
struct atShortDDP {
u_short length;
u_char dstSkt;
u_char srcSkt;
u_char type;
u_int16_t length;
u_int8_t dstSkt;
u_int8_t srcSkt;
u_int8_t type;
};
#define ddpMaxWKS 0x7F
@ -73,9 +73,9 @@ struct atShortDDP {
/* AppleTalk Transaction Protocol */
struct atATP {
u_char control;
u_char bitmap;
u_short transID;
u_int8_t control;
u_int8_t bitmap;
u_int16_t transID;
int32_t userData;
};
@ -94,8 +94,8 @@ struct atATP {
/* AppleTalk Echo Protocol */
struct atEcho {
u_char echoFunction;
u_char *echoData;
u_int8_t echoFunction;
u_int8_t *echoData;
};
#define echoSkt 4 /* the echoer socket */
@ -107,15 +107,15 @@ struct atEcho {
/* Name Binding Protocol */
struct atNBP {
u_char control;
u_char id;
u_int8_t control;
u_int8_t id;
};
struct atNBPtuple {
u_short net;
u_char node;
u_char skt;
u_char enumerator;
u_int16_t net;
u_int8_t node;
u_int8_t skt;
u_int8_t enumerator;
};
#define nbpBrRq 0x10
@ -141,8 +141,8 @@ struct atNBPtuple {
/* Zone Information Protocol */
struct zipHeader {
u_char command;
u_char netcount;
u_int8_t command;
u_int8_t netcount;
};
#define zipHeaderSize 2

View File

@ -1,4 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.8 1999/10/17 23:35:46 mcr Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.10 2000/12/03 23:42:23 fenner Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
@ -21,21 +21,21 @@
struct bootp {
unsigned char bp_op; /* packet opcode type */
unsigned char bp_htype; /* hardware addr type */
unsigned char bp_hlen; /* hardware addr length */
unsigned char bp_hops; /* gateway hops */
u_int8_t bp_op; /* packet opcode type */
u_int8_t bp_htype; /* hardware addr type */
u_int8_t bp_hlen; /* hardware addr length */
u_int8_t bp_hops; /* gateway hops */
u_int32_t bp_xid; /* transaction ID */
unsigned short bp_secs; /* seconds since boot began */
unsigned short bp_flags; /* flags: 0x8000 is broadcast */
u_int16_t bp_secs; /* seconds since boot began */
u_int16_t 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 */
struct in_addr bp_giaddr; /* gateway IP address */
unsigned char bp_chaddr[16]; /* client hardware address */
unsigned char bp_sname[64]; /* server host name */
unsigned char bp_file[128]; /* boot file name */
unsigned char bp_vend[64]; /* vendor-specific area */
u_int8_t bp_chaddr[16]; /* client hardware address */
u_int8_t bp_sname[64]; /* server host name */
u_int8_t bp_file[128]; /* boot file name */
u_int8_t bp_vend[64]; /* vendor-specific area */
};
/*
@ -65,85 +65,127 @@ struct bootp {
* the vendor field of the packet.
*/
#define TAG_PAD ((unsigned char) 0)
#define TAG_SUBNET_MASK ((unsigned char) 1)
#define TAG_TIME_OFFSET ((unsigned char) 2)
#define TAG_GATEWAY ((unsigned char) 3)
#define TAG_TIME_SERVER ((unsigned char) 4)
#define TAG_NAME_SERVER ((unsigned char) 5)
#define TAG_DOMAIN_SERVER ((unsigned char) 6)
#define TAG_LOG_SERVER ((unsigned char) 7)
#define TAG_COOKIE_SERVER ((unsigned char) 8)
#define TAG_LPR_SERVER ((unsigned char) 9)
#define TAG_IMPRESS_SERVER ((unsigned char) 10)
#define TAG_RLP_SERVER ((unsigned char) 11)
#define TAG_HOSTNAME ((unsigned char) 12)
#define TAG_BOOTSIZE ((unsigned char) 13)
#define TAG_END ((unsigned char) 255)
#define TAG_PAD ((u_int8_t) 0)
#define TAG_SUBNET_MASK ((u_int8_t) 1)
#define TAG_TIME_OFFSET ((u_int8_t) 2)
#define TAG_GATEWAY ((u_int8_t) 3)
#define TAG_TIME_SERVER ((u_int8_t) 4)
#define TAG_NAME_SERVER ((u_int8_t) 5)
#define TAG_DOMAIN_SERVER ((u_int8_t) 6)
#define TAG_LOG_SERVER ((u_int8_t) 7)
#define TAG_COOKIE_SERVER ((u_int8_t) 8)
#define TAG_LPR_SERVER ((u_int8_t) 9)
#define TAG_IMPRESS_SERVER ((u_int8_t) 10)
#define TAG_RLP_SERVER ((u_int8_t) 11)
#define TAG_HOSTNAME ((u_int8_t) 12)
#define TAG_BOOTSIZE ((u_int8_t) 13)
#define TAG_END ((u_int8_t) 255)
/* RFC1497 tags */
#define TAG_DUMPPATH ((unsigned char) 14)
#define TAG_DOMAINNAME ((unsigned char) 15)
#define TAG_SWAP_SERVER ((unsigned char) 16)
#define TAG_ROOTPATH ((unsigned char) 17)
#define TAG_EXTPATH ((unsigned char) 18)
#define TAG_DUMPPATH ((u_int8_t) 14)
#define TAG_DOMAINNAME ((u_int8_t) 15)
#define TAG_SWAP_SERVER ((u_int8_t) 16)
#define TAG_ROOTPATH ((u_int8_t) 17)
#define TAG_EXTPATH ((u_int8_t) 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)
#define TAG_IP_FORWARD ((u_int8_t) 19)
#define TAG_NL_SRCRT ((u_int8_t) 20)
#define TAG_PFILTERS ((u_int8_t) 21)
#define TAG_REASS_SIZE ((u_int8_t) 22)
#define TAG_DEF_TTL ((u_int8_t) 23)
#define TAG_MTU_TIMEOUT ((u_int8_t) 24)
#define TAG_MTU_TABLE ((u_int8_t) 25)
#define TAG_INT_MTU ((u_int8_t) 26)
#define TAG_LOCAL_SUBNETS ((u_int8_t) 27)
#define TAG_BROAD_ADDR ((u_int8_t) 28)
#define TAG_DO_MASK_DISC ((u_int8_t) 29)
#define TAG_SUPPLY_MASK ((u_int8_t) 30)
#define TAG_DO_RDISC ((u_int8_t) 31)
#define TAG_RTR_SOL_ADDR ((u_int8_t) 32)
#define TAG_STATIC_ROUTE ((u_int8_t) 33)
#define TAG_USE_TRAILERS ((u_int8_t) 34)
#define TAG_ARP_TIMEOUT ((u_int8_t) 35)
#define TAG_ETH_ENCAP ((u_int8_t) 36)
#define TAG_TCP_TTL ((u_int8_t) 37)
#define TAG_TCP_KEEPALIVE ((u_int8_t) 38)
#define TAG_KEEPALIVE_GO ((u_int8_t) 39)
#define TAG_NIS_DOMAIN ((u_int8_t) 40)
#define TAG_NIS_SERVERS ((u_int8_t) 41)
#define TAG_NTP_SERVERS ((u_int8_t) 42)
#define TAG_VENDOR_OPTS ((u_int8_t) 43)
#define TAG_NETBIOS_NS ((u_int8_t) 44)
#define TAG_NETBIOS_DDS ((u_int8_t) 45)
#define TAG_NETBIOS_NODE ((u_int8_t) 46)
#define TAG_NETBIOS_SCOPE ((u_int8_t) 47)
#define TAG_XWIN_FS ((u_int8_t) 48)
#define TAG_XWIN_DM ((u_int8_t) 49)
#define TAG_NIS_P_DOMAIN ((u_int8_t) 64)
#define TAG_NIS_P_SERVERS ((u_int8_t) 65)
#define TAG_MOBILE_HOME ((u_int8_t) 68)
#define TAG_SMPT_SERVER ((u_int8_t) 69)
#define TAG_POP3_SERVER ((u_int8_t) 70)
#define TAG_NNTP_SERVER ((u_int8_t) 71)
#define TAG_WWW_SERVER ((u_int8_t) 72)
#define TAG_FINGER_SERVER ((u_int8_t) 73)
#define TAG_IRC_SERVER ((u_int8_t) 74)
#define TAG_STREETTALK_SRVR ((u_int8_t) 75)
#define TAG_STREETTALK_STDA ((u_int8_t) 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)
#define TAG_REQUESTED_IP ((u_int8_t) 50)
#define TAG_IP_LEASE ((u_int8_t) 51)
#define TAG_OPT_OVERLOAD ((u_int8_t) 52)
#define TAG_TFTP_SERVER ((u_int8_t) 66)
#define TAG_BOOTFILENAME ((u_int8_t) 67)
#define TAG_DHCP_MESSAGE ((u_int8_t) 53)
#define TAG_SERVER_ID ((u_int8_t) 54)
#define TAG_PARM_REQUEST ((u_int8_t) 55)
#define TAG_MESSAGE ((u_int8_t) 56)
#define TAG_MAX_MSG_SIZE ((u_int8_t) 57)
#define TAG_RENEWAL_TIME ((u_int8_t) 58)
#define TAG_REBIND_TIME ((u_int8_t) 59)
#define TAG_VENDOR_CLASS ((u_int8_t) 60)
#define TAG_CLIENT_ID ((u_int8_t) 61)
/* RFC 2241 */
#define TAG_NDS_SERVERS ((u_int8_t) 85)
#define TAG_NDS_TREE_NAME ((u_int8_t) 86)
#define TAG_NDS_CONTEXT ((u_int8_t) 87)
/* RFC 2485 */
#define TAG_OPEN_GROUP_UAP ((u_int8_t) 98)
/* RFC 2563 */
#define TAG_DISABLE_AUTOCONF ((u_int8_t) 116)
/* RFC 2610 */
#define TAG_SLP_DA ((u_int8_t) 78)
#define TAG_SLP_SCOPE ((u_int8_t) 79)
/* RFC 2937 */
#define TAG_NS_SEARCH ((u_int8_t) 117)
/* RFC 3011 */
#define TAG_IP4_SUBNET_SELECT ((u_int8_t) 118)
/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
#define TAG_USER_CLASS ((u_int8_t) 77)
#define TAG_SLP_NAMING_AUTH ((u_int8_t) 80)
#define TAG_CLIENT_FQDN ((u_int8_t) 81)
#define TAG_AGENT_CIRCUIT ((u_int8_t) 82)
#define TAG_AGENT_REMOTE ((u_int8_t) 83)
#define TAG_AGENT_MASK ((u_int8_t) 84)
#define TAG_TZ_STRING ((u_int8_t) 88)
#define TAG_FQDN_OPTION ((u_int8_t) 89)
#define TAG_AUTH ((u_int8_t) 90)
#define TAG_VINES_SERVERS ((u_int8_t) 91)
#define TAG_SERVER_RANK ((u_int8_t) 92)
#define TAG_CLIENT_ARCH ((u_int8_t) 93)
#define TAG_CLIENT_NDI ((u_int8_t) 94)
#define TAG_CLIENT_GUID ((u_int8_t) 97)
#define TAG_LDAP_URL ((u_int8_t) 95)
#define TAG_6OVER4 ((u_int8_t) 96)
#define TAG_PRINTER_NAME ((u_int8_t) 100)
#define TAG_MDHCP_SERVER ((u_int8_t) 101)
#define TAG_IPX_COMPAT ((u_int8_t) 110)
#define TAG_NETINFO_PARENT ((u_int8_t) 112)
#define TAG_NETINFO_PARENT_TAG ((u_int8_t) 113)
#define TAG_URL ((u_int8_t) 114)
#define TAG_FAILOVER ((u_int8_t) 115)
#define TAG_EXTENDED_REQUEST ((u_int8_t) 126)
#define TAG_EXTENDED_OPTION ((u_int8_t) 127)
/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
#define DHCPDISCOVER 1
@ -161,14 +203,14 @@ struct bootp {
*/
struct cmu_vend {
unsigned char v_magic[4]; /* magic number */
u_int8_t v_magic[4]; /* magic number */
u_int32_t v_flags; /* flags/opcodes, etc. */
struct in_addr v_smask; /* Subnet mask */
struct in_addr v_dgate; /* Default gateway */
struct in_addr v_dns1, v_dns2; /* Domain name servers */
struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
struct in_addr v_ts1, v_ts2; /* Time servers */
unsigned char v_unused[24]; /* currently unused */
u_int8_t v_unused[24]; /* currently unused */
};

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.10 1999/11/21 09:36:44 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.13 2000/12/09 02:58:45 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -35,8 +35,6 @@ static const char rcsid[] =
#include "interface.h"
extern void bpf_dump(struct bpf_program *, int);
void
bpf_dump(struct bpf_program *p, int option)
{

27
contrib/tcpdump/chdlc.h Normal file
View File

@ -0,0 +1,27 @@
/* @(#) $Header: /tcpdump/master/tcpdump/chdlc.h,v 1.1 2000/09/18 05:11:43 guy Exp $ (LBL) */
/*
* 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.
*/
#define CHDLC_HDRLEN 4
#define CHDLC_UNICAST 0x0f
#define CHDLC_BCAST 0x8f
#define CHDLC_TYPE_SLARP 0x8035
#define CHDLC_TYPE_CDP 0x2000

File diff suppressed because it is too large Load Diff

View File

@ -18,46 +18,21 @@
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
/* Define if you enable IPv6 support */
#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
@ -73,15 +48,9 @@
/* 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
@ -91,6 +60,9 @@
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
/* define if you have both getipnodebyname() and getipnodebyaddr() */
#undef USE_GETIPNODEBY
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
@ -106,9 +78,6 @@
/* 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
@ -129,14 +98,23 @@
/* The number of bytes in a short. */
#undef SIZEOF_SHORT
/* Define if you have the bpf_dump function. */
#undef HAVE_BPF_DUMP
/* Define if you have the ether_ntohost function. */
#undef HAVE_ETHER_NTOHOST
/* Define if you have the freeaddrinfo function. */
#undef HAVE_FREEADDRINFO
/* 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 getipnodebyaddr function. */
#undef HAVE_GETIPNODEBYADDR
/* Define if you have the getipnodebyname function. */
#undef HAVE_GETIPNODEBYNAME
/* Define if you have the getnameinfo function. */
#undef HAVE_GETNAMEINFO
@ -162,26 +140,32 @@
/* Define if you have the sigset function. */
#undef HAVE_SIGSET
/* Define if you have the snprintf function. */
#undef HAVE_SNPRINTF
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strlcat function. */
#undef HAVE_STRLCAT
/* Define if you have the strlcpy function. */
#undef HAVE_STRLCPY
/* Define if you have the vfprintf function. */
#undef HAVE_VFPRINTF
/* Define if you have the vsnprintf function. */
#undef HAVE_VSNPRINTF
/* 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 <netinet/if_ether.h> header file. */
#undef HAVE_NETINET_IF_ETHER_H
/* Define if you have the <rc5.h> header file. */
#undef HAVE_RC5_H
@ -192,15 +176,15 @@
/* 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 nsl library (-lnsl). */
#undef HAVE_LIBNSL
/* Define if you have the resolv library (-lresolv). */
#undef HAVE_LIBRESOLV
@ -216,5 +200,6 @@
/* Define if you have the str library (-lstr). */
#undef HAVE_LIBSTR
/* Define if you have the z library (-lz). */
#undef HAVE_LIBZ
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__

View File

@ -1,6 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script, version 1.1.
# Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
timestamp='2000-12-15'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
@ -25,6 +29,8 @@
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Please send patches to <config-patches@gnu.org>.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
@ -45,30 +51,73 @@
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
if [ x$1 = x ]
then
echo Configuration name missing. 1>&2
echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
echo "or $0 ALIAS" 1>&2
echo where ALIAS is a recognized configuration type. 1>&2
exit 1
fi
me=`echo "$0" | sed -e 's,.*/,,'`
# First pass through any local machine types.
case $1 in
*local*)
echo $1
exit 0
;;
*)
;;
usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS
$0 [OPTION] ALIAS
Canonicalize a configuration name.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit 0 ;;
--version | -v )
echo "$version" ; exit 0 ;;
--help | --h* | -h )
echo "$usage"; exit 0 ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help"
exit 1 ;;
*local*)
# First pass through any local machine types.
echo $1
exit 0;;
* )
break ;;
esac
done
case $# in
0) echo "$me: missing argument$help" >&2
exit 1;;
1) ;;
*) echo "$me: too many arguments$help" >&2
exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
linux-gnu*)
nto-qnx* | linux-gnu* | storm-chaos*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@ -94,15 +143,25 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple)
-apple | -axis)
os=
basic_machine=$1
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
;;
-scout)
;;
-wrs)
os=-vxworks
basic_machine=$1
;;
-hiux*)
os=-hiuxwe2
;;
-sco5)
os=sco3.2v5
os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
@ -121,6 +180,9 @@ case $os in
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-udk*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@ -143,25 +205,47 @@ case $os in
-psos*)
os=-psos
;;
-mint | -mint[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
tahoe | i860 | m68k | m68000 | m88k | ns32k | arm \
| arme[lb] | pyramid \
| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
| alpha | we32k | ns16k | clipper | i370 | sh \
| powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \
| pdp11 | mips64el | mips64orion | mips64orionel \
| sparc | sparclet | sparclite | sparc64)
tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
| arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
| pyramid | mn10200 | mn10300 | tron | a29k \
| 580 | i960 | h8300 \
| x86 | ppcbe | mipsbe | mipsle | shbe | shle \
| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
| hppa64 \
| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
| alphaev6[78] \
| we32k | ns16k | clipper | i370 | sh | sh[34] \
| powerpc | powerpcle \
| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
| mips64orion | mips64orionel | mipstx39 | mipstx39el \
| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
| mips64vr5000 | miprs64vr5000el | mcore \
| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
| thumb | d10v | d30v | fr30 | avr)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i[3456]86)
i[234567]86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
@ -170,23 +254,50 @@ case $basic_machine in
exit 1
;;
# Recognize the basic CPU types with company name.
vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \
| sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
| none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
| hppa-* | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
| pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
| pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \
| mips64el-* | mips64orion-* | mips64orionel-* | f301-*)
# FIXME: clean up the formatting here.
vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
| arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
| power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
| xmp-* | ymp-* \
| x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
| hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
| hppa2.0n-* | hppa64-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
| alphaev6[78]-* \
| we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
| clipper-* | orion-* \
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
| sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
| mips64el-* | mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
| mipstx39-* | mipstx39el-* | mcore-* \
| f30[01]-* | s390-* | sv1-* | t3e-* \
| m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
| thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
| bs2000-* | tic54x-* | c54x-* | x86_64-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
basic_machine=i386-unknown
os=-bsd
;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
a29khif)
basic_machine=a29k-amd
os=-udi
;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
;;
alliant | fx80)
basic_machine=fx80-alliant
;;
@ -202,20 +313,24 @@ case $basic_machine in
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-cbm
basic_machine=m68k-unknown
;;
amigados)
basic_machine=m68k-cbm
os=-amigados
amigaos | amigados)
basic_machine=m68k-unknown
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-cbm
basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
os=-bsd
;;
aux)
basic_machine=m68k-apple
os=-aux
@ -259,6 +374,9 @@ case $basic_machine in
crds | unos)
basic_machine=m68k-crds
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
@ -292,6 +410,10 @@ case $basic_machine in
encore | umax | mmax)
basic_machine=ns32k-encore
;;
es1800 | OSE68k | ose68k | ose | OSE)
basic_machine=m68k-ericsson
os=-ose
;;
fx2800)
basic_machine=i860-alliant
;;
@ -310,6 +432,14 @@ case $basic_machine in
basic_machine=h8300-hitachi
os=-hms
;;
h8300xray)
basic_machine=h8300-hitachi
os=-xray
;;
h8500hms)
basic_machine=h8500-hitachi
os=-hms
;;
harris)
basic_machine=m88k-harris
os=-sysv3
@ -325,13 +455,30 @@ case $basic_machine in
basic_machine=m68k-hp
os=-hpux
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
hp9k6[0-9][0-9] | hp6[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k7[0-79][0-9] | hp7[0-79][0-9])
basic_machine=hppa1.1-hp
;;
hp9k78[0-9] | hp78[0-9])
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][13679] | hp8[0-9][13679])
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
@ -340,27 +487,54 @@ case $basic_machine in
hppa-next)
os=-nextstep3
;;
hppaosf)
basic_machine=hppa1.1-hp
os=-osf
;;
hppro)
basic_machine=hppa1.1-hp
os=-proelf
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
os=-mvs
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i[3456]86v32)
i[34567]86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i[3456]86v4*)
i[34567]86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i[3456]86v)
i[34567]86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i[3456]86sol2)
i[34567]86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
i386mach)
basic_machine=i386-mach
os=-mach
;;
i386-vsta | vsta)
basic_machine=i386-unknown
os=-vsta
;;
i386-go32 | go32)
basic_machine=i386-unknown
os=-go32
;;
i386-mingw32 | mingw32)
basic_machine=i386-unknown
os=-mingw32
;;
i[34567]86-pw32 | pw32)
basic_machine=i586-unknown
os=-pw32
;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
@ -389,16 +563,52 @@ case $basic_machine in
miniframe)
basic_machine=m68000-convergent
;;
*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
mipsel*-linux*)
basic_machine=mipsel-unknown
os=-linux-gnu
;;
mips*-linux*)
basic_machine=mips-unknown
os=-linux-gnu
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
mmix*)
basic_machine=mmix-knuth
os=-mmixware
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
;;
msdos)
basic_machine=i386-unknown
os=-msdos
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
netbsd386)
basic_machine=i386-unknown
os=-netbsd
;;
netwinder)
basic_machine=armv4l-rebel
os=-linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
@ -411,6 +621,10 @@ case $basic_machine in
basic_machine=mips-sony
os=-newsos
;;
necv70)
basic_machine=v70-nec
os=-sysv
;;
next | m*-next )
basic_machine=m68k-next
case $os in
@ -436,9 +650,32 @@ case $basic_machine in
basic_machine=i960-intel
os=-nindy
;;
mon960)
basic_machine=i960-intel
os=-mon960
;;
nonstopux)
basic_machine=mips-compaq
os=-nonstopux
;;
np1)
basic_machine=np1-gould
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
;;
os68k)
basic_machine=m68k-none
os=-os68k
;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
@ -456,30 +693,28 @@ case $basic_machine in
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pentium | p5)
basic_machine=i586-intel
pentium | p5 | k5 | k6 | nexgen)
basic_machine=i586-pc
;;
pentiumpro | p6)
basic_machine=i686-intel
pentiumpro | p6 | 6x86 | athlon)
basic_machine=i686-pc
;;
pentium-* | p5-*)
pentiumii | pentium2)
basic_machine=i686-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-*)
pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
k5)
# We don't have specific support for AMD's K5 yet, so just call it a Pentium
basic_machine=i586-amd
;;
nexen)
# We don't have specific support for Nexgen yet, so just call it a Pentium
basic_machine=i586-nexgen
pentiumii-* | pentium2-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=rs6000-ibm
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
@ -494,12 +729,20 @@ case $basic_machine in
ps2)
basic_machine=i386-ibm
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
sequent)
basic_machine=i386-sequent
;;
@ -507,6 +750,10 @@ case $basic_machine in
basic_machine=sh-hitachi
os=-hms
;;
sparclite-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
sps7)
basic_machine=m68k-bull
os=-sysv2
@ -514,6 +761,13 @@ case $basic_machine in
spur)
basic_machine=spur-unknown
;;
st2000)
basic_machine=m68k-tandem
;;
stratus)
basic_machine=i860-stratus
os=-sysv4
;;
sun2)
basic_machine=m68000-sun
;;
@ -554,10 +808,28 @@ case $basic_machine in
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
sv1)
basic_machine=sv1-cray
os=-unicos
;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
t3e)
basic_machine=t3e-cray
os=-unicos
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
@ -569,6 +841,10 @@ case $basic_machine in
basic_machine=a29k-nyu
os=-sym1
;;
v810 | necv810)
basic_machine=v810-nec
os=-none
;;
vaxv)
basic_machine=vax-dec
os=-sysv
@ -577,7 +853,7 @@ case $basic_machine in
basic_machine=vax-dec
os=-vms
;;
vpp*|vx|vx-*)
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
@ -592,6 +868,14 @@ case $basic_machine in
basic_machine=a29k-wrs
os=-vxworks
;;
w65*)
basic_machine=w65-wdc
os=-none
;;
w89k-*)
basic_machine=hppa1.1-winbond
os=-proelf
;;
xmp)
basic_machine=xmp-cray
os=-unicos
@ -599,6 +883,10 @@ case $basic_machine in
xps | xps100)
basic_machine=xps100-honeywell
;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
;;
none)
basic_machine=none-none
os=-none
@ -606,8 +894,21 @@ case $basic_machine in
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
w89k)
basic_machine=hppa1.1-winbond
;;
op50n)
basic_machine=hppa1.1-oki
;;
op60c)
basic_machine=hppa1.1-oki
;;
mips)
basic_machine=mips-mips
if [ x$os = x-linux-gnu ]; then
basic_machine=mips-unknown
else
basic_machine=mips-mips
fi
;;
romp)
basic_machine=romp-ibm
@ -624,7 +925,10 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
sparc)
sh3 | sh4)
basic_machine=sh-unknown
;;
sparc | sparcv9)
basic_machine=sparc-sun
;;
cydra)
@ -636,6 +940,16 @@ case $basic_machine in
orion105)
basic_machine=clipper-highlevel
;;
mac | mpw | mac-mpw)
basic_machine=m68k-apple
;;
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
c4x*)
basic_machine=c4x-none
os=-coff
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
@ -668,9 +982,12 @@ case $os in
-solaris)
os=-solaris2
;;
-unixware* | svr4*)
-svr4*)
os=-sysv4
;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
@ -681,17 +998,39 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -linux-gnu* | -uxpv*)
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* | -storm-chaos*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
case $basic_machine in
x86-* | i[34567]86-*)
;;
*)
os=-nto$os
;;
esac
;;
-nto*)
os=-nto-qnx
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
@ -701,6 +1040,12 @@ case $os in
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
-opened*)
os=-openedition
;;
-wince*)
os=-wince
;;
-osfrose*)
os=-osfrose
;;
@ -716,12 +1061,18 @@ case $os in
-acis*)
os=-aos
;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
-ns2 )
os=-nextstep2
;;
-nsk*)
os=-nsk
;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
@ -747,9 +1098,18 @@ case $os in
# This must come after -sysvr4.
-sysv*)
;;
-ose*)
os=-ose
;;
-es1800*)
os=-ose
;;
-xenix)
os=-xenix
;;
-*mint | -*MiNT)
os=-mint
;;
-none)
;;
*)
@ -775,6 +1135,9 @@ case $basic_machine in
*-acorn)
os=-riscix1.2
;;
arm*-rebel)
os=-linux
;;
arm*-semi)
os=-aout
;;
@ -796,15 +1159,36 @@ case $basic_machine in
# default.
# os=-sunos4
;;
m68*-cisco)
os=-aout
;;
mips*-cisco)
os=-elf
;;
mips*-*)
os=-elf
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
*-be)
os=-beos
;;
*-ibm)
os=-aix
;;
*-wec)
os=-proelf
;;
*-winbond)
os=-proelf
;;
*-oki)
os=-proelf
;;
*-hp)
os=-hpux
;;
@ -815,7 +1199,7 @@ case $basic_machine in
os=-sysv
;;
*-cbm)
os=-amigados
os=-amigaos
;;
*-dg)
os=-dgux
@ -865,9 +1249,21 @@ case $basic_machine in
*-masscomp)
os=-rtu
;;
f301-fujitsu)
f30[01]-fujitsu)
os=-uxpv
;;
*-rom68k)
os=-coff
;;
*-*bug)
os=-coff
;;
*-apple)
os=-macos
;;
*-atari*)
os=-mint
;;
*)
os=-none
;;
@ -889,9 +1285,15 @@ case $basic_machine in
-aix*)
vendor=ibm
;;
-beos*)
vendor=be
;;
-hpux*)
vendor=hp
;;
-mpeix*)
vendor=hp
;;
-hiux*)
vendor=hitachi
;;
@ -907,7 +1309,7 @@ case $basic_machine in
-genix*)
vendor=ns
;;
-mvs*)
-mvs* | -opened*)
vendor=ibm
;;
-ptx*)
@ -919,9 +1321,26 @@ case $basic_machine in
-aux*)
vendor=apple
;;
-hms*)
vendor=hitachi
;;
-mpw* | -macos*)
vendor=apple
;;
-*mint | -*MiNT)
vendor=atari
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.87.2.4 2000/01/25 18:39:02 itojun Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.132.4.1 2001/01/17 18:29:58 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@ -6,59 +6,72 @@ dnl
dnl Process this file with autoconf to produce a configure script.
dnl
AC_REVISION($Revision: 1.132.4.1 $)
AC_PREREQ(2.13)
AC_INIT(tcpdump.c)
AC_CANONICAL_SYSTEM
umask 002
if test -z "$PWD" ; then
PWD=`pwd`
fi
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_C_INLINE
AC_C___ATTRIBUTE__
AC_CHECK_HEADERS(fcntl.h malloc.h memory.h rpc/rpcent.h)
AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netinet/if_ether.h)
AC_HEADER_TIME
case "$target_os" in
linux*)
AC_MSG_CHECKING(Linux kernel version)
AC_CACHE_VAL(ac_cv_linux_vers,
ac_cv_linux_vers=`uname -r 2>&1 | \
sed -n -e '$s/.* //' -e '$s/\..*//p'`)
if test "$cross_compiling" = yes; then
AC_CACHE_VAL(ac_cv_linux_vers,
ac_cv_linux_vers=unknown)
else
AC_CACHE_VAL(ac_cv_linux_vers,
ac_cv_linux_vers=`uname -r 2>&1 | \
sed -n -e '$s/.* //' -e '$s/\..*//p'`)
fi
AC_MSG_RESULT($ac_cv_linux_vers)
if test $ac_cv_linux_vers = unknown ; then
AC_MSG_ERROR(cannot determine linux version when cross-compiling)
fi
if test $ac_cv_linux_vers -lt 2 ; then
AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
fi
AC_DEFINE(HAVE_NET_SLIP_H)
;;
*)
AC_CHECK_HEADERS(net/slip.h)
;;
esac
AC_CHECK_HEADERS(smi.h)
AC_CHECK_LIB(smi, main)
AC_CHECK_LIB(smi, smiInit)
AC_MSG_CHECKING([whether to enable libsmi])
AC_TRY_RUN([ /* libsmi available check */
#include <smi.h>
main()
{
int current, revision, age, n;
const int required = 2;
if (smiInit(""))
exit(1);
else
exit(0);
if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
exit(2);
n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
if (n != 3)
exit(3);
if (required < current - age || required > current)
exit(4);
exit(0);
}
],
[ AC_MSG_RESULT(yes)
AC_DEFINE(LIBSMI)
libsmi=yes],
[ AC_MSG_RESULT(no)
libsmi=no],
[ AC_MSG_RESULT(not when cross-compiling)
libsmi=no]
)
@ -70,7 +83,6 @@ AC_ARG_ENABLE(ipv6,
--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
@ -93,7 +105,6 @@ main()
}
],
[ 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],
@ -213,7 +224,7 @@ fi
if test "$ipv6" = "yes"; then
AC_CHECK_FUNCS(getaddrinfo, [dnl
AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
AC_MSG_CHECKING(getaddrinfo bug)
AC_TRY_RUN([
#include <sys/types.h>
@ -329,7 +340,31 @@ main()
fi
AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
fi
AC_REPLACE_FUNCS(inet_ntop inet_pton inet_aton)
dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
AC_MSG_CHECKING(for inet_ntop)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>], [char src[4], dst[128];
inet_ntop(AF_INET, src, dst, sizeof(dst));],
[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
AC_REPLACE_FUNCS(inet_ntop)])
AC_MSG_CHECKING(for inet_pton)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>], [char src[128], dst[4];
inet_pton(AF_INET, src, dst);],
[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
AC_REPLACE_FUNCS(inet_pton)])
AC_MSG_CHECKING(for inet_aton)
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>], [char src[128];
struct in_addr dst;
inet_aton(src, &dst);],
[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
AC_REPLACE_FUNCS(inet_aton)])
dnl portability macros for getaddrinfo/getnameinfo
dnl
@ -339,13 +374,6 @@ 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.
@ -403,13 +431,6 @@ 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)
@ -429,21 +450,40 @@ if test "$missing_includes" = "yes"; then
fi
AC_REPLACE_FUNCS(vfprintf strcasecmp)
AC_CHECK_FUNCS(ether_ntohost setlinebuf gethostbyname2)
AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy)
AC_CHECK_FUNCS(ether_ntohost setlinebuf)
usegetipnodeby=yes
AC_CHECK_FUNCS(getipnodebyname getipnodebyaddr freeaddrinfo,
[], [usegetipnodeby=no])
if test $usegetipnodeby = yes; then
AC_DEFINE(USE_GETIPNODEBY)
fi
needsnprintf=no
AC_CHECK_FUNCS(vsnprintf snprintf,,
[needsnprintf=yes])
if test $needsnprintf = yes; then
LIBOBJS="$LIBOBJS snprintf.o"
fi
dnl The following generates a warning from autoconf...
errprint(__file__:__line__: please ignore the next warning:
)dnl
AC_C_BIGENDIAN
AC_CHECK_LIB(dnet, main)
AC_CHECK_LIB(rpc, main)
AC_CHECK_LIB(z, uncompress)
AC_CHECK_HEADERS(zlib.h)
AC_CHECK_LIB(nsl, getrpcbynumber)
dnl AC_CHECK_LIB(z, uncompress)
dnl AC_CHECK_HEADERS(zlib.h)
AC_LBL_TYPE_SIGNAL
AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
V_GROUP=0
if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
V_GROUP=wheel
@ -459,14 +499,8 @@ irix*)
V_GROUP=sys
;;
linux*)
V_INCLS="$V_INCLS -I\$(srcdir)/linux-include"
;;
osf*)
V_GROUP=system
dnl Workaround around ip_hl vs. ip_vhl problem in netinet/ip.h
AC_DEFINE(__STDC__,2)
;;
solaris*)
@ -488,99 +522,25 @@ AC_LBL_DEVEL(V_CCOPT)
AC_LBL_SOCKADDR_SA_LEN
AC_MSG_CHECKING(if ether_header uses ether_addr structs)
AC_CACHE_VAL(ac_cv_ether_header_has_ea,
LBL_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $V_INCLS"
AC_TRY_COMPILE([
# include <sys/types.h>
# if __STDC__
/* osf3 has REALLY good prototyes */
struct mbuf;
struct rtentry;
# endif
# include <sys/socket.h>
# include <net/if.h>
# include <netinet/in.h>
# include <netinet/if_ether.h>],
[u_int i =
sizeof(((struct ether_header *)0)->ether_dhost.ether_addr_octet)],
ac_cv_ether_header_has_ea=yes,
ac_cv_ether_header_has_ea=no)
CFLAGS="$LBL_SAVE_CFLAGS")
AC_MSG_RESULT($ac_cv_ether_header_has_ea)
if test $ac_cv_ether_header_has_ea = yes ; then
AC_DEFINE(ETHER_HEADER_HAS_EA)
fi
AC_MSG_CHECKING(if ether_arp uses ether_addr structs)
AC_CACHE_VAL(ac_cv_ether_arp_has_ea,
LBL_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $V_INCLS"
AC_TRY_COMPILE([
# include <sys/types.h>
# if __STDC__
/* osf3 has REALLY good prototyes */
struct mbuf;
struct rtentry;
# endif
# include <sys/socket.h>
# include <net/if.h>
# include <netinet/in.h>
# include <netinet/if_ether.h>],
[u_int i =
sizeof(((struct ether_arp *)0)->arp_sha.ether_addr_octet)],
ac_cv_ether_arp_has_ea=yes,
ac_cv_ether_arp_has_ea=no)
CFLAGS="$LBL_SAVE_CFLAGS")
AC_MSG_RESULT($ac_cv_ether_arp_has_ea)
if test $ac_cv_ether_arp_has_ea = yes ; then
AC_DEFINE(ETHER_ARP_HAS_EA)
fi
AC_MSG_CHECKING(if ether_arp uses erp_xsha member)
AC_CACHE_VAL(ac_cv_struct_ether_arp_x,
LBL_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $V_INCLS"
AC_TRY_COMPILE([
# include <sys/types.h>
# include <sys/socket.h>
# if __STDC__
/* osf3 has REALLY good prototyes */
struct mbuf;
struct rtentry;
# endif
# include <net/if.h>
# include <netinet/in.h>
# include <netinet/if_ether.h>],
[u_int i = sizeof( ((struct ether_arp *)0)->arp_xsha)],
ac_cv_struct_ether_arp_x=yes,
ac_cv_struct_ether_arp_x=no)
CFLAGS="$LBL_SAVE_CFLAGS")
AC_MSG_RESULT($ac_cv_struct_ether_arp_x)
if test $ac_cv_struct_ether_arp_x = yes ; then
AC_DEFINE(ETHER_ARP_HAS_X)
fi
AC_LBL_UNALIGNED_ACCESS
AC_VAR_H_ERRNO
AC_ARG_WITH(crypto, [ --without-crypto disable crypto support],
[], [
AC_MSG_CHECKING(for SSLeay)
ac_cv_ssleay_path=no
incdir=no
for dir in /usr/local /usr/local/ssl /usr/pkg; do
for dir in /usr /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
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"
elif 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;
@ -592,7 +552,7 @@ 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"
LDFLAGS="-L$dir/lib $LDFLAGS"
if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
LIBS="$LIBS -lRSAglue"
fi
@ -600,11 +560,10 @@ if test "$ac_cv_ssleay_path" != no; 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)
AC_CHECK_HEADERS(cast.h)
if test "$ac_cv_header_cast_h" = "yes"; then
AC_MSG_CHECKING(for buggy CAST128)
@ -638,11 +597,8 @@ main()
CPPFLAGS=$bak_CPPFLAGS
fi
if test -r ${srcdir}/lbl/gnuc.h ; then
rm -f gnuc.h
ln -s ${srcdir}/lbl/gnuc.h gnuc.h
fi
])
AC_CHECK_HEADERS(rc5.h)
AC_SUBST(V_CCOPT)
AC_SUBST(V_GROUP)
@ -654,9 +610,10 @@ AC_PROG_INSTALL
AC_CONFIG_HEADER(config.h)
AC_OUTPUT(Makefile)
if test -f .devel ; then
AC_OUTPUT_COMMANDS([if test -f .devel; then
echo timestamp > stamp-h
cat Makefile-devel-adds >> Makefile
make depend
fi
fi])
AC_OUTPUT(Makefile)
exit 0

View File

@ -18,21 +18,21 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.6.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.7 2000/10/03 02:54:55 itojun Exp $ (LBL)
*/
typedef unsigned char byte[1]; /* single byte field */
typedef unsigned char word[2]; /* 2 byte field */
typedef unsigned char longword[4]; /* 4 bytes field */
typedef u_int8_t byte[1]; /* single byte field */
typedef u_int8_t word[2]; /* 2 byte field */
typedef u_int8_t longword[4]; /* 4 bytes field */
/*
* Definitions for DECNET Phase IV protocol headers
*/
union etheraddress {
unsigned char dne_addr[6]; /* full ethernet address */
u_int8_t dne_addr[6]; /* full ethernet address */
struct {
unsigned char dne_hiord[4]; /* DECnet HIORD prefix */
unsigned char dne_nodeaddr[2]; /* DECnet node address */
u_int8_t dne_hiord[4]; /* DECnet HIORD prefix */
u_int8_t dne_nodeaddr[2]; /* DECnet node address */
} dne_remote;
};
@ -46,8 +46,8 @@ typedef union etheraddress etheraddr; /* Ethernet address */
#define DN_MAXADDL 20 /* max size of DECnet address */
struct dn_naddr {
unsigned short a_len; /* length of address */
unsigned char a_addr[DN_MAXADDL]; /* address as bytes */
u_int16_t a_len; /* length of address */
u_int8_t a_addr[DN_MAXADDL]; /* address as bytes */
};
/*

View File

@ -1,3 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/dhcp6.h,v 1.4 2000/12/17 23:07:48 guy Exp $ (LBL) */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@ -27,7 +28,7 @@
* SUCH DAMAGE.
*/
/*
* draft-ietf-dhc-dhcpv6-14
* draft-ietf-dhc-dhcpv6-15
*/
#ifndef __DHCP6_H_DEFINED
@ -79,20 +80,27 @@ 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 */
#define DH6SOL_PREFIX 0x40
/* XXX: solicit-ID is a 9-bit field...ugly! */
#define DH6SOL_SOLICIT_ID_MASK 0x01ff
#define DH6SOL_SOLICIT_ID_SHIFT 0
#define DH6SOL_SOLICIT_ID(x) \
(((x) & DH6SOL_SOLICIT_ID_MASK) >> DH6SOL_SOLICIT_ID_SHIFT)
#define DH6SOL_SOLICIT_PLEN_MASK 0xfe00
#define DH6SOL_SOLICIT_PLEN_SHIFT 9
#define DH6SOL_SOLICIT_PLEN(x) \
(((x) & DH6SOL_SOLICIT_PLEN_MASK) >> DH6SOL_SOLICIT_PLEN_SHIFT)
u_int16_t dh6sol_plen_id; /* prefix-len and solict-ID */
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_rsv_id; /* reserved and uppermost bit of ID */
u_int8_t dh6adv_solcit_id; /* lower 8 bits of solicit-ID */
u_int8_t dh6adv_pref;
struct in6_addr dh6adv_cliaddr; /* client's lladdr */
struct in6_addr dh6adv_cliaddr; /* client's link-local addr */
struct in6_addr dh6adv_relayaddr; /* relay agent's (non-ll) addr */
struct in6_addr dh6adv_serveraddr; /* server's addr */
/* extensions */
@ -102,25 +110,26 @@ 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
#define DH6REQ_REBOOT 0x40
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 */
struct in6_addr dh6req_serveraddr; /* 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_RELAYPRESENT 0x80
#define DH6REP_STATMASK 0x7f
u_int16_t dh6rep_xid; /* transaction-ID */
/* struct in6_addr dh6rep_cliaddr; optional: client's lladdr */
struct in6_addr dh6rep_cliaddr; /* client's lladdr */
/* struct in6_addr dh6rep_relayaddr; optional: relay address */
/* extensions */
};
/* XXX: followings are based on older drafts */
struct dhcp6_release {
u_int8_t dh6rel_msgtype; /* DH6_RELEASE */
u_int8_t dh6rel_flags;

View File

@ -1,3 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/dhcp6opt.h,v 1.3 2000/12/17 23:07:49 guy Exp $ (LBL) */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@ -72,9 +73,9 @@ struct dhcp6_opt {
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));
extern void dhcp6opttab_init (void);
extern struct dhcp6_opt *dhcp6opttab_byname (char *);
extern struct dhcp6_opt *dhcp6opttab_bycode (u_int);
#endif
#endif /*__DHCP6OPT_H_DEFINED*/

68
contrib/tcpdump/esp.h Normal file
View File

@ -0,0 +1,68 @@
/* $NetBSD: esp.h,v 1.13 2000/09/26 08:37:38 itojun Exp $ */
/* $KAME: esp.h,v 1.15 2000/09/20 18:15:22 itojun Exp $ */
/*
* 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.
*/
/*
* RFC1827/2406 Encapsulated Security Payload.
*/
#ifndef _NETINET6_ESP_H_
#define _NETINET6_ESP_H_
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 */
};
struct esptail {
u_int8_t esp_padlen; /* pad length */
u_int8_t esp_nxt; /* Next header */
/*variable size, 32bit bound*/ /* Authentication data (new IPsec)*/
};
#endif /*_NETINET6_ESP_H_*/

59
contrib/tcpdump/ether.h Normal file
View File

@ -0,0 +1,59 @@
/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.6 2000/10/09 03:24:24 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* 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 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.
*
* @(#)if_ether.h 8.3 (Berkeley) 5/2/95
*/
#define ETHERMTU 1500
/*
* The number of bytes in an ethernet (MAC) address.
*/
#define ETHER_ADDR_LEN 6
/*
* Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
*/
struct ether_header {
u_int8_t ether_dhost[ETHER_ADDR_LEN];
u_int8_t ether_shost[ETHER_ADDR_LEN];
u_int16_t ether_type;
};
/*
* Length of a DEC/Intel/Xerox or 802.3 Ethernet header; note that some
* compilers may pad "struct ether_header" to a multiple of 4 bytes,
* for example, so "sizeof (struct ether_header)" may not give the right
* answer.
*/
#define ETHER_HDRLEN 14

View File

@ -18,11 +18,33 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.7.2.1 2000/01/29 22:00:12 fenner Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.12 2000/09/23 08:03:30 guy Exp $ (LBL)
*/
/* Types missing from some systems */
/*
* Ethernet types.
*
* We wrap the declarations with #ifdef, so that if a file includes
* <netinet/if_ether.h>, which may declare some of these, we don't
* get a bunch of complaints from the C compiler about redefinitions
* of these values.
*
* We declare all of them here so that no file has to include
* <netinet/if_ether.h> if all it needs are ETHERTYPE_ values.
*/
#ifndef ETHERTYPE_PUP
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
#endif
#ifndef ETHERTYPE_IP
#define ETHERTYPE_IP 0x0800 /* IP protocol */
#endif
#ifndef ETHERTYPE_ARP
#define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
#endif
#ifndef ETHERTYPE_REVARP
#define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
#endif
#ifndef ETHERTYPE_NS
#define ETHERTYPE_NS 0x0600
#endif
@ -74,6 +96,9 @@
#ifndef ETHERTYPE_8021Q
#define ETHERTYPE_8021Q 0x8100
#endif
#ifndef ETHERTYPE_IPX
#define ETHERTYPE_IPX 0x8137
#endif
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86dd
#endif

View File

@ -18,40 +18,40 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.15.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.16 2000/10/03 02:54:55 itojun Exp $ (LBL)
*/
/* Network to host order macros */
#ifdef LBL_ALIGN
#define EXTRACT_16BITS(p) \
((u_short)*((u_char *)(p) + 0) << 8 | \
(u_short)*((u_char *)(p) + 1))
((u_int16_t)*((u_int8_t *)(p) + 0) << 8 | \
(u_int16_t)*((u_int8_t *)(p) + 1))
#define EXTRACT_32BITS(p) \
((u_int32_t)*((u_char *)(p) + 0) << 24 | \
(u_int32_t)*((u_char *)(p) + 1) << 16 | \
(u_int32_t)*((u_char *)(p) + 2) << 8 | \
(u_int32_t)*((u_char *)(p) + 3))
((u_int32_t)*((u_int8_t *)(p) + 0) << 24 | \
(u_int32_t)*((u_int8_t *)(p) + 1) << 16 | \
(u_int32_t)*((u_int8_t *)(p) + 2) << 8 | \
(u_int32_t)*((u_int8_t *)(p) + 3))
#else
#define EXTRACT_16BITS(p) \
((u_short)ntohs(*(u_short *)(p)))
((u_int16_t)ntohs(*(u_int16_t *)(p)))
#define EXTRACT_32BITS(p) \
((u_int32_t)ntohl(*(u_int32_t *)(p)))
#endif
#define EXTRACT_24BITS(p) \
((u_int32_t)*((u_char *)(p) + 0) << 16 | \
(u_int32_t)*((u_char *)(p) + 1) << 8 | \
(u_int32_t)*((u_char *)(p) + 2))
((u_int32_t)*((u_int8_t *)(p) + 0) << 16 | \
(u_int32_t)*((u_int8_t *)(p) + 1) << 8 | \
(u_int32_t)*((u_int8_t *)(p) + 2))
/* Little endian protocol host order macros */
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_LE_16BITS(p) \
((u_short)*((u_char *)(p) + 1) << 8 | \
(u_short)*((u_char *)(p) + 0))
((u_int16_t)*((u_int8_t *)(p) + 1) << 8 | \
(u_int16_t)*((u_int8_t *)(p) + 0))
#define EXTRACT_LE_32BITS(p) \
((u_int32_t)*((u_char *)(p) + 3) << 24 | \
(u_int32_t)*((u_char *)(p) + 2) << 16 | \
(u_int32_t)*((u_char *)(p) + 1) << 8 | \
(u_int32_t)*((u_char *)(p) + 0))
((u_int32_t)*((u_int8_t *)(p) + 3) << 24 | \
(u_int32_t)*((u_int8_t *)(p) + 2) << 16 | \
(u_int32_t)*((u_int8_t *)(p) + 1) << 8 | \
(u_int32_t)*((u_int8_t *)(p) + 0))

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.8.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.9 2000/10/09 02:59:39 guy Exp $ (LBL)
*/
/*
@ -37,6 +37,13 @@ struct fddi_header {
u_char fddi_shost[6];
};
/*
* Length of an FDDI header; note that some compilers may pad
* "struct fddi_header" to a multiple of 4 bytes, for example, so
* "sizeof (struct fddi_header)" may not give the right
* answer.
*/
#define FDDI_HDRLEN 13
/* Useful values for fddi_fc (frame control) field */

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.3 1999/11/21 09:36:47 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.4 2000/07/11 00:49:02 assar Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -36,7 +36,6 @@ static const char rcsid[] =
#include <time.h>
#endif
#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif

412
contrib/tcpdump/icmp6.h Normal file
View File

@ -0,0 +1,412 @@
/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.4 2000/12/17 23:13:32 guy Exp $ (LBL) */
/* $NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp $ */
/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
/*
* 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.
*/
/*
* Copyright (c) 1982, 1986, 1993
* 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 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.
*
* @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _NETINET_ICMP6_H_
#define _NETINET_ICMP6_H_
struct icmp6_hdr {
u_int8_t icmp6_type; /* type field */
u_int8_t icmp6_code; /* code field */
u_int16_t icmp6_cksum; /* checksum field */
union {
u_int32_t icmp6_un_data32[1]; /* type-specific field */
u_int16_t icmp6_un_data16[2]; /* type-specific field */
u_int8_t icmp6_un_data8[4]; /* type-specific field */
} icmp6_dataun;
};
#define icmp6_data32 icmp6_dataun.icmp6_un_data32
#define icmp6_data16 icmp6_dataun.icmp6_un_data16
#define icmp6_data8 icmp6_dataun.icmp6_un_data8
#define icmp6_pptr icmp6_data32[0] /* parameter prob */
#define icmp6_mtu icmp6_data32[0] /* packet too big */
#define icmp6_id icmp6_data16[0] /* echo request/reply */
#define icmp6_seq icmp6_data16[1] /* echo request/reply */
#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
#define ICMP6_ECHO_REQUEST 128 /* echo service */
#define ICMP6_ECHO_REPLY 129 /* echo reply */
#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
#define MLD6_LISTENER_QUERY 130 /* multicast listener query */
#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
#define MLD6_LISTENER_REPORT 131 /* multicast listener report */
#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
#define MLD6_LISTENER_DONE 132 /* multicast listener done */
#define ND_ROUTER_SOLICIT 133 /* router solicitation */
#define ND_ROUTER_ADVERT 134 /* router advertisment */
#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
#define ND_REDIRECT 137 /* redirect */
#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
#define ICMP6_WRUREQUEST 139 /* who are you request */
#define ICMP6_WRUREPLY 140 /* who are you reply */
#define ICMP6_FQDN_QUERY 139 /* FQDN query */
#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
#define ICMP6_NI_QUERY 139 /* node information request */
#define ICMP6_NI_REPLY 140 /* node information reply */
/* The definitions below are experimental. TBA */
#define MLD6_MTRACE_RESP 141 /* mtrace response(to sender) */
#define MLD6_MTRACE 142 /* mtrace messages */
#define ICMP6_MAXTYPE 142
#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
#define ICMP6_NI_REFUSED 1 /* node information request is refused */
#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
/* Used in kernel only */
#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
/*
* Multicast Listener Discovery
*/
struct mld6_hdr {
struct icmp6_hdr mld6_hdr;
struct in6_addr mld6_addr; /* multicast address */
};
#define mld6_type mld6_hdr.icmp6_type
#define mld6_code mld6_hdr.icmp6_code
#define mld6_cksum mld6_hdr.icmp6_cksum
#define mld6_maxdelay mld6_hdr.icmp6_data16[0]
#define mld6_reserved mld6_hdr.icmp6_data16[1]
/*
* Neighbor Discovery
*/
struct nd_router_solicit { /* router solicitation */
struct icmp6_hdr nd_rs_hdr;
/* could be followed by options */
};
#define nd_rs_type nd_rs_hdr.icmp6_type
#define nd_rs_code nd_rs_hdr.icmp6_code
#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
struct nd_router_advert { /* router advertisement */
struct icmp6_hdr nd_ra_hdr;
u_int32_t nd_ra_reachable; /* reachable time */
u_int32_t nd_ra_retransmit; /* retransmit timer */
/* could be followed by options */
};
#define nd_ra_type nd_ra_hdr.icmp6_type
#define nd_ra_code nd_ra_hdr.icmp6_code
#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
#define ND_RA_FLAG_MANAGED 0x80
#define ND_RA_FLAG_OTHER 0x40
#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
struct nd_neighbor_solicit { /* neighbor solicitation */
struct icmp6_hdr nd_ns_hdr;
struct in6_addr nd_ns_target; /*target address */
/* could be followed by options */
};
#define nd_ns_type nd_ns_hdr.icmp6_type
#define nd_ns_code nd_ns_hdr.icmp6_code
#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
struct nd_neighbor_advert { /* neighbor advertisement */
struct icmp6_hdr nd_na_hdr;
struct in6_addr nd_na_target; /* target address */
/* could be followed by options */
};
#define nd_na_type nd_na_hdr.icmp6_type
#define nd_na_code nd_na_hdr.icmp6_code
#define nd_na_cksum nd_na_hdr.icmp6_cksum
#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
/* netowkr endian */
#define ND_NA_FLAG_ROUTER ((u_int32_t)htonl(0x80000000))
#define ND_NA_FLAG_SOLICITED ((u_int32_t)htonl(0x40000000))
#define ND_NA_FLAG_OVERRIDE ((u_int32_t)htonl(0x20000000))
struct nd_redirect { /* redirect */
struct icmp6_hdr nd_rd_hdr;
struct in6_addr nd_rd_target; /* target address */
struct in6_addr nd_rd_dst; /* destination address */
/* could be followed by options */
};
#define nd_rd_type nd_rd_hdr.icmp6_type
#define nd_rd_code nd_rd_hdr.icmp6_code
#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
struct nd_opt_hdr { /* Neighbor discovery option header */
u_int8_t nd_opt_type;
u_int8_t nd_opt_len;
/* followed by option specific data*/
};
#define ND_OPT_SOURCE_LINKADDR 1
#define ND_OPT_TARGET_LINKADDR 2
#define ND_OPT_PREFIX_INFORMATION 3
#define ND_OPT_REDIRECTED_HEADER 4
#define ND_OPT_MTU 5
#define ND_OPT_ADVINT 7
struct nd_opt_prefix_info { /* prefix information */
u_int8_t nd_opt_pi_type;
u_int8_t nd_opt_pi_len;
u_int8_t nd_opt_pi_prefix_len;
u_int8_t nd_opt_pi_flags_reserved;
u_int32_t nd_opt_pi_valid_time;
u_int32_t nd_opt_pi_preferred_time;
u_int32_t nd_opt_pi_reserved2;
struct in6_addr nd_opt_pi_prefix;
};
#define ND_OPT_PI_FLAG_ONLINK 0x80
#define ND_OPT_PI_FLAG_AUTO 0x40
#define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
struct nd_opt_rd_hdr { /* redirected header */
u_int8_t nd_opt_rh_type;
u_int8_t nd_opt_rh_len;
u_int16_t nd_opt_rh_reserved1;
u_int32_t nd_opt_rh_reserved2;
/* followed by IP header and data */
};
struct nd_opt_mtu { /* MTU option */
u_int8_t nd_opt_mtu_type;
u_int8_t nd_opt_mtu_len;
u_int16_t nd_opt_mtu_reserved;
u_int32_t nd_opt_mtu_mtu;
};
struct nd_opt_advint { /* Advertisement interval option */
u_int8_t nd_opt_advint_type;
u_int8_t nd_opt_advint_len;
u_int16_t nd_opt_advint_reserved;
u_int32_t nd_opt_advint_advint;
};
/*
* icmp6 namelookup
*/
struct icmp6_namelookup {
struct icmp6_hdr icmp6_nl_hdr;
u_int8_t icmp6_nl_nonce[8];
int32_t icmp6_nl_ttl;
#if 0
u_int8_t icmp6_nl_len;
u_int8_t icmp6_nl_name[3];
#endif
/* could be followed by options */
};
/*
* icmp6 node information
*/
struct icmp6_nodeinfo {
struct icmp6_hdr icmp6_ni_hdr;
u_int8_t icmp6_ni_nonce[8];
/* could be followed by reply data */
};
#define ni_type icmp6_ni_hdr.icmp6_type
#define ni_code icmp6_ni_hdr.icmp6_code
#define ni_cksum icmp6_ni_hdr.icmp6_cksum
#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
#define NI_QTYPE_NOOP 0 /* NOOP */
#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
#define NI_QTYPE_DNSNAME 2 /* DNS Name */
#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
/* network endian */
#define NI_SUPTYPE_FLAG_COMPRESS ((u_int16_t)htons(0x1))
#define NI_FQDN_FLAG_VALIDTTL ((u_int16_t)htons(0x1))
/* network endian */
#define NI_NODEADDR_FLAG_TRUNCATE ((u_int16_t)htons(0x1))
#define NI_NODEADDR_FLAG_ALL ((u_int16_t)htons(0x2))
#define NI_NODEADDR_FLAG_COMPAT ((u_int16_t)htons(0x4))
#define NI_NODEADDR_FLAG_LINKLOCAL ((u_int16_t)htons(0x8))
#define NI_NODEADDR_FLAG_SITELOCAL ((u_int16_t)htons(0x10))
#define NI_NODEADDR_FLAG_GLOBAL ((u_int16_t)htons(0x20))
#define NI_NODEADDR_FLAG_ANYCAST ((u_int16_t)htons(0x40)) /* just experimental. not in spec */
struct ni_reply_fqdn {
u_int32_t ni_fqdn_ttl; /* TTL */
u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
};
/*
* Router Renumbering. as router-renum-08.txt
*/
struct icmp6_router_renum { /* router renumbering header */
struct icmp6_hdr rr_hdr;
u_int8_t rr_segnum;
u_int8_t rr_flags;
u_int16_t rr_maxdelay;
u_int32_t rr_reserved;
};
#define ICMP6_RR_FLAGS_TEST 0x80
#define ICMP6_RR_FLAGS_REQRESULT 0x40
#define ICMP6_RR_FLAGS_ALLIF 0x20
#define ICMP6_RR_FLAGS_SPECSITE 0x10
#define ICMP6_RR_FLAGS_PREVDONE 0x08
#define rr_type rr_hdr.icmp6_type
#define rr_code rr_hdr.icmp6_code
#define rr_cksum rr_hdr.icmp6_cksum
#define rr_seqnum rr_hdr.icmp6_data32[0]
struct rr_pco_match { /* match prefix part */
u_int8_t rpm_code;
u_int8_t rpm_len;
u_int8_t rpm_ordinal;
u_int8_t rpm_matchlen;
u_int8_t rpm_minlen;
u_int8_t rpm_maxlen;
u_int16_t rpm_reserved;
struct in6_addr rpm_prefix;
};
#define RPM_PCO_ADD 1
#define RPM_PCO_CHANGE 2
#define RPM_PCO_SETGLOBAL 3
#define RPM_PCO_MAX 4
struct rr_pco_use { /* use prefix part */
u_int8_t rpu_uselen;
u_int8_t rpu_keeplen;
u_int8_t rpu_ramask;
u_int8_t rpu_raflags;
u_int32_t rpu_vltime;
u_int32_t rpu_pltime;
u_int32_t rpu_flags;
struct in6_addr rpu_prefix;
};
#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
/* network endian */
#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((u_int32_t)htonl(0x80000000))
#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((u_int32_t)htonl(0x40000000))
struct rr_result { /* router renumbering result message */
u_int16_t rrr_flags;
u_int8_t rrr_ordinal;
u_int8_t rrr_matchedlen;
u_int32_t rrr_ifid;
struct in6_addr rrr_prefix;
};
/* network endian */
#define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002))
#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001))
#endif /* not _NETINET_ICMP6_H_ */

View File

@ -1,21 +1,18 @@
/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.4 2000/12/17 23:07:49 guy Exp $ (LBL) */
/* Cisco IGRP definitions */
/* IGRP Header */
struct igrphdr {
#ifdef WORDS_BIGENDIAN
u_int ig_v:4; /* protocol version number */
u_int ig_op:4; /* opcode */
#else
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 */
u_short ig_ni; /* number of subnet in local net */
u_short ig_ns; /* number of networks in AS */
u_short ig_nx; /* number of networks ouside AS */
u_short ig_sum; /* checksum of IGRP header & data */
u_int8_t ig_vop; /* protocol version number / opcode */
#define IGRP_V(x) (((x) & 0xf0) >> 4)
#define IGRP_OP(x) ((x) & 0x0f)
u_int8_t ig_ed; /* edition number */
u_int16_t ig_as; /* autonomous system number */
u_int16_t ig_ni; /* number of subnet in local net */
u_int16_t ig_ns; /* number of networks in AS */
u_int16_t ig_nx; /* number of networks ouside AS */
u_int16_t ig_sum; /* checksum of IGRP header & data */
};
#define IGRP_UPDATE 1
@ -24,13 +21,13 @@ struct igrphdr {
/* IGRP routing entry */
struct igrprte {
u_char igr_net[3]; /* 3 significant octets of IP address */
u_char igr_dly[3]; /* delay in tens of microseconds */
u_char igr_bw[3]; /* bandwidth in units of 1 kb/s */
u_char igr_mtu[2]; /* MTU in octets */
u_char igr_rel; /* percent packets successfully tx/rx */
u_char igr_ld; /* percent of channel occupied */
u_char igr_hct; /* hop count */
u_int8_t igr_net[3]; /* 3 significant octets of IP address */
u_int8_t igr_dly[3]; /* delay in tens of microseconds */
u_int8_t igr_bw[3]; /* bandwidth in units of 1 kb/s */
u_int8_t igr_mtu[2]; /* MTU in octets */
u_int8_t igr_rel; /* percent packets successfully tx/rx */
u_int8_t igr_ld; /* percent of channel occupied */
u_int8_t igr_hct; /* hop count */
};
#define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */

View File

@ -18,16 +18,42 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.118 1999/12/22 15:44:09 itojun Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.149 2001/01/02 22:47:06 guy Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
#define tcpdump_interface_h
#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif
#include <sys/types.h>
#include <sys/time.h>
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#endif
/* snprintf et al */
#include <stdarg.h>
#if !defined(HAVE_SNPRINTF)
int snprintf (char *str, size_t sz, const char *format, ...)
__attribute__ ((format (printf, 3, 4)));
#endif
#if !defined(HAVE_VSNPRINTF)
int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
__attribute__((format (printf, 3, 0)));
#endif
#ifndef HAVE_STRLCAT
extern size_t strlcat (char *, const char *, size_t);
#endif
#ifndef HAVE_STRLCPY
extern size_t strlcpy (char *, const char *, size_t);
#endif
struct tok {
int v; /* value */
@ -45,11 +71,11 @@ 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 uflag; /* Print undecoded NFS handles */
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 */
@ -59,6 +85,7 @@ extern int packettype; /* as specified by -T */
#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 */
#define PT_CNFP 7 /* Cisco NetFlow protocol */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
@ -84,30 +111,8 @@ extern int packettype; /* as specified by -T */
#define LITTLE_ENDIAN 1234
#endif
#ifdef ETHER_HEADER_HAS_EA
#define ESRC(ep) ((ep)->ether_shost.ether_addr_octet)
#define EDST(ep) ((ep)->ether_dhost.ether_addr_octet)
#else
#define ESRC(ep) ((ep)->ether_shost)
#define EDST(ep) ((ep)->ether_dhost)
#endif
#ifdef ETHER_ARP_HAS_X
#define SHA(ap) ((ap)->arp_xsha)
#define THA(ap) ((ap)->arp_xtha)
#define SPA(ap) ((ap)->arp_xspa)
#define TPA(ap) ((ap)->arp_xtpa)
#else
#ifdef ETHER_ARP_HAS_EA
#define SHA(ap) ((ap)->arp_sha.ether_addr_octet)
#define THA(ap) ((ap)->arp_tha.ether_addr_octet)
#else
#define SHA(ap) ((ap)->arp_sha)
#define THA(ap) ((ap)->arp_tha)
#endif
#define SPA(ap) ((ap)->arp_spa)
#define TPA(ap) ((ap)->arp_tpa)
#endif
#ifndef NTOHL
#define NTOHL(x) (x) = ntohl(x)
@ -138,9 +143,7 @@ extern const u_char *snapend;
/* Bail if "var" was not captured */
#define TCHECK(var) TCHECK2(var, sizeof(var))
#ifdef __STDC__
struct timeval;
#endif
extern void ts_print(const struct timeval *);
extern void relts_print(int);
@ -152,15 +155,16 @@ extern char *dnaddr_string(u_short);
extern void wrapup(int);
#if __STDC__
extern __dead void error(const char *, ...)
__attribute__((volatile, format (printf, 1, 2)));
extern void error(const char *, ...)
__attribute__((noreturn, format (printf, 1, 2)));
extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
#endif
extern char *read_infile(char *);
extern char *copy_argv(char **);
extern void safeputchar(int);
extern void safeputs(const char *);
extern char *isonsap_string(const u_char *);
extern char *llcsap_string(u_char);
extern char *protoid_string(const u_char *);
@ -169,24 +173,24 @@ extern char *dnnum_string(u_short);
/* The printer routines. */
#ifdef __STDC__
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 ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
const u_char *);
const u_char *, u_short *);
extern void aarp_print(const u_char *, u_int);
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 bxxp_print(const u_char *, u_int);
extern void cnfp_print(const u_char *cp, u_int len, const u_char *bp);
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);
@ -194,15 +198,20 @@ extern void dvmrp_print(const u_char *, u_int);
extern void egp_print(const u_char *, u_int, const u_char *);
extern void ether_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern void token_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 *, u_int, const u_char *);
extern void igmp_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 ipN_print(const u_char *, u_int);
extern void ipx_print(const u_char *, u_int);
extern void isoclns_print(const u_char *, u_int, u_int, const u_char *,
const u_char *);
extern void krb_print(const u_char *, u_int);
extern void llap_print(const u_char *, u_int);
extern void nfsreply_print(const u_char *, u_int, const u_char *);
extern void nfsreq_print(const u_char *, u_int, const u_char *);
extern void ns_print(const u_char *, u_int);
@ -214,7 +223,10 @@ 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_print(register const u_char *, u_int);
extern void ppp_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void ppp_hdlc_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);
@ -227,18 +239,20 @@ 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 sll_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 tcp_print(const u_char *, u_int, const u_char *, int);
extern void tftp_print(const u_char *, u_int);
extern void udp_print(const u_char *, u_int, const u_char *);
extern void timed_print(const u_char *, u_int);
extern void udp_print(const u_char *, u_int, const u_char *, int);
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 netbeui_print(u_short, 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);
@ -247,6 +261,11 @@ 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);
extern void vrrp_print(const u_char *bp, u_int len, int ttl);
extern void cdp_print(const u_char *p, u_int length, u_int caplen,
const u_char *esrc, const u_char *edst);
extern void stp_print(const u_char *p, u_int length);
extern void radius_print(const u_char *, u_int);
#ifdef INET6
extern void ip6_print(const u_char *, int);
@ -258,6 +277,6 @@ 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);
extern void dhcp6_print(const u_char *, u_int, u_int16_t, u_int16_t);
#endif /*INET6*/
extern u_short in_cksum(const u_short *addr, register int len, u_short csum);

159
contrib/tcpdump/ip.h Normal file
View File

@ -0,0 +1,159 @@
/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.7 2000/10/03 09:17:40 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* 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 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.
*
* @(#)ip.h 8.2 (Berkeley) 6/1/94
*/
/*
* Definitions for internet protocol version 4.
* Per RFC 791, September 1981.
*/
#define IPVERSION 4
/*
* Structure of an internet header, naked of options.
*
* We declare ip_len and ip_off to be short, rather than u_short
* pragmatically since otherwise unsigned comparisons can result
* against negative integers quite easily, and fail in subtle ways.
*/
struct ip {
u_int8_t ip_vhl; /* header length, version */
#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
u_int8_t ip_tos; /* type of service */
u_int16_t ip_len; /* total length */
u_int16_t ip_id; /* identification */
u_int16_t ip_off; /* fragment offset field */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
u_int8_t ip_ttl; /* time to live */
u_int8_t ip_p; /* protocol */
u_int16_t ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
};
#define IP_MAXPACKET 65535 /* maximum packet size */
/*
* Definitions for IP type of service (ip_tos)
*/
#define IPTOS_LOWDELAY 0x10
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_RELIABILITY 0x04
/*
* Definitions for IP precedence (also in ip_tos) (hopefully unused)
*/
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
#define IPTOS_PREC_CRITIC_ECP 0xa0
#define IPTOS_PREC_FLASHOVERRIDE 0x80
#define IPTOS_PREC_FLASH 0x60
#define IPTOS_PREC_IMMEDIATE 0x40
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
/*
* Definitions for options.
*/
#define IPOPT_COPIED(o) ((o)&0x80)
#define IPOPT_CLASS(o) ((o)&0x60)
#define IPOPT_NUMBER(o) ((o)&0x1f)
#define IPOPT_CONTROL 0x00
#define IPOPT_RESERVED1 0x20
#define IPOPT_DEBMEAS 0x40
#define IPOPT_RESERVED2 0x60
#define IPOPT_EOL 0 /* end of option list */
#define IPOPT_NOP 1 /* no operation */
#define IPOPT_RR 7 /* record packet route */
#define IPOPT_TS 68 /* timestamp */
#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
#define IPOPT_LSRR 131 /* loose source route */
#define IPOPT_SATID 136 /* satnet id */
#define IPOPT_SSRR 137 /* strict source route */
/*
* Offsets to fields in options other than EOL and NOP.
*/
#define IPOPT_OPTVAL 0 /* option ID */
#define IPOPT_OLEN 1 /* option length */
#define IPOPT_OFFSET 2 /* offset within option */
#define IPOPT_MINOFF 4 /* min value of above */
/*
* Time stamp option structure.
*/
struct ip_timestamp {
u_int8_t ipt_code; /* IPOPT_TS */
u_int8_t ipt_len; /* size of structure (variable) */
u_int8_t ipt_ptr; /* index of current entry */
u_int8_t ipt_oflwflg; /* flags, overflow counter */
#define IPTS_OFLW(ip) (((ipt)->ipt_oflwflg & 0xf0) >> 4)
#define IPTS_FLG(ip) ((ipt)->ipt_oflwflg & 0x0f)
union ipt_timestamp {
u_int32_t ipt_time[1];
struct ipt_ta {
struct in_addr ipt_addr;
u_int32_t ipt_time;
} ipt_ta[1];
} ipt_timestamp;
};
/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
/* bits for security (not byte swapped) */
#define IPOPT_SECUR_UNCLASS 0x0000
#define IPOPT_SECUR_CONFID 0xf135
#define IPOPT_SECUR_EFTO 0x789a
#define IPOPT_SECUR_MMMM 0xbc4d
#define IPOPT_SECUR_RESTR 0xaf13
#define IPOPT_SECUR_SECRET 0xd788
#define IPOPT_SECUR_TOPSECRET 0x6bc5
/*
* Internet implementation parameters.
*/
#define MAXTTL 255 /* maximum time to live (seconds) */
#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
#define IPFRAGTTL 60 /* time to live for frags, slowhz */
#define IPTTLDEC 1 /* subtracted when forwarding */
#define IP_MSS 576 /* default maximum segment size */

195
contrib/tcpdump/ip6.h Normal file
View File

@ -0,0 +1,195 @@
/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.3 2000/12/17 23:07:48 guy Exp $ (LBL) */
/* $NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp $ */
/* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */
/*
* 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.
*/
/*
* Copyright (c) 1982, 1986, 1993
* 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 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.
*
* @(#)ip.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _NETINET_IP6_H_
#define _NETINET_IP6_H_
/*
* Definition for internet protocol version 6.
* RFC 2460
*/
struct ip6_hdr {
union {
struct ip6_hdrctl {
u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */
u_int16_t ip6_un1_plen; /* payload length */
u_int8_t ip6_un1_nxt; /* next header */
u_int8_t ip6_un1_hlim; /* hop limit */
} ip6_un1;
u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
} ip6_ctlun;
struct in6_addr ip6_src; /* source address */
struct in6_addr ip6_dst; /* destination address */
};
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
#define IPV6_VERSION 0x60
#define IPV6_VERSION_MASK 0xf0
/* in network endian */
#define IPV6_FLOWINFO_MASK ((u_int32_t)htonl(0x0fffffff)) /* flow info (28 bits) */
#define IPV6_FLOWLABEL_MASK ((u_int32_t)htonl(0x000fffff)) /* flow label (20 bits) */
#if 1
/* ECN bits proposed by Sally Floyd */
#define IP6TOS_CE 0x01 /* congestion experienced */
#define IP6TOS_ECT 0x02 /* ECN-capable transport */
#endif
/*
* Extension Headers
*/
struct ip6_ext {
u_char ip6e_nxt;
u_char ip6e_len;
};
/* Hop-by-Hop options header */
/* XXX should we pad it to force alignment on an 8-byte boundary? */
struct ip6_hbh {
u_int8_t ip6h_nxt; /* next header */
u_int8_t ip6h_len; /* length in units of 8 octets */
/* followed by options */
};
/* Destination options header */
/* XXX should we pad it to force alignment on an 8-byte boundary? */
struct ip6_dest {
u_int8_t ip6d_nxt; /* next header */
u_int8_t ip6d_len; /* length in units of 8 octets */
/* followed by options */
};
/* Option types and related macros */
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
#define IP6OPT_PADN 0x01 /* 00 0 00001 */
#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
#define IP6OPT_JUMBO_LEN 6
#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
#define IP6OPT_RTALERT_LEN 4
#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
#define IP6OPT_MINLEN 2
#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
#define IP6OPT_EID 0x8a /* 10 0 01010 */
#define IP6OPT_TYPE(o) ((o) & 0xC0)
#define IP6OPT_TYPE_SKIP 0x00
#define IP6OPT_TYPE_DISCARD 0x40
#define IP6OPT_TYPE_FORCEICMP 0x80
#define IP6OPT_TYPE_ICMP 0xC0
#define IP6OPT_MUTABLE 0x20
/* Routing header */
struct ip6_rthdr {
u_int8_t ip6r_nxt; /* next header */
u_int8_t ip6r_len; /* length in units of 8 octets */
u_int8_t ip6r_type; /* routing type */
u_int8_t ip6r_segleft; /* segments left */
/* followed by routing type specific data */
};
/* Type 0 Routing header */
struct ip6_rthdr0 {
u_int8_t ip6r0_nxt; /* next header */
u_int8_t ip6r0_len; /* length in units of 8 octets */
u_int8_t ip6r0_type; /* always zero */
u_int8_t ip6r0_segleft; /* segments left */
u_int8_t ip6r0_reserved; /* reserved field */
u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */
struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
};
/* Fragment header */
struct ip6_frag {
u_int8_t ip6f_nxt; /* next header */
u_int8_t ip6f_reserved; /* reserved field */
u_int16_t ip6f_offlg; /* offset, reserved, and flag */
u_int32_t ip6f_ident; /* identification */
};
/* network endian */
#define IP6F_OFF_MASK ((u_int16_t)htons(0xfff8)) /* mask out offset from _offlg */
#define IP6F_RESERVED_MASK ((u_int16_t)htons(0x0006)) /* reserved bits in ip6f_offlg */
#define IP6F_MORE_FRAG ((u_int16_t)htons(0x0001)) /* more-fragments flag */
#endif /* not _NETINET_IP6_H_ */

View File

@ -26,7 +26,7 @@
* 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 $ */
/* YIPS @(#)$Id: ipsec_doi.h,v 1.4 2000/10/04 03:00:29 itojun Exp $ */
/* refer to RFC 2407 */
@ -51,6 +51,9 @@
#define IPSECDOI_AH_MD5 2
#define IPSECDOI_AH_SHA 3
#define IPSECDOI_AH_DES 4
#define IPSECDOI_AH_SHA2_256 5
#define IPSECDOI_AH_SHA2_384 6
#define IPSECDOI_AH_SHA2_512 7
/* 4.4.1 IPSEC Security Protocol Identifiers */
#define IPSECDOI_PROTO_IPSEC_ESP 3
@ -66,6 +69,8 @@
#define IPSECDOI_ESP_DES_IV32 9
#define IPSECDOI_ESP_RC4 10
#define IPSECDOI_ESP_NULL 11
#define IPSECDOI_ESP_RIJNDAEL 12
#define IPSECDOI_ESP_AES 12
/* 4.4.1 IPSEC Security Protocol Identifiers */
#define IPSECDOI_PROTO_IPCOMP 4
@ -73,7 +78,6 @@
#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 */
@ -88,16 +92,17 @@
#define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1
#define IPSECDOI_ATTR_ENC_MODE_TRNS 2
#define IPSECDOI_ATTR_AUTH 5 /* B */
/* 0 means not to use authentication. */
#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
#define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/
/*
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.
* 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 */
@ -143,22 +148,4 @@ struct ipsecdoi_id {
#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: /tcpdump/master/tcpdump/ipx.h,v 1.1.1.1 1999/10/07 23:47:10 mcr Exp $
* @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.2 2000/10/03 02:54:56 itojun Exp $
*/
/* well-known sockets */
@ -13,16 +13,16 @@
/* IPX transport header */
struct ipxHdr {
u_short cksum; /* Checksum */
u_short length; /* Length, in bytes, including header */
u_char tCtl; /* Transport Control (i.e. hop count) */
u_char pType; /* Packet Type (i.e. level 2 protocol) */
u_short dstNet[2]; /* destination net */
u_char dstNode[6]; /* destination node */
u_short dstSkt; /* destination socket */
u_short srcNet[2]; /* source net */
u_char srcNode[6]; /* source node */
u_short srcSkt; /* source socket */
u_int16_t cksum; /* Checksum */
u_int16_t length; /* Length, in bytes, including header */
u_int8_t tCtl; /* Transport Control (i.e. hop count) */
u_int8_t pType; /* Packet Type (i.e. level 2 protocol) */
u_int16_t dstNet[2]; /* destination net */
u_int8_t dstNode[6]; /* destination node */
u_int16_t dstSkt; /* destination socket */
u_int16_t srcNet[2]; /* source net */
u_int8_t srcNode[6]; /* source node */
u_int16_t srcSkt; /* source socket */
} ipx_hdr_t;
#define ipxSize 30

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* YIPS @(#)$Id: isakmp.h,v 1.4.2.1 2000/01/14 19:19:56 mcr Exp $ */
/* YIPS @(#)$Id: isakmp.h,v 1.7 2000/10/03 05:16:38 itojun Exp $ */
/* refer to RFC 2408 */
@ -369,75 +369,6 @@ struct isakmp_ph2tab {
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

View File

@ -1,3 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.4 2000/12/17 23:07:49 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@ -18,7 +19,7 @@
* 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)
* L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
@ -61,22 +62,22 @@
struct l2tp_avp_vec {
const char *name;
void (*print)(const u_char *, u_int);
void (*print)(const u_char *, u_int32_t);
};
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;
u_int16_t reserved;
u_int32_t crc_errs;
u_int32_t framing_errs;
u_int32_t hardware_overruns;
u_int32_t buffer_overruns;
u_int32_t timeout_errs;
u_int32_t alignment_errs;
};
struct l2tp_accm {
u_short reserved;
u_int send_accm;
u_int recv_accm;
u_int16_t reserved;
u_int32_t send_accm;
u_int32_t recv_accm;
};

View File

@ -20,15 +20,15 @@
*
*/
/* $Id: lane.h,v 1.2 1999/11/21 16:35:11 assar Exp $ */
/* $Id: lane.h,v 1.3 2000/10/03 02:54:56 itojun 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;
u_int16_t le_header;
u_int8_t h_dest[ETHER_ADDR_LEN];
u_int8_t h_source[ETHER_ADDR_LEN];
u_int16_t h_type;
};

View File

@ -18,37 +18,13 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/lbl/os-solaris2.h,v 1.18.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/lbl/os-solaris2.h,v 1.19 2000/10/11 04:02:15 guy Exp $ (LBL)
*/
/* Prototypes missing in SunOS 5 */
int daemon(int, int);
int dn_expand(const u_char *, const u_char *, const u_char *, char *, int);
int dn_skipname(const u_char *, const u_char *);
int flock(int, int);
int getdtablesize(void);
int gethostname(char *, int);
int getpagesize(void);
char *getusershell(void);
char *getwd(char *);
int iruserok(u_int, int, char *, char *);
#ifdef __STDC__
struct utmp;
void login(struct utmp *);
#endif
int logout(const char *);
int res_query(const char *, int, int, u_char *, int);
int setenv(const char *, const char *, int);
#if defined(_STDIO_H) && defined(HAVE_SETLINEBUF)
int setlinebuf(FILE *);
#endif
int sigblock(int);
int sigsetmask(int);
char *strerror(int);
int snprintf(char *, size_t, const char *, ...);
int strcasecmp(const char *, const char *);
void unsetenv(const char *);
#ifdef __STDC__
struct timeval;
#endif
int utimes(const char *, struct timeval *);

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.6.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.8 2000/12/18 07:55:36 guy Exp $ (LBL)
*/
/*
@ -32,19 +32,19 @@
*/
struct llc {
u_char dsap;
u_char ssap;
u_int8_t dsap;
u_int8_t ssap;
union {
u_char u_ctl;
u_short is_ctl;
u_int8_t u_ctl;
u_int16_t is_ctl;
struct {
u_char snap_ui;
u_char snap_pi[5];
u_int8_t snap_ui;
u_int8_t snap_pi[5];
} snap;
struct {
u_char snap_ui;
u_char snap_orgcode[3];
u_char snap_ethertype[2];
u_int8_t snap_ui;
u_int8_t snap_orgcode[3];
u_int8_t snap_ethertype[2];
} snap_ether;
} ctl;
};
@ -61,7 +61,7 @@ struct llc {
#define LLC_S_FMT 1
#define LLC_U_POLL 0x10
#define LLC_IS_POLL 0x0001
#define LLC_IS_POLL 0x0100
#define LLC_XID_FI 0x81
#define LLC_U_CMD(u) ((u) & 0xef)
@ -74,13 +74,13 @@ struct llc {
#define LLC_XID 0xaf
#define LLC_FRMR 0x87
#define LLC_S_CMD(is) (((is) >> 10) & 0x03)
#define LLC_RR 0x0100
#define LLC_RNR 0x0500
#define LLC_REJ 0x0900
#define LLC_S_CMD(is) (((is) >> 1) & 0x03)
#define LLC_RR 0x0001
#define LLC_RNR 0x0005
#define LLC_REJ 0x0009
#define LLC_IS_NR(is) (((is) >> 1) & 0x7f)
#define LLC_I_NS(is) (((is) >> 9) & 0x7f)
#define LLC_IS_NR(is) (((is) >> 9) & 0x7f)
#define LLC_I_NS(is) (((is) >> 1) & 0x7f)
#ifndef LLCSAP_NULL
#define LLCSAP_NULL 0x00

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.5 1999/11/21 09:36:47 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.6 2000/01/17 06:24:23 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -37,13 +37,13 @@ static const char rcsid[] =
#include "machdep.h"
int
abort_on_misalignment(char *ebuf)
abort_on_misalignment(char *ebuf, size_t ebufsiz)
{
#ifdef __osf__
static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS };
if (setsysinfo(SSI_NVPAIRS, (caddr_t)buf, 1, 0, 0) < 0) {
(void)sprintf(ebuf, "setsysinfo: errno %d", errno);
(void)snprintf(ebuf, ebufsiz, "setsysinfo: errno %d", errno);
return (-1);
}
#endif

View File

@ -18,10 +18,10 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.1.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.2 2000/01/17 06:24:24 itojun Exp $ (LBL)
*/
#ifndef tcpdump_machdep_h
#define tcpdump_machdep_h
int abort_on_misalignment(char *);
int abort_on_misalignment(char *, size_t);
#endif

View File

@ -27,7 +27,7 @@
* SUCH DAMAGE.
*/
/* $Id: addrinfo.h,v 1.2 1999/11/21 01:35:41 assar Exp $ */
/* $Id: addrinfo.h,v 1.3 2000/10/24 00:56:52 fenner Exp $ */
#ifndef HAVE_ADDRINFO
@ -79,17 +79,17 @@ struct addrinfo {
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));
extern void freeaddrinfo (struct addrinfo *);
extern void freehostent (struct hostent *);
extern char *gai_strerror (int);
extern int getaddrinfo (const char *, const char *,
const struct addrinfo *, struct addrinfo **);
extern int getnameinfo (const struct sockaddr *, size_t, char *,
size_t, char *, size_t, int);
extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
extern struct hostent *getipnodebyname (const char *, int, int, int *);
extern int inet_pton (int, const char *, void *);
extern const char *inet_ntop (int, const void *, char *, size_t);
#endif /* HAVE_ADDRINFO */
/*

View File

@ -51,7 +51,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/getaddrinfo.c,v 1.6.2.2 2000/01/25 18:39:03 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/missing/getaddrinfo.c,v 1.10 2000/10/24 00:56:53 fenner Exp $";
#endif
#include <sys/types.h>
@ -74,10 +74,6 @@ static const char rcsid[] =
#include <stdio.h>
#include <errno.h>
#ifndef HAVE_PORTABLE_PROTOTYPE
#include "cdecl_ext.h"
#endif
#ifndef HAVE_U_INT32_T
#include "bittypes.h"
#endif
@ -175,24 +171,24 @@ static const struct explore explore[] = {
#endif
static int str_isnumber __P((const char *));
static int explore_fqdn __P((const struct addrinfo *, const char *,
const char *, struct addrinfo **));
static int explore_null __P((const struct addrinfo *, const char *,
const char *, struct addrinfo **));
static int explore_numeric __P((const struct addrinfo *, const char *,
const char *, struct addrinfo **));
static int explore_numeric_scope __P((const struct addrinfo *, const char *,
const char *, struct addrinfo **));
static int get_name __P((const char *, const struct afd *, struct addrinfo **,
char *, const struct addrinfo *, const char *));
static int get_canonname __P((const struct addrinfo *,
struct addrinfo *, const char *));
static struct addrinfo *get_ai __P((const struct addrinfo *,
const struct afd *, const char *));
static int get_portmatch __P((const struct addrinfo *, const char *));
static int get_port __P((struct addrinfo *, const char *, int));
static const struct afd *find_afd __P((int));
static int str_isnumber (const char *);
static int explore_fqdn (const struct addrinfo *, const char *,
const char *, struct addrinfo **);
static int explore_null (const struct addrinfo *, const char *,
const char *, struct addrinfo **);
static int explore_numeric (const struct addrinfo *, const char *,
const char *, struct addrinfo **);
static int explore_numeric_scope (const struct addrinfo *, const char *,
const char *, struct addrinfo **);
static int get_name (const char *, const struct afd *, struct addrinfo **,
char *, const struct addrinfo *, const char *);
static int get_canonname (const struct addrinfo *,
struct addrinfo *, const char *);
static struct addrinfo *get_ai (const struct addrinfo *,
const struct afd *, const char *);
static int get_portmatch (const struct addrinfo *, const char *);
static int get_port (struct addrinfo *, const char *, int);
static const struct afd *find_afd (int);
static char *ai_errlist[] = {
"Success",

View File

@ -43,7 +43,7 @@
#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 $";
"@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.8 2000/10/24 00:56:53 fenner Exp $";
#endif
#include <sys/types.h>
@ -58,10 +58,6 @@ static const char rcsid[] =
#include <stddef.h>
#include <errno.h>
#ifndef HAVE_PORTABLE_PROTOTYPE
#include "cdecl_ext.h"
#endif
#ifdef NEED_ADDRINFO_H
#include "addrinfo.h"
#endif
@ -159,12 +155,12 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
(flags & NI_DGRAM) ? "udp" : "tcp");
}
if (sp) {
if (strlen(sp->s_name) > servlen)
if (strlen(sp->s_name) + 1 > servlen)
return ENI_MEMORY;
strcpy(serv, sp->s_name);
} else {
sprintf(numserv, "%d", ntohs(port));
if (strlen(numserv) > servlen)
snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
if (strlen(numserv) + 1 > servlen)
return ENI_MEMORY;
strcpy(serv, numserv);
}
@ -220,7 +216,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return ENI_SYSTEM;
if (strlen(numaddr) > hostlen)
if (strlen(numaddr) + 1 > hostlen)
return ENI_MEMORY;
strcpy(host, numaddr);
#if defined(INET6) && defined(NI_WITHSCOPEID)
@ -260,7 +256,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
p = strchr(hp->h_name, '.');
if (p) *p = '\0';
}
if (strlen(hp->h_name) > hostlen) {
if (strlen(hp->h_name) + 1 > hostlen) {
#ifdef USE_GETIPNODEBY
freehostent(hp);
#endif
@ -276,7 +272,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return ENI_NOHOSTNAME;
if (strlen(numaddr) > hostlen)
if (strlen(numaddr) + 1 > hostlen)
return ENI_MEMORY;
strcpy(host, numaddr);
}

View File

@ -36,11 +36,11 @@
* SUCH DAMAGE.
*/
/* $Id: inet_aton.c,v 1.1.2.1 2000/01/11 06:58:29 fenner Exp $ */
/* $Id: inet_aton.c,v 1.2 2000/01/09 21:35:45 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 $";
"@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.2 2000/01/09 21:35:45 fenner Exp $";
#endif
#include <sys/types.h>

View File

@ -36,11 +36,11 @@
* SUCH DAMAGE.
*/
/* $Id: inet_ntop.c,v 1.2.2.1 2000/01/11 06:58:30 fenner Exp $ */
/* $Id: inet_ntop.c,v 1.3 2000/01/09 21:35:45 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 $";
"@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.3 2000/01/09 21:35:45 fenner Exp $";
#endif
#include <stdio.h>

View File

@ -36,11 +36,11 @@
* SUCH DAMAGE.
*/
/* $Id: inet_pton.c,v 1.1.2.1 2000/01/11 06:58:30 fenner Exp $ */
/* $Id: inet_pton.c,v 1.2 2000/01/09 21:35:46 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 $";
"@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.2 2000/01/09 21:35:46 fenner Exp $";
#endif
#include <errno.h>

View File

@ -0,0 +1,628 @@
/*
* Copyright (c) 1995-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. 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: snprintf.c,v 1.4 2001/01/02 22:33:04 guy Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.4 2001/01/02 22:33:04 guy Exp $";
#endif
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <interface.h>
enum format_flags {
minus_flag = 1,
plus_flag = 2,
space_flag = 4,
alternate_flag = 8,
zero_flag = 16
};
/*
* Common state
*/
struct state {
unsigned char *str;
unsigned char *s;
unsigned char *theend;
size_t sz;
size_t max_sz;
int (*append_char)(struct state *, unsigned char);
int (*reserve)(struct state *, size_t);
/* XXX - methods */
};
#ifndef HAVE_VSNPRINTF
static int
sn_reserve (struct state *state, size_t n)
{
return state->s + n > state->theend;
}
static int
sn_append_char (struct state *state, unsigned char c)
{
if (sn_reserve (state, 1)) {
return 1;
} else {
*state->s++ = c;
return 0;
}
}
#endif
static int
as_reserve (struct state *state, size_t n)
{
if (state->s + n > state->theend) {
int off = state->s - state->str;
unsigned char *tmp;
if (state->max_sz && state->sz >= state->max_sz)
return 1;
state->sz = max(state->sz * 2, state->sz + n);
if (state->max_sz)
state->sz = min(state->sz, state->max_sz);
tmp = realloc (state->str, state->sz);
if (tmp == NULL)
return 1;
state->str = tmp;
state->s = state->str + off;
state->theend = state->str + state->sz - 1;
}
return 0;
}
static int
as_append_char (struct state *state, unsigned char c)
{
if(as_reserve (state, 1))
return 1;
else {
*state->s++ = c;
return 0;
}
}
static int
append_number(struct state *state,
unsigned long num, unsigned base, char *rep,
int width, int prec, int flags, int minusp)
{
int len = 0;
int i;
/* given precision, ignore zero flag */
if(prec != -1)
flags &= ~zero_flag;
else
prec = 1;
/* zero value with zero precision -> "" */
if(prec == 0 && num == 0)
return 0;
do{
if((*state->append_char)(state, rep[num % base]))
return 1;
len++;
num /= base;
}while(num);
prec -= len;
/* pad with prec zeros */
while(prec-- > 0){
if((*state->append_char)(state, '0'))
return 1;
len++;
}
/* add length of alternate prefix (added later) to len */
if(flags & alternate_flag && (base == 16 || base == 8))
len += base / 8;
/* pad with zeros */
if(flags & zero_flag){
width -= len;
if(minusp || (flags & space_flag) || (flags & plus_flag))
width--;
while(width-- > 0){
if((*state->append_char)(state, '0'))
return 1;
len++;
}
}
/* add alternate prefix */
if(flags & alternate_flag && (base == 16 || base == 8)){
if(base == 16)
if((*state->append_char)(state, rep[10] + 23)) /* XXX */
return 1;
if((*state->append_char)(state, '0'))
return 1;
}
/* add sign */
if(minusp){
if((*state->append_char)(state, '-'))
return 1;
len++;
} else if(flags & plus_flag) {
if((*state->append_char)(state, '+'))
return 1;
len++;
} else if(flags & space_flag) {
if((*state->append_char)(state, ' '))
return 1;
len++;
}
if(flags & minus_flag)
/* swap before padding with spaces */
for(i = 0; i < len / 2; i++){
char c = state->s[-i-1];
state->s[-i-1] = state->s[-len+i];
state->s[-len+i] = c;
}
width -= len;
while(width-- > 0){
if((*state->append_char)(state, ' '))
return 1;
len++;
}
if(!(flags & minus_flag))
/* swap after padding with spaces */
for(i = 0; i < len / 2; i++){
char c = state->s[-i-1];
state->s[-i-1] = state->s[-len+i];
state->s[-len+i] = c;
}
return 0;
}
static int
append_string (struct state *state,
unsigned char *arg,
int width,
int prec,
int flags)
{
if(prec != -1)
width -= prec;
else
width -= strlen((char *)arg);
if(!(flags & minus_flag))
while(width-- > 0)
if((*state->append_char) (state, ' '))
return 1;
if (prec != -1) {
while (*arg && prec--)
if ((*state->append_char) (state, *arg++))
return 1;
} else {
while (*arg)
if ((*state->append_char) (state, *arg++))
return 1;
}
if(flags & minus_flag)
while(width-- > 0)
if((*state->append_char) (state, ' '))
return 1;
return 0;
}
static int
append_char(struct state *state,
unsigned char arg,
int width,
int flags)
{
while(!(flags & minus_flag) && --width > 0)
if((*state->append_char) (state, ' '))
return 1;
if((*state->append_char) (state, arg))
return 1;
while((flags & minus_flag) && --width > 0)
if((*state->append_char) (state, ' '))
return 1;
return 0;
}
/*
* This can't be made into a function...
*/
#define PARSE_INT_FORMAT(res, arg, unsig) \
if (long_flag) \
res = (unsig long)va_arg(arg, unsig long); \
else if (short_flag) \
res = (unsig short)va_arg(arg, unsig int); \
else \
res = (unsig int)va_arg(arg, unsig int)
/*
* zyxprintf - return 0 or -1
*/
static int
xyzprintf (struct state *state, const char *char_format, va_list ap)
{
const unsigned char *format = (const unsigned char *)char_format;
unsigned char c;
while((c = *format++)) {
if (c == '%') {
int flags = 0;
int width = 0;
int prec = -1;
int long_flag = 0;
int short_flag = 0;
/* flags */
while((c = *format++)){
if(c == '-')
flags |= minus_flag;
else if(c == '+')
flags |= plus_flag;
else if(c == ' ')
flags |= space_flag;
else if(c == '#')
flags |= alternate_flag;
else if(c == '0')
flags |= zero_flag;
else
break;
}
if((flags & space_flag) && (flags & plus_flag))
flags ^= space_flag;
if((flags & minus_flag) && (flags & zero_flag))
flags ^= zero_flag;
/* width */
if (isdigit(c))
do {
width = width * 10 + c - '0';
c = *format++;
} while(isdigit(c));
else if(c == '*') {
width = va_arg(ap, int);
c = *format++;
}
/* precision */
if (c == '.') {
prec = 0;
c = *format++;
if (isdigit(c))
do {
prec = prec * 10 + c - '0';
c = *format++;
} while(isdigit(c));
else if (c == '*') {
prec = va_arg(ap, int);
c = *format++;
}
}
/* size */
if (c == 'h') {
short_flag = 1;
c = *format++;
} else if (c == 'l') {
long_flag = 1;
c = *format++;
}
switch (c) {
case 'c' :
if(append_char(state, va_arg(ap, int), width, flags))
return -1;
break;
case 's' :
if (append_string(state,
va_arg(ap, unsigned char*),
width,
prec,
flags))
return -1;
break;
case 'd' :
case 'i' : {
long arg;
unsigned long num;
int minusp = 0;
PARSE_INT_FORMAT(arg, ap, signed);
if (arg < 0) {
minusp = 1;
num = -arg;
} else
num = arg;
if (append_number (state, num, 10, "0123456789",
width, prec, flags, minusp))
return -1;
break;
}
case 'u' : {
unsigned long arg;
PARSE_INT_FORMAT(arg, ap, unsigned);
if (append_number (state, arg, 10, "0123456789",
width, prec, flags, 0))
return -1;
break;
}
case 'o' : {
unsigned long arg;
PARSE_INT_FORMAT(arg, ap, unsigned);
if (append_number (state, arg, 010, "01234567",
width, prec, flags, 0))
return -1;
break;
}
case 'x' : {
unsigned long arg;
PARSE_INT_FORMAT(arg, ap, unsigned);
if (append_number (state, arg, 0x10, "0123456789abcdef",
width, prec, flags, 0))
return -1;
break;
}
case 'X' :{
unsigned long arg;
PARSE_INT_FORMAT(arg, ap, unsigned);
if (append_number (state, arg, 0x10, "0123456789ABCDEF",
width, prec, flags, 0))
return -1;
break;
}
case 'p' : {
unsigned long arg = (unsigned long)va_arg(ap, void*);
if (append_number (state, arg, 0x10, "0123456789ABCDEF",
width, prec, flags, 0))
return -1;
break;
}
case 'n' : {
int *arg = va_arg(ap, int*);
*arg = state->s - state->str;
break;
}
case '\0' :
--format;
/* FALLTHROUGH */
case '%' :
if ((*state->append_char)(state, c))
return -1;
break;
default :
if ( (*state->append_char)(state, '%')
|| (*state->append_char)(state, c))
return -1;
break;
}
} else
if ((*state->append_char) (state, c))
return -1;
}
return 0;
}
#ifndef HAVE_SNPRINTF
int
snprintf (char *str, size_t sz, const char *format, ...)
{
va_list args;
int ret;
va_start(args, format);
ret = vsnprintf (str, sz, format, args);
#ifdef PARANOIA
{
int ret2;
char *tmp;
tmp = malloc (sz);
if (tmp == NULL)
abort ();
ret2 = vsprintf (tmp, format, args);
if (ret != ret2 || strcmp(str, tmp))
abort ();
free (tmp);
}
#endif
va_end(args);
return ret;
}
#endif
#ifndef HAVE_ASPRINTF
int
asprintf (char **ret, const char *format, ...)
{
va_list args;
int val;
va_start(args, format);
val = vasprintf (ret, format, args);
#ifdef PARANOIA
{
int ret2;
char *tmp;
tmp = malloc (val + 1);
if (tmp == NULL)
abort ();
ret2 = vsprintf (tmp, format, args);
if (val != ret2 || strcmp(*ret, tmp))
abort ();
free (tmp);
}
#endif
va_end(args);
return val;
}
#endif
#ifndef HAVE_ASNPRINTF
int
asnprintf (char **ret, size_t max_sz, const char *format, ...)
{
va_list args;
int val;
va_start(args, format);
val = vasnprintf (ret, max_sz, format, args);
#ifdef PARANOIA
{
int ret2;
char *tmp;
tmp = malloc (val + 1);
if (tmp == NULL)
abort ();
ret2 = vsprintf (tmp, format, args);
if (val != ret2 || strcmp(*ret, tmp))
abort ();
free (tmp);
}
#endif
va_end(args);
return val;
}
#endif
#ifndef HAVE_VASPRINTF
int
vasprintf (char **ret, const char *format, va_list args)
{
return vasnprintf (ret, 0, format, args);
}
#endif
#ifndef HAVE_VASNPRINTF
int
vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
{
int st;
size_t len;
struct state state;
state.max_sz = max_sz;
state.sz = 1;
state.str = malloc(state.sz);
if (state.str == NULL) {
*ret = NULL;
return -1;
}
state.s = state.str;
state.theend = state.s + state.sz - 1;
state.append_char = as_append_char;
state.reserve = as_reserve;
st = xyzprintf (&state, format, args);
if (st) {
free (state.str);
*ret = NULL;
return -1;
} else {
char *tmp;
*state.s = '\0';
len = state.s - state.str;
tmp = realloc (state.str, len+1);
if (tmp == NULL) {
free (state.str);
*ret = NULL;
return -1;
}
*ret = tmp;
return len;
}
}
#endif
#ifndef HAVE_VSNPRINTF
int
vsnprintf (char *str, size_t sz, const char *format, va_list args)
{
struct state state;
int ret;
unsigned char *ustr = (unsigned char *)str;
state.max_sz = 0;
state.sz = sz;
state.str = ustr;
state.s = ustr;
state.theend = ustr + sz - 1;
state.append_char = sn_append_char;
state.reserve = sn_reserve;
ret = xyzprintf (&state, format, args);
*state.s = '\0';
if (ret)
return sz;
else
return state.s - state.str;
}
#endif

View File

@ -0,0 +1,78 @@
/* $NetBSD: strlcat.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */
/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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/missing/strlcat.c,v 1.1 2000/01/19 05:34:19 itojun Exp $ (LBL)";
#endif
#include <config.h>
#include <sys/types.h>
#include <string.h>
#include "interface.h"
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
strlcat(dst, src, siz)
char *dst;
const char *src;
size_t siz;
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
while (*d != '\0' && n-- != 0)
d++;
dlen = d - dst;
n = siz - dlen;
if (n == 0)
return(dlen + strlen(s));
while (*s != '\0') {
if (n != 1) {
*d++ = *s;
n--;
}
s++;
}
*d = '\0';
return(dlen + (s - src)); /* count does not include NUL */
}

View File

@ -0,0 +1,75 @@
/* $NetBSD: strlcpy.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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/missing/strlcpy.c,v 1.1 2000/01/19 05:34:19 itojun Exp $ (LBL)";
#endif
#include <config.h>
#include <sys/types.h>
#include <string.h>
#include "interface.h"
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
strlcpy(dst, src, siz)
char *dst;
const char *src;
size_t siz;
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {
if ((*d++ = *s++) == 0)
break;
} while (--n != 0);
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) {
if (siz != 0)
*d = '\0'; /* NUL-terminate dst */
while (*s++)
;
}
return(s - src - 1); /* count does not include NUL */
}

254
contrib/tcpdump/nameser.h Normal file
View File

@ -0,0 +1,254 @@
/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.5 2000/12/28 20:30:41 itojun Exp $ (LBL) */
/*
* Copyright (c) 1983, 1989, 1993
* 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 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.
*
* @(#)nameser.h 8.2 (Berkeley) 2/16/94
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
* -
* --Copyright--
*/
#ifndef _NAMESER_H_
#define _NAMESER_H_
#include <sys/types.h>
/*
* Define constants based on rfc883
*/
#define PACKETSZ 512 /* maximum packet size */
#define MAXDNAME 256 /* maximum domain name */
#define MAXCDNAME 255 /* maximum compressed domain name */
#define MAXLABEL 63 /* maximum length of domain label */
/* Number of bytes of fixed size data in query structure */
#define QFIXEDSZ 4
/* number of bytes of fixed size data in resource record */
#define RRFIXEDSZ 10
/*
* Internet nameserver port number
*/
#define NAMESERVER_PORT 53
/*
* Currently defined opcodes
*/
#define QUERY 0x0 /* standard query */
#define IQUERY 0x1 /* inverse query */
#define STATUS 0x2 /* nameserver status query */
#if 0
#define xxx 0x3 /* 0x3 reserved */
#endif
/* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
#define UPDATEA 0x9 /* add resource record */
#define UPDATED 0xa /* delete a specific resource record */
#define UPDATEDA 0xb /* delete all named resource record */
#define UPDATEM 0xc /* modify a specific resource record */
#define UPDATEMA 0xd /* modify all named resource record */
#define ZONEINIT 0xe /* initial zone transfer */
#define ZONEREF 0xf /* incremental zone referesh */
/*
* Currently defined response codes
*/
#define NOERROR 0 /* no error */
#define FORMERR 1 /* format error */
#define SERVFAIL 2 /* server failure */
#define NXDOMAIN 3 /* non existent domain */
#define NOTIMP 4 /* not implemented */
#define REFUSED 5 /* query refused */
/* non standard */
#define NOCHANGE 0xf /* update failed to change db */
/*
* Type values for resources and queries
*/
#define T_A 1 /* host address */
#define T_NS 2 /* authoritative server */
#define T_MD 3 /* mail destination */
#define T_MF 4 /* mail forwarder */
#define T_CNAME 5 /* connonical name */
#define T_SOA 6 /* start of authority zone */
#define T_MB 7 /* mailbox domain name */
#define T_MG 8 /* mail group member */
#define T_MR 9 /* mail rename name */
#define T_NULL 10 /* null resource record */
#define T_WKS 11 /* well known service */
#define T_PTR 12 /* domain name pointer */
#define T_HINFO 13 /* host information */
#define T_MINFO 14 /* mailbox information */
#define T_MX 15 /* mail routing information */
#define T_TXT 16 /* text strings */
#define T_RP 17 /* responsible person */
#define T_AFSDB 18 /* AFS cell database */
#define T_NSAP 22 /* NSAP address */
#define T_NSAP_PTR 23 /* reverse lookup for NSAP */
/* non standard */
#define T_UINFO 100 /* user (finger) information */
#define T_UID 101 /* user ID */
#define T_GID 102 /* group ID */
#define T_UNSPEC 103 /* Unspecified format (binary data) */
/* Query type values which do not appear in resource records */
#define T_AXFR 252 /* transfer zone of authority */
#define T_MAILB 253 /* transfer mailbox records */
#define T_MAILA 254 /* transfer mail agent records */
#define T_ANY 255 /* wildcard match */
/*
* Values for class field
*/
#define C_IN 1 /* the arpa internet */
#define C_CHAOS 3 /* for chaos net (MIT) */
#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
/* Query class values which do not appear in resource records */
#define C_ANY 255 /* wildcard match */
/*
* Status return codes for T_UNSPEC conversion routines
*/
#define CONV_SUCCESS 0
#define CONV_OVERFLOW -1
#define CONV_BADFMT -2
#define CONV_BADCKSUM -3
#define CONV_BADBUFLEN -4
/*
* Structure for query header.
*/
typedef struct {
u_int16_t id; /* query identification number */
u_int8_t flags1; /* first byte of flags */
u_int8_t flags2; /* second byte of flags */
u_int16_t qdcount; /* number of question entries */
u_int16_t ancount; /* number of answer entries */
u_int16_t nscount; /* number of authority entries */
u_int16_t arcount; /* number of resource entries */
} HEADER;
/*
* Macros for subfields of flag fields.
*/
#define DNS_QR(np) ((np)->flags1 & 0x80) /* response flag */
#define DNS_OPCODE(np) ((((np)->flags1) >> 3) & 0xF) /* purpose of message */
#define DNS_AA(np) ((np)->flags1 & 0x04) /* authoritative answer */
#define DNS_TC(np) ((np)->flags1 & 0x02) /* truncated message */
#define DNS_RD(np) ((np)->flags1 & 0x01) /* recursion desired */
#define DNS_RA(np) ((np)->flags2 & 0x80) /* recursion available */
#define DNS_AD(np) ((np)->flags2 & 0x20) /* authentic data from named */
#define DNS_CD(np) ((np)->flags2 & 0x10) /* checking disabled by resolver */
#define DNS_RCODE(np) ((np)->flags2 & 0xF) /* response code */
/*
* Defines for handling compressed domain names, EDNS0 labels, etc.
*/
#define INDIR_MASK 0xc0 /* 11.... */
#define EDNS0_MASK 0x40 /* 01.... */
# define EDNS0_ELT_BITLABEL 0x01
/*
* Structure for passing resource records around.
*/
struct rrec {
int16_t r_zone; /* zone number */
int16_t r_class; /* class number */
int16_t r_type; /* type number */
u_int32_t r_ttl; /* time to live */
int r_size; /* size of data area */
char *r_data; /* pointer to data */
};
/*
* Inline versions of get/put short/long. Pointer is advanced.
* We also assume that a "u_int16_t" holds 2 "chars"
* and that a "u_int32_t" holds 4 "chars".
*
* These macros demonstrate the property of C whereby it can be
* portable or it can be elegant but never both.
*/
#define GETSHORT(s, cp) { \
register u_char *t_cp = (u_char *)(cp); \
(s) = ((u_int16_t)t_cp[0] << 8) | (u_int16_t)t_cp[1]; \
(cp) += 2; \
}
#define GETLONG(l, cp) { \
register u_char *t_cp = (u_char *)(cp); \
(l) = (((u_int32_t)t_cp[0]) << 24) \
| (((u_int32_t)t_cp[1]) << 16) \
| (((u_int32_t)t_cp[2]) << 8) \
| (((u_int32_t)t_cp[3])); \
(cp) += 4; \
}
#define PUTSHORT(s, cp) { \
register u_int16_t t_s = (u_int16_t)(s); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
(cp) += 2; \
}
/*
* Warning: PUTLONG --no-longer-- destroys its first argument. if you
* were depending on this "feature", you will lose.
*/
#define PUTLONG(l, cp) { \
register u_int32_t t_l = (u_int32_t)(l); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
*t_cp++ = t_l >> 8; \
*t_cp = t_l; \
(cp) += 4; \
}
#endif /* !_NAMESER_H_ */

View File

@ -245,7 +245,7 @@
/* File types */
typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
NFSOCK=6, NFFIFO=7 } nfstype;
NFSOCK=6, NFFIFO=7 } nfs_type;
/* Structs for common parts of the rpc's */
/*
@ -294,7 +294,7 @@ typedef struct nfs_uquad nfsuint64;
*/
union nfs_quadconvert {
u_int32_t lval[2];
u_quad_t qval;
u_int64_t qval;
};
typedef union nfs_quadconvert nfsquad_t;

View File

@ -1,5 +1,5 @@
/*
* $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.8 1999/12/15 06:49:05 fenner Exp $
* $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.9 2000/06/01 01:16:36 assar Exp $
*
* nfsfh.h - NFS file handle definitions (for portable use)
*
@ -25,6 +25,7 @@ typedef struct {
*/
typedef struct {
my_devt Fsid_dev; /* XXX avoid name conflict with AIX */
char Opaque_Handle[2 * 32 + 1];
u_int32_t fsid_code;
} my_fsid;

View File

@ -1,4 +1,4 @@
/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.3.1.1 1999/10/07 23:47:11 mcr Exp $ */
/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.4 2000/10/03 02:54:57 itojun Exp $ */
/*
* Based on ntp.h from the U of MD implementation
@ -33,8 +33,8 @@ struct l_fixedpt {
};
struct s_fixedpt {
u_short int_part;
u_short fraction;
u_int16_t int_part;
u_int16_t fraction;
};
/* ================= Table 3.3. Packet Variables ================= */

View File

@ -1,3 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@ -91,14 +92,14 @@
/* link state advertisement header */
struct lsa_hdr {
u_short ls_age;
u_char ls_options;
u_char ls_type;
u_int16_t ls_age;
u_int8_t ls_options;
u_int8_t ls_type;
struct in_addr ls_stateid;
struct in_addr ls_router;
u_int32_t ls_seq;
u_short ls_chksum;
u_short ls_length;
u_int16_t ls_chksum;
u_int16_t ls_length;
} ;
/* link state advertisement */
@ -109,15 +110,15 @@ struct lsa {
union {
/* Router links advertisements */
struct {
u_char rla_flags;
u_char rla_zero[1];
u_short rla_count;
u_int8_t rla_flags;
u_int8_t rla_zero[1];
u_int16_t rla_count;
struct rlalink {
struct in_addr link_id;
struct in_addr link_data;
u_char link_type;
u_char link_toscount;
u_short link_tos0metric;
u_int8_t link_type;
u_int8_t link_toscount;
u_int16_t link_tos0metric;
} rla_link[1]; /* may repeat */
} un_rla;
@ -156,9 +157,9 @@ struct lsa {
* TOS metric struct (will be 0 or more in router links update)
*/
struct tos_metric {
u_char tos_type;
u_char tos_zero;
u_short tos_metric;
u_int8_t tos_type;
u_int8_t tos_zero;
u_int16_t tos_metric;
} ;
#define OSPF_AUTH_SIZE 8
@ -167,22 +168,22 @@ struct tos_metric {
* the main header
*/
struct ospfhdr {
u_char ospf_version;
u_char ospf_type;
u_short ospf_len;
u_int8_t ospf_version;
u_int8_t ospf_type;
u_int16_t ospf_len;
struct in_addr ospf_routerid;
struct in_addr ospf_areaid;
u_short ospf_chksum;
u_short ospf_authtype;
u_char ospf_authdata[OSPF_AUTH_SIZE];
u_int16_t ospf_chksum;
u_int16_t ospf_authtype;
u_int8_t ospf_authdata[OSPF_AUTH_SIZE];
union {
/* Hello packet */
struct {
struct in_addr hello_mask;
u_short hello_helloint;
u_char hello_options;
u_char hello_priority;
u_int16_t hello_helloint;
u_int8_t hello_options;
u_int8_t hello_priority;
u_int32_t hello_deadint;
struct in_addr hello_dr;
struct in_addr hello_bdr;
@ -191,9 +192,9 @@ struct ospfhdr {
/* Database Description packet */
struct {
u_char db_zero[2];
u_char db_options;
u_char db_flags;
u_int8_t db_zero[2];
u_int8_t db_options;
u_int8_t db_flags;
u_int32_t db_seq;
struct lsa_hdr db_lshdr[1]; /* may repeat */
} un_db;

View File

@ -1,3 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@ -83,10 +84,10 @@
#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
/* asla_metric */
#define ASLA_FLAG_EXTERNAL 0x04000000
#define ASLA_FLAG_FWDADDR 0x02000000
#define ASLA_FLAG_ROUTETAG 0x01000000
#define ASLA_MASK_METRIC 0x00ffffff
/* multicast vertex type */
@ -149,6 +150,13 @@ struct lsa {
struct lsa_prefix inter_ap_prefix[1];
} un_inter_ap;
/* AS external links advertisements */
struct {
u_int32_t asla_metric;
struct lsa_prefix asla_prefix[1];
/* some optional fields follow */
} un_asla;
#if 0
/* Summary links advertisements */
struct {
@ -156,16 +164,6 @@ struct lsa {
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;

View File

@ -9,7 +9,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.16 1999/11/21 09:36:47 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.18 2000/07/01 03:39:00 assar Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -20,9 +20,6 @@ static const char rcsid[] =
#include <sys/time.h>
#include <ctype.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <stdio.h>
#include <string.h>
@ -93,6 +90,7 @@ int ourself; /* true if file handle was generated on this host */
register unsigned char *fhp = (unsigned char *)fh;
u_int32_t temp;
int fhtype = FHT_UNKNOWN;
int i;
if (ourself) {
/* File handle generated on this host, no need for guessing */
@ -370,15 +368,18 @@ int ourself; /* true if file handle was generated on this host */
case FHT_UNKNOWN:
#ifdef DEBUG
{
/* XXX debugging */
int i;
for (i = 0; i < 32; i++)
(void)fprintf(stderr, "%x.", fhp[i]);
(void)fprintf(stderr, "\n");
}
/* XXX debugging */
int i;
for (i = 0; i < 32; i++)
(void)fprintf(stderr, "%x.", fhp[i]);
(void)fprintf(stderr, "\n");
#endif
/* XXX for now, give "bogus" values to aid debugging */
/* Save the actual handle, so it can be display with -u */
for (i = 0; i < 32; i++)
(void)sprintf(&(fsidp->Opaque_Handle[i*2]), "%.2X", fhp[i]);
fsidp->fsid_code = 0;
fsidp->Fsid_dev.Minor = 257;
fsidp->Fsid_dev.Major = 257;

View File

@ -1,4 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.8 1999/11/21 03:43:56 assar Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.11 2000/10/09 01:53:19 guy Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
@ -15,6 +15,8 @@
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#define PPP_HDRLEN 4 /* length of PPP header */
#define PPP_ADDRESS 0xff /* The address byte value */
#define PPP_CONTROL 0x03 /* The control byte value */
@ -30,6 +32,7 @@
#define PPP_BRPDU 0x0031 /* Bridging PDU */
#define PPP_STII 0x0033 /* Stream Protocol (ST-II) */
#define PPP_VINES 0x0035 /* Banyan Vines */
#define PPP_IPV6 0x0057 /* IPv6 */
#define PPP_HELLO 0x0201 /* 802.1d Hello Packets */
#define PPP_LUXCOM 0x0231 /* Luxcom */
@ -43,9 +46,15 @@
#define PPP_IPXCP 0x802b /* Novell IPX Control Protocol */
#define PPP_STIICP 0x8033 /* Strean Protocol Control Protocol */
#define PPP_VINESCP 0x8035 /* Banyan Vines Control Protocol */
#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
#define PPP_CCP 0x80fd /* Compress Control Protocol */
#define PPP_LCP 0xc021 /* Link Control Protocol */
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
#define PPP_LQM 0xc025 /* Link Quality Monitoring */
#define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */
#define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */
#define PPP_BAP 0xc02d /* BAP */
#define PPP_MP 0xc03d /* Multi-Link */
extern struct tok ppptype2str[];

View File

@ -23,7 +23,7 @@
#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)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.14 2000/12/12 09:58:40 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -35,38 +35,11 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#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 "ah.h"
#include "interface.h"
#include "addrtoname.h"
@ -80,7 +53,7 @@ ah_print(register const u_char *bp, register const u_char *bp2)
u_int32_t spi;
ah = (struct ah *)bp;
ep = snapend; /* 'ep' points to the end of avaible data. */
ep = snapend; /* 'ep' points to the end of available data. */
if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
goto trunc;
@ -88,7 +61,7 @@ ah_print(register const u_char *bp, register const u_char *bp2)
sumlen = ah->ah_len << 2;
spi = (u_int32_t)ntohl(ah->ah_spi);
printf("AH(spi=%u", spi);
printf("AH(spi=0x%08x", spi);
if (vflag)
printf(",sumlen=%d", sumlen);
printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.44 1999/11/21 09:36:48 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.49 2000/10/10 05:05:07 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -30,28 +30,84 @@ static const char rcsid[] =
#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 "ether.h"
#include "ethertype.h"
#include "extract.h" /* must come after interface.h */
/*
* Address Resolution Protocol.
*
* See RFC 826 for protocol description. ARP packets are variable
* in size; the arphdr structure defines the fixed-length portion.
* Protocol type values are the same as those for 10 Mb/s Ethernet.
* It is followed by the variable-sized fields ar_sha, arp_spa,
* arp_tha and arp_tpa in that order, according to the lengths
* specified. Field names used correspond to RFC 826.
*/
struct arphdr {
u_short ar_hrd; /* format of hardware address */
#define ARPHRD_ETHER 1 /* ethernet hardware format */
#define ARPHRD_IEEE802 6 /* token-ring hardware format */
#define ARPHRD_FRELAY 15 /* frame relay hardware format */
u_short ar_pro; /* format of protocol address */
u_char ar_hln; /* length of hardware address */
u_char ar_pln; /* length of protocol address */
u_short ar_op; /* one of: */
#define ARPOP_REQUEST 1 /* request to resolve address */
#define ARPOP_REPLY 2 /* response to previous request */
#define ARPOP_REVREQUEST 3 /* request protocol address given hardware */
#define ARPOP_REVREPLY 4 /* response giving protocol address */
#define ARPOP_INVREQUEST 8 /* request to identify peer */
#define ARPOP_INVREPLY 9 /* response identifying peer */
/*
* The remaining fields are variable in size,
* according to the sizes above.
*/
#ifdef COMMENT_ONLY
u_char ar_sha[]; /* sender hardware address */
u_char ar_spa[]; /* sender protocol address */
u_char ar_tha[]; /* target hardware address */
u_char ar_tpa[]; /* target protocol address */
#endif
};
#define ARP_HDRLEN 8
/*
* Ethernet Address Resolution Protocol.
*
* See RFC 826 for protocol description. Structure below is adapted
* to resolving internet addresses. Field names used correspond to
* RFC 826.
*/
struct ether_arp {
struct arphdr ea_hdr; /* fixed-size header */
u_char arp_sha[6]; /* sender hardware address */
u_char arp_spa[4]; /* sender protocol address */
u_char arp_tha[6]; /* target hardware address */
u_char arp_tpa[4]; /* target protocol address */
};
#define arp_hrd ea_hdr.ar_hrd
#define arp_pro ea_hdr.ar_pro
#define arp_hln ea_hdr.ar_hln
#define arp_pln ea_hdr.ar_pln
#define arp_op ea_hdr.ar_op
#define ETHER_ARP_HDRLEN (ARP_HDRLEN + 6 + 4 + 6 + 4)
#define SHA(ap) ((ap)->arp_sha)
#define THA(ap) ((ap)->arp_tha)
#define SPA(ap) ((ap)->arp_spa)
#define TPA(ap) ((ap)->arp_tpa)
/* Compatibility */
#ifndef REVARP_REQUEST
#define REVARP_REQUEST 3
@ -74,7 +130,7 @@ arp_print(register const u_char *bp, u_int length, u_int caplen)
printf("[|arp]");
return;
}
if (length < sizeof(struct ether_arp)) {
if (length < ETHER_ARP_HDRLEN) {
(void)printf("truncated-arp");
default_print((u_char *)ap, length);
return;

View File

@ -42,7 +42,7 @@
#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 $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.6 2000/01/29 16:47:46 itojun Exp $";
#endif
#include <stdio.h>
#include <sys/types.h>
@ -72,7 +72,8 @@ ascii_print_with_offset(register const u_char *cp, register u_int length,
while (--nshorts >= 0) {
s1 = *cp++;
s2 = *cp++;
(void)sprintf(hsp, " %02x%02x", s1, s2);
(void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
" %02x%02x", s1, s2);
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
*(asp++) = (isgraph(s1) ? s1 : '.');
*(asp++) = (isgraph(s2) ? s2 : '.');
@ -87,7 +88,8 @@ ascii_print_with_offset(register const u_char *cp, register u_int length,
}
if (length & 1) {
s1 = *cp++;
(void)sprintf(hsp, " %02x", s1);
(void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
" %02x", s1);
hsp += 3;
*(asp++) = (isgraph(s1) ? s1 : '.');
++i;

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.51 1999/11/21 09:36:48 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.64 2000/10/30 06:22:14 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -34,24 +34,12 @@ static const char rcsid[] =
#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/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/if_ether.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h> /* for MAXHOSTNAMELEN on some platforms */
#include "interface.h"
#include "addrtoname.h"
@ -71,13 +59,13 @@ static struct tok type2str[] = {
};
struct aarp {
u_short htype, ptype;
u_char halen, palen;
u_short op;
u_char hsaddr[6];
u_char psaddr[4];
u_char hdaddr[6];
u_char pdaddr[4];
u_int16_t htype, ptype;
u_int8_t halen, palen;
u_int16_t op;
u_int8_t hsaddr[6];
u_int8_t psaddr[4];
u_int8_t hdaddr[6];
u_int8_t pdaddr[4];
};
static char tstr[] = "[|atalk]";
@ -96,10 +84,10 @@ static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char);
static const char *ddpskt_string(int);
/*
* Print AppleTalk Datagram Delivery Protocol packets.
* Print AppleTalk LLAP packets.
*/
void
atalk_print(register const u_char *bp, u_int length)
llap_print(register const u_char *bp, u_int length)
{
register const struct LAP *lp;
register const struct atDDP *dp;
@ -156,6 +144,33 @@ atalk_print(register const u_char *bp, u_int length)
}
}
/*
* Print EtherTalk/TokenTalk packets (or FDDITalk, or whatever it's called
* when it runs over FDDI; yes, I've seen FDDI captures with AppleTalk
* packets in them).
*/
void
atalk_print(register const u_char *bp, u_int length)
{
register const struct atDDP *dp;
u_short snet;
if (length < ddpSize) {
(void)printf(" [|ddp %d]", length);
return;
}
dp = (const struct atDDP *)bp;
snet = EXTRACT_16BITS(&dp->srcNet);
printf("%s.%s", ataddr_string(snet, dp->srcNode),
ddpskt_string(dp->srcSkt));
printf(" > %s.%s:",
ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
ddpskt_string(dp->dstSkt));
bp += ddpSize;
length -= ddpSize;
ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
}
/* XXX should probably pass in the snap header and do checks like arp_print() */
void
aarp_print(register const u_char *bp, u_int length)
@ -166,9 +181,9 @@ aarp_print(register const u_char *bp, u_int length)
printf("aarp ");
ap = (const struct aarp *)bp;
if (ap->htype == 1 && ap->ptype == ETHERTYPE_ATALK &&
if (ntohs(ap->htype) == 1 && ntohs(ap->ptype) == ETHERTYPE_ATALK &&
ap->halen == 6 && ap->palen == 4 )
switch (ap->op) {
switch (ntohs(ap->op)) {
case 1: /* request */
(void)printf("who-has %s tell %s",
@ -185,10 +200,14 @@ aarp_print(register const u_char *bp, u_int length)
AT(pdaddr), AT(psaddr));
return;
}
(void)printf("len %d op %d htype %d ptype %#x halen %d palen %d",
length, ap->op, ap->htype, ap->ptype, ap->halen, ap->palen );
(void)printf("len %u op %u htype %u ptype %#x halen %u palen %u",
length, ntohs(ap->op), ntohs(ap->htype), ntohs(ap->ptype),
ap->halen, ap->palen);
}
/*
* Print AppleTalk Datagram Delivery Protocol packets.
*/
static void
ddp_print(register const u_char *bp, register u_int length, register int t,
register u_short snet, register u_char snode, u_char skt)
@ -491,7 +510,7 @@ ataddr_string(u_short atnet, u_char athost)
{
register struct hnamemem *tp, *tp2;
register int i = (atnet << 8) | athost;
char nambuf[256];
char nambuf[MAXHOSTNAMELEN + 20];
static int first = 1;
FILE *fp;
@ -507,11 +526,11 @@ ataddr_string(u_short atnet, u_char athost)
while (fgets(line, sizeof(line), fp)) {
if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
continue;
if (sscanf(line, "%d.%d.%d %s", &i1, &i2, &i3,
if (sscanf(line, "%d.%d.%d %256s", &i1, &i2, &i3,
nambuf) == 4)
/* got a hostname. */
i3 |= ((i1 << 8) | i2) << 8;
else if (sscanf(line, "%d.%d %s", &i1, &i2,
else if (sscanf(line, "%d.%d %256s", &i1, &i2,
nambuf) == 3)
/* got a net name */
i3 = (((i1 << 8) | i2) << 8) | 255;
@ -538,7 +557,8 @@ ataddr_string(u_short atnet, u_char athost)
if (tp2->addr == i) {
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem();
(void)sprintf(nambuf, "%s.%d", tp2->name, athost);
(void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
tp2->name, athost);
tp->name = savestr(nambuf);
return (tp->name);
}
@ -546,10 +566,11 @@ ataddr_string(u_short atnet, u_char athost)
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem();
if (athost != 255)
(void)sprintf(nambuf, "%d.%d.%d",
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d.%d",
atnet >> 8, atnet & 0xff, athost);
else
(void)sprintf(nambuf, "%d.%d", atnet >> 8, atnet & 0xff);
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8,
atnet & 0xff);
tp->name = savestr(nambuf);
return (tp->name);
@ -569,7 +590,7 @@ ddpskt_string(register int skt)
static char buf[8];
if (nflag) {
(void)sprintf(buf, "%d", skt);
(void)snprintf(buf, sizeof(buf), "%d", skt);
return (buf);
}
return (tok2str(skt2str, "%d", skt));

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.12 1999/11/21 09:36:48 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.20 2000/12/22 22:45:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -31,20 +31,7 @@ static const char rcsid[] =
#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>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <pcap.h>
@ -144,8 +131,8 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
/* ether_type not known, print raw packet */
if (!eflag)
printf("%02x %02x %02x %02x-%02x-%02x %04x: ",
p[0], p[1], p[2], /* dsap/ssap/ctrl */
p[3], p[4], p[5], /* manufacturer's code */
packetp[0], packetp[1], packetp[2], /* dsap/ssap/ctrl */
packetp[3], packetp[4], packetp[5], /* manufacturer's code */
ethertype);
if (!xflag && !qflag)
default_print(p, caplen);

View File

@ -33,7 +33,7 @@
#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 $";
"@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.21 2000/12/05 05:48:35 guy Exp $";
#endif
#include <sys/param.h>
@ -42,18 +42,15 @@ static const char rcsid[] =
#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 <netdb.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
struct bgp {
u_int8_t bgp_marker[16];
@ -240,7 +237,7 @@ 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);
snprintf(buf, sizeof(buf), "#%d", value);
return buf;
} else
return table[value];
@ -266,7 +263,7 @@ bgp_notify_minor(int major, int minor)
} else
p = NULL;
if (p == NULL) {
sprintf(buf, "#%d", minor);
snprintf(buf, sizeof(buf), "#%d", minor);
return buf;
} else
return p;
@ -288,7 +285,7 @@ decode_prefix4(const u_char *pd, char *buf, int buflen)
((u_char *)&addr)[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
sprintf(buf, "%s/%d", getname((char *)&addr), plen);
snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen);
return 1 + (plen + 7) / 8;
}
@ -309,7 +306,7 @@ decode_prefix6(const u_char *pd, char *buf, int buflen)
addr.s6_addr[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
sprintf(buf, "%s/%d", getname6((char *)&addr), plen);
snprintf(buf, buflen, "%s/%d", getname6((char *)&addr), plen);
return 1 + (plen + 7) / 8;
}
#endif
@ -323,7 +320,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
int advance;
int tlen;
const u_char *p;
char buf[256];
char buf[MAXHOSTNAMELEN + 100];
p = dat;
@ -430,20 +427,24 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
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)
i = 0;
while (i < tlen) {
switch (af) {
case AFNUM_INET:
printf(" %s", getname(p + 1 + i));
i += sizeof(struct in_addr);
break;
#ifdef INET6
else if (af == AFNUM_INET6)
case AFNUM_INET6:
printf(" %s", getname6(p + 1 + i));
i += sizeof(struct in6_addr);
break;
#endif
default:
printf(" (unknown af)");
i = tlen; /*exit loop*/
break;
}
}
printf(",");
}
@ -462,13 +463,23 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
printf(" NLRI");
while (len - (p - dat) > 0) {
if (af == AFNUM_INET)
switch (af) {
case AFNUM_INET:
advance = decode_prefix4(p, buf, sizeof(buf));
printf(" %s", buf);
break;
#ifdef INET6
else if (af == AFNUM_INET6)
case AFNUM_INET6:
advance = decode_prefix6(p, buf, sizeof(buf));
printf(" %s", buf);
break;
#endif
printf(" %s", buf);
default:
printf(" (unknown af)");
advance = 0;
p = dat + len;
break;
}
p += advance;
}
@ -488,13 +499,23 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
printf(" Withdraw");
while (len - (p - dat) > 0) {
if (af == AFNUM_INET)
switch (af) {
case AFNUM_INET:
advance = decode_prefix4(p, buf, sizeof(buf));
printf(" %s", buf);
break;
#ifdef INET6
else if (af == AFNUM_INET6)
case AFNUM_INET6:
advance = decode_prefix6(p, buf, sizeof(buf));
printf(" %s", buf);
break;
#endif
printf(" %s", buf);
default:
printf(" (unknown af)");
advance = 0;
p = dat + len;
break;
}
p += advance;
}
@ -513,13 +534,14 @@ bgp_open_print(const u_char *dat, int length)
const u_char *opt;
int i;
TCHECK2(dat[0], sizeof(bgpo));
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(" ID %s,", getname((u_char *)&bgpo.bgpo_id));
printf(" Option length %u", bgpo.bgpo_optlen);
/* ugly! */
@ -537,6 +559,9 @@ bgp_open_print(const u_char *dat, int length)
bgpopt.bgpopt_len);
i += sizeof(bgpopt) + bgpopt.bgpopt_len;
}
return;
trunc:
printf("[|BGP]");
}
static void
@ -550,19 +575,40 @@ bgp_update_print(const u_char *dat, int length)
int i;
int newline;
TCHECK2(dat[0], sizeof(bgp));
memcpy(&bgp, dat, sizeof(bgp));
hlen = ntohs(bgp.bgp_len);
p = dat + BGP_SIZE; /*XXX*/
printf(":");
/* Unfeasible routes */
len = ntohs(*(u_int16_t *)p);
len = EXTRACT_16BITS(p);
if (len) {
/* Without keeping state from the original NLRI message,
* it's not possible to tell if this a v4 or v6 route,
* so only try to decode it if we're not v6 enabled.
*/
#ifdef INET6
printf(" (Withdrawn routes: %d bytes)", len);
#else
char buf[MAXHOSTNAMELEN + 100];
TCHECK2(p[2], len);
i = 2;
printf(" (Withdrawn routes:");
while(i < 2 + len) {
i += decode_prefix4(&p[i], buf, sizeof(buf));
printf(" %s", buf);
}
printf(")\n");
#endif
}
p += 2 + len;
len = ntohs(*(u_int16_t *)p);
TCHECK2(p[0], 2);
len = EXTRACT_16BITS(p);
if (len) {
/* do something more useful!*/
i = 2;
@ -571,6 +617,7 @@ bgp_update_print(const u_char *dat, int length)
while (i < 2 + len) {
int alen, aoff;
TCHECK2(p[i], sizeof(bgpa));
memcpy(&bgpa, &p[i], sizeof(bgpa));
alen = bgp_attr_len(&bgpa);
aoff = bgp_attr_off(&bgpa);
@ -582,11 +629,14 @@ bgp_update_print(const u_char *dat, int length)
printf("("); /* ) */
printf("%s", bgp_attr_type(bgpa.bgpa_type));
if (bgpa.bgpa_flags) {
printf("[%s%s%s%s]",
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" : "");
bgpa.bgpa_flags & 0x10 ? "E" : "");
if (bgpa.bgpa_flags & 0xf)
printf("+%x", bgpa.bgpa_flags & 0xf);
printf("]");
}
bgp_attr_print(&bgpa, &p[i + aoff], alen);
@ -608,7 +658,7 @@ bgp_update_print(const u_char *dat, int length)
if (dat + length > p) {
printf("(NLRI:"); /* ) */
while (dat + length > p) {
char buf[256];
char buf[MAXHOSTNAMELEN + 100];
i = decode_prefix4(p, buf, sizeof(buf));
printf(" %s", buf);
if (i < 0)
@ -619,6 +669,9 @@ bgp_update_print(const u_char *dat, int length)
/* ( */
printf(")");
}
return;
trunc:
printf("[|BGP]");
}
static void
@ -627,12 +680,16 @@ bgp_notification_print(const u_char *dat, int length)
struct bgp_notification bgpn;
int hlen;
TCHECK2(dat[0], sizeof(bgpn));
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));
return;
trunc:
printf("[|BGP]");
}
static void
@ -640,6 +697,7 @@ bgp_header_print(const u_char *dat, int length)
{
struct bgp bgp;
TCHECK2(dat[0], sizeof(bgp));
memcpy(&bgp, dat, sizeof(bgp));
printf("(%s", bgp_type(bgp.bgp_type)); /* ) */
@ -657,6 +715,9 @@ bgp_header_print(const u_char *dat, int length)
/* ( */
printf(")");
return;
trunc:
printf("[|BGP]");
}
void
@ -698,7 +759,7 @@ bgp_print(const u_char *dat, int length)
}
/* found BGP header */
TCHECK2(p[0], BGP_SIZE); /*XXX*/
TCHECK2(p[0], sizeof(bgp)); /*XXX*/
memcpy(&bgp, p, sizeof(bgp));
if (start != p)

View File

@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.48 1999/11/21 09:36:49 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.56 2000/12/04 00:00:08 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -33,24 +33,19 @@ static const char rcsid[] =
#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>
#include <ctype.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
#include "ether.h"
#include "bootp.h"
static void rfc1048_print(const u_char *, u_int);
@ -179,7 +174,7 @@ bootp_print(register const u_char *cp, u_int length,
else {
u_int32_t ul;
memcpy((char *)&ul, (char *)bp->bp_vend, sizeof(ul));
ul = EXTRACT_32BITS(&bp->bp_vend);
if (ul != 0)
printf("vend-#0x%x", ul);
}
@ -194,7 +189,7 @@ static struct tok tag2str[] = {
/* RFC1048 tags */
{ TAG_PAD, " PAD" },
{ TAG_SUBNET_MASK, "iSM" }, /* subnet mask (RFC950) */
{ TAG_TIME_OFFSET, "lTZ" }, /* seconds from UTC */
{ TAG_TIME_OFFSET, "LTZ" }, /* seconds from UTC */
{ TAG_GATEWAY, "iDG" }, /* default gateway */
{ TAG_TIME_SERVER, "iTS" }, /* time servers (RFC868) */
{ TAG_NAME_SERVER, "iIEN" }, /* IEN name servers (IEN116) */
@ -269,7 +264,46 @@ static struct tok tag2str[] = {
{ TAG_RENEWAL_TIME, "lRN" },
{ TAG_REBIND_TIME, "lRB" },
{ TAG_VENDOR_CLASS, "bVC" },
{ TAG_CLIENT_ID, "bCID" },
{ TAG_CLIENT_ID, "xCID" },
/* RFC 2485 */
{ TAG_OPEN_GROUP_UAP, "aUAP" },
/* RFC 2563 */
{ TAG_DISABLE_AUTOCONF, "BNOAUTO" },
/* RFC 2610 */
{ TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */
{ TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */
/* RFC 2937 */
{ TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */
/* RFC 3011 */
{ TAG_IP4_SUBNET_SELECT, "iSUBNET" },
/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
{ TAG_USER_CLASS, "aCLASS" },
{ TAG_SLP_NAMING_AUTH, "aSLP-NA" },
{ TAG_CLIENT_FQDN, "bFQDN" }, /* XXX 'b' */
{ TAG_AGENT_CIRCUIT, "bACKT" },
{ TAG_AGENT_REMOTE, "bARMT" },
{ TAG_AGENT_MASK, "bAMSK" },
{ TAG_TZ_STRING, "aTZSTR" },
{ TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */
{ TAG_AUTH, "bAUTH" }, /* XXX 'b' */
{ TAG_VINES_SERVERS, "iVINES" },
{ TAG_SERVER_RANK, "sRANK" },
{ TAG_CLIENT_ARCH, "sARCH" },
{ TAG_CLIENT_NDI, "bNDI" }, /* XXX 'b' */
{ TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */
{ TAG_LDAP_URL, "aLDAP" },
{ TAG_6OVER4, "i6o4" },
{ TAG_PRINTER_NAME, "aPRTR" },
{ TAG_MDHCP_SERVER, "bMDHCP" }, /* XXX 'b' */
{ TAG_IPX_COMPAT, "bIPX" }, /* XXX 'b' */
{ TAG_NETINFO_PARENT, "iNI" },
{ TAG_NETINFO_PARENT_TAG, "aNITAG" },
{ TAG_URL, "aURL" },
{ TAG_FAILOVER, "bFAIL" }, /* XXX 'b' */
{ 0, NULL }
};
/* 2-byte extended tags */
static struct tok xtag2str[] = {
{ 0, NULL }
};
@ -296,7 +330,16 @@ rfc1048_print(register const u_char *bp, register u_int length)
continue;
if (tag == TAG_END)
return;
cp = tok2str(tag2str, "?T%d", tag);
if (tag == TAG_EXTENDED_OPTION) {
TCHECK2(*(bp + 1), 2);
tag = EXTRACT_16BITS(bp + 1);
/* XXX we don't know yet if the IANA will
* preclude overlap of 1-byte and 2-byte spaces.
* If not, we need to offset tag after this step.
*/
cp = tok2str(xtag2str, "?xT%d", tag);
} else
cp = tok2str(tag2str, "?T%d", tag);
c = *cp++;
printf(" %s:", cp);
@ -331,7 +374,21 @@ rfc1048_print(register const u_char *bp, register u_int length)
first = 1;
while (len-- > 0) {
c = *bp++;
cp = tok2str(tag2str, "?%d", c);
cp = tok2str(tag2str, "?T%d", c);
if (!first)
putchar('+');
printf("%s", cp + 1);
first = 0;
}
continue;
}
if (tag == TAG_EXTENDED_REQUEST) {
first = 1;
while (len > 1) {
len -= 2;
c = EXTRACT_16BITS(bp);
bp += 2;
cp = tok2str(xtag2str, "?xT%d", c);
if (!first)
putchar('+');
printf("%s", cp + 1);
@ -365,13 +422,17 @@ rfc1048_print(register const u_char *bp, register u_int length)
case 'i':
case 'l':
case 'L':
/* ip addresses/32-bit words */
while (size >= sizeof(ul)) {
if (!first)
putchar(',');
memcpy((char *)&ul, (char *)bp, sizeof(ul));
if (c == 'i')
ul = EXTRACT_32BITS(bp);
if (c == 'i') {
ul = htonl(ul);
printf("%s", ipaddr_string(&ul));
} else if (c == 'L')
printf("%d", ul);
else
printf("%u", ul);
bp += sizeof(ul);
@ -401,7 +462,7 @@ rfc1048_print(register const u_char *bp, register u_int length)
while (size >= sizeof(us)) {
if (!first)
putchar(',');
memcpy((char *)&us, (char *)bp, sizeof(us));
us = EXTRACT_16BITS(bp);
printf("%d", us);
bp += sizeof(us);
size -= sizeof(us);
@ -432,12 +493,13 @@ rfc1048_print(register const u_char *bp, register u_int length)
break;
case 'b':
case 'x':
default:
/* Bytes */
while (size > 0) {
if (!first)
putchar('.');
printf("%d", *bp);
putchar (c == 'x' ? ':' : '.');
printf (c == 'x' ? "%02x" : "%d", *bp);
++bp;
--size;
first = 0;
@ -448,6 +510,9 @@ rfc1048_print(register const u_char *bp, register u_int length)
if (size)
printf("[len %d]", len);
}
return;
trunc:
printf("|[rfc1048]");
}
static void

View File

@ -0,0 +1,82 @@
/*
* Copyright (C) 2000, Richard Sharpe
*
* This software may be distributed either under the terms of the
* BSD-style licence that accompanies tcpdump or under the GNU GPL
* version 2 or later.
*
* print-bxxp.c
*
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-bxxp.c,v 1.3 2000/10/05 04:10:01 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "interface.h"
#include "extract.h"
/* Check for a string but not go beyond length
* Return TRUE on match, FALSE otherwise
*
* Looks at the first few chars up to tl1 ...
*/
int l_strnstart(const u_char *, u_int, const u_char *, u_int);
int
l_strnstart(register const u_char *tstr1, register u_int tl1,
register const u_char *str2, register u_int l2)
{
if (tl1 > l2)
return 0;
return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
}
void
bxxp_print(register const u_char *bp, register u_int length)
{
if (l_strnstart("REQ ", 4, bp, length)) { /* A REQuest */
printf(" BXXP REQ");
}
else if (l_strnstart("RSP ", 4, bp, length)) {
printf(" BXXP RSP");
}
else if (l_strnstart("SEQ ", 4, bp, length)) {
printf(" BXXP SEQ");
}
else if (l_strnstart("END", 4, bp, length)) {
printf(" BXXP END");
}
else
printf(" BXXP (payload or undecoded)");
}

187
contrib/tcpdump/print-cdp.c Normal file
View File

@ -0,0 +1,187 @@
/*
* 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.
*
* Code by Gert Doering, SpaceNet GmbH, gert@space.net
*
* Reference documentation:
* http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.4 2000/07/29 07:27:54 assar Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <ctype.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
static void cdp_print_addr( const u_char * p, int l );
static void cdp_print_prefixes( const u_char * p, int l );
/*
* Returns non-zero IFF it succeeds in printing the header
*/
void
cdp_print(const u_char *p, u_int length, u_int caplen,
const u_char *esrc, const u_char *edst)
{
int i;
int type, len;
/* Cisco Discovery Protocol */
if ( caplen < 12 ) {
(void)printf("[|cdp]");
return;
}
i=8; /* CDP data starts at offset 8 */
printf ("CDP v%d, ttl=%ds", p[i], p[i+1] );
i+=4; /* skip version, TTL and chksum */
while (i < length) {
if ( i+4 > caplen ) {
printf("[!cdp]");
return;
}
type = (p[i]<<8) + p[i+1];
len = (p[i+2]<<8) + p[i+3];
if ( vflag )
printf( "\n\t%02x/%02x", type, len );
else
printf( "\n\t" );
if ( i+len > caplen ) {
printf("[!cdp]");
return;
}
switch( type )
{
case 0x01:
printf( " DevID '%.*s'", len-4, p+i+4 );
break;
case 0x02:
printf( " Addr" );
cdp_print_addr( p+i+4, len-4 );
break;
case 0x03:
printf( " PortID '%.*s'", len-4, p+i+4 );
break;
case 0x04:
printf( " CAP 0x%02x", (unsigned) p[i+7] );
break;
case 0x05:
if ( vflag )
printf( " Version:\n%.*s", len-4, p+i+4 );
else
printf( " Version: (suppressed)" );
break;
case 0x06:
printf( " Platform: '%.*s'", len-4, p+i+4 );
break;
case 0x07:
cdp_print_prefixes( p+i+4, len-4 );
break;
case 0x09: /* guess - not documented */
printf( " VTP Management Domain: '%.*s'", len-4, p+i+4 );
break;
case 0x0a: /* guess - not documented */
printf( " Native VLAN ID: %d", (p[i+4]<<8) + p[i+4+1] - 1 );
break;
case 0x0b: /* guess - not documented */
printf( " Duplex: %s", p[i+4] ? "full": "half" );
break;
default:
printf( " unknown field type %02x, len %d", type, len );
}
/* avoid infinite loop */
if (len == 0)
break;
i+=len;
}
}
static void
cdp_print_addr( const u_char * p, int l )
{
int pl, al, num;
const u_char * endp = p+l;
num = (p[0] << 24) + (p[1]<<16) + (p[2]<<8)+ p[3];
p+=4;
printf(" (%d): ", num );
while( p < endp && num >= 0) {
pl=*(p+1);
p+=2;
/* special case: IPv4, protocol type=0xcc, addr. length=4 */
if ( pl == 1 && *p == 0xcc &&
p[1] == 0 && p[2] == 4 ) {
p+=3;
printf( "IPv4 %d.%d.%d.%d ", p[0], p[1], p[2], p[3] );
p+=4;
} else { /* generic case: just print raw data */
printf("pt=0x%02x, pl=%d, pb=", *(p-2), pl);
while( pl-- > 0 )
printf( " %02x", *p++);
al=(*p << 8) + *(p+1);
printf( ", al=%d, a=", al );
p+=2;
while( al-- > 0 )
printf( " %02x", *p++);
}
printf(" ");
num--;
}
}
static void
cdp_print_prefixes( const u_char * p, int l )
{
printf( " IPv4 Prefixes (%d):", l/5 );
while(l > 0) {
printf( " %d.%d.%d.%d/%d", p[0], p[1], p[2], p[3], p[4] );
l-=5; p+=5;
}
}

View File

@ -22,7 +22,7 @@
#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)";
"@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.11 2000/10/09 01:53:19 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -31,40 +31,19 @@ static const char rcsid[] =
#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 "ethertype.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
#include "chdlc.h"
static void chdlc_slarp_print(const u_char *, u_int);
@ -111,7 +90,7 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
length -= CHDLC_HDRLEN;
ip = (struct ip *)(p + CHDLC_HDRLEN);
switch(proto) {
switch (proto) {
case ETHERTYPE_IP:
ip_print((const u_char *)ip, length);
break;
@ -136,7 +115,7 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
}
struct cisco_slarp {
long code;
u_int32_t code;
#define SLARP_REQUEST 0
#define SLARP_REPLY 1
#define SLARP_KEEPALIVE 2
@ -144,14 +123,14 @@ struct cisco_slarp {
struct {
struct in_addr addr;
struct in_addr mask;
u_short unused[3];
u_int16_t unused[3];
} addr;
struct {
long myseq;
long yourseq;
short rel;
short t1;
short t2;
u_int32_t myseq;
u_int32_t yourseq;
u_int16_t rel;
u_int16_t t1;
u_int16_t t2;
} keep;
} un;
};

View File

@ -22,7 +22,7 @@
#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)";
"@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.11 2000/12/22 22:45:10 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -34,59 +34,52 @@ static const char rcsid[] =
#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 "ethertype.h"
#include "ether.h"
const u_char *packetp;
const u_char *snapend;
#define RFC1483LLC_LEN 8
#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 };
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;
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);
}
}
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);
}
}
}
/*
@ -112,7 +105,7 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
}
if (eflag)
cip_print(p, length);
cip_print(p, length);
/*
* Some printers want to get back at the ethernet addresses,
@ -123,13 +116,15 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *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;
length -= RFC1483LLC_LEN;
caplen -= RFC1483LLC_LEN;
bp = (u_short *)p;
p += RFC1483LLC_LEN;
ether_type = ntohs(bp[3]);
} else {
ether_type = ETHERTYPE_IP;
bp = (u_short *)p;
}
/*
* Is it (gag) an 802.3 encapsulation?
@ -137,10 +132,11 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
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) {
if (llc_print(p, length, caplen, NULL, NULL,
&extracted_ethertype)==0) {
/* ether_type not known, print raw packet */
if (!eflag)
cip_print((u_char *)bp, length);
cip_print((u_char *)bp, length + RFC1483LLC_LEN);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
@ -148,7 +144,8 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (!xflag && !qflag)
default_print(p, caplen);
}
} else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
} else if (ether_encap_print(ether_type, p, length, caplen,
&extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
cip_print((u_char *)bp, length + RFC1483LLC_LEN);

View File

@ -0,0 +1,181 @@
/* $OpenBSD: print-cnfp.c,v 1.2 1998/06/25 20:26:59 mickey Exp $ */
/*
* Copyright (c) 1998 Michael Shalayeff
* 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 Michael Shalayeff.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/* Cisco NetFlow protocol */
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.6 2000/09/23 08:26:32 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "tcp.h"
struct nfhdr {
u_int32_t ver_cnt; /* version [15], and # of records */
u_int32_t msys_uptime;
u_int32_t utc_sec;
u_int32_t utc_nsec;
u_int32_t sequence; /* v5 flow sequence number */
u_int32_t reserved; /* v5 only */
};
struct nfrec {
struct in_addr src_ina;
struct in_addr dst_ina;
struct in_addr nhop_ina;
u_int32_t ifaces; /* src,dst ifaces */
u_int32_t packets;
u_int32_t octets;
u_int32_t start_time; /* sys_uptime value */
u_int32_t last_time; /* sys_uptime value */
u_int32_t ports; /* src,dst ports */
u_int32_t proto_tos; /* proto, tos, pad, flags(v5) */
u_int32_t asses; /* v1: flags; v5: src,dst AS */
u_int32_t masks; /* src,dst addr prefix */
};
void
cnfp_print(const u_char *cp, u_int len, const u_char *bp)
{
register const struct nfhdr *nh;
register const struct nfrec *nr;
register const struct ip *ip;
struct protoent *pent;
int nrecs, ver;
time_t t;
ip = (struct ip *)bp;
nh = (struct nfhdr *)cp;
if ((u_char *)(nh + 1) > snapend)
return;
nrecs = ntohl(nh->ver_cnt) & 0xffff;
ver = (ntohl(nh->ver_cnt) & 0xffff0000) >> 16;
t = ntohl(nh->utc_sec);
/* (p = ctime(&t))[24] = '\0'; */
printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
(unsigned)ntohl(nh->msys_uptime)/1000,
(unsigned)ntohl(nh->msys_uptime)%1000,
(unsigned)ntohl(nh->utc_sec), (unsigned)ntohl(nh->utc_nsec));
if (ver == 5) {
printf("#%u, ", (unsigned)htonl(nh->sequence));
nr = (struct nfrec *)&nh[1];
snaplen -= 24;
} else {
nr = (struct nfrec *)&nh->sequence;
snaplen -= 16;
}
printf("%2u recs", nrecs);
for (; nrecs-- && (u_char *)(nr + 1) <= snapend; nr++) {
char buf[20];
char asbuf[20];
printf("\n started %u.%03u, last %u.%03u",
(unsigned)ntohl(nr->start_time)/1000,
(unsigned)ntohl(nr->start_time)%1000,
(unsigned)ntohl(nr->last_time)/1000,
(unsigned)ntohl(nr->last_time)%1000);
asbuf[0] = buf[0] = '\0';
if (ver == 5) {
snprintf(buf, sizeof(buf), "/%u",
(unsigned)(ntohl(nr->masks) >> 24) & 0xff);
snprintf(asbuf, sizeof(asbuf), "%u:",
(unsigned)(ntohl(nr->asses) >> 16) & 0xffff);
}
printf("\n %s%s%s:%u ", inet_ntoa(nr->src_ina), buf, asbuf,
(unsigned)ntohl(nr->ports) >> 16);
if (ver == 5) {
snprintf(buf, sizeof(buf), "/%d",
(unsigned)(ntohl(nr->masks) >> 16) & 0xff);
snprintf(asbuf, sizeof(asbuf), "%u:",
(unsigned)ntohl(nr->asses) & 0xffff);
}
printf("> %s%s%s:%u ", inet_ntoa(nr->dst_ina), buf, asbuf,
(unsigned)ntohl(nr->ports) & 0xffff);
printf(">> %s\n ", inet_ntoa(nr->nhop_ina));
pent = getprotobynumber((ntohl(nr->proto_tos) >> 8) & 0xff);
if (!pent || nflag)
printf("%u ",
(unsigned)(ntohl(nr->proto_tos) >> 8) & 0xff);
else
printf("%s ", pent->p_name);
/* tcp flags for tcp only */
if (pent && pent->p_proto == IPPROTO_TCP) {
int flags;
if (ver == 1)
flags = (ntohl(nr->asses) >> 24) & 0xff;
else
flags = (ntohl(nr->proto_tos) >> 16) & 0xff;
if (flags & TH_FIN) putchar('F');
if (flags & TH_SYN) putchar('S');
if (flags & TH_RST) putchar('R');
if (flags & TH_PUSH) putchar('P');
if (flags & TH_ACK) putchar('A');
if (flags & TH_URG) putchar('U');
if (flags)
putchar(' ');
}
printf("tos %u, %u (%u octets)",
(unsigned)ntohl(nr->proto_tos) & 0xff,
(unsigned)ntohl(nr->packets),
(unsigned)ntohl(nr->octets));
}
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.27 1999/11/21 09:36:50 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.30 2000/09/28 06:42:57 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -32,20 +32,14 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
#if __STDC__
struct mbuf;
struct rtentry;
#endif
#include <net/if.h>
#ifdef HAVE_LIBDNET
#include <netdnet/dnetdb.h>
#endif
#include <ctype.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -740,13 +734,14 @@ char *
dnnum_string(u_short dnaddr)
{
char *str;
size_t siz;
int area = (u_short)(dnaddr & AREAMASK) >> AREASHIFT;
int node = dnaddr & NODEMASK;
str = (char *)malloc(sizeof("00.0000"));
str = (char *)malloc(siz = sizeof("00.0000"));
if (str == NULL)
error("dnnum_string: malloc");
sprintf(str, "%d.%d", area, node);
snprintf(str, siz, "%d.%d", area, node);
return(str);
}

View File

@ -29,7 +29,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.3 1999/12/22 06:27:20 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.12 2000/10/24 00:56:50 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -40,18 +40,12 @@ static const char rcsid[] =
#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>
@ -62,10 +56,10 @@ struct rtentry;
#include "dhcp6opt.h"
#if 0
static void dhcp6opttab_init __P((void));
static struct dhcp6_opt *dhcp6opttab_byname __P((char *));
static void dhcp6opttab_init (void);
static struct dhcp6_opt *dhcp6opttab_byname (char *);
#endif
static struct dhcp6_opt *dhcp6opttab_bycode __P((u_int));
static struct dhcp6_opt *dhcp6opttab_bycode (u_int);
static char tstr[] = " [|dhcp6]";
@ -74,36 +68,35 @@ static struct dhcp6_opt dh6opttab[] = {
{ 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, },
{ 8193, OL6_N, "IEEE 1003.1 POSIX Timezone", OT6_STR, },
{ 8194, OL6_16N, "Domain Name Server", OT6_V6, },
{ 8195, 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, },
{ 8196, OL6_N, "SLP Agent", OT6_NONE, },
{ 8197, OL6_N, "SLP Scope" , OT6_NONE, },
{ 8198, OL6_16N, "Network Time Protocol Servers", OT6_V6, },
{ 8199, OL6_N, "NIS Domain", OT6_STR, },
{ 8200, OL6_16N, "NIS Servers", OT6_V6, },
{ 8201, OL6_N, "NIS+ Domain", OT6_STR, },
{ 8202, OL6_16N, "NIS+ Servers", OT6_V6, },
/* TCP Parameters */
{ 32, 4, "TCP Keepalive Interval", OT6_NUM, },
{ 8203, 4, "TCP Keepalive Interval", OT6_NUM, },
/* DHCPv6 Extensions */
{ 40, 4, "Maximum DHCPv6 Message Size", OT6_NUM, },
{ 41, OL6_N, "DHCP Retransmission and Configuration Parameter",
{ 8204, 4, "Maximum DHCPv6 Message Size", OT6_NUM, },
{ 8205, 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",
{ 8206, OL6_N, "Extension Request", OT6_NONE, },
{ 8207, OL6_N, "Subnet Prefix", OT6_NONE, },
{ 8208, OL6_N, "Platform Specific Information", OT6_NONE, },
{ 8209, OL6_N, "Platform Class Identifier", OT6_STR, },
{ 8210, OL6_N, "Class Identifier", OT6_STR, },
{ 8211, 16, "Reconfigure Multicast Address", OT6_V6, },
{ 8212, 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, },
{ 8213, OL6_N, "Client-Server Authentication", OT6_NONE, },
{ 8214, 4, "Client Key Selection", OT6_NUM, },
/* End Extension */
{ 65536, OL6_Z, "End", OT6_NONE, },
@ -159,13 +152,18 @@ dhcp6ext_print(u_char *cp, u_char *ep)
if (cp == ep)
return;
printf(" ");
while (cp < ep) {
if (ep - cp < sizeof(u_int16_t))
break;
code = ntohs(*(u_int16_t *)&cp[0]);
if (ep - cp < sizeof(u_int16_t) * 2)
break;
if (code != 65535)
len = ntohs(*(u_int16_t *)&cp[2]);
else
len = 0;
if (ep - cp < len + 4)
break;
p = dhcp6opttab_bycode(code);
if (p == NULL) {
printf("(unknown, len=%d)", len);
@ -191,11 +189,11 @@ dhcp6ext_print(u_char *cp, u_char *ep)
break;
}
if (cp + 4 + len > ep) {
printf("[|%s]", p->name);
printf(" [|%s]", p->name);
return;
}
printf("(%s, ", p->name);
printf(" (%s, ", p->name);
switch (p->type) {
case OT6_V6:
for (i = 0; i < len; i += 16) {
@ -232,11 +230,12 @@ dhcp6ext_print(u_char *cp, u_char *ep)
*/
void
dhcp6_print(register const u_char *cp, u_int length,
u_short sport, u_short dport)
u_int16_t sport, u_int16_t dport)
{
union dhcp6 *dh6;
u_char *ep;
u_char *extp;
u_int16_t field16;
printf("dhcp6");
@ -246,31 +245,43 @@ dhcp6_print(register const u_char *cp, u_int length,
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
if (!(vflag && TTEST(dh6->dh6_sol.dh6sol_relayaddr))) {
printf(" solicit");
break;
}
printf(" solicit ("); /*)*/
if (dh6->dh6_sol.dh6sol_flags != 0) {
u_int8_t f = dh6->dh6_sol.dh6sol_flags;
printf("%s%s ",
(f & DH6SOL_PREFIX) ? "P" : "",
(f & DH6SOL_CLOSE) ? "C" : "");
}
memcpy(&field16, &dh6->dh6_sol.dh6sol_plen_id,
sizeof(field16));
field16 = ntohs(field16);
if (field16 & ~DH6SOL_SOLICIT_PLEN_MASK)
printf("plen=%d ", DH6SOL_SOLICIT_PLEN(field16));
printf("solicit-ID=%d", DH6SOL_SOLICIT_ID(field16));
printf(" cliaddr=%s",
ip6addr_string(&dh6->dh6_sol.dh6sol_cliaddr));
printf(" relayaddr=%s",
ip6addr_string(&dh6->dh6_sol.dh6sol_relayaddr));
/*(*/
printf(")");
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(" advert ("); /*)*/
memcpy(&field16, &dh6->dh6_adv.dh6adv_rsv_id, sizeof(field16));
printf("solicit-ID=%d",
ntohs(field16) & DH6SOL_SOLICIT_ID_MASK);
printf(" pref=%u", dh6->dh6_adv.dh6adv_pref);
printf(" cliaddr=%s",
ip6addr_string(&dh6->dh6_adv.dh6adv_cliaddr));
printf(" relayaddr=%s",
@ -279,6 +290,7 @@ dhcp6_print(register const u_char *cp, u_int length,
ip6addr_string(&dh6->dh6_adv.dh6adv_serveraddr));
extp = (u_char *)((&dh6->dh6_adv) + 1);
dhcp6ext_print(extp, ep);
/*(*/
printf(")");
break;
case DH6_REQUEST:
@ -286,26 +298,22 @@ dhcp6_print(register const u_char *cp, u_int length,
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(" request ("); /*)*/
if (dh6->dh6_req.dh6req_flags != 0) {
u_int8_t f = dh6->dh6_req.dh6req_flags;
printf("%s%s ",
(f & DH6REQ_CLOSE) ? "C" : "",
(f & DH6REQ_REBOOT) ? "R" : "");
}
printf("xid=0x%04x", dh6->dh6_req.dh6req_xid);
printf(" cliaddr=%s",
ip6addr_string(&dh6->dh6_req.dh6req_cliaddr));
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);
ip6addr_string(&dh6->dh6_req.dh6req_relayaddr));
printf(" servaddr=%s",
ip6addr_string(&dh6->dh6_req.dh6req_serveraddr));
dhcp6ext_print((char *)(&dh6->dh6_req + 1), ep);
/*(*/
printf(")");
break;
case DH6_REPLY:
@ -313,19 +321,22 @@ dhcp6_print(register const u_char *cp, u_int length,
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(" reply ("); /*)*/
if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_RELAYPRESENT) != 0)
printf("R ");
printf("stat=0x%02x",
dh6->dh6_rep.dh6rep_flagandstat & DH6REP_STATMASK);
printf(" xid=0x%04x", dh6->dh6_rep.dh6rep_xid);
printf(" cliaddr=%s",
ip6addr_string(&dh6->dh6_rep.dh6rep_cliaddr));
extp = (u_char *)((&dh6->dh6_rep) + 1);
if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_CLIPRESENT) != 0) {
printf(" cliaddr=%s", ip6addr_string(extp));
extp += 16;
if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_RELAYPRESENT) !=
0) {
printf(" relayaddr=%s", ip6addr_string(extp));
extp += sizeof(struct in6_addr);
}
dhcp6ext_print(extp, ep);
/*(*/
printf(")");
break;
case DH6_RELEASE:

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.42 1999/11/21 09:36:50 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.64 2001/01/02 23:24:51 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -30,22 +30,8 @@ static const char rcsid[] =
#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>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#ifdef NOERROR
#undef NOERROR /* Solaris sucks */
@ -53,7 +39,7 @@ struct rtentry;
#ifdef NOERROR
#undef T_UNSPEC /* SINIX does too */
#endif
#include <arpa/nameser.h>
#include "nameser.h"
#include <stdio.h>
#include <string.h>
@ -124,7 +110,14 @@ struct rtentry;
#define T_NAPTR 35 /* Naming Authority PoinTeR */
#endif
#ifndef T_A6
#define T_A6 38 /* IP6 address (ipngwg-dns-lookups) */
#define T_A6 38 /* IP6 address */
#endif
#ifndef T_DNAME
#define T_DNAME 39 /* non-terminal redirection */
#endif
#ifndef T_OPT
#define T_OPT 41 /* EDNS0 option (meta-RR) */
#endif
#ifndef T_UNSPEC
@ -162,8 +155,22 @@ ns_nskip(register const u_char *cp, register const u_char *bp)
if (((i = *cp++) & INDIR_MASK) == INDIR_MASK)
return (cp + 1);
if (cp >= snapend)
return(NULL);
while (i && cp < snapend) {
cp += i;
if ((i & INDIR_MASK) == EDNS0_MASK) {
int bitlen, bytelen;
if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL)
return(NULL); /* unknown ELT */
if ((bitlen = *cp++) == 0)
bitlen = 256;
bytelen = (bitlen + 7) / 8;
cp += bytelen;
} else
cp += i;
if (cp >= snapend)
return(NULL);
i = *cp++;
}
return (cp);
@ -171,33 +178,135 @@ ns_nskip(register const u_char *cp, register const u_char *bp)
/* print a <domain-name> */
static const u_char *
ns_nprint(register const u_char *cp, register const u_char *bp)
blabel_print(const u_char *cp)
{
int bitlen, slen, b;
int truncated = 0;
const u_char *bitp, *lim;
char tc;
if (cp >= snapend)
return(NULL);
if ((bitlen = *cp) == 0)
bitlen = 256;
slen = (bitlen + 3) / 4;
if ((lim = cp + 1 + slen) > snapend) {
truncated = 1;
lim = snapend;
}
/* print the bit string as a hex string */
printf("\\[x");
for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++)
printf("%02x", *bitp);
if (bitp == lim)
printf("...");
else if (b > 4) {
tc = *bitp++;
printf("%02x", tc & (0xff << (8 - b)));
} else if (b > 0) {
tc = *bitp++;
printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)));
}
printf("/%d]", bitlen);
return(truncated ? NULL : lim);
}
static int
labellen(const u_char *cp)
{
register u_int i;
register const u_char *rp;
register int compress;
i = *cp++;
rp = cp + i;
if ((i & INDIR_MASK) == INDIR_MASK) {
rp = cp + 1;
compress = 1;
if (cp >= snapend)
return(-1);
i = *cp;
if ((i & INDIR_MASK) == EDNS0_MASK) {
int bitlen, elt;
if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL)
return(-1);
if (cp + 1 >= snapend)
return(-1);
if ((bitlen = *(cp + 1)) == 0)
bitlen = 256;
return(((bitlen + 7) / 8) + 1);
} else
return(i);
}
static const u_char *
ns_nprint(register const u_char *cp, register const u_char *bp)
{
register u_int i, l;
register const u_char *rp = NULL;
register int compress = 0;
int chars_processed;
int elt;
int data_size = snapend - bp;
if ((l = labellen(cp)) < 0)
return(NULL);
if (cp >= snapend)
return(NULL);
chars_processed = 1;
if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {
compress = 0;
rp = cp + l;
}
if (i != 0)
while (i && cp < snapend) {
if ((i & INDIR_MASK) == INDIR_MASK) {
if (!compress) {
rp = cp + 1;
compress = 1;
}
cp = bp + (((i << 8) | *cp) & 0x3fff);
if (cp >= snapend)
return(NULL);
if ((l = labellen(cp)) < 0)
return(NULL);
i = *cp++;
chars_processed++;
/*
* If we've looked at every character in
* the message, this pointer will make
* us look at some character again,
* which means we're looping.
*/
if (chars_processed >= data_size) {
printf("<LOOP>");
return (NULL);
}
continue;
}
if (fn_printn(cp, i, snapend))
break;
cp += i;
if ((i & INDIR_MASK) == EDNS0_MASK) {
elt = (i & ~INDIR_MASK);
switch(elt) {
case EDNS0_ELT_BITLABEL:
blabel_print(cp);
break;
default:
/* unknown ELT */
printf("<ELT %d>", elt);
return(NULL);
}
} else {
if (fn_printn(cp, l, snapend))
break;
}
cp += l;
chars_processed += l;
putchar('.');
if (cp >= snapend || (l = labellen(cp)) < 0)
return(NULL);
i = *cp++;
chars_processed++;
if (!compress)
rp += i + 1;
rp += l + 1;
}
else
putchar('.');
@ -210,6 +319,8 @@ ns_cprint(register const u_char *cp, register const u_char *bp)
{
register u_int i;
if (cp >= snapend)
return NULL;
i = *cp++;
(void)fn_printn(cp, i, snapend);
return (cp + i);
@ -252,17 +363,10 @@ static struct tok type2str[] = {
{ T_ATMA, "ATMA " },
{ T_NAPTR, "NAPTR " },
{ T_A6, "A6 " },
#ifndef T_UINFO
#define T_UINFO 100
#endif
{ T_DNAME, "DNAME " },
{ T_OPT, "OPT " },
{ T_UINFO, "UINFO" },
#ifndef T_UID
#define T_UID 101
#endif
{ T_UID, "UID" },
#ifndef T_GID
#define T_GID 102
#endif
{ T_GID, "GID" },
{ T_UNSPEC, "UNSPEC" },
{ T_UNSPECA, "UNSPECA" },
@ -282,7 +386,7 @@ static struct tok class2str[] = {
};
/* print a query */
static void
static const u_char *
ns_qprint(register const u_char *cp, register const u_char *bp)
{
register const u_char *np = cp;
@ -290,8 +394,8 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
cp = ns_nskip(cp, bp);
if (cp + 4 > snapend)
return;
if (cp + 4 > snapend || cp == NULL)
return(NULL);
/* print the qtype and qclass (if it's not IN) */
i = *cp++ << 8;
@ -303,33 +407,35 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
printf(" %s", tok2str(class2str, "(Class %d)", i));
fputs("? ", stdout);
ns_nprint(np, bp);
cp = ns_nprint(np, bp);
return(cp ? cp + 4 : NULL);
}
/* print a reply */
static const u_char *
ns_rprint(register const u_char *cp, register const u_char *bp)
{
register u_int i;
register u_int class;
register u_short typ, len;
register const u_char *rp;
if (vflag) {
putchar(' ');
cp = ns_nprint(cp, bp);
if ((cp = ns_nprint(cp, bp)) == NULL)
return NULL;
} else
cp = ns_nskip(cp, bp);
if (cp + 10 > snapend)
if (cp + 10 > snapend || cp == NULL)
return (snapend);
/* print the type/qtype and class (if it's not IN) */
typ = *cp++ << 8;
typ |= *cp++;
i = *cp++ << 8;
i |= *cp++;
if (i != C_IN)
printf(" %s", tok2str(class2str, "(Class %d)", i));
class = *cp++ << 8;
class |= *cp++;
if (class != C_IN && typ != T_OPT)
printf(" %s", tok2str(class2str, "(Class %d)", class));
/* ignore ttl */
cp += 4;
@ -340,9 +446,13 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
rp = cp + len;
printf(" %s", tok2str(type2str, "Type%d", typ));
switch (typ) {
if (rp > snapend)
return(NULL);
switch (typ) {
case T_A:
if (cp + sizeof(struct in_addr) > snapend)
return(NULL);
printf(" %s", ipaddr_string(cp));
break;
@ -350,15 +460,41 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
case T_CNAME:
case T_PTR:
#ifdef T_DNAME
case T_DNAME: /*XXX not checked as there's no server support yet*/
case T_DNAME:
#endif
putchar(' ');
(void)ns_nprint(cp, bp);
if (ns_nprint(cp, bp) == NULL)
return(NULL);
break;
case T_SOA:
if (!vflag)
break;
putchar(' ');
if ((cp = ns_nprint(cp, bp)) == NULL)
return(NULL);
putchar(' ');
if ((cp = ns_nprint(cp, bp)) == NULL)
return(NULL);
if (cp + 5 * 4 > snapend)
return(NULL);
printf(" %u", EXTRACT_32BITS(cp));
cp += 4;
printf(" %u", EXTRACT_32BITS(cp));
cp += 4;
printf(" %u", EXTRACT_32BITS(cp));
cp += 4;
printf(" %u", EXTRACT_32BITS(cp));
cp += 4;
printf(" %u", EXTRACT_32BITS(cp));
cp += 4;
break;
case T_MX:
putchar(' ');
(void)ns_nprint(cp + 2, bp);
if (cp + 2 > snapend)
return(NULL);
if (ns_nprint(cp + 2, bp) == NULL)
return(NULL);
printf(" %d", EXTRACT_16BITS(cp));
break;
@ -369,25 +505,43 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
#ifdef INET6
case T_AAAA:
if (cp + sizeof(struct in6_addr) > snapend)
return(NULL);
printf(" %s", ip6addr_string(cp));
break;
case T_A6: /*XXX not checked as there's no server support yet*/
case T_A6:
{
struct in6_addr a;
int pbyte;
int pbit, 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);
pbit = *cp;
pbyte = (pbit & ~7) / 8;
if (pbit > 128) {
printf(" %u(bad plen)", pbit);
break;
} else if (pbit < 128) {
memset(&a, 0, sizeof(a));
memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
printf(" %u %s", pbit, ip6addr_string(&a));
}
if (pbit > 0) {
putchar(' ');
if (ns_nprint(cp + 1 + sizeof(a) - pbyte, bp) == NULL)
return(NULL);
}
break;
}
#endif /*INET6*/
case T_OPT:
printf(" UDPsize=%u", class);
break;
case T_UNSPECA: /* One long string */
printf(" %.*s", len, cp);
if (cp + len > snapend)
return(NULL);
fn_printn(cp, len, snapend);
break;
}
return (rp); /* XXX This isn't always right */
@ -398,7 +552,7 @@ ns_print(register const u_char *bp, u_int length)
{
register const HEADER *np;
register int qdcount, ancount, nscount, arcount;
register const u_char *cp;
register const u_char *cp = NULL;
np = (const HEADER *)bp;
/* get the byte-order right */
@ -407,44 +561,76 @@ ns_print(register const u_char *bp, u_int length)
nscount = ntohs(np->nscount);
arcount = ntohs(np->arcount);
if (np->qr) {
if (DNS_QR(np)) {
/* this is a response */
printf(" %d%s%s%s%s%s",
printf(" %d%s%s%s%s%s%s",
ntohs(np->id),
ns_ops[np->opcode],
ns_resp[np->rcode],
np->aa? "*" : "",
np->ra? "" : "-",
np->tc? "|" : "");
ns_ops[DNS_OPCODE(np)],
ns_resp[DNS_RCODE(np)],
DNS_AA(np)? "*" : "",
DNS_RA(np)? "" : "-",
DNS_TC(np)? "|" : "",
DNS_CD(np)? "%" : "");
if (qdcount != 1)
printf(" [%dq]", qdcount);
/* Print QUESTION section on -vv */
if (vflag > 1) {
fputs(" q: ", stdout);
cp = ns_nprint((const u_char *)(np + 1), bp);
} else
cp = ns_nskip((const u_char *)(np + 1), bp);
fputs(" q:", stdout);
if ((cp = ns_qprint((const u_char *)(np + 1), bp))
== NULL)
goto trunc;
} else {
if ((cp = ns_nskip((const u_char *)(np + 1), bp))
== NULL)
goto trunc;
cp += 4;
}
printf(" %d/%d/%d", ancount, nscount, arcount);
if (ancount--) {
cp = ns_rprint(cp + 4, bp);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (ancount-- && cp < snapend) {
putchar(',');
cp = ns_rprint(cp, bp);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
/* Print NS and AR sections on -vv */
if (vflag > 1) {
if (nscount-- && cp < snapend) {
fputs(" ns:", stdout);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (nscount-- && cp < snapend) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
if (arcount-- && cp < snapend) {
fputs(" ar:", stdout);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (arcount-- && cp < snapend) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
}
}
else {
/* this is a request */
printf(" %d%s%s",
ntohs(np->id),
ns_ops[np->opcode],
np->rd? "+" : "");
printf(" %d%s%s%s", ntohs(np->id), ns_ops[DNS_OPCODE(np)],
DNS_RD(np) ? "+" : "",
DNS_AD(np) ? "$" : "");
/* any weirdness? */
if (*(((u_short *)np)+1) & htons(0x6ff))
if (*(((u_short *)np)+1) & htons(0x6cf))
printf(" [b2&3=0x%x]", ntohs(*(((u_short *)np)+1)));
if (np->opcode == IQUERY) {
if (DNS_OPCODE(np) == IQUERY) {
if (qdcount)
printf(" [%dq]", qdcount);
if (ancount != 1)
@ -461,7 +647,60 @@ ns_print(register const u_char *bp, u_int length)
if (arcount)
printf(" [%dau]", arcount);
ns_qprint((const u_char *)(np + 1), (const u_char *)np);
if (qdcount--) {
cp = ns_qprint((const u_char *)(np + 1),
(const u_char *)np);
if (!cp)
goto trunc;
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (qdcount-- && cp < snapend) {
cp = ns_qprint((const u_char *)cp,
(const u_char *)np);
if (!cp)
goto trunc;
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
/* Print remaining sections on -vv */
if (vflag > 1) {
if (ancount--) {
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (ancount-- && cp < snapend) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
if (nscount-- && cp < snapend) {
fputs(" ns:", stdout);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (nscount-- && cp < snapend) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
if (arcount-- && cp < snapend) {
fputs(" ar:", stdout);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (arcount-- && cp < snapend) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
}
}
printf(" (%d)", length);
return;
trunc:
printf("[|domain]");
return;
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.17 1999/11/22 04:30:34 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.20 2000/09/29 04:58:36 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -33,12 +33,6 @@ static const char rcsid[] =
#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>
#include <string.h>

View File

@ -20,7 +20,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.24 1999/11/21 09:36:51 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.26 2000/09/29 04:58:36 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -33,8 +33,6 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netdb.h>
#include <stdio.h>
@ -42,6 +40,8 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
#include "ip.h"
struct egp_packet {
u_char egp_version;
#define EGP_VERSION 2

View File

@ -23,7 +23,7 @@
#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)";
"@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.17 2000/12/12 09:58:41 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -36,20 +36,9 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#ifdef CRYPTO
#ifdef HAVE_LIBCRYPTO
#include <des.h>
#include <blowfish.h>
#ifdef HAVE_RC5_H
@ -62,33 +51,12 @@ static const char rcsid[] =
#include <stdio.h>
#include "ip.h"
#include "esp.h"
#ifdef INET6
#include <netinet/ip6.h>
#include "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"
@ -112,14 +80,14 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
esp = (struct esp *)bp;
spi = (u_int32_t)ntohl(esp->esp_spi);
/* 'ep' points to the end of avaible data. */
/* 'ep' points to the end of available data. */
ep = snapend;
if ((u_char *)(esp + 1) >= ep - sizeof(struct esp)) {
fputs("[|ESP]", stdout);
goto fail;
}
printf("ESP(spi=%u", spi);
printf("ESP(spi=0x%08x", spi);
printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(esp + 1)));
printf(")");
@ -164,7 +132,7 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
ip = (struct ip *)bp2;
switch (ip->ip_v) {
switch (IP_V(ip)) {
#ifdef INET6
case 6:
ip6 = (struct ip6_hdr *)bp2;
@ -197,7 +165,7 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
switch (algo) {
case DESCBC:
#ifdef CRYPTO
#ifdef HAVE_LIBCRYPTO
{
u_char iv[8];
des_key_schedule schedule;
@ -232,10 +200,10 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
#endif /*CRYPTO*/
#endif /*HAVE_LIBCRYPTO*/
case BLOWFISH:
#ifdef CRYPTO
#ifdef HAVE_LIBCRYPTO
{
BF_KEY schedule;
u_char *p;
@ -250,10 +218,10 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
#endif /*CRYPTO*/
#endif /*HAVE_LIBCRYPTO*/
case RC5:
#if defined(CRYPTO) && defined(HAVE_RC5_H)
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_RC5_H)
{
RC5_32_KEY schedule;
u_char *p;
@ -269,10 +237,10 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
#endif /*CRYPTO*/
#endif /*HAVE_LIBCRYPTO*/
case CAST128:
#if defined(CRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128)
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128)
{
CAST_KEY schedule;
u_char *p;
@ -287,10 +255,10 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
#endif /*CRYPTO*/
#endif /*HAVE_LIBCRYPTO*/
case DES3CBC:
#if defined(CRYPTO)
#if defined(HAVE_LIBCRYPTO)
{
des_key_schedule s1, s2, s3;
u_char *p;
@ -308,7 +276,7 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
}
#else
goto fail;
#endif /*CRYPTO*/
#endif /*HAVE_LIBCRYPTO*/
case NONE:
default:

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.48 1999/11/21 09:36:51 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.61 2000/12/22 22:45:10 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -31,32 +31,20 @@ static const char rcsid[] =
#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>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <pcap.h>
#ifdef INET6
#include <netinet/ip6.h>
#endif
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "ether.h"
const u_char *packetp;
const u_char *snapend;
@ -79,8 +67,6 @@ 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, 'h->tv' is the timestamp,
@ -94,10 +80,11 @@ 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;
u_short extracted_ethertype;
ts_print(&h->ts);
if (caplen < sizeof(struct ether_header)) {
if (caplen < ETHER_HDRLEN) {
printf("[|ether]");
goto out;
}
@ -113,10 +100,10 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
packetp = p;
snapend = p + caplen;
length -= sizeof(struct ether_header);
caplen -= sizeof(struct ether_header);
length -= ETHER_HDRLEN;
caplen -= ETHER_HDRLEN;
ep = (struct ether_header *)p;
p += sizeof(struct ether_header);
p += ETHER_HDRLEN;
ether_type = ntohs(ep->ether_type);
@ -126,10 +113,11 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
extracted_ethertype = 0;
if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep)) == 0) {
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
ether_print((u_char *)ep, length);
ether_print((u_char *)ep, length + ETHER_HDRLEN);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
@ -137,10 +125,11 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (!xflag && !qflag)
default_print(p, caplen);
}
} else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
} else if (ether_encap_print(ether_type, p, length, caplen,
&extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
ether_print((u_char *)ep, length + sizeof(*ep));
ether_print((u_char *)ep, length + ETHER_HDRLEN);
if (!xflag && !qflag)
default_print(p, caplen);
}
@ -156,16 +145,18 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
*
* Returns non-zero if it can do so, zero if the ethertype is unknown.
*
* Stuffs the ether type into a global for the benefit of lower layers
* that might want to know what it is.
* The Ethernet type code is passed through a pointer; if it was
* ETHERTYPE_8021Q, it gets updated to be the Ethernet type of
* the 802.1Q payload, for the benefit of lower layers that might
* want to know what it is.
*/
int
ether_encap_print(u_short ethertype, const u_char *p,
u_int length, u_int caplen)
u_int length, u_int caplen, u_short *extracted_ethertype)
{
recurse:
extracted_ethertype = ethertype;
*extracted_ethertype = ethertype;
switch (ethertype) {
@ -198,30 +189,35 @@ ether_encap_print(u_short ethertype, const u_char *p,
aarp_print(p, length);
return (1);
case ETHERTYPE_IPX:
ipx_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));
printf("802.1Q vlan#%d P%d%s ",
ntohs(*(u_int16_t *)p) & 0xfff,
ntohs(*(u_int16_t *)p) >> 13,
(ntohs(*(u_int16_t *)p) & 0x1000) ? " CFI" : "");
ethertype = ntohs(*(u_int16_t *)(p + 2));
p += 4;
length -= 4;
caplen -= 4;
if (ethertype > ETHERMTU)
if (ethertype > ETHERMTU)
goto recurse;
extracted_ethertype = 0;
*extracted_ethertype = 0;
if (llc_print(p, length, caplen, p-18, p-12) == 0) {
if (llc_print(p, length, caplen, p - 18, p - 12,
extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
ether_print(p-18, length+4);
if (extracted_ethertype) {
ether_print(p - 18, length + 4);
if (*extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
etherproto_string(htons(*extracted_ethertype)));
}
if (!xflag && !qflag)
default_print(p-18, caplen+4);
default_print(p - 18, caplen + 4);
}
return (1);

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.40 1999/12/14 16:49:02 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.50 2000/12/23 20:48:13 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -34,16 +34,7 @@ static const char rcsid[] =
#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/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <ctype.h>
#include <netdb.h>
@ -55,6 +46,7 @@ struct rtentry;
#include "addrtoname.h"
#include "ethertype.h"
#include "ether.h"
#include "fddi.h"
/*
@ -96,8 +88,6 @@ int fddi_bitswap = 1;
* - vj
*/
#define FDDI_HDRLEN (sizeof(struct fddi_header))
static u_char fddi_bit_swap[] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
@ -289,10 +279,10 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
*/
snapend = p + caplen;
/*
* Actually, the only printer that uses packetp is print-bootp.c,
* and it assumes that packetp points to an Ethernet header. The
* right thing to do is to fix print-bootp.c to know which link
* type is in use when it excavates. XXX
* Actually, the only printers that use packetp are print-arp.c
* and print-bootp.c, and they assume that packetp points to an
* Ethernet header. The right thing to do is to fix them to know
* which link type is in use when they excavate. XXX
*/
packetp = (u_char *)&ehdr;
@ -308,14 +298,14 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
extracted_ethertype = 0;
if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr))
== 0) {
if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
&extracted_ethertype) == 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!eflag)
fddi_print(fddip, length,
fddi_print(fddip, length + FDDI_HDRLEN,
ESRC(&ehdr), EDST(&ehdr));
if (extracted_ethertype) {
printf("(LLC %s) ",
@ -329,7 +319,8 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
else {
/* Some kinds of FDDI packet we cannot handle intelligently */
if (!eflag)
fddi_print(fddip, length, ESRC(&ehdr), EDST(&ehdr));
fddi_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
EDST(&ehdr));
if (!xflag && !qflag)
default_print(p, caplen);
}

View File

@ -21,7 +21,7 @@
#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 $";
"@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.12 2000/10/07 05:53:10 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -35,21 +35,12 @@ static const char rcsid[] =
#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 "ip6.h"
#include "interface.h"
#include "addrtoname.h"
@ -68,7 +59,7 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
dp = (struct ip6_frag *)bp;
ip6 = (struct ip6_hdr *)bp2;
/* 'ep' points to the end of avaible data. */
/* 'ep' points to the end of available data. */
ep = snapend;
TCHECK(dp->ip6f_offlg);
@ -86,7 +77,7 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
(long)(bp - bp2) - sizeof(struct ip6_frag));
}
#if 0
#if 1
/* it is meaningless to decode non-first fragment */
if (ntohs(dp->ip6f_offlg & IP6F_OFF_MASK) != 0)
return 65535;

View File

@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.6 1999/11/21 09:36:52 fenner Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.9 2000/12/18 05:41:59 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -37,8 +37,6 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netdb.h>
#include <stdio.h>
@ -88,7 +86,7 @@ gre_print(const u_char *bp, u_int length)
{
const u_char *cp = bp + 4;
const struct gre *gre;
u_short flags, proto;
u_short flags, proto, extracted_ethertype;
gre = (const struct gre *)bp;
@ -125,7 +123,8 @@ gre_print(const u_char *bp, u_int length)
cp += 4;
length -= cp - bp;
if (ether_encap_print(proto, cp, length, length) == 0)
if (ether_encap_print(proto, cp, length, length,
&extracted_ethertype) == 0)
printf("gre-proto-0x%04X", proto);
return;

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.43 1999/11/22 04:28:21 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.57 2000/10/10 05:03:32 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -32,29 +32,139 @@ static const char rcsid[] =
#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>
#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 <string.h>
#include <netdb.h> /* for MAXHOSTNAMELEN on some platforms */
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#include "ip.h"
#include "udp.h"
/*
* Interface Control Message Protocol Definitions.
* Per RFC 792, September 1981.
*/
/*
* Structure of an icmp header.
*/
struct icmp {
u_int8_t icmp_type; /* type of message, see below */
u_int8_t icmp_code; /* type sub code */
u_int16_t icmp_cksum; /* ones complement cksum of struct */
union {
u_int8_t ih_pptr; /* ICMP_PARAMPROB */
struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
struct ih_idseq {
u_int16_t icd_id;
u_int16_t icd_seq;
} ih_idseq;
u_int32_t ih_void;
/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
struct ih_pmtu {
u_int16_t ipm_void;
u_int16_t ipm_nextmtu;
} ih_pmtu;
} icmp_hun;
#define icmp_pptr icmp_hun.ih_pptr
#define icmp_gwaddr icmp_hun.ih_gwaddr
#define icmp_id icmp_hun.ih_idseq.icd_id
#define icmp_seq icmp_hun.ih_idseq.icd_seq
#define icmp_void icmp_hun.ih_void
#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
union {
struct id_ts {
u_int32_t its_otime;
u_int32_t its_rtime;
u_int32_t its_ttime;
} id_ts;
struct id_ip {
struct ip idi_ip;
/* options and then 64 bits of data */
} id_ip;
u_int32_t id_mask;
u_int8_t id_data[1];
} icmp_dun;
#define icmp_otime icmp_dun.id_ts.its_otime
#define icmp_rtime icmp_dun.id_ts.its_rtime
#define icmp_ttime icmp_dun.id_ts.its_ttime
#define icmp_ip icmp_dun.id_ip.idi_ip
#define icmp_mask icmp_dun.id_mask
#define icmp_data icmp_dun.id_data
};
/*
* Lower bounds on packet lengths for various types.
* For the error advice packets must first insure that the
* packet is large enought to contain the returned ip header.
* Only then can we do the check to see if 64 bits of packet
* data have been returned, since we need to check the returned
* ip header length.
*/
#define ICMP_MINLEN 8 /* abs minimum */
#define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */
#define ICMP_MASKLEN 12 /* address mask */
#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
#define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
/* N.B.: must separately check that ip_hl >= 5 */
/*
* Definition of type and code field values.
*/
#define ICMP_ECHOREPLY 0 /* echo reply */
#define ICMP_UNREACH 3 /* dest unreachable, codes: */
#define ICMP_UNREACH_NET 0 /* bad net */
#define ICMP_UNREACH_HOST 1 /* bad host */
#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
#define ICMP_UNREACH_PORT 3 /* bad port */
#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
#define ICMP_REDIRECT 5 /* shorter route, codes: */
#define ICMP_REDIRECT_NET 0 /* for network */
#define ICMP_REDIRECT_HOST 1 /* for host */
#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
#define ICMP_ECHO 8 /* echo service */
#define ICMP_ROUTERADVERT 9 /* router advertisement */
#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
#define ICMP_TIMXCEED 11 /* time exceeded, code: */
#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
#define ICMP_PARAMPROB 12 /* ip header bad */
#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
#define ICMP_TSTAMP 13 /* timestamp request */
#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
#define ICMP_IREQ 15 /* information request */
#define ICMP_IREQREPLY 16 /* information reply */
#define ICMP_MASKREQ 17 /* address mask request */
#define ICMP_MASKREPLY 18 /* address mask reply */
#define ICMP_MAXTYPE 18
#define ICMP_INFOTYPE(type) \
((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
(type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
/* rfc1700 */
#ifndef ICMP_UNREACH_NET_UNKNOWN
#define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */
@ -89,14 +199,6 @@ struct rtentry;
#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */
#endif
/* rfc1256 */
#ifndef ICMP_ROUTERADVERT
#define ICMP_ROUTERADVERT 9 /* router advertisement */
#endif
#ifndef ICMP_ROUTERSOLICIT
#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
#endif
/* Most of the icmp types */
static struct tok icmp2str[] = {
{ ICMP_ECHOREPLY, "echo reply" },
@ -149,15 +251,15 @@ static struct tok type2str[] = {
/* rfc1191 */
struct mtu_discovery {
short unused;
short nexthopmtu;
u_int16_t unused;
u_int16_t nexthopmtu;
};
/* rfc1256 */
struct ih_rdiscovery {
u_char ird_addrnum;
u_char ird_addrsiz;
u_short ird_lifetime;
u_int8_t ird_addrnum;
u_int8_t ird_addrsiz;
u_int16_t ird_lifetime;
};
struct id_rdiscovery {
@ -175,7 +277,7 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
register const struct ip *oip;
register const struct udphdr *ouh;
register u_int hlen, dport, mtu;
char buf[256];
char buf[MAXHOSTNAMELEN + 100];
dp = (struct icmp *)bp;
ip = (struct ip *)bp2;
@ -196,35 +298,36 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
case ICMP_UNREACH_PROTOCOL:
TCHECK(dp->icmp_ip.ip_p);
(void)sprintf(buf, "%s protocol %d unreachable",
ipaddr_string(&dp->icmp_ip.ip_dst),
dp->icmp_ip.ip_p);
(void)snprintf(buf, sizeof(buf),
"%s protocol %d unreachable",
ipaddr_string(&dp->icmp_ip.ip_dst),
dp->icmp_ip.ip_p);
break;
case ICMP_UNREACH_PORT:
TCHECK(dp->icmp_ip.ip_p);
oip = &dp->icmp_ip;
hlen = oip->ip_hl * 4;
hlen = IP_HL(oip) * 4;
ouh = (struct udphdr *)(((u_char *)oip) + hlen);
dport = ntohs(ouh->uh_dport);
switch (oip->ip_p) {
case IPPROTO_TCP:
(void)sprintf(buf,
(void)snprintf(buf, sizeof(buf),
"%s tcp port %s unreachable",
ipaddr_string(&oip->ip_dst),
tcpport_string(dport));
break;
case IPPROTO_UDP:
(void)sprintf(buf,
(void)snprintf(buf, sizeof(buf),
"%s udp port %s unreachable",
ipaddr_string(&oip->ip_dst),
udpport_string(dport));
break;
default:
(void)sprintf(buf,
(void)snprintf(buf, sizeof(buf),
"%s protocol %d port %d unreachable",
ipaddr_string(&oip->ip_dst),
oip->ip_p, dport);
@ -233,26 +336,26 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
break;
case ICMP_UNREACH_NEEDFRAG:
{
{
register const struct mtu_discovery *mp;
mp = (struct mtu_discovery *)&dp->icmp_void;
mtu = EXTRACT_16BITS(&mp->nexthopmtu);
if (mtu)
(void)sprintf(buf,
"%s unreachable - need to frag (mtu %d)",
ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
else
(void)sprintf(buf,
"%s unreachable - need to frag",
ipaddr_string(&dp->icmp_ip.ip_dst));
if (mtu) {
(void)snprintf(buf, sizeof(buf),
"%s unreachable - need to frag (mtu %d)",
ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
} else {
(void)snprintf(buf, sizeof(buf),
"%s unreachable - need to frag",
ipaddr_string(&dp->icmp_ip.ip_dst));
}
}
break;
default:
fmt = tok2str(unreach2str, "#%d %%s unreachable",
dp->icmp_code);
(void)sprintf(buf, fmt,
(void)snprintf(buf, sizeof(buf), fmt,
ipaddr_string(&dp->icmp_ip.ip_dst));
break;
}
@ -262,55 +365,60 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
TCHECK(dp->icmp_ip.ip_dst);
fmt = tok2str(type2str, "redirect-#%d %%s to net %%s",
dp->icmp_code);
(void)sprintf(buf, fmt,
(void)snprintf(buf, sizeof(buf), fmt,
ipaddr_string(&dp->icmp_ip.ip_dst),
ipaddr_string(&dp->icmp_gwaddr));
break;
case ICMP_ROUTERADVERT:
{
{
register const struct ih_rdiscovery *ihp;
register const struct id_rdiscovery *idp;
u_int lifetime, num, size;
(void)strcpy(buf, "router advertisement");
(void)snprintf(buf, sizeof(buf), "router advertisement");
cp = buf + strlen(buf);
ihp = (struct ih_rdiscovery *)&dp->icmp_void;
TCHECK(*ihp);
(void)strcpy(cp, " lifetime ");
(void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf));
cp = buf + strlen(buf);
lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
if (lifetime < 60)
(void)sprintf(cp, "%u", lifetime);
else if (lifetime < 60 * 60)
(void)sprintf(cp, "%u:%02u",
if (lifetime < 60) {
(void)snprintf(cp, sizeof(buf) - (cp - buf), "%u",
lifetime);
} else if (lifetime < 60 * 60) {
(void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u",
lifetime / 60, lifetime % 60);
else
(void)sprintf(cp, "%u:%02u:%02u",
} else {
(void)snprintf(cp, sizeof(buf) - (cp - buf),
"%u:%02u:%02u",
lifetime / 3600,
(lifetime % 3600) / 60,
lifetime % 60);
}
cp = buf + strlen(buf);
num = ihp->ird_addrnum;
(void)sprintf(cp, " %d:", num);
(void)snprintf(cp, sizeof(buf) - (cp - buf), " %d:", num);
cp = buf + strlen(buf);
size = ihp->ird_addrsiz;
if (size != 2) {
(void)sprintf(cp, " [size %d]", size);
(void)snprintf(cp, sizeof(buf) - (cp - buf),
" [size %d]", size);
break;
}
idp = (struct id_rdiscovery *)&dp->icmp_data;
while (num-- > 0) {
TCHECK(*idp);
(void)sprintf(cp, " {%s %u}",
(void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
ipaddr_string(&idp->ird_addr),
EXTRACT_32BITS(&idp->ird_pref));
cp = buf + strlen(buf);
++idp;
}
}
}
break;
case ICMP_TIMXCEED:
@ -326,26 +434,46 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
break;
default:
(void)sprintf(buf, "time exceeded-#%d", dp->icmp_code);
(void)snprintf(buf, sizeof(buf), "time exceeded-#%d",
dp->icmp_code);
break;
}
break;
case ICMP_PARAMPROB:
if (dp->icmp_code)
(void)sprintf(buf, "parameter problem - code %d",
dp->icmp_code);
(void)snprintf(buf, sizeof(buf),
"parameter problem - code %d", dp->icmp_code);
else {
TCHECK(dp->icmp_pptr);
(void)sprintf(buf, "parameter problem - octet %d",
dp->icmp_pptr);
(void)snprintf(buf, sizeof(buf),
"parameter problem - octet %d", dp->icmp_pptr);
}
break;
case ICMP_MASKREPLY:
TCHECK(dp->icmp_mask);
(void)sprintf(buf, "address mask is 0x%08x",
(u_int32_t)ntohl(dp->icmp_mask));
(void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
(unsigned)ntohl(dp->icmp_mask));
break;
case ICMP_TSTAMP:
TCHECK(dp->icmp_seq);
(void)snprintf(buf, sizeof(buf),
"time stamp query id %u seq %u",
(unsigned)ntohs(dp->icmp_id),
(unsigned)ntohs(dp->icmp_seq));
break;
case ICMP_TSTAMPREPLY:
TCHECK(dp->icmp_ttime);
(void)snprintf(buf, sizeof(buf),
"time stamp reply id %u seq %u : org 0x%lx recv 0x%lx xmit 0x%lx",
(unsigned)ntohs(dp->icmp_id),
(unsigned)ntohs(dp->icmp_seq),
(unsigned long)ntohl(dp->icmp_otime),
(unsigned long)ntohl(dp->icmp_rtime),
(unsigned long)ntohl(dp->icmp_ttime));
break;
default:

View File

@ -21,7 +21,7 @@
#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 $";
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.42 2000/12/13 07:57:05 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -37,43 +37,46 @@ static const char rcsid[] =
#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 <netdb.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include "ip6.h"
#include "icmp6.h"
#include "interface.h"
#include "addrtoname.h"
#include "udp.h"
#include "ah.h"
void icmp6_opt_print(const u_char *, int);
void mld6_print(const u_char *);
static struct udphdr *get_upperlayer(u_char *, int *);
static void dnsname_print(const u_char *, const u_char *);
void icmp6_nodeinfo_print(int, const u_char *, const u_char *);
void icmp6_rrenum_print(int, const u_char *, const u_char *);
#ifndef abs
#define abs(a) ((0 < (a)) ? (a) : -(a))
#endif
void
icmp6_print(register const u_char *bp, register const u_char *bp2)
{
register const struct icmp6_hdr *dp;
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 int dport;
register const u_char *ep;
char buf[256];
int icmp6len;
int icmp6len, prot;
#if 0
#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
@ -83,7 +86,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
ip = (struct ip6_hdr *)bp2;
oip = (struct ip6_hdr *)(dp + 1);
str = buf;
/* 'ep' points to the end of avaible data. */
/* 'ep' points to the end of available data. */
ep = snapend;
if (ip->ip6_plen)
icmp6len = (ntohs(ip->ip6_plen) + sizeof(struct ip6_hdr) -
@ -92,13 +95,13 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
icmp6len = snapend - bp;
#if 0
(void)printf("%s > %s: ",
(void)printf("%s > %s: ",
ip6addr_string(&ip->ip6_src),
ip6addr_string(&ip->ip6_dst));
#endif
TCHECK(dp->icmp6_code);
switch(dp->icmp6_type) {
switch (dp->icmp6_type) {
case ICMP6_DST_UNREACH:
TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
@ -110,11 +113,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
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));
@ -124,11 +123,12 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
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);
if ((ouh = get_upperlayer((u_char *)oip, &prot))
== NULL)
goto trunc;
dport = ntohs(ouh->uh_dport);
switch (oip->ip6_nxt) {
switch (prot) {
case IPPROTO_TCP:
printf("icmp6: %s tcp port %s unreachable",
ip6addr_string(&oip->ip6_dst),
@ -216,7 +216,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
printf("icmp6: router solicitation ");
if (vflag) {
#define RTSOLLEN 8
icmp6_opt_print((const u_char *)dp + RTSOLLEN,
icmp6_opt_print((const u_char *)dp + RTSOLLEN,
icmp6len - RTSOLLEN);
}
break;
@ -232,6 +232,11 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
printf("M");
if (p->nd_ra_flags_reserved & ND_RA_FLAG_OTHER)
printf("O");
#ifndef ND_RA_FLAG_HA
#define ND_RA_FLAG_HA 0x20
#endif
if (p->nd_ra_flags_reserved & ND_RA_FLAG_HA)
printf("H");
if (p->nd_ra_flags_reserved != 0)
printf(" ");
printf("router_ltime=%d, ", ntohs(p->nd_ra_router_lifetime));
@ -240,7 +245,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
printf("retrans_time=%u)",
(u_int32_t)ntohl(p->nd_ra_retransmit));
#define RTADVLEN 16
icmp6_opt_print((const u_char *)dp + RTADVLEN,
icmp6_opt_print((const u_char *)dp + RTADVLEN,
icmp6len - RTADVLEN);
}
break;
@ -253,7 +258,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
ip6addr_string(&p->nd_ns_target));
if (vflag) {
#define NDSOLLEN 24
icmp6_opt_print((const u_char *)dp + NDSOLLEN,
icmp6_opt_print((const u_char *)dp + NDSOLLEN,
icmp6len - NDSOLLEN);
}
}
@ -266,7 +271,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
TCHECK(p->nd_na_target);
printf("icmp6: neighbor adv: tgt is %s",
ip6addr_string(&p->nd_na_target));
if (vflag) {
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. */
@ -285,124 +290,34 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
printf(")");
}
#define NDADVLEN 24
icmp6_opt_print((const u_char *)dp + NDADVLEN,
icmp6_opt_print((const u_char *)dp + NDADVLEN,
icmp6len - NDADVLEN);
#undef 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);
printf("icmp6: redirect %s",
getname6((const u_char *)&RDR(dp)->nd_rd_dst));
printf(" to %s",
getname6((const u_char*)&RDR(dp)->nd_rd_target));
#define REDIRECTLEN 40
if (vflag) {
icmp6_opt_print((const u_char *)dp + REDIRECTLEN,
icmp6len - REDIRECTLEN);
}
break;
}
#undef REDIRECTLEN
#undef RDR
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;
}
icmp6_rrenum_print(icmp6len, bp, ep);
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);
}
}
case ICMP6_NI_QUERY:
case ICMP6_NI_REPLY:
icmp6_nodeinfo_print(icmp6len, bp, ep);
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;
@ -415,6 +330,79 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
#endif
}
static struct udphdr *
get_upperlayer(register u_char *bp, int *prot)
{
register const u_char *ep;
struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
struct udphdr *uh;
struct ip6_hbh *hbh;
struct ip6_frag *fragh;
struct ah *ah;
int nh, hlen;
/* 'ep' points to the end of available data. */
ep = snapend;
if (TTEST(ip6->ip6_nxt) == 0)
return NULL;
nh = ip6->ip6_nxt;
hlen = sizeof(struct ip6_hdr);
while (bp < snapend) {
bp += hlen;
switch(nh) {
case IPPROTO_UDP:
case IPPROTO_TCP:
uh = (struct udphdr *)bp;
if (TTEST(uh->uh_dport)) {
*prot = nh;
return(uh);
}
else
return(NULL);
/* NOTREACHED */
case IPPROTO_HOPOPTS:
case IPPROTO_DSTOPTS:
case IPPROTO_ROUTING:
hbh = (struct ip6_hbh *)bp;
if (TTEST(hbh->ip6h_len) == 0)
return(NULL);
nh = hbh->ip6h_nxt;
hlen = (hbh->ip6h_len + 1) << 3;
break;
case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */
fragh = (struct ip6_frag *)bp;
if (TTEST(fragh->ip6f_offlg) == 0)
return(NULL);
/* fragments with non-zero offset are meaningless */
if ((fragh->ip6f_offlg & IP6F_OFF_MASK) != 0)
return(NULL);
nh = fragh->ip6f_nxt;
hlen = sizeof(struct ip6_frag);
break;
case IPPROTO_AH:
ah = (struct ah *)bp;
if (TTEST(ah->ah_len) == 0)
return(NULL);
nh = ah->ah_nxt;
hlen = (ah->ah_len + 2) << 2;
break;
default: /* unknown or undecodable header */
*prot = nh; /* meaningless, but set here anyway */
return(NULL);
}
}
return(NULL); /* should be notreached, though */
}
void
icmp6_opt_print(register const u_char *bp, int resid)
{
@ -423,6 +411,7 @@ icmp6_opt_print(register const u_char *bp, int resid)
register const struct nd_opt_prefix_info *opp;
register const struct icmp6_opts_redirect *opr;
register const struct nd_opt_mtu *opm;
register const struct nd_opt_advint *opa;
register const u_char *ep;
int opts_len;
#if 0
@ -434,9 +423,6 @@ icmp6_opt_print(register const u_char *bp, int resid)
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;
@ -445,13 +431,13 @@ icmp6_opt_print(register const u_char *bp, int resid)
oip = &dp->icmp6_ip6;
str = buf;
#endif
/* 'ep' points to the end of avaible data. */
/* 'ep' points to the end of available data. */
ep = snapend;
ECHECK(op->nd_opt_len);
if (resid <= 0)
return;
switch(op->nd_opt_type) {
switch (op->nd_opt_type) {
case ND_OPT_SOURCE_LINKADDR:
opl = (struct nd_opt_hdr *)op;
#if 1
@ -460,10 +446,11 @@ icmp6_opt_print(register const u_char *bp, int resid)
#else
TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
#endif
printf("(src lladdr: %s",
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));
@ -476,10 +463,11 @@ icmp6_opt_print(register const u_char *bp, int resid)
#else
TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
#endif
printf("(tgt lladdr: %s",
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));
@ -487,11 +475,13 @@ icmp6_opt_print(register const u_char *bp, int resid)
case ND_OPT_PREFIX_INFORMATION:
opp = (struct nd_opt_prefix_info *)op;
TCHECK(opp->nd_opt_pi_prefix);
printf("(prefix info: ");
printf("(prefix info: "); /*)*/
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)
printf("L");
printf("L");
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)
printf("A");
printf("A");
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ROUTER)
printf("R");
if (opp->nd_opt_pi_flags_reserved)
printf(" ");
printf("valid_ltime=");
@ -512,6 +502,7 @@ icmp6_opt_print(register const u_char *bp, int resid)
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));
@ -526,7 +517,7 @@ icmp6_opt_print(register const u_char *bp, int resid)
case ND_OPT_MTU:
opm = (struct nd_opt_mtu *)op;
TCHECK(opm->nd_opt_mtu_mtu);
printf("(mtu: ");
printf("(mtu: "); /*)*/
printf("mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu));
if (opm->nd_opt_mtu_len != 1)
printf("!");
@ -534,6 +525,17 @@ icmp6_opt_print(register const u_char *bp, int resid)
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
case ND_OPT_ADVINT:
opa = (struct nd_opt_advint *)op;
TCHECK(opa->nd_opt_advint_advint);
printf("(advint: "); /*)*/
printf("advint=%u",
(u_int32_t)ntohl(opa->nd_opt_advint_advint));
/*(*/
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)",
@ -548,9 +550,6 @@ icmp6_opt_print(register const u_char *bp, int resid)
trunc:
fputs("[ndp opt]", stdout);
return;
#if 0
#undef TCHECK
#endif
#undef ECHECK
}
@ -560,7 +559,7 @@ 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' points to the end of available data. */
ep = snapend;
if ((u_char *)mp + sizeof(*mp) > ep)
@ -568,7 +567,427 @@ mld6_print(register const u_char *bp)
printf("max resp delay: %d ", ntohs(mp->mld6_maxdelay));
printf("addr: %s", ip6addr_string(&mp->mld6_addr));
}
static void
dnsname_print(const u_char *cp, const u_char *ep)
{
int i;
/* DNS name decoding - no decompression */
printf(", \"");
while (cp < ep) {
i = *cp++;
if (i) {
if (i > ep - cp) {
printf("???");
break;
}
while (i-- && cp < ep) {
safeputchar(*cp);
cp++;
}
if (cp + 1 < ep && *cp)
printf(".");
} else {
if (cp == ep) {
/* FQDN */
printf(".");
} else if (cp + 1 == ep && *cp == '\0') {
/* truncated */
} else {
/* invalid */
printf("???");
}
break;
}
}
printf("\"");
}
void
icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
{
struct icmp6_nodeinfo *ni6;
struct icmp6_hdr *dp;
const u_char *cp;
int siz, i;
int needcomma;
dp = (struct icmp6_hdr *)bp;
ni6 = (struct icmp6_nodeinfo *)bp;
siz = ep - bp;
switch (ni6->ni_type) {
case ICMP6_NI_QUERY:
if (siz == sizeof(*dp) + 4) {
/* KAME who-are-you */
printf("icmp6: who-are-you request");
break;
}
printf("icmp6: node information query");
TCHECK2(*dp, sizeof(*ni6));
ni6 = (struct icmp6_nodeinfo *)dp;
printf(" ("); /*)*/
switch (ntohs(ni6->ni_qtype)) {
case NI_QTYPE_NOOP:
printf("noop");
break;
case NI_QTYPE_SUPTYPES:
printf("supported qtypes");
i = ntohs(ni6->ni_flags);
if (i)
printf(" [%s]", (i & 0x01) ? "C" : "");
break;
break;
case NI_QTYPE_FQDN:
printf("DNS name");
break;
case NI_QTYPE_NODEADDR:
printf("node addresses");
i = ni6->ni_flags;
if (!i)
break;
/* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
printf(" [%s%s%s%s%s%s]",
(i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
(i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
(i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
(i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
(i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
(i & NI_NODEADDR_FLAG_ALL) ? "A" : "");
break;
default:
printf("unknown");
break;
}
if (ni6->ni_qtype == NI_QTYPE_NOOP ||
ni6->ni_qtype == NI_QTYPE_SUPTYPES) {
if (siz != sizeof(*ni6))
if (vflag)
printf(", invalid len");
/*(*/
printf(")");
break;
}
/* XXX backward compat, icmp-name-lookup-03 */
if (siz == sizeof(*ni6)) {
printf(", 03 draft");
/*(*/
printf(")");
break;
}
switch (ni6->ni_code) {
case ICMP6_NI_SUBJ_IPV6:
if (!TTEST2(*dp,
sizeof(*ni6) + sizeof(struct in6_addr)))
break;
if (siz != sizeof(*ni6) + sizeof(struct in6_addr)) {
if (vflag)
printf(", invalid subject len");
break;
}
printf(", subject=%s",
getname6((const u_char *)(ni6 + 1)));
break;
case ICMP6_NI_SUBJ_FQDN:
printf(", subject=DNS name");
cp = (const u_char *)(ni6 + 1);
if (cp[0] == ep - cp - 1) {
/* icmp-name-lookup-03, pascal string */
if (vflag)
printf(", 03 draft");
cp++;
printf(", \"");
while (cp < ep) {
safeputchar(*cp);
cp++;
}
printf("\"");
} else
dnsname_print(cp, ep);
break;
case ICMP6_NI_SUBJ_IPV4:
if (!TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr)))
break;
if (siz != sizeof(*ni6) + sizeof(struct in_addr)) {
if (vflag)
printf(", invalid subject len");
break;
}
printf(", subject=%s",
getname((const u_char *)(ni6 + 1)));
break;
default:
printf(", unknown subject");
break;
}
/*(*/
printf(")");
break;
case ICMP6_NI_REPLY:
if (icmp6len > siz) {
printf("[|icmp6: node information reply]");
break;
}
needcomma = 0;
ni6 = (struct icmp6_nodeinfo *)dp;
printf("icmp6: node information reply");
printf(" ("); /*)*/
switch (ni6->ni_code) {
case ICMP6_NI_SUCCESS:
if (vflag) {
printf("success");
needcomma++;
}
break;
case ICMP6_NI_REFUSED:
printf("refused");
needcomma++;
if (siz != sizeof(*ni6))
if (vflag)
printf(", invalid length");
break;
case ICMP6_NI_UNKNOWN:
printf("unknown");
needcomma++;
if (siz != sizeof(*ni6))
if (vflag)
printf(", invalid length");
break;
}
if (ni6->ni_code != ICMP6_NI_SUCCESS) {
/*(*/
printf(")");
break;
}
switch (ntohs(ni6->ni_qtype)) {
case NI_QTYPE_NOOP:
if (needcomma)
printf(", ");
printf("noop");
if (siz != sizeof(*ni6))
if (vflag)
printf(", invalid length");
break;
case NI_QTYPE_SUPTYPES:
if (needcomma)
printf(", ");
printf("supported qtypes");
i = ntohs(ni6->ni_flags);
if (i)
printf(" [%s]", (i & 0x01) ? "C" : "");
break;
case NI_QTYPE_FQDN:
if (needcomma)
printf(", ");
printf("DNS name");
cp = (const u_char *)(ni6 + 1) + 4;
if (cp[0] == ep - cp - 1) {
/* icmp-name-lookup-03, pascal string */
if (vflag)
printf(", 03 draft");
cp++;
printf(", \"");
while (cp < ep) {
safeputchar(*cp);
cp++;
}
printf("\"");
} else
dnsname_print(cp, ep);
if ((ntohs(ni6->ni_flags) & 0x01) != 0)
printf(" [TTL=%u]", *(u_int32_t *)(ni6 + 1));
break;
case NI_QTYPE_NODEADDR:
if (needcomma)
printf(", ");
printf("node addresses");
i = sizeof(*ni6);
while (i < siz) {
if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz)
break;
printf(" %s", getname6(bp + i));
i += sizeof(struct in6_addr);
printf("(%d)", ntohl(*(int32_t *)(bp + i)));
i += sizeof(int32_t);
}
i = ni6->ni_flags;
if (!i)
break;
printf(" [%s%s%s%s%s%s%s]",
(i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
(i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
(i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
(i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
(i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
(i & NI_NODEADDR_FLAG_ALL) ? "A" : "",
(i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : "");
break;
default:
if (needcomma)
printf(", ");
printf("unknown");
break;
}
/*(*/
printf(")");
break;
}
return;
trunc:
fputs("[|icmp6]", stdout);
}
void
icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
{
struct icmp6_router_renum *rr6;
struct icmp6_hdr *dp;
size_t siz;
const char *cp;
struct rr_pco_match *match;
struct rr_pco_use *use;
char hbuf[NI_MAXHOST];
int n;
dp = (struct icmp6_hdr *)bp;
rr6 = (struct icmp6_router_renum *)bp;
siz = ep - bp;
cp = (const char *)(rr6 + 1);
TCHECK(rr6->rr_reserved);
switch (rr6->rr_code) {
case ICMP6_ROUTER_RENUMBERING_COMMAND:
printf("router renum: command");
break;
case ICMP6_ROUTER_RENUMBERING_RESULT:
printf("router renum: result");
break;
case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET:
printf("router renum: sequence number reset");
break;
default:
printf("router renum: code-#%d", rr6->rr_code);
break;
}
printf(", seq=%u", (u_int32_t)ntohl(rr6->rr_seqnum));
if (vflag) {
#define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
printf("["); /*]*/
if (rr6->rr_flags) {
printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"),
F(ICMP6_RR_FLAGS_REQRESULT, "R"),
F(ICMP6_RR_FLAGS_ALLIF, "A"),
F(ICMP6_RR_FLAGS_SPECSITE, "S"),
F(ICMP6_RR_FLAGS_PREVDONE, "P"));
}
printf("seg=%u,", rr6->rr_segnum);
printf("maxdelay=%u", rr6->rr_maxdelay);
if (rr6->rr_reserved)
printf("rsvd=0x%x", (u_int16_t)ntohs(rr6->rr_reserved));
/*[*/
printf("]");
#undef F
}
if (rr6->rr_code == ICMP6_ROUTER_RENUMBERING_COMMAND) {
match = (struct rr_pco_match *)cp;
cp = (const char *)(match + 1);
TCHECK(match->rpm_prefix);
if (vflag)
printf("\n\t");
else
printf(" ");
printf("match("); /*)*/
switch (match->rpm_code) {
case RPM_PCO_ADD: printf("add"); break;
case RPM_PCO_CHANGE: printf("change"); break;
case RPM_PCO_SETGLOBAL: printf("setglobal"); break;
default: printf("#%u", match->rpm_code); break;
}
if (vflag) {
printf(",ord=%u", match->rpm_ordinal);
printf(",min=%u", match->rpm_minlen);
printf(",max=%u", match->rpm_maxlen);
}
if (inet_ntop(AF_INET6, &match->rpm_prefix, hbuf, sizeof(hbuf)))
printf(",%s/%u", hbuf, match->rpm_matchlen);
else
printf(",?/%u", match->rpm_matchlen);
/*(*/
printf(")");
n = match->rpm_len - 3;
if (n % 4)
goto trunc;
n /= 4;
while (n-- > 0) {
use = (struct rr_pco_use *)cp;
cp = (const char *)(use + 1);
TCHECK(use->rpu_prefix);
if (vflag)
printf("\n\t");
else
printf(" ");
printf("use("); /*)*/
if (use->rpu_flags) {
#define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
printf("%s%s,",
F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"),
F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P"));
#undef F
}
if (vflag) {
printf("mask=0x%x,", use->rpu_ramask);
printf("raflags=0x%x,", use->rpu_raflags);
if (~use->rpu_vltime == 0)
printf("vltime=infty,");
else
printf("vltime=%u,",
(u_int32_t)ntohl(use->rpu_vltime));
if (~use->rpu_pltime == 0)
printf("pltime=infty,");
else
printf("pltime=%u,",
(u_int32_t)ntohl(use->rpu_pltime));
}
if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf,
sizeof(hbuf)))
printf("%s/%u/%u", hbuf, use->rpu_uselen,
use->rpu_keeplen);
else
printf("?/%u/%u", use->rpu_uselen,
use->rpu_keeplen);
/*(*/
printf(")");
}
}
return;
trunc:
fputs("[|icmp6]", stdout);
}
#endif /* INET6 */

View File

@ -0,0 +1,307 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
* 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-igmp.c,v 1.3 2001/01/09 08:01:18 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#ifndef IN_CLASSD
#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
#endif
/* (following from ipmulti/mrouted/prune.h) */
/*
* The packet format for a traceroute request.
*/
struct tr_query {
u_int tr_src; /* traceroute source */
u_int tr_dst; /* traceroute destination */
u_int tr_raddr; /* traceroute response address */
u_int tr_rttlqid; /* response ttl and 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
* beginning, followed by one tr_resp for each hop taken.
*/
struct tr_resp {
u_int tr_qarr; /* query arrival time */
u_int tr_inaddr; /* incoming interface address */
u_int tr_outaddr; /* outgoing interface address */
u_int tr_rmtaddr; /* parent address in source tree */
u_int tr_vifin; /* input packet count on interface */
u_int tr_vifout; /* output packet count on interface */
u_int tr_pktcnt; /* total incoming packets for src-grp */
u_char tr_rproto; /* routing proto deployed on router */
u_char tr_fttl; /* ttl required to forward on outvif */
u_char tr_smask; /* subnet mask for src addr */
u_char tr_rflags; /* forwarding error codes */
};
/* defs within mtrace */
#define TR_QUERY 1
#define TR_RESP 2
/* fields for tr_rflags (forwarding error codes) */
#define TR_NO_ERR 0
#define TR_WRONG_IF 1
#define TR_PRUNED 2
#define TR_OPRUNED 3
#define TR_SCOPED 4
#define TR_NO_RTE 5
#define TR_NO_FWD 7
#define TR_NO_SPACE 0x81
#define TR_OLD_ROUTER 0x82
/* fields for tr_rproto (routing protocol) */
#define TR_PROTO_DVMRP 1
#define TR_PROTO_MOSPF 2
#define TR_PROTO_PIM 3
#define TR_PROTO_CBT 4
/* igmpv3 report types */
static struct tok igmpv3report2str[] = {
{ 1, "is_in" },
{ 2, "is_ex" },
{ 3, "to_in" },
{ 4, "to_ex" },
{ 5, "allow" },
{ 6, "block" },
{ 0, NULL }
};
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 %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_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 %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_GETTTL(ntohl(tr->tr_rttlqid)));
}
static void
print_igmpv3_report(register const u_char *bp, register u_int len,
register const u_char *bp2)
{
int group, nsrcs, ngroups;
register int i, j;
/* Minimum len is 16, and should be a multiple of 4 */
if (len < 16 || len & 0x03) {
(void)printf(" [invalid len %d]", len);
return;
}
TCHECK2(bp[6], 2);
ngroups = EXTRACT_16BITS(&bp[6]);
(void)printf(", %d group record(s)", ngroups);
if (vflag > 0) {
/* Print the group records */
group = 8;
for (i=0; i<ngroups; i++) {
if (len < group+8) {
(void)printf(" [invalid number of groups]");
return;
}
TCHECK2(bp[group+4], 4);
(void)printf(" [gaddr %s", ipaddr_string(&bp[group+4]));
(void)printf(" %s", tok2str(igmpv3report2str, " [v3-report-#%d]",
bp[group]));
nsrcs = EXTRACT_16BITS(&bp[group+2]);
/* Check the number of sources and print them */
if (len < group+8+(nsrcs<<2)) {
(void)printf(" [invalid number of sources %d]", nsrcs);
return;
}
if (vflag == 1)
(void)printf(", %d source(s)", nsrcs);
else {
/* Print the sources */
(void)printf(" {");
for (j=0; j<nsrcs; j++) {
TCHECK2(bp[group+8+(j<<2)], 4);
(void)printf(" %s", ipaddr_string(&bp[group+8+(j<<2)]));
}
(void)printf(" }");
}
/* Next group record */
group += 8 + (nsrcs << 2);
(void)printf("]");
}
}
return;
trunc:
(void)printf("[|igmp]");
return;
}
static void
print_igmpv3_query(register const u_char *bp, register u_int len,
register const u_char *bp2)
{
int nsrcs;
register int i;
(void)printf(" v3");
/* Minimum len is 12, and should be a multiple of 4 */
if (len < 12 || len & 0x03) {
(void)printf(" [invalid len %d]", len);
return;
}
TCHECK2(bp[4], 4);
if (EXTRACT_32BITS(&bp[4]) == 0)
return;
(void)printf(" [gaddr %s", ipaddr_string(&bp[4]));
TCHECK2(bp[10], 2);
nsrcs = EXTRACT_16BITS(&bp[10]);
if (nsrcs > 0) {
if (len < 12 + (nsrcs << 2))
(void)printf(" [invalid number of sources]");
else if (vflag > 1) {
(void)printf(" {");
for (i=0; i<nsrcs; i++) {
TCHECK2(bp[12+(i<<2)], 4);
(void)printf(" %s", ipaddr_string(&bp[12+(i<<2)]));
}
(void)printf(" }");
} else
(void)printf(", %d source(s)", nsrcs);
}
(void)printf("]");
return;
trunc:
(void)printf("[|igmp]");
return;
}
void
igmp_print(register const u_char *bp, register u_int len,
register const u_char *bp2)
{
if (qflag) {
(void)printf("igmp");
return;
}
TCHECK2(bp[0], 8);
switch (bp[0]) {
case 0x11:
(void)printf("igmp query");
if (len >= 12)
print_igmpv3_query(bp, len, bp2);
else {
if (bp[1]) {
(void)printf(" v2");
if (bp[1] != 100)
(void)printf(" [max resp time %d]", bp[1]);
} else
(void)printf(" v1");
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 v1 report %s", ipaddr_string(&bp[4]));
if (len != 8)
(void)printf(" [len %d]", len);
break;
case 0x16:
(void)printf("igmp v2 report %s", ipaddr_string(&bp[4]));
break;
case 0x22:
(void)printf("igmp v3 report");
print_igmpv3_report(bp, len, bp2);
break;
case 0x17:
(void)printf("igmp leave %s", ipaddr_string(&bp[4]));
break;
case 0x13:
(void)printf("igmp dvmrp");
if (len < 8)
(void)printf(" [len %d]", len);
else
dvmrp_print(bp, len);
break;
case 0x14:
(void)printf("igmp pimv1");
pimv1_print(bp, len);
break;
case 0x1e:
print_mresp(bp, len);
break;
case 0x1f:
print_mtrace(bp, len);
break;
default:
(void)printf("igmp-%d", bp[0]);
break;
}
if (vflag && TTEST2(bp[0], len)) {
/* Check the IGMP checksum */
if (in_cksum((const u_short*)bp, len, 0))
printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
}
return;
trunc:
fputs("[|igmp]", stdout);
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.11 1999/11/21 09:36:53 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.15 2000/09/29 04:58:40 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -35,11 +35,6 @@ static const char rcsid[] =
#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>
@ -47,6 +42,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
#include "igrp.h"
#include "ip.h"
#include "extract.h" /* must come after interface.h */
static void
@ -107,8 +103,8 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
next = EXTRACT_16BITS(&hdr->ig_nx);
(void)printf(" %s V%d edit=%d AS=%d (%d/%d/%d)",
tok2str(op2str, "op-#%d", hdr->ig_op),
hdr->ig_v,
tok2str(op2str, "op-#%d", IGRP_OP(hdr->ig_vop)),
IGRP_V(hdr->ig_vop),
hdr->ig_ed,
EXTRACT_16BITS(&hdr->ig_as),
nint,

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.79 1999/12/22 06:27:21 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.92 2001/01/02 23:00:01 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -33,16 +33,7 @@ static const char rcsid[] =
#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>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -52,161 +43,13 @@ static const char rcsid[] =
#include "interface.h"
#include "extract.h" /* must come after interface.h */
#include "ip.h"
/* Compatibility */
#ifndef IPPROTO_ND
#define IPPROTO_ND 77
#endif
#ifndef IN_CLASSD
#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
#endif
/* (following from ipmulti/mrouted/prune.h) */
/*
* The packet format for a traceroute request.
*/
struct tr_query {
u_int tr_src; /* traceroute source */
u_int tr_dst; /* traceroute destination */
u_int tr_raddr; /* traceroute response address */
u_int tr_rttlqid; /* response ttl and 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
* beginning, followed by one tr_resp for each hop taken.
*/
struct tr_resp {
u_int tr_qarr; /* query arrival time */
u_int tr_inaddr; /* incoming interface address */
u_int tr_outaddr; /* outgoing interface address */
u_int tr_rmtaddr; /* parent address in source tree */
u_int tr_vifin; /* input packet count on interface */
u_int tr_vifout; /* output packet count on interface */
u_int tr_pktcnt; /* total incoming packets for src-grp */
u_char tr_rproto; /* routing proto deployed on router */
u_char tr_fttl; /* ttl required to forward on outvif */
u_char tr_smask; /* subnet mask for src addr */
u_char tr_rflags; /* forwarding error codes */
};
/* defs within mtrace */
#define TR_QUERY 1
#define TR_RESP 2
/* fields for tr_rflags (forwarding error codes) */
#define TR_NO_ERR 0
#define TR_WRONG_IF 1
#define TR_PRUNED 2
#define TR_OPRUNED 3
#define TR_SCOPED 4
#define TR_NO_RTE 5
#define TR_NO_FWD 7
#define TR_NO_SPACE 0x81
#define TR_OLD_ROUTER 0x82
/* fields for tr_rproto (routing protocol) */
#define TR_PROTO_DVMRP 1
#define TR_PROTO_MOSPF 2
#define TR_PROTO_PIM 3
#define TR_PROTO_CBT 4
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 %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_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 %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_GETTTL(ntohl(tr->tr_rttlqid)));
}
static void
igmp_print(register const u_char *bp, register u_int len,
register const u_char *bp2)
{
register const struct ip *ip;
ip = (const struct ip *)bp2;
(void)printf("%s > %s: ",
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 (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 v1 report %s", ipaddr_string(&bp[4]));
if (len != 8)
(void)printf(" [len %d]", len);
break;
case 0x16:
(void)printf("igmp v2 report %s", ipaddr_string(&bp[4]));
break;
case 0x17:
(void)printf("igmp leave %s", ipaddr_string(&bp[4]));
break;
case 0x13:
(void)printf("igmp dvmrp");
if (len < 8)
(void)printf(" [len %d]", len);
else
dvmrp_print(bp, len);
break;
case 0x14:
(void)printf("igmp pimv1");
pimv1_print(bp, len);
break;
case 0x1e:
print_mresp(bp, len);
break;
case 0x1f:
print_mtrace(bp, len);
break;
default:
(void)printf("igmp-%d", bp[0]);
break;
}
if (vflag && TTEST2(bp[0], len)) {
/* Check the IGMP checksum */
if (in_cksum((const u_short*)bp, len, 0))
printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
}
return;
trunc:
fputs("[|igmp]", stdout);
}
/*
* print the recorded route in an IP RR, LSRR or SSRR option.
*/
@ -299,7 +142,15 @@ ip_optprint(register const u_char *cp, u_int length)
for (; length > 0; cp += len, length -= len) {
int tt = *cp;
len = (tt == IPOPT_NOP || tt == IPOPT_EOL) ? 1 : cp[1];
if (tt == IPOPT_NOP || tt == IPOPT_EOL)
len = 1;
else {
if (&cp[1] >= snapend) {
printf("[|ip]");
return;
}
len = cp[1];
}
if (len <= 0) {
printf("[|ip op len %d]", len);
return;
@ -442,7 +293,11 @@ ip_print(register const u_char *bp, register u_int length)
(void)printf("truncated-ip %d", length);
return;
}
hlen = ip->ip_hl * 4;
hlen = IP_HL(ip) * 4;
if (hlen < sizeof (struct ip)) {
(void)printf("bad-hlen %d", hlen);
return;
}
len = ntohs(ip->ip_len);
if (length < len)
@ -508,11 +363,11 @@ ip_print(register const u_char *bp, register u_int length)
}
case IPPROTO_TCP:
tcp_print(cp, len, (const u_char *)ip);
tcp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
break;
case IPPROTO_UDP:
udp_print(cp, len, (const u_char *)ip);
udp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
break;
case IPPROTO_ICMP:
@ -626,6 +481,17 @@ ip_print(register const u_char *bp, register u_int length)
pim_print(cp, len);
break;
#ifndef IPPROTO_VRRP
#define IPPROTO_VRRP 112
#endif
case IPPROTO_VRRP:
if (vflag)
(void)printf("vrrp %s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
vrrp_print(cp, len, ip->ip_ttl);
break;
default:
#if 0
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
@ -695,6 +561,8 @@ ip_print(register const u_char *bp, register u_int length)
(void)printf("%sid %d", sep, (int)ntohs(ip->ip_id));
sep = ", ";
}
(void)printf("%slen %d", sep, (int)ntohs(ip->ip_len));
sep = ", ";
if ((u_char *)ip + hlen <= snapend) {
sum = in_cksum((const u_short *)ip, hlen, 0);
if (sum != 0) {
@ -710,3 +578,29 @@ ip_print(register const u_char *bp, register u_int length)
printf(")");
}
}
void
ipN_print(register const u_char *bp, register u_int length)
{
struct ip *ip, hdr;
ip = (struct ip *)bp;
if (length < 4) {
(void)printf("truncated-ip %d", length);
return;
}
memcpy (&hdr, (char *)ip, 4);
switch (IP_V(&hdr)) {
case 4:
ip_print (bp, length);
return;
#ifdef INET6
case 6:
ip6_print (bp, length);
return;
#endif
default:
(void)printf("unknown ip %d", IP_V(&hdr));
return;
}
}

View File

@ -21,7 +21,7 @@
#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 $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.16 2000/11/17 19:08:15 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -36,23 +36,16 @@ static const char rcsid[] =
#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 <string.h>
#include "interface.h"
#include "addrtoname.h"
#include <netinet/ip6.h>
#include "ip6.h"
/*
* print an IP6 datagram.
@ -61,29 +54,30 @@ void
ip6_print(register const u_char *bp, register int length)
{
register const struct ip6_hdr *ip6;
register int hlen;
register int advance;
register int len;
register const u_char *cp;
int nh;
int fragmented = 0;
u_int flow;
ip6 = (const struct ip6_hdr *)bp;
#ifdef TCPDUMP_ALIGN
#ifdef LBL_ALIGN
/*
* The IP header is not word aligned, so copy into abuf.
* The IP6 header is not 16-byte 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)) {
if ((u_long)ip6 & 15) {
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;
if (abuf == NULL)
abuf = malloc(snaplen);
memcpy(abuf, ip6, min(length, snaplen));
snapend += abuf - (u_char *)ip6;
packetp = abuf;
ip = (struct ip6_hdr *)abuf;
ip6 = (struct ip6_hdr *)abuf;
}
#endif
if ((u_char *)(ip6 + 1) > snapend) {
@ -94,17 +88,17 @@ ip6_print(register const u_char *bp, register int length)
(void)printf("truncated-ip6 %d", length);
return;
}
hlen = sizeof(struct ip6_hdr);
advance = sizeof(struct ip6_hdr);
len = ntohs(ip6->ip6_plen);
if (length < len + hlen)
if (length < len + advance)
(void)printf("truncated-ip6 - %d bytes missing!",
len + hlen - length);
len + advance - length);
cp = (const u_char *)ip6;
nh = ip6->ip6_nxt;
while (cp < snapend) {
cp += hlen;
cp += advance;
if (cp == (u_char *)(ip6 + 1)
&& nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
@ -114,42 +108,43 @@ ip6_print(register const u_char *bp, register int length)
switch (nh) {
case IPPROTO_HOPOPTS:
hlen = hbhopt_print(cp);
advance = hbhopt_print(cp);
nh = *cp;
break;
case IPPROTO_DSTOPTS:
hlen = dstopt_print(cp);
advance = dstopt_print(cp);
nh = *cp;
break;
case IPPROTO_FRAGMENT:
hlen = frag6_print(cp, (const u_char *)ip6);
if (snapend <= cp + hlen)
advance = frag6_print(cp, (const u_char *)ip6);
if (snapend <= cp + advance)
goto end;
nh = *cp;
fragmented = 1;
break;
case IPPROTO_ROUTING:
hlen = rt6_print(cp, (const u_char *)ip6);
advance = 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);
(const u_char *)ip6, fragmented);
goto end;
case IPPROTO_UDP:
udp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
(const u_char *)ip6);
(const u_char *)ip6, fragmented);
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);
advance = ah_print(cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_ESP:
{
int enh;
cp += esp_print(cp, (const u_char *)ip6, &enh);
advance = esp_print(cp, (const u_char *)ip6, &enh);
if (enh < 0)
goto end;
nh = enh & 0xff;
@ -161,14 +156,17 @@ ip6_print(register const u_char *bp, register int length)
case IPPROTO_IPCOMP:
{
int enh;
cp += ipcomp_print(cp, (const u_char *)ip6, &enh);
advance = ipcomp_print(cp, (const u_char *)ip6, &enh);
if (enh < 0)
goto end;
nh = enh & 0xff;
break;
}
#ifndef IPPROTO_PIM
#define IPPROTO_PIM 103
#endif
case IPPROTO_PIM:
(void)printf("PIM");
pim_print(cp, len);
goto end;
#ifndef IPPROTO_OSPF

View File

@ -33,7 +33,7 @@
#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 $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.8 2000/12/13 07:57:05 itojun Exp $";
#endif
#ifdef INET6
@ -43,13 +43,86 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <stdio.h>
#include "ip6.h"
#include "interface.h"
#include "addrtoname.h"
/* items outside of rfc2292bis */
#ifndef IP6OPT_MINLEN
#define IP6OPT_MINLEN 2
#endif
#ifndef IP6OPT_RTALERT_LEN
#define IP6OPT_RTALERT_LEN 4
#endif
#ifndef IP6OPT_JUMBO_LEN
#define IP6OPT_JUMBO_LEN 6
#endif
#define IP6OPT_HOMEADDR_MINLEN 18
#define IP6OPT_BU_MINLEN 10
#define IP6OPT_BA_MINLEN 13
#define IP6OPT_BR_MINLEN 2
#define IP6SOPT_ALTCOA 0x4
#define IP6SOPT_ALTCOA_MINLEN 18
#define IP6SOPT_UI 0x2
#define IP6SOPT_UI_MINLEN 4
static void ip6_sopt_print(const u_char *, int);
static void
ip6_sopt_print(const u_char *bp, int len)
{
int i;
int optlen;
for (i = 0; i < len; i += optlen) {
switch (bp[i]) {
case IP6OPT_PAD1:
printf(", pad1");
optlen = 1;
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
printf(", padn: trunc");
goto trunc;
}
printf(", padn");
optlen = bp[i + 1] + 2;
break;
case IP6SOPT_ALTCOA:
if (len - i < IP6SOPT_ALTCOA_MINLEN) {
printf(", altcoa: trunc");
goto trunc;
}
printf(", alt-CoA: %s", ip6addr_string(&bp[i+2]));
optlen = bp[i + 1] + 2;
break;
case IP6SOPT_UI:
if (len - i < IP6SOPT_UI_MINLEN) {
printf(", ui: trunc");
goto trunc;
}
printf("(ui: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2]));
optlen = bp[i + 1] + 2;
break;
default:
if (len - i < IP6OPT_MINLEN) {
printf(", sopt_type %d: trunc)", bp[i]);
goto trunc;
}
printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]);
optlen = bp[i + 1] + 2;
break;
}
}
return;
trunc:
printf("[trunc] ");
}
void
ip6_opt_print(const u_char *bp, int len)
{
@ -59,6 +132,7 @@ ip6_opt_print(const u_char *bp, int len)
for (i = 0; i < len; i += optlen) {
switch (bp[i]) {
case IP6OPT_PAD1:
printf("(pad1)");
optlen = 1;
break;
case IP6OPT_PADN:
@ -66,9 +140,10 @@ ip6_opt_print(const u_char *bp, int len)
printf("(padn: trunc)");
goto trunc;
}
printf("(padn)");
optlen = bp[i + 1] + 2;
break;
case IP6OPT_RTALERT:
case IP6OPT_ROUTER_ALERT:
if (len - i < IP6OPT_RTALERT_LEN) {
printf("(rtalert: trunc)");
goto trunc;
@ -77,7 +152,7 @@ ip6_opt_print(const u_char *bp, int len)
printf("(rtalert: invalid len %d)", bp[i + 1]);
goto trunc;
}
printf("(rtalert: 0x%04x) ", ntohs(*(u_short *)&bp[i + 2]));
printf("(rtalert: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2]));
optlen = IP6OPT_RTALERT_LEN;
break;
case IP6OPT_JUMBO:
@ -89,15 +164,103 @@ ip6_opt_print(const u_char *bp, int len)
printf("(jumbo: invalid len %d)", bp[i + 1]);
goto trunc;
}
printf("(jumbo: %u) ", (u_int32_t)ntohl(*(u_int *)&bp[i + 2]));
printf("(jumbo: %u) ", (u_int32_t)ntohl(*(u_int32_t *)&bp[i + 2]));
optlen = IP6OPT_JUMBO_LEN;
break;
case IP6OPT_HOME_ADDRESS:
if (len - i < IP6OPT_HOMEADDR_MINLEN) {
printf("(homeaddr: trunc)");
goto trunc;
}
if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) {
printf("(homeaddr: invalid len %d)", bp[i + 1]);
goto trunc;
}
printf("(homeaddr: %s", ip6addr_string(&bp[i + 2]));
if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_HOMEADDR_MINLEN],
(optlen-IP6OPT_HOMEADDR_MINLEN));
}
printf(")");
optlen = bp[i + 1] + 2;
break;
case IP6OPT_BINDING_UPDATE:
if (len - i < IP6OPT_BU_MINLEN) {
printf("(bu: trunc)");
goto trunc;
}
if (bp[i + 1] < IP6OPT_BU_MINLEN - 2) {
printf("(bu: invalid len %d)", bp[i + 1]);
goto trunc;
}
printf("(bu: ");
if (bp[i + 2] & 0x80)
printf("A");
if (bp[i + 2] & 0x40)
printf("H");
if (bp[i + 2] & 0x20)
printf("R");
if (bp[i + 2] & 0x10)
printf("D");
if (bp[i + 2] & 0x0f)
printf("res");
printf(", prefixlen: %u", bp[i + 3]);
printf(", sequence: %u",
(u_int16_t)ntohs(*(u_int16_t *)&bp[i + 4]));
printf(", lifetime: %u",
(u_int32_t)ntohs(*(u_int32_t *)&bp[i + 8]));
optlen = bp[i + 1] + 2;
if (bp[i + 1] > IP6OPT_BU_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_BU_MINLEN],
(optlen - IP6OPT_BU_MINLEN));
}
printf(")");
break;
case IP6OPT_BINDING_ACK:
if (len - i < IP6OPT_BA_MINLEN) {
printf("(ba: trunc)");
goto trunc;
}
if (bp[i + 1] < IP6OPT_BA_MINLEN - 2) {
printf("(ba: invalid len %d)", bp[i + 1]);
goto trunc;
}
printf("(ba: ");
printf("status: %u", bp[i + 2]);
printf(", sequence: %u",
(u_int16_t)ntohs(*(u_int16_t *)&bp[i + 3]));
printf(", lifetime: %u",
(u_int32_t)ntohs(*(u_int32_t *)&bp[i + 7]));
printf(", refresh: %u",
(u_int32_t)ntohs(*(u_int32_t *)&bp[i + 11]));
if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN],
(optlen-IP6OPT_BA_MINLEN));
}
printf(")");
optlen = bp[i + 1] + 2;
break;
case IP6OPT_BINDING_REQ:
if (len - i < IP6OPT_BR_MINLEN) {
printf("(br: trunc)");
goto trunc;
}
printf("(br");
if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN],
(optlen-IP6OPT_BR_MINLEN));
}
printf(")");
optlen = bp[i + 1] + 2;
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]);
printf("(opt_type 0x%02x: len=%d) ", bp[i], bp[i + 1]);
optlen = bp[i + 1] + 2;
break;
}
@ -119,11 +282,11 @@ hbhopt_print(register const u_char *bp)
register const u_char *ep;
int hbhlen = 0;
/* 'ep' points to the end of avaible data. */
/* 'ep' points to the end of available data. */
ep = snapend;
TCHECK(dp->ip6h_len);
hbhlen = (int)((dp->ip6h_len + 1) << 3);
TCHECK2(dp, hbhlen);
TCHECK2(*dp, hbhlen);
printf("HBH ");
if (vflag)
ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
@ -142,11 +305,11 @@ dstopt_print(register const u_char *bp)
register const u_char *ep;
int dstoptlen = 0;
/* 'ep' points to the end of avaible data. */
/* 'ep' points to the end of available data. */
ep = snapend;
TCHECK(dp->ip6d_len);
dstoptlen = (int)((dp->ip6d_len + 1) << 3);
TCHECK2(dp, dstoptlen);
TCHECK2(*dp, dstoptlen);
printf("DSTOPT ");
if (vflag) {
ip6_opt_print((const u_char *)dp + sizeof(*dp),

View File

@ -21,7 +21,7 @@
#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 $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.13 2000/12/12 09:58:41 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -34,25 +34,10 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#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 */
@ -79,14 +64,14 @@ ipcomp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
ipcomp = (struct ipcomp *)bp;
cpi = (u_int16_t)ntohs(ipcomp->comp_cpi);
/* 'ep' points to the end of avaible data. */
/* 'ep' points to the end of available data. */
ep = snapend;
if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
fputs("[|IPCOMP]", stdout);
goto fail;
}
printf("IPComp(cpi=%u)", cpi);
printf("IPComp(cpi=0x%04x)", cpi);
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
if (1)

View File

@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.22 1999/11/21 09:36:54 fenner Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.27 2000/09/29 04:58:41 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -36,16 +36,8 @@ static const char rcsid[] =
#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>
#ifdef __STDC__
#include <stdlib.h>
#endif
#include <stdio.h>
#include <string.h>
@ -92,7 +84,7 @@ ipxaddr_string(u_int32_t net, const u_char *node)
{
static char line[256];
sprintf(line, "%x.%02x:%02x:%02x:%02x:%02x:%02x",
snprintf(line, sizeof(line), "%x.%02x:%02x:%02x:%02x:%02x:%02x",
net, node[0], node[1], node[2], node[3], node[4], node[5]);
return line;

View File

@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.8.2.1 2000/01/14 19:19:56 mcr Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.26 2000/12/12 09:20:26 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -43,24 +43,10 @@ static const char rcsid[] =
#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>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#ifdef INET6
#include <netinet/ip6.h>
#endif
#include <stdio.h>
#include <netdb.h>
@ -72,35 +58,47 @@ struct rtentry;
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#include "ip.h"
#ifdef INET6
#include "ip6.h"
#endif
#ifndef HAVE_SOCKADDR_STORAGE
#define sockaddr_storage sockaddr
#endif
static u_char *isakmp_sa_print __P((struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t));
static u_char *isakmp_p_print __P((struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t));
static u_char *isakmp_t_print __P((struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t));
static u_char *isakmp_ke_print __P((struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t));
static u_char *isakmp_id_print __P((struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t));
static u_char *isakmp_hash_print __P((struct isakmp_gen *, u_char *,
u_int32_t, u_int32_t, u_int32_t));
static u_char *isakmp_nonce_print __P((struct isakmp_gen *, u_char *,
u_int32_t, u_int32_t, u_int32_t));
static u_char *isakmp_n_print __P((struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t));
static u_char *isakmp_d_print __P((struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t));
static u_char *isakmp_vid_print __P((struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t));
static u_char *isakmp_sub0_print __P((u_char, struct isakmp_gen *, u_char *,
u_int32_t, u_int32_t, u_int32_t));
static u_char *isakmp_sub_print __P((u_char, struct isakmp_gen *, u_char *,
u_int32_t, u_int32_t, u_int32_t));
static char *numstr __P((int));
static u_char *isakmp_sa_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_p_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_t_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_ke_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_id_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_cert_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_cr_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_sig_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_hash_print(struct isakmp_gen *, u_char *,
u_int32_t, u_int32_t, u_int32_t);
static u_char *isakmp_nonce_print(struct isakmp_gen *, u_char *,
u_int32_t, u_int32_t, u_int32_t);
static u_char *isakmp_n_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_d_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_vid_print(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t);
static u_char *isakmp_sub0_print(u_char, struct isakmp_gen *, u_char *,
u_int32_t, u_int32_t, u_int32_t);
static u_char *isakmp_sub_print(u_char, struct isakmp_gen *, u_char *,
u_int32_t, u_int32_t, u_int32_t);
static char *numstr(int);
static void safememcpy(void *, void *, size_t);
#define MAXINITIATORS 20
int ninitiator = 0;
@ -122,18 +120,18 @@ static char *npstr[] = {
};
/* isakmp->np */
static u_char *(*npfunc[]) __P((struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t)) = {
static u_char *(*npfunc[])(struct isakmp_gen *, u_char *, u_int32_t,
u_int32_t, u_int32_t) = {
NULL,
isakmp_sa_print,
isakmp_p_print,
isakmp_t_print,
isakmp_ke_print,
isakmp_id_print,
NULL,
NULL,
isakmp_cert_print,
isakmp_cr_print,
isakmp_hash_print,
NULL,
isakmp_sig_print,
isakmp_nonce_print,
isakmp_n_print,
isakmp_d_print,
@ -202,7 +200,7 @@ cookie_record(cookie_t *in, const u_char *bp2)
}
ip = (struct ip *)bp2;
switch (ip->ip_v) {
switch (IP_V(ip)) {
case 4:
memset(&cookiecache[ninitiator].iaddr, 0,
sizeof(cookiecache[ninitiator].iaddr));
@ -268,7 +266,7 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
memset(&ss, 0, sizeof(ss));
ip = (struct ip *)bp2;
switch (ip->ip_v) {
switch (IP_V(ip)) {
case 4:
sin = (struct sockaddr_in *)&ss;
#ifdef HAVE_SOCKADDR_SA_LEN
@ -351,11 +349,11 @@ struct attrmap {
static u_char *
isakmp_attrmap_print(u_char *p, u_char *ep, struct attrmap *map, size_t nmap)
{
u_short *q;
u_int16_t *q;
int totlen;
u_int32_t t, v;
q = (u_short *)p;
q = (u_int16_t *)p;
if (p[0] & 0x80)
totlen = 4;
else
@ -389,11 +387,11 @@ isakmp_attrmap_print(u_char *p, u_char *ep, struct attrmap *map, size_t nmap)
static u_char *
isakmp_attr_print(u_char *p, u_char *ep)
{
u_short *q;
u_int16_t *q;
int totlen;
u_int32_t t;
q = (u_short *)p;
q = (u_int16_t *)p;
if (p[0] & 0x80)
totlen = 4;
else
@ -422,43 +420,47 @@ static u_char *
isakmp_sa_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
struct isakmp_pl_sa *p;
struct isakmp_pl_sa *p, sa;
u_int32_t *q;
u_int32_t doi;
u_int32_t sit;
u_char *cp;
u_int32_t doi, sit, ident;
u_char *cp, *np;
int t;
printf("%s:", NPSTR(ISAKMP_NPTYPE_SA));
p = (struct isakmp_pl_sa *)ext;
doi = ntohl(p->doi);
safememcpy(&sa, ext, sizeof(sa));
doi = ntohl(sa.doi);
sit = ntohl(sa.sit);
if (doi != 1) {
printf(" doi=%d", doi);
printf(" situation=%u", (u_int32_t)ntohl(p->sit));
printf(" situation=%u", (u_int32_t)ntohl(sa.sit));
return (u_char *)(p + 1);
}
printf(" doi=ipsec");
q = (u_int32_t *)&p->sit;
q = (u_int32_t *)&sa.sit;
printf(" situation=");
t = 0;
if (ntohl(*q) & 0x01) {
if (sit & 0x01) {
printf("identity");
t++;
}
if (ntohl(*q) & 0x02) {
if (sit & 0x02) {
printf("%ssecrecy", t ? "+" : "");
t++;
}
if (ntohl(*q) & 0x04)
if (sit & 0x04)
printf("%sintegrity", t ? "+" : "");
sit = htonl(*q++);
if (sit != 0x01)
printf(" ident=%u", (u_int32_t)ntohl(*q++));
np = (u_char *)ext + sizeof(sa);
if (sit != 0x01) {
safememcpy(&ident, ext + 1, sizeof(ident));
printf(" ident=%u", (u_int32_t)ntohl(ident));
np += sizeof(ident);
}
ext = (struct isakmp_gen *)q;
ext = (struct isakmp_gen *)np;
cp = isakmp_sub_print(ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0);
@ -469,23 +471,24 @@ static u_char *
isakmp_p_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
struct isakmp_pl_p *p;
struct isakmp_pl_p *p, prop;
u_char *cp;
printf("%s:", NPSTR(ISAKMP_NPTYPE_P));
p = (struct isakmp_pl_p *)ext;
safememcpy(&prop, ext, sizeof(prop));
printf(" #%d protoid=%s transform=%d",
p->p_no, PROTOIDSTR(p->prot_id), p->num_t);
if (p->spi_size) {
prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t);
if (prop.spi_size) {
printf(" spi=");
rawprint((caddr_t)(p + 1), p->spi_size);
rawprint((caddr_t)(p + 1), prop.spi_size);
}
ext = (struct isakmp_gen *)((u_char *)(p + 1) + p->spi_size);
ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
cp = isakmp_sub_print(ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
p->prot_id);
prop.prot_id);
return cp;
}
@ -495,12 +498,13 @@ static char *isakmp_p_map[] = {
};
static char *ah_p_map[] = {
NULL, "md5", "sha", "1des",
NULL, "(reserved)", "md5", "sha", "1des",
"sha2-256", "sha2-384", "sha2-512",
};
static char *esp_p_map[] = {
NULL, "1des-iv64", "1des", "3des", "rc5", "idea", "cast",
"blowfish", "3idea", "1des-iv32", "rc4", "null"
"blowfish", "3idea", "1des-iv32", "rc4", "null", "aes"
};
static char *ipcomp_p_map[] = {
@ -523,9 +527,10 @@ struct attrmap ipsec_t_map[] = {
struct attrmap oakley_t_map[] = {
{ NULL, 0 },
{ "enc", 7, { NULL, "1des", "idea", "blowfish", "rc5",
"3des", "cast"}, },
{ "hash", 4, { NULL, "md5", "sha1", "tiger", }, },
{ "enc", 8, { NULL, "1des", "idea", "blowfish", "rc5",
"3des", "cast", "aes", }, },
{ "hash", 7, { NULL, "md5", "sha1", "tiger",
"sha2-256", "sha2-384", "sha2-512", }, },
{ "auth", 6, { NULL, "preshared", "dss", "rsa sig", "rsa enc",
"rsa enc revised", }, },
{ "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155",
@ -548,7 +553,7 @@ static u_char *
isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
struct isakmp_pl_t *p;
struct isakmp_pl_t *p, t;
u_char *cp;
char *idstr;
struct attrmap *map;
@ -558,25 +563,26 @@ isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf("%s:", NPSTR(ISAKMP_NPTYPE_T));
p = (struct isakmp_pl_t *)ext;
safememcpy(&t, ext, sizeof(t));
switch (proto) {
case 1:
idstr = STR_OR_ID(p->t_id, isakmp_p_map);
idstr = STR_OR_ID(t.t_id, isakmp_p_map);
map = oakley_t_map;
nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]);
break;
case 2:
idstr = STR_OR_ID(p->t_id, ah_p_map);
idstr = STR_OR_ID(t.t_id, ah_p_map);
map = ipsec_t_map;
nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
break;
case 3:
idstr = STR_OR_ID(p->t_id, esp_p_map);
idstr = STR_OR_ID(t.t_id, esp_p_map);
map = ipsec_t_map;
nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
break;
case 4:
idstr = STR_OR_ID(p->t_id, ipcomp_p_map);
idstr = STR_OR_ID(t.t_id, ipcomp_p_map);
map = ipsec_t_map;
nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]);
break;
@ -588,11 +594,11 @@ isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
}
if (idstr)
printf(" #%d id=%s ", p->t_no, idstr);
printf(" #%d id=%s ", t.t_no, idstr);
else
printf(" #%d id=%d ", p->t_no, p->t_id);
printf(" #%d id=%d ", t.t_no, t.t_id);
cp = (u_char *)(p + 1);
ep2 = (u_char *)p + ntohs(ext->len);
ep2 = (u_char *)p + ntohs(t.h.len);
while (cp < ep && cp < ep2) {
if (map && nmap) {
cp = isakmp_attrmap_print(cp, (ep < ep2) ? ep : ep2,
@ -609,14 +615,17 @@ static u_char *
isakmp_ke_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
struct isakmp_gen e;
printf("%s:", NPSTR(ISAKMP_NPTYPE_KE));
printf(" key len=%d", ntohs(ext->len) - 4);
if (2 < vflag && 4 < ntohs(ext->len)) {
safememcpy(&e, ext, sizeof(e));
printf(" key len=%d", ntohs(e.len) - 4);
if (2 < vflag && 4 < ntohs(e.len)) {
printf(" ");
rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
}
return (u_char *)ext + ntohs(ext->len);
return (u_char *)ext + ntohs(e.len);
}
static u_char *
@ -624,7 +633,7 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
#define USE_IPSECDOI_IN_PHASE1 1
struct isakmp_pl_id *p;
struct isakmp_pl_id *p, id;
static char *idtypestr[] = {
"IPv4", "IPv4net", "IPv6", "IPv6net",
};
@ -639,11 +648,12 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf("%s:", NPSTR(ISAKMP_NPTYPE_ID));
p = (struct isakmp_pl_id *)ext;
if (sizeof(*p) < ext->len)
safememcpy(&id, ext, sizeof(id));
if (sizeof(*p) < id.h.len)
data = (u_char *)(p + 1);
else
data = NULL;
len = ntohs(ext->len) - sizeof(*p);
len = ntohs(id.h.len) - sizeof(*p);
#if 0 /*debug*/
printf(" [phase=%d doi=%d proto=%d]", phase, doi, proto);
@ -653,9 +663,9 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
case 1:
#endif
default:
printf(" idtype=%s", STR_OR_ID(p->d.id_type, idtypestr));
printf(" idtype=%s", STR_OR_ID(id.d.id_type, idtypestr));
printf(" doi_data=%u",
(u_int32_t)(ntohl(p->d.doi_data) & 0xffffff));
(u_int32_t)(ntohl(id.d.doi_data) & 0xffffff));
break;
#ifdef USE_IPSECDOI_IN_PHASE1
@ -663,22 +673,26 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
#endif
case 2:
{
struct ipsecdoi_id *p;
struct ipsecdoi_id *p, id;
struct protoent *pe;
p = (struct ipsecdoi_id *)ext;
printf(" idtype=%s", STR_OR_ID(p->type, ipsecidtypestr));
setprotoent(1);
pe = getprotobynumber(p->proto_id);
if (pe)
printf(" protoid=%s", pe->p_name);
else
printf(" protoid=%s", PROTOIDSTR(p->proto_id));
endprotoent();
printf(" port=%d", ntohs(p->port));
safememcpy(&id, ext, sizeof(id));
printf(" idtype=%s", STR_OR_ID(id.type, ipsecidtypestr));
if (id.proto_id) {
setprotoent(1);
pe = getprotobynumber(id.proto_id);
if (pe)
printf(" protoid=%s", pe->p_name);
endprotoent();
} else {
/* it DOES NOT mean IPPROTO_IP! */
printf(" protoid=%s", "0");
}
printf(" port=%d", ntohs(id.port));
if (!len)
break;
switch (p->type) {
switch (id.type) {
case IPSECDOI_ID_IPV4_ADDR:
printf(" len=%d %s", len, ipaddr_string(data));
len = 0;
@ -752,42 +766,113 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
rawprint((caddr_t)data, len);
}
}
return (u_char *)ext + ntohs(ext->len);
return (u_char *)ext + ntohs(id.h.len);
}
static u_char *
isakmp_cert_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
struct isakmp_pl_cert *p, cert;
static char *certstr[] = {
"none", "pkcs7", "pgp", "dns",
"x509sign", "x509ke", "kerberos", "crl",
"arl", "spki", "x509attr",
};
printf("%s:", NPSTR(ISAKMP_NPTYPE_CERT));
p = (struct isakmp_pl_cert *)ext;
safememcpy(&cert, ext, sizeof(cert));
printf(" len=%d", ntohs(cert.h.len) - 4);
printf(" type=%s", STR_OR_ID((cert.encode), certstr));
if (2 < vflag && 4 < ntohs(cert.h.len)) {
printf(" ");
rawprint((caddr_t)(ext + 1), ntohs(cert.h.len) - 4);
}
return (u_char *)ext + ntohs(cert.h.len);
}
static u_char *
isakmp_cr_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
struct isakmp_pl_cert *p, cert;
static char *certstr[] = {
"none", "pkcs7", "pgp", "dns",
"x509sign", "x509ke", "kerberos", "crl",
"arl", "spki", "x509attr",
};
printf("%s:", NPSTR(ISAKMP_NPTYPE_CR));
p = (struct isakmp_pl_cert *)ext;
safememcpy(&cert, ext, sizeof(cert));
printf(" len=%d", ntohs(cert.h.len) - 4);
printf(" type=%s", STR_OR_ID((cert.encode), certstr));
if (2 < vflag && 4 < ntohs(cert.h.len)) {
printf(" ");
rawprint((caddr_t)(ext + 1), ntohs(cert.h.len) - 4);
}
return (u_char *)ext + ntohs(cert.h.len);
}
static u_char *
isakmp_hash_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
struct isakmp_gen e;
printf("%s:", NPSTR(ISAKMP_NPTYPE_HASH));
printf(" len=%d", ntohs(ext->len) - 4);
if (2 < vflag && 4 < ntohs(ext->len)) {
safememcpy(&e, ext, sizeof(e));
printf(" len=%d", ntohs(e.len) - 4);
if (2 < vflag && 4 < ntohs(e.len)) {
printf(" ");
rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
}
return (u_char *)ext + ntohs(ext->len);
return (u_char *)ext + ntohs(e.len);
}
static u_char *
isakmp_sig_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
struct isakmp_gen e;
printf("%s:", NPSTR(ISAKMP_NPTYPE_SIG));
safememcpy(&e, ext, sizeof(e));
printf(" len=%d", ntohs(e.len) - 4);
if (2 < vflag && 4 < ntohs(e.len)) {
printf(" ");
rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
}
return (u_char *)ext + ntohs(e.len);
}
static u_char *
isakmp_nonce_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
struct isakmp_gen e;
printf("%s:", NPSTR(ISAKMP_NPTYPE_NONCE));
printf(" n len=%d", ntohs(ext->len) - 4);
if (2 < vflag && 4 < ntohs(ext->len)) {
safememcpy(&e, ext, sizeof(e));
printf(" n len=%d", ntohs(e.len) - 4);
if (2 < vflag && 4 < ntohs(e.len)) {
printf(" ");
rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
}
return (u_char *)ext + ntohs(ext->len);
return (u_char *)ext + ntohs(e.len);
}
static u_char *
isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
struct isakmp_pl_n *p;
struct isakmp_pl_n *p, n;
u_char *cp;
u_char *ep2;
u_int32_t doi;
@ -823,42 +908,43 @@ isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf("%s:", NPSTR(ISAKMP_NPTYPE_N));
p = (struct isakmp_pl_n *)ext;
doi = ntohl(p->doi);
proto = p->prot_id;
safememcpy(&n, ext, sizeof(n));
doi = ntohl(n.doi);
proto = n.prot_id;
if (doi != 1) {
printf(" doi=%d", doi);
printf(" proto=%d", proto);
printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
if (p->spi_size) {
printf(" type=%s", NOTIFYSTR(ntohs(n.type)));
if (n.spi_size) {
printf(" spi=");
rawprint((caddr_t)(p + 1), p->spi_size);
rawprint((caddr_t)(p + 1), n.spi_size);
}
return (u_char *)(p + 1) + p->spi_size;
return (u_char *)(p + 1) + n.spi_size;
}
printf(" doi=ipsec");
printf(" proto=%s", PROTOIDSTR(proto));
if (ntohs(p->type) < 8192)
printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
else if (ntohs(p->type) < 16384)
printf(" type=%s", IPSECNOTIFYSTR(ntohs(p->type)));
else if (ntohs(p->type) < 24576)
printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
else if (ntohs(p->type) < 40960)
printf(" type=%s", IPSECNOTIFYSTR(ntohs(p->type)));
if (ntohs(n.type) < 8192)
printf(" type=%s", NOTIFYSTR(ntohs(n.type)));
else if (ntohs(n.type) < 16384)
printf(" type=%s", IPSECNOTIFYSTR(ntohs(n.type)));
else if (ntohs(n.type) < 24576)
printf(" type=%s", NOTIFYSTR(ntohs(n.type)));
else if (ntohs(n.type) < 40960)
printf(" type=%s", IPSECNOTIFYSTR(ntohs(n.type)));
else
printf(" type=%s", NOTIFYSTR(ntohs(p->type)));
if (p->spi_size) {
printf(" type=%s", NOTIFYSTR(ntohs(n.type)));
if (n.spi_size) {
printf(" spi=");
rawprint((caddr_t)(p + 1), p->spi_size);
rawprint((caddr_t)(p + 1), n.spi_size);
}
cp = (u_char *)(p + 1) + p->spi_size;
ep2 = (u_char *)p + ntohs(ext->len);
cp = (u_char *)(p + 1) + n.spi_size;
ep2 = (u_char *)p + ntohs(n.h.len);
if (cp < ep) {
printf(" orig=(");
switch (ntohs(p->type)) {
switch (ntohs(n.type)) {
case IPSECDOI_NTYPE_RESPONDER_LIFETIME:
{
struct attrmap *map = oakley_t_map;
@ -880,19 +966,19 @@ isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
default:
/* NULL is dummy */
isakmp_print(cp,
ntohs(ext->len) - sizeof(*p) - p->spi_size,
ntohs(n.h.len) - sizeof(*p) - n.spi_size,
NULL);
}
printf(")");
}
return (u_char *)ext + ntohs(ext->len);
return (u_char *)ext + ntohs(n.h.len);
}
static u_char *
isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi0, u_int32_t proto0)
{
struct isakmp_pl_d *p;
struct isakmp_pl_d *p, d;
u_int8_t *q;
u_int32_t doi;
u_int32_t proto;
@ -901,8 +987,9 @@ isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf("%s:", NPSTR(ISAKMP_NPTYPE_D));
p = (struct isakmp_pl_d *)ext;
doi = ntohl(p->doi);
proto = p->prot_id;
safememcpy(&d, ext, sizeof(d));
doi = ntohl(d.doi);
proto = d.prot_id;
if (doi != 1) {
printf(" doi=%u", doi);
printf(" proto=%u", proto);
@ -910,15 +997,15 @@ isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
printf(" doi=ipsec");
printf(" proto=%s", PROTOIDSTR(proto));
}
printf(" spilen=%u", p->spi_size);
printf(" nspi=%u", ntohs(p->num_spi));
printf(" spilen=%u", d.spi_size);
printf(" nspi=%u", ntohs(d.num_spi));
printf(" spi=");
q = (u_int8_t *)(p + 1);
for (i = 0; i < ntohs(p->num_spi); i++) {
for (i = 0; i < ntohs(d.num_spi); i++) {
if (i != 0)
printf(",");
rawprint((caddr_t)q, p->spi_size);
q += p->spi_size;
rawprint((caddr_t)q, d.spi_size);
q += d.spi_size;
}
return q;
}
@ -927,14 +1014,17 @@ static u_char *
isakmp_vid_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
u_int32_t doi, u_int32_t proto)
{
struct isakmp_gen e;
printf("%s:", NPSTR(ISAKMP_NPTYPE_VID));
printf(" len=%d", ntohs(ext->len) - 4);
if (2 < vflag && 4 < ntohs(ext->len)) {
safememcpy(&e, ext, sizeof(e));
printf(" len=%d", ntohs(e.len) - 4);
if (2 < vflag && 4 < ntohs(e.len)) {
printf(" ");
rawprint((caddr_t)(ext + 1), ntohs(ext->len) - 4);
rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4);
}
return (u_char *)ext + ntohs(ext->len);
return (u_char *)ext + ntohs(e.len);
}
static u_char *
@ -942,14 +1032,16 @@ isakmp_sub0_print(u_char np, struct isakmp_gen *ext, u_char *ep,
u_int32_t phase, u_int32_t doi, u_int32_t proto)
{
u_char *cp;
struct isakmp_gen e;
cp = (u_char *)ext;
safememcpy(&e, ext, sizeof(e));
if (NPFUNC(np))
cp = (*NPFUNC(np))(ext, ep, phase, doi, proto);
else {
printf("%s", NPSTR(np));
cp += ntohs(ext->len);
cp += ntohs(e.len);
}
return cp;
}
@ -961,11 +1053,14 @@ isakmp_sub_print(u_char np, struct isakmp_gen *ext, u_char *ep,
u_char *cp;
static int depth = 0;
int i;
struct isakmp_gen e;
cp = (u_char *)ext;
while (np) {
if (ep < (u_char *)ext + ntohs(ext->len)) {
safememcpy(&e, ext, sizeof(e));
if (ep < (u_char *)ext + ntohs(e.len)) {
printf(" [|%s]", NPSTR(np));
cp = ep + 1;
break;
@ -979,7 +1074,7 @@ isakmp_sub_print(u_char np, struct isakmp_gen *ext, u_char *ep,
printf(")");
depth--;
np = ext->np;
np = e.np;
ext = (struct isakmp_gen *)cp;
}
return cp;
@ -989,63 +1084,76 @@ static char *
numstr(int x)
{
static char buf[20];
sprintf(buf, "#%d", x);
snprintf(buf, sizeof(buf), "#%d", x);
return buf;
}
/*
* some compiler tries to optimize memcpy(), using the alignment constraint
* on the argument pointer type. by using this function, we try to avoid the
* optimization.
*/
static void
safememcpy(void *p, void *q, size_t l)
{
memcpy(p, q, l);
}
void
isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
{
struct isakmp *base;
struct isakmp *p, base;
u_char *ep;
u_char np;
int i;
int phase;
int major, minor;
base = (struct isakmp *)bp;
p = (struct isakmp *)bp;
ep = (u_char *)snapend;
if ((struct isakmp *)ep < base + 1) {
if ((struct isakmp *)ep < p + 1) {
printf("[|isakmp]");
return;
}
safememcpy(&base, p, sizeof(base));
printf("isakmp");
if (vflag) {
major = (base->vers & ISAKMP_VERS_MAJOR)
major = (base.vers & ISAKMP_VERS_MAJOR)
>> ISAKMP_VERS_MAJOR_SHIFT;
minor = (base->vers & ISAKMP_VERS_MINOR)
minor = (base.vers & ISAKMP_VERS_MINOR)
>> ISAKMP_VERS_MINOR_SHIFT;
printf(" %d.%d", major, minor);
}
if (vflag) {
printf(" msgid ");
rawprint((caddr_t)&base->msgid, sizeof(base->msgid));
rawprint((caddr_t)&base.msgid, sizeof(base.msgid));
}
if (1 < vflag) {
printf(" cookie ");
rawprint((caddr_t)&base->i_ck, sizeof(base->i_ck));
rawprint((caddr_t)&base.i_ck, sizeof(base.i_ck));
printf("->");
rawprint((caddr_t)&base->r_ck, sizeof(base->r_ck));
rawprint((caddr_t)&base.r_ck, sizeof(base.r_ck));
}
printf(":");
phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2;
phase = (*(u_int32_t *)base.msgid == 0) ? 1 : 2;
if (phase == 1)
printf(" phase %d", phase);
else
printf(" phase %d/others", phase);
i = cookie_find(&base->i_ck);
i = cookie_find(&base.i_ck);
if (i < 0) {
if (iszero((u_char *)&base->r_ck, sizeof(base->r_ck))) {
if (iszero((u_char *)&base.r_ck, sizeof(base.r_ck))) {
/* the first packet */
printf(" I");
if (bp2)
cookie_record(&base->i_ck, bp2);
cookie_record(&base.i_ck, bp2);
} else
printf(" ?");
} else {
@ -1057,10 +1165,10 @@ isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
printf(" ?");
}
printf(" %s", ETYPESTR(base->etype));
if (base->flags) {
printf("[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "",
base->flags & ISAKMP_FLAG_C ? "C" : "");
printf(" %s", ETYPESTR(base.etype));
if (base.flags) {
printf("[%s%s]", base.flags & ISAKMP_FLAG_E ? "E" : "",
base.flags & ISAKMP_FLAG_C ? "C" : "");
}
printf(":");
@ -1075,28 +1183,28 @@ isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
}
/* regardless of phase... */
if (base->flags & ISAKMP_FLAG_E) {
if (base.flags & ISAKMP_FLAG_E) {
/*
* encrypted, nothing we can do right now.
* we hope to decrypt the packet in the future...
*/
printf(" [|%s]", NPSTR(base->np));
printf(" [|%s]", NPSTR(base.np));
goto done;
}
nparen = 0;
CHECKLEN(base + 1, base->np)
CHECKLEN(p + 1, base.np)
np = base->np;
ext = (struct isakmp_gen *)(base + 1);
np = base.np;
ext = (struct isakmp_gen *)(p + 1);
isakmp_sub_print(np, ext, ep, phase, 0, 0);
}
done:
if (vflag) {
if (ntohl(base->len) != length) {
if (ntohl(base.len) != length) {
printf(" (len mismatch: isakmp %u/ip %d)",
(u_int32_t)ntohl(base->len), length);
(u_int32_t)ntohl(base.len), length);
}
}
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.16 1999/11/21 09:36:55 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.22 2000/10/11 04:04:33 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -34,33 +34,150 @@ static const char rcsid[] =
#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>
#include <stdio.h>
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "ether.h"
#include "extract.h"
#define CLNS 129
#define ESIS 130
#define ISIS 131
#define NULLNS 0
#define NLPID_CLNS 129 /* 0x81 */
#define NLPID_ESIS 130 /* 0x82 */
#define NLPID_ISIS 131 /* 0x83 */
#define NLPID_NULLNS 0
static int osi_cksum(const u_char *, u_int, const u_char *, u_char *, u_char *);
/*
* IS-IS is defined in ISO 10589. Look there for protocol definitions.
*/
#define SYSTEM_ID_LEN ETHER_ADDR_LEN
#define ISIS_VERSION 1
#define PDU_TYPE_MASK 0x1F
#define PRIORITY_MASK 0x7F
#define L1_LAN_IIH 15
#define L2_LAN_IIH 16
#define PTP_IIH 17
#define L1_LS_PDU 18
#define L2_LS_PDU 19
#define L1_COMPLETE_SEQ_PDU 24
#define L2_COMPLETE_SEQ_PDU 25
/*
* A TLV is a tuple of a type, length and a value and is normally used for
* encoding information in all sorts of places. This is an enumeration of
* the well known types.
*/
#define TLV_AREA_ADDR 1
#define TLV_IS_REACH 2
#define TLV_ES_REACH 3
#define TLV_SUMMARY 5
#define TLV_ISNEIGH 6
#define TLV_PADDING 8
#define TLV_LSP 9
#define TLV_AUTHENT 10
#define TLV_IP_REACH 128
#define TLV_PROTOCOLS 129
#define TLV_IP_EXTERN 130
#define TLV_IDRP_INFO 131
#define TLV_IPADDR 132
#define TLV_IPAUTH 133
#define TLV_PTP_ADJ 240
/*
* Katz's point to point adjacency TLV uses codes to tell us the state of
* the remote adjacency. Enumerate them.
*/
#define ISIS_PTP_ADJ_UP 0
#define ISIS_PTP_ADJ_INIT 1
#define ISIS_PTP_ADJ_DOWN 2
static int osi_cksum(const u_char *, int, u_char *);
static void esis_print(const u_char *, u_int);
static int isis_print(const u_char *, u_int);
struct isis_ptp_adjancey_values {
u_char id;
char *name;
};
static struct isis_ptp_adjancey_values isis_ptp_adjancey_values[] = {
{ ISIS_PTP_ADJ_UP, "UP" },
{ ISIS_PTP_ADJ_INIT, "INIT" },
{ ISIS_PTP_ADJ_DOWN, "DOWN" }
};
struct isis_common_header {
u_char nlpid;
u_char fixed_len;
u_char version; /* Protocol version? */
u_char id_length;
u_char enc_pdu_type; /* 3 MSbs are reserved */
u_char pkt_version; /* Packet format version? */
u_char reserved;
u_char enc_max_area;
};
struct isis_header {
u_char nlpid;
u_char fixed_len;
u_char version; /* Protocol version? */
u_char id_length;
u_char enc_pdu_type; /* 3 MSbs are reserved */
u_char pkt_version; /* Packet format version? */
u_char reserved;
u_char enc_max_area;
u_char circuit;
u_char enc_source_id[SYSTEM_ID_LEN];
u_char enc_holding_time[2];
u_char enc_packet_len[2];
u_char enc_priority;
u_char enc_lan_id[SYSTEM_ID_LEN+1];
};
struct isis_lan_header {
u_char circuit;
u_char enc_source_id[SYSTEM_ID_LEN];
u_char enc_holding_time[2];
u_char enc_packet_len[2];
u_char enc_priority;
u_char enc_lan_id[SYSTEM_ID_LEN+1];
};
struct isis_ptp_header {
u_char circuit;
u_char enc_source_id[SYSTEM_ID_LEN];
u_char enc_holding_time[2];
u_char enc_packet_len[2];
u_char loc_circuit_id;
};
#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
#define ISIS_HEADER_SIZE (15+(SYSTEM_ID_LEN<<1))
#define ISIS_PTP_HEADER_SIZE (14+SYSTEM_ID_LEN)
#define L1_LS_PDU_HEADER_SIZE (21+SYSTEM_ID_LEN)
#define L2_LS_PDU_HEADER_SIZE L1_LS_PDU_HEADER_SIZE
#define L1_COMPLETE_SEQ_PDU_HEADER_SIZE 33
#define L2_COMPLETE_SEQ_PDU_HEADER_SIZE L1_COMPLETE_SEQ_PDU_HEADER_SIZE
void
isoclns_print(const u_char *p, u_int length, u_int caplen,
const u_char *esrc, const u_char *edst)
{
u_char pdu_type;
struct isis_header *header;
header = (struct isis_header *)p;
pdu_type = header->enc_pdu_type & PDU_TYPE_MASK;
if (caplen < 1) {
printf("[|iso-clns] ");
if (!eflag)
@ -72,17 +189,16 @@ isoclns_print(const u_char *p, u_int length, u_int caplen,
switch (*p) {
case CLNS:
/* esis_print(&p, &length); */
printf("iso-clns");
case NLPID_CLNS:
printf("iso clns");
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
etheraddr_string(edst));
break;
case ESIS:
printf("iso-esis");
case NLPID_ESIS:
printf("iso esis");
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
@ -90,20 +206,21 @@ isoclns_print(const u_char *p, u_int length, u_int caplen,
esis_print(p, length);
return;
case ISIS:
printf("iso-isis");
if (!eflag)
(void)printf(" %s > %s",
case NLPID_ISIS:
printf("iso isis");
if (!eflag) {
if(pdu_type != PTP_IIH)
(void)printf(" %s > %s",
etheraddr_string(esrc),
etheraddr_string(edst));
/* isis_print(&p, &length); */
}
(void)printf(" len=%d ", length);
if (caplen > 1)
default_print_unaligned(p, caplen);
if (!isis_print(p, length))
default_print_unaligned(p, caplen);
break;
case NULLNS:
printf("iso-nullns");
case NLPID_NULLNS:
printf("iso nullns");
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
@ -111,7 +228,7 @@ isoclns_print(const u_char *p, u_int length, u_int caplen,
break;
default:
printf("iso-clns %02x", p[0]);
printf("iso clns %02x", p[0]);
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
@ -141,7 +258,6 @@ esis_print(const u_char *p, u_int length)
const u_char *ep;
int li = p[1];
const struct esis_hdr *eh = (const struct esis_hdr *) &p[2];
u_char cksum[2];
u_char off[2];
if (length == 2) {
@ -189,9 +305,10 @@ esis_print(const u_char *p, u_int length)
}
off[0] = eh->cksum[0];
off[1] = eh->cksum[1];
if (vflag && osi_cksum(p, li, eh->cksum, cksum, off)) {
printf(" bad cksum (got %02x%02x want %02x%02x)",
eh->cksum[1], eh->cksum[0], cksum[1], cksum[0]);
if (vflag && osi_cksum(p, li, off)) {
printf(" bad cksum (got %02x%02x)",
eh->cksum[1], eh->cksum[0]);
default_print(p, length);
return;
}
if (eh->version != 1) {
@ -208,7 +325,7 @@ esis_print(const u_char *p, u_int length)
dst = p; p += *p + 1;
if (p > snapend)
return;
printf(" %s", isonsap_string(dst));
printf("\n\t\t\t %s", isonsap_string(dst));
snpa = p; p += *p + 1;
is = p; p += *p + 1;
if (p > snapend)
@ -239,7 +356,8 @@ esis_print(const u_char *p, u_int length)
}
if (p > snapend)
return;
printf(" %s", isonsap_string(is));
if (!qflag)
printf("\n\t\t\t %s", isonsap_string(is));
li = ep - p;
break;
}
@ -286,36 +404,270 @@ esis_print(const u_char *p, u_int length)
}
}
static int
osi_cksum(register const u_char *p, register u_int len,
const u_char *toff, u_char *cksum, u_char *off)
/*
* print_nsap
* Print out an NSAP.
*/
static void
print_nsap (register const u_char *cp, register int length)
{
int i;
for (i = 0; i < length; i++) {
printf("%02x", *cp++);
if (((i & 1) == 0) && (i + 1 < length)) {
printf(".");
}
}
}
/*
* isis_print
* Decode IS-IS packets. Return 0 on error.
*
* So far, this is only smart enough to print IIH's. Someday...
*/
static int
isis_print (const u_char *p, u_int length)
{
struct isis_header *header;
struct isis_ptp_header *header_ptp;
u_char pdu_type, max_area, priority, type, len, tmp, alen;
const u_char *pptr, *tptr;
u_short packet_len, holding_time;
int i;
header = (struct isis_header *)p;
header_ptp = (struct isis_ptp_header *)header;
printf("\n\t\t\t");
/*
* Sanity checking of the header.
*/
if (header->nlpid != NLPID_ISIS) {
printf(" coding error!");
return(0);
}
if (header->version != ISIS_VERSION) {
printf(" version %d packet not supported", header->version);
return(0);
}
if ((header->id_length != SYSTEM_ID_LEN) && (header->id_length != 0)) {
printf(" system ID length of %d is not supported",
header->id_length);
return(0);
}
if ((header->fixed_len != ISIS_HEADER_SIZE) &&
(header->fixed_len != ISIS_PTP_HEADER_SIZE) &&
(header->fixed_len != L1_LS_PDU_HEADER_SIZE) &&
(header-> fixed_len != L1_COMPLETE_SEQ_PDU_HEADER_SIZE) ) {
printf(" bogus fixed header length %u",
header->fixed_len);
return(0);
}
pdu_type = header->enc_pdu_type & PDU_TYPE_MASK;
if ((pdu_type != L1_LAN_IIH) && (pdu_type != L2_LAN_IIH) &&
(pdu_type != PTP_IIH) &&
(pdu_type != L1_COMPLETE_SEQ_PDU) &&
(pdu_type != L2_COMPLETE_SEQ_PDU) ) {
printf(" PDU type (%d) not supported", pdu_type);
return(0);
}
if (header->pkt_version != ISIS_VERSION) {
printf(" version %d packet not supported", header->pkt_version);
return(0);
}
max_area = header->enc_max_area;
switch(max_area) {
case 0:
max_area = 3; /* silly shit */
break;
case 255:
printf(" bad packet -- 255 areas");
return(0);
default:
break;
}
switch (header->circuit) {
case 0:
printf(" PDU with circuit type 0");
return(0);
case 1:
if (pdu_type == L2_LAN_IIH) {
printf(" L2 IIH on an L1 only circuit");
return(0);
}
break;
case 2:
if (pdu_type == L1_LAN_IIH) {
printf(" L1 IIH on an L2 only circuit");
return(0);
}
break;
case 3:
break;
default:
printf(" unknown circuit type");
return(0);
}
holding_time = EXTRACT_16BITS(header->enc_holding_time);
packet_len = EXTRACT_16BITS(header->enc_packet_len);
if ((packet_len < ISIS_HEADER_SIZE) ||
(packet_len > length)) {
printf(" bogus packet length %d, real length %d", packet_len,
length);
return(0);
}
if(pdu_type != PTP_IIH)
priority = header->enc_priority & PRIORITY_MASK;
/*
* Now print the fixed header.
*/
switch (pdu_type) {
case L1_LAN_IIH:
printf(" L1 lan iih, ");
break;
case L2_LAN_IIH:
printf(" L2 lan iih, ");
break;
case PTP_IIH:
printf(" PTP iih, ");
break;
}
printf("circuit ");
switch (header->circuit) {
case 1:
printf("l1 only, ");
break;
case 2:
printf("l2 only, ");
break;
case 3:
printf("l1-l2, ");
break;
}
printf ("holding time %d ", holding_time);
printf ("\n\t\t\t source %s, length %d",
etheraddr_string(header->enc_source_id), packet_len);
if((pdu_type==L1_LAN_IIH)||(pdu_type==L2_LAN_IIH))
printf ("\n\t\t\t lan id %s(%d)", etheraddr_string(header->enc_lan_id),
header->enc_lan_id[SYSTEM_ID_LEN]);
/*
* Now print the TLV's.
*/
if(pdu_type==PTP_IIH) {
packet_len -= ISIS_PTP_HEADER_SIZE;
pptr = p + ISIS_PTP_HEADER_SIZE;
} else {
packet_len -= ISIS_HEADER_SIZE;
pptr = p + ISIS_HEADER_SIZE;
}
while (packet_len >= 2) {
if (pptr >= snapend) {
printf("\n\t\t\t packet exceeded snapshot");
return(1);
}
type = *pptr++;
len = *pptr++;
packet_len -= 2;
if (len > packet_len) {
break;
}
switch (type) {
case TLV_AREA_ADDR:
printf("\n\t\t\t area addresses");
tmp = len;
tptr = pptr;
alen = *tptr++;
while (tmp && alen < tmp) {
printf("\n\t\t\t ");
print_nsap(tptr, alen);
printf(" (%d)", alen);
tptr += alen;
tmp -= alen + 1;
alen = *tptr++;
}
break;
case TLV_ISNEIGH:
printf("\n\t\t\t neighbor addresses");
tmp = len;
tptr = pptr;
while (tmp >= ETHER_ADDR_LEN) {
printf("\n\t\t\t %s", etheraddr_string(tptr));
tmp -= ETHER_ADDR_LEN;
tptr += ETHER_ADDR_LEN;
}
break;
case TLV_PADDING:
printf("\n\t\t\t padding for %d bytes", len);
break;
case TLV_AUTHENT:
printf("\n\t\t\t authentication data");
default_print(pptr, len);
break;
case TLV_PTP_ADJ:
printf("\n\t\t\t PTP adjacency status %s",
isis_ptp_adjancey_values[*pptr].name);
break;
case TLV_PROTOCOLS:
printf("\n\t\t\t Supports protocols %s", (len>1)? "are":"is");
for(i=0;i<len;i++)
printf(" %02X", (u_char)*(pptr+i));
break;
case TLV_IPADDR:
printf("\n\t\t\t IP address: %s", ipaddr_string(pptr));
break;
default:
printf("\n\t\t\t unknown TLV, type %d, length %d", type, len);
break;
}
pptr += len;
packet_len -= len;
}
if (packet_len != 0) {
printf("\n\t\t\t %d straggler bytes", packet_len);
}
return(1);
}
/*
* Verify the checksum. See 8473-1, Appendix C, section C.4.
*/
static int
osi_cksum(register const u_char *p, register int len, u_char *off)
{
int x, y, f = (len - ((toff - p) + 1));
int32_t c0 = 0, c1 = 0;
if ((cksum[0] = off[0]) == 0 && (cksum[1] = off[1]) == 0)
if ((off[0] == 0) && (off[1] == 0))
return 0;
off[0] = off[1] = 0;
while ((int)--len >= 0) {
c0 += *p++;
c1 += c0;
c0 %= 255;
c1 += c0;
c1 %= 255;
}
x = (c0 * f - c1);
if (x < 0)
x = 255 - (-x % 255);
else
x %= 255;
y = -1 * (x + c0);
if (y < 0)
y = 255 - (-y % 255);
else
y %= 255;
off[0] = x;
off[1] = y;
return (off[0] != cksum[0] || off[1] != cksum[1]);
return (c0 | c1);
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.12 1999/11/21 09:36:55 fenner Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.15 2000/09/29 04:58:42 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -35,11 +35,6 @@ static const char rcsid[] =
#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 <ctype.h>
#include <errno.h>

View File

@ -18,12 +18,12 @@
* 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)
* L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.6 1999/12/22 06:27:21 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.8 2000/08/18 07:44:46 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -303,7 +303,7 @@ l2tp_bearer_cap_print(const u_char *dat, u_int length)
static void
l2tp_tie_breaker_print(const u_char *dat, u_int length)
{
printf("%lx", *(u_long *)dat); /* XXX */
print_octets(dat, 8); /* Tie Break Value is 64bits long */
}
static void
@ -592,23 +592,30 @@ l2tp_avp_print(const u_char *dat, u_int length)
}
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);
if (ntohs(*ptr)) {
/* Vendor Specific Attribute */
printf("VENDOR%04x:", ntohs(*ptr));
ptr++;
printf("ATTR%04x", ntohs(*ptr));
printf("(");
if (!hidden) {
(l2tp_avp[ntohs(*ptr)].print)
((u_char *)ptr+2, len-6);
} else {
printf("???");
}
print_octets((u_char *)ptr+2, len-6);
printf(")");
} else {
printf(" invalid AVP %u", ntohs(*ptr));
/* IETF-defined Attribute */
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);
@ -705,12 +712,8 @@ l2tp_print(const u_char *dat, u_int length)
l2tp_avp_print((u_char *)ptr, length - cnt);
}
} else {
#if 0
printf(" {");
ppp_hdlc_print((u_char *)ptr, length - cnt);
ppp_print((u_char *)ptr, length - cnt);
printf("}");
#else
printf("[hdlc|]");
#endif
}
}

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