Import tcpdump 3.7.1, from

http://www.tcpdump.org/release/tcpdump-3.7.1.tar.gz
This commit is contained in:
Bill Fenner 2002-06-21 00:43:23 +00:00
parent 39eaefddae
commit a90e161be3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/tcpdump/dist/; revision=98524
116 changed files with 13707 additions and 5840 deletions

View File

@ -1,4 +1,62 @@
$Header: /tcpdump/master/tcpdump/CHANGES,v 1.79 2001/01/10 20:13:58 mcr Exp $
$Header: /tcpdump/master/tcpdump/CHANGES,v 1.81 2002/01/21 11:03:33 mcr Exp $
Monday, January 21, 2002. mcr@sandelman.ottawa.on.ca. Summary for 3.7 release
see http://www.tcpdump.org/cvs-log/2002-01-21.10:16:48.html for commit log.
keyword "ipx" added.
Better OSI/802.2 support on Linux.
IEEE 802.11 support, from clenahan@fortresstech.com, achirica@ttd.net.
LLC SAP support for FDDI/token ring/RFC-1483 style ATM
BXXP protocol was replaced by the BEEP protocol;
improvements to SNAP demux.
Changes to "any" interface documentation.
Documentation on pcap_stats() counters.
Fix a memory leak found by Miklos Szeredi - pcap_ether_aton().
Added MPLS encapsulation decoding per RFC3032.
DNS dissector handles TKEY, TSIG and IXFR.
adaptive SLIP interface patch from Igor Khristophorov <igor@atdot.org>
SMB printing has much improved bounds checks
OUI 0x0000f8 decoded as encapsulated ethernet for Cisco-custom bridging
Zephyr support, from Nickolai Zeldovich <kolya@MIT.EDU>.
Solaris - devices with digits in them. Stefan Hudson <hudson@mbay.net>
IPX socket 0x85be is for Cisco EIGRP over IPX.
Improvements to fragmented ESP handling.
SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
Linux ARPHDR_ATM support fixed.
Added a "netbeui" keyword, which selects NetBEUI packets.
IPv6 ND improvements, MobileIP dissector, 2292bis-02 for RA option.
Handle ARPHDR_HDLC from Marcus Felipe Pereira <marcus@task.com.br>.
Handle IPX socket 0x553 -> NetBIOS-over-IPX socket, "nwlink-dgm"
Better Linux libc5 compat.
BIND9 lwres dissector added.
MIPS and SPARC get strict alignment macros (affects print-bgp.c)
Apple LocalTalk LINKTYPE_ reserved.
New time stamp formats documented.
DHCP6 updated to draft-22.txt spec.
ICMP types/codes now accept symbolic names.
Add SIGINFO handler from LBL
encrypted CIPE tunnels in IRIX, from Franz Schaefer <schaefer@mond.at>.
now we are -Wstrict-prototype clean.
NetBSD DLT_PPP_ETHER; adapted from Martin Husemann <martin@netbsd.org>.
PPPoE dissector cleaned up.
Support for LocalTalk hardware, from Uns Lider <unslider@miranda.org>.
In dissector, now the caller prints the IP addresses rather than proto.
cjclark@alum.mit.edu: print the IP proto for non-initial fragments.
LLC frames with a DSAP and LSAP of 0xe0 are IPX frames.
Linux cooked frames with a type value of LINUX_SLL_P_802_3 are IPX.
captures on the "any" device won't be done in promiscuous mode
Token Ring support on DLPI - Onno van der Linden <onno@simplex.nl>
ARCNet support, from NetBSD.
HSRP dissector, from Julian Cowley <julian@lava.net>.
Handle (GRE-encapsulated) PPTP
added -C option to rotate save file every optarg * 1,000,000 bytes.
support for "vrrp" name - NetBSD, by Klaus Klein <kleink@netbsd.org>.
PPTP support, from Motonori Shindo <mshindo@mshindo.net>.
IS-IS over PPP support, from Hannes Gredler <hannes@juniper.net>.
CNFP support for IPv6,format. Harry Raaymakers <harryr@connect.com.au>.
ESP printing updated to RFC2406.
HP-UX can now handle large number of PPAs.
MSDP printer added.
L2TP dissector improvements from Motonori Shindo.
Tuesday January 9, 2001. mcr@sandelman.ottawa.on.ca. Summary for 3.6 release
Cleaned up documentation.
@ -595,4 +653,4 @@ v2.0 Sun Jan 13 12:20:40 PST 1991
- Initial public release.
@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.79 2001/01/10 20:13:58 mcr Exp $ (LBL)
@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.81 2002/01/21 11:03:33 mcr Exp $ (LBL)

View File

@ -15,29 +15,55 @@ Additional people who have contributed patches:
Alfredo Andres <aandres@s21sec.com>
Andrew Tridgell <tridge@linuxcare.com>
Arkadiusz Miskiewicz <misiek@pld.org.pl>
Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
Ben Smithurst <ben@scientia.demon.co.uk>
Brent L. Bates <blbates@vigyan.com>
Charlie Lenahan <clenahan@fortresstech.com>
Chris G. Demetriou <cgd@netbsd.org>
Chris Jepeway <jepeway@blasted-heath.com>
Craig Rodrigues <rodrigc@mediaone.net>
Crist J. Clark <cjclark@alum.mit.edu>
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>
Hannes Gredler <hannes@juniper.net>
Harry Raaymakers <harryr@connect.com.au>
Heinz-Ado Arnolds <Ado.Arnolds@dhm-systems.de>
Hendrik Scholz <hendrik@scholz.net>
Jakob Schlyter <jakob@openbsd.org>
Jan Oravec <wsx@wsx6.net>
Jason R. Thorpe <thorpej@zembu.com>
Jefferson Ogata <jogata@nodc.noaa.gov>
Jeffrey Hutzelman <jhutz@cmu.edu>
Jim Hutchins <jim@ca.sandia.gov>
JINMEI Tatuya <jinmei@kame.net>
Juergen Schoenwaelder <schoenw@ibr.cs.tu-bs.de>
Julian Cowley <julian@lava.net>
Kaarthik Sivakumar <kaarthik@torrentnet.com>
Kazushi Sugyo <sugyo@pb.jp.nec.com>
Kelly Carmichael <kcarmich@ipapp.com>
Ken Hornstein <kenh@cmf.nrl.navy.mil>
Kevin Steves <stevesk@sweden.hp.com>
Klaus Klein <kleink@reziprozitaet.de>
Kris Kennaway <kris@freebsd.org>
Larry Lile <lile@stdio.com>
Lennert Buytenhek <buytenh@gnu.org>
Love Hörnquist-Åstrand <lha@stacken.kth.se>
Maciej W. Rozycki <macro@ds2.pg.gda.pl>
Marko Kiiskila <carnil@cs.tut.fi>
Marshall Rose <mrose@dbc.mtview.ca.us>
Martin Husemann <martin@netbsd.org>
Michael Madore <mmadore@turbolinux.com>
Michael Shalayeff <mickey@openbsd.org>
Michael T. Stolarchuk <mts@off.to>
Monroe Williams <monroe@pobox.com>
Motonori Shindo <mshindo@mshindo.net>
Nathan J. Williams <nathanw@MIT.EDU>
Nathaniel Couper-Noles <Nathaniel@isi1.tccisi.com>
Nickolai Zeldovich <kolya@MIT.EDU>
Olaf Kirch <okir@caldera.de>
Onno van der Linden <onno@simplex.nl>
Pascal Hennequin <pascal.hennequin@int-evry.fr>
@ -48,11 +74,11 @@ Additional people who have contributed patches:
Rick Jones <raj@cup.hp.com>
Roderick Schertler <roderick@argon.org>
Sebastian Krahmer <krahmer@cs.uni-potsdam.de>
Seth Webster <swebster@sst.ll.mit.edu>
Timo Koskiahde
Tony Li <tli@jnx.com>
Uns Lider <unslider@miranda.org>
Wilbert de Graaf <wilbertdg@hetnet.nl>
Kris Kennaway <kris@freebsd.org>
Ben Smithurst <ben@scientia.demon.co.uk>
The original LBL crew:
Steve McCanne

View File

@ -12,8 +12,10 @@ addrtoname.c
addrtoname.h
ah.h
appletalk.h
arcnet.h
atime.awk
bootp.h
bpf_dump.c
chdlc.h
config.guess
config.h.in
@ -30,10 +32,13 @@ extract.h
fddi.h
gmt2local.c
gmt2local.h
icmp6.h
ieee802_11.h
igrp.h
install-sh
interface.h
ip.h
ip6.h
ipsec_doi.h
ipx.h
isakmp.h
@ -59,6 +64,7 @@ missing/resolv6.h
missing/resolv_ext.h
missing/snprintf.c
missing/sockstorage.h
missing/strdup.c
missing/strlcat.c
missing/strlcpy.c
mkdep
@ -73,14 +79,16 @@ ospf6.h
packetdat.awk
parsenfsfh.c
ppp.h
print-802_11.c
print-ah.c
print-arcnet.c
print-arp.c
print-ascii.c
print-atalk.c
print-atm.c
print-bgp.c
print-bootp.c
print-bxxp.c
print-beep.c
print-cdp.c
print-chdlc.c
print-cip.c
@ -95,6 +103,7 @@ print-ether.c
print-fddi.c
print-frag6.c
print-gre.c
print-hsrp.c
print-icmp.c
print-icmp6.c
print-igmp.c
@ -111,7 +120,10 @@ print-l2tp.c
print-lane.c
print-lcp.c
print-llc.c
print-lwres.c
print-mobile.c
print-mpls.c
print-msdp.c
print-netbios.c
print-nfs.c
print-ntp.c
@ -121,12 +133,14 @@ print-ospf6.c
print-pim.c
print-ppp.c
print-pppoe.c
print-pptp.c
print-radius.c
print-raw.c
print-rip.c
print-ripng.c
print-rt6.c
print-rx.c
print-sctp.c
print-sl.c
print-sll.c
print-smb.c
@ -142,15 +156,16 @@ print-udp.c
print-vjc.c
print-vrrp.c
print-wb.c
print-zephyr.c
route6d.h
rx.h
savestr.c
savestr.h
sctpConstants.h
sctpHeader.h
send-ack.awk
setsignal.c
setsignal.h
slip.h
slcompress.h
slip.h
sll.h
smb.h
smbutil.c
@ -159,6 +174,7 @@ strcasecmp.c
tcp.h
tcpdump.1
tcpdump.c
telnet.h
timed.h
token.h
udp.h

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.244 2000/12/21 10:43:20 guy Exp $ (LBL)
# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.260 2001/12/10 08:21:23 guy Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@ -65,22 +65,25 @@ INSTALL_DATA = @INSTALL_DATA@
@rm -f $@
$(CC) $(CFLAGS) -c $(srcdir)/$*.c
CSRC = tcpdump.c \
print-arp.c print-atalk.c print-atm.c print-bootp.c \
print-decnet.c print-domain.c print-dvmrp.c print-egp.c \
print-ether.c print-fddi.c print-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-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-cnfp.c \
print-vrrp.c print-cdp.c print-token.c print-bxxp.c print-timed.c \
print-radius.c print-sll.c
CSRC = addrtoname.c gmt2local.c machdep.c parsenfsfh.c \
print-802_11.c print-ah.c print-arcnet.c print-arp.c \
print-ascii.c print-atalk.c print-atm.c print-bgp.c \
print-bootp.c print-beep.c print-cdp.c print-chdlc.c \
print-cip.c print-cnfp.c print-decnet.c print-domain.c \
print-dvmrp.c print-egp.c print-esp.c print-ether.c \
print-fddi.c print-gre.c print-hsrp.c print-icmp.c \
print-igmp.c print-igrp.c print-ip.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-lwres.c \
print-msdp.c print-mobile.c print-mpls.c print-nfs.c \
print-ntp.c print-null.c print-ospf.c print-pim.c \
print-ppp.c print-pppoe.c print-pptp.c print-radius.c \
print-raw.c print-rip.c print-rx.c print-sctp.c \
print-sl.c print-sll.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 print-zephyr.c \
setsignal.c tcpdump.c util.c
LOCALSRC = @LOCALSRC@
GENSRC = version.c
@ -94,7 +97,7 @@ 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 \
setsignal.h \
gnuc.h ipsec_doi.h isakmp.h l2tp.h nameser.h \
netbios.h oakley.h ospf6.h ppp.h route6d.h

View File

@ -1,5 +1,6 @@
== Tested platforms ==
NetBSD 1.5/i386 (mcr - 2000/12/8)
NetBSD 1.5/i386 (mcr - 2002/1/1)
Debian Linux (woody/i386) (mcr - 2002/1/1)
---
RedHat Linux 6.1/i386 (assar)

View File

@ -1,6 +1,6 @@
@(#) $Header: /tcpdump/master/tcpdump/README,v 1.58.2.1 2001/04/11 05:27:42 guy Exp $ (LBL)
@(#) $Header: /tcpdump/master/tcpdump/README,v 1.60 2002/01/21 11:16:33 mcr Exp $ (LBL)
TCPDUMP 3.6.2
TCPDUMP 3.7.1
Now maintained by "The Tcpdump Group"
See www.tcpdump.org
@ -11,8 +11,8 @@ Anonymous CVS is available via:
(password "anoncvs")
cvs -d cvs.tcpdump.org:/tcpdump/master checkout tcpdump
Version 3.6.2 of TCPDUMP can be retrived with the CVS tag "tcpdump_3_6rel2":
cvs -d cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_6rel2 tcpdump
Version 3.7.1 of TCPDUMP can be retrived with the CVS tag "tcpdump_3_7rel1":
cvs -d cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_7rel1 tcpdump
Please send patches against the master copy to patches@tcpdump.org.

View File

@ -1 +1 @@
3.6.3
3.7.1

View File

@ -62,6 +62,9 @@
/* define if you have both getipnodebyname() and getipnodebyaddr() */
#undef USE_GETIPNODEBY
/* define if you have ether_ntohost() and it works */
#undef USE_ETHER_NTOHOST
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
@ -84,3 +87,14 @@
#undef u_int16_t
#undef u_int32_t
#undef u_int8_t
/* Whether or not to include the possibly-buggy SMB printer */
#undef TCPDUMP_DO_SMB
/* Long story short: aclocal.m4 depends on autoconf 2.13
* implementation details wrt "const"; newer versions
* have different implementation details so for now we
* put "const" here. This may cause duplicate definitions
* in config.h but that should be OK since they're the same.
*/
#undef const

View File

@ -1,4 +1,4 @@
dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.73 2001/01/02 22:18:27 guy Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.80 2001/12/10 08:41:15 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1995, 1996, 1997, 1998
dnl The Regents of the University of California. All rights reserved.
@ -57,7 +57,7 @@ AC_DEFUN(AC_LBL_C_INIT,
LBL_CFLAGS="$CFLAGS"
fi
if test -z "$CC" ; then
case "$target_os" in
case "$host_os" in
bsdi*)
AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
@ -100,7 +100,7 @@ AC_DEFUN(AC_LBL_C_INIT,
ac_cv_lbl_cc_ansi_prototypes=no))
AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes)
if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
case "$target_os" in
case "$host_os" in
hpux*)
AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
@ -129,14 +129,14 @@ AC_DEFUN(AC_LBL_C_INIT,
$2="$$2 -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
case "$target_os" in
case "$host_os" in
irix*)
V_CCOPT="$V_CCOPT -xansi -signed -g3"
V_CCOPT="$V_CCOPT -xansi -signed -O"
;;
osf*)
V_CCOPT="$V_CCOPT -std1 -g3"
V_CCOPT="$V_CCOPT -std1 -O"
;;
ultrix*)
@ -214,17 +214,19 @@ AC_DEFUN(AC_LBL_LIBPCAP,
fi
else
$1=$libpcap
places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
if test -r $d/pcap.h; then
$2="-I$d $$2"
elif test -r $srcdir/../libpcap/pcap.h; then
$2="-I$d -I$srcdir/../libpcap $$2"
elif test -r $places/pcap.h; then
$2="-I$places $$2"
else
AC_MSG_ERROR(cannot find pcap.h, see INSTALL)
fi
AC_MSG_RESULT($libpcap)
fi
LIBS="$libpcap $LIBS"
case "$target_os" in
case "$host_os" in
aix*)
pseexe="/lib/pse.exp"
@ -256,7 +258,7 @@ AC_DEFUN(AC_LBL_TYPE_SIGNAL,
else
AC_DEFINE(RETSIGVAL,(0))
fi
case "$target_os" in
case "$host_os" in
irix*)
AC_DEFINE(_BSD_SIGNALS)
@ -489,10 +491,10 @@ dnl
AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
[AC_MSG_CHECKING(if unaligned accesses fail)
AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
[case "$target_cpu" in
[case "$host_cpu" in
# XXX: should also check that they don't do weird things (like on arm)
alpha*|arm*|hp*|mips|sparc)
alpha*|arm*|hp*|mips*|sparc*|ia64)
ac_cv_lbl_unaligned_fail=yes
;;
@ -577,7 +579,7 @@ AC_DEFUN(AC_LBL_DEVEL,
fi
fi
else
case "$target_os" in
case "$host_os" in
irix6*)
V_CCOPT="$V_CCOPT -n32"
@ -587,7 +589,7 @@ AC_DEFUN(AC_LBL_DEVEL,
;;
esac
fi
os=`echo $target_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
name="lbl/os-$os.h"
if test -f $name ; then
ln -s $name os-proto.h
@ -614,10 +616,11 @@ dnl
define(AC_LBL_CHECK_LIB,
[AC_MSG_CHECKING([for $2 in -l$1])
dnl Use a cache variable name containing both the library and function name,
dnl because the test really is for library $1 defining function $2, not
dnl just for library $1. Separate tests with the same $1 and different $2's
dnl may have different results.
dnl Use a cache variable name containing the library, function
dnl name, and extra libraries to link with, because the test really is
dnl for library $1 defining function $2, when linked with potinal
dnl library $5, not just for library $1. Separate tests with the same
dnl $1 and different $2's or $5's may have different results.
ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
[ac_save_LIBS="$LIBS"
@ -693,23 +696,20 @@ dnl
AC_DEFUN(AC_LBL_LIBRARY_NET, [
# Most operating systems have gethostbyname() in the default searched
# libraries (i.e. libc):
AC_CHECK_FUNC(gethostbyname, ,
# Some OSes (eg. Solaris) place it in libnsl:
AC_LBL_CHECK_LIB(nsl, gethostbyname, ,
# Some strange OSes (SINIX) have it in libsocket:
AC_LBL_CHECK_LIB(socket, gethostbyname, ,
# Unfortunately libsocket sometimes depends on libnsl.
# AC_CHECK_LIB's API is essentially broken so the
# following ugliness is necessary:
AC_LBL_CHECK_LIB(socket, gethostbyname,
LIBS="-lsocket -lnsl $LIBS",
AC_CHECK_LIB(resolv, gethostbyname),
-lnsl))))
AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
AC_LBL_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", ,
-lnsl)))
# Some OSes (eg. Solaris) place it in libnsl
# Some strange OSes (SINIX) have it in libsocket:
AC_SEARCH_LIBS(gethostbyname, nsl socket resolv)
# Unfortunately libsocket sometimes depends on libnsl and
# AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
if test "$ac_cv_search_gethostbyname" = "no"
then
AC_CHECK_LIB(socket, gethostbyname,
LIBS="-lsocket -lnsl $LIBS", , -lnsl)
fi
AC_SEARCH_LIBS(socket, socket, ,
AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
# DLPI needs putmsg under HPUX so test for -lstr while we're at it
AC_CHECK_LIB(str, putmsg)
AC_SEARCH_LIBS(putmsg, str)
])
dnl Copyright (c) 1999 WIDE Project. All rights reserved.

View File

@ -23,7 +23,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.69.2.1 2001/01/17 18:29:58 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.83 2001/09/17 21:57:50 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -58,7 +58,6 @@ struct rtentry;
#include "interface.h"
#include "addrtoname.h"
#include "llc.h"
#include "savestr.h"
#include "setsignal.h"
/* Forwards */
@ -72,7 +71,7 @@ static RETSIGTYPE nohostname(int);
struct hnamemem {
u_int32_t addr;
char *name;
const char *name;
struct hnamemem *nxt;
};
@ -97,18 +96,20 @@ struct enamemem {
u_short e_addr0;
u_short e_addr1;
u_short e_addr2;
char *e_name;
const char *e_name;
u_char *e_nsap; /* used only for nsaptable[] */
#define e_bs e_nsap /* for bytestringtable */
struct enamemem *e_nxt;
};
struct enamemem enametable[HASHNAMESIZE];
struct enamemem nsaptable[HASHNAMESIZE];
struct enamemem bytestringtable[HASHNAMESIZE];
struct protoidmem {
u_int32_t p_oui;
u_short p_proto;
char *p_name;
const char *p_name;
struct protoidmem *p_nxt;
};
@ -117,7 +118,7 @@ struct protoidmem protoidtable[HASHNAMESIZE];
/*
* A faster replacement for inet_ntoa().
*/
char *
const char *
intoa(u_int32_t addr)
{
register char *cp;
@ -169,18 +170,14 @@ nohostname(int signo)
* Return a name for the IP address pointed to by ap. This address
* is assumed to be in network byte order.
*/
char *
const char *
getname(const u_char *ap)
{
register struct hostent *hp;
u_int32_t addr;
static struct hnamemem *p; /* static for longjmp() */
#ifndef LBL_ALIGN
addr = *(const u_int32_t *)ap;
#else
memcpy(&addr, ap, sizeof(addr));
#endif
p = &hnametable[addr & (HASHNAMESIZE-1)];
for (; p->nxt; p = p->nxt) {
if (p->addr == addr)
@ -210,7 +207,7 @@ getname(const u_char *ap)
if (hp) {
char *dotp;
p->name = savestr(hp->h_name);
p->name = strdup(hp->h_name);
if (Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@ -221,7 +218,7 @@ getname(const u_char *ap)
}
}
}
p->name = savestr(intoa(addr));
p->name = strdup(intoa(addr));
return (p->name);
}
@ -230,13 +227,13 @@ getname(const u_char *ap)
* Return a name for the IP6 address pointed to by ap. This address
* is assumed to be in network byte order.
*/
char *
const char *
getname6(const u_char *ap)
{
register struct hostent *hp;
struct in6_addr addr;
static struct h6namemem *p; /* static for longjmp() */
register char *cp;
register const char *cp;
char ntop_buf[INET6_ADDRSTRLEN];
memcpy(&addr, ap, sizeof(addr));
@ -273,7 +270,7 @@ getname6(const u_char *ap)
if (hp) {
char *dotp;
p->name = savestr(hp->h_name);
p->name = strdup(hp->h_name);
if (Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@ -284,8 +281,8 @@ getname6(const u_char *ap)
}
}
}
cp = (char *)inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
p->name = savestr(cp);
cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
p->name = strdup(cp);
return (p->name);
}
#endif /* INET6 */
@ -323,13 +320,58 @@ lookup_emem(const u_char *ep)
return tp;
}
/*
* Find the hash node that corresponds to the bytestring 'bs'
* with length 'nlen'
*/
static inline struct enamemem *
lookup_bytestring(register const u_char *bs, const unsigned int nlen)
{
struct enamemem *tp;
register u_int i, j, k;
if (nlen >= 6) {
k = (bs[0] << 8) | bs[1];
j = (bs[2] << 8) | bs[3];
i = (bs[4] << 8) | bs[5];
} else if (nlen >= 4) {
k = (bs[0] << 8) | bs[1];
j = (bs[2] << 8) | bs[3];
i = 0;
} else
i = j = k = 0;
tp = &bytestringtable[(i ^ j) & (HASHNAMESIZE-1)];
while (tp->e_nxt)
if (tp->e_addr0 == i &&
tp->e_addr1 == j &&
tp->e_addr2 == k &&
memcmp((const char *)bs, (const char *)(tp->e_bs), nlen) == 0)
return tp;
else
tp = tp->e_nxt;
tp->e_addr0 = i;
tp->e_addr1 = j;
tp->e_addr2 = k;
tp->e_bs = (u_char *) calloc(1, nlen + 1);
memcpy(tp->e_bs, bs, nlen);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
error("lookup_bytestring: calloc");
return tp;
}
/* Find the hash node that corresponds the NSAP 'nsap' */
static inline struct enamemem *
lookup_nsap(register const u_char *nsap)
{
register u_int i, j, k;
int nlen = *nsap;
unsigned int nlen = *nsap;
struct enamemem *tp;
const u_char *ensap = nsap + nlen - 6;
@ -347,7 +389,7 @@ lookup_nsap(register const u_char *nsap)
tp->e_addr1 == j &&
tp->e_addr2 == k &&
tp->e_nsap[0] == nlen &&
memcmp((char *)&(nsap[1]),
memcmp((const char *)&(nsap[1]),
(char *)&(tp->e_nsap[1]), nlen) == 0)
return tp;
else
@ -358,7 +400,7 @@ lookup_nsap(register const u_char *nsap)
tp->e_nsap = (u_char *)malloc(nlen + 1);
if (tp->e_nsap == NULL)
error("lookup_nsap: malloc");
memcpy((char *)tp->e_nsap, (char *)nsap, nlen + 1);
memcpy((char *)tp->e_nsap, (const char *)nsap, nlen + 1);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
error("lookup_nsap: calloc");
@ -394,7 +436,7 @@ lookup_protoid(const u_char *pi)
return tp;
}
char *
const char *
etheraddr_string(register const u_char *ep)
{
register u_int i, j;
@ -405,11 +447,11 @@ etheraddr_string(register const u_char *ep)
tp = lookup_emem(ep);
if (tp->e_name)
return (tp->e_name);
#ifdef HAVE_ETHER_NTOHOST
#ifdef USE_ETHER_NTOHOST
if (!nflag) {
char buf[128];
if (ether_ntohost(buf, (struct ether_addr *)ep) == 0) {
tp->e_name = savestr(buf);
if (ether_ntohost(buf, (const struct ether_addr *)ep) == 0) {
tp->e_name = strdup(buf);
return (tp->e_name);
}
}
@ -425,11 +467,41 @@ etheraddr_string(register const u_char *ep)
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';
tp->e_name = savestr(buf);
tp->e_name = strdup(buf);
return (tp->e_name);
}
char *
const char *
linkaddr_string(const u_char *ep, const unsigned int len)
{
register u_int i, j;
register char *cp;
register struct enamemem *tp;
if (len == 6) /* XXX not totally correct... */
return etheraddr_string(ep);
tp = lookup_bytestring(ep, len);
if (tp->e_name)
return (tp->e_name);
tp->e_name = cp = (char *)malloc(len*3);
if (tp->e_name == NULL)
error("linkaddr_string: malloc");
if ((j = *ep >> 4) != 0)
*cp++ = hex[j];
*cp++ = hex[*ep++ & 0xf];
for (i = len-1; i > 0 ; --i) {
*cp++ = ':';
if ((j = *ep >> 4) != 0)
*cp++ = hex[j];
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';
return (tp->e_name);
}
const char *
etherproto_string(u_short port)
{
register char *cp;
@ -451,11 +523,11 @@ etherproto_string(u_short port)
*cp++ = hex[port >> 4 & 0xf];
*cp++ = hex[port & 0xf];
*cp++ = '\0';
tp->name = savestr(buf);
tp->name = strdup(buf);
return (tp->name);
}
char *
const char *
protoid_string(register const u_char *pi)
{
register u_int i, j;
@ -478,11 +550,11 @@ protoid_string(register const u_char *pi)
*cp++ = hex[*pi++ & 0xf];
}
*cp = '\0';
tp->p_name = savestr(buf);
tp->p_name = strdup(buf);
return (tp->p_name);
}
char *
const char *
llcsap_string(u_char sap)
{
register struct hnamemem *tp;
@ -497,11 +569,11 @@ llcsap_string(u_char sap)
tp->nxt = newhnamemem();
snprintf(buf, sizeof(buf), "sap %02x", sap & 0xff);
tp->name = savestr(buf);
tp->name = strdup(buf);
return (tp->name);
}
char *
const char *
isonsap_string(const u_char *nsap)
{
register u_int i, nlen = nsap[0];
@ -526,7 +598,7 @@ isonsap_string(const u_char *nsap)
return (tp->e_name);
}
char *
const char *
tcpport_string(u_short port)
{
register struct hnamemem *tp;
@ -541,11 +613,11 @@ tcpport_string(u_short port)
tp->nxt = newhnamemem();
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = savestr(buf);
tp->name = strdup(buf);
return (tp->name);
}
char *
const char *
udpport_string(register u_short port)
{
register struct hnamemem *tp;
@ -560,7 +632,7 @@ udpport_string(register u_short port)
tp->nxt = newhnamemem();
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = savestr(buf);
tp->name = strdup(buf);
return (tp->name);
}
@ -586,9 +658,9 @@ init_servarray(void)
table = table->nxt;
if (nflag) {
(void)snprintf(buf, sizeof(buf), "%d", port);
table->name = savestr(buf);
table->name = strdup(buf);
} else
table->name = savestr(sv->s_name);
table->name = strdup(sv->s_name);
table->addr = port;
table->nxt = newhnamemem();
}
@ -618,6 +690,18 @@ init_eprotoarray(void)
}
}
static struct protoidlist {
const u_char protoid[5];
const char *name;
} protoidlist[] = {
{{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" },
{{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" },
{{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" },
{{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" },
{{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" },
{{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL }
};
/*
* SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet
* types.
@ -627,6 +711,7 @@ init_protoidarray(void)
{
register int i;
register struct protoidmem *tp;
struct protoidlist *pl;
u_char protoid[5];
protoid[0] = 0;
@ -637,13 +722,22 @@ init_protoidarray(void)
memcpy((char *)&protoid[3], (char *)&etype, 2);
tp = lookup_protoid(protoid);
tp->p_name = savestr(eproto_db[i].s);
tp->p_name = strdup(eproto_db[i].s);
}
/* Hardwire some SNAP proto ID names */
for (pl = protoidlist; pl->name != NULL; ++pl) {
tp = lookup_protoid(pl->protoid);
/* Don't override existing name */
if (tp->p_name != NULL)
continue;
tp->p_name = pl->name;
}
}
static struct etherlist {
u_char addr[6];
char *name;
const u_char addr[6];
const char *name;
} etherlist[] = {
{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" },
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL }
@ -668,7 +762,7 @@ init_etherarray(void)
{
register struct etherlist *el;
register struct enamemem *tp;
#ifdef HAVE_ETHER_NTOHOST
#ifdef USE_ETHER_NTOHOST
char name[256];
#else
register struct pcap_etherent *ep;
@ -679,7 +773,7 @@ init_etherarray(void)
if (fp != NULL) {
while ((ep = pcap_next_etherent(fp)) != NULL) {
tp = lookup_emem(ep->addr);
tp->e_name = savestr(ep->name);
tp->e_name = strdup(ep->name);
}
(void)fclose(fp);
}
@ -692,10 +786,10 @@ init_etherarray(void)
if (tp->e_name != NULL)
continue;
#ifdef HAVE_ETHER_NTOHOST
#ifdef USE_ETHER_NTOHOST
/* Use yp/nis version of name if available */
if (ether_ntohost(name, (struct ether_addr *)el->addr) == 0) {
tp->e_name = savestr(name);
if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {
tp->e_name = strdup(name);
continue;
}
#endif
@ -713,6 +807,9 @@ static struct tok llcsap_db[] = {
{ LLCSAP_RS511, "eia-rs511" },
{ LLCSAP_ISO8208, "x.25/llc2" },
{ LLCSAP_PROWAY, "proway" },
{ LLCSAP_SNAP, "snap" },
{ LLCSAP_IPX, "IPX" },
{ LLCSAP_NETBEUI, "netbeui" },
{ LLCSAP_ISONS, "iso-clns" },
{ LLCSAP_GLOBAL, "global" },
{ 0, NULL }
@ -761,7 +858,7 @@ init_addrtoname(u_int32_t localnet, u_int32_t mask)
init_protoidarray();
}
char *
const char *
dnaddr_string(u_short dnaddr)
{
register struct hnamemem *tp;

View File

@ -18,20 +18,21 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.16 1999/10/30 05:11:07 itojun Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.18 2001/09/17 21:57:51 fenner Exp $ (LBL)
*/
/* Name to address translation routines. */
extern char *etheraddr_string(const u_char *);
extern char *etherproto_string(u_short);
extern char *tcpport_string(u_short);
extern char *udpport_string(u_short);
extern char *getname(const u_char *);
extern const char *linkaddr_string(const u_char *, const unsigned int);
extern const char *etheraddr_string(const u_char *);
extern const char *etherproto_string(u_short);
extern const char *tcpport_string(u_short);
extern const char *udpport_string(u_short);
extern const char *getname(const u_char *);
#ifdef INET6
extern char *getname6(const u_char *);
extern const char *getname6(const u_char *);
#endif
extern char *intoa(u_int32_t);
extern const char *intoa(u_int32_t);
extern void init_addrtoname(u_int32_t, u_int32_t);
extern struct hnamemem *newhnamemem(void);

79
contrib/tcpdump/arcnet.h Normal file
View File

@ -0,0 +1,79 @@
/*
* 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.
*
* @(#) $Id: arcnet.h,v 1.1 2001/04/17 08:39:18 guy Exp $ (LBL)
*
* from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
*/
/*
* Structure of a 2.5MB/s Arcnet header.
* as given to interface code.
*/
struct arc_header {
u_int8_t arc_shost;
u_int8_t arc_dhost;
u_int8_t arc_type;
/*
* only present for newstyle encoding with LL fragmentation.
* Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
*/
u_int8_t arc_flag;
u_int16_t arc_seqid;
/*
* only present in exception packets (arc_flag == 0xff)
*/
u_int8_t arc_type2; /* same as arc_type */
u_int8_t arc_flag2; /* real flag value */
u_int16_t arc_seqid2; /* real seqid value */
} __attribute__((__packed__));
#define ARC_HDRLEN 3
#define ARC_HDRNEWLEN 6
#define ARC_HDRNEWLEN_EXC 10
/* RFC 1051 */
#define ARCTYPE_IP_OLD 240 /* IP protocol */
#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */
/* RFC 1201 */
#define ARCTYPE_IP 212 /* IP protocol */
#define ARCTYPE_ARP 213 /* address resolution protocol */
#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */
#define ARCTYPE_ATALK 221 /* Appletalk */
#define ARCTYPE_BANIAN 247 /* Banyan Vines */
#define ARCTYPE_IPX 250 /* Novell IPX */
#define ARCTYPE_INET6 0xc4 /* IPng */
#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */

View File

@ -1,4 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.10 2000/12/03 23:42:23 fenner Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.11 2001/01/09 07:39:13 fenner Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
@ -148,6 +148,9 @@ struct bootp {
#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 2242 */
#define TAG_NDS_IPDOMAIN ((u_int8_t) 62)
#define TAG_NDS_IPINFO ((u_int8_t) 63)
/* RFC 2485 */
#define TAG_OPEN_GROUP_UAP ((u_int8_t) 98)
/* RFC 2563 */

View File

@ -1,9 +1,9 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
timestamp='2000-12-15'
timestamp='2001-04-20'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -33,10 +33,6 @@ timestamp='2000-12-15'
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit build system type.
#
# Only a few systems have been added to this list; please add others
# (but try to keep the structure clean).
#
me=`echo "$0" | sed -e 's,.*/,,'`
@ -93,7 +89,7 @@ fi
dummy=dummy-$$
trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
@ -107,7 +103,7 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in
CC_FOR_BUILD="$c"; break
fi
done
rm -f $dummy.c $dummy.o
rm -f $dummy.c $dummy.o $dummy.rel
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found
fi
@ -276,7 +272,7 @@ EOF
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
SR2?01:HI-UX/MPP:*:*)
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit 0;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
@ -412,10 +408,13 @@ EOF
EOF
$CC_FOR_BUILD $dummy.c -o $dummy \
&& ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& rm $dummy.c $dummy && exit 0
&& rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
@ -463,9 +462,17 @@ EOF
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i?86:AIX:*:*)
i*86:AIX:*:*)
echo i386-ibm-aix
exit 0 ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
exit 0 ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
sed 's/^ //' << EOF >$dummy.c
@ -479,7 +486,7 @@ EOF
exit(0);
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
@ -488,9 +495,9 @@ EOF
echo rs6000-ibm-aix3.2
fi
exit 0 ;;
*:AIX:*:4)
*:AIX:*:[45])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
@ -498,23 +505,10 @@ EOF
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=4.${UNAME_RELEASE}
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit 0 ;;
*:AIX:*:5)
case "`lsattr -El proc0 -a type -F value`" in
PowerPC*) IBM_ARCH=powerpc
IBM_MANUF=ibm ;;
Itanium) IBM_ARCH=ia64
IBM_MANUF=unknown ;;
POWER*) IBM_ARCH=power
IBM_MANUF=ibm ;;
*) IBM_ARCH=powerpc
IBM_MANUF=ibm ;;
esac
echo ${IBM_ARCH}-${IBM_MANUF}-aix${UNAME_VERSION}.${UNAME_RELEASE}
exit 0 ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit 0 ;;
@ -599,6 +593,10 @@ EOF
esac
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux${HPUX_REV}
exit 0 ;;
3050*:HI-UX:*:*)
sed 's/^ //' << EOF >$dummy.c
#include <unistd.h>
@ -625,7 +623,7 @@ EOF
exit (0);
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
echo unknown-hitachi-hiuxwe2
exit 0 ;;
@ -644,7 +642,7 @@ EOF
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit 0 ;;
i?86:OSF1:*:*)
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
@ -701,18 +699,16 @@ EOF
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
F300:UNIX_System_V:*:*)
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
F301:UNIX_System_V:*:*)
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
sparc*:BSD/OS:*:*)
@ -757,60 +753,38 @@ EOF
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit 0 ;;
*:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
ld_supported_emulations=`cd /; ld --help 2>&1 \
| sed -ne '/supported emulations:/!d
s/[ ][ ]*/ /g
s/.*supported emulations: *//
s/ .*//
p'`
case "$ld_supported_emulations" in
*ia64)
echo "${UNAME_MACHINE}-unknown-linux"
exit 0
;;
i?86linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit 0
;;
elf_i?86)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
i?86coff)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit 0
;;
sparclinux)
echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
exit 0
;;
elf32_sparc)
echo "${UNAME_MACHINE}-unknown-linux-gnu"
exit 0
;;
armlinux)
echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
exit 0
;;
elf32arm*)
echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
exit 0
;;
armelf_linux*)
echo "${UNAME_MACHINE}-unknown-linux-gnu"
exit 0
;;
m68klinux)
echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
exit 0
;;
elf32ppc | elf32ppclinux)
# Determine Lib Version
cat >$dummy.c <<EOF
arm*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux
exit 0 ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
mips:Linux:*:*)
cat >$dummy.c <<EOF
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#ifdef __MIPSEB__
printf ("%s-unknown-linux-gnu\n", argv[1]);
#endif
#ifdef __MIPSEL__
printf ("%sel-unknown-linux-gnu\n", argv[1]);
#endif
return 0;
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
;;
ppc:Linux:*:*)
# Determine Lib Version
cat >$dummy.c <<EOF
#include <features.h>
#if defined(__GLIBC__)
extern char __libc_version[];
@ -823,143 +797,127 @@ main(argc, argv)
#if defined(__GLIBC__)
printf("%s %s\n", __libc_version, __libc_release);
#else
printf("unkown\n");
printf("unknown\n");
#endif
return 0;
}
EOF
LIBC=""
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
LIBC=""
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
if test "$?" = 0 ; then
./$dummy | grep 1\.99 > /dev/null
if test "$?" = 0 ; then LIBC="libc1" ; fi
fi
rm -f $dummy.c $dummy
echo powerpc-unknown-linux-gnu${LIBC}
exit 0 ;;
alpha:Linux:*:*)
cat <<EOF >$dummy.s
.data
\$Lformat:
.byte 37,100,45,37,120,10,0 # "%d-%x\n"
.text
.globl main
.align 4
.ent main
main:
.frame \$30,16,\$26,0
ldgp \$29,0(\$27)
.prologue 1
.long 0x47e03d80 # implver \$0
lda \$2,-1
.long 0x47e20c21 # amask \$2,\$1
lda \$16,\$Lformat
mov \$0,\$17
not \$1,\$18
jsr \$26,printf
ldgp \$29,0(\$26)
mov 0,\$16
jsr \$26,exit
.end main
EOF
LIBC=""
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
case `./$dummy` in
0-0) UNAME_MACHINE="alpha" ;;
1-0) UNAME_MACHINE="alphaev5" ;;
1-1) UNAME_MACHINE="alphaev56" ;;
1-101) UNAME_MACHINE="alphapca56" ;;
2-303) UNAME_MACHINE="alphaev6" ;;
2-307) UNAME_MACHINE="alphaev67" ;;
esac
objdump --private-headers $dummy | \
grep ld.so.1 > /dev/null
if test "$?" = 0 ; then
./$dummy | grep 1\.99 > /dev/null
if test "$?" = 0 ; then
LIBC="libc1"
fi
LIBC="libc1"
fi
rm -f $dummy.c $dummy
echo powerpc-unknown-linux-gnu${LIBC}
fi
rm -f $dummy.s $dummy
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit 0 ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-gnu ;;
PA8*) echo hppa2.0-unknown-linux-gnu ;;
*) echo hppa-unknown-linux-gnu ;;
esac
exit 0 ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
exit 0 ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
exit 0 ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
exit 0 ;;
i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
ld_supported_emulations=`cd /; ld --help 2>&1 \
| sed -ne '/supported emulations:/!d
s/[ ][ ]*/ /g
s/.*supported emulations: *//
s/ .*//
p'`
case "$ld_supported_emulations" in
i*86linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit 0
;;
shelf_linux)
echo "${UNAME_MACHINE}-unknown-linux-gnu"
elf_i*86)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
i*86coff)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit 0
;;
esac
if test "${UNAME_MACHINE}" = "alpha" ; then
cat <<EOF >$dummy.s
.data
\$Lformat:
.byte 37,100,45,37,120,10,0 # "%d-%x\n"
.text
.globl main
.align 4
.ent main
main:
.frame \$30,16,\$26,0
ldgp \$29,0(\$27)
.prologue 1
.long 0x47e03d80 # implver \$0
lda \$2,-1
.long 0x47e20c21 # amask \$2,\$1
lda \$16,\$Lformat
mov \$0,\$17
not \$1,\$18
jsr \$26,printf
ldgp \$29,0(\$26)
mov 0,\$16
jsr \$26,exit
.end main
EOF
LIBC=""
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
case `./$dummy` in
0-0)
UNAME_MACHINE="alpha"
;;
1-0)
UNAME_MACHINE="alphaev5"
;;
1-1)
UNAME_MACHINE="alphaev56"
;;
1-101)
UNAME_MACHINE="alphapca56"
;;
2-303)
UNAME_MACHINE="alphaev6"
;;
2-307)
UNAME_MACHINE="alphaev67"
;;
esac
objdump --private-headers $dummy | \
grep ld.so.1 > /dev/null
if test "$?" = 0 ; then
LIBC="libc1"
fi
fi
rm -f $dummy.s $dummy
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
elif test "${UNAME_MACHINE}" = "mips" ; then
cat >$dummy.c <<EOF
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#ifdef __MIPSEB__
printf ("%s-unknown-linux-gnu\n", argv[1]);
#endif
#ifdef __MIPSEL__
printf ("%sel-unknown-linux-gnu\n", argv[1]);
#endif
return 0;
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
elif test "${UNAME_MACHINE}" = "s390"; then
echo s390-ibm-linux && exit 0
elif test "${UNAME_MACHINE}" = "x86_64"; then
echo x86_64-unknown-linux-gnu && exit 0
elif test "${UNAME_MACHINE}" = "parisc" -o "${UNAME_MACHINE}" = "hppa"; then
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*)
echo hppa1.1-unknown-linux-gnu
;;
PA8*)
echo hppa2.0-unknown-linux-gnu
;;
*)
echo hppa-unknown-linux-gnu
;;
esac
exit 0
else
# Either a pre-BFD a.out linker (linux-gnuoldld)
# or one that does not give us useful --help.
# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
# If ld does not provide *any* "supported emulations:"
# that means it is gnuoldld.
test -z "$ld_supported_emulations" \
&& echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
case "${UNAME_MACHINE}" in
i?86)
VENDOR=pc;
;;
*)
VENDOR=unknown;
;;
esac
# Determine whether the default compiler is a.out or elf
cat >$dummy.c <<EOF
# Either a pre-BFD a.out linker (linux-gnuoldld)
# or one that does not give us useful --help.
# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
# If ld does not provide *any* "supported emulations:"
# that means it is gnuoldld.
test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
case "${UNAME_MACHINE}" in
i*86)
VENDOR=pc;
;;
*)
VENDOR=unknown;
;;
esac
# Determine whether the default compiler is a.out or elf
cat >$dummy.c <<EOF
#include <features.h>
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
@ -983,16 +941,16 @@ EOF
return 0;
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
fi ;;
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
;;
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
# are messed up and put the nodename in both sysname and nodename.
i?86:DYNIX/ptx:4*:*)
i*86:DYNIX/ptx:4*:*)
echo i386-sequent-sysv4
exit 0 ;;
i?86:UNIX_SV:4.2MP:2.*)
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
@ -1000,7 +958,7 @@ EOF
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;;
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
@ -1008,7 +966,7 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit 0 ;;
i?86:*:5:7*)
i*86:*:5:7*)
# Fixed at (any) Pentium or better
UNAME_MACHINE=i586
if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
@ -1017,7 +975,7 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
fi
exit 0 ;;
i?86:*:3.2:*)
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
@ -1035,7 +993,7 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
i?86:*DOS:*:*)
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit 0 ;;
pc:*:*:*)
@ -1074,21 +1032,24 @@ EOF
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4 && exit 0 ;;
m68*:LynxOS:2.*:*)
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit 0 ;;
@ -1188,11 +1149,29 @@ EOF
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit 0 ;;
i?86:OS/2:*:*)
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit 0 ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit 0 ;;
*:TENEX:*:*)
echo pdp10-unknown-tenex
exit 0 ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
echo pdp10-dec-tops20
exit 0 ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
echo pdp10-xkl-tops20
exit 0 ;;
*:TOPS-20:*:*)
echo pdp10-unknown-tops20
exit 0 ;;
*:ITS:*:*)
echo pdp10-unknown-its
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
@ -1284,11 +1263,24 @@ main ()
#endif
#if defined (vax)
#if !defined (ultrix)
printf ("vax-dec-bsd\n"); exit (0);
#else
printf ("vax-dec-ultrix\n"); exit (0);
#endif
# if !defined (ultrix)
# include <sys/param.h>
# if defined (BSD)
# if BSD == 43
printf ("vax-dec-bsd4.3\n"); exit (0);
# else
# if BSD == 199006
printf ("vax-dec-bsd4.3reno\n"); exit (0);
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# endif
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# else
printf ("vax-dec-ultrix\n"); exit (0);
# endif
#endif
#if defined (alliant) && defined (i860)
@ -1299,7 +1291,7 @@ main ()
}
EOF
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
# Apollos put the system type in the environment.
@ -1335,8 +1327,9 @@ fi
cat >&2 <<EOF
$0: unable to guess system type
The $version version of this script cannot recognize your system type.
Please download the most up to date version of the config scripts:
This script, last modified $timestamp, has failed to recognize
the operating system you are using. It is advised that you
download the most up to date version of the config scripts from
ftp://ftp.gnu.org/pub/gnu/config/
@ -1345,7 +1338,7 @@ send the following data and any information you think might be
pertinent to <config-patches@gnu.org> in order to provide the needed
information to handle your system.
config.guess version = $version
config.guess timestamp = $timestamp
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`

View File

@ -14,10 +14,6 @@
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define if your processor stores words with the most significant
byte first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define if you have SSLeay 0.9.0b with the buggy cast128. */
#undef HAVE_BUGGY_CAST128
@ -60,8 +56,8 @@
/* define if you have struct sockaddr_storage */
#undef HAVE_SOCKADDR_STORAGE
/* define if you have both getipnodebyname() and getipnodebyaddr() */
#undef USE_GETIPNODEBY
/* define if you have ether_ntohost() and it works */
#undef USE_ETHER_NTOHOST
/* define if unaligned memory accesses fail */
#undef LBL_ALIGN
@ -86,6 +82,17 @@
#undef u_int32_t
#undef u_int8_t
/* Whether or not to include the possibly-buggy SMB printer */
#undef TCPDUMP_DO_SMB
/* Long story short: aclocal.m4 depends on autoconf 2.13
* implementation details wrt "const"; newer versions
* have different implementation details so for now we
* put "const" here. This may cause duplicate definitions
* in config.h but that should be OK since they're the same.
*/
#undef const
/* The number of bytes in a char. */
#undef SIZEOF_CHAR
@ -104,18 +111,9 @@
/* 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 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
@ -146,6 +144,9 @@
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strdup function. */
#undef HAVE_STRDUP
/* Define if you have the strlcat function. */
#undef HAVE_STRLCAT
@ -182,24 +183,12 @@
/* 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
/* Define if you have the rpc library (-lrpc). */
#undef HAVE_LIBRPC
/* Define if you have the smi library (-lsmi). */
#undef HAVE_LIBSMI
/* Define if you have the socket library (-lsocket). */
#undef HAVE_LIBSOCKET
/* Define if you have the str library (-lstr). */
#undef HAVE_LIBSTR
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__

View File

@ -1,9 +1,9 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
timestamp='2000-12-15'
timestamp='2001-04-20'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@ -69,7 +69,7 @@ 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
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
@ -117,7 +117,7 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | storm-chaos*)
nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@ -226,12 +226,15 @@ case $basic_machine in
| alphaev6[78] \
| we32k | ns16k | clipper | i370 | sh | sh[34] \
| powerpc | powerpcle \
| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
| 1750a | dsp16xx | pdp10 | 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)
| mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \
| sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \
| v850 | c4x \
| thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
| pj | pjl | h8500)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
@ -239,13 +242,13 @@ case $basic_machine in
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65)
;;
# 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[234567]86 | x86_64)
i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
@ -255,7 +258,7 @@ case $basic_machine in
;;
# Recognize the basic CPU types with company name.
# FIXME: clean up the formatting here.
vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
vax-* | tahoe-* | i*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-* \
@ -268,15 +271,17 @@ case $basic_machine in
| alphaev6[78]-* \
| we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
| clipper-* | orion-* \
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
| sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
| sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
| sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \
| mips16-* | mips64-* | mipsel-* \
| mips64el-* | mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
| mipstx39-* | mipstx39el-* | mcore-* \
| f30[01]-* | s390-* | sv1-* | t3e-* \
| f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
| [cjt]90-* \
| m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
| thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
| bs2000-* | tic54x-* | c54x-* | x86_64-*)
| thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
| bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@ -367,8 +372,8 @@ case $basic_machine in
basic_machine=cray2-cray
os=-unicos
;;
[ctj]90-cray)
basic_machine=c90-cray
[cjt]90)
basic_machine=${basic_machine}-cray
os=-unicos
;;
crds | unos)
@ -424,6 +429,10 @@ case $basic_machine in
basic_machine=tron-gmicro
os=-sysv
;;
go32)
basic_machine=i386-pc
os=-go32
;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
@ -499,19 +508,19 @@ case $basic_machine in
basic_machine=i370-ibm
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i[34567]86v32)
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i[34567]86v4*)
i*86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i[34567]86v)
i*86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i[34567]86sol2)
i*86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
@ -523,18 +532,6 @@ case $basic_machine in
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
@ -560,6 +557,10 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
;;
miniframe)
basic_machine=m68000-convergent
;;
@ -590,7 +591,7 @@ case $basic_machine in
os=-coff
;;
msdos)
basic_machine=i386-unknown
basic_machine=i386-pc
os=-msdos
;;
mvs)
@ -729,6 +730,10 @@ case $basic_machine in
ps2)
basic_machine=i386-ibm
;;
pw32)
basic_machine=i586-unknown
os=-pw32
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
@ -919,6 +924,10 @@ case $basic_machine in
vax)
basic_machine=vax-dec
;;
pdp10)
# there are many clones, so DEC is not a safe bet
basic_machine=pdp10-unknown
;;
pdp11)
basic_machine=pdp11-dec
;;
@ -928,7 +937,7 @@ case $basic_machine in
sh3 | sh4)
basic_machine=sh-unknown
;;
sparc | sparcv9)
sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun
;;
cydra)
@ -950,6 +959,9 @@ case $basic_machine in
basic_machine=c4x-none
os=-coff
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
@ -1009,12 +1021,13 @@ case $os in
| -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*)
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
case $basic_machine in
x86-* | i[34567]86-*)
x86-* | i*86-*)
;;
*)
os=-nto$os
@ -1107,7 +1120,7 @@ case $os in
-xenix)
os=-xenix
;;
-*mint | -*MiNT)
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-none)
@ -1141,6 +1154,9 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
pdp10-*)
os=-tops20
;;
pdp11-*)
os=-none
;;
@ -1249,7 +1265,7 @@ case $basic_machine in
*-masscomp)
os=-rtu
;;
f30[01]-fujitsu)
f30[01]-fujitsu | f700-fujitsu)
os=-uxpv
;;
*-rom68k)
@ -1327,7 +1343,7 @@ case $basic_machine in
-mpw* | -macos*)
vendor=apple
;;
-*mint | -*MiNT)
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
esac

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.132.4.1 2001/01/17 18:29:58 guy Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.145 2002/01/17 05:00:16 guy Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@ -6,11 +6,11 @@ dnl
dnl Process this file with autoconf to produce a configure script.
dnl
AC_REVISION($Revision: 1.132.4.1 $)
AC_REVISION($Revision: 1.145 $)
AC_PREREQ(2.13)
AC_INIT(tcpdump.c)
AC_CANONICAL_SYSTEM
AC_CANONICAL_HOST
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_C_INLINE
@ -19,7 +19,7 @@ AC_C___ATTRIBUTE__
AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netinet/if_ether.h)
AC_HEADER_TIME
case "$target_os" in
case "$host_os" in
linux*)
AC_MSG_CHECKING(Linux kernel version)
@ -47,6 +47,8 @@ esac
AC_CHECK_HEADERS(smi.h)
AC_CHECK_LIB(smi, smiInit)
if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
then
AC_MSG_CHECKING([whether to enable libsmi])
AC_TRY_RUN([ /* libsmi available check */
#include <smi.h>
@ -69,12 +71,36 @@ main()
[ AC_MSG_RESULT(yes)
AC_DEFINE(LIBSMI)
libsmi=yes],
[ AC_MSG_RESULT(no)
dnl autoconf documentation says that $? contains the exit value.
dnl reality is that it does not. We leave this in just in case
dnl autoconf ever comes back to match the documentation.
[ case $? in
1) AC_MSG_RESULT(no - smiInit failed) ;;
2) AC_MSG_RESULT(no - header/library version mismatch) ;;
3) AC_MSG_RESULT(no - can't determine library version) ;;
4) AC_MSG_RESULT(no - too old) ;;
*) AC_MSG_RESULT(no) ;;
esac
libsmi=no],
[ AC_MSG_RESULT(not when cross-compiling)
libsmi=no]
)
fi
AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
AC_ARG_ENABLE(smb,
[ --enable-smb enable possibly-buggy SMB printer [default=yes]
--disable-smb disable possibly-buggy SMB printer],,
enableval=yes)
case "$enableval" in
yes) AC_MSG_RESULT(yes)
AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
AC_DEFINE(TCPDUMP_DO_SMB)
LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
;;
*) AC_MSG_RESULT(no)
;;
esac
CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len"
AC_MSG_CHECKING([whether to enable ipv6])
@ -450,15 +476,32 @@ if test "$missing_includes" = "yes"; then
fi
AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy)
AC_CHECK_FUNCS(ether_ntohost setlinebuf)
AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup)
AC_CHECK_FUNCS(ether_ntohost, [
AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
AC_TRY_RUN([
#include <netdb.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
usegetipnodeby=yes
AC_CHECK_FUNCS(getipnodebyname getipnodebyaddr freeaddrinfo,
[], [usegetipnodeby=no])
if test $usegetipnodeby = yes; then
AC_DEFINE(USE_GETIPNODEBY)
fi
int
main(int argc, char **argv)
{
u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
char name[MAXHOSTNAMELEN];
ether_ntohost(name, (struct ether_addr *)ea);
exit(0);
}
], [ac_cv_buggy_ether_ntohost=no],
[ac_cv_buggy_ether_ntohost=yes],
[ac_cv_buggy_ether_ntohost=not while cross-compiling])])
if test "$ac_cv_buggy_ether_ntohost" = "no"; then
AC_DEFINE(USE_ETHER_NTOHOST)
fi
])
AC_CHECK_FUNCS(setlinebuf)
needsnprintf=no
AC_CHECK_FUNCS(vsnprintf snprintf,,
@ -467,19 +510,18 @@ 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_LBL_TYPE_SIGNAL
AC_CHECK_LIB(dnet, dnet_htoa)
AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
dnl HP/UX may need -lnsl for getrpcbynumber.
AC_SEARCH_LIBS(getrpcbynumber, nsl)
AC_CHECK_LIB(dnet, main)
AC_CHECK_LIB(rpc, main)
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
@ -488,7 +530,7 @@ V_GROUP=0
if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
V_GROUP=wheel
fi
case "$target_os" in
case "$host_os" in
aix*)
dnl Workaround to enable certain features
@ -535,11 +577,7 @@ 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/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
if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
incdir="-I$dir/include"
fi
if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then

View File

@ -1,4 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/dhcp6.h,v 1.4 2000/12/17 23:07:48 guy Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6.h,v 1.4 2000/12/17 23:07:48 guy Exp $ (LBL) */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.

View File

@ -1,4 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/dhcp6opt.h,v 1.3 2000/12/17 23:07:49 guy Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6opt.h,v 1.4 2001/09/17 21:57:51 fenner Exp $ (LBL) */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@ -47,7 +47,7 @@
struct dhcp6_opt {
u_int code;
int len;
char *name;
const char *name;
int type;
};

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/ethertype.h,v 1.12 2000/09/23 08:03:30 guy Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.16 2001/06/21 17:56:02 itojun Exp $ (LBL)
*/
/*
@ -97,11 +97,20 @@
#define ETHERTYPE_8021Q 0x8100
#endif
#ifndef ETHERTYPE_IPX
#define ETHERTYPE_IPX 0x8137
#define ETHERTYPE_IPX 0x8137
#endif
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86dd
#endif
#ifndef ETHERTYPE_PPP
#define ETHERTYPE_PPP 0x880b
#endif
#ifndef ETHERTYPE_MPLS
#define ETHERTYPE_MPLS 0x8847
#endif
#ifndef ETHERTYPE_MPLS_MULTI
#define ETHERTYPE_MPLS_MULTI 0x8848
#endif
#ifndef ETHERTYPE_PPPOED
#define ETHERTYPE_PPPOED 0x8863
#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.16 2000/10/03 02:54:55 itojun Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.17 2001/09/17 21:57:52 fenner Exp $ (LBL)
*/
/* Network to host order macros */
#ifdef LBL_ALIGN
#define EXTRACT_16BITS(p) \
((u_int16_t)*((u_int8_t *)(p) + 0) << 8 | \
(u_int16_t)*((u_int8_t *)(p) + 1))
((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
(u_int16_t)*((const u_int8_t *)(p) + 1))
#define EXTRACT_32BITS(p) \
((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))
((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
(u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
(u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
(u_int32_t)*((const u_int8_t *)(p) + 3))
#else
#define EXTRACT_16BITS(p) \
((u_int16_t)ntohs(*(u_int16_t *)(p)))
((u_int16_t)ntohs(*(const u_int16_t *)(p)))
#define EXTRACT_32BITS(p) \
((u_int32_t)ntohl(*(u_int32_t *)(p)))
((u_int32_t)ntohl(*(const u_int32_t *)(p)))
#endif
#define EXTRACT_24BITS(p) \
((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))
((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
(u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
(u_int32_t)*((const u_int8_t *)(p) + 2))
/* Little endian protocol host order macros */
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_LE_16BITS(p) \
((u_int16_t)*((u_int8_t *)(p) + 1) << 8 | \
(u_int16_t)*((u_int8_t *)(p) + 0))
((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
(u_int16_t)*((const u_int8_t *)(p) + 0))
#define EXTRACT_LE_32BITS(p) \
((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))
((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
(u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
(u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
(u_int32_t)*((const u_int8_t *)(p) + 0))

View File

@ -1,4 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.4 2000/12/17 23:13:32 guy Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.11 2001/06/01 23:01:04 itojun 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 $ */
@ -198,6 +198,19 @@ struct nd_router_advert { /* router advertisement */
#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_FLAG_HOME_AGENT 0x20
/*
* Router preference values based on draft-draves-ipngwg-router-selection-01.
* These are non-standard definitions.
*/
#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
struct nd_neighbor_solicit { /* neighbor solicitation */
@ -249,7 +262,10 @@ struct nd_opt_hdr { /* Neighbor discovery option header */
#define ND_OPT_PREFIX_INFORMATION 3
#define ND_OPT_REDIRECTED_HEADER 4
#define ND_OPT_MTU 5
#define ND_OPT_ADVINT 7
#define ND_OPT_ADVINTERVAL 7
#define ND_OPT_HOMEAGENT_INFO 8
#define ND_OPT_ROUTE_INFO 9 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
struct nd_opt_prefix_info { /* prefix information */
u_int8_t nd_opt_pi_type;
@ -281,11 +297,28 @@ struct nd_opt_mtu { /* MTU option */
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;
struct nd_opt_advinterval { /* Advertisement interval option */
u_int8_t nd_opt_adv_type;
u_int8_t nd_opt_adv_len;
u_int16_t nd_opt_adv_reserved;
u_int32_t nd_opt_adv_interval;
};
struct nd_opt_homeagent_info { /* Home Agent info */
u_int8_t nd_opt_hai_type;
u_int8_t nd_opt_hai_len;
u_int16_t nd_opt_hai_reserved;
int16_t nd_opt_hai_preference;
u_int16_t nd_opt_hai_lifetime;
};
struct nd_opt_route_info { /* route info */
u_int8_t nd_opt_rti_type;
u_int8_t nd_opt_rti_len;
u_int8_t nd_opt_rti_prefixlen;
u_int8_t nd_opt_rti_flags;
u_int32_t nd_opt_rti_lifetime;
/* prefix follows */
};
/*
@ -356,7 +389,7 @@ struct icmp6_router_renum { /* router renumbering header */
};
#define ICMP6_RR_FLAGS_TEST 0x80
#define ICMP6_RR_FLAGS_REQRESULT 0x40
#define ICMP6_RR_FLAGS_ALLIF 0x20
#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
#define ICMP6_RR_FLAGS_SPECSITE 0x10
#define ICMP6_RR_FLAGS_PREVDONE 0x08

View File

@ -0,0 +1,244 @@
/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.3 2001/06/14 09:50:01 guy Exp $ (LBL) */
/*
* Copyright (c) 2001
* Fortress Technologies
* Charlie Lenahan ( clenahan@fortresstech.com )
*
* 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 IEEE802_11_FC_LEN 2
#define T_MGMT 0x0 /* management */
#define T_CTRL 0x1 /* control */
#define T_DATA 0x2 /* data */
#define T_RESV 0x3 /* reserved */
#define ST_ASSOC_REQUEST 0x0
#define ST_ASSOC_RESPONSE 0x1
#define ST_REASSOC_REQUEST 0x2
#define ST_REASSOC_RESPONSE 0x3
#define ST_PROBE_REQUEST 0x4
#define ST_PROBE_RESPONSE 0x5
/* RESERVED 0x6 */
/* RESERVED 0x7 */
#define ST_BEACON 0x8
#define ST_ATIM 0x9
#define ST_DISASSOC 0xA
#define ST_AUTH 0xB
#define ST_DEAUTH 0xC
/* RESERVED 0xD */
/* RESERVED 0xE */
/* RESERVED 0xF */
#define CTRL_PS_POLL 0xA
#define CTRL_RTS 0xB
#define CTRL_CTS 0xC
#define CTRL_ACK 0xD
#define CTRL_CF_END 0xE
#define CTRL_END_ACK 0xF
/*
* Bits in the frame control field.
*/
#define FC_VERSION(fc) ((fc) & 0x3)
#define FC_TYPE(fc) (((fc) >> 2) & 0x3)
#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
#define FC_TO_DS(fc) ((fc) & 0x0100)
#define FC_FROM_DS(fc) ((fc) & 0x0200)
#define FC_MORE_FLAG(fc) ((fc) & 0x0400)
#define FC_RETRY(fc) ((fc) & 0x0800)
#define FC_POWER_MGMT(fc) ((fc) & 0x1000)
#define FC_MORE_DATA(fc) ((fc) & 0x2000)
#define FC_WEP(fc) ((fc) & 0x4000)
#define FC_ORDER(fc) ((fc) & 0x8000)
struct mgmt_header_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t da[6];
u_int8_t sa[6];
u_int8_t bssid[6];
u_int16_t seq_ctrl;
};
#define MGMT_HEADER_LEN (2+2+6+6+6+2)
#define CAPABILITY_ESS(cap) ((cap) & 0x0001)
#define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
#define CAPABILITY_CFP(cap) ((cap) & 0x0004)
#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
struct ssid_t {
u_int8_t element_id;
u_int8_t length;
u_char ssid[33]; /* 32 + 1 for null */
} ;
struct rates_t {
u_int8_t element_id;
u_int8_t length;
u_int8_t rate[8];
};
struct challenge_t {
u_int8_t element_id;
u_int8_t length;
u_int8_t text[254]; /* 1-253 + 1 for null */
};
struct fh_t {
u_int8_t element_id;
u_int8_t length;
u_int16_t dwell_time;
u_int8_t hop_set;
u_int8_t hop_pattern;
u_int8_t hop_index;
};
struct ds_t {
u_int8_t element_id;
u_int8_t length;
u_int8_t channel;
};
struct cf_t {
u_int8_t element_id;
u_int8_t length;
u_int8_t count;
u_int8_t period;
u_int16_t max_duration;
u_int16_t dur_remaing;
};
struct tim_t {
u_int8_t element_id;
u_int8_t length;
u_int8_t count;
u_int8_t period;
u_int8_t bitmap_control;
u_int8_t bitmap[251];
};
#define E_SSID 0
#define E_RATES 1
#define E_FH 2
#define E_DS 3
#define E_CF 4
#define E_TIM 5
#define E_IBSS 6
/* reserved 7 */
/* reserved 8 */
/* reserved 9 */
/* reserved 10 */
/* reserved 11 */
/* reserved 12 */
/* reserved 13 */
/* reserved 14 */
/* reserved 15 */
/* reserved 16 */
#define E_CHALLENGE 16
/* reserved 17 */
/* reserved 18 */
/* reserved 19 */
/* reserved 16 */
/* reserved 16 */
struct mgmt_body_t {
u_int8_t timestamp[8];
u_int16_t beacon_interval;
u_int16_t listen_interval;
u_int16_t status_code;
u_int16_t aid;
u_char ap[6];
u_int16_t reason_code;
u_int16_t auth_alg;
u_int16_t auth_trans_seq_num;
struct challenge_t challenge;
u_int16_t capability_info;
struct ssid_t ssid;
struct rates_t rates;
struct ds_t ds;
struct cf_t cf;
struct fh_t fh;
struct tim_t tim;
};
struct ctrl_rts_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t ta[6];
u_int8_t fcs[4];
};
#define CTRL_RTS_LEN (2+2+6+6+4)
struct ctrl_cts_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t fcs[4];
};
#define CTRL_CTS_LEN (2+2+6+4)
struct ctrl_ack_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t fcs[4];
};
#define CTRL_ACK_LEN (2+2+6+4)
struct ctrl_ps_poll_t {
u_int16_t fc;
u_int16_t aid;
u_int8_t bssid[6];
u_int8_t ta[6];
u_int8_t fcs[4];
};
#define CTRL_PS_POLL_LEN (2+2+6+6+4)
struct ctrl_end_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t bssid[6];
u_int8_t fcs[4];
};
#define CTRL_END_LEN (2+2+6+6+4)
struct ctrl_end_ack_t {
u_int16_t fc;
u_int16_t duration;
u_int8_t ra[6];
u_int8_t bssid[6];
u_int8_t fcs[4];
};
#define CTRL_END_ACK_LEN (2+2+6+6+4)
#define IV_IV(iv) ((iv) & 0xFFFFFF)
#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
#define IV_KEYID(iv) (((iv) >> 30) & 0x03)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* Copyright (c) 1988-2002
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.149 2001/01/02 22:47:06 guy Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.178 2002/01/21 11:39:58 mcr Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@ -39,25 +39,29 @@
#include <stdarg.h>
#if !defined(HAVE_SNPRINTF)
int snprintf (char *str, size_t sz, const char *format, ...)
__attribute__ ((format (printf, 3, 4)));
int snprintf(char *, size_t, const char *, ...)
__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)));
int vsnprintf(char *, size_t, const char *, va_list)
__attribute__((format(printf, 3, 0)));
#endif
#ifndef HAVE_STRLCAT
extern size_t strlcat (char *, const char *, size_t);
extern size_t strlcat(char *, const char *, size_t);
#endif
#ifndef HAVE_STRLCPY
extern size_t strlcpy (char *, const char *, size_t);
extern size_t strlcpy(char *, const char *, size_t);
#endif
#ifndef HAVE_STRDUP
extern char *strdup(const char *);
#endif
struct tok {
int v; /* value */
char *s; /* string */
const char *s; /* string */
};
extern int aflag; /* translate network and broadcast addresses */
@ -77,6 +81,8 @@ extern int xflag; /* print packet in hex */
extern int Xflag; /* print packet in hex/ascii */
extern char *espsecret;
extern struct esp_algorithm *espsecret_xform; /* cache of decoded alg. */
extern char *espsecret_key;
extern int packettype; /* as specified by -T */
#define PT_VAT 1 /* Visual Audio Tool */
@ -94,16 +100,14 @@ extern int packettype; /* as specified by -T */
#define max(a,b) ((b)>(a)?(b):(a))
#endif
#ifndef INET6
/*
* The default snapshot length. This value allows most printers to print
* useful information while keeping the amount of unwanted data down.
* In particular, it allows for an ethernet header, tcp/ip header, and
* 14 bytes of data (assuming no ip options).
*/
#define DEFAULT_SNAPLEN 68
#ifndef INET6
#define DEFAULT_SNAPLEN 68 /* ether + IPv4 + TCP + 14 */
#else
#define DEFAULT_SNAPLEN 96
#define DEFAULT_SNAPLEN 96 /* ether + IPv6 + TCP + 22 */
#endif
#ifndef BIG_ENDIAN
@ -132,7 +136,7 @@ extern const u_char *packetp;
extern const u_char *snapend;
/* True if "l" bytes of "var" were captured */
#define TTEST2(var, l) ((u_char *)&(var) <= snapend - (l))
#define TTEST2(var, l) ((const u_char *)&(var) <= snapend - (l))
/* True if "var" was captured */
#define TTEST(var) TTEST2(var, sizeof(var))
@ -143,17 +147,20 @@ extern const u_char *snapend;
/* Bail if "var" was not captured */
#define TCHECK(var) TCHECK2(var, sizeof(var))
struct timeval;
extern void ts_print(const struct timeval *);
extern void relts_print(int);
extern int fn_print(const u_char *, const u_char *);
extern int fn_printn(const u_char *, u_int, const u_char *);
extern const char *tok2str(const struct tok *, const char *, int);
extern char *dnaddr_string(u_short);
extern const char *tok2strary_internal(const char **, int, const char *, int);
#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
extern void wrapup(int);
extern const char *dnaddr_string(u_short);
extern void info(int);
extern int infodelay;
extern int infoprint;
extern void error(const char *, ...)
__attribute__((noreturn, format (printf, 1, 2)));
@ -165,15 +172,16 @@ 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 *);
extern char *dnname_string(u_short);
extern char *dnnum_string(u_short);
extern const char *isonsap_string(const u_char *);
extern const char *llcsap_string(u_char);
extern const char *protoid_string(const u_char *);
extern const char *ipxsap_string(u_short);
extern const char *dnname_string(u_short);
extern const char *dnnum_string(u_short);
/* The printer routines. */
struct pcap_pkthdr;
#include <pcap.h>
extern void ascii_print_with_offset(const u_char *, u_int, u_int);
extern void ascii_print(const u_char *, u_int);
@ -189,21 +197,25 @@ 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 beep_print(const u_char *, u_int);
extern void cnfp_print(const u_char *, u_int, const u_char *);
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);
extern void dvmrp_print(const u_char *, u_int);
extern void egp_print(const u_char *, u_int, const u_char *);
extern void arcnet_if_print(u_char *, const struct pcap_pkthdr *,
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 ieee802_11_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 igmp_print(const u_char *, u_int);
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);
@ -212,6 +224,9 @@ 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 ltalk_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern void msdp_print(const unsigned 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);
@ -229,6 +244,8 @@ 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 void pppoe_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern int vjc_print(register const char *, register u_int, u_short);
extern void raw_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void rip_print(const u_char *, u_int);
@ -239,6 +256,7 @@ 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 chdlc_print(register const u_char *, u_int, u_int);
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 *);
@ -248,35 +266,47 @@ 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 int esp_print(register const u_char *, register const u_char *, int *, 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(u_short, const u_char *, const u_char *);
extern void ipx_netbios_print(const u_char *, const u_char *);
extern void netbeui_print(u_short, const u_char *, int);
extern void ipx_netbios_print(const u_char *, u_int);
extern void nbt_tcp_print(const u_char *, int);
extern void nbt_udp137_print(const u_char *data, int);
extern void nbt_udp138_print(const u_char *data, int);
extern void nbt_udp137_print(const u_char *, int);
extern void nbt_udp138_print(const u_char *, int);
extern char *smb_errstr(int, int);
extern void print_data(const unsigned char *, int);
extern void l2tp_print(const u_char *, u_int);
extern void lcp_print(const u_char *, u_int);
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 vrrp_print(const u_char *, u_int, int);
extern void cdp_print(const u_char *, u_int, u_int, const u_char *,
const u_char *);
extern void stp_print(const u_char *, u_int);
extern void radius_print(const u_char *, u_int);
extern void lwres_print(const u_char *, u_int);
extern void pptp_print(const u_char *, u_int);
extern void sctp_print(const u_char *, const u_char *, u_int);
extern void mpls_print(const u_char *, u_int);
extern void zephyr_print(const u_char *, int);
extern void hsrp_print(const u_char *, u_int);
#ifdef INET6
extern void ip6_print(const u_char *, int);
extern void ip6_print(const u_char *, u_int);
extern void ip6_opt_print(const u_char *, int);
extern int hbhopt_print(const u_char *);
extern int dstopt_print(const u_char *);
extern int frag6_print(const u_char *, const u_char *);
extern void icmp6_print(const u_char *, const u_char *);
extern void ripng_print(const u_char *, int);
extern void ripng_print(const u_char *, unsigned 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_int16_t, u_int16_t);
#endif /*INET6*/
extern u_short in_cksum(const u_short *addr, register int len, u_short csum);
extern u_short in_cksum(const u_short *, register u_int, int);
#ifndef HAVE_BPF_DUMP
struct bpf_program;
extern void bpf_dump(struct bpf_program *, int);
#endif

View File

@ -1,7 +1,7 @@
/*
* IPX protocol formats
*
* @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.2 2000/10/03 02:54:56 itojun Exp $
* @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.4 2001/01/15 03:23:59 guy Exp $
*/
/* well-known sockets */
@ -10,6 +10,8 @@
#define IPX_SKT_RIP 0x0453
#define IPX_SKT_NETBIOS 0x0455
#define IPX_SKT_DIAGNOSTICS 0x0456
#define IPX_SKT_NWLINK_DGM 0x0553 /* NWLink datagram, may contain SMB */
#define IPX_SKT_EIGRP 0x85be /* Cisco EIGRP over IPX */
/* IPX transport header */
struct ipxHdr {

View File

@ -1,4 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.4 2000/12/17 23:07:49 guy Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.5 2001/11/05 10:03:27 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@ -55,29 +55,8 @@
#define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */
#define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */
#define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */
#define L2TP_AUTHEN_TYPE_MSCHAP 0x0005 /* MSCHAPv1 */
#define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */
#define L2TP_PROXY_AUTH_ID_MASK 0x00ff
struct l2tp_avp_vec {
const char *name;
void (*print)(const u_char *, u_int32_t);
};
struct l2tp_call_errors {
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_int16_t reserved;
u_int32_t send_accm;
u_int32_t recv_accm;
};

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.8 2000/12/18 07:55:36 guy Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.13 2001/06/04 05:47:13 guy Exp $ (LBL)
*/
/*
@ -51,8 +51,8 @@ struct llc {
#define llcui ctl.snap.snap_ui
#define llcpi ctl.snap.snap_pi
#define orgcode ctl.snap_ether.snap_orgcode
#define ethertype ctl.snap_ether.snap_ethertype
#define llc_orgcode ctl.snap_ether.snap_orgcode
#define llc_ethertype ctl.snap_ether.snap_ethertype
#define llcis ctl.is_ctl
#define llcu ctl.u_ctl
@ -88,10 +88,10 @@ struct llc {
#ifndef LLCSAP_GLOBAL
#define LLCSAP_GLOBAL 0xff
#endif
#ifndef LLCSAP_8021B
#ifndef LLCSAP_8021B_I
#define LLCSAP_8021B_I 0x02
#endif
#ifndef LLCSAP_8021B
#ifndef LLCSAP_8021B_G
#define LLCSAP_8021B_G 0x03
#endif
#ifndef LLCSAP_IP
@ -115,6 +115,18 @@ struct llc {
#ifndef LLCSAP_SNAP
#define LLCSAP_SNAP 0xaa
#endif
#ifndef LLCSAP_IPX
#define LLCSAP_IPX 0xe0
#endif
#ifndef LLCSAP_NETBEUI
#define LLCSAP_NETBEUI 0xf0
#endif
#ifndef LLCSAP_ISONS
#define LLCSAP_ISONS 0xfe
#endif
#define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */
#define OUI_CISCO 0x00000c /* Cisco protocols */
#define ETHERTYPE_CISCO_CDP 0x2000 /* Cisco Discovery Protocol */
#define OUI_CISCO_90 0x0000f8 /* Cisco bridging */
#define OUI_APPLETALK 0x080007 /* Appletalk */

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.6 2000/01/17 06:24:23 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.7 2001/06/27 05:42:04 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -32,7 +32,16 @@ static const char rcsid[] =
#ifdef __osf__
#include <sys/sysinfo.h>
#include <sys/proc.h>
#endif
#if !defined(HAVE_SNPRINTF)
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#endif /* HAVE___ATTRIBUTE__ */
int snprintf(char *, size_t, const char *, ...)
__attribute__((format(printf, 3, 4)));
#endif /* !defined(HAVE_SNPRINTF) */
#endif /* __osf__ */
#include "machdep.h"

View File

@ -1,20 +1,33 @@
#!/bin/sh
#
# Copyright (c) 1990, 1996, by John Robert LoVerso.
# All rights reserved.
# SMIv2 parsing copyright (c) 1999 by William C. Fenner.
# Copyright (c) 1990, 1996
# John Robert LoVerso. All rights reserved.
# SMIv2 parsing copyright (c) 1999
# William C. Fenner.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by John Robert LoVerso.
# 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.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# @(#) $Id: makemib,v 1.2 1999/11/21 17:24:15 fenner Exp $ (jlv)
# 1. Redistributions of source code must retain the above copyright
# notices, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notices, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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: makemib,v 1.3 2001/09/17 22:16:52 fenner Exp $ (jlv)
#
# This script will read either ASN.1-style MIB files or the ".defs" files

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
/* $Id: snprintf.c,v 1.4 2001/01/02 22:33:04 guy Exp $ */
/* $Id: snprintf.c,v 1.5 2001/01/12 10:14:40 guy Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -39,7 +39,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.4 2001/01/02 22:33:04 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.5 2001/01/12 10:14:40 guy Exp $";
#endif
#include <stdio.h>
@ -93,6 +93,7 @@ sn_append_char (struct state *state, unsigned char c)
}
#endif
#if 0
static int
as_reserve (struct state *state, size_t n)
{
@ -126,6 +127,7 @@ as_append_char (struct state *state, unsigned char c)
return 0;
}
}
#endif
static int
append_number(struct state *state,
@ -490,6 +492,7 @@ snprintf (char *str, size_t sz, const char *format, ...)
}
#endif
#if 0
#ifndef HAVE_ASPRINTF
int
asprintf (char **ret, const char *format, ...)
@ -600,6 +603,7 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
}
}
#endif
#endif
#ifndef HAVE_VSNPRINTF
int

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 1988, 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 defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/strdup.c,v 1.1 2001/01/20 07:26:08 guy Exp $ (LBL)";
#endif /* LIBC_SCCS and not lint */
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "interface.h"
char *
strdup(str)
const char *str;
{
size_t len;
char *copy;
len = strlen(str) + 1;
if ((copy = malloc(len)) == NULL)
return (NULL);
memcpy(copy, str, len);
return (copy);
}

View File

@ -1,4 +1,4 @@
/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.5 2000/12/28 20:30:41 itojun Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.9 2001/06/27 05:40:16 guy Exp $ (LBL) */
/*
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -95,6 +95,23 @@
#define ZONEINIT 0xe /* initial zone transfer */
#define ZONEREF 0xf /* incremental zone referesh */
/*
* Undefine various #defines from various System V-flavored OSes (Solaris,
* SINIX, HP-UX) so the compiler doesn't whine that we redefine them.
*/
#ifdef T_NULL
#undef T_NULL
#endif
#ifdef T_OPT
#undef T_OPT
#endif
#ifdef T_UNSPEC
#undef T_UNSPEC
#endif
#ifdef NOERROR
#undef NOERROR
#endif
/*
* Currently defined response codes
*/
@ -128,14 +145,36 @@
#define T_TXT 16 /* text strings */
#define T_RP 17 /* responsible person */
#define T_AFSDB 18 /* AFS cell database */
#define T_X25 19 /* X_25 calling address */
#define T_ISDN 20 /* ISDN calling address */
#define T_RT 21 /* router */
#define T_NSAP 22 /* NSAP address */
#define T_NSAP_PTR 23 /* reverse lookup for NSAP */
#define T_SIG 24 /* security signature */
#define T_KEY 25 /* security key */
#define T_PX 26 /* X.400 mail mapping */
#define T_GPOS 27 /* geographical position (withdrawn) */
#define T_AAAA 28 /* IP6 Address */
#define T_LOC 29 /* Location Information */
#define T_NXT 30 /* Next Valid Name in Zone */
#define T_EID 31 /* Endpoint identifier */
#define T_NIMLOC 32 /* Nimrod locator */
#define T_SRV 33 /* Server selection */
#define T_ATMA 34 /* ATM Address */
#define T_NAPTR 35 /* Naming Authority PoinTeR */
#define T_A6 38 /* IP6 address */
#define T_DNAME 39 /* non-terminal redirection */
#define T_OPT 41 /* EDNS0 option (meta-RR) */
/* 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) */
#define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */
/* Query type values which do not appear in resource records */
#define T_TKEY 249 /* Transaction Key [RFC2930] */
#define T_TSIG 250 /* Transaction Signature [RFC2845] */
#define T_IXFR 251 /* incremental transfer [RFC1995] */
#define T_AXFR 252 /* transfer zone of authority */
#define T_MAILB 253 /* transfer mailbox records */
#define T_MAILA 254 /* transfer mail agent records */

View File

@ -1,12 +1,45 @@
/* @(#) $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.12 2001/09/17 21:57:52 fenner Exp $ (LBL) */
/*
* $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.9 2000/06/01 01:16:36 assar Exp $
* Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation,
* Western Research Laboratory. All rights reserved.
* Copyright (c) 2001 Compaq Computer Corporation. All rights reserved.
*
* Permission to use, copy, and modify this software and its
* documentation is hereby granted only under the following terms and
* conditions. Both the above copyright notice and this permission
* notice must appear in all copies of the software, derivative works
* or modified versions, and any portions thereof, and both notices
* must appear in supporting documentation.
*
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND COMPAQ COMPUTER CORPORATION
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL COMPAQ COMPUTER 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.
*/
/*
* nfsfh.h - NFS file handle definitions (for portable use)
*
* Jeffrey C. Mogul
* Digital Equipment Corporation
* Western Research Laboratory
* $NetBSD: nfsfh.h,v 1.1.1.2 1997/10/03 17:25:13 christos Exp $ */
*/
/*
* Internal representation of dev_t, because different NFS servers
@ -32,4 +65,4 @@ typedef struct {
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
dev_eq(a.Fsid_dev, b.Fsid_dev))
extern void Parse_fh(caddr_t *, int, my_fsid *, ino_t *, char **, char **, int);
extern void Parse_fh(caddr_t *, int, my_fsid *, ino_t *, const char **, const char **, int);

View File

@ -1,3 +1,36 @@
/*
* Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation,
* Western Research Laboratory. All rights reserved.
* Copyright (c) 2001 Compaq Computer Corporation. All rights reserved.
*
* Permission to use, copy, and modify this software and its
* documentation is hereby granted only under the following terms and
* conditions. Both the above copyright notice and this permission
* notice must appear in all copies of the software, derivative works
* or modified versions, and any portions thereof, and both notices
* must appear in supporting documentation.
*
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND COMPAQ COMPUTER CORPORATION
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL COMPAQ COMPUTER 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.
*/
/*
* parsenfsfh.c - portable parser for NFS file handles
* uses all sorts of heuristics
@ -9,7 +42,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.18 2000/07/01 03:39:00 assar Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.23 2001/09/17 21:57:53 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -83,8 +116,8 @@ register caddr_t *fh;
int len;
my_fsid *fsidp;
ino_t *inop;
char **osnamep; /* if non-NULL, return OS name here */
char **fsnamep; /* if non-NULL, return server fs name here (for VMS) */
const char **osnamep; /* if non-NULL, return OS name here */
const char **fsnamep; /* if non-NULL, return server fs name here (for VMS) */
int ourself; /* true if file handle was generated on this host */
{
register unsigned char *fhp = (unsigned char *)fh;
@ -369,17 +402,15 @@ 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");
#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]);
(void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X", fhp[i]);
/* XXX for now, give "bogus" values to aid debugging */
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.11 2000/10/09 01:53:19 guy Exp $ (LBL) */
/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.12 2001/02/04 02:17:55 fenner Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
@ -33,6 +33,7 @@
#define PPP_STII 0x0033 /* Stream Protocol (ST-II) */
#define PPP_VINES 0x0035 /* Banyan Vines */
#define PPP_IPV6 0x0057 /* IPv6 */
#define PPP_COMP 0x00fd /* Compressed Datagram */
#define PPP_HELLO 0x0201 /* 802.1d Hello Packets */
#define PPP_LUXCOM 0x0231 /* Luxcom */

View File

@ -0,0 +1,858 @@
/*
* Copyright (c) 2001
* Fortress Technologies, Inc. All rights reserved.
* Charlie Lenahan (clenahan@fortresstech.com)
*
* 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-802_11.c,v 1.6 2001/09/17 21:57:53 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <pcap.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
#include "ieee802_11.h"
#define RATEStoBUF(p, buf) \
do { \
int z = 0; \
for (z = 0 ; z < p.rates.length ; z++) \
snprintf(buf, sizeof(buf), "%s %2.1f", buf, (.5 * (p.rates.rate[z] & 0x7f))); \
} while (0)
static const char *auth_alg_text[]={"Open System","Shared Key","EAP"};
static const char *subtype_text[]={
"Assoc Request",
"Assoc Response",
"ReAssoc Request",
"ReAssoc Response",
"Probe Request",
"Probe Response",
"RESERVED",
"RESERVED",
"Beacon",
"ATIM",
"Disassociation",
"Authentication",
"DeAuthentication",
"RESERVED",
"RESERVED"
};
static const char *status_text[] = {
"Succesful", /* 0 */
"Unspecified failure", /* 1 */
"Reserved", /* 2 */
"Reserved", /* 3 */
"Reserved", /* 4 */
"Reserved", /* 5 */
"Reserved", /* 6 */
"Reserved", /* 7 */
"Reserved", /* 8 */
"Reserved", /* 9 */
"Cannot Support all requested capabilities in the Capability Information field", /* 10 */
"Reassociation denied due to inability to confirm that association exists", /* 11 */
"Association denied due to reason outside the scope of the standard", /* 12 */
"Responding station does not support the specified authentication algorithm ", /* 13 */
"Received an Authentication frame with authentication transaction " \
"sequence number out of expected sequence", /* 14 */
"Authentication rejected because of challenge failure", /* 15 */
"Authentication rejected due to timeout waiting for next frame in sequence", /* 16 */
"Association denied because AP is unable to handle additional associated stations", /* 17 */
"Association denied due to requesting station not supporting all of the " \
"data rates in BSSBasicRateSet parameter", /* 18 */
NULL
};
static const char *reason_text[] = {
"Reserved", /* 0 */
"Unspecified reason", /* 1 */
"Previous authentication no longer valid", /* 2 */
"Deauthenticated because sending station is leaving (or has left) IBSS or ESS", /* 3 */
"Disassociated due to inactivity", /* 4 */
"Disassociated because AP is unable to handle all currently associated stations", /* 5 */
"Class 2 frame receivedfrom nonauthenticated station", /* 6 */
"Class 3 frame received from nonassociated station", /* 7 */
"Disassociated because sending station is leaving (or has left) BSS", /* 8 */
"Station requesting (re)association is not authenticated with responding station", /* 9 */
NULL
};
static int wep_print(const u_char *p,u_int length)
{
u_int32_t iv;
if (!TTEST2(*p, 4))
return 0;
iv = EXTRACT_LE_32BITS(p);
printf("Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
IV_KEYID(iv));
return 1;
}
static int parse_elements(struct mgmt_body_t *pbody,const u_char *p,int offset)
{
for (;;) {
if (!TTEST2(*(p + offset), 1))
return 0;
if (*(p + offset) == 0xff)
break;
switch (*(p + offset)) {
case E_SSID:
if (!TTEST2(*(p+offset), 2))
return 0;
memcpy(&(pbody->ssid),p+offset,2); offset += 2;
if (pbody->ssid.length > 0)
{
if (!TTEST2(*(p+offset), pbody->ssid.length))
return 0;
memcpy(&(pbody->ssid.ssid),p+offset,pbody->ssid.length); offset += pbody->ssid.length;
pbody->ssid.ssid[pbody->ssid.length]='\0';
}
break;
case E_CHALLENGE:
if (!TTEST2(*(p+offset), 2))
return 0;
memcpy(&(pbody->challenge),p+offset,2); offset += 2;
if (pbody->challenge.length > 0)
{
if (!TTEST2(*(p+offset), pbody->challenge.length))
return 0;
memcpy(&(pbody->challenge.text),p+offset,pbody->challenge.length); offset += pbody->challenge.length;
pbody->challenge.text[pbody->challenge.length]='\0';
}
break;
case E_RATES:
if (!TTEST2(*(p+offset), 2))
return 0;
memcpy(&(pbody->rates),p+offset,2); offset += 2;
if (pbody->rates.length > 0) {
if (!TTEST2(*(p+offset), pbody->rates.length))
return 0;
memcpy(&(pbody->rates.rate),p+offset,pbody->rates.length); offset += pbody->rates.length;
}
break;
case E_DS:
if (!TTEST2(*(p+offset), 3))
return 0;
memcpy(&(pbody->ds),p+offset,3); offset +=3;
break;
case E_CF:
if (!TTEST2(*(p+offset), 8))
return 0;
memcpy(&(pbody->cf),p+offset,8); offset +=8;
break;
case E_TIM:
if (!TTEST2(*(p+offset), 2))
return 0;
memcpy(&(pbody->tim),p+offset,2); offset +=2;
if (!TTEST2(*(p+offset), 3))
return 0;
memcpy(&(pbody->tim.count),p+offset,3); offset +=3;
if ((pbody->tim.length -3) > 0)
{
if (!TTEST2(*(p+offset), pbody->tim.length -3))
return 0;
memcpy((pbody->tim.bitmap),p+(pbody->tim.length -3),(pbody->tim.length -3));
offset += pbody->tim.length -3;
}
break;
default:
#if 0
printf("(1) unhandled element_id (%d) ", *(p+offset) );
#endif
offset+= *(p+offset+1) + 2;
break;
}
}
return 1;
}
/*********************************************************************************
* Print Handle functions for the management frame types
*********************************************************************************/
static int handle_beacon(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
char buf[128];
memset(buf, 0, sizeof(buf));
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 12))
return 0;
memcpy(&pbody.timestamp, p, 8);
offset += 8;
pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
offset += 2;
pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
offset += 2;
if (!parse_elements(&pbody,p,offset))
return 0;
RATEStoBUF(pbody, buf);
printf("%s (%s) [%s Mbit] %s CH: %x %s",
subtype_text[FC_SUBTYPE(fc)], pbody.ssid.ssid, buf,
CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS",
pbody.ds.channel,
CAPABILITY_PRIVACY(pbody.capability_info) ? ", PRIVACY" : "" );
return 1;
}
static int handle_assoc_request(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
char buf[128];
memset(buf, 0, sizeof(buf));
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 4))
return 0;
pbody.capability_info = EXTRACT_LE_16BITS(p);
offset += 2;
pbody.listen_interval = EXTRACT_LE_16BITS(p+offset);
offset += 2;
if (!parse_elements(&pbody,p,offset))
return 0;
RATEStoBUF(pbody,buf);
printf("%s (%s) [%s Mbit] ",
subtype_text[FC_SUBTYPE(fc)], pbody.ssid.ssid,buf);
return 1;
}
static int handle_assoc_response(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 6))
return 0;
pbody.capability_info = EXTRACT_LE_16BITS(p);
offset += 2;
pbody.status_code = EXTRACT_LE_16BITS(p+offset);
offset += 2;
pbody.aid = EXTRACT_LE_16BITS(p+offset);
offset += 2;
if (!parse_elements(&pbody,p,offset))
return 0;
printf("%s AID(%x) :%s: %s ", subtype_text[FC_SUBTYPE(fc)],
((u_int16_t)(pbody.aid << 2 )) >> 2 ,
CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "",
(pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a"));
return 1;
}
static int handle_reassoc_request(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 10))
return 0;
pbody.capability_info = EXTRACT_LE_16BITS(p);
offset += 2;
pbody.listen_interval = EXTRACT_LE_16BITS(p+offset);
offset += 2;
memcpy(&pbody.ap,p+offset,6);
offset += 6;
if (!parse_elements(&pbody,p,offset))
return 0;
printf("%s (%s) AP : %s",subtype_text[FC_SUBTYPE(fc)], pbody.ssid.ssid, etheraddr_string( pbody.ap ));
return 1;
}
static int handle_reassoc_response(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
/* Same as a Association Reponse */
return handle_assoc_response(fc,pmh,p);
}
static int handle_probe_request(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
char buf[128];
memset(buf, 0, sizeof(buf));
memset(&pbody, 0, sizeof(pbody));
if (!parse_elements(&pbody, p, offset))
return 0;
RATEStoBUF(pbody, buf);
printf("%s (%s) [%s Mbit] ", subtype_text[FC_SUBTYPE(fc)],
pbody.ssid.ssid,buf);
return 1;
}
static int handle_probe_response(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
char buf[128];
memset(buf, 0, sizeof(buf));
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 12))
return 0;
memcpy(&pbody.timestamp,p,8);
offset += 8;
pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
offset += 2;
pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
offset += 2;
if (!parse_elements(&pbody, p, offset))
return 0;
printf("%s (%s) CH: %x %s", subtype_text[FC_SUBTYPE(fc)], pbody.ssid.ssid,pbody.ds.channel,
CAPABILITY_PRIVACY(pbody.capability_info) ? ",PRIVACY " : "" );
return 1;
}
static int handle_atim(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
/* the frame body for ATIM is null. */
printf("ATIM");
return 1;
}
static int handle_disassoc(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 2))
return 0;
pbody.reason_code = EXTRACT_LE_16BITS(p);
offset += 2;
printf("%s: %s ", subtype_text[FC_SUBTYPE(fc)],
pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" );
return 1;
}
static int handle_auth(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 6))
return 0;
pbody.auth_alg = EXTRACT_LE_16BITS(p);
offset += 2;
pbody.auth_trans_seq_num = EXTRACT_LE_16BITS(p + offset);
offset += 2;
pbody.status_code = EXTRACT_LE_16BITS(p + offset);
offset += 2;
if (!parse_elements(&pbody,p,offset))
return 0;
if ((pbody.auth_alg == 1) &&
((pbody.auth_trans_seq_num == 2) || (pbody.auth_trans_seq_num == 3))) {
printf("%s (%s)-%x [Challenge Text] %s",
subtype_text[FC_SUBTYPE(fc)],
pbody.auth_alg < 4 ? auth_alg_text[pbody.auth_alg] : "Reserved" ,
pbody.auth_trans_seq_num,
((pbody.auth_trans_seq_num % 2) ?
(pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a") : "" ));
} else {
printf("%s (%s)-%x: %s",
subtype_text[FC_SUBTYPE(fc)],
pbody.auth_alg < 4 ? auth_alg_text[pbody.auth_alg] : "Reserved" ,
pbody.auth_trans_seq_num,
((pbody.auth_trans_seq_num % 2) ? (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a") : ""));
}
return 1;
}
static int handle_deauth(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p)
{
struct mgmt_body_t pbody;
int offset = 0;
memset(&pbody, 0, sizeof(pbody));
if (!TTEST2(*p, 2))
return 0;
pbody.reason_code = EXTRACT_LE_16BITS(p);
offset += 2;
if (eflag) {
printf("%s: %s",
subtype_text[FC_SUBTYPE(fc)],
pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" );
} else {
printf("%s (%s): %s",
subtype_text[FC_SUBTYPE(fc)], etheraddr_string(pmh->sa),
pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" );
}
return 1;
}
/*********************************************************************************
* Print Body funcs
*********************************************************************************/
static int mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
const u_char *p, u_int length)
{
switch (FC_SUBTYPE(fc)) {
case ST_ASSOC_REQUEST:
return (handle_assoc_request(fc, pmh, p));
case ST_ASSOC_RESPONSE:
return (handle_assoc_response(fc, pmh, p));
case ST_REASSOC_REQUEST:
return (handle_reassoc_request(fc, pmh, p));
case ST_REASSOC_RESPONSE:
return (handle_reassoc_response(fc, pmh, p));
case ST_PROBE_REQUEST:
return (handle_probe_request(fc, pmh, p));
case ST_PROBE_RESPONSE:
return (handle_probe_response(fc, pmh, p));
case ST_BEACON:
return (handle_beacon(fc, pmh, p));
case ST_ATIM:
return (handle_atim(fc, pmh, p));
case ST_DISASSOC:
return (handle_disassoc(fc, pmh, p));
case ST_AUTH:
if (!TTEST2(*p, 3))
return 0;
if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) {
printf("Authentication (Shared-Key)-3 ");
return (wep_print(p, length));
}
else
return (handle_auth(fc, pmh, p));
case ST_DEAUTH:
return (handle_deauth(fc, pmh, p));
break;
default:
printf("Unhandled Managment subtype(%x)",
FC_SUBTYPE(fc));
return 1;
}
}
/*********************************************************************************
* Handles printing all the control frame types
*********************************************************************************/
static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length)
{
switch (FC_SUBTYPE(fc)) {
case CTRL_PS_POLL:
if (!TTEST2(*p, CTRL_PS_POLL_LEN))
return 0;
printf("Power Save-Poll AID(%x)",
EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid)));
break;
case CTRL_RTS:
if (!TTEST2(*p, CTRL_RTS_LEN))
return 0;
if (eflag)
printf("Request-To-Send");
else
printf("Request-To-Send TA:%s ",
etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
break;
case CTRL_CTS:
if (!TTEST2(*p, CTRL_CTS_LEN))
return 0;
if (eflag)
printf("Clear-To-Send");
else
printf("Clear-To-Send RA:%s ",
etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
break;
case CTRL_ACK:
if (!TTEST2(*p, CTRL_ACK_LEN))
return 0;
if (eflag)
printf("Acknowledgment");
else
printf("Acknowledgment RA:%s ",
etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
break;
case CTRL_CF_END:
if (!TTEST2(*p, CTRL_END_LEN))
return 0;
if (eflag)
printf("CF-End");
else
printf("CF-End RA:%s ",
etheraddr_string(((const struct ctrl_end_t *)p)->ra));
break;
case CTRL_END_ACK:
if (!TTEST2(*p, CTRL_END_ACK_LEN))
return 0;
if (eflag)
printf("CF-End+CF-Ack");
else
printf("CF-End+CF-Ack RA:%s ",
etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra));
break;
default:
printf("(B) Unknown Ctrl Subtype");
}
return 1;
}
/*
* Print Header funcs
*/
/*
* Data Frame - Address field contents
*
* To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4
* 0 | 0 | DA | SA | BSSID | n/a
* 0 | 1 | DA | BSSID | SA | n/a
* 1 | 0 | BSSID | SA | DA | n/a
* 1 | 1 | RA | TA | DA | SA
*/
static void data_header_print(u_int16_t fc,const u_char *p, u_int length)
{
#define ADDR1 (p + 4)
#define ADDR2 (p + 10)
#define ADDR3 (p + 16)
#define ADDR4 (p + 24)
if (!FC_TO_DS(fc)) {
if (!FC_FROM_DS(fc))
printf("DA:%s SA:%s BSSID:%s ",
etheraddr_string(ADDR1), etheraddr_string(ADDR2),
etheraddr_string(ADDR3));
else
printf("DA:%s BSSID:%s SA:%s ",
etheraddr_string(ADDR1), etheraddr_string(ADDR2),
etheraddr_string(ADDR3));
} else {
if (!FC_FROM_DS(fc))
printf("BSSID:%s SA:%s DA:%s ",
etheraddr_string(ADDR1), etheraddr_string(ADDR2),
etheraddr_string(ADDR3));
else
printf("RA:%s TA:%s DA:%s SA:%s ",
etheraddr_string(ADDR1), etheraddr_string(ADDR2),
etheraddr_string(ADDR3), etheraddr_string(ADDR4));
}
#undef ADDR1
#undef ADDR2
#undef ADDR3
#undef ADDR4
}
static void mgmt_header_print(const u_char *p, u_int length)
{
const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
printf("BSSID:%s DA:%s SA:%s ",
etheraddr_string((hp)->bssid), etheraddr_string((hp)->da),
etheraddr_string((hp)->sa));
}
static void ctrl_header_print(u_int16_t fc,const u_char *p, u_int length)
{
switch (FC_SUBTYPE(fc)) {
case CTRL_PS_POLL:
printf("BSSID:%s TA:%s ",
etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid),
etheraddr_string(((const struct ctrl_ps_poll_t *)p)->ta));
break;
case CTRL_RTS:
printf("RA:%s TA:%s ",
etheraddr_string(((const struct ctrl_rts_t *)p)->ra),
etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
break;
case CTRL_CTS:
printf("RA:%s ",
etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
break;
case CTRL_ACK:
printf("RA:%s ",
etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
break;
case CTRL_CF_END:
printf("RA:%s BSSID:%s ",
etheraddr_string(((const struct ctrl_end_t *)p)->ra),
etheraddr_string(((const struct ctrl_end_t *)p)->bssid));
break;
case CTRL_END_ACK:
printf("RA:%s BSSID:%s ",
etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra),
etheraddr_string(((const struct ctrl_end_ack_t *)p)->bssid));
break;
default:
printf("(H) Unknown Ctrl Subtype");
}
}
static int GetHeaderLength(u_int16_t fc)
{
int iLength=0;
switch (FC_TYPE(fc)) {
case T_MGMT:
iLength = MGMT_HEADER_LEN;
break;
case T_CTRL:
switch (FC_SUBTYPE(fc)) {
case CTRL_PS_POLL:
iLength = CTRL_PS_POLL_LEN;
break;
case CTRL_RTS:
iLength = CTRL_RTS_LEN;
break;
case CTRL_CTS:
iLength = CTRL_CTS_LEN;
break;
case CTRL_ACK:
iLength = CTRL_ACK_LEN;
break;
case CTRL_CF_END:
iLength = CTRL_END_LEN;
break;
case CTRL_END_ACK:
iLength = CTRL_END_ACK_LEN;
break;
default:
iLength = 0;
break;
}
break;
case T_DATA:
if (FC_TO_DS(fc) && FC_FROM_DS(fc))
iLength = 30;
else
iLength = 24;
break;
default:
printf("unknown IEEE802.11 frame type (%d)",
FC_TYPE(fc));
break;
}
return iLength;
}
/*
* Print the 802.11 MAC header
*/
static inline void
ieee_802_11_print(u_int16_t fc, const u_char *p, u_int length)
{
switch (FC_TYPE(fc)) {
case T_MGMT:
mgmt_header_print(p, length);
break;
case T_CTRL:
ctrl_header_print(fc, p, length);
break;
case T_DATA:
data_header_print(fc, p, length);
break;
default:
printf("(header) unknown IEEE802.11 frame type (%d)",
FC_TYPE(fc));
break;
}
}
/*
* This is the top level routine of the printer. 'p' is the points
* to the ether header of the packet, 'h->tv' is the timestamp,
* 'h->length' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
void
ieee802_11_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
u_int16_t fc;
u_int HEADER_LENGTH;
u_short extracted_ethertype;
++infodelay;
ts_print(&h->ts);
if (caplen < IEEE802_11_FC_LEN) {
printf("[|802.11]");
goto out;
}
fc=EXTRACT_LE_16BITS(p);
if (eflag)
ieee_802_11_print(fc, p, length);
/*
* Some printers want to get back at the ethernet addresses,
* and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
packetp = p;
snapend = p + caplen;
HEADER_LENGTH=GetHeaderLength(fc);
length -= HEADER_LENGTH;
caplen -= HEADER_LENGTH;
p += HEADER_LENGTH;
switch (FC_TYPE(fc)) {
case T_MGMT:
if (!mgmt_body_print(fc, (const struct mgmt_header_t *)packetp,
p, length)) {
printf("[|802.11]");
goto out;
}
break;
case T_CTRL:
if (!ctrl_body_print(fc, p - HEADER_LENGTH,
length + HEADER_LENGTH)) {
printf("[|802.11]");
goto out;
}
break;
case T_DATA:
/* There may be a problem w/ AP not having this bit set */
if (FC_WEP(fc)) {
if (!wep_print(p,length)) {
printf("[|802.11]");
goto out;
}
} else {
if (llc_print(p, length, caplen, packetp + 10,
packetp + 4, &extracted_ethertype) == 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!eflag)
ieee_802_11_print(fc, p - HEADER_LENGTH,
length + HEADER_LENGTH);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
}
if (!xflag && !qflag)
default_print(p, caplen);
}
}
break;
default:
printf("(body) unhandled IEEE802.11 frame type (%d)",
FC_TYPE(fc));
break;
}
if (xflag)
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.14 2000/12/12 09:58:40 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.15 2001/09/17 21:57:54 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -52,11 +52,10 @@ ah_print(register const u_char *bp, register const u_char *bp2)
int sumlen;
u_int32_t spi;
ah = (struct ah *)bp;
ah = (const struct ah *)bp;
ep = snapend; /* 'ep' points to the end of available data. */
if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
goto trunc;
TCHECK(*ah);
sumlen = ah->ah_len << 2;
spi = (u_int32_t)ntohl(ah->ah_spi);
@ -64,7 +63,7 @@ ah_print(register const u_char *bp, register const u_char *bp2)
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)));
printf(",seq=0x%x", (u_int32_t)ntohl(*(const u_int32_t *)(ah + 1)));
if (bp + sizeof(struct ah) + sumlen > ep)
fputs("[truncated]", stdout);
fputs("): ", stdout);

View File

@ -0,0 +1,248 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.6 2001/09/17 21:57:54 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
struct mbuf;
struct rtentry;
#include <netinet/in.h>
#include <stdio.h>
#include <pcap.h>
#include "interface.h"
#include "arcnet.h"
int arcnet_encap_print(u_char arctype, const u_char *p,
u_int length, u_int caplen);
struct tok arctypemap[] = {
{ ARCTYPE_IP_OLD, "oldip" },
{ ARCTYPE_ARP_OLD, "oldarp" },
{ ARCTYPE_IP, "ip" },
{ ARCTYPE_ARP, "arp" },
{ ARCTYPE_REVARP, "rarp" },
{ ARCTYPE_ATALK, "atalk" },
{ ARCTYPE_BANIAN, "banyan" },
{ ARCTYPE_IPX, "ipx" },
{ ARCTYPE_INET6, "ipv6" },
{ ARCTYPE_DIAGNOSE, "diag" },
{ 0, 0 }
};
static inline void
arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
{
const struct arc_header *ap;
const char *arctypename;
ap = (const struct arc_header *)bp;
if (qflag) {
(void)printf("%02x %02x %d: ",
ap->arc_shost,
ap->arc_dhost,
length);
return;
}
arctypename = tok2str(arctypemap, "%02x", ap->arc_type);
if (!phds) {
(void)printf("%02x %02x %s %d: ",
ap->arc_shost, ap->arc_dhost, arctypename,
length);
return;
}
if (flag == 0) {
(void)printf("%02x %02x %s seqid %04x %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
length);
return;
}
if (flag & 1)
(void)printf("%02x %02x %s seqid %04x "
"(first of %d fragments) %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
(flag + 3) / 2, length);
else
(void)printf("%02x %02x %s seqid %04x "
"(fragment %d) %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
flag/2 + 1, length);
}
/*
* This is the top level routine of the printer. 'p' is the points
* to the ether header of the packet, 'tvp' is the timestamp,
* 'length' is the length of the packet off the wire, and 'caplen'
* is the number of bytes actually captured.
*/
void
arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
const struct arc_header *ap;
int phds, flag = 0, archdrlen = 0;
u_int seqid = 0;
u_char arc_type;
++infodelay;
ts_print(&h->ts);
if (caplen < ARC_HDRLEN) {
printf("[|arcnet]");
goto out;
}
ap = (const struct arc_header *)p;
arc_type = ap->arc_type;
switch (arc_type) {
default:
phds = 1;
break;
case ARCTYPE_IP_OLD:
case ARCTYPE_ARP_OLD:
case ARCTYPE_DIAGNOSE:
phds = 0;
archdrlen = ARC_HDRLEN;
break;
}
if (phds) {
if (caplen < ARC_HDRNEWLEN) {
arcnet_print(p, length, 0, 0, 0);
printf("[|phds]");
goto out;
}
if (ap->arc_flag == 0xff) {
if (caplen < ARC_HDRNEWLEN_EXC) {
arcnet_print(p, length, 0, 0, 0);
printf("[|phds extended]");
goto out;
}
flag = ap->arc_flag2;
seqid = ap->arc_seqid2;
archdrlen = ARC_HDRNEWLEN_EXC;
} else {
flag = ap->arc_flag;
seqid = ap->arc_seqid;
archdrlen = ARC_HDRNEWLEN;
}
}
if (eflag)
arcnet_print(p, length, phds, flag, seqid);
/*
* Some printers want to get back at the ethernet addresses,
* and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
packetp = p;
snapend = p + caplen;
length -= archdrlen;
caplen -= archdrlen;
p += archdrlen;
if (phds && flag && (flag & 1) == 0)
goto out2;
if (!arcnet_encap_print(arc_type, p, length, caplen)) {
default_print(p, caplen);
goto out;
}
out2:
if (xflag)
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}
/*
* Prints the packet encapsulated in an ARCnet data field,
* given the ARCnet system code.
*
* Returns non-zero if it can do so, zero if the system code is unknown.
*/
int
arcnet_encap_print(u_char arctype, const u_char *p,
u_int length, u_int caplen)
{
switch (arctype) {
case ARCTYPE_IP_OLD:
case ARCTYPE_IP:
ip_print(p, length);
return (1);
#ifdef INET6
case ARCTYPE_INET6:
ip6_print(p, length);
return (1);
#endif /*INET6*/
case ARCTYPE_ARP_OLD:
case ARCTYPE_ARP:
case ARCTYPE_REVARP:
arp_print(p, length, caplen);
return (1);
case ARCTYPE_ATALK: /* XXX was this ever used? */
if (vflag)
fputs("et1 ", stdout);
atalk_print(p, length);
return (1);
default:
return (0);
}
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.49 2000/10/10 05:05:07 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.51 2001/09/17 21:57:54 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -56,7 +56,10 @@ 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_ARCNET 7 /* arcnet hardware format */
#define ARPHRD_FRELAY 15 /* frame relay hardware format */
#define ARPHRD_STRIP 23 /* Ricochet Starmode Radio hardware format */
#define ARPHRD_IEEE1394 24 /* IEEE 1394 (FireWire) 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 */
@ -77,117 +80,86 @@ struct arphdr {
u_char ar_tha[]; /* target hardware address */
u_char ar_tpa[]; /* target protocol address */
#endif
#define ar_sha(ap) (((const caddr_t)((ap)+1))+0)
#define ar_spa(ap) (((const caddr_t)((ap)+1))+ (ap)->ar_hln)
#define ar_tha(ap) (((const caddr_t)((ap)+1))+ (ap)->ar_hln+(ap)->ar_pln)
#define ar_tpa(ap) (((const caddr_t)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
};
#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
#endif
#ifndef REVARP_REPLY
#define REVARP_REPLY 4
#endif
#define HRD(ap) ((ap)->ar_hrd)
#define HLN(ap) ((ap)->ar_hln)
#define PLN(ap) ((ap)->ar_pln)
#define OP(ap) ((ap)->ar_op)
#define PRO(ap) ((ap)->ar_pro)
#define SHA(ap) (ar_sha(ap))
#define SPA(ap) (ar_spa(ap))
#define THA(ap) (ar_tha(ap))
#define TPA(ap) (ar_tpa(ap))
static u_char ezero[6];
void
arp_print(register const u_char *bp, u_int length, u_int caplen)
arp_print(const u_char *bp, u_int length, u_int caplen)
{
register const struct ether_arp *ap;
register const struct ether_header *eh;
register u_short pro, hrd, op;
const struct arphdr *ap;
u_short pro, hrd, op;
ap = (struct ether_arp *)bp;
if ((u_char *)(ap + 1) > snapend) {
printf("[|arp]");
return;
}
if (length < ETHER_ARP_HDRLEN) {
ap = (const struct arphdr *)bp;
TCHECK(*ap);
if ((const u_char *)(ar_tpa(ap) + PLN(ap)) > snapend) {
(void)printf("truncated-arp");
default_print((u_char *)ap, length);
default_print((const u_char *)ap, length);
return;
}
pro = EXTRACT_16BITS(&ap->arp_pro);
hrd = EXTRACT_16BITS(&ap->arp_hrd);
op = EXTRACT_16BITS(&ap->arp_op);
pro = EXTRACT_16BITS(&PRO(ap));
hrd = EXTRACT_16BITS(&HRD(ap));
op = EXTRACT_16BITS(&OP(ap));
if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL)
|| ap->arp_hln != sizeof(SHA(ap))
|| ap->arp_pln != sizeof(SPA(ap))) {
if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) {
(void)printf("arp-#%d for proto #%d (%d) hardware #%d (%d)",
op, pro, ap->arp_pln,
hrd, ap->arp_hln);
op, pro, PLN(ap), hrd, HLN(ap));
return;
}
if (pro == ETHERTYPE_TRAIL)
(void)printf("trailer-");
eh = (struct ether_header *)packetp;
switch (op) {
case ARPOP_REQUEST:
(void)printf("arp who-has %s", ipaddr_string(TPA(ap)));
if (memcmp((char *)ezero, (char *)THA(ap), 6) != 0)
(void)printf(" (%s)", etheraddr_string(THA(ap)));
if (memcmp((const char *)ezero, (const char *)THA(ap), HLN(ap)) != 0)
(void)printf(" (%s)",
linkaddr_string(THA(ap), HLN(ap)));
(void)printf(" tell %s", ipaddr_string(SPA(ap)));
if (memcmp((char *)ESRC(eh), (char *)SHA(ap), 6) != 0)
(void)printf(" (%s)", etheraddr_string(SHA(ap)));
break;
case ARPOP_REPLY:
(void)printf("arp reply %s", ipaddr_string(SPA(ap)));
if (memcmp((char *)ESRC(eh), (char *)SHA(ap), 6) != 0)
(void)printf(" (%s)", etheraddr_string(SHA(ap)));
(void)printf(" is-at %s", etheraddr_string(SHA(ap)));
if (memcmp((char *)EDST(eh), (char *)THA(ap), 6) != 0)
(void)printf(" (%s)", etheraddr_string(THA(ap)));
(void)printf(" is-at %s", linkaddr_string(SHA(ap), HLN(ap)));
break;
case REVARP_REQUEST:
case ARPOP_REVREQUEST:
(void)printf("rarp who-is %s tell %s",
etheraddr_string(THA(ap)),
etheraddr_string(SHA(ap)));
linkaddr_string(THA(ap), HLN(ap)),
linkaddr_string(SHA(ap), HLN(ap)));
break;
case REVARP_REPLY:
case ARPOP_REVREPLY:
(void)printf("rarp reply %s at %s",
etheraddr_string(THA(ap)),
linkaddr_string(THA(ap), HLN(ap)),
ipaddr_string(TPA(ap)));
break;
default:
(void)printf("arp-#%d", op);
default_print((u_char *)ap, caplen);
default_print((const u_char *)ap, caplen);
return;
}
if (hrd != ARPHRD_ETHER)
printf(" hardware #%d", hrd);
return;
trunc:
(void)printf("[|arp]");
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.64 2000/10/30 06:22:14 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.70 2001/11/15 08:23:12 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -40,13 +40,13 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <netdb.h> /* for MAXHOSTNAMELEN on some platforms */
#include <pcap.h>
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h" /* must come after interface.h */
#include "appletalk.h"
#include "savestr.h"
static struct tok type2str[] = {
{ ddpRTMP, "rtmp" },
@ -83,6 +83,24 @@ static const char *ataddr_string(u_short, u_char);
static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char);
static const char *ddpskt_string(int);
/*
* Print LLAP packets received on a physical LocalTalk interface.
*/
void
ltalk_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
snapend = p + h->caplen;
++infodelay;
ts_print(&h->ts);
llap_print(p, h->caplen);
if(xflag)
default_print(p, h->caplen);
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}
/*
* Print AppleTalk LLAP packets.
*/
@ -94,7 +112,7 @@ llap_print(register const u_char *bp, u_int length)
register const struct atShortDDP *sdp;
u_short snet;
lp = (struct LAP *)bp;
lp = (const struct LAP *)bp;
bp += sizeof(*lp);
length -= sizeof(*lp);
switch (lp->type) {
@ -156,8 +174,8 @@ atalk_print(register const u_char *bp, u_int length)
u_short snet;
if (length < ddpSize) {
(void)printf(" [|ddp %d]", length);
return;
(void)printf(" [|ddp %d]", length);
return;
}
dp = (const struct atDDP *)bp;
snet = EXTRACT_16BITS(&dp->srcNet);
@ -168,6 +186,21 @@ atalk_print(register const u_char *bp, u_int length)
ddpskt_string(dp->dstSkt));
bp += ddpSize;
length -= ddpSize;
#ifdef LBL_ALIGN
if ((long)bp & 3) {
static u_char *abuf = NULL;
if (abuf == NULL) {
abuf = (u_char *)malloc(snaplen);
if (abuf == NULL)
error("atalk_print: malloc");
}
memcpy((char *)abuf, (char *)bp, min(length, snaplen));
snapend += abuf - (u_char *)bp;
packetp = abuf;
bp = abuf;
}
#endif
ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
}
@ -357,7 +390,7 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
register u_char snode, register u_char skt)
{
register const struct atNBPtuple *tp =
(struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
(const struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
int i;
const u_char *ep;
@ -433,7 +466,7 @@ print_cstring(register const char *cp, register const u_char *ep)
return (0);
}
while ((int)--length >= 0) {
if (cp >= (char *)ep) {
if (cp >= (const char *)ep) {
fputs(tstr, stdout);
return (0);
}
@ -542,7 +575,7 @@ ataddr_string(u_short atnet, u_char athost)
;
tp->addr = i3;
tp->nxt = newhnamemem();
tp->name = savestr(nambuf);
tp->name = strdup(nambuf);
}
fclose(fp);
}
@ -559,7 +592,7 @@ ataddr_string(u_short atnet, u_char athost)
tp->nxt = newhnamemem();
(void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
tp2->name, athost);
tp->name = savestr(nambuf);
tp->name = strdup(nambuf);
return (tp->name);
}
@ -571,7 +604,7 @@ ataddr_string(u_short atnet, u_char athost)
else
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8,
atnet & 0xff);
tp->name = savestr(nambuf);
tp->name = strdup(nambuf);
return (tp->name);
}

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.20 2000/12/22 22:45:09 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.21 2001/07/05 18:54:14 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -53,6 +53,7 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_int length = h->len;
u_short ethertype;
++infodelay;
ts_print(&h->ts);
if (caplen < 8) {
@ -141,4 +142,7 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}

View File

@ -0,0 +1,73 @@
/*
* 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-beep.c
*
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.1 2001/12/10 08:21:24 guy 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 ...
*/
static int l_strnstart(const char *, u_int, const char *, u_int);
static int
l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
{
if (tl1 > l2)
return 0;
return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
}
void
beep_print(const u_char *bp, u_int length)
{
if (l_strnstart("MSG", 4, bp, length)) /* A REQuest */
printf(" BEEP MSG");
else if (l_strnstart("RPY ", 4, bp, length))
printf(" BEEP RPY");
else if (l_strnstart("ERR ", 4, bp, length))
printf(" BEEP ERR");
else if (l_strnstart("ANS ", 4, bp, length))
printf(" BEEP ANS");
else if (l_strnstart("NUL ", 4, bp, length))
printf(" BEEP NUL");
else if (l_strnstart("SEQ ", 4, bp, length))
printf(" BEEP SEQ");
else if (l_strnstart("END", 4, bp, length))
printf(" BEEP END");
else
printf(" BEEP (payload or undecoded)");
}

View File

@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.21 2000/12/05 05:48:35 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.27 2001/10/18 09:52:17 itojun Exp $";
#endif
#include <sys/param.h>
@ -75,12 +75,14 @@ struct bgp_open {
u_int8_t bgpo_optlen;
/* options should follow */
};
#define BGP_OPEN_SIZE 29 /* unaligned */
struct bgp_opt {
u_int8_t bgpopt_type;
u_int8_t bgpopt_len;
/* variable length */
};
#define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */
struct bgp_notification {
u_int8_t bgpn_marker[16];
@ -90,6 +92,7 @@ struct bgp_notification {
u_int8_t bgpn_minor;
/* data should follow */
};
#define BGP_NOTIFICATION_SIZE 21 /* unaligned */
struct bgp_attr {
u_int8_t bgpa_flags;
@ -128,7 +131,7 @@ static const char *bgptype[] = {
#define bgp_type(x) num_or_str(bgptype, sizeof(bgptype)/sizeof(bgptype[0]), (x))
static const char *bgpopt_type[] = {
NULL, "Authentication Information",
NULL, "Authentication Information", "Capabilities Advertisement",
};
#define bgp_opttype(x) \
num_or_str(bgpopt_type, sizeof(bgpopt_type)/sizeof(bgpopt_type[0]), (x))
@ -192,7 +195,7 @@ static const char *bgpattr_type[] = {
/* Subsequent address family identifier, RFC2283 section 7 */
static const char *bgpattr_nlri_safi[] = {
"Reserved", "Unicast", "Multicast", "Unicast+Multicast",
"Reserved", "Unicast", "Multicast", "Unicast+Multicast",
};
#define bgp_attr_nlri_safi(x) \
num_or_str(bgpattr_nlri_safi, \
@ -270,10 +273,10 @@ bgp_notify_minor(int major, int minor)
}
static int
decode_prefix4(const u_char *pd, char *buf, int buflen)
decode_prefix4(const u_char *pd, char *buf, u_int buflen)
{
struct in_addr addr;
int plen;
u_int plen;
plen = pd[0];
if (plen < 0 || 32 < plen)
@ -291,10 +294,10 @@ decode_prefix4(const u_char *pd, char *buf, int buflen)
#ifdef INET6
static int
decode_prefix6(const u_char *pd, char *buf, int buflen)
decode_prefix6(const u_char *pd, char *buf, u_int buflen)
{
struct in6_addr addr;
int plen;
u_int plen;
plen = pd[0];
if (plen < 0 || 128 < plen)
@ -306,7 +309,7 @@ decode_prefix6(const u_char *pd, char *buf, int buflen)
addr.s6_addr[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
snprintf(buf, buflen, "%s/%d", getname6((char *)&addr), plen);
snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen);
return 1 + (plen + 7) / 8;
}
#endif
@ -346,9 +349,9 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
if (p[0] == 3 || p[0] == 4)
printf("confed");
printf("%s", (p[0] & 1) ? "{" : "");
for (i = 0; i < p[1]; i += 2) {
for (i = 0; i < p[1] * 2; i += 2) {
printf("%s%u", i == 0 ? "" : " ",
ntohs(*(u_int16_t *)&p[2 + i]));
EXTRACT_16BITS(&p[2 + i]));
}
printf("%s", (p[0] & 1) ? "}" : "");
p += 2 + p[1] * 2;
@ -365,7 +368,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
if (len != 4)
printf(" invalid len");
else
printf(" %u", (u_int32_t)ntohl(*(u_int32_t *)p));
printf(" %u", EXTRACT_32BITS(p));
break;
case BGPTYPE_ATOMIC_AGGREGATE:
if (len != 0)
@ -376,7 +379,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
printf(" invalid len");
break;
}
printf(" AS #%u, origin %s", ntohs(*(u_int16_t *)p),
printf(" AS #%u, origin %s", EXTRACT_16BITS(p),
getname(p + 2));
break;
case BGPTYPE_COMMUNITIES:
@ -386,7 +389,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
}
for (i = 0; i < len; i += 4) {
u_int32_t comm;
comm = (u_int32_t)ntohl(*(u_int32_t *)&p[i]);
comm = EXTRACT_32BITS(&p[i]);
switch (comm) {
case BGP_COMMUNITY_NO_EXPORT:
printf(" NO_EXPORT");
@ -405,7 +408,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
}
break;
case BGPTYPE_MP_REACH_NLRI:
af = ntohs(*(u_int16_t *)p);
af = EXTRACT_16BITS(p);
safi = p[2];
if (safi >= 128)
printf(" %s vendor specific,", af_name(af));
@ -487,7 +490,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
break;
case BGPTYPE_MP_UNREACH_NLRI:
af = ntohs(*(u_int16_t *)p);
af = EXTRACT_16BITS(p);
safi = p[2];
if (safi >= 128)
printf(" %s vendor specific,", af_name(af));
@ -534,8 +537,8 @@ 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));
TCHECK2(dat[0], BGP_OPEN_SIZE);
memcpy(&bgpo, dat, BGP_OPEN_SIZE);
hlen = ntohs(bgpo.bgpo_len);
printf(": Version %d,", bgpo.bgpo_version);
@ -545,11 +548,13 @@ bgp_open_print(const u_char *dat, int length)
printf(" Option length %u", bgpo.bgpo_optlen);
/* ugly! */
opt = &((struct bgp_open *)dat)->bgpo_optlen;
opt = &((const struct bgp_open *)dat)->bgpo_optlen;
opt++;
for (i = 0; i < bgpo.bgpo_optlen; i++) {
memcpy(&bgpopt, &opt[i], sizeof(bgpopt));
i = 0;
while (i < bgpo.bgpo_optlen) {
TCHECK2(opt[i], BGP_OPT_SIZE);
memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE);
if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
printf(" [|opt %d %d]", bgpopt.bgpopt_len, bgpopt.bgpopt_type);
break;
@ -557,7 +562,7 @@ bgp_open_print(const u_char *dat, int length)
printf(" (option %s, len=%d)", bgp_opttype(bgpopt.bgpopt_type),
bgpopt.bgpopt_len);
i += sizeof(bgpopt) + bgpopt.bgpopt_len;
i += BGP_OPT_SIZE + bgpopt.bgpopt_len;
}
return;
trunc:
@ -575,8 +580,8 @@ bgp_update_print(const u_char *dat, int length)
int i;
int newline;
TCHECK2(dat[0], sizeof(bgp));
memcpy(&bgp, dat, sizeof(bgp));
TCHECK2(dat[0], BGP_SIZE);
memcpy(&bgp, dat, BGP_SIZE);
hlen = ntohs(bgp.bgp_len);
p = dat + BGP_SIZE; /*XXX*/
printf(":");
@ -584,9 +589,10 @@ bgp_update_print(const u_char *dat, int length)
/* Unfeasible routes */
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.
/*
* 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);
@ -680,8 +686,8 @@ 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));
TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
hlen = ntohs(bgpn.bgpn_len);
printf(": error %s,", bgp_notify_major(bgpn.bgpn_major));
@ -697,8 +703,8 @@ bgp_header_print(const u_char *dat, int length)
{
struct bgp bgp;
TCHECK2(dat[0], sizeof(bgp));
memcpy(&bgp, dat, sizeof(bgp));
TCHECK2(dat[0], BGP_SIZE);
memcpy(&bgp, dat, BGP_SIZE);
printf("(%s", bgp_type(bgp.bgp_type)); /* ) */
switch (bgp.bgp_type) {
@ -759,8 +765,8 @@ bgp_print(const u_char *dat, int length)
}
/* found BGP header */
TCHECK2(p[0], sizeof(bgp)); /*XXX*/
memcpy(&bgp, p, sizeof(bgp));
TCHECK2(p[0], BGP_SIZE); /*XXX*/
memcpy(&bgp, p, BGP_SIZE);
if (start != p)
printf(" [|BGP]");

View File

@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.56 2000/12/04 00:00:08 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.60 2001/09/17 21:57:56 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -48,8 +48,8 @@ struct rtentry;
#include "ether.h"
#include "bootp.h"
static void rfc1048_print(const u_char *, u_int);
static void cmu_print(const u_char *, u_int);
static void rfc1048_print(const u_char *);
static void cmu_print(const u_char *);
static char tstr[] = " [|bootp]";
@ -61,10 +61,10 @@ bootp_print(register const u_char *cp, u_int length,
u_short sport, u_short dport)
{
register const struct bootp *bp;
static u_char vm_cmu[4] = VM_CMU;
static u_char vm_rfc1048[4] = VM_RFC1048;
static const u_char vm_cmu[4] = VM_CMU;
static const u_char vm_rfc1048[4] = VM_RFC1048;
bp = (struct bootp *)cp;
bp = (const struct bootp *)cp;
TCHECK(bp->bp_op);
switch (bp->bp_op) {
@ -130,14 +130,14 @@ bootp_print(register const u_char *cp, u_int length,
register const char *e;
TCHECK2(bp->bp_chaddr[0], 6);
eh = (struct ether_header *)packetp;
eh = (const struct ether_header *)packetp;
if (bp->bp_op == BOOTREQUEST)
e = (const char *)ESRC(eh);
else if (bp->bp_op == BOOTREPLY)
e = (const char *)EDST(eh);
else
e = 0;
if (e == 0 || memcmp((char *)bp->bp_chaddr, e, 6) != 0)
if (e == 0 || memcmp((const char *)bp->bp_chaddr, e, 6) != 0)
printf(" ether %s", etheraddr_string(bp->bp_chaddr));
}
@ -164,13 +164,12 @@ bootp_print(register const u_char *cp, u_int length,
/* Decode the vendor buffer */
TCHECK(bp->bp_vend[0]);
length -= sizeof(*bp) - sizeof(bp->bp_vend);
if (memcmp((char *)bp->bp_vend, (char *)vm_rfc1048,
if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
sizeof(u_int32_t)) == 0)
rfc1048_print(bp->bp_vend, length);
else if (memcmp((char *)bp->bp_vend, (char *)vm_cmu,
rfc1048_print(bp->bp_vend);
else if (memcmp((const char *)bp->bp_vend, vm_cmu,
sizeof(u_int32_t)) == 0)
cmu_print(bp->bp_vend, length);
cmu_print(bp->bp_vend);
else {
u_int32_t ul;
@ -184,7 +183,19 @@ bootp_print(register const u_char *cp, u_int length,
fputs(tstr, stdout);
}
/* The first character specifies the format to print */
/*
* The first character specifies the format to print:
* i - ip address (32 bits)
* p - ip address pairs (32 bits + 32 bits)
* l - long (32 bits)
* L - unsigned long (32 bits)
* s - short (16 bits)
* b - period-seperated decimal bytes (variable length)
* x - colon-seperated hex bytes (variable length)
* a - ascii string (variable length)
* B - on/off (8 bits)
* $ - special (explicit code to handle)
*/
static struct tok tag2str[] = {
/* RFC1048 tags */
{ TAG_PAD, " PAD" },
@ -236,7 +247,7 @@ static struct tok tag2str[] = {
{ TAG_VENDOR_OPTS, "bVO" },
{ TAG_NETBIOS_NS, "iWNS" },
{ TAG_NETBIOS_DDS, "iWDD" },
{ TAG_NETBIOS_NODE, "bWNT" },
{ TAG_NETBIOS_NODE, "$WNT" },
{ TAG_NETBIOS_SCOPE, "aWSC" },
{ TAG_XWIN_FS, "iXFS" },
{ TAG_XWIN_DM, "iXDM" },
@ -253,7 +264,7 @@ static struct tok tag2str[] = {
{ TAG_STREETTALK_STDA, "iSTDA" },
{ TAG_REQUESTED_IP, "iRQ" },
{ TAG_IP_LEASE, "lLT" },
{ TAG_OPT_OVERLOAD, "bOO" },
{ TAG_OPT_OVERLOAD, "$OO" },
{ TAG_TFTP_SERVER, "aTFTP" },
{ TAG_BOOTFILENAME, "aBF" },
{ TAG_DHCP_MESSAGE, " DHCP" },
@ -263,8 +274,8 @@ static struct tok tag2str[] = {
{ TAG_MAX_MSG_SIZE, "sMSZ" },
{ TAG_RENEWAL_TIME, "lRN" },
{ TAG_REBIND_TIME, "lRB" },
{ TAG_VENDOR_CLASS, "bVC" },
{ TAG_CLIENT_ID, "xCID" },
{ TAG_VENDOR_CLASS, "aVC" },
{ TAG_CLIENT_ID, "$CID" },
/* RFC 2485 */
{ TAG_OPEN_GROUP_UAP, "aUAP" },
/* RFC 2563 */
@ -279,7 +290,7 @@ static struct tok tag2str[] = {
/* 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_CLIENT_FQDN, "$FQDN" },
{ TAG_AGENT_CIRCUIT, "bACKT" },
{ TAG_AGENT_REMOTE, "bARMT" },
{ TAG_AGENT_MASK, "bAMSK" },
@ -307,8 +318,36 @@ static struct tok xtag2str[] = {
{ 0, NULL }
};
/* DHCP "options overload" types */
static struct tok oo2str[] = {
{ 1, "file" },
{ 2, "sname" },
{ 3, "file+sname" },
{ 0, NULL }
};
/* NETBIOS over TCP/IP node type options */
static struct tok nbo2str[] = {
{ 0x1, "b-node" },
{ 0x2, "p-node" },
{ 0x4, "m-node" },
{ 0x8, "h-node" },
{ 0, NULL }
};
/* ARP Hardware types, for Client-ID option */
static struct tok arp2str[] = {
{ 0x1, "ether" },
{ 0x6, "ieee802" },
{ 0x7, "arcnet" },
{ 0xf, "frelay" },
{ 0x17, "strip" },
{ 0x18, "ieee1394" },
{ 0, NULL }
};
static void
rfc1048_print(register const u_char *bp, register u_int length)
rfc1048_print(register const u_char *bp)
{
register u_char tag;
register u_int len, size;
@ -446,10 +485,10 @@ rfc1048_print(register const u_char *bp, register u_int length)
while (size >= 2*sizeof(ul)) {
if (!first)
putchar(',');
memcpy((char *)&ul, (char *)bp, sizeof(ul));
memcpy((char *)&ul, (const char *)bp, sizeof(ul));
printf("(%s:", ipaddr_string(&ul));
bp += sizeof(ul);
memcpy((char *)&ul, (char *)bp, sizeof(ul));
memcpy((char *)&ul, (const char *)bp, sizeof(ul));
printf("%s)", ipaddr_string(&ul));
bp += sizeof(ul);
size -= 2*sizeof(ul);
@ -498,13 +537,76 @@ rfc1048_print(register const u_char *bp, register u_int length)
/* Bytes */
while (size > 0) {
if (!first)
putchar (c == 'x' ? ':' : '.');
printf (c == 'x' ? "%02x" : "%d", *bp);
putchar(c == 'x' ? ':' : '.');
if (c == 'x')
printf("%02x", *bp);
else
printf("%d", *bp);
++bp;
--size;
first = 0;
}
break;
case '$':
/* Guys we can't handle with one of the usual cases */
switch (tag) {
case TAG_NETBIOS_NODE:
tag = *bp++;
--size;
fputs(tok2str(nbo2str, NULL, tag), stdout);
break;
case TAG_OPT_OVERLOAD:
tag = *bp++;
--size;
fputs(tok2str(oo2str, NULL, tag), stdout);
break;
case TAG_CLIENT_FQDN:
if (*bp++)
printf("[svrreg]");
if (*bp)
printf("%d/%d/", *bp, *(bp+1));
bp += 2;
putchar('"');
(void)fn_printn(bp, size - 3, NULL);
putchar('"');
bp += size - 3;
size = 0;
break;
case TAG_CLIENT_ID:
{ int type = *bp++;
size--;
if (type == 0) {
putchar('"');
(void)fn_printn(bp, size, NULL);
putchar('"');
break;
} else {
printf("[%s]", tok2str(arp2str, "type-%d", type));
}
while (size > 0) {
if (!first)
putchar(':');
printf("%02x", *bp);
++bp;
--size;
first = 0;
}
break;
}
default:
printf("[unknown special tag %d, size %d]",
tag, size);
bp += size;
size = 0;
break;
}
break;
}
/* Data left over? */
if (size)
@ -516,17 +618,16 @@ rfc1048_print(register const u_char *bp, register u_int length)
}
static void
cmu_print(register const u_char *bp, register u_int length)
cmu_print(register const u_char *bp)
{
register const struct cmu_vend *cmu;
char *fmt = " %s:%s";
#define PRINTCMUADDR(m, s) { TCHECK(cmu->m); \
if (cmu->m.s_addr != 0) \
printf(fmt, s, ipaddr_string(&cmu->m.s_addr)); }
printf(" %s:%s", s, ipaddr_string(&cmu->m.s_addr)); }
printf(" vend-cmu");
cmu = (struct cmu_vend *)bp;
cmu = (const struct cmu_vend *)bp;
/* Only print if there are unknown bits */
TCHECK(cmu->v_flags);

View File

@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.4 2000/07/29 07:27:54 assar Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.11 2001/09/17 21:57:56 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -47,141 +47,216 @@ static const char rcsid[] =
#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 );
static int cdp_print_addr(const u_char *, int);
static int cdp_print_prefixes(const u_char *, int);
/*
* 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;
u_int i;
int type, len;
/* Cisco Discovery Protocol */
if ( caplen < 12 ) {
if (caplen < 4) {
(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 */
i = 0; /* CDP data starts at offset 0 */
printf("CDP v%u, ttl=%us", 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 (i + 4 > caplen)
goto trunc;
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 (vflag > 1)
printf("\n\t");
if ( i+len > caplen ) {
printf("[!cdp]");
return;
}
if (vflag)
printf(" %02x/%02x", type, len);
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 );
}
if (i + len > caplen)
goto trunc;
/* 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++);
switch (type) {
case 0x00:
printf(" Goodbye");
break;
case 0x01:
printf(" DevID '%.*s'", len - 4, p + i + 4);
break;
case 0x02:
printf(" Addr");
if (cdp_print_addr(p + i + 4, len - 4) < 0)
goto trunc;
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 > 1)
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:
if (cdp_print_prefixes(p + i + 4, len - 4) < 0)
goto trunc;
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);
break;
}
printf(" ");
num--;
/* avoid infinite loop */
if (len == 0)
break;
i += len;
}
return;
trunc:
printf("[|cdp]");
}
/*
* Protocol type values.
*
* PT_NLPID means that the protocol type field contains an OSI NLPID.
*
* PT_IEEE_802_2 means that the protocol type field contains an IEEE 802.2
* LLC header that specifies that the payload is for that protocol.
*/
#define PT_NLPID 1 /* OSI NLPID */
#define PT_IEEE_802_2 2 /* IEEE 802.2 LLC header */
static void
cdp_print_prefixes( const u_char * p, int l )
static int
cdp_print_addr(const u_char * p, int l)
{
printf( " IPv4 Prefixes (%d):", l/5 );
int pt, pl, al, num;
const u_char *endp = p + l;
#ifdef INET6
static u_char prot_ipv6[] = {
0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
};
#endif
while(l > 0) {
printf( " %d.%d.%d.%d/%d", p[0], p[1], p[2], p[3], p[4] );
l-=5; p+=5;
}
num = EXTRACT_32BITS(p);
p += 4;
printf(" (%d): ", num);
while (p < endp && num >= 0) {
if (p + 2 > endp)
goto trunc;
pt = p[0]; /* type of "protocol" field */
pl = p[1]; /* length of "protocol" field */
p += 2;
if (p + pl + 2 > endp)
goto trunc;
al = EXTRACT_16BITS(&p[pl]); /* address length */
if (pt == PT_NLPID && pl == 1 && *p == 0xcc && al == 4) {
/*
* IPv4: protocol type = NLPID, protocol length = 1
* (1-byte NLPID), protocol = 0xcc (NLPID for IPv4),
* address length = 4
*/
p += 3;
if (p + 4 > endp)
goto trunc;
printf("IPv4 %u.%u.%u.%u", p[0], p[1], p[2], p[3]);
p += 4;
}
#ifdef INET6
else if (pt == PT_IEEE_802_2 && pl == 8 &&
memcmp(p, prot_ipv6, 8) == 0 && al == 16) {
/*
* IPv6: protocol type = IEEE 802.2 header,
* protocol length = 8 (size of LLC+SNAP header),
* protocol = LLC+SNAP header with the IPv6
* Ethertype, address length = 16
*/
p += 10;
if (p + al > endp)
goto trunc;
printf("IPv6 %s", ip6addr_string(p));
p += al;
}
#endif
else {
/*
* Generic case: just print raw data
*/
if (p + pl > endp)
goto trunc;
printf("pt=0x%02x, pl=%d, pb=", *(p - 2), pl);
while (pl-- > 0)
printf(" %02x", *p++);
if (p + 2 > endp)
goto trunc;
al = (*p << 8) + *(p + 1);
printf(", al=%d, a=", al);
p += 2;
if (p + al > endp)
goto trunc;
while (al-- > 0)
printf(" %02x", *p++);
}
num--;
if (num)
printf(" ");
}
return 0;
trunc:
return -1;
}
static int
cdp_print_prefixes(const u_char * p, int l)
{
if (l % 5)
goto trunc;
printf(" IPv4 Prefixes (%d):", l / 5);
while (l > 0) {
printf(" %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]);
l -= 5;
p += 5;
}
return 0;
trunc:
return -1;
}

View File

@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.11 2000/10/09 01:53:19 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.13 2001/09/17 21:57:57 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -42,6 +42,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
#include "ppp.h"
#include "chdlc.h"
@ -54,25 +55,38 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
{
register u_int length = h->len;
register u_int caplen = h->caplen;
const struct ip *ip;
u_int proto;
++infodelay;
ts_print(&h->ts);
if (caplen < CHDLC_HDRLEN) {
printf("[|chdlc]");
goto out;
}
/*
* Some printers want to get back at the link level addresses,
* and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
proto = ntohs(*(u_short *)&p[2]);
packetp = p;
snapend = p + caplen;
chdlc_print(p, length, caplen);
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}
void
chdlc_print(register const u_char *p, u_int length, u_int caplen)
{
const struct ip *ip;
u_int proto;
if (caplen < CHDLC_HDRLEN) {
printf("[|chdlc]");
return;
}
proto = EXTRACT_16BITS(&p[2]);
if (eflag) {
switch (p[0]) {
case CHDLC_UNICAST:
@ -89,7 +103,7 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
}
length -= CHDLC_HDRLEN;
ip = (struct ip *)(p + CHDLC_HDRLEN);
ip = (const struct ip *)(p + CHDLC_HDRLEN);
switch (proto) {
case ETHERTYPE_IP:
ip_print((const u_char *)ip, length);
@ -110,8 +124,6 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
}
if (xflag)
default_print((const u_char *)ip, caplen - CHDLC_HDRLEN);
out:
putchar('\n');
}
struct cisco_slarp {
@ -140,14 +152,14 @@ struct cisco_slarp {
static void
chdlc_slarp_print(const u_char *cp, u_int length)
{
struct cisco_slarp *slarp;
const struct cisco_slarp *slarp;
if (length < SLARP_LEN) {
printf("[|slarp]");
return;
}
slarp = (struct cisco_slarp *)cp;
slarp = (const struct cisco_slarp *)cp;
switch (ntohl(slarp->code)) {
case SLARP_REQUEST:
printf("slarp-request");

View File

@ -22,13 +22,15 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.11 2000/12/22 22:45:10 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.16 2001/09/23 21:52:38 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
@ -45,9 +47,6 @@ static const char rcsid[] =
#include "ethertype.h"
#include "ether.h"
const u_char *packetp;
const u_char *snapend;
#define RFC1483LLC_LEN 8
static unsigned char rfcllc[] = {
@ -61,25 +60,10 @@ static unsigned char rfcllc[] = {
static inline void
cip_print(register const u_char *bp, int length)
{
int i;
if (memcmp(rfcllc, bp, sizeof(rfcllc))) {
if (qflag) {
for (i = 0;i < RFC1483LLC_LEN; i++)
(void)printf("%2.2x ",bp[i]);
} else {
for (i = 0;i < RFC1483LLC_LEN - 2; i++)
(void)printf("%2.2x ",bp[i]);
etherproto_string(((u_short*)bp)[3]);
}
} else {
if (qflag)
(void)printf("(null encapsulation)");
else {
(void)printf("(null encap)");
etherproto_string(ETHERTYPE_IP);
}
}
/*
* There is no MAC-layer header, so just print the length.
*/
printf("%d: ", length);
}
/*
@ -91,12 +75,11 @@ cip_print(register const u_char *bp, int length)
void
cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
int caplen = h->caplen;
int length = h->len;
u_short ether_type;
u_int caplen = h->caplen;
u_int length = h->len;
u_short extracted_ethertype;
u_short *bp;
++infodelay;
ts_print(&h->ts);
if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
@ -115,28 +98,15 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
packetp = p;
snapend = p + caplen;
if (memcmp(rfcllc, p, sizeof(rfcllc))==0) {
length -= RFC1483LLC_LEN;
caplen -= RFC1483LLC_LEN;
bp = (u_short *)p;
p += RFC1483LLC_LEN;
ether_type = ntohs(bp[3]);
} else {
ether_type = ETHERTYPE_IP;
bp = (u_short *)p;
}
/*
* Is it (gag) an 802.3 encapsulation?
*/
extracted_ethertype = 0;
if (ether_type < ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
/*
* LLC header is present. Try to print it & higher layers.
*/
if (llc_print(p, length, caplen, NULL, NULL,
&extracted_ethertype)==0) {
&extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
cip_print((u_char *)bp, length + RFC1483LLC_LEN);
cip_print(p, length);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
@ -144,16 +114,18 @@ 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,
&extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
cip_print((u_char *)bp, length + RFC1483LLC_LEN);
if (!xflag && !qflag)
default_print(p, caplen);
} else {
/*
* LLC header is absent; treat it as just IP.
*/
ip_print(p, length);
}
if (xflag)
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}

View File

@ -34,7 +34,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.6 2000/09/23 08:26:32 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.8 2001/09/17 21:57:58 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -78,8 +78,8 @@ struct nfrec {
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 */
u_int32_t masks; /* src,dst addr prefix; v6: encaps */
struct in_addr peer_nexthop; /* v6: IP address of the nexthop within the peer (FIB)*/
};
void
@ -92,10 +92,10 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
int nrecs, ver;
time_t t;
ip = (struct ip *)bp;
nh = (struct nfhdr *)cp;
ip = (const struct ip *)bp;
nh = (const struct nfhdr *)cp;
if ((u_char *)(nh + 1) > snapend)
if ((const u_char *)(nh + 1) > snapend)
return;
nrecs = ntohl(nh->ver_cnt) & 0xffff;
@ -108,18 +108,18 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
(unsigned)ntohl(nh->msys_uptime)%1000,
(unsigned)ntohl(nh->utc_sec), (unsigned)ntohl(nh->utc_nsec));
if (ver == 5) {
if (ver == 5 || ver == 6) {
printf("#%u, ", (unsigned)htonl(nh->sequence));
nr = (struct nfrec *)&nh[1];
nr = (const struct nfrec *)&nh[1];
snaplen -= 24;
} else {
nr = (struct nfrec *)&nh->sequence;
nr = (const struct nfrec *)&nh->sequence;
snaplen -= 16;
}
printf("%2u recs", nrecs);
for (; nrecs-- && (u_char *)(nr + 1) <= snapend; nr++) {
for (; nrecs-- && (const u_char *)(nr + 1) <= snapend; nr++) {
char buf[20];
char asbuf[20];
@ -130,19 +130,19 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
(unsigned)ntohl(nr->last_time)%1000);
asbuf[0] = buf[0] = '\0';
if (ver == 5) {
if (ver == 5 || ver == 6) {
snprintf(buf, sizeof(buf), "/%u",
(unsigned)(ntohl(nr->masks) >> 24) & 0xff);
snprintf(asbuf, sizeof(asbuf), "%u:",
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) {
if (ver == 5 || ver ==6) {
snprintf(buf, sizeof(buf), "/%d",
(unsigned)(ntohl(nr->masks) >> 16) & 0xff);
snprintf(asbuf, sizeof(asbuf), "%u:",
snprintf(asbuf, sizeof(asbuf), ":%u",
(unsigned)ntohl(nr->asses) & 0xffff);
}
printf("> %s%s%s:%u ", inet_ntoa(nr->dst_ina), buf, asbuf,
@ -173,9 +173,16 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
if (flags)
putchar(' ');
}
printf("tos %u, %u (%u octets)",
buf[0]='\0';
if (ver == 6) {
snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
(unsigned)(ntohl(nr->masks) >> 8) & 0xff,
(unsigned)(ntohl(nr->masks)) & 0xff);
}
printf("tos %u, %u (%u octets) %s",
(unsigned)ntohl(nr->proto_tos) & 0xff,
(unsigned)ntohl(nr->packets),
(unsigned)ntohl(nr->octets));
(unsigned)ntohl(nr->octets), buf);
}
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.30 2000/09/28 06:42:57 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.33 2001/09/17 21:57:59 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -730,7 +730,7 @@ print_reason(register int reason)
printf("%s ", tok2str(reason2str, "reason-%d", reason));
}
char *
const char *
dnnum_string(u_short dnaddr)
{
char *str;
@ -745,7 +745,7 @@ dnnum_string(u_short dnaddr)
return(str);
}
char *
const char *
dnname_string(u_short dnaddr)
{
#ifdef HAVE_LIBDNET
@ -753,7 +753,7 @@ dnname_string(u_short dnaddr)
dna.a_len = sizeof(short);
memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
return (savestr(dnet_htoa(&dna)));
return (strdup(dnet_htoa(&dna)));
#else
return(dnnum_string(dnaddr)); /* punt */
#endif
@ -768,10 +768,7 @@ pdata(u_char *dp, u_int maxlen)
while (x-- > 0) {
c = *dp++;
if (isprint(c))
putchar(c);
else
printf("\\%o", c & 0xFF);
safeputchar(c);
}
}
#endif

View File

@ -29,7 +29,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.12 2000/10/24 00:56:50 fenner Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.14 2001/09/17 21:57:59 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -56,12 +56,12 @@ struct rtentry;
#include "dhcp6opt.h"
#if 0
static void dhcp6opttab_init (void);
static struct dhcp6_opt *dhcp6opttab_byname (char *);
static void dhcp6opttab_init(void);
static struct dhcp6_opt *dhcp6opttab_byname(char *);
#endif
static struct dhcp6_opt *dhcp6opttab_bycode (u_int);
static struct dhcp6_opt *dhcp6opttab_bycode(u_int);
static char tstr[] = " [|dhcp6]";
static const char tstr[] = " [|dhcp6]";
static struct dhcp6_opt dh6opttab[] = {
/* IP Address Extension */

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.64.2.1 2001/02/21 09:01:20 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.78 2001/10/19 09:00:48 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -33,12 +33,6 @@ static const char rcsid[] =
#include <netinet/in.h>
#ifdef NOERROR
#undef NOERROR /* Solaris sucks */
#endif
#ifdef NOERROR
#undef T_UNSPEC /* SINIX does too */
#endif
#include "nameser.h"
#include <stdio.h>
@ -48,102 +42,16 @@ static const char rcsid[] =
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
/* Compatibility */
#ifndef T_TXT
#define T_TXT 16 /* text strings */
#endif
#ifndef T_RP
#define T_RP 17 /* responsible person */
#endif
#ifndef T_AFSDB
#define T_AFSDB 18 /* AFS cell database */
#endif
#ifndef T_X25
#define T_X25 19 /* X_25 calling address */
#endif
#ifndef T_ISDN
#define T_ISDN 20 /* ISDN calling address */
#endif
#ifndef T_RT
#define T_RT 21 /* router */
#endif
#ifndef T_NSAP
#define T_NSAP 22 /* NSAP address */
#endif
#ifndef T_NSAP_PTR
#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
#endif
#ifndef T_SIG
#define T_SIG 24 /* security signature */
#endif
#ifndef T_KEY
#define T_KEY 25 /* security key */
#endif
#ifndef T_PX
#define T_PX 26 /* X.400 mail mapping */
#endif
#ifndef T_GPOS
#define T_GPOS 27 /* geographical position (withdrawn) */
#endif
#ifndef T_AAAA
#define T_AAAA 28 /* IP6 Address */
#endif
#ifndef T_LOC
#define T_LOC 29 /* Location Information */
#endif
#ifndef T_NXT
#define T_NXT 30 /* Next Valid Name in Zone */
#endif
#ifndef T_EID
#define T_EID 31 /* Endpoint identifier */
#endif
#ifndef T_NIMLOC
#define T_NIMLOC 32 /* Nimrod locator */
#endif
#ifndef T_SRV
#define T_SRV 33 /* Server selection */
#endif
#ifndef T_ATMA
#define T_ATMA 34 /* ATM Address */
#endif
#ifndef T_NAPTR
#define T_NAPTR 35 /* Naming Authority PoinTeR */
#endif
#ifndef T_A6
#define T_A6 38 /* IP6 address */
#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
#define T_UNSPEC 103 /* Unspecified format (binary data) */
#endif
#ifndef T_UNSPECA
#define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */
#endif
#ifndef C_CHAOS
#define C_CHAOS 3 /* for chaos net (MIT) */
#endif
#ifndef C_HS
#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
#endif
static char *ns_ops[] = {
"", " inv_q", " stat", " op3", " notify", " op5", " op6", " op7",
static const char *ns_ops[] = {
"", " inv_q", " stat", " op3", " notify", " update", " op6", " op7",
" op8", " updataA", " updateD", " updateDA",
" updateM", " updateMA", " zoneInit", " zoneRef",
};
static char *ns_resp[] = {
static const char *ns_resp[] = {
"", " FormErr", " ServFail", " NXDomain",
" NotImp", " Refused", " Resp6", " Resp7",
" Resp8", " Resp9", " Resp10", " Resp11",
" NotImp", " Refused", " YXDomain", " YXRRSet",
" NXRRSet", " NotAuth", " NotZone", " Resp11",
" Resp12", " Resp13", " Resp14", " NoChange",
};
@ -153,24 +61,26 @@ ns_nskip(register const u_char *cp, register const u_char *bp)
{
register u_char i;
if (!TTEST2(*cp, 1))
return (NULL);
if (((i = *cp++) & INDIR_MASK) == INDIR_MASK)
return (cp + 1);
if (cp >= snapend)
return(NULL);
while (i && cp < snapend) {
while (i) {
if ((i & INDIR_MASK) == EDNS0_MASK) {
int bitlen, bytelen;
if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL)
return(NULL); /* unknown ELT */
if (!TTEST2(*cp, 1))
return (NULL);
if ((bitlen = *cp++) == 0)
bitlen = 256;
bytelen = (bitlen + 7) / 8;
cp += bytelen;
} else
cp += i;
if (cp >= snapend)
return(NULL);
if (!TTEST2(*cp, 1))
return (NULL);
i = *cp++;
}
return (cp);
@ -185,7 +95,7 @@ blabel_print(const u_char *cp)
const u_char *bitp, *lim;
char tc;
if (cp >= snapend)
if (!TTEST2(*cp, 1))
return(NULL);
if ((bitlen = *cp) == 0)
bitlen = 256;
@ -218,7 +128,7 @@ labellen(const u_char *cp)
{
register u_int i;
if (cp >= snapend)
if (!TTEST2(*cp, 1))
return(-1);
i = *cp;
if ((i & INDIR_MASK) == EDNS0_MASK) {
@ -226,7 +136,7 @@ labellen(const u_char *cp)
if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL)
return(-1);
if (cp + 1 >= snapend)
if (!TTEST2(*(cp + 1), 1))
return(-1);
if ((bitlen = *(cp + 1)) == 0)
bitlen = 256;
@ -247,7 +157,7 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
if ((l = labellen(cp)) < 0)
return(NULL);
if (cp >= snapend)
if (!TTEST2(*cp, 1))
return(NULL);
chars_processed = 1;
if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {
@ -262,11 +172,13 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
rp = cp + 1;
compress = 1;
}
cp = bp + (((i << 8) | *cp) & 0x3fff);
if (cp >= snapend)
if (!TTEST2(*cp, 1))
return(NULL);
cp = bp + (((i << 8) | *cp) & 0x3fff);
if ((l = labellen(cp)) < 0)
return(NULL);
if (!TTEST2(*cp, 1))
return(NULL);
i = *cp++;
chars_processed++;
@ -286,7 +198,8 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
elt = (i & ~INDIR_MASK);
switch(elt) {
case EDNS0_ELT_BITLABEL:
blabel_print(cp);
if (blabel_print(cp) == NULL)
return (NULL);
break;
default:
/* unknown ELT */
@ -295,13 +208,15 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
}
} else {
if (fn_printn(cp, l, snapend))
break;
return(NULL);
}
cp += l;
chars_processed += l;
putchar('.');
if (cp >= snapend || (l = labellen(cp)) < 0)
if ((l = labellen(cp)) < 0)
return(NULL);
if (!TTEST2(*cp, 1))
return(NULL);
i = *cp++;
chars_processed++;
@ -319,14 +234,15 @@ ns_cprint(register const u_char *cp, register const u_char *bp)
{
register u_int i;
if (cp >= snapend)
return NULL;
if (!TTEST2(*cp, 1))
return (NULL);
i = *cp++;
(void)fn_printn(cp, i, snapend);
if (fn_printn(cp, i, snapend))
return (NULL);
return (cp + i);
}
static struct tok type2str[] = {
struct tok ns_type2str[] = {
{ T_A, "A" },
{ T_NS, "NS" },
{ T_MD, "MD" },
@ -355,21 +271,24 @@ static struct tok type2str[] = {
{ T_PX, "PX" },
{ T_GPOS, "GPOS" },
{ T_AAAA, "AAAA" },
{ T_LOC, "LOC " },
{ T_NXT, "NXT " },
{ T_EID, "EID " },
{ T_NIMLOC, "NIMLOC " },
{ T_SRV, "SRV " },
{ T_ATMA, "ATMA " },
{ T_NAPTR, "NAPTR " },
{ T_A6, "A6 " },
{ T_DNAME, "DNAME " },
{ T_OPT, "OPT " },
{ T_LOC, "LOC" },
{ T_NXT, "NXT" },
{ T_EID, "EID" },
{ T_NIMLOC, "NIMLOC" },
{ T_SRV, "SRV" },
{ T_ATMA, "ATMA" },
{ T_NAPTR, "NAPTR" },
{ T_A6, "A6" },
{ T_DNAME, "DNAME" },
{ T_OPT, "OPT" },
{ T_UINFO, "UINFO" },
{ T_UID, "UID" },
{ T_GID, "GID" },
{ T_UNSPEC, "UNSPEC" },
{ T_UNSPECA, "UNSPECA" },
{ T_TKEY, "TKEY" },
{ T_TSIG, "TSIG" },
{ T_IXFR, "IXFR" },
{ T_AXFR, "AXFR" },
{ T_MAILB, "MAILB" },
{ T_MAILA, "MAILA" },
@ -377,9 +296,9 @@ static struct tok type2str[] = {
{ 0, NULL }
};
static struct tok class2str[] = {
struct tok ns_class2str[] = {
{ C_IN, "IN" }, /* Not used */
{ C_CHAOS, "CHAOS)" },
{ C_CHAOS, "CHAOS" },
{ C_HS, "HS" },
{ C_ANY, "ANY" },
{ 0, NULL }
@ -394,17 +313,17 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
cp = ns_nskip(cp, bp);
if (cp + 4 > snapend || cp == NULL)
if (cp == NULL || !TTEST2(*cp, 4))
return(NULL);
/* print the qtype and qclass (if it's not IN) */
i = *cp++ << 8;
i |= *cp++;
printf(" %s", tok2str(type2str, "Type%d", i));
printf(" %s", tok2str(ns_type2str, "Type%d", i));
i = *cp++ << 8;
i |= *cp++;
if (i != C_IN)
printf(" %s", tok2str(class2str, "(Class %d)", i));
printf(" %s", tok2str(ns_class2str, "(Class %d)", i));
fputs("? ", stdout);
cp = ns_nprint(np, bp);
@ -426,7 +345,7 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
} else
cp = ns_nskip(cp, bp);
if (cp + 10 > snapend || cp == NULL)
if (cp == NULL || !TTEST2(*cp, 10))
return (snapend);
/* print the type/qtype and class (if it's not IN) */
@ -435,7 +354,7 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
class = *cp++ << 8;
class |= *cp++;
if (class != C_IN && typ != T_OPT)
printf(" %s", tok2str(class2str, "(Class %d)", class));
printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
/* ignore ttl */
cp += 4;
@ -445,13 +364,13 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
rp = cp + len;
printf(" %s", tok2str(type2str, "Type%d", typ));
printf(" %s", tok2str(ns_type2str, "Type%d", typ));
if (rp > snapend)
return(NULL);
switch (typ) {
case T_A:
if (cp + sizeof(struct in_addr) > snapend)
if (!TTEST2(*cp, sizeof(struct in_addr)))
return(NULL);
printf(" %s", ipaddr_string(cp));
break;
@ -476,7 +395,7 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
putchar(' ');
if ((cp = ns_nprint(cp, bp)) == NULL)
return(NULL);
if (cp + 5 * 4 > snapend)
if (!TTEST2(*cp, 5 * 4))
return(NULL);
printf(" %u", EXTRACT_32BITS(cp));
cp += 4;
@ -491,7 +410,7 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
break;
case T_MX:
putchar(' ');
if (cp + 2 > snapend)
if (!TTEST2(*cp, 2))
return(NULL);
if (ns_nprint(cp + 2, bp) == NULL)
return(NULL);
@ -505,7 +424,7 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
#ifdef INET6
case T_AAAA:
if (cp + sizeof(struct in6_addr) > snapend)
if (!TTEST2(*cp, sizeof(struct in6_addr)))
return(NULL);
printf(" %s", ip6addr_string(cp));
break;
@ -515,12 +434,16 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
struct in6_addr a;
int pbit, pbyte;
if (!TTEST2(*cp, 1))
return(NULL);
pbit = *cp;
pbyte = (pbit & ~7) / 8;
if (pbit > 128) {
printf(" %u(bad plen)", pbit);
break;
} else if (pbit < 128) {
if (!TTEST2(*(cp + 1), sizeof(a) - pbyte))
return(NULL);
memset(&a, 0, sizeof(a));
memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
printf(" %u %s", pbit, ip6addr_string(&a));
@ -539,10 +462,43 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
break;
case T_UNSPECA: /* One long string */
if (!TTEST2(*cp, len))
return(NULL);
if (fn_printn(cp, len, snapend))
return(NULL);
break;
case T_TSIG:
{
if (cp + len > snapend)
return(NULL);
fn_printn(cp, len, snapend);
break;
if (!vflag)
break;
putchar(' ');
if ((cp = ns_nprint(cp, bp)) == NULL)
return(NULL);
cp += 6;
if (!TTEST2(*cp, 2))
return(NULL);
printf(" fudge=%u", EXTRACT_16BITS(cp));
cp += 2;
if (!TTEST2(*cp, 2))
return(NULL);
printf(" maclen=%u", EXTRACT_16BITS(cp));
cp += 2 + EXTRACT_16BITS(cp);
if (!TTEST2(*cp, 2))
return(NULL);
printf(" origid=%u", EXTRACT_16BITS(cp));
cp += 2;
if (!TTEST2(*cp, 2))
return(NULL);
printf(" error=%u", EXTRACT_16BITS(cp));
cp += 2;
if (!TTEST2(*cp, 2))
return(NULL);
printf(" otherlen=%u", EXTRACT_16BITS(cp));
cp += 2;
}
}
return (rp); /* XXX This isn't always right */
}
@ -552,7 +508,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 = NULL;
register const u_char *cp;
np = (const HEADER *)bp;
TCHECK(*np);
@ -576,49 +532,58 @@ ns_print(register const u_char *bp, u_int length)
if (qdcount != 1)
printf(" [%dq]", qdcount);
/* Print QUESTION section on -vv */
if (vflag > 1) {
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;
cp = (const u_char *)(np + 1);
while (qdcount--) {
if (qdcount < ntohs(np->qdcount) - 1)
putchar(',');
if (vflag > 1) {
fputs(" q:", stdout);
if ((cp = ns_qprint(cp, bp)) == NULL)
goto trunc;
} else {
if ((cp = ns_nskip(cp, bp)) == NULL)
goto trunc;
cp += 4; /* skip QTYPE and QCLASS */
}
}
printf(" %d/%d/%d", ancount, nscount, arcount);
if (ancount--) {
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (ancount-- && cp < snapend) {
while (cp < snapend && ancount--) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
if (ancount > 0)
goto trunc;
/* Print NS and AR sections on -vv */
if (vflag > 1) {
if (nscount-- && cp < snapend) {
if (cp < snapend && nscount--) {
fputs(" ns:", stdout);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (nscount-- && cp < snapend) {
while (cp < snapend && nscount--) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
if (arcount-- && cp < snapend) {
if (nscount > 0)
goto trunc;
if (cp < snapend && arcount--) {
fputs(" ar:", stdout);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (arcount-- && cp < snapend) {
while (cp < snapend && arcount--) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
if (arcount > 0)
goto trunc;
}
}
else {
@ -648,35 +613,35 @@ ns_print(register const u_char *bp, u_int length)
if (arcount)
printf(" [%dau]", arcount);
cp = (const u_char *)(np + 1);
if (qdcount--) {
cp = ns_qprint((const u_char *)(np + 1),
(const u_char *)np);
cp = ns_qprint(cp, (const u_char *)np);
if (!cp)
goto trunc;
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (qdcount-- && cp < snapend) {
while (cp < snapend && qdcount--) {
cp = ns_qprint((const u_char *)cp,
(const u_char *)np);
if (!cp)
goto trunc;
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
if (qdcount > 0)
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) {
while (cp < snapend && ancount--) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
if (nscount-- && cp < snapend) {
if (ancount > 0)
goto trunc;
if (cp < snapend && nscount--) {
fputs(" ns:", stdout);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
@ -686,16 +651,20 @@ ns_print(register const u_char *bp, u_int length)
goto trunc;
}
}
if (arcount-- && cp < snapend) {
if (nscount > 0)
goto trunc;
if (cp < snapend && arcount--) {
fputs(" ar:", stdout);
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
while (arcount-- && cp < snapend) {
while (cp < snapend && arcount--) {
putchar(',');
if ((cp = ns_rprint(cp, bp)) == NULL)
goto trunc;
}
}
if (arcount > 0)
goto trunc;
}
}
printf(" (%d)", length);

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.20 2000/09/29 04:58:36 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.21 2001/05/10 05:30:20 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -50,9 +50,7 @@ static const char rcsid[] =
#define DVMRP_PROBE 1 /* for finding neighbors */
#define DVMRP_REPORT 2 /* for reporting some or all routes */
#define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */
/*
* of this router's neighbors
*/
/* of this router's neighbors */
#define DVMRP_NEIGHBORS 4 /* response to such a request */
#define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */
#define DVMRP_NEIGHBORS2 6
@ -90,11 +88,9 @@ dvmrp_print(register const u_char *bp, register u_int len)
return;
type = bp[1];
bp += 8;
/*
* Skip IGMP header
*/
/* Skip IGMP header */
bp += 8;
len -= 8;
switch (type) {
@ -107,7 +103,7 @@ dvmrp_print(register const u_char *bp, register u_int len)
case DVMRP_REPORT:
printf(" Report");
if (vflag)
if (vflag > 1)
print_report(bp, ep, len);
break;
@ -222,7 +218,13 @@ print_probe(register const u_char *bp, register const u_char *ep,
genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
bp += 4;
len -= 4;
printf("\n\tgenid %u", genid);
if (vflag > 1)
printf("\n\t");
else
printf(" ");
printf("genid %u", genid);
if (vflag < 2)
return;
while ((len > 0) && (bp < ep)) {
TCHECK2(bp[0], 4);

View File

@ -20,7 +20,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.26 2000/09/29 04:58:36 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.28 2001/09/17 21:58:01 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -99,7 +99,7 @@ struct egp_packet {
#define egp_sourcenet egp_pands.egpu_sourcenet
};
char *egp_acquire_codes[] = {
const char *egp_acquire_codes[] = {
"request",
"confirm",
"refuse",
@ -107,7 +107,7 @@ char *egp_acquire_codes[] = {
"cease_ack"
};
char *egp_acquire_status[] = {
const char *egp_acquire_status[] = {
"unspecified",
"active_mode",
"passive_mode",
@ -118,18 +118,18 @@ char *egp_acquire_status[] = {
"protocol_violation"
};
char *egp_reach_codes[] = {
const char *egp_reach_codes[] = {
"hello",
"i-h-u"
};
char *egp_status_updown[] = {
const char *egp_status_updown[] = {
"indeterminate",
"up",
"down"
};
char *egp_reasons[] = {
const char *egp_reasons[] = {
"unspecified",
"bad_EGP_header_format",
"bad_EGP_data_field_format",
@ -230,9 +230,7 @@ egp_print(register const u_char *bp, register u_int length,
egp = (struct egp_packet *)bp;
ip = (struct ip *)bp2;
(void)printf("%s > %s: egp: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
(void)printf("egp: ");
if (egp->egp_version != EGP_VERSION) {
printf("[version %d]", egp->egp_version);

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.17 2000/12/12 09:58:41 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.20 2002/01/21 11:39:59 mcr Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -39,13 +39,13 @@ static const char rcsid[] =
#include <netinet/in.h>
#ifdef HAVE_LIBCRYPTO
#include <des.h>
#include <blowfish.h>
#include <openssl/des.h>
#include <openssl/blowfish.h>
#ifdef HAVE_RC5_H
#include <rc5.h>
#include <openssl/rc5.h>
#endif
#ifdef HAVE_CAST_H
#include <cast.h>
#include <openssl/cast.h>
#endif
#endif
@ -57,28 +57,153 @@ static const char rcsid[] =
#include "ip6.h"
#endif
#define AVOID_CHURN 1
#include "interface.h"
#include "addrtoname.h"
static struct esp_algorithm *espsecret_xform=NULL; /* cache of decoded alg. */
static char *espsecret_key=NULL;
enum cipher { NONE,
DESCBC,
BLOWFISH,
RC5,
CAST128,
DES3CBC};
struct esp_algorithm {
char *name;
enum cipher algo;
int ivlen;
int authlen;
int replaysize;
};
struct esp_algorithm esp_xforms[]={
{"none", NONE, 0, 0, 0},
{"des-cbc", DESCBC, 8, 0, 0},
{"des-cbc-hmac96", DESCBC, 8, 12, 4},
{"blowfish-cbc", BLOWFISH,8, 0, 0},
{"blowfish-cbc-hmac96", BLOWFISH,8, 12, 4},
{"rc5-cbc", RC5, 8, 0, 0},
{"rc5-cbc-hmac96", RC5, 8, 12, 4},
{"cast128-cbc", CAST128, 8, 0, 0},
{"cast128-cbc-hmac96", CAST128, 8, 12, 4},
{"3des-cbc-hmac96", DES3CBC, 8, 12, 4},
};
static int hexdigit(char hex)
{
if(hex >= '0' && hex <= '9') {
return (hex - '0');
} else if(hex >= 'A' && hex <= 'F') {
return (hex - 'A' + 10);
} else if(hex >= 'a' && hex <= 'f') {
return (hex - 'a' + 10);
} else {
printf("invalid hex digit %c in espsecret\n", hex);
return 0;
}
}
static int hex2byte(char *hexstring)
{
int byte;
byte = (hexdigit(hexstring[0]) << 4) +
hexdigit(hexstring[1]);
return byte;
}
void esp_print_decodesecret()
{
char *colon;
int len, i;
struct esp_algorithm *xf;
if(espsecret == NULL) {
/* set to NONE transform */
espsecret_xform = esp_xforms;
return;
}
if(espsecret_key != NULL) {
return;
}
colon = strchr(espsecret, ':');
if(colon == NULL) {
printf("failed to decode espsecret: %s\n",
espsecret);
/* set to NONE transform */
espsecret_xform = esp_xforms;
}
len = colon - espsecret;
xf = esp_xforms;
while(xf->name && strncasecmp(espsecret, xf->name, len)!=0) {
xf++;
}
if(xf->name == NULL) {
printf("failed to find cipher algo %s\n",
espsecret);
espsecret_xform = esp_xforms;
return;
}
espsecret_xform = xf;
colon++;
if(colon[0]=='0' && colon[1]=='x') {
/* decode some hex! */
colon+=2;
len = strlen(colon) / 2;
espsecret_key = (char *)malloc(len);
if(espsecret_key == NULL) {
fprintf(stderr, "%s: ran out of memory (%d) to allocate secret key\n",
program_name, len);
exit(2);
}
i = 0;
while(colon[0] != '\0' && colon[1]!='\0') {
espsecret_key[i]=hex2byte(colon);
colon+=2;
i++;
}
} else {
espsecret_key = colon;
}
}
int
esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
esp_print(register const u_char *bp, register const u_char *bp2,
int *nhdr, int *padlen)
{
register const struct esp *esp;
register const u_char *ep;
u_int32_t spi;
enum { NONE, DESCBC, BLOWFISH, RC5, CAST128, DES3CBC } algo = NONE;
struct ip *ip = NULL;
#ifdef INET6
struct ip6_hdr *ip6 = NULL;
#endif
int advance;
int len;
char *secret = NULL;
char *secret;
int ivlen = 0;
u_char *ivoff;
u_char *p;
esp = (struct esp *)bp;
spi = (u_int32_t)ntohl(esp->esp_spi);
secret = NULL;
#if 0
/* keep secret out of a register */
p = (u_char *)&secret;
#endif
/* 'ep' points to the end of available data. */
ep = snapend;
@ -95,40 +220,11 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
if (!espsecret)
goto fail;
if (strncmp(espsecret, "des-cbc:", 8) == 0
&& strlen(espsecret + 8) == 8) {
algo = DESCBC;
ivlen = 8;
secret = espsecret + 8;
} else if (strncmp(espsecret, "blowfish-cbc:", 13) == 0) {
algo = BLOWFISH;
ivlen = 8;
secret = espsecret + 13;
} else if (strncmp(espsecret, "rc5-cbc:", 8) == 0) {
algo = RC5;
ivlen = 8;
secret = espsecret + 8;
} else if (strncmp(espsecret, "cast128-cbc:", 12) == 0) {
algo = CAST128;
ivlen = 8;
secret = espsecret + 12;
} else if (strncmp(espsecret, "3des-cbc:", 9) == 0
&& strlen(espsecret + 9) == 24) {
algo = DES3CBC;
ivlen = 8;
secret = espsecret + 9;
} else if (strncmp(espsecret, "none:", 5) == 0) {
algo = NONE;
ivlen = 0;
secret = espsecret + 5;
} else if (strlen(espsecret) == 8) {
algo = DESCBC;
ivlen = 8;
secret = espsecret;
} else {
algo = NONE;
ivlen = 0;
secret = espsecret;
if(!espsecret_xform) {
esp_print_decodesecret();
}
if(espsecret_xform->algo == NONE) {
goto fail;
}
ip = (struct ip *)bp2;
@ -145,6 +241,9 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
break;
#endif /*INET6*/
case 4:
/* nexthdr & padding are in the last fragment */
if (ntohs(ip->ip_off) & IP_MF)
goto fail;
#ifdef INET6
ip6 = NULL;
#endif
@ -158,18 +257,16 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
if (ep - bp2 < len)
goto fail;
if (Rflag)
ivoff = (u_char *)(esp + 1) + sizeof(u_int32_t);
else
ivoff = (u_char *)(esp + 1);
ivoff = (u_char *)(esp + 1) + espsecret_xform->replaysize;
ivlen = espsecret_xform->ivlen;
secret = espsecret_key;
switch (algo) {
switch (espsecret_xform->algo) {
case DESCBC:
#ifdef HAVE_LIBCRYPTO
{
u_char iv[8];
des_key_schedule schedule;
u_char *p;
switch (ivlen) {
case 4:
@ -206,7 +303,6 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
#ifdef HAVE_LIBCRYPTO
{
BF_KEY schedule;
u_char *p;
BF_set_key(&schedule, strlen(secret), secret);
@ -224,7 +320,6 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_RC5_H)
{
RC5_32_KEY schedule;
u_char *p;
RC5_32_set_key(&schedule, strlen(secret), secret,
RC5_16_ROUNDS);
@ -243,7 +338,6 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128)
{
CAST_KEY schedule;
u_char *p;
CAST_set_key(&schedule, strlen(secret), secret);
@ -261,16 +355,26 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
#if defined(HAVE_LIBCRYPTO)
{
des_key_schedule s1, s2, s3;
u_char *p;
des_check_key = 0;
des_set_key((void *)secret, s1);
des_set_key((void *)(secret + 8), s2);
des_set_key((void *)(secret + 16), s3);
des_check_key = 1;
des_set_odd_parity((void *)secret);
des_set_odd_parity((void *)secret+8);
des_set_odd_parity((void *)secret+16);
if(des_set_key((void *)secret, s1) != 0) {
printf("failed to schedule key 1\n");
}
if(des_set_key((void *)(secret + 8), s2)!=0) {
printf("failed to schedule key 2\n");
}
if(des_set_key((void *)(secret + 16), s3)!=0) {
printf("failed to schedule key 3\n");
}
p = ivoff + ivlen;
des_ede3_cbc_encrypt((void *)p, (void *)p,
(long)(ep - p), s1, s2, s3, (void *)ivoff, DES_DECRYPT);
(long)(ep - p),
s1, s2, s3,
(void *)ivoff, DES_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
@ -280,17 +384,18 @@ esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
case NONE:
default:
if (Rflag)
advance = sizeof(struct esp) + sizeof(u_int32_t);
else
advance = sizeof(struct esp);
advance = sizeof(struct esp) + espsecret_xform->replaysize;
break;
}
ep = ep - espsecret_xform->authlen;
/* sanity check for pad length */
if (ep - bp < *(ep - 2))
goto fail;
if (padlen)
*padlen = *(ep - 2) + 2;
if (nhdr)
*nhdr = *(ep - 1);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.61 2000/12/22 22:45:10 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.65 2001/07/04 22:03:14 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -82,6 +82,7 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_short ether_type;
u_short extracted_ethertype;
++infodelay;
ts_print(&h->ts);
if (caplen < ETHER_HDRLEN) {
@ -137,6 +138,9 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}
/*
@ -226,6 +230,19 @@ ether_encap_print(u_short ethertype, const u_char *p,
pppoe_print(p, length);
return (1);
case ETHERTYPE_PPP:
printf("ppp");
if (length) {
printf(": ");
ppp_print(p, length);
}
return (1);
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
mpls_print(p, length);
return (1);
case ETHERTYPE_LAT:
case ETHERTYPE_SCA:
case ETHERTYPE_MOPRC:

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.50 2000/12/23 20:48:13 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.53 2001/11/14 16:46:34 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -52,7 +52,7 @@ static const char rcsid[] =
/*
* Some FDDI interfaces use bit-swapped addresses.
*/
#if defined(ultrix) || defined(__alpha) || defined(__bsdi) || defined(__NetBSD__)
#if defined(ultrix) || defined(__alpha) || defined(__bsdi) || defined(__NetBSD__) || defined(__linux__)
int fddi_bitswap = 0;
#else
int fddi_bitswap = 1;
@ -210,8 +210,8 @@ extract_fddi_addrs(const struct fddi_header *fddip, char *fsrc, char *fdst)
fsrc[i] = fddi_bit_swap[fddip->fddi_shost[i]];
}
else {
memcpy(fdst, (char *)fddip->fddi_dhost, 6);
memcpy(fsrc, (char *)fddip->fddi_shost, 6);
memcpy(fdst, (const char *)fddip->fddi_dhost, 6);
memcpy(fsrc, (const char *)fddip->fddi_shost, 6);
}
}
@ -222,7 +222,7 @@ static inline void
fddi_print(register const struct fddi_header *fddip, register u_int length,
register const u_char *fsrc, register const u_char *fdst)
{
char *srcname, *dstname;
const char *srcname, *dstname;
srcname = etheraddr_string(fsrc);
dstname = etheraddr_string(fdst);
@ -258,10 +258,11 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
{
u_int caplen = h->caplen;
u_int length = h->len;
const struct fddi_header *fddip = (struct fddi_header *)p;
const struct fddi_header *fddip = (const struct fddi_header *)p;
struct ether_header ehdr;
u_short extracted_ethertype;
++infodelay;
ts_print(&h->ts);
if (caplen < FDDI_HDRLEN) {
@ -328,4 +329,7 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.12 2000/10/07 05:53:10 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.13 2001/09/17 21:58:02 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -52,12 +52,8 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
register const struct ip6_hdr *ip6;
register const u_char *ep;
#if 0
#define TCHECK(var) if ((u_char *)&(var) >= ep - sizeof(var)) goto trunc
#endif
dp = (struct ip6_frag *)bp;
ip6 = (struct ip6_hdr *)bp2;
dp = (const struct ip6_frag *)bp;
ip6 = (const struct ip6_hdr *)bp2;
/* 'ep' points to the end of available data. */
ep = snapend;

View File

@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.9 2000/12/18 05:41:59 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.13 2001/06/15 22:17:31 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -45,38 +45,31 @@ static const char rcsid[] =
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#define GRE_SIZE (20)
struct gre {
u_short flags;
u_short proto;
union {
struct gre_ckof {
u_short cksum;
u_short offset;
} gre_ckof;
u_int32_t key;
u_int32_t seq;
} gre_void1;
union {
u_int32_t key;
u_int32_t seq;
u_int32_t routing;
} gre_void2;
union {
u_int32_t seq;
u_int32_t routing;
} gre_void3;
union {
u_int32_t routing;
} gre_void4;
u_int16_t flags;
u_int16_t proto;
};
/* RFC 2784 - GRE */
#define GRE_CP 0x8000 /* Checksum Present */
#define GRE_RP 0x4000 /* Routing Present */
#define GRE_VER_MASK 0x0007 /* Version */
/* RFC 2890 - Key and Sequence extensions to GRE */
#define GRE_KP 0x2000 /* Key Present */
#define GRE_SP 0x1000 /* Sequence Present */
/* Legacy from RFC 1700 */
#define GRE_RP 0x4000 /* Routing Present */
#define GRE_sP 0x0800 /* strict source route present */
#define GRE_RECUR_MASK 0x0700 /* Recursion Control */
#define GRE_RECUR_SHIFT 8
#define GRE_COP (GRE_RP|GRE_CP) /* Checksum & Offset Present */
/* "Enhanced GRE" from RFC2637 - PPTP */
#define GRE_AP 0x0080 /* Ack present */
#define GRE_MBZ_MASK 0x0078 /* not defined */
/*
* Deencapsulate and print a GRE-tunneled IP datagram
@ -86,17 +79,18 @@ gre_print(const u_char *bp, u_int length)
{
const u_char *cp = bp + 4;
const struct gre *gre;
u_short flags, proto, extracted_ethertype;
u_int16_t flags, proto;
u_short ver=0;
u_short extracted_ethertype;
gre = (const struct gre *)bp;
if (length < GRE_SIZE) {
goto trunc;
}
TCHECK(gre->proto);
flags = EXTRACT_16BITS(&gre->flags);
proto = EXTRACT_16BITS(&gre->proto);
(void)printf("gre ");
if (vflag) {
if (flags) {
/* Decode the flags */
putchar('[');
if (flags & GRE_CP)
@ -107,20 +101,68 @@ gre_print(const u_char *bp, u_int length)
putchar('K');
if (flags & GRE_SP)
putchar('S');
if (flags & GRE_sP)
putchar('s');
if (flags & GRE_AP)
putchar('A');
if (flags & GRE_RECUR_MASK)
printf("R%x", (flags & GRE_RECUR_MASK) >> GRE_RECUR_SHIFT);
ver = flags & GRE_VER_MASK;
printf("v%u", ver);
if (flags & GRE_MBZ_MASK)
printf("!%x", flags & GRE_MBZ_MASK);
fputs("] ", stdout);
}
/* Checksum & Offset are present */
if ((flags & GRE_CP) | (flags & GRE_RP))
cp += 4;
if (flags & GRE_COP) {
int checksum, offset;
TCHECK2(*cp, 4);
checksum = EXTRACT_16BITS(cp);
offset = EXTRACT_16BITS(cp + 2);
if (flags & GRE_CP) {
/* Checksum present */
/* todo: check checksum */
if (vflag > 1)
printf("C:%04x ", checksum);
}
if (flags & GRE_RP) {
/* Offset present */
if (vflag > 1)
printf("O:%04x ", offset);
}
cp += 4; /* skip checksum and offset */
}
if (flags & GRE_KP) {
TCHECK2(*cp, 4);
if (ver == 1) { /* PPTP */
if (vflag > 1)
printf("PL:%u ", EXTRACT_16BITS(cp));
printf("ID:%04x ", EXTRACT_16BITS(cp+2));
}
else
printf("K:%08x ", EXTRACT_32BITS(cp));
cp += 4; /* skip key */
}
if (flags & GRE_SP) {
TCHECK2(*cp, 4);
printf("S:%u ", EXTRACT_32BITS(cp));
cp += 4; /* skip seq */
}
if (flags & GRE_AP && ver >= 1) {
TCHECK2(*cp, 4);
printf("A:%u ", EXTRACT_32BITS(cp));
cp += 4; /* skip ack */
}
/* We don't support routing fields (variable length) now. Punt. */
if (flags & GRE_RP)
return;
if (flags & GRE_KP)
cp += 4;
if (flags & GRE_SP)
cp += 4;
TCHECK(cp[0]);
length -= cp - bp;
if (ether_encap_print(proto, cp, length, length,

View File

@ -0,0 +1,137 @@
/*
* Copyright (C) 2001 Julian Cowley
* 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.
*/
/* Cisco Hot Standby Router Protocol (HSRP). */
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.2 2001/10/08 16:12:37 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <stdio.h>
#include <netinet/in.h>
#include "interface.h"
#include "addrtoname.h"
/* HSRP op code types. */
static const char *op_code_str[] = {
"hello",
"coup",
"resign"
};
/* HSRP states and associated names. */
static struct tok states[] = {
{ 0, "initial" },
{ 1, "learn" },
{ 2, "listen" },
{ 4, "speak" },
{ 8, "standby" },
{ 16, "active" },
{ 0, NULL }
};
/*
* RFC 2281:
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Version | Op Code | State | Hellotime |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Holdtime | Priority | Group | Reserved |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Authentication Data |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Authentication Data |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Virtual IP Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define HSRP_AUTH_SIZE 8
/* HSRP protocol header. */
struct hsrp {
u_char hsrp_version;
u_char hsrp_op_code;
u_char hsrp_state;
u_char hsrp_hellotime;
u_char hsrp_holdtime;
u_char hsrp_priority;
u_char hsrp_group;
u_char hsrp_reserved;
u_char hsrp_authdata[HSRP_AUTH_SIZE];
struct in_addr hsrp_virtaddr;
};
void
hsrp_print(register const u_char *bp, register u_int len)
{
struct hsrp *hp = (struct hsrp *) bp;
TCHECK(hp->hsrp_version);
printf("HSRPv%d", hp->hsrp_version);
if (hp->hsrp_version != 0)
return;
TCHECK(hp->hsrp_op_code);
printf("-");
printf("%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code));
printf("%d: ", len);
TCHECK(hp->hsrp_state);
printf("state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state));
TCHECK(hp->hsrp_group);
printf("group=%d ", hp->hsrp_group);
TCHECK(hp->hsrp_reserved);
if (hp->hsrp_reserved != 0) {
printf("[reserved=%d!] ", hp->hsrp_reserved);
}
TCHECK2(hp->hsrp_virtaddr, sizeof(hp->hsrp_virtaddr));
printf("addr=%s", ipaddr_string(&hp->hsrp_virtaddr));
if (vflag) {
printf(" hellotime=");
relts_print(hp->hsrp_hellotime);
printf(" holdtime=");
relts_print(hp->hsrp_holdtime);
printf(" priority=%d", hp->hsrp_priority);
printf(" auth=\"");
fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata), NULL);
printf("\"");
}
return;
trunc:
printf("[|hsrp]");
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.57 2000/10/10 05:03:32 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.62 2001/07/24 16:56:11 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -245,7 +245,7 @@ static struct tok type2str[] = {
{ ICMP_REDIRECT_NET, "redirect %s to net %s" },
{ ICMP_REDIRECT_HOST, "redirect %s to host %s" },
{ ICMP_REDIRECT_TOSNET, "redirect-tos %s to net %s" },
{ ICMP_REDIRECT_TOSHOST, "redirect-tos %s to net %s" },
{ ICMP_REDIRECT_TOSHOST, "redirect-tos %s to host %s" },
{ 0, NULL }
};
@ -268,27 +268,21 @@ struct id_rdiscovery {
};
void
icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
{
register char *cp;
register const struct icmp *dp;
register const struct ip *ip;
register const char *str, *fmt;
register const struct ip *oip;
register const struct udphdr *ouh;
register u_int hlen, dport, mtu;
char *cp;
const struct icmp *dp;
const struct ip *ip;
const char *str, *fmt;
const struct ip *oip;
const struct udphdr *ouh;
u_int hlen, dport, mtu;
char buf[MAXHOSTNAMELEN + 100];
dp = (struct icmp *)bp;
ip = (struct ip *)bp2;
str = buf;
#if 0
(void)printf("%s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
#endif
TCHECK(dp->icmp_code);
switch (dp->icmp_type) {
@ -339,12 +333,12 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
{
register const struct mtu_discovery *mp;
mp = (struct mtu_discovery *)&dp->icmp_void;
mtu = EXTRACT_16BITS(&mp->nexthopmtu);
if (mtu) {
mtu = EXTRACT_16BITS(&mp->nexthopmtu);
if (mtu) {
(void)snprintf(buf, sizeof(buf),
"%s unreachable - need to frag (mtu %d)",
ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
} else {
} else {
(void)snprintf(buf, sizeof(buf),
"%s unreachable - need to frag",
ipaddr_string(&dp->icmp_ip.ip_dst));
@ -480,7 +474,7 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
str = tok2str(icmp2str, "type-#%d", dp->icmp_type);
break;
}
(void)printf("icmp: %s", str);
(void)printf("icmp: %s", str);
if (vflag) {
if (TTEST2(*bp, plen)) {
if (in_cksum((u_short*)dp, plen, 0))

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.42 2000/12/13 07:57:05 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.56 2001/06/27 02:48:43 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -43,6 +43,7 @@ static const char rcsid[] =
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include "ip6.h"
@ -54,6 +55,9 @@ static const char rcsid[] =
#include "udp.h"
#include "ah.h"
static const char *get_rtpref(u_int);
static const char *get_lifetime(u_int32_t);
static void print_lladdr(const u_char *, size_t);
void icmp6_opt_print(const u_char *, int);
void mld6_print(const u_char *);
static struct udphdr *get_upperlayer(u_char *, int *);
@ -65,23 +69,60 @@ void icmp6_rrenum_print(int, const u_char *, const u_char *);
#define abs(a) ((0 < (a)) ? (a) : -(a))
#endif
static const char *
get_rtpref(u_int v)
{
static const char *rtpref_str[] = {
"medium", /* 00 */
"high", /* 01 */
"rsv", /* 10 */
"low" /* 11 */
};
return rtpref_str[((v & ND_RA_FLAG_RTPREF_MASK) >> 3) & 0xff];
}
static const char *
get_lifetime(u_int32_t v)
{
static char buf[20];
if (v == (u_int32_t)~0UL)
return "infinity";
else {
snprintf(buf, sizeof(buf), "%u", v);
return buf;
}
}
static void
print_lladdr(const u_int8_t *p, size_t l)
{
const u_int8_t *ep, *q;
q = p;
ep = p + l;
while (l > 0 && q < ep) {
if (q > p)
printf(":");
printf("%02x", *q++);
l--;
}
}
void
icmp6_print(register const u_char *bp, register const u_char *bp2)
icmp6_print(const u_char *bp, const u_char *bp2)
{
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 dport;
register const u_char *ep;
const struct ip6_hdr *ip;
const char *str;
const struct ip6_hdr *oip;
const struct udphdr *ouh;
int dport;
const u_char *ep;
char buf[256];
int icmp6len, prot;
#if 0
#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
#endif
dp = (struct icmp6_hdr *)bp;
ip = (struct ip6_hdr *)bp2;
oip = (struct ip6_hdr *)(dp + 1);
@ -94,12 +135,6 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
else /* XXX: jumbo payload case... */
icmp6len = snapend - bp;
#if 0
(void)printf("%s > %s: ",
ip6addr_string(&ip->ip6_src),
ip6addr_string(&ip->ip6_dst));
#endif
TCHECK(dp->icmp6_code);
switch (dp->icmp6_type) {
case ICMP6_DST_UNREACH:
@ -155,7 +190,7 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
break;
case ICMP6_PACKET_TOO_BIG:
TCHECK(dp->icmp6_mtu);
printf("icmp6: too big %u\n", (u_int32_t)ntohl(dp->icmp6_mtu));
printf("icmp6: too big %u", (u_int32_t)ntohl(dp->icmp6_mtu));
break;
case ICMP6_TIME_EXCEEDED:
TCHECK(oip->ip6_dst);
@ -177,15 +212,15 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
case ICMP6_PARAMPROB_HEADER:
printf("icmp6: parameter problem errorneous - octet %u\n",
printf("icmp6: parameter problem errorneous - octet %u",
(u_int32_t)ntohl(dp->icmp6_pptr));
break;
case ICMP6_PARAMPROB_NEXTHEADER:
printf("icmp6: parameter problem next header - octet %u\n",
printf("icmp6: parameter problem next header - octet %u",
(u_int32_t)ntohl(dp->icmp6_pptr));
break;
case ICMP6_PARAMPROB_OPTION:
printf("icmp6: parameter problem option - octet %u\n",
printf("icmp6: parameter problem option - octet %u",
(u_int32_t)ntohl(dp->icmp6_pptr));
break;
default:
@ -232,13 +267,16 @@ 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)
if (p->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT)
printf("H");
if (p->nd_ra_flags_reserved != 0)
if ((p->nd_ra_flags_reserved & ~ND_RA_FLAG_RTPREF_MASK)
!= 0)
printf(" ");
printf("pref=%s, ",
get_rtpref(p->nd_ra_flags_reserved));
printf("router_ltime=%d, ", ntohs(p->nd_ra_router_lifetime));
printf("reachable_time=%u, ",
(u_int32_t)ntohl(p->nd_ra_reachable));
@ -325,15 +363,12 @@ icmp6_print(register const u_char *bp, register const u_char *bp2)
return;
trunc:
fputs("[|icmp6]", stdout);
#if 0
#undef TCHECK
#endif
}
static struct udphdr *
get_upperlayer(register u_char *bp, int *prot)
get_upperlayer(u_char *bp, int *prot)
{
register const u_char *ep;
const u_char *ep;
struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
struct udphdr *uh;
struct ip6_hbh *hbh;
@ -404,149 +439,151 @@ get_upperlayer(register u_char *bp, int *prot)
}
void
icmp6_opt_print(register const u_char *bp, int resid)
icmp6_opt_print(const u_char *bp, int resid)
{
register const struct nd_opt_hdr *op;
register const struct nd_opt_hdr *opl; /* why there's no struct? */
register const struct nd_opt_prefix_info *opp;
register const struct icmp6_opts_redirect *opr;
register const struct nd_opt_mtu *opm;
register const struct nd_opt_advint *opa;
register const u_char *ep;
int opts_len;
#if 0
register const struct ip6_hdr *ip;
register const char *str;
register const struct ip6_hdr *oip;
register const struct udphdr *ouh;
register int hlen, dport;
char buf[256];
#endif
const struct nd_opt_hdr *op;
const struct nd_opt_hdr *opl; /* why there's no struct? */
const struct nd_opt_prefix_info *opp;
const struct icmp6_opts_redirect *opr;
const struct nd_opt_mtu *opm;
const struct nd_opt_advinterval *opa;
const struct nd_opt_route_info *opri;
const u_char *cp, *ep;
struct in6_addr in6, *in6p;
size_t l;
#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
op = (struct nd_opt_hdr *)bp;
#if 0
ip = (struct ip6_hdr *)bp2;
oip = &dp->icmp6_ip6;
str = buf;
#endif
cp = bp;
/* 'ep' points to the end of available data. */
ep = snapend;
ECHECK(op->nd_opt_len);
if (resid <= 0)
return;
switch (op->nd_opt_type) {
case ND_OPT_SOURCE_LINKADDR:
opl = (struct nd_opt_hdr *)op;
#if 1
if ((u_char *)opl + (opl->nd_opt_len << 3) > ep)
while (cp < ep) {
op = (struct nd_opt_hdr *)cp;
ECHECK(op->nd_opt_len);
if (resid <= 0)
return;
if (op->nd_opt_len == 0)
goto trunc;
#else
TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
#endif
printf("(src lladdr: %s", /*)*/
etheraddr_string((u_char *)(opl + 1)));
if (opl->nd_opt_len != 1)
printf("!");
/*(*/
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
case ND_OPT_TARGET_LINKADDR:
opl = (struct nd_opt_hdr *)op;
#if 1
if ((u_char *)opl + (opl->nd_opt_len << 3) > ep)
if (cp + (op->nd_opt_len << 3) > ep)
goto trunc;
#else
TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
#endif
printf("(tgt lladdr: %s", /*)*/
etheraddr_string((u_char *)(opl + 1)));
if (opl->nd_opt_len != 1)
printf("!");
/*(*/
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
case ND_OPT_PREFIX_INFORMATION:
opp = (struct nd_opt_prefix_info *)op;
TCHECK(opp->nd_opt_pi_prefix);
printf("(prefix info: "); /*)*/
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)
printf("L");
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)
printf("A");
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ROUTER)
printf("R");
if (opp->nd_opt_pi_flags_reserved)
printf(" ");
printf("valid_ltime=");
if ((u_int32_t)ntohl(opp->nd_opt_pi_valid_time) == ~0U)
printf("infinity");
else {
printf("%u", (u_int32_t)ntohl(opp->nd_opt_pi_valid_time));
switch (op->nd_opt_type) {
case ND_OPT_SOURCE_LINKADDR:
opl = (struct nd_opt_hdr *)op;
printf("(src lladdr: ");
l = (op->nd_opt_len << 3) - 2;
print_lladdr(cp + 2, l);
/*(*/
printf(")");
break;
case ND_OPT_TARGET_LINKADDR:
opl = (struct nd_opt_hdr *)op;
printf("(tgt lladdr: ");
l = (op->nd_opt_len << 3) - 2;
print_lladdr(cp + 2, l);
/*(*/
printf(")");
break;
case ND_OPT_PREFIX_INFORMATION:
opp = (struct nd_opt_prefix_info *)op;
TCHECK(opp->nd_opt_pi_prefix);
printf("(prefix info: "); /*)*/
if (op->nd_opt_len != 4) {
printf("badlen");
/*(*/
printf(")");
break;
}
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)
printf("L");
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)
printf("A");
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ROUTER)
printf("R");
if (opp->nd_opt_pi_flags_reserved)
printf(" ");
printf("valid_ltime=%s,",
get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_valid_time)));
printf("preferred_ltime=%s,",
get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_preferred_time)));
printf("prefix=%s/%d",
ip6addr_string(&opp->nd_opt_pi_prefix),
opp->nd_opt_pi_prefix_len);
if (opp->nd_opt_pi_len != 4)
printf("!");
/*(*/
printf(")");
break;
case ND_OPT_REDIRECTED_HEADER:
opr = (struct icmp6_opts_redirect *)op;
printf("(redirect)");
/* xxx */
break;
case ND_OPT_MTU:
opm = (struct nd_opt_mtu *)op;
TCHECK(opm->nd_opt_mtu_mtu);
printf("(mtu:"); /*)*/
if (op->nd_opt_len != 1) {
printf("badlen");
/*(*/
printf(")");
break;
}
printf(" mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu));
if (opm->nd_opt_mtu_len != 1)
printf("!");
printf(")");
break;
case ND_OPT_ADVINTERVAL:
opa = (struct nd_opt_advinterval *)op;
TCHECK(opa->nd_opt_adv_interval);
printf("(advint:"); /*)*/
printf(" advint=%u",
(u_int32_t)ntohl(opa->nd_opt_adv_interval));
/*(*/
printf(")");
break;
case ND_OPT_ROUTE_INFO:
opri = (struct nd_opt_route_info *)op;
TCHECK(opri->nd_opt_rti_lifetime);
memset(&in6, 0, sizeof(in6));
in6p = (struct in6_addr *)(opri + 1);
switch (op->nd_opt_len) {
case 1:
break;
case 2:
TCHECK2(*in6p, 8);
memcpy(&in6, opri + 1, 8);
break;
case 3:
TCHECK(*in6p);
memcpy(&in6, opri + 1, sizeof(in6));
break;
default:
goto trunc;
}
printf("(rtinfo:"); /*)*/
printf(" %s/%u", ip6addr_string(&in6),
opri->nd_opt_rti_prefixlen);
printf(", pref=%s", get_rtpref(opri->nd_opt_rti_flags));
printf(", lifetime=%s",
get_lifetime((u_int32_t)ntohl(opri->nd_opt_rti_lifetime)));
/*(*/
printf(")");
break;
default:
printf("(unknwon opt_type=%d, opt_len=%d)",
op->nd_opt_type, op->nd_opt_len);
break;
}
printf(", ");
printf("preffered_ltime=");
if ((u_int32_t)ntohl(opp->nd_opt_pi_preferred_time) == ~0U)
printf("infinity");
else {
printf("%u", (u_int32_t)ntohl(opp->nd_opt_pi_preferred_time));
}
printf(", ");
printf("prefix=%s/%d", ip6addr_string(&opp->nd_opt_pi_prefix),
opp->nd_opt_pi_prefix_len);
if (opp->nd_opt_pi_len != 4)
printf("!");
/*(*/
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
case ND_OPT_REDIRECTED_HEADER:
opr = (struct icmp6_opts_redirect *)op;
printf("(redirect)");
/* xxx */
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
case ND_OPT_MTU:
opm = (struct nd_opt_mtu *)op;
TCHECK(opm->nd_opt_mtu_mtu);
printf("(mtu: "); /*)*/
printf("mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu));
if (opm->nd_opt_mtu_len != 1)
printf("!");
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
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)",
op->nd_opt_type, opts_len);
if (opts_len == 0)
opts_len = 1; /* XXX */
icmp6_opt_print((const u_char *)op + (opts_len << 3),
resid - (opts_len << 3));
break;
cp += op->nd_opt_len << 3;
resid -= op->nd_opt_len << 3;
}
return;
trunc:
fputs("[ndp opt]", stdout);
return;
@ -554,10 +591,10 @@ icmp6_opt_print(register const u_char *bp, int resid)
}
void
mld6_print(register const u_char *bp)
mld6_print(const u_char *bp)
{
register struct mld6_hdr *mp = (struct mld6_hdr *)bp;
register const u_char *ep;
struct mld6_hdr *mp = (struct mld6_hdr *)bp;
const u_char *ep;
/* 'ep' points to the end of available data. */
ep = snapend;
@ -820,7 +857,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
break;
printf(" %s", getname6(bp + i));
i += sizeof(struct in6_addr);
printf("(%d)", ntohl(*(int32_t *)(bp + i)));
printf("(%d)", (int32_t)ntohl(*(int32_t *)(bp + i)));
i += sizeof(int32_t);
}
i = ni6->ni_flags;
@ -893,7 +930,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
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_FORCEAPPLY, "A"),
F(ICMP6_RR_FLAGS_SPECSITE, "S"),
F(ICMP6_RR_FLAGS_PREVDONE, "P"));
}
@ -912,7 +949,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
TCHECK(match->rpm_prefix);
if (vflag)
if (vflag > 1)
printf("\n\t");
else
printf(" ");
@ -946,7 +983,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
TCHECK(use->rpu_prefix);
if (vflag)
if (vflag > 1)
printf("\n\t");
else
printf(" ");

View File

@ -21,7 +21,7 @@
#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)";
"@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.5 2001/09/17 21:58:02 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -114,7 +114,7 @@ static struct tok igmpv3report2str[] = {
static void
print_mtrace(register const u_char *bp, register u_int len)
{
register struct tr_query *tr = (struct tr_query *)(bp + 8);
register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
printf("mtrace %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
@ -127,7 +127,7 @@ print_mtrace(register const u_char *bp, register u_int len)
static void
print_mresp(register const u_char *bp, register u_int len)
{
register struct tr_query *tr = (struct tr_query *)(bp + 8);
register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
printf("mresp %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
@ -138,11 +138,10 @@ print_mresp(register const u_char *bp, register u_int len)
}
static void
print_igmpv3_report(register const u_char *bp, register u_int len,
register const u_char *bp2)
print_igmpv3_report(register const u_char *bp, register u_int len)
{
int group, nsrcs, ngroups;
register int i, j;
u_int group, nsrcs, ngroups;
register u_int i, j;
/* Minimum len is 16, and should be a multiple of 4 */
if (len < 16 || len & 0x03) {
@ -193,11 +192,12 @@ print_igmpv3_report(register const u_char *bp, register u_int len,
}
static void
print_igmpv3_query(register const u_char *bp, register u_int len,
register const u_char *bp2)
print_igmpv3_query(register const u_char *bp, register u_int len)
{
int nsrcs;
register int i;
u_int mrc;
int mrt;
u_int nsrcs;
register u_int i;
(void)printf(" v3");
/* Minimum len is 12, and should be a multiple of 4 */
@ -205,6 +205,17 @@ print_igmpv3_query(register const u_char *bp, register u_int len,
(void)printf(" [invalid len %d]", len);
return;
}
mrc = bp[1];
if (mrc < 128) {
mrt = mrc;
} else {
mrt = ((mrc & 0x0f) | 0x10) << (((mrc & 0x70) >> 4) + 3);
}
if (mrc != 100) {
(void)printf(" [max resp time ");
relts_print(mrt);
(void)printf("]");
}
TCHECK2(bp[4], 4);
if (EXTRACT_32BITS(&bp[4]) == 0)
return;
@ -232,8 +243,7 @@ print_igmpv3_query(register const u_char *bp, register u_int len,
}
void
igmp_print(register const u_char *bp, register u_int len,
register const u_char *bp2)
igmp_print(register const u_char *bp, register u_int len)
{
if (qflag) {
(void)printf("igmp");
@ -245,7 +255,7 @@ igmp_print(register const u_char *bp, register u_int len,
case 0x11:
(void)printf("igmp query");
if (len >= 12)
print_igmpv3_query(bp, len, bp2);
print_igmpv3_query(bp, len);
else {
if (bp[1]) {
(void)printf(" v2");
@ -269,7 +279,7 @@ igmp_print(register const u_char *bp, register u_int len,
break;
case 0x22:
(void)printf("igmp v3 report");
print_igmpv3_report(bp, len, bp2);
print_igmpv3_report(bp, len);
break;
case 0x17:
(void)printf("igmp leave %s", ipaddr_string(&bp[4]));

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.15 2000/09/29 04:58:40 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.16 2001/06/15 22:17:32 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -92,9 +92,7 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
hdr = (struct igrphdr *)bp;
ip = (struct ip *)bp2;
cp = (u_char *)(hdr + 1);
(void)printf("%s > %s: igrp: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
(void)printf("igrp:");
/* Header */
TCHECK(*hdr);
@ -126,7 +124,7 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
igrp_entry_print((struct igrprte *)cp, 0, 1);
--next;
} else {
(void)printf("[extra bytes %d]", length);
(void)printf(" [extra bytes %d]", length);
break;
}
cp += IGRP_RTE_SIZE;
@ -135,5 +133,5 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
if (nint == 0 && nsys == 0 && next == 0)
return;
trunc:
fputs("[|igrp]", stdout);
fputs(" [|igrp]", stdout);
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.92 2001/01/02 23:00:01 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.100 2001/09/17 21:58:03 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -203,7 +203,7 @@ ip_optprint(register const u_char *cp, u_int length)
printf("{%d}", len);
else if (cp[2] || cp[3])
printf("%d.%d", cp[2], cp[3]);
break;
break;
default:
printf(" IPOPT-%d{%d}", cp[0], len);
@ -217,7 +217,7 @@ ip_optprint(register const u_char *cp, u_int length)
* don't modifiy the packet.
*/
u_short
in_cksum(const u_short *addr, register int len, u_short csum)
in_cksum(const u_short *addr, register u_int len, int csum)
{
int nleft = len;
const u_short *w = addr;
@ -301,7 +301,7 @@ ip_print(register const u_char *bp, register u_int length)
len = ntohs(ip->ip_len);
if (length < len)
(void)printf("truncated-ip - %d bytes missing!",
(void)printf("truncated-ip - %d bytes missing! ",
len - length);
len -= hlen;
len0 = len;
@ -315,7 +315,11 @@ ip_print(register const u_char *bp, register u_int length)
cp = (const u_char *)ip + hlen;
nh = ip->ip_p;
if (nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
#ifndef IPPROTO_SCTP
#define IPPROTO_SCTP 132
#endif
if (nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
nh != IPPROTO_SCTP) {
(void)printf("%s > %s: ", ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
}
@ -337,10 +341,10 @@ ip_print(register const u_char *bp, register u_int length)
#endif
case IPPROTO_ESP:
{
int enh;
advance = esp_print(cp, (const u_char *)ip, &enh);
int enh, padlen;
advance = esp_print(cp, (const u_char *)ip, &enh, &padlen);
cp += advance;
len -= advance;
len -= advance + padlen;
if (enh < 0)
break;
nh = enh & 0xff;
@ -362,6 +366,10 @@ ip_print(register const u_char *bp, register u_int length)
goto again;
}
case IPPROTO_SCTP:
sctp_print(cp, (const u_char *)ip, len);
break;
case IPPROTO_TCP:
tcp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
break;
@ -382,10 +390,6 @@ ip_print(register const u_char *bp, register u_int length)
break;
case IPPROTO_ND:
#if 0
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
#endif
(void)printf(" nd %d", len);
break;
@ -404,20 +408,14 @@ ip_print(register const u_char *bp, register u_int length)
#define IPPROTO_IGMP 2
#endif
case IPPROTO_IGMP:
igmp_print(cp, len, (const u_char *)ip);
igmp_print(cp, len);
break;
case 4:
/* DVMRP multicast tunnel (ip-in-ip encapsulation) */
#if 0
if (vflag)
(void)printf("%s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
#endif
ip_print(cp, len);
if (! vflag) {
printf(" (ipip)");
printf(" (ipip-proto-4)");
return;
}
break;
@ -428,17 +426,7 @@ ip_print(register const u_char *bp, register u_int length)
#endif
case IP6PROTO_ENCAP:
/* ip6-in-ip encapsulation */
#if 0
if (vflag)
(void)printf("%s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
#endif
ip6_print(cp, len);
if (! vflag) {
printf(" (encap)");
return;
}
break;
#endif /*INET6*/
@ -447,31 +435,15 @@ ip_print(register const u_char *bp, register u_int length)
#define IPPROTO_GRE 47
#endif
case IPPROTO_GRE:
if (vflag)
(void)printf("gre %s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
/* do it */
gre_print(cp, len);
if (! vflag) {
printf(" (gre encap)");
return;
}
break;
break;
#ifndef IPPROTO_MOBILE
#define IPPROTO_MOBILE 55
#endif
case IPPROTO_MOBILE:
if (vflag)
(void)printf("mobile %s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
mobile_print(cp, len);
if (! vflag) {
printf(" (mobile encap)");
return;
}
break;
#ifndef IPPROTO_PIM
@ -485,18 +457,10 @@ ip_print(register const u_char *bp, register u_int length)
#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),
ipaddr_string(&ip->ip_dst));
#endif
(void)printf(" ip-proto-%d %d", nh, len);
break;
}
@ -537,10 +501,17 @@ ip_print(register const u_char *bp, register u_int length)
if (ip->ip_tos) {
(void)printf(" [tos 0x%x", (int)ip->ip_tos);
/* ECN bits */
if (ip->ip_tos&0x02) {
(void)printf(",ECT");
if (ip->ip_tos&0x01)
if (ip->ip_tos & 0x03) {
switch (ip->ip_tos & 0x03) {
case 1:
(void)printf(",ECT(1)");
break;
case 2:
(void)printf(",ECT(0)");
break;
case 3:
(void)printf(",CE");
}
}
(void)printf("] ");
}
@ -592,15 +563,15 @@ ipN_print(register const u_char *bp, register u_int length)
memcpy (&hdr, (char *)ip, 4);
switch (IP_V(&hdr)) {
case 4:
ip_print (bp, length);
return;
ip_print (bp, length);
return;
#ifdef INET6
case 6:
ip6_print (bp, length);
return;
ip6_print (bp, length);
return;
#endif
default:
(void)printf("unknown ip %d", IP_V(&hdr));
return;
(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.16 2000/11/17 19:08:15 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.21 2001/11/16 02:17:36 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -51,11 +51,11 @@ static const char rcsid[] =
* print an IP6 datagram.
*/
void
ip6_print(register const u_char *bp, register int length)
ip6_print(register const u_char *bp, register u_int length)
{
register const struct ip6_hdr *ip6;
register int advance;
register int len;
register u_int len;
register const u_char *cp;
int nh;
int fragmented = 0;
@ -66,24 +66,23 @@ ip6_print(register const u_char *bp, register int length)
#ifdef LBL_ALIGN
/*
* 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 ((u_long)ip6 & 15) {
static u_char *abuf;
if (abuf == NULL)
if (abuf == NULL) {
abuf = malloc(snaplen);
if (abuf == NULL)
error("ip6_print: malloc");
}
memcpy(abuf, ip6, min(length, snaplen));
snapend += abuf - (u_char *)ip6;
packetp = abuf;
ip6 = (struct ip6_hdr *)abuf;
bp = abuf;
}
#endif
if ((u_char *)(ip6 + 1) > snapend) {
printf("[|ip6]");
return;
}
TCHECK(*ip6);
if (length < sizeof (struct ip6_hdr)) {
(void)printf("truncated-ip6 %d", length);
return;
@ -100,7 +99,7 @@ ip6_print(register const u_char *bp, register int length)
while (cp < snapend) {
cp += advance;
if (cp == (u_char *)(ip6 + 1)
if (cp == (const u_char *)(ip6 + 1)
&& nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
(void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src),
ip6addr_string(&ip6->ip6_dst));
@ -143,11 +142,12 @@ ip6_print(register const u_char *bp, register int length)
break;
case IPPROTO_ESP:
{
int enh;
advance = esp_print(cp, (const u_char *)ip6, &enh);
int enh, padlen;
advance = esp_print(cp, (const u_char *)ip6, &enh, &padlen);
if (enh < 0)
goto end;
nh = enh & 0xff;
len -= padlen;
break;
}
#ifndef IPPROTO_IPCOMP
@ -221,6 +221,9 @@ ip6_print(register const u_char *bp, register int length)
(void)printf(", hlim %d", (int)ip6->ip6_hlim);
printf(")");
}
return;
trunc:
(void)printf("[|ip6]");
}
#endif /* INET6 */

View File

@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.8 2000/12/13 07:57:05 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.9 2001/05/09 02:47:26 itojun Exp $";
#endif
#ifdef INET6
@ -78,10 +78,20 @@ ip6_sopt_print(const u_char *bp, int len)
int optlen;
for (i = 0; i < len; i += optlen) {
if (bp[i] == IP6OPT_PAD1)
optlen = 1;
else {
if (i + 1 < len)
optlen = bp[i + 1] + 2;
else
goto trunc;
}
if (i + optlen > len)
goto trunc;
switch (bp[i]) {
case IP6OPT_PAD1:
printf(", pad1");
optlen = 1;
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
@ -89,7 +99,6 @@ ip6_sopt_print(const u_char *bp, int len)
goto trunc;
}
printf(", padn");
optlen = bp[i + 1] + 2;
break;
case IP6SOPT_ALTCOA:
if (len - i < IP6SOPT_ALTCOA_MINLEN) {
@ -97,7 +106,6 @@ ip6_sopt_print(const u_char *bp, int len)
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) {
@ -105,7 +113,6 @@ ip6_sopt_print(const u_char *bp, int len)
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) {
@ -113,7 +120,6 @@ ip6_sopt_print(const u_char *bp, int len)
goto trunc;
}
printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]);
optlen = bp[i + 1] + 2;
break;
}
}
@ -130,10 +136,20 @@ ip6_opt_print(const u_char *bp, int len)
int optlen;
for (i = 0; i < len; i += optlen) {
if (bp[i] == IP6OPT_PAD1)
optlen = 1;
else {
if (i + 1 < len)
optlen = bp[i + 1] + 2;
else
goto trunc;
}
if (i + optlen > len)
goto trunc;
switch (bp[i]) {
case IP6OPT_PAD1:
printf("(pad1)");
optlen = 1;
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
@ -141,7 +157,6 @@ ip6_opt_print(const u_char *bp, int len)
goto trunc;
}
printf("(padn)");
optlen = bp[i + 1] + 2;
break;
case IP6OPT_ROUTER_ALERT:
if (len - i < IP6OPT_RTALERT_LEN) {
@ -153,7 +168,6 @@ ip6_opt_print(const u_char *bp, int len)
goto trunc;
}
printf("(rtalert: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2]));
optlen = IP6OPT_RTALERT_LEN;
break;
case IP6OPT_JUMBO:
if (len - i < IP6OPT_JUMBO_LEN) {
@ -165,7 +179,6 @@ ip6_opt_print(const u_char *bp, int len)
goto trunc;
}
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) {
@ -179,10 +192,9 @@ ip6_opt_print(const u_char *bp, int len)
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));
(optlen - IP6OPT_HOMEADDR_MINLEN));
}
printf(")");
optlen = bp[i + 1] + 2;
break;
case IP6OPT_BINDING_UPDATE:
if (len - i < IP6OPT_BU_MINLEN) {
@ -210,7 +222,6 @@ ip6_opt_print(const u_char *bp, int len)
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));
@ -237,10 +248,9 @@ ip6_opt_print(const u_char *bp, int len)
if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN],
(optlen-IP6OPT_BA_MINLEN));
(optlen - IP6OPT_BA_MINLEN));
}
printf(")");
optlen = bp[i + 1] + 2;
break;
case IP6OPT_BINDING_REQ:
if (len - i < IP6OPT_BR_MINLEN) {
@ -250,10 +260,9 @@ ip6_opt_print(const u_char *bp, int len)
printf("(br");
if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN],
(optlen-IP6OPT_BR_MINLEN));
(optlen - IP6OPT_BR_MINLEN));
}
printf(")");
optlen = bp[i + 1] + 2;
break;
default:
if (len - i < IP6OPT_MINLEN) {
@ -261,7 +270,6 @@ ip6_opt_print(const u_char *bp, int len)
goto trunc;
}
printf("(opt_type 0x%02x: len=%d) ", bp[i], bp[i + 1]);
optlen = bp[i + 1] + 2;
break;
}
}

View File

@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.27 2000/09/29 04:58:41 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.32 2001/10/08 21:25:20 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -108,10 +108,22 @@ ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
break;
case IPX_SKT_NETBIOS:
(void)printf(" ipx-netbios %d", length);
#ifdef TCPDUMP_DO_SMB
ipx_netbios_print(datap, length);
#endif
break;
case IPX_SKT_DIAGNOSTICS:
(void)printf(" ipx-diags %d", length);
break;
case IPX_SKT_NWLINK_DGM:
(void)printf(" ipx-nwlink-dgm %d", length);
#ifdef TCPDUMP_DO_SMB
ipx_netbios_print(datap, length);
#endif
break;
case IPX_SKT_EIGRP:
(void)printf(" ipx-eigrp %d", length);
break;
default:
(void)printf(" ipx-#%x %d", dstSkt, length);
break;
@ -136,12 +148,8 @@ ipx_sap_print(const u_short *ipx, u_int length)
else
(void)printf("ipx-sap-nearest-req");
if (length > 0) {
TCHECK(ipx[1]);
(void)printf(" %x '", EXTRACT_16BITS(&ipx[0]));
fn_print((u_char *)&ipx[1], (u_char *)&ipx[1] + 48);
putchar('\'');
}
TCHECK(ipx[0]);
(void)printf(" %x", EXTRACT_16BITS(&ipx[0]));
break;
case 2:
@ -152,7 +160,7 @@ ipx_sap_print(const u_short *ipx, u_int length)
(void)printf("ipx-sap-nearest-resp");
for (i = 0; i < 8 && length > 0; i++) {
TCHECK2(ipx[27], 1);
TCHECK2(ipx[25], 10);
(void)printf(" %x '", EXTRACT_16BITS(&ipx[0]));
fn_print((u_char *)&ipx[1], (u_char *)&ipx[1] + 48);
printf("' addr %s",
@ -162,12 +170,12 @@ ipx_sap_print(const u_short *ipx, u_int length)
}
break;
default:
(void)printf("ipx-sap-?%x", command);
(void)printf("ipx-sap-?%x", command);
break;
}
return;
return;
trunc:
printf("[|ipx %d]", length);
printf("[|ipx %d]", length);
}
void
@ -201,10 +209,11 @@ ipx_rip_print(const u_short *ipx, u_int length)
}
break;
default:
(void)printf("ipx-rip-?%x", command);
(void)printf("ipx-rip-?%x", command);
break;
}
return;
return;
trunc:
printf("[|ipx %d]", length);
printf("[|ipx %d]", length);
}

View File

@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.26 2000/12/12 09:20:26 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.29 2001/10/26 03:41:29 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -702,12 +702,8 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
{
int i;
printf(" len=%d ", len);
for (i = 0; i < len; i++) {
if (isprint(data[i]))
printf("%c", data[i]);
else
printf("\\%03o", data[i]);
}
for (i = 0; i < len; i++)
safeputchar(data[i]);
len = 0;
break;
}
@ -759,7 +755,6 @@ isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase,
}
}
if (data && len) {
len -= sizeof(*p);
printf(" len=%d", len);
if (2 < vflag) {
printf(" ");
@ -1188,7 +1183,7 @@ isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
* encrypted, nothing we can do right now.
* we hope to decrypt the packet in the future...
*/
printf(" [|%s]", NPSTR(base.np));
printf(" [encrypted %s]", NPSTR(base.np));
goto done;
}

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.8 2000/08/18 07:44:46 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.10 2001/11/10 21:37:58 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -49,111 +49,145 @@ static char tstr[] = " [|l2tp]";
#define FALSE 0
#endif
static char *l2tp_message_type_string[] = {
"RESERVED_0", /* 0 Reserved */
"SCCRQ", /* 1 Start-Control-Connection-Request */
"SCCRP", /* 2 Start-Control-Connection-Reply */
"SCCCN", /* 3 Start-Control-Connection-Connected */
"StopCCN", /* 4 Stop-Control-Connection-Notification */
"RESERVED_5", /* 5 Reserved */
"HELLO", /* 6 Hello */
"OCRQ", /* 7 Outgoing-Call-Request */
"OCRP", /* 8 Outgoing-Call-Reply */
"OCCN", /* 9 Outgoing-Call-Connected */
"ICRQ", /* 10 Incoming-Call-Request */
"ICRP", /* 11 Incoming-Call-Reply */
"ICCN", /* 12 Incoming-Call-Connected */
"RESERVED_13", /* 13 Reserved */
"CDN", /* 14 Call-Disconnect-Notify */
"WEN", /* 15 WAN-Error-Notify */
"SLI" /* 16 Set-Link-Info */
#define L2TP_MAX_MSGTYPE_INDEX 17
#define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */
#define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */
#define L2TP_MSGTYPE_SCCCN 3 /* Start-Control-Connection-Connected */
#define L2TP_MSGTYPE_STOPCCN 4 /* Stop-Control-Connection-Notification */
#define L2TP_MSGTYPE_HELLO 6 /* Hello */
#define L2TP_MSGTYPE_OCRQ 7 /* Outgoing-Call-Request */
#define L2TP_MSGTYPE_OCRP 8 /* Outgoing-Call-Reply */
#define L2TP_MSGTYPE_OCCN 9 /* Outgoing-Call-Connected */
#define L2TP_MSGTYPE_ICRQ 10 /* Incoming-Call-Request */
#define L2TP_MSGTYPE_ICRP 11 /* Incoming-Call-Reply */
#define L2TP_MSGTYPE_ICCN 12 /* Incoming-Call-Connected */
#define L2TP_MSGTYPE_CDN 14 /* Call-Disconnect-Notify */
#define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */
#define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */
static struct tok l2tp_msgtype2str[] = {
{ L2TP_MSGTYPE_SCCRQ, "SCCRQ" },
{ L2TP_MSGTYPE_SCCRP, "SCCRP" },
{ L2TP_MSGTYPE_SCCCN, "SCCCN" },
{ L2TP_MSGTYPE_STOPCCN, "StopCCN" },
{ L2TP_MSGTYPE_HELLO, "HELLO" },
{ L2TP_MSGTYPE_OCRQ, "OCRQ" },
{ L2TP_MSGTYPE_OCRP, "OCRP" },
{ L2TP_MSGTYPE_OCCN, "OCCN" },
{ L2TP_MSGTYPE_ICRQ, "ICRQ" },
{ L2TP_MSGTYPE_ICRP, "ICRP" },
{ L2TP_MSGTYPE_ICCN, "ICCN" },
{ L2TP_MSGTYPE_CDN, "CDN" },
{ L2TP_MSGTYPE_WEN, "WEN" },
{ L2TP_MSGTYPE_SLI, "SLI" },
{ 0, NULL }
};
static void l2tp_msgtype_print(const u_char *dat, u_int length);
static void l2tp_result_code_print(const u_char *dat, u_int length);
static void l2tp_proto_ver_print(const u_char *dat, u_int length);
static void l2tp_framing_cap_print(const u_char *dat, u_int length);
static void l2tp_bearer_cap_print(const u_char *dat, u_int length);
static void l2tp_tie_breaker_print(const u_char *dat, u_int length);
static void l2tp_firm_ver_print(const u_char *dat, u_int length);
static void l2tp_host_name_print(const u_char *dat, u_int length);
static void l2tp_vendor_name_print(const u_char *dat, u_int length);
static void l2tp_assnd_tun_id_print(const u_char *dat, u_int length);
static void l2tp_recv_win_size_print(const u_char *dat, u_int length);
static void l2tp_challenge_print(const u_char *dat, u_int length);
static void l2tp_q931_cc_print(const u_char *dat, u_int length);
static void l2tp_challenge_resp_print(const u_char *dat, u_int length);
static void l2tp_assnd_sess_id_print(const u_char *dat, u_int length);
static void l2tp_call_ser_num_print(const u_char *dat, u_int length);
static void l2tp_minimum_bps_print(const u_char *dat, u_int length);
static void l2tp_maximum_bps_print(const u_char *dat, u_int length);
static void l2tp_bearer_type_print(const u_char *dat, u_int length);
static void l2tp_framing_type_print(const u_char *dat, u_int length);
static void l2tp_packet_proc_delay_print(const u_char *dat, u_int length);
static void l2tp_called_number_print(const u_char *dat, u_int length);
static void l2tp_calling_number_print(const u_char *dat, u_int length);
static void l2tp_sub_address_print(const u_char *dat, u_int length);
static void l2tp_tx_conn_speed_print(const u_char *dat, u_int length);
static void l2tp_phy_channel_id_print(const u_char *dat, u_int length);
static void l2tp_ini_recv_lcp_print(const u_char *dat, u_int length);
static void l2tp_last_sent_lcp_print(const u_char *dat, u_int length);
static void l2tp_last_recv_lcp_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_type_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_name_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_chal_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_id_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_resp_print(const u_char *dat, u_int length);
static void l2tp_call_errors_print(const u_char *dat, u_int length);
static void l2tp_accm_print(const u_char *dat, u_int length);
static void l2tp_random_vector_print(const u_char *dat, u_int length);
static void l2tp_private_grp_id_print(const u_char *dat, u_int length);
static void l2tp_rx_conn_speed_print(const u_char *dat, u_int length);
static void l2tp_seq_required_print(const u_char *dat, u_int length);
static void l2tp_avp_print(const u_char *dat, u_int length);
#define L2TP_AVP_MSGTYPE 0 /* Message Type */
#define L2TP_AVP_RESULT_CODE 1 /* Result Code */
#define L2TP_AVP_PROTO_VER 2 /* Protocol Version */
#define L2TP_AVP_FRAMING_CAP 3 /* Framing Capabilities */
#define L2TP_AVP_BEARER_CAP 4 /* Bearer Capabilities */
#define L2TP_AVP_TIE_BREAKER 5 /* Tie Breaker */
#define L2TP_AVP_FIRM_VER 6 /* Firmware Revision */
#define L2TP_AVP_HOST_NAME 7 /* Host Name */
#define L2TP_AVP_VENDOR_NAME 8 /* Vendor Name */
#define L2TP_AVP_ASSND_TUN_ID 9 /* Assigned Tunnel ID */
#define L2TP_AVP_RECV_WIN_SIZE 10 /* Receive Window Size */
#define L2TP_AVP_CHALLENGE 11 /* Challenge */
#define L2TP_AVP_Q931_CC 12 /* Q.931 Cause Code */
#define L2TP_AVP_CHALLENGE_RESP 13 /* Challenge Response */
#define L2TP_AVP_ASSND_SESS_ID 14 /* Assigned Session ID */
#define L2TP_AVP_CALL_SER_NUM 15 /* Call Serial Number */
#define L2TP_AVP_MINIMUM_BPS 16 /* Minimum BPS */
#define L2TP_AVP_MAXIMUM_BPS 17 /* Maximum BPS */
#define L2TP_AVP_BEARER_TYPE 18 /* Bearer Type */
#define L2TP_AVP_FRAMING_TYPE 19 /* Framing Type */
#define L2TP_AVP_PACKET_PROC_DELAY 20 /* Packet Processing Delay (OBSOLETE) */
#define L2TP_AVP_CALLED_NUMBER 21 /* Called Number */
#define L2TP_AVP_CALLING_NUMBER 22 /* Calling Number */
#define L2TP_AVP_SUB_ADDRESS 23 /* Sub-Address */
#define L2TP_AVP_TX_CONN_SPEED 24 /* (Tx) Connect Speed */
#define L2TP_AVP_PHY_CHANNEL_ID 25 /* Physical Channel ID */
#define L2TP_AVP_INI_RECV_LCP 26 /* Initial Received LCP CONFREQ */
#define L2TP_AVP_LAST_SENT_LCP 27 /* Last Sent LCP CONFREQ */
#define L2TP_AVP_LAST_RECV_LCP 28 /* Last Received LCP CONFREQ */
#define L2TP_AVP_PROXY_AUTH_TYPE 29 /* Proxy Authen Type */
#define L2TP_AVP_PROXY_AUTH_NAME 30 /* Proxy Authen Name */
#define L2TP_AVP_PROXY_AUTH_CHAL 31 /* Proxy Authen Challenge */
#define L2TP_AVP_PROXY_AUTH_ID 32 /* Proxy Authen ID */
#define L2TP_AVP_PROXY_AUTH_RESP 33 /* Proxy Authen Response */
#define L2TP_AVP_CALL_ERRORS 34 /* Call Errors */
#define L2TP_AVP_ACCM 35 /* ACCM */
#define L2TP_AVP_RANDOM_VECTOR 36 /* Random Vector */
#define L2TP_AVP_PRIVATE_GRP_ID 37 /* Private Group ID */
#define L2TP_AVP_RX_CONN_SPEED 38 /* (Rx) Connect Speed */
#define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */
#define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */
static struct l2tp_avp_vec l2tp_avp[] = {
{"MSGTYPE", l2tp_msgtype_print}, /* 0 Message Type */
{"RESULT_CODE", l2tp_result_code_print}, /* 1 Result Code */
{"PROTO_VER", l2tp_proto_ver_print}, /* 2 Protocol Version */
{"FRAMING_CAP", l2tp_framing_cap_print}, /* 3 Framing Capabilities */
{"BEARER_CAP", l2tp_bearer_cap_print}, /* 4 Bearer Capabilities */
{"TIE_BREAKER", l2tp_tie_breaker_print}, /* 5 Tie Breaker */
{"FIRM_VER", l2tp_firm_ver_print}, /* 6 Firmware Revision */
{"HOST_NAME", l2tp_host_name_print}, /* 7 Host Name */
{"VENDOR_NAME", l2tp_vendor_name_print}, /* 8 Vendor Name */
{"ASSND_TUN_ID", l2tp_assnd_tun_id_print}, /* 9 Assigned Tunnel ID */
{"RECV_WIN_SIZE", l2tp_recv_win_size_print}, /* 10 Receive Window Size */
{"CHALLENGE", l2tp_challenge_print}, /* 11 Challenge */
{"Q931_CC", l2tp_q931_cc_print}, /* 12 Q.931 Cause Code */
{"CHALLENGE_RESP", l2tp_challenge_resp_print},/* 13 Challenge Response */
{"ASSND_SESS_ID", l2tp_assnd_sess_id_print}, /* 14 Assigned Session ID */
{"CALL_SER_NUM", l2tp_call_ser_num_print}, /* 15 Call Serial Number */
{"MINIMUM_BPS", l2tp_minimum_bps_print},/* 16 Minimum BPS */
{"MAXIMUM_BPS", l2tp_maximum_bps_print}, /* 17 Maximum BPS */
{"BEARER_TYPE", l2tp_bearer_type_print},/* 18 Bearer Type */
{"FRAMING_TYPE", l2tp_framing_type_print}, /* 19 Framing Type */
{"PACKET_PROC_DELAY", l2tp_packet_proc_delay_print}, /* 20 Packet Processing Delay (OBSOLETE) */
{"CALLED_NUMBER", l2tp_called_number_print}, /* 21 Called Number */
{"CALLING_NUMBER", l2tp_calling_number_print},/* 22 Calling Number */
{"SUB_ADDRESS", l2tp_sub_address_print},/* 23 Sub-Address */
{"TX_CONN_SPEED", l2tp_tx_conn_speed_print}, /* 24 (Tx) Connect Speed */
{"PHY_CHANNEL_ID", l2tp_phy_channel_id_print},/* 25 Physical Channel ID */
{"INI_RECV_LCP", l2tp_ini_recv_lcp_print}, /* 26 Initial Received LCP CONFREQ */
{"LAST_SENT_LCP", l2tp_last_sent_lcp_print}, /* 27 Last Sent LCP CONFREQ */
{"LAST_RECV_LCP", l2tp_last_recv_lcp_print}, /* 28 Last Received LCP CONFREQ */
{"PROXY_AUTH_TYPE", l2tp_proxy_auth_type_print},/* 29 Proxy Authen Type */
{"PROXY_AUTH_NAME", l2tp_proxy_auth_name_print},/* 30 Proxy Authen Name */
{"PROXY_AUTH_CHAL", l2tp_proxy_auth_chal_print},/* 31 Proxy Authen Challenge */
{"PROXY_AUTH_ID", l2tp_proxy_auth_id_print}, /* 32 Proxy Authen ID */
{"PROXY_AUTH_RESP", l2tp_proxy_auth_resp_print},/* 33 Proxy Authen Response */
{"CALL_ERRORS", l2tp_call_errors_print}, /* 34 Call Errors */
{"ACCM", l2tp_accm_print}, /* 35 ACCM */
{"RANDOM_VECTOR", l2tp_random_vector_print}, /* 36 Random Vector */
{"PRIVATE_GRP_ID", l2tp_private_grp_id_print},/* 37 Private Group ID */
{"RX_CONN_SPEED", l2tp_rx_conn_speed_print}, /* 38 (Rx) Connect Speed */
{"SEQ_REQUIRED", l2tp_seq_required_print}, /* 39 Sequencing Required */
#define L2TP_MAX_AVP_INDEX 40
static struct tok l2tp_avp2str[] = {
{ L2TP_AVP_MSGTYPE, "MSGTYPE" },
{ L2TP_AVP_RESULT_CODE, "RESULT_CODE" },
{ L2TP_AVP_PROTO_VER, "PROTO_VER" },
{ L2TP_AVP_FRAMING_CAP, "FRAMING_CAP" },
{ L2TP_AVP_BEARER_CAP, "BEARER_CAP" },
{ L2TP_AVP_TIE_BREAKER, "TIE_BREAKER" },
{ L2TP_AVP_FIRM_VER, "FIRM_VER" },
{ L2TP_AVP_HOST_NAME, "HOST_NAME" },
{ L2TP_AVP_VENDOR_NAME, "VENDOR_NAME" },
{ L2TP_AVP_ASSND_TUN_ID, "ASSND_TUN_ID" },
{ L2TP_AVP_RECV_WIN_SIZE, "RECV_WIN_SIZE" },
{ L2TP_AVP_CHALLENGE, "CHALLENGE" },
{ L2TP_AVP_Q931_CC, "Q931_CC", },
{ L2TP_AVP_CHALLENGE_RESP, "CHALLENGE_RESP" },
{ L2TP_AVP_ASSND_SESS_ID, "ASSND_SESS_ID" },
{ L2TP_AVP_CALL_SER_NUM, "CALL_SER_NUM" },
{ L2TP_AVP_MINIMUM_BPS, "MINIMUM_BPS" },
{ L2TP_AVP_MAXIMUM_BPS, "MAXIMUM_BPS" },
{ L2TP_AVP_BEARER_TYPE, "BEARER_TYPE" },
{ L2TP_AVP_FRAMING_TYPE, "FRAMING_TYPE" },
{ L2TP_AVP_PACKET_PROC_DELAY, "PACKET_PROC_DELAY" },
{ L2TP_AVP_CALLED_NUMBER, "CALLED_NUMBER" },
{ L2TP_AVP_CALLING_NUMBER, "CALLING_NUMBER" },
{ L2TP_AVP_SUB_ADDRESS, "SUB_ADDRESS" },
{ L2TP_AVP_TX_CONN_SPEED, "TX_CONN_SPEED" },
{ L2TP_AVP_PHY_CHANNEL_ID, "PHY_CHANNEL_ID" },
{ L2TP_AVP_INI_RECV_LCP, "INI_RECV_LCP" },
{ L2TP_AVP_LAST_SENT_LCP, "LAST_SENT_LCP" },
{ L2TP_AVP_LAST_RECV_LCP, "LAST_RECV_LCP" },
{ L2TP_AVP_PROXY_AUTH_TYPE, "PROXY_AUTH_TYPE" },
{ L2TP_AVP_PROXY_AUTH_NAME, "PROXY_AUTH_NAME" },
{ L2TP_AVP_PROXY_AUTH_CHAL, "PROXY_AUTH_CHAL" },
{ L2TP_AVP_PROXY_AUTH_ID, "PROXY_AUTH_ID" },
{ L2TP_AVP_PROXY_AUTH_RESP, "PROXY_AUTH_RESP" },
{ L2TP_AVP_CALL_ERRORS, "CALL_ERRORS" },
{ L2TP_AVP_ACCM, "ACCM" },
{ L2TP_AVP_RANDOM_VECTOR, "RANDOM_VECTOR" },
{ L2TP_AVP_PRIVATE_GRP_ID, "PRIVATE_GRP_ID" },
{ L2TP_AVP_RX_CONN_SPEED, "RX_CONN_SPEED" },
{ L2TP_AVP_SEQ_REQUIRED, "SEQ_REQUIRED" },
{ L2TP_AVP_PPP_DISCON_CC, "PPP_DISCON_CC" },
{ 0, NULL }
};
static struct tok l2tp_authentype2str[] = {
{ L2TP_AUTHEN_TYPE_RESERVED, "Reserved" },
{ L2TP_AUTHEN_TYPE_TEXTUAL, "Textual" },
{ L2TP_AUTHEN_TYPE_CHAP, "CHAP" },
{ L2TP_AUTHEN_TYPE_PAP, "PAP" },
{ L2TP_AUTHEN_TYPE_NO_AUTH, "No Auth" },
{ L2TP_AUTHEN_TYPE_MSCHAPv1, "MS-CHAPv1" },
{ 0, NULL }
};
#define L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL 0
#define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1
#define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2
static struct tok l2tp_cc_direction2str[] = {
{ L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL, "global error" },
{ L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER, "at peer" },
{ L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL,"at local" },
{ 0, NULL }
};
#if 0
@ -227,57 +261,53 @@ print_octets(const u_char *dat, u_int length)
}
static void
print_short(const u_short *dat)
print_16bits_val(const u_int16_t *dat)
{
printf("%u", ntohs(*dat));
}
static void
print_int(const u_int *dat)
print_32bits_val(const u_int32_t *dat)
{
printf("%lu", (u_long)ntohl(*dat));
}
/**********************************/
/* AVP-specific print out routines*/
/**********************************/
/***********************************/
/* AVP-specific print out routines */
/***********************************/
static void
l2tp_msgtype_print(const u_char *dat, u_int length)
l2tp_msgtype_print(const u_char *dat)
{
u_short *ptr = (u_short *)dat;
u_int16_t *ptr = (u_int16_t*)dat;
if (ntohs(*ptr) < L2TP_MAX_MSGTYPE_INDEX) {
printf("%s", l2tp_message_type_string[ntohs(*ptr)]);
}
printf("%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u", ntohs(*ptr)));
}
static void
l2tp_result_code_print(const u_char *dat, u_int length)
{
/* we just print out the result and error code number */
u_short *ptr = (u_short *)dat;
u_int16_t *ptr = (u_int16_t *)dat;
if (length == 2) { /* result code */
printf("%u", ntohs(*ptr));
} else if (length == 4) { /* result & error code */
printf("%u/%u", ntohs(*ptr), ntohs(*(ptr+1)));
} else if (length > 4) { /* result & error code & msg */
printf("%u/%u ", ntohs(*ptr), ntohs(*(ptr+1)));
print_string((u_char *)(ptr+2), length - 4);
printf("%u", ntohs(*ptr++)); /* Result Code */
if (length > 2) { /* Error Code (opt) */
printf("/%u", ntohs(*ptr++));
}
if (length > 4) { /* Error Message (opt) */
printf(" ");
print_string((u_char *)ptr, length - 4);
}
}
static void
l2tp_proto_ver_print(const u_char *dat, u_int length)
l2tp_proto_ver_print(const u_int16_t *dat)
{
printf("%d.%d", *dat, *(dat+1));
printf("%u.%u", (ntohs(*dat) >> 8), (ntohs(*dat) & 0xff));
}
static void
l2tp_framing_cap_print(const u_char *dat, u_int length)
l2tp_framing_cap_print(const u_char *dat)
{
u_int *ptr = (u_int *)dat;
u_int32_t *ptr = (u_int32_t *)dat;
if (ntohl(*ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) {
printf("A");
@ -288,9 +318,9 @@ l2tp_framing_cap_print(const u_char *dat, u_int length)
}
static void
l2tp_bearer_cap_print(const u_char *dat, u_int length)
l2tp_bearer_cap_print(const u_char *dat)
{
u_int *ptr = (u_int *)dat;
u_int32_t *ptr = (u_int32_t *)dat;
if (ntohl(*ptr) & L2TP_BEARER_CAP_ANALOG_MASK) {
printf("A");
@ -300,52 +330,10 @@ l2tp_bearer_cap_print(const u_char *dat, u_int length)
}
}
static void
l2tp_tie_breaker_print(const u_char *dat, u_int length)
{
print_octets(dat, 8); /* Tie Break Value is 64bits long */
}
static void
l2tp_firm_ver_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
}
static void
l2tp_host_name_print(const u_char *dat, u_int length)
{
print_string(dat, length);
}
static void
l2tp_vendor_name_print(const u_char *dat, u_int length)
{
print_string(dat, length);
}
static void
l2tp_assnd_tun_id_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
}
static void
l2tp_recv_win_size_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
}
static void
l2tp_challenge_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_q931_cc_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
print_16bits_val((u_int16_t *)dat);
printf(", %02x", dat[2]);
if (length > 3) {
printf(" ");
@ -354,39 +342,9 @@ l2tp_q931_cc_print(const u_char *dat, u_int length)
}
static void
l2tp_challenge_resp_print(const u_char *dat, u_int length)
l2tp_bearer_type_print(const u_char *dat)
{
print_octets(dat, 16); /* XXX length should be 16? */
}
static void
l2tp_assnd_sess_id_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
}
static void
l2tp_call_ser_num_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_minimum_bps_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_maximum_bps_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_bearer_type_print(const u_char *dat, u_int length)
{
u_int *ptr = (u_int *)dat;
u_int32_t *ptr = (u_int32_t *)dat;
if (ntohl(*ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) {
printf("A");
@ -397,9 +355,9 @@ l2tp_bearer_type_print(const u_char *dat, u_int length)
}
static void
l2tp_framing_type_print(const u_char *dat, u_int length)
l2tp_framing_type_print(const u_char *dat)
{
u_int *ptr = (u_int *)dat;
u_int32_t *ptr = (u_int32_t *)dat;
if (ntohl(*ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
printf("A");
@ -410,241 +368,251 @@ l2tp_framing_type_print(const u_char *dat, u_int length)
}
static void
l2tp_packet_proc_delay_print(const u_char *dat, u_int length)
l2tp_packet_proc_delay_print(void)
{
printf("obsolete");
}
static void
l2tp_called_number_print(const u_char *dat, u_int length)
l2tp_proxy_auth_type_print(const u_char *dat)
{
print_string(dat, length);
u_int16_t *ptr = (u_int16_t *)dat;
printf("%s", tok2str(l2tp_authentype2str,
"AuthType-#%u", ntohs(*ptr)));
}
static void
l2tp_calling_number_print(const u_char *dat, u_int length)
l2tp_proxy_auth_id_print(const u_char *dat)
{
print_string(dat, length);
}
static void
l2tp_sub_address_print(const u_char *dat, u_int length)
{
print_string(dat, length);
}
static void
l2tp_tx_conn_speed_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_phy_channel_id_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_ini_recv_lcp_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_last_sent_lcp_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_last_recv_lcp_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_proxy_auth_type_print(const u_char *dat, u_int length)
{
u_short *ptr = (u_short *)dat;
switch (ntohs(*ptr)) {
case L2TP_AUTHEN_TYPE_RESERVED:
printf("Reserved");
break;
case L2TP_AUTHEN_TYPE_TEXTUAL:
printf("Textual");
break;
case L2TP_AUTHEN_TYPE_CHAP:
printf("CHAP");
break;
case L2TP_AUTHEN_TYPE_PAP:
printf("PAP");
break;
case L2TP_AUTHEN_TYPE_NO_AUTH:
printf("No Auth");
break;
case L2TP_AUTHEN_TYPE_MSCHAP:
printf("MS-CHAP");
break;
default:
printf("unknown");
}
}
static void
l2tp_proxy_auth_name_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_proxy_auth_chal_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_proxy_auth_id_print(const u_char *dat, u_int length)
{
u_short *ptr = (u_short *)dat;
u_int16_t *ptr = (u_int16_t *)dat;
printf("%u", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);
}
static void
l2tp_proxy_auth_resp_print(const u_char *dat, u_int length)
l2tp_call_errors_print(const u_char *dat)
{
print_octets(dat, length);
u_int16_t *ptr = (u_int16_t *)dat;
u_int16_t val_h, val_l;
ptr++; /* skip "Reserved" */
val_h = ntohs(*ptr++);
val_l = ntohs(*ptr++);
printf("CRCErr=%u ", (val_h<<16) + val_l);
val_h = ntohs(*ptr++);
val_l = ntohs(*ptr++);
printf("FrameErr=%u ", (val_h<<16) + val_l);
val_h = ntohs(*ptr++);
val_l = ntohs(*ptr++);
printf("HardOver=%u ", (val_h<<16) + val_l);
val_h = ntohs(*ptr++);
val_l = ntohs(*ptr++);
printf("BufOver=%u ", (val_h<<16) + val_l);
val_h = ntohs(*ptr++);
val_l = ntohs(*ptr++);
printf("Timeout=%u ", (val_h<<16) + val_l);
val_h = ntohs(*ptr++);
val_l = ntohs(*ptr++);
printf("AlignErr=%u ", (val_h<<16) + val_l);
}
static void
l2tp_call_errors_print(const u_char *dat, u_int length)
l2tp_accm_print(const u_char *dat)
{
struct l2tp_call_errors *ptr = (struct l2tp_call_errors *)dat;
u_int16_t *ptr = (u_int16_t *)dat;
u_int16_t val_h, val_l;
printf("CRCErr=%d FrameErr=%d HardOver=%d BufOver=%d ",
ptr->crc_errs,
ptr->framing_errs,
ptr->hardware_overruns,
ptr->buffer_overruns);
printf("Timeout=%d AlingErr=%d",
ptr->timeout_errs,
ptr->alignment_errs);
ptr++; /* skip "Reserved" */
val_h = ntohs(*ptr++);
val_l = ntohs(*ptr++);
printf("send=%08x ", (val_h<<16) + val_l);
val_h = ntohs(*ptr++);
val_l = ntohs(*ptr++);
printf("recv=%08x ", (val_h<<16) + val_l);
}
static void
l2tp_accm_print(const u_char *dat, u_int length)
l2tp_ppp_discon_cc_print(const u_char *dat, u_int length)
{
struct l2tp_accm *ptr = (struct l2tp_accm *)dat;
u_int16_t *ptr = (u_int16_t *)dat;
printf("%04x, ", ntohs(*ptr++)); /* Disconnect Code */
printf("%04x ", ntohs(*ptr++)); /* Control Protocol Number */
printf("%s", tok2str(l2tp_cc_direction2str,
"Direction-#%u", *((u_char *)ptr++)));
printf("send=%x recv=%x", ptr->send_accm, ptr->recv_accm);
if (length > 5) {
printf(" ");
print_string((const u_char *)ptr, length-5);
}
}
static void
l2tp_random_vector_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_private_grp_id_print(const u_char *dat, u_int length)
{
print_string(dat, length);
/* XXX print_octets is more appropriate?? */
}
static void
l2tp_rx_conn_speed_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_seq_required_print(const u_char *dat, u_int length)
{
return;
}
static void
l2tp_avp_print(const u_char *dat, u_int length)
l2tp_avp_print(const u_char *dat, int length)
{
u_int len;
const u_short *ptr = (u_short *)dat;
const u_int16_t *ptr = (u_int16_t *)dat;
u_int16_t attr_type;
int hidden = FALSE;
printf(" ");
if (length > 0 && (snapend - dat) >= 2) {
/* there must be at least two octets for the length
to be decoded */
if ((len = (ntohs(*ptr) & L2TP_AVP_HDR_LEN_MASK)) <=
(snapend - dat)) {
if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
printf("*");
}
if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
hidden = TRUE;
printf("?");
}
} else {
printf("|...");
return;
}
ptr++;
if (ntohs(*ptr)) {
/* Vendor Specific Attribute */
printf("VENDOR%04x:", ntohs(*ptr));
ptr++;
printf("ATTR%04x", ntohs(*ptr));
printf("(");
print_octets((u_char *)ptr+2, len-6);
printf(")");
} else {
/* 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);
} else if (length == 0) {
if (length <= 0) {
return;
} else {
printf("|...");
}
printf(" ");
TCHECK(*ptr); /* Flags & Length */
len = ntohs(*ptr) & L2TP_AVP_HDR_LEN_MASK;
/* If it is not long enough to decode the entire AVP, we'll
abandon. */
TCHECK2(*ptr, len);
/* After this point, no need to worry about truncation */
if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
printf("*");
}
if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
hidden = TRUE;
printf("?");
}
ptr++;
if (ntohs(*ptr)) {
/* Vendor Specific Attribute */
printf("VENDOR%04x:", ntohs(*ptr++));
printf("ATTR%04x", ntohs(*ptr++));
printf("(");
print_octets((u_char *)ptr, len-6);
printf(")");
} else {
/* IETF-defined Attributes */
ptr++;
attr_type = ntohs(*ptr++);
printf("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type));
printf("(");
if (hidden) {
printf("???");
} else {
switch (attr_type) {
case L2TP_AVP_MSGTYPE:
l2tp_msgtype_print((u_char *)ptr);
break;
case L2TP_AVP_RESULT_CODE:
l2tp_result_code_print((u_char *)ptr, len-6);
break;
case L2TP_AVP_PROTO_VER:
l2tp_proto_ver_print(ptr);
break;
case L2TP_AVP_FRAMING_CAP:
l2tp_framing_cap_print((u_char *)ptr);
break;
case L2TP_AVP_BEARER_CAP:
l2tp_bearer_cap_print((u_char *)ptr);
break;
case L2TP_AVP_TIE_BREAKER:
print_octets((u_char *)ptr, 8);
break;
case L2TP_AVP_FIRM_VER:
case L2TP_AVP_ASSND_TUN_ID:
case L2TP_AVP_RECV_WIN_SIZE:
case L2TP_AVP_ASSND_SESS_ID:
print_16bits_val(ptr);
break;
case L2TP_AVP_HOST_NAME:
case L2TP_AVP_VENDOR_NAME:
case L2TP_AVP_CALLING_NUMBER:
case L2TP_AVP_CALLED_NUMBER:
case L2TP_AVP_SUB_ADDRESS:
case L2TP_AVP_PROXY_AUTH_NAME:
case L2TP_AVP_PRIVATE_GRP_ID:
print_string((u_char *)ptr, len-6);
break;
case L2TP_AVP_CHALLENGE:
case L2TP_AVP_INI_RECV_LCP:
case L2TP_AVP_LAST_SENT_LCP:
case L2TP_AVP_LAST_RECV_LCP:
case L2TP_AVP_PROXY_AUTH_CHAL:
case L2TP_AVP_PROXY_AUTH_RESP:
case L2TP_AVP_RANDOM_VECTOR:
print_octets((u_char *)ptr, len-6);
break;
case L2TP_AVP_Q931_CC:
l2tp_q931_cc_print((u_char *)ptr, len-6);
break;
case L2TP_AVP_CHALLENGE_RESP:
print_octets((u_char *)ptr, 16);
break;
case L2TP_AVP_CALL_SER_NUM:
case L2TP_AVP_MINIMUM_BPS:
case L2TP_AVP_MAXIMUM_BPS:
case L2TP_AVP_TX_CONN_SPEED:
case L2TP_AVP_PHY_CHANNEL_ID:
case L2TP_AVP_RX_CONN_SPEED:
print_32bits_val((u_int32_t *)ptr);
break;
case L2TP_AVP_BEARER_TYPE:
l2tp_bearer_type_print((u_char *)ptr);
break;
case L2TP_AVP_FRAMING_TYPE:
l2tp_framing_type_print((u_char *)ptr);
break;
case L2TP_AVP_PACKET_PROC_DELAY:
l2tp_packet_proc_delay_print();
break;
case L2TP_AVP_PROXY_AUTH_TYPE:
l2tp_proxy_auth_type_print((u_char *)ptr);
break;
case L2TP_AVP_PROXY_AUTH_ID:
l2tp_proxy_auth_id_print((u_char *)ptr);
break;
case L2TP_AVP_CALL_ERRORS:
l2tp_call_errors_print((u_char *)ptr);
break;
case L2TP_AVP_ACCM:
l2tp_accm_print((u_char *)ptr);
break;
case L2TP_AVP_SEQ_REQUIRED:
break; /* No Attribute Value */
case L2TP_AVP_PPP_DISCON_CC:
l2tp_ppp_discon_cc_print((u_char *)ptr, len-6);
break;
default:
break;
}
}
printf(")");
}
l2tp_avp_print(dat+len, length-len);
return;
trunc:
printf("|...");
}
void
l2tp_print(const u_char *dat, u_int length)
{
const u_short *ptr = (u_short *)dat;
const u_int16_t *ptr = (u_int16_t *)dat;
u_int cnt = 0; /* total octets consumed */
u_short pad;
u_int16_t pad;
int flag_t, flag_l, flag_s, flag_o, flag_p;
u_short l2tp_len;
u_int16_t l2tp_len;
flag_t = flag_l = flag_s = flag_o = flag_p = FALSE;
if (min(length, snapend - dat) - 6 < 0) {
/* flag/ver, tunnel_id, session_id must be present for
this packet to be properly decoded */
printf("%s", tstr);
return;
}
TCHECK(*ptr); /* Flags & Version */
if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
printf(" l2tp:");
} else if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
@ -682,24 +650,31 @@ l2tp_print(const u_char *dat, u_int length)
cnt += 2;
if (flag_l) {
l2tp_len = ntohs(*ptr++); /* XXX need to consider
truncation ?? */
TCHECK(*ptr); /* Length */
l2tp_len = ntohs(*ptr++);
cnt += 2;
} else {
l2tp_len = 0;
}
printf("(%u/", ntohs(*ptr++)); /* Tunnel ID */
printf("%u)", ntohs(*ptr++)); /* Session ID */
cnt += 4;
TCHECK(*ptr); /* Tunnel ID */
printf("(%u/", ntohs(*ptr++));
cnt += 2;
TCHECK(*ptr); /* Session ID */
printf("%u)", ntohs(*ptr++));
cnt += 2;
if (flag_s) {
TCHECK(*ptr); /* Ns */
printf("Ns=%u,", ntohs(*ptr++));
cnt += 2;
TCHECK(*ptr); /* Nr */
printf("Nr=%u", ntohs(*ptr++));
cnt += 4;
cnt += 2;
}
if (flag_o) {
TCHECK(*ptr); /* Offset Size */
pad = ntohs(*ptr++);
ptr += pad / sizeof(*ptr);
cnt += (2 + pad);
@ -716,4 +691,9 @@ l2tp_print(const u_char *dat, u_int length)
ppp_print((u_char *)ptr, length - cnt);
printf("}");
}
return;
trunc:
printf("%s", tstr);
}

View File

@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.11 2000/12/22 22:45:11 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.12 2001/07/05 18:54:15 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -81,6 +81,7 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_short ether_type;
u_short extracted_ethertype;
++infodelay;
ts_print(&h->ts);
if (caplen < sizeof(struct lecdatahdr_8023)) {
@ -136,4 +137,7 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}

View File

@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.32 2000/12/18 07:55:36 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.43 2001/10/08 21:25:22 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -46,6 +46,7 @@ static const char rcsid[] =
#include "extract.h" /* must come after interface.h */
#include "llc.h"
#include "ethertype.h"
static struct tok cmd2str[] = {
{ LLC_UI, "ui" },
@ -81,23 +82,47 @@ llc_print(const u_char *p, u_int length, u_int caplen,
memcpy((char *)&llc, (char *)p, min(caplen, sizeof(llc)));
if (llc.ssap == LLCSAP_GLOBAL && llc.dsap == LLCSAP_GLOBAL) {
/*
* This is an Ethernet_802.3 IPX frame; it has an
* 802.3 header (i.e., an Ethernet header where the
* type/length field is <= ETHERMTU, i.e. it's a length
* field, not a type field), but has no 802.2 header -
* the IPX packet starts right after the Ethernet header,
* with a signature of two bytes of 0xFF (which is
* LLCSAP_GLOBAL).
*
* (It might also have been an Ethernet_802.3 IPX at
* one time, but got bridged onto another network,
* such as an 802.11 network; this has appeared in at
* least one capture file.)
*/
ipx_print(p, length);
return (1);
}
/* Cisco Discovery Protocol - SNAP & ether type 0x2000 */
if(llc.ssap == LLCSAP_SNAP && llc.dsap == LLCSAP_SNAP &&
llc.llcui == LLC_UI &&
llc.ethertype[0] == 0x20 && llc.ethertype[1] == 0x00 ) {
cdp_print( p, length, caplen, esrc, edst);
return (1);
}
if (llc.ssap == LLCSAP_8021D && llc.dsap == LLCSAP_8021D) {
stp_print(p, length);
return (1);
}
if (llc.ssap == 0xf0 && llc.dsap == 0xf0
if (llc.ssap == LLCSAP_IPX && llc.dsap == LLCSAP_IPX &&
llc.llcui == LLC_UI) {
/*
* This is an Ethernet_802.2 IPX frame, with an 802.3
* header and an 802.2 LLC header with the source and
* destination SAPs being the IPX SAP.
*
* Skip DSAP, LSAP, and control field.
*/
p += 3;
length -= 3;
caplen -= 3;
ipx_print(p, length);
return (1);
}
#ifdef TCPDUMP_DO_SMB
if (llc.ssap == LLCSAP_NETBEUI && llc.dsap == LLCSAP_NETBEUI
&& (!(llc.llcu & LLC_S_FMT) || llc.llcu == LLC_U_FMT)) {
/*
* we don't actually have a full netbeui parser yet, but the
@ -138,9 +163,10 @@ llc_print(const u_char *p, u_int length, u_int caplen,
length -= 2;
caplen -= 2;
}
netbeui_print(control, p, p + min(caplen, length));
netbeui_print(control, p, length);
return (1);
}
#endif
if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS
&& llc.llcui == LLC_UI) {
isoclns_print(p + 3, length - 3, caplen - 3, esrc, edst);
@ -149,6 +175,8 @@ llc_print(const u_char *p, u_int length, u_int caplen,
if (llc.ssap == LLCSAP_SNAP && llc.dsap == LLCSAP_SNAP
&& llc.llcui == LLC_UI) {
u_int32_t orgcode;
if (caplen < sizeof(llc)) {
(void)printf("[|llc-snap]");
default_print((u_char *)p, caplen);
@ -161,16 +189,51 @@ llc_print(const u_char *p, u_int length, u_int caplen,
length -= sizeof(llc);
p += sizeof(llc);
/* This is an encapsulated Ethernet packet */
et = EXTRACT_16BITS(&llc.ethertype[0]);
ret = ether_encap_print(et, p, length, caplen,
extracted_ethertype);
if (ret)
return (ret);
orgcode = EXTRACT_24BITS(&llc.llc_orgcode[0]);
et = EXTRACT_16BITS(&llc.llc_ethertype[0]);
switch (orgcode) {
case OUI_ENCAP_ETHER:
case OUI_CISCO_90:
/*
* This is an encapsulated Ethernet packet,
* or a packet bridged by some piece of
* Cisco hardware; the protocol ID is
* an Ethernet protocol type.
*/
ret = ether_encap_print(et, p, length, caplen,
extracted_ethertype);
if (ret)
return (ret);
break;
case OUI_APPLETALK:
if (et == ETHERTYPE_ATALK) {
/*
* No, I have no idea why Apple used one
* of their own OUIs, rather than
* 0x000000, and an Ethernet packet
* type, for Appletalk data packets,
* but used 0x000000 and an Ethernet
* packet type for AARP packets.
*/
ret = ether_encap_print(et, p, length, caplen,
extracted_ethertype);
if (ret)
return (ret);
}
break;
case OUI_CISCO:
if (et == ETHERTYPE_CISCO_CDP) {
cdp_print(p, length, caplen, esrc, edst);
return 1;
}
break;
}
}
if ((llc.ssap & ~LLC_GSAP) == llc.dsap) {
if (eflag)
if (eflag || esrc == NULL || edst == NULL)
(void)printf("%s ", llcsap_string(llc.dsap));
else
(void)printf("%s > %s %s ",
@ -178,7 +241,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
etheraddr_string(edst),
llcsap_string(llc.dsap));
} else {
if (eflag)
if (eflag || esrc == NULL || edst == NULL)
(void)printf("%s > %s ",
llcsap_string(llc.ssap & ~LLC_GSAP),
llcsap_string(llc.dsap));
@ -219,14 +282,6 @@ llc_print(const u_char *p, u_int length, u_int caplen,
caplen -= 3;
}
}
if (cmd == LLC_UI && f == 'C') {
/*
* we don't have a proper ipx decoder yet, but there
* is a partial one in the smb code
*/
ipx_netbios_print(p,p+min(caplen,length));
}
} else {
char f;

View File

@ -0,0 +1,599 @@
/*
* Copyright (C) 2001 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.5 2001/06/26 06:19:05 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <netinet/in.h>
#include "nameser.h"
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
/* BIND9 lib/lwres/include/lwres */
typedef u_int32_t lwres_uint32_t;
typedef u_int16_t lwres_uint16_t;
typedef u_int8_t lwres_uint8_t;
struct lwres_lwpacket {
lwres_uint32_t length;
lwres_uint16_t version;
lwres_uint16_t pktflags;
lwres_uint32_t serial;
lwres_uint32_t opcode;
lwres_uint32_t result;
lwres_uint32_t recvlength;
lwres_uint16_t authtype;
lwres_uint16_t authlength;
};
#define LWRES_LWPACKETFLAG_RESPONSE 0x0001U /* if set, pkt is a response */
#define LWRES_LWPACKETVERSION_0 0
#define LWRES_FLAG_TRUSTNOTREQUIRED 0x00000001U
#define LWRES_FLAG_SECUREDATA 0x00000002U
/*
* no-op
*/
#define LWRES_OPCODE_NOOP 0x00000000U
typedef struct {
/* public */
lwres_uint16_t datalength;
/* data follows */
} lwres_nooprequest_t;
typedef struct {
/* public */
lwres_uint16_t datalength;
/* data follows */
} lwres_noopresponse_t;
/*
* get addresses by name
*/
#define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
typedef struct lwres_addr lwres_addr_t;
struct lwres_addr {
lwres_uint32_t family;
lwres_uint16_t length;
/* address folows */
};
typedef struct {
/* public */
lwres_uint32_t flags;
lwres_uint32_t addrtypes;
lwres_uint16_t namelen;
/* name follows */
} lwres_gabnrequest_t;
typedef struct {
/* public */
lwres_uint32_t flags;
lwres_uint16_t naliases;
lwres_uint16_t naddrs;
lwres_uint16_t realnamelen;
/* aliases follows */
/* addrs follows */
/* realname follows */
} lwres_gabnresponse_t;
/*
* get name by address
*/
#define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U
typedef struct {
/* public */
lwres_uint32_t flags;
lwres_addr_t addr;
/* addr body follows */
} lwres_gnbarequest_t;
typedef struct {
/* public */
lwres_uint32_t flags;
lwres_uint16_t naliases;
lwres_uint16_t realnamelen;
/* aliases follows */
/* realname follows */
} lwres_gnbaresponse_t;
/*
* get rdata by name
*/
#define LWRES_OPCODE_GETRDATABYNAME 0x00010003U
typedef struct {
/* public */
lwres_uint32_t flags;
lwres_uint16_t rdclass;
lwres_uint16_t rdtype;
lwres_uint16_t namelen;
/* name follows */
} lwres_grbnrequest_t;
typedef struct {
/* public */
lwres_uint32_t flags;
lwres_uint16_t rdclass;
lwres_uint16_t rdtype;
lwres_uint32_t ttl;
lwres_uint16_t nrdatas;
lwres_uint16_t nsigs;
/* realname here (len + name) */
/* rdata here (len + name) */
/* signatures here (len + name) */
} lwres_grbnresponse_t;
#define LWRDATA_VALIDATED 0x00000001
#define LWRES_ADDRTYPE_V4 0x00000001U /* ipv4 */
#define LWRES_ADDRTYPE_V6 0x00000002U /* ipv6 */
#define LWRES_MAX_ALIASES 16 /* max # of aliases */
#define LWRES_MAX_ADDRS 64 /* max # of addrs */
struct tok opcode[] = {
{ LWRES_OPCODE_NOOP, "noop", },
{ LWRES_OPCODE_GETADDRSBYNAME, "getaddrsbyname", },
{ LWRES_OPCODE_GETNAMEBYADDR, "getnamebyaddr", },
{ LWRES_OPCODE_GETRDATABYNAME, "getrdatabyname", },
{ 0, NULL, },
};
/* print-domain.c */
extern struct tok ns_type2str[];
extern struct tok ns_class2str[];
static int lwres_printname(size_t, const char *);
static int lwres_printnamelen(const char *);
static int lwres_printbinlen(const char *);
static int lwres_printaddr(lwres_addr_t *);
static int
lwres_printname(size_t l, const char *p0)
{
const char *p;
int i;
p = p0;
/* + 1 for terminating \0 */
if (p + l + 1 > (const char *)snapend)
goto trunc;
printf(" ");
for (i = 0; i < l; i++)
safeputchar(*p++);
p++; /* skip terminating \0 */
return p - p0;
trunc:
return -1;
}
static int
lwres_printnamelen(const char *p)
{
u_int16_t l;
int advance;
if (p + 2 > (const char *)snapend)
goto trunc;
l = EXTRACT_16BITS(p);
advance = lwres_printname(l, p + 2);
if (advance < 0)
goto trunc;
return 2 + advance;
trunc:
return -1;
}
static int
lwres_printbinlen(const char *p0)
{
const char *p;
u_int16_t l;
int i;
p = p0;
if (p + 2 > (const char *)snapend)
goto trunc;
l = EXTRACT_16BITS(p);
if (p + 2 + l > (const char *)snapend)
goto trunc;
p += 2;
for (i = 0; i < l; i++)
printf("%02x", *p++);
return p - p0;
trunc:
return -1;
}
static int
lwres_printaddr(lwres_addr_t *ap)
{
u_int16_t l;
const char *p;
int i;
TCHECK(ap->length);
l = ntohs(ap->length);
/* XXX ap points to packed struct */
p = (const char *)&ap->length + sizeof(ap->length);
if (p + l > (const char *)snapend)
goto trunc;
switch (ntohl(ap->family)) {
case 1: /* IPv4 */
printf(" %s", ipaddr_string(p));
p += sizeof(struct in_addr);
break;
#ifdef INET6
case 2: /* IPv6 */
printf(" %s", ip6addr_string(p));
p += sizeof(struct in6_addr);
break;
#endif
default:
printf(" %lu/", (unsigned long)ntohl(ap->family));
for (i = 0; i < l; i++)
printf("%02x", *p++);
}
return p - (const char *)ap;
trunc:
return -1;
}
void
lwres_print(register const u_char *bp, u_int length)
{
const struct lwres_lwpacket *np;
u_int32_t v;
const char *s;
int response;
int advance;
int unsupported = 0;
np = (const struct lwres_lwpacket *)bp;
TCHECK(np->authlength);
printf(" lwres");
v = ntohs(np->version);
if (vflag || v != LWRES_LWPACKETVERSION_0)
printf(" v%u", v);
if (v != LWRES_LWPACKETVERSION_0) {
s = (const char *)np + ntohl(np->length);
goto tail;
}
response = ntohs(np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE;
/* opcode and pktflags */
v = (u_int32_t)ntohl(np->opcode);
s = tok2str(opcode, "#0x%x", v);
printf(" %s%s", s, response ? "" : "?");
/* pktflags */
v = ntohs(np->pktflags);
if (v & ~LWRES_LWPACKETFLAG_RESPONSE)
printf("[0x%x]", v);
if (vflag > 1) {
printf(" ("); /*)*/
printf("serial:0x%lx", (unsigned long)ntohl(np->serial));
printf(" result:0x%lx", (unsigned long)ntohl(np->result));
printf(" recvlen:%lu", (unsigned long)ntohl(np->recvlength));
/* BIND910: not used */
if (vflag > 2) {
printf(" authtype:0x%x", ntohs(np->authtype));
printf(" authlen:%u", ntohs(np->authlength));
}
/*(*/
printf(")");
}
/* per-opcode content */
if (!response) {
/*
* queries
*/
lwres_gabnrequest_t *gabn;
lwres_gnbarequest_t *gnba;
lwres_grbnrequest_t *grbn;
u_int32_t l;
gabn = NULL;
gnba = NULL;
grbn = NULL;
switch (ntohl(np->opcode)) {
case LWRES_OPCODE_NOOP:
break;
case LWRES_OPCODE_GETADDRSBYNAME:
gabn = (lwres_gabnrequest_t *)(np + 1);
TCHECK(gabn->namelen);
/* XXX gabn points to packed struct */
s = (const char *)&gabn->namelen +
sizeof(gabn->namelen);
l = ntohs(gabn->namelen);
/* BIND910: not used */
if (vflag > 2) {
printf(" flags:0x%lx",
(unsigned long)ntohl(gabn->flags));
}
v = (u_int32_t)ntohl(gabn->addrtypes);
switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) {
case LWRES_ADDRTYPE_V4:
printf(" IPv4");
break;
case LWRES_ADDRTYPE_V6:
printf(" IPv6");
break;
case LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6:
printf(" IPv4/6");
break;
}
if (v & ~(LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6))
printf("[0x%x]", v);
advance = lwres_printname(l, s);
if (advance < 0)
goto trunc;
s += advance;
break;
case LWRES_OPCODE_GETNAMEBYADDR:
gnba = (lwres_gnbarequest_t *)(np + 1);
TCHECK(gnba->addr);
/* BIND910: not used */
if (vflag > 2) {
printf(" flags:0x%lx",
(unsigned long)ntohl(gnba->flags));
}
s = (const char *)&gnba->addr;
advance = lwres_printaddr(&gnba->addr);
if (advance < 0)
goto trunc;
s += advance;
break;
case LWRES_OPCODE_GETRDATABYNAME:
/* XXX no trace, not tested */
grbn = (lwres_grbnrequest_t *)(np + 1);
TCHECK(grbn->namelen);
/* BIND910: not used */
if (vflag > 2) {
printf(" flags:0x%lx",
(unsigned long)ntohl(grbn->flags));
}
printf(" %s", tok2str(ns_type2str, "Type%d",
ntohs(grbn->rdtype)));
if (ntohs(grbn->rdclass) != C_IN);
printf(" %s", tok2str(ns_class2str, "Class%d",
ntohs(grbn->rdclass)));
/* XXX grbn points to packed struct */
s = (const char *)&grbn->namelen +
sizeof(grbn->namelen);
l = ntohs(gabn->namelen);
advance = lwres_printname(l, s);
if (advance < 0)
goto trunc;
s += advance;
break;
default:
unsupported++;
break;
}
} else {
/*
* responses
*/
lwres_gabnresponse_t *gabn;
lwres_gnbaresponse_t *gnba;
lwres_grbnresponse_t *grbn;
u_int32_t l, na;
int i;
gabn = NULL;
gnba = NULL;
grbn = NULL;
switch (ntohl(np->opcode)) {
case LWRES_OPCODE_NOOP:
break;
case LWRES_OPCODE_GETADDRSBYNAME:
gabn = (lwres_gabnresponse_t *)(np + 1);
TCHECK(gabn->realnamelen);
/* XXX gabn points to packed struct */
s = (const char *)&gabn->realnamelen +
sizeof(gabn->realnamelen);
l = ntohs(gabn->realnamelen);
/* BIND910: not used */
if (vflag > 2) {
printf(" flags:0x%lx",
(unsigned long)ntohl(gabn->flags));
}
printf(" %u/%u", ntohs(gabn->naliases),
ntohs(gabn->naddrs));
advance = lwres_printname(l, s);
if (advance < 0)
goto trunc;
s += advance;
/* aliases */
na = ntohs(gabn->naliases);
for (i = 0; i < na; i++) {
advance = lwres_printnamelen(s);
if (advance < 0)
goto trunc;
s += advance;
}
/* addrs */
na = ntohs(gabn->naddrs);
for (i = 0; i < na; i++) {
advance = lwres_printaddr((lwres_addr_t *)s);
if (advance < 0)
goto trunc;
s += advance;
}
break;
case LWRES_OPCODE_GETNAMEBYADDR:
gnba = (lwres_gnbaresponse_t *)(np + 1);
TCHECK(gnba->realnamelen);
/* XXX gnba points to packed struct */
s = (const char *)&gnba->realnamelen +
sizeof(gnba->realnamelen);
l = ntohs(gnba->realnamelen);
/* BIND910: not used */
if (vflag > 2) {
printf(" flags:0x%lx",
(unsigned long)ntohl(gnba->flags));
}
printf(" %u", ntohs(gnba->naliases));
advance = lwres_printname(l, s);
if (advance < 0)
goto trunc;
s += advance;
/* aliases */
na = ntohs(gnba->naliases);
for (i = 0; i < na; i++) {
advance = lwres_printnamelen(s);
if (advance < 0)
goto trunc;
s += advance;
}
break;
case LWRES_OPCODE_GETRDATABYNAME:
/* XXX no trace, not tested */
grbn = (lwres_grbnresponse_t *)(np + 1);
TCHECK(grbn->nsigs);
/* BIND910: not used */
if (vflag > 2) {
printf(" flags:0x%lx",
(unsigned long)ntohl(grbn->flags));
}
printf(" %s", tok2str(ns_type2str, "Type%d",
ntohs(grbn->rdtype)));
if (ntohs(grbn->rdclass) != C_IN);
printf(" %s", tok2str(ns_class2str, "Class%d",
ntohs(grbn->rdclass)));
printf(" TTL ");
relts_print(ntohl(grbn->ttl));
printf(" %u/%u", ntohs(grbn->nrdatas),
ntohs(grbn->nsigs));
/* XXX grbn points to packed struct */
s = (const char *)&grbn->nsigs+ sizeof(grbn->nsigs);
advance = lwres_printnamelen(s);
if (advance < 0)
goto trunc;
s += advance;
/* rdatas */
na = ntohs(grbn->nrdatas);
for (i = 0; i < na; i++) {
/* XXX should decode resource data */
advance = lwres_printbinlen(s);
if (advance < 0)
goto trunc;
s += advance;
}
/* sigs */
na = ntohs(grbn->nsigs);
for (i = 0; i < na; i++) {
/* XXX how should we print it? */
advance = lwres_printbinlen(s);
if (advance < 0)
goto trunc;
s += advance;
}
break;
default:
unsupported++;
break;
}
}
tail:
/* length mismatch */
if (ntohl(np->length) != length) {
printf(" [len: %lu != %u]", (unsigned long)ntohl(np->length),
length);
}
if (!unsupported && s < (const char *)np + ntohl(np->length))
printf("[extra]");
return;
trunc:
printf("[|lwres]");
return;
}

View File

@ -42,7 +42,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.5 2000/09/29 04:58:43 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.7 2001/08/20 17:53:54 fenner Exp $";
#endif
#include <sys/param.h>
@ -70,8 +70,6 @@ struct mobile_ip {
#define OSRC_PRES 0x0080 /* old source is present */
static u_int16_t mob_in_cksum(u_short *p, int len);
/*
* Deencapsulate and print a mobile-tunneled IP datagram
*/
@ -89,6 +87,7 @@ mobile_print(const u_char *bp, u_int length)
fputs("[|mobile]", stdout);
return;
}
fputs("mobile: ", stdout);
proto = EXTRACT_16BITS(&mob->proto);
crc = EXTRACT_16BITS(&mob->hcheck);
@ -108,34 +107,9 @@ mobile_print(const u_char *bp, u_int length)
(void)printf("> %s ",ipaddr_string(&mob->odst));
(void)printf("(oproto=%d)",proto>>8);
}
if (mob_in_cksum((u_short *)mob, osp ? 12 : 8)!=0) {
if (in_cksum((u_short *)mob, osp ? 12 : 8, 0)!=0) {
(void)printf(" (bad checksum %d)",crc);
}
return;
}
static u_int16_t mob_in_cksum(u_short *p, int len)
{
u_int32_t sum = 0;
int nwords = len >> 1;
while (nwords-- != 0)
sum += *p++;
if (len & 1) {
union {
u_int16_t w;
u_int8_t c[2];
} u;
u.c[0] = *(u_char *)p;
u.c[1] = 0;
sum += u.w;
}
/* end-around-carry */
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
return (~sum);
}

View File

@ -0,0 +1,123 @@
/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.2 2001/06/26 06:24:57 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "addrtoname.h"
#include "interface.h"
#include "extract.h" /* must come after interface.h */
#define LABEL_MASK 0xfffff000
#define LABEL_SHIFT 12
#define EXP_MASK 0x00000e00
#define EXP_SHIFT 9
#define STACK_MASK 0x00000100
#define STACK_SHIFT 8
#define TTL_MASK 0x000000ff
#define TTL_SHIFT 0
#define MPLS_LABEL(x) (((x) & LABEL_MASK) >> LABEL_SHIFT)
#define MPLS_EXP(x) (((x) & EXP_MASK) >> EXP_SHIFT)
#define MPLS_STACK(x) (((x) & STACK_MASK) >> STACK_SHIFT)
#define MPLS_TTL(x) (((x) & TTL_MASK) >> TTL_SHIFT)
static const char *mpls_labelname[] = {
/*0*/ "IPv4 explicit NULL", "router alert", "IPv6 explicit NULL",
"implicit NULL", "rsvd",
/*5*/ "rsvd", "rsvd", "rsvd", "rsvd", "rsvd",
/*10*/ "rsvd", "rsvd", "rsvd", "rsvd", "rsvd",
/*15*/ "rsvd",
};
/*
* RFC3032: MPLS label stack encoding
*/
void
mpls_print(const u_char *bp, u_int length)
{
const u_char *p;
u_int32_t v;
p = bp;
printf("MPLS");
TCHECK2(*p, sizeof(v));
memcpy(&v, p, sizeof(v));
v = (u_int32_t)ntohl(v);
printf(" ("); /*)*/
printf("label 0x%x", MPLS_LABEL(v));
if (vflag &&
MPLS_LABEL(v) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))
printf("(%s)", mpls_labelname[MPLS_LABEL(v)]);
if (MPLS_EXP(v))
printf(" exp 0x%x", MPLS_EXP(v));
if (MPLS_STACK(v))
printf("[S]");
printf(" TTL %u", MPLS_TTL(v));
/*(*/
printf(")");
p += sizeof(v);
switch (MPLS_LABEL(v)) {
case 0: /* IPv4 explicit NULL label */
ip_print(p, length - (p - bp));
break;
#ifdef INET6
case 2: /* IPv6 explicit NULL label */
ip6_print(p, length - (p - bp));
break;
#endif
default:
/*
* Since there's no indication of protocol in MPLS label
* encoding, we can print nothing further.
*/
return;
}
trunc:
printf("[|MPLS]");
}

View File

@ -0,0 +1,102 @@
/*
* Copyright (c) 2001 William C. Fenner.
* 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, and (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.
* The name of William C. Fenner 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.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.2 2001/12/10 08:06:40 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
#define MSDP_TYPE_MAX 7
void
msdp_print(const unsigned char *sp, u_int length)
{
unsigned int type, len;
TCHECK2(*sp, 3);
/* See if we think we're at the beginning of a compound packet */
type = *sp;
len = EXTRACT_16BITS(sp + 1);
if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX)
goto trunc; /* not really truncated, but still not decodable */
(void)printf(" msdp:");
while (length > 0) {
TCHECK2(*sp, 3);
type = *sp;
len = EXTRACT_16BITS(sp + 1);
if (len > 1400 || vflag)
printf(" [len %d]", len);
if (len < 3)
goto trunc;
sp += 3;
length -= 3;
switch (type) {
case 1: /* IPv4 Source-Active */
case 3: /* IPv4 Source-Active Response */
if (type == 1)
(void)printf(" SA");
else
(void)printf(" SA-Response");
TCHECK(*sp);
(void)printf(" %d entries", *sp);
if (*sp * 12 + 8 < len) {
(void)printf(" [w/data]");
if (vflag > 1) {
(void)printf(" ");
ip_print(sp + *sp * 12 + 8 - 3,
len - (*sp * 12 + 8));
}
}
break;
case 2:
(void)printf(" SA-Request");
TCHECK2(*sp, 5);
(void)printf(" for %s", ipaddr_string(sp + 1));
break;
case 4:
(void)printf(" Keepalive");
if (len != 3)
(void)printf("[len=%d] ", len);
break;
case 5:
(void)printf(" Notification");
break;
default:
(void)printf(" [type=%d len=%d]", type, len);
break;
}
sp += (len - 3);
length -= (len - 3);
}
return;
trunc:
(void)printf(" [|msdp]");
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.87 2000/10/07 05:53:12 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.89 2001/07/08 08:01:43 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -1205,7 +1205,7 @@ parserddires(const u_int32_t *dp)
int er;
dp = parsestatus(dp, &er);
if (dp == 0 || er)
if (dp == NULL || er)
return (0);
if (qflag)
return (1);
@ -1487,7 +1487,8 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_ACCESS:
printf(" access");
dp = parserep(rp, length);
if (!(dp = parserep(rp, length)))
break;
if (!(dp = parsestatus(dp, &er)))
break;
if (vflag)

View File

@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.31 2000/10/06 04:23:13 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.32 2001/08/20 15:36:57 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -61,7 +61,6 @@ ntp_print(register const u_char *cp, u_int length)
{
register const struct ntpdata *bp;
int mode, version, leapind;
static char rclock[5];
bp = (struct ntpdata *)cp;
/* Note funny sized packets */
@ -156,9 +155,7 @@ ntp_print(register const u_char *cp, u_int length)
break;
case PRIM_REF:
strncpy(rclock, (char *)&(bp->refid), 4);
rclock[4] = '\0';
fputs(rclock, stdout);
fn_printn((char *)&(bp->refid), 4, NULL);
break;
case INFO_QUERY:

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.40 2000/12/16 22:00:50 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.41 2001/07/05 18:54:15 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -113,6 +113,7 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
const struct ip *ip;
u_int family;
++infodelay;
ts_print(&h->ts);
memcpy((char *)&family, (char *)p, sizeof(family));
@ -160,5 +161,8 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (xflag)
default_print((const u_char *)ip, caplen - NULL_HDRLEN);
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.29 2000/09/29 04:58:45 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.31 2001/06/28 04:34:51 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -403,8 +403,9 @@ ospf_decode_v2(register const struct ospfhdr *op,
printf(" bdr %s",
ipaddr_string(&op->ospf_hello.hello_bdr));
if (vflag) {
printf(" nbrs");
ap = op->ospf_hello.hello_neighbor;
if ((u_char *)ap < dataend)
printf(" nbrs");
while ((u_char *)ap < dataend) {
TCHECK(*ap);
printf(" %s", ipaddr_string(ap));
@ -509,12 +510,6 @@ ospf_print(register const u_char *bp, register u_int length,
op = (struct ospfhdr *)bp;
ip = (struct ip *)bp2;
/* Print the source and destination address */
#if 0
(void) printf("%s > %s:",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
#endif
/* XXX Before we do anything else, strip off the MD5 trailer */
TCHECK(op->ospf_authtype);
@ -527,7 +522,7 @@ ospf_print(register const u_char *bp, register u_int length,
/* value. If it's not valid, say so and return */
TCHECK(op->ospf_type);
cp = tok2str(type2str, "type%d", op->ospf_type);
printf(" OSPFv%d-%s %d:", op->ospf_version, cp, length);
printf("OSPFv%d-%s %d:", op->ospf_version, cp, length);
if (*cp == 't')
return;

View File

@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.6 2000/09/29 04:58:45 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.7 2001/05/09 01:08:03 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -359,7 +359,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
flags32 = ntohl(lsap->lsa_un.un_asla.asla_metric);
ospf6_print_bits(ospf6_asla_flag_bits, flags32);
printf(" metric %u",
ntohl(lsap->lsa_un.un_asla.asla_metric) &
(u_int32_t)ntohl(lsap->lsa_un.un_asla.asla_metric) &
ASLA_MASK_METRIC);
lsapp = lsap->lsa_un.un_asla.asla_prefix;
k = ospf6_print_lsaprefix(lsapp);

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.23 2000/10/03 02:55:00 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.29 2001/07/04 21:36:15 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -69,280 +69,287 @@ static void pimv2_print(register const u_char *bp, register u_int len);
static void
pimv1_join_prune_print(register const u_char *bp, register u_int len)
{
int maddrlen, addrlen, ngroups, njoin, nprune;
int njp;
int maddrlen, addrlen, ngroups, njoin, nprune;
int njp;
/* If it's a single group and a single source, use 1-line output. */
if (TTEST2(bp[0], 30) && bp[11] == 1 &&
((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
int hold;
/* If it's a single group and a single source, use 1-line output. */
if (TTEST2(bp[0], 30) && bp[11] == 1 &&
((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
int hold;
(void)printf(" RPF %s ", ipaddr_string(bp));
hold = EXTRACT_16BITS(&bp[6]);
if (hold != 180) {
(void)printf("Hold ");
relts_print(hold);
}
(void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune",
ipaddr_string(&bp[26]), bp[25] & 0x3f,
ipaddr_string(&bp[12]));
if (EXTRACT_32BITS(&bp[16]) != 0xffffffff)
(void)printf("/%s", ipaddr_string(&bp[16]));
(void)printf(") %s%s %s",
(void)printf(" RPF %s ", ipaddr_string(bp));
hold = EXTRACT_16BITS(&bp[6]);
if (hold != 180) {
(void)printf("Hold ");
relts_print(hold);
}
(void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune",
ipaddr_string(&bp[26]), bp[25] & 0x3f,
ipaddr_string(&bp[12]));
if (EXTRACT_32BITS(&bp[16]) != 0xffffffff)
(void)printf("/%s", ipaddr_string(&bp[16]));
(void)printf(") %s%s %s",
(bp[24] & 0x01) ? "Sparse" : "Dense",
(bp[25] & 0x80) ? " WC" : "",
(bp[25] & 0x40) ? "RP" : "SPT");
return;
}
TCHECK2(bp[0], 4);
(void)printf("\n Upstream Nbr: %s", ipaddr_string(bp));
TCHECK2(bp[6], 2);
(void)printf("\n Hold time: ");
relts_print(EXTRACT_16BITS(&bp[6]));
bp += 8; len -= 8;
return;
}
TCHECK2(bp[0], 4);
maddrlen = bp[1];
addrlen = bp[2];
ngroups = bp[3];
bp += 4; len -= 4;
while (ngroups--) {
TCHECK2(bp[0], 4);
(void)printf("\n\tGroup: %s", ipaddr_string(bp));
if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
(void)printf("/%s", ipaddr_string(&bp[4]));
TCHECK2(bp[8], 4);
njoin = EXTRACT_16BITS(&bp[8]);
nprune = EXTRACT_16BITS(&bp[10]);
(void)printf(" joined: %d pruned: %d", njoin, nprune);
bp += 12; len -= 12;
for (njp = 0; njp < (njoin + nprune); njp++) {
char *type;
if (vflag > 1)
(void)printf("\n");
(void)printf(" Upstream Nbr: %s", ipaddr_string(bp));
TCHECK2(bp[6], 2);
if (vflag > 1)
(void)printf("\n");
(void)printf(" Hold time: ");
relts_print(EXTRACT_16BITS(&bp[6]));
if (vflag < 2)
return;
bp += 8;
len -= 8;
if (njp < njoin) {
type = "Join ";
} else {
type = "Prune";
}
TCHECK2(bp[0], 6);
(void)printf("\n\t%s %s%s%s%s/%d", type,
TCHECK2(bp[0], 4);
maddrlen = bp[1];
addrlen = bp[2];
ngroups = bp[3];
bp += 4;
len -= 4;
while (ngroups--) {
TCHECK2(bp[0], 4);
(void)printf("\n\tGroup: %s", ipaddr_string(bp));
if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
(void)printf("/%s", ipaddr_string(&bp[4]));
TCHECK2(bp[8], 4);
njoin = EXTRACT_16BITS(&bp[8]);
nprune = EXTRACT_16BITS(&bp[10]);
(void)printf(" joined: %d pruned: %d", njoin, nprune);
bp += 12;
len -= 12;
for (njp = 0; njp < (njoin + nprune); njp++) {
char *type;
if (njp < njoin)
type = "Join ";
else
type = "Prune";
TCHECK2(bp[0], 6);
(void)printf("\n\t%s %s%s%s%s/%d", type,
(bp[0] & 0x01) ? "Sparse " : "Dense ",
(bp[1] & 0x80) ? "WC " : "",
(bp[1] & 0x40) ? "RP " : "SPT ",
ipaddr_string(&bp[2]), bp[1] & 0x3f);
bp += 6; len -= 6;
ipaddr_string(&bp[2]), bp[1] & 0x3f);
bp += 6;
len -= 6;
}
}
}
return;
return;
trunc:
(void)printf("[|pim]");
return;
(void)printf("[|pim]");
return;
}
void
pimv1_print(register const u_char *bp, register u_int len)
{
register const u_char *ep;
register u_char type;
register const u_char *ep;
register u_char type;
ep = (const u_char *)snapend;
if (bp >= ep)
return;
ep = (const u_char *)snapend;
if (bp >= ep)
return;
type = bp[1];
type = bp[1];
switch (type) {
case 0:
(void)printf(" Query");
if (TTEST(bp[8])) {
switch (bp[8] >> 4) {
case 0: (void)printf(" Dense-mode");
switch (type) {
case 0:
(void)printf(" Query");
if (TTEST(bp[8])) {
switch (bp[8] >> 4) {
case 0:
(void)printf(" Dense-mode");
break;
case 1: (void)printf(" Sparse-mode");
case 1:
(void)printf(" Sparse-mode");
break;
case 2: (void)printf(" Sparse-Dense-mode");
case 2:
(void)printf(" Sparse-Dense-mode");
break;
default: (void)printf(" mode-%d", bp[8] >> 4);
default:
(void)printf(" mode-%d", bp[8] >> 4);
break;
}
}
}
if (vflag) {
TCHECK2(bp[10],2);
(void)printf(" (Hold-time ");
relts_print(EXTRACT_16BITS(&bp[10]));
(void)printf(")");
}
break;
if (vflag) {
TCHECK2(bp[10],2);
(void)printf(" (Hold-time ");
relts_print(EXTRACT_16BITS(&bp[10]));
(void)printf(")");
}
break;
case 1:
(void)printf(" Register");
TCHECK2(bp[8], 20); /* ip header */
(void)printf(" for %s > %s", ipaddr_string(&bp[20]),
ipaddr_string(&bp[24]));
break;
case 2:
(void)printf(" Register-Stop");
TCHECK2(bp[12], 4);
(void)printf(" for %s > %s", ipaddr_string(&bp[8]),
ipaddr_string(&bp[12]));
break;
case 3:
(void)printf(" Join/Prune");
if (vflag) {
pimv1_join_prune_print(&bp[8], len - 8);
}
break;
case 4:
(void)printf(" RP-reachable");
if (vflag) {
TCHECK2(bp[22], 2);
(void)printf(" group %s",
case 1:
(void)printf(" Register");
TCHECK2(bp[8], 20); /* ip header */
(void)printf(" for %s > %s", ipaddr_string(&bp[20]),
ipaddr_string(&bp[24]));
break;
case 2:
(void)printf(" Register-Stop");
TCHECK2(bp[12], 4);
(void)printf(" for %s > %s", ipaddr_string(&bp[8]),
ipaddr_string(&bp[12]));
break;
case 3:
(void)printf(" Join/Prune");
if (vflag)
pimv1_join_prune_print(&bp[8], len - 8);
break;
case 4:
(void)printf(" RP-reachable");
if (vflag) {
TCHECK2(bp[22], 2);
(void)printf(" group %s",
ipaddr_string(&bp[8]));
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
(void)printf("/%s", ipaddr_string(&bp[12]));
(void)printf(" RP %s hold ", ipaddr_string(&bp[16]));
relts_print(EXTRACT_16BITS(&bp[22]));
}
break;
case 5:
(void)printf(" Assert");
TCHECK2(bp[16], 4);
(void)printf(" for %s > %s", ipaddr_string(&bp[16]),
ipaddr_string(&bp[8]));
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
(void)printf("/%s", ipaddr_string(&bp[12]));
(void)printf(" RP %s hold ",
ipaddr_string(&bp[16]));
relts_print(EXTRACT_16BITS(&bp[22]));
}
break;
case 5:
(void)printf(" Assert");
TCHECK2(bp[16], 4);
(void)printf(" for %s > %s", ipaddr_string(&bp[16]),
ipaddr_string(&bp[8]));
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
(void)printf("/%s", ipaddr_string(&bp[12]));
TCHECK2(bp[24], 4);
(void)printf(" %s pref %d metric %d",
(bp[20] & 0x80) ? "RP-tree" : "SPT",
TCHECK2(bp[24], 4);
(void)printf(" %s pref %d metric %d",
(bp[20] & 0x80) ? "RP-tree" : "SPT",
EXTRACT_32BITS(&bp[20]) & 0x7fffffff,
EXTRACT_32BITS(&bp[24]));
break;
case 6:
(void)printf(" Graft");
if (vflag) {
pimv1_join_prune_print(&bp[8], len - 8);
break;
case 6:
(void)printf(" Graft");
if (vflag)
pimv1_join_prune_print(&bp[8], len - 8);
break;
case 7:
(void)printf(" Graft-ACK");
if (vflag)
pimv1_join_prune_print(&bp[8], len - 8);
break;
case 8:
(void)printf(" Mode");
break;
default:
(void)printf(" [type %d]", type);
break;
}
break;
case 7:
(void)printf(" Graft-ACK");
if (vflag) {
pimv1_join_prune_print(&bp[8], len - 8);
}
break;
case 8:
(void)printf(" Mode");
break;
default:
(void)printf(" [type %d]", type);
break;
}
if ((bp[4] >> 4) != 1)
(void)printf(" [v%d]", bp[4] >> 4);
return;
if ((bp[4] >> 4) != 1)
(void)printf(" [v%d]", bp[4] >> 4);
return;
trunc:
(void)printf("[|pim]");
return;
(void)printf("[|pim]");
return;
}
/*
* auto-RP is a cisco protocol, documented at
* ftp://ftpeng.cisco.com/ipmulticast/pim-autorp-spec01.txt
* ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
*
* This implements version 1+, dated Sept 9, 1998.
*/
void
cisco_autorp_print(register const u_char *bp, register u_int len)
{
int type;
int numrps;
int hold;
int type;
int numrps;
int hold;
TCHECK(bp[0]);
(void)printf(" auto-rp ");
type = bp[0];
switch (type) {
case 0x11:
(void)printf("candidate-advert");
break;
case 0x12:
(void)printf("mapping");
break;
default:
(void)printf("type-0x%02x", type);
break;
}
TCHECK(bp[1]);
numrps = bp[1];
TCHECK2(bp[2], 2);
(void)printf(" Hold ");
hold = EXTRACT_16BITS(&bp[2]);
if (hold)
relts_print(EXTRACT_16BITS(&bp[2]));
else
printf("FOREVER");
/* Next 4 bytes are reserved. */
bp += 8; len -= 8;
/*XXX skip unless -v? */
/*
* Rest of packet:
* numrps entries of the form:
* 32 bits: RP
* 6 bits: reserved
* 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
* 8 bits: # of entries for this RP
* each entry: 7 bits: reserved, 1 bit: negative,
* 8 bits: mask 32 bits: source
* lather, rinse, repeat.
*/
while (numrps--) {
int nentries;
char s;
TCHECK2(bp[0], 4);
(void)printf(" RP %s", ipaddr_string(bp));
TCHECK(bp[4]);
switch (bp[4] & 0x3) {
case 0: printf(" PIMv?");
TCHECK(bp[0]);
(void)printf(" auto-rp ");
type = bp[0];
switch (type) {
case 0x11:
(void)printf("candidate-advert");
break;
case 1: printf(" PIMv1");
case 0x12:
(void)printf("mapping");
break;
case 2: printf(" PIMv2");
break;
case 3: printf(" PIMv1+2");
default:
(void)printf("type-0x%02x", type);
break;
}
TCHECK(bp[5]);
nentries = bp[5];
bp += 6; len -= 6;
s = ' ';
for (; nentries; nentries--) {
TCHECK2(bp[0], 6);
(void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
ipaddr_string(&bp[2]), bp[1]);
s = ',';
bp += 6; len -= 6;
TCHECK(bp[1]);
numrps = bp[1];
TCHECK2(bp[2], 2);
(void)printf(" Hold ");
hold = EXTRACT_16BITS(&bp[2]);
if (hold)
relts_print(EXTRACT_16BITS(&bp[2]));
else
printf("FOREVER");
/* Next 4 bytes are reserved. */
bp += 8; len -= 8;
/*XXX skip unless -v? */
/*
* Rest of packet:
* numrps entries of the form:
* 32 bits: RP
* 6 bits: reserved
* 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
* 8 bits: # of entries for this RP
* each entry: 7 bits: reserved, 1 bit: negative,
* 8 bits: mask 32 bits: source
* lather, rinse, repeat.
*/
while (numrps--) {
int nentries;
char s;
TCHECK2(bp[0], 4);
(void)printf(" RP %s", ipaddr_string(bp));
TCHECK(bp[4]);
switch (bp[4] & 0x3) {
case 0: printf(" PIMv?");
break;
case 1: printf(" PIMv1");
break;
case 2: printf(" PIMv2");
break;
case 3: printf(" PIMv1+2");
break;
}
if (bp[4] & 0xfc)
(void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc);
TCHECK(bp[5]);
nentries = bp[5];
bp += 6; len -= 6;
s = ' ';
for (; nentries; nentries--) {
TCHECK2(bp[0], 6);
(void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
ipaddr_string(&bp[2]), bp[1]);
if (bp[0] & 0xfe)
(void)printf("[rsvd=0x%02x]", bp[0] & 0xfe);
s = ',';
bp += 6; len -= 6;
}
}
}
return;
return;
trunc:
(void)printf("[|autorp]");
return;
(void)printf("[|autorp]");
return;
}
void
@ -359,11 +366,11 @@ pim_print(register const u_char *bp, register u_int len)
#endif
switch (PIM_VER(pim->pim_typever)) {
case 2: /* avoid hardcoding? */
case 2: /* avoid hardcoding? */
(void)printf("pim v2");
pimv2_print(bp, len);
break;
default:
default:
(void)printf("pim v%d", PIM_VER(pim->pim_typever));
break;
}
@ -415,11 +422,6 @@ static int pimv2_addr_len;
enum pimv2_addrtype {
pimv2_unicast, pimv2_group, pimv2_source
};
#if 0
static char *addrtypestr[] = {
"unicast", "group", "source"
};
#endif
/* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@ -453,19 +455,19 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
if (pimv2_addr_len == 0) {
TCHECK(bp[1]);
switch (bp[0]) {
case 1:
case 1:
af = AF_INET;
afstr = "IPv4";
len = 4;
break;
#ifdef INET6
case 2:
case 2:
af = AF_INET6;
afstr = "IPv6";
len = 16;
break;
#endif
default:
default:
return -1;
}
if (bp[1] != 0)
@ -473,17 +475,17 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
hdrlen = 2;
} else {
switch (pimv2_addr_len) {
case 4:
case 4:
af = AF_INET;
afstr = "IPv4";
break;
#ifdef INET6
case 16:
case 16:
af = AF_INET6;
afstr = "IPv6";
break;
#endif
default:
default:
return -1;
break;
}
@ -493,7 +495,7 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
bp += hdrlen;
switch (at) {
case pimv2_unicast:
case pimv2_unicast:
TCHECK2(bp[0], len);
if (af == AF_INET) {
if (!silent)
@ -506,8 +508,8 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
}
#endif
return hdrlen + len;
case pimv2_group:
case pimv2_source:
case pimv2_group:
case pimv2_source:
TCHECK2(bp[0], len + 2);
if (af == AF_INET) {
if (!silent) {
@ -565,7 +567,7 @@ pimv2_print(register const u_char *bp, register u_int len)
(void)printf("[RFC2117-encoding] ");
switch (PIM_TYPE(pim->pim_typever)) {
case 0:
case 0:
{
u_int16_t otype, olen;
(void)printf(" Hello");
@ -582,20 +584,13 @@ pimv2_print(register const u_char *bp, register u_int len)
(void)printf(")");
break;
/* XXX
* draft-ietf-idmr-pimv2-dr-priority-00.txt
* says that DR-Priority is option 19.
* draft-ietf-pim-v2-sm-00.txt says it's 18.
*/
case 18: /* DR-Priority */
(void)printf(" (DR-Priority: %d)", EXTRACT_32BITS(&bp[4]));
break;
case 19: /* Bidir-Capable */
if (olen == 4)
(void)printf(" (OLD-DR-Priority: %d)", EXTRACT_32BITS(&bp[4]));
else
(void)printf(" (bidir-capable)");
case 19: /* DR-Priority */
(void)printf(" (DR-Priority: ");
if (olen != 4) {
(void)printf("!olen=%d!)", olen);
} else {
(void)printf("%d)", EXTRACT_32BITS(&bp[4]));
}
break;
case 20:
@ -603,13 +598,21 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
case 21:
(void)printf(" (State Refresh Capable");
if (EXTRACT_32BITS(&bp[4]) != 1) {
(void)printf(" ?0x%x?", EXTRACT_32BITS(&bp[4]));
(void)printf(" (State Refresh Capable; v%d", bp[4]);
if (bp[5] != 0) {
(void)printf(" interval ");
relts_print(bp[5]);
}
if (EXTRACT_16BITS(&bp[6]) != 0) {
(void)printf(" ?0x%04x?", EXTRACT_16BITS(&bp[6]));
}
(void)printf(")");
break;
case 22: /* Bidir-Capable */
(void)printf(" (bidir-capable)");
break;
default:
if (vflag)
(void)printf(" [Hello option %d]", otype);
@ -619,8 +622,8 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
}
case 1:
{
case 1:
{
struct ip *ip;
(void)printf(" Register");
@ -635,24 +638,24 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
ip = (struct ip *)bp;
switch (IP_V(ip)) {
case 4: /* IPv4 */
case 4: /* IPv4 */
printf(" ");
ip_print(bp, len);
break;
#ifdef INET6
case 6: /* IPv6 */
case 6: /* IPv6 */
printf(" ");
ip6_print(bp, len);
break;
#endif
default:
default:
(void)printf(" IP ver %d", IP_V(ip));
break;
}
break;
}
}
case 2:
case 2:
(void)printf(" Register-Stop");
bp += 4; len -= 4;
if (bp >= ep)
@ -673,9 +676,9 @@ pimv2_print(register const u_char *bp, register u_int len)
bp += advance; len -= advance;
break;
case 3:
case 6:
case 7:
case 3:
case 6:
case 7:
{
u_int8_t ngroup;
u_int16_t holdtime;
@ -684,13 +687,13 @@ pimv2_print(register const u_char *bp, register u_int len)
int i, j;
switch (PIM_TYPE(pim->pim_typever)) {
case 3:
case 3:
(void)printf(" Join/Prune");
break;
case 6:
case 6:
(void)printf(" Graft");
break;
case 7:
case 7:
(void)printf(" Graft-ACK");
break;
}
@ -758,8 +761,8 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
}
case 4:
{
case 4:
{
int i, j, frpcnt;
(void)printf(" Bootstrap");
@ -835,8 +838,8 @@ pimv2_print(register const u_char *bp, register u_int len)
}
bs_done:
break;
}
case 5:
}
case 5:
(void)printf(" Assert");
bp += 4; len -= 4;
if (bp >= ep)
@ -863,8 +866,8 @@ pimv2_print(register const u_char *bp, register u_int len)
(void)printf(" metric=%u", EXTRACT_32BITS(&bp[4]));
break;
case 8:
{
case 8:
{
int i, pfxcnt;
(void)printf(" Candidate-RP-Advertisement");
@ -901,9 +904,9 @@ pimv2_print(register const u_char *bp, register u_int len)
bp += advance;
}
break;
}
}
case 9:
case 9:
(void)printf(" Prune-Refresh");
(void)printf(" src=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {

View File

@ -31,7 +31,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.58 2000/12/27 11:09:08 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.64 2001/09/09 02:04:19 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -352,14 +352,14 @@ ppp_protoname(u_int proto)
case PPP_XNS: return "XNS";
#endif
case PPP_IPX: return "IPX";
case PPP_OSI: return "OSI";
case PPP_VJC: return "VJC";
case PPP_VJNC: return "VJNC";
#ifdef PPP_COMP
case PPP_COMP: return "COMP";
#endif
case PPP_IPCP: return "IPCP";
case PPP_IPV6CP: return "IPv6CP";
case PPP_IPXCP: return "IPXCP";
case PPP_OSICP: return "OSICP";
case PPP_CCP: return "CCP";
case PPP_LCP: return "LCP";
case PPP_PAP: return "PAP";
@ -981,6 +981,11 @@ handle_ppp(u_int proto, const u_char *p, int length)
case PPP_IPX:
ipx_print(p, length);
break;
case PPP_OSI:
isoclns_print(p, length, length, NULL, NULL);
break;
default:
break;
}
}
@ -1014,7 +1019,8 @@ ppp_print(register const u_char *p, u_int length)
length -= 2;
}
printf("%s %d: ", ppp_protoname(proto), full_length);
if (eflag)
printf("%s %d: ", ppp_protoname(proto), full_length);
handle_ppp(proto, p, length);
return;
@ -1031,6 +1037,7 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
register u_int length = h->len;
register u_int caplen = h->caplen;
++infodelay;
ts_print(&h->ts);
if (caplen < PPP_HDRLEN) {
@ -1093,6 +1100,9 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}
/*
@ -1112,6 +1122,9 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
register u_int caplen = h->caplen;
u_int proto;
++infodelay;
ts_print(&h->ts);
if (caplen < 2) {
printf("[|ppp]");
goto out;
@ -1133,7 +1146,6 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
goto out;
}
ts_print(&h->ts);
if (eflag)
printf("%02x %02x %d ", p[0], p[1], length);
p += 2;
@ -1142,21 +1154,18 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
proto = EXTRACT_16BITS(p);
p += 2;
length -= 2;
printf("%s: ", ppp_protoname(proto));
if (eflag)
printf("%s: ", ppp_protoname(proto));
handle_ppp(proto, p, length);
break;
case CHDLC_UNICAST:
case CHDLC_BCAST:
/*
* Have the Cisco HDLC print routine do all the work.
*/
chdlc_if_print(user, h, p);
return;
chdlc_print(p, length, caplen);
goto out;
default:
ts_print(&h->ts);
if (eflag)
printf("%02x %02x %d ", p[0], p[1], length);
p += 2;
@ -1175,6 +1184,9 @@ ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}
@ -1229,6 +1241,7 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
const u_char *q;
int i;
++infodelay;
ts_print(&h->ts);
if (caplen < PPP_BSDI_HDRLEN) {
@ -1370,5 +1383,8 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
default_print((const u_char *)p, caplen - hdrlength);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
#endif /* __bsdi__ */
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.12 2000/10/09 02:59:40 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.15 2001/07/05 18:54:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -45,178 +45,175 @@ static const char rcsid[] =
#include "extract.h" /* must come after interface.h */
/* Codes */
enum {
PPPOE_PADI = 0x09,
PPPOE_PADO = 0x07,
PPPOE_PADR = 0x19,
PPPOE_PADS = 0x65,
PPPOE_PADT = 0xa7
enum {
PPPOE_PADI = 0x09,
PPPOE_PADO = 0x07,
PPPOE_PADR = 0x19,
PPPOE_PADS = 0x65,
PPPOE_PADT = 0xa7
};
static struct tok pppoecode2str[] = {
{ PPPOE_PADI, "PADI"},
{ PPPOE_PADO, "PADO"},
{ PPPOE_PADR, "PADR"},
{ PPPOE_PADS, "PADS"},
{ PPPOE_PADT, "PADT"},
{ 0, ""}, /* PPP Data */
{ 0, NULL }
{ PPPOE_PADI, "PADI" },
{ PPPOE_PADO, "PADO" },
{ PPPOE_PADR, "PADR" },
{ PPPOE_PADS, "PADS" },
{ PPPOE_PADT, "PADT" },
{ 0, "" }, /* PPP Data */
{ 0, NULL }
};
/* Tags */
enum {
PPPOE_EOL = 0,
PPPOE_SERVICE_NAME = 0x0101,
PPPOE_AC_NAME = 0x0102,
PPPOE_HOST_UNIQ = 0x0103,
PPPOE_AC_COOKIE = 0x0104,
PPPOE_VENDOR = 0x0105,
PPPOE_RELAY_SID = 0x0110,
PPPOE_SERVICE_NAME_ERROR = 0x0201,
PPPOE_AC_SYSTEM_ERROR = 0x0202,
PPPOE_GENERIC_ERROR = 0x0203
PPPOE_EOL = 0,
PPPOE_SERVICE_NAME = 0x0101,
PPPOE_AC_NAME = 0x0102,
PPPOE_HOST_UNIQ = 0x0103,
PPPOE_AC_COOKIE = 0x0104,
PPPOE_VENDOR = 0x0105,
PPPOE_RELAY_SID = 0x0110,
PPPOE_SERVICE_NAME_ERROR = 0x0201,
PPPOE_AC_SYSTEM_ERROR = 0x0202,
PPPOE_GENERIC_ERROR = 0x0203
};
static struct tok pppoetag2str[] = {
{ PPPOE_EOL, "EOL"},
{ PPPOE_SERVICE_NAME, "Service-Name" },
{ PPPOE_AC_NAME, "AC-Name" },
{ PPPOE_HOST_UNIQ, "Host-Uniq" },
{ PPPOE_AC_COOKIE, "AC-Cookie" },
{ PPPOE_VENDOR, "Vendor-Specific" },
{ PPPOE_RELAY_SID, "Relay-Session-ID" },
{ PPPOE_SERVICE_NAME_ERROR, "Service-Name-Error" },
{ PPPOE_AC_SYSTEM_ERROR, "AC-System-Error" },
{ PPPOE_GENERIC_ERROR, "Generic-Error" },
{ 0, NULL}
{ PPPOE_EOL, "EOL" },
{ PPPOE_SERVICE_NAME, "Service-Name" },
{ PPPOE_AC_NAME, "AC-Name" },
{ PPPOE_HOST_UNIQ, "Host-Uniq" },
{ PPPOE_AC_COOKIE, "AC-Cookie" },
{ PPPOE_VENDOR, "Vendor-Specific" },
{ PPPOE_RELAY_SID, "Relay-Session-ID" },
{ PPPOE_SERVICE_NAME_ERROR, "Service-Name-Error" },
{ PPPOE_AC_SYSTEM_ERROR, "AC-System-Error" },
{ PPPOE_GENERIC_ERROR, "Generic-Error" },
{ 0, NULL }
};
#define PPPOE_HDRLEN 6
void
pppoe_if_print(u_char *user, const struct pcap_pkthdr *h,
register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
++infodelay;
ts_print(&h->ts);
/*
* Some printers want to get back at the link level addresses,
* and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
packetp = p;
snapend = p + caplen;
pppoe_print(p, length);
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}
void
pppoe_print(register const u_char *bp, u_int length)
{
register const struct ether_header *eh;
register u_short pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid, pppoe_length;
const u_char *pppoe_packet, *pppoe_payload;
u_short pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid, pppoe_length;
const u_char *pppoe_packet, *pppoe_payload;
eh = (struct ether_header *)packetp;
pppoe_packet = packetp+ETHER_HDRLEN;
if (pppoe_packet > snapend) {
printf("[|pppoe]");
return;
}
pppoe_packet = bp;
if (pppoe_packet > snapend) {
printf("[|pppoe]");
return;
}
pppoe_ver = (pppoe_packet[0]&0xF0)>>4;
pppoe_type = (pppoe_packet[0]&0x0F);
pppoe_code = (pppoe_packet[1]);
pppoe_sessionid = (EXTRACT_16BITS(pppoe_packet+2));
pppoe_length = (EXTRACT_16BITS(pppoe_packet+4));
pppoe_payload = pppoe_packet+6;
if (snapend < pppoe_payload) {
printf(" truncated PPPoE");
return;
}
if (pppoe_ver != 1) {
printf(" [ver %d]",pppoe_ver);
}
if (pppoe_type != 1) {
printf(" [type %d]",pppoe_type);
}
printf("PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code));
if (pppoe_code == PPPOE_PADI && pppoe_length > 1484-PPPOE_HDRLEN) {
printf(" [len %d!]",pppoe_length);
}
if (pppoe_sessionid) {
printf(" [ses 0x%x]",pppoe_sessionid);
}
pppoe_ver = (pppoe_packet[0] & 0xF0) >> 4;
pppoe_type = (pppoe_packet[0] & 0x0F);
pppoe_code = pppoe_packet[1];
pppoe_sessionid = EXTRACT_16BITS(pppoe_packet + 2);
pppoe_length = EXTRACT_16BITS(pppoe_packet + 4);
pppoe_payload = pppoe_packet + PPPOE_HDRLEN;
if (pppoe_payload + pppoe_length < snapend) {
/*
printf(" [length %d (%d extra bytes)]", pppoe_length, snapend-pppoe_payload-pppoe_length);
{
const u_char *x = pppoe_payload+pppoe_length;
default_print(x, snapend - x);
}
*/
snapend = pppoe_payload+pppoe_length;
}
if (snapend < pppoe_payload) {
printf(" truncated PPPoE");
return;
}
if (pppoe_code) {
/* PPP session packets don't contain tags */
u_short tag_type = 0xffff, tag_len;
const u_char *p = pppoe_payload;
if (pppoe_ver != 1) {
printf(" [ver %d]",pppoe_ver);
}
if (pppoe_type != 1) {
printf(" [type %d]",pppoe_type);
}
/* loop invariant:
p points to next tag,
tag_type is previous tag or 0xffff for first iteration
*/
while (tag_type &&
p+4 < pppoe_payload + length &&
p+4 < snapend) {
tag_type = EXTRACT_16BITS(p);
tag_len = EXTRACT_16BITS(p+2);
p += 4;
/* p points to tag_value */
printf("PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code));
if (pppoe_code == PPPOE_PADI && pppoe_length > 1484 - PPPOE_HDRLEN) {
printf(" [len %d!]",pppoe_length);
}
if (pppoe_sessionid) {
printf(" [ses 0x%x]", pppoe_sessionid);
}
if (tag_len) {
int isascii = 1;
const u_char *v = p;
for (v=p; v<p+tag_len; v++)
if (*v >= 127 || *v < 32) {
isascii = 0;
break;
}
/* TODO print UTF8 decoded text */
if (isascii)
printf(" [%s \"%*.*s\"]",
tok2str(pppoetag2str, "TAG-0x%x", tag_type),
tag_len < 80 ? tag_len : 80,
tag_len < 80 ? tag_len : 80,
p
);
else
printf(" [%s UTF8]", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
} else
printf(" [%s]", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
p += tag_len;
/* p points to next tag */
}
} else {
if (pppoe_payload + pppoe_length < snapend) {
#if 0
/* We now make use of ppp_print() instead, because it has more
comprehensive support for PPP. It also gives us a consistent
output with other protocols like L2TP. */
u_short ptype;
if (pppoe_payload[0] & 0x1) {
ptype = pppoe_payload[0];
pppoe_payload +=1;
pppoe_length -=1;
} else if (pppoe_payload[1] & 0x1) {
ptype = ntohs(*(u_short *)pppoe_payload);
pppoe_payload +=2;
pppoe_length -=2;
} else {
printf(" Invalid PPP protocol ID: %x %x", pppoe_payload[0],pppoe_payload[1]);
return;
}
printf(" ");
if (ptype == PPP_IP)
ip_print(pppoe_payload, pppoe_length);
else if (ptype == PPP_LCP)
lcp_print(pppoe_payload, pppoe_length);
else
printf("%s ", tok2str(ppptype2str, "proto-0x%x", ptype));
const u_char *x = pppoe_payload + pppoe_length;
printf(" [length %d (%d extra bytes)]",
pppoe_length, snapend - pppoe_payload - pppoe_length);
default_print(x, snapend - x);
#endif
printf(" ");
ppp_print(pppoe_payload, pppoe_length);
}
return;
snapend = pppoe_payload+pppoe_length;
}
if (pppoe_code) {
/* PPP session packets don't contain tags */
u_short tag_type = 0xffff, tag_len;
const u_char *p = pppoe_payload;
/*
* loop invariant:
* p points to next tag,
* tag_type is previous tag or 0xffff for first iteration
*/
while (tag_type && p + 4 < pppoe_payload + length &&
p + 4 < snapend) {
tag_type = EXTRACT_16BITS(p);
tag_len = EXTRACT_16BITS(p + 2);
p += 4;
/* p points to tag_value */
if (tag_len) {
int isascii = 1;
const u_char *v = p;
u_short l;
for (v = p; v < p + tag_len; v++)
if (*v >= 127 || *v < 32) {
isascii = 0;
break;
}
/* TODO print UTF8 decoded text */
if (isascii) {
l = (tag_len < 80 ? tag_len : 80);
printf(" [%s \"%*.*s\"]",
tok2str(pppoetag2str, "TAG-0x%x", tag_type),
l, l, p);
} else
printf(" [%s UTF8]",
tok2str(pppoetag2str, "TAG-0x%x", tag_type));
} else
printf(" [%s]", tok2str(pppoetag2str,
"TAG-0x%x", tag_type));
p += tag_len;
/* p points to next tag */
}
} else {
printf(" ");
ppp_print(pppoe_payload, pppoe_length);
}
return;
}

1070
contrib/tcpdump/print-pptp.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,24 @@
/*
* Copyright (C) 2000 Alfredo Andres Omella. 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 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.
*/
/*
* Radius printer routines as specified on:
*
@ -23,13 +44,15 @@
#ifndef lint
static const char rcsid[] =
"$Id: print-radius.c,v 1.5 2000/12/18 08:16:58 guy Exp $";
"$Id: print-radius.c,v 1.10 2001/10/22 06:58:33 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <sys/param.h>
#include <netinet/in.h>
@ -115,6 +138,7 @@ struct radius_hdr { u_int8_t code; /* Radius packet code */
u_int8_t auth[16]; /* Authenticator */
};
#define MIN_RADIUS_LEN 20
struct radius_attr { u_int8_t type; /* Attribute type */
u_int8_t len; /* Attribute length */
@ -495,7 +519,6 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
}
else
{
data++;
data_value = EXTRACT_32BITS(data);
}
if ( data_value <= (attr_type[attr_code].siz_subtypes - 1 +
@ -638,7 +661,7 @@ static void print_attr_time(register u_char *data, u_int length, u_short attr_co
TCHECK2(data[0],4);
attr_time = EXTRACT_32BITS(data);
strcpy(string, ctime(&attr_time));
strlcpy(string, ctime(&attr_time), sizeof(string));
/* Get rid of the newline */
string[24] = '\0';
printf("{%.24s}", string);
@ -730,7 +753,7 @@ static void print_attr_strange(register u_char *data, u_int length, u_short attr
static void
radius_attr_print(register u_char *attr, u_int length)
radius_attr_print(register const u_char *attr, u_int length)
{
register const struct radius_attr *rad_attr = (struct radius_attr *)attr;
@ -743,6 +766,11 @@ radius_attr_print(register u_char *attr, u_int length)
printf(" Attr[ ");
while (length > 0)
{
if (rad_attr->len == 0)
{
printf("(zero-length attribute)");
return;
}
if ( rad_attr->len <= length )
{
if ( !rad_attr->type || (rad_attr->type > (TAM_SIZE(attr_type)-1)) )
@ -778,17 +806,30 @@ radius_print(const u_char *dat, u_int length)
{
register const struct radius_hdr *rad;
register int i;
int len;
i = min(length, snapend - dat) - sizeof(*rad);
i = min(length, snapend - dat);
if (i < 0)
if (i < MIN_RADIUS_LEN)
{
printf(" [|radius]");
return;
}
rad = (struct radius_hdr *)dat;
len = ntohs(rad->len);
if (len < MIN_RADIUS_LEN)
{
printf(" [|radius]");
return;
}
if (len < i)
i = len;
i -= MIN_RADIUS_LEN;
switch (rad->code)
{
case RADCMD_ACCESS_REQ:
@ -834,5 +875,5 @@ radius_print(const u_char *dat, u_int length)
printf(" [id %d]", rad->id);
if (i)
radius_attr_print( ((u_char *)(rad+1)), i);
radius_attr_print( dat + MIN_RADIUS_LEN, i);
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.33 2000/10/06 04:23:13 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.34 2001/07/05 18:54:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -53,6 +53,7 @@ raw_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_int length = h->len;
u_int caplen = h->caplen;
++infodelay;
ts_print(&h->ts);
/*
@ -71,4 +72,7 @@ raw_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (xflag)
default_print(p, caplen);
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.47 2000/10/03 04:19:07 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.49 2001/05/10 05:30:22 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -181,7 +181,7 @@ rip_print(const u_char *dat, u_int length)
*
* so perhaps we should just dump the first few words of
* the packet, in hex.
*/
*/
printf(" RIPv0: ");
ni = (struct rip_netinfo *)(rp + 1);
rip_printblk((u_char *)&ni->rip_family,
@ -215,7 +215,7 @@ rip_print(const u_char *dat, u_int length)
case RIPCMD_TRACEON:
printf(" RIPv%d-traceon %d: \"", rp->rip_vers, length);
(void)fn_print((const u_char *)(rp + 1), snapend);
fputs("\"\n", stdout);
fputs("\"", stdout);
break;
case RIPCMD_TRACEOFF:
printf(" RIPv%d-traceoff %d", rp->rip_vers, length);
@ -231,5 +231,5 @@ rip_print(const u_char *dat, u_int length)
length);
break;
}
}
}
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.7 2000/10/07 05:46:21 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.10 2001/11/16 08:59:22 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -57,7 +57,7 @@ rip6_entry_print(register const struct netinfo6 *ni, int metric)
}
void
ripng_print(const u_char *dat, int length)
ripng_print(const u_char *dat, unsigned int length)
{
register const struct rip6 *rp = (struct rip6 *)dat;
register const struct netinfo6 *ni;
@ -81,12 +81,12 @@ ripng_print(const u_char *dat, int length)
break;
}
if (j * sizeof(*ni) != length - 4)
printf(" ripng-req %d[%d]:", j, length);
printf(" ripng-req %d[%u]:", j, length);
else
printf(" ripng-req %d:", j);
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
if (vflag)
if (vflag > 1)
printf("\n\t");
else
printf(" ");
@ -96,22 +96,22 @@ ripng_print(const u_char *dat, int length)
case RIP6_RESPONSE:
j = length / sizeof(*ni);
if (j * sizeof(*ni) != length - 4)
printf(" ripng-resp %d[%d]:", j, length);
printf(" ripng-resp %d[%u]:", j, length);
else
printf(" ripng-resp %d:", j);
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
if (vflag)
if (vflag > 1)
printf("\n\t");
else
printf(" ");
rip6_entry_print(ni, ni->rip6_metric);
}
if (trunc)
printf("[|rip]");
printf("[|ripng]");
break;
default:
printf(" ripng-%d ?? %d", rp->rip6_cmd, length);
printf(" ripng-%d ?? %u", rp->rip6_cmd, length);
break;
}
if (rp->rip6_vers != RIP6_VERSION)

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.17 2000/12/13 07:57:05 itojun Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.18 2001/06/15 22:17:34 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -62,12 +62,6 @@ rt6_print(register const u_char *bp, register const u_char *bp2)
/* 'ep' points to the end of available data. */
ep = snapend;
#if 0
printf("%s > %s: ",
ip6addr_string(&ip->ip6_src),
ip6addr_string(&ip->ip6_dst));
#endif
TCHECK(dp->ip6r_segleft);
printf("srcrt (len=%d", dp->ip6r_len); /*)*/

View File

@ -1,3 +1,25 @@
/*
* Copyright: (c) 2000 United States Government as represented by the
* Secretary of the Navy. 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 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.
*/
/*
* This code unmangles RX packets. RX is the mutant form of RPC that AFS
* uses to communicate between clients and servers.
@ -8,12 +30,11 @@
* Bah. If I never look at rx_packet.h again, it will be too soon.
*
* Ken Hornstein <kenh@cmf.nrl.navy.mil>
*
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.20.2.1 2001/07/09 01:40:59 fenner Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.27 2001/10/20 07:41:55 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -35,9 +56,6 @@ static const char rcsid[] =
#include "addrtoname.h"
#include "extract.h"
#undef NOERROR /* Solaris sucks */
#include <arpa/nameser.h>
#include "rx.h"
#include "ip.h"
@ -56,12 +74,18 @@ static struct tok rx_types[] = {
{ 0, NULL },
};
static struct tok rx_flags[] = {
{ RX_CLIENT_INITIATED, "client-init" },
{ RX_REQUEST_ACK, "req-ack" },
{ RX_LAST_PACKET, "last-pckt" },
{ RX_MORE_PACKETS, "more-pckts" },
{ RX_FREE_PACKET, "free-pckt" }
static struct double_tok {
int flag; /* Rx flag */
int packetType; /* Packet type */
char *s; /* Flag string */
} rx_flags[] = {
{ RX_CLIENT_INITIATED, 0, "client-init" },
{ RX_REQUEST_ACK, 0, "req-ack" },
{ RX_LAST_PACKET, 0, "last-pckt" },
{ RX_MORE_PACKETS, 0, "more-pckts" },
{ RX_FREE_PACKET, 0, "free-pckt" },
{ RX_SLOW_START_OK, RX_PACKET_TYPE_ACK, "slow-start" },
{ RX_JUMBO_PACKET, RX_PACKET_TYPE_DATA, "jumbogram" }
};
static struct tok fs_req[] = {
@ -99,6 +123,7 @@ static struct tok fs_req[] = {
{ 161, "dfs-lookup" },
{ 162, "dfs-flushcps" },
{ 163, "dfs-symlink" },
{ 220, "residency" },
{ 0, NULL },
};
@ -114,6 +139,10 @@ static struct tok cb_req[] = {
{ 212, "whoareyou" },
{ 213, "initcb3" },
{ 214, "probeuuid" },
{ 215, "getsrvprefs" },
{ 216, "getcellservdb" },
{ 217, "getlocalcell" },
{ 218, "getcacheconf" },
{ 0, NULL },
};
@ -139,6 +168,7 @@ static struct tok pt_req[] = {
{ 518, "get-cps2" },
{ 519, "get-host-cps" },
{ 520, "update-entry" },
{ 521, "list-entries" },
{ 0, NULL },
};
@ -176,6 +206,7 @@ static struct tok vldb_req[] = {
{ 531, "linked-list-u" },
{ 532, "regaddr" },
{ 533, "get-addrs-u" },
{ 534, "list-attrib-n2" },
{ 0, NULL },
};
@ -270,6 +301,8 @@ static struct tok bos_req[] = {
{ 112, "start-bozo-log" },
{ 113, "wait-all" },
{ 114, "get-instance-strings" },
{ 115, "get-restricted" },
{ 116, "set-restricted" },
{ 0, NULL },
};
@ -439,7 +472,9 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
if (vflag > 1)
for (i = 0; i < NUM_RX_FLAGS; i++) {
if (rxh->flags & rx_flags[i].v) {
if (rxh->flags & rx_flags[i].flag &&
(!rx_flags[i].packetType ||
rxh->type == rx_flags[i].packetType)) {
if (!firstflag) {
firstflag = 1;
printf(" ");
@ -638,7 +673,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
#define STROUT(MAX) { unsigned int i; \
TCHECK2(bp[0], sizeof(int32_t)); \
i = EXTRACT_32BITS(bp); \
if (i > MAX) \
if (i > (MAX)) \
goto trunc; \
bp += sizeof(int32_t); \
printf(" \""); \
@ -721,14 +756,17 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
*/
#define VECOUT(MAX) { char *sp; \
char s[AFSNAMEMAX]; \
int k; \
TCHECK2(bp[0], MAX * sizeof(int32_t)); \
if ((MAX) + 1 > sizeof(s)) \
goto trunc; \
TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
sp = s; \
for (k = 0; k < MAX; k++) { \
for (k = 0; k < (MAX); k++) { \
*sp++ = (char) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
} \
s[MAX] = '\0'; \
s[(MAX)] = '\0'; \
printf(" \""); \
fn_print(s, NULL); \
printf("\""); \
@ -812,7 +850,6 @@ fs_print(register const u_char *bp, int length)
{
int fs_op;
unsigned long i;
char s[AFSNAMEMAX];
if (length <= sizeof(struct rx_header))
return;
@ -963,7 +1000,6 @@ static void
fs_reply_print(register const u_char *bp, int length, int32_t opcode)
{
unsigned long i;
char s[AFSNAMEMAX];
struct rx_header *rxh;
if (length <= sizeof(struct rx_header))
@ -1259,7 +1295,6 @@ static void
prot_print(register const u_char *bp, int length)
{
unsigned long i;
char s[AFSNAMEMAX];
int pt_op;
if (length <= sizeof(struct rx_header))
@ -1403,7 +1438,6 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
unsigned long i;
char s[AFSNAMEMAX];
if (length < sizeof(struct rx_header))
return;
@ -1516,7 +1550,6 @@ vldb_print(register const u_char *bp, int length)
{
int vldb_op;
unsigned long i;
char s[AFSNAMEMAX];
if (length <= sizeof(struct rx_header))
return;
@ -1610,7 +1643,6 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
unsigned long i;
char s[AFSNAMEMAX];
if (length < sizeof(struct rx_header))
return;
@ -1797,7 +1829,6 @@ static void
kauth_print(register const u_char *bp, int length)
{
int kauth_op;
char s[AFSNAMEMAX];
if (length <= sizeof(struct rx_header))
return;
@ -2024,7 +2055,6 @@ static void
bos_print(register const u_char *bp, int length)
{
int bos_op;
char s[BOSNAMEMAX];
if (length <= sizeof(struct rx_header))
return;

View File

@ -0,0 +1,351 @@
/* Copyright (c) 2001 NETLAB, Temple University
* Copyright (c) 2001 Protocol Engineering Lab, University of Delaware
*
* Jerry Heinz <gheinz@astro.temple.edu>
* John Fiore <jfiore@joda.cis.temple.edu>
* Armando L. Caro Jr. <acaro@cis.udel.edu>
*
* 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 University nor of the Laboratory 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.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.7 2001/12/12 07:16:40 guy Exp $ (NETLAB/PEL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <unistd.h>
#include "sctpHeader.h"
#include "sctpConstants.h"
#include <assert.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#include "ip.h"
#ifdef INET6
#include "ip6.h"
#endif
void sctp_print(const u_char *bp, /* beginning of sctp packet */
const u_char *bp2, /* beginning of enclosing */
u_int sctpPacketLength) /* ip packet */
{
const struct sctpHeader *sctpPktHdr;
const struct ip *ip;
#ifdef INET6
const struct ip6_hdr *ip6;
#endif
const u_char *cp;
void *endPacketPtr;
u_short sourcePort, destPort;
int chunkCount;
struct sctpChunkDesc *chunkDescPtr;
void *nextChunk;
sctpPktHdr = (struct sctpHeader*) bp;
endPacketPtr = ((u_char*)((u_char*)sctpPktHdr+sctpPacketLength));
if( (u_long) endPacketPtr > (u_long) snapend)
endPacketPtr = (void *) snapend;
ip = (struct ip *)bp2;
#ifdef INET6
if (IP_V(ip) == 6)
ip6 = (struct ip6_hdr *)bp2;
else
ip6 = NULL;
#endif /*INET6*/
cp = (u_char *)(sctpPktHdr + 1);
if (cp > snapend)
{
printf("[|sctp]");
return;
}
if (sctpPacketLength < sizeof(struct sctpHeader))
{
(void)printf("truncated-sctp - %ld bytes missing!",
(long)sctpPacketLength-sizeof(struct sctpHeader));
return;
}
/* sctpPacketLength -= sizeof(struct sctpHeader); packet length */
/* is now only as long as the payload */
sourcePort = ntohs(sctpPktHdr->source);
destPort = ntohs(sctpPktHdr->destination);
#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_SCTP) {
(void)printf("%s.%d > %s.%d: sctp",
ip6addr_string(&ip6->ip6_src),
sourcePort,
ip6addr_string(&ip6->ip6_dst),
destPort);
} else {
(void)printf("%d > %d: sctp",
sourcePort, destPort);
}
} else
#endif /*INET6*/
{
if (ip->ip_p == IPPROTO_SCTP) {
(void)printf("%s.%d > %s.%d: sctp",
ipaddr_string(&ip->ip_src),
sourcePort,
ipaddr_string(&ip->ip_dst),
destPort);
} else {
(void)printf("%d > %d: sctp",
sourcePort, destPort);
}
}
fflush(stdout);
if (vflag < 2)
return;
/* cycle through all chunks, printing information on each one */
for (chunkCount = 0,
chunkDescPtr = (struct sctpChunkDesc *) ( (u_char*) sctpPktHdr +
sizeof(struct sctpHeader));
chunkDescPtr != NULL &&
( (void *) ((u_char *) chunkDescPtr + sizeof(struct sctpChunkDesc))
<= endPacketPtr);
chunkDescPtr = (struct sctpChunkDesc *) nextChunk, chunkCount++)
{
u_short align;
u_char *chunkEnd;
chunkEnd = ((u_char*)chunkDescPtr + ntohs(chunkDescPtr->chunkLength));
align=ntohs(chunkDescPtr->chunkLength) % 4;
if (align != 0)
align = 4 - align;
nextChunk = (void *) (chunkEnd + align);
printf("\n\t%d) ", chunkCount+1);
switch (chunkDescPtr->chunkID)
{
case SCTP_DATA :
{
struct sctpDataPart *dataHdrPtr;
printf("[DATA] ");
if ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
== SCTP_DATA_UNORDERED)
printf("(U)");
if ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG)
== SCTP_DATA_FIRST_FRAG)
printf("(B)");
if ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
== SCTP_DATA_LAST_FRAG)
printf("(E)");
if( ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
== SCTP_DATA_UNORDERED)
||
((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG)
== SCTP_DATA_FIRST_FRAG)
||
((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
== SCTP_DATA_LAST_FRAG) )
printf(" ");
dataHdrPtr=(struct sctpDataPart*)(chunkDescPtr+1);
printf("[TSN: %u] ", (u_int32_t)ntohl(dataHdrPtr->TSN));
printf("[SID: %u] ", ntohs(dataHdrPtr->streamId));
printf("[SSEQ %u] ", ntohs(dataHdrPtr->sequence));
printf("[PPID 0x%x] ", (u_int32_t)ntohl(dataHdrPtr->payloadtype));
fflush(stdout);
if (vflag) /* if verbose output is specified */
{ /* at the command line */
char *payloadPtr;
printf("[Payload");
if (!xflag && !qflag) {
payloadPtr = (char *) (++dataHdrPtr);
printf(":");
default_print(payloadPtr,
htons(chunkDescPtr->chunkLength)-1 -
sizeof(struct sctpDataPart)-sizeof(struct sctpChunkDesc));
} else
printf("]");
}
break;
}
case SCTP_INITIATION :
{
struct sctpInitiation *init;
printf("[INIT] ");
init=(struct sctpInitiation*)(chunkDescPtr+1);
printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag));
printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit));
printf("[OS: %u] ", ntohs(init->NumPreopenStreams));
printf("[MIS: %u] ", ntohs(init->MaxInboundStreams));
printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN));
#if(0) /* ALC you can add code for optional params here */
if( (init+1) < chunkEnd )
printf(" @@@@@ UNFINISHED @@@@@@%s\n",
"Optional params present, but not printed.");
#endif
break;
}
case SCTP_INITIATION_ACK :
{
struct sctpInitiation *init;
printf("[INIT ACK] ");
init=(struct sctpInitiation*)(chunkDescPtr+1);
printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag));
printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit));
printf("[OS: %u] ", ntohs(init->NumPreopenStreams));
printf("[MIS: %u] ", ntohs(init->MaxInboundStreams));
printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN));
#if(0) /* ALC you can add code for optional params here */
if( (init+1) < chunkEnd )
printf(" @@@@@ UNFINISHED @@@@@@%s\n",
"Optional params present, but not printed.");
#endif
break;
}
case SCTP_SELECTIVE_ACK:
{
struct sctpSelectiveAck *sack;
struct sctpSelectiveFrag *frag;
int fragNo, tsnNo;
u_long *dupTSN;
printf("[SACK] ");
sack=(struct sctpSelectiveAck*)(chunkDescPtr+1);
printf("[cum ack %u] ", (u_int32_t)ntohl(sack->highestConseqTSN));
printf("[a_rwnd %u] ", (u_int32_t)ntohl(sack->updatedRwnd));
printf("[#gap acks %u] ", ntohs(sack->numberOfdesc));
printf("[#dup tsns %u] ", ntohs(sack->numDupTsns));
/* print gaps */
for (frag = ( (struct sctpSelectiveFrag *)
((struct sctpSelectiveAck *) sack+1)),
fragNo=0;
(void *)frag < nextChunk && fragNo < ntohs(sack->numberOfdesc);
frag++, fragNo++)
printf("\n\t\t[gap ack block #%d: start = %u, end = %u] ",
fragNo+1,
(u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentStart)),
(u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentEnd)));
/* print duplicate TSNs */
for (dupTSN = (u_long*)frag, tsnNo=0;
(void *) dupTSN < nextChunk && tsnNo<ntohs(sack->numDupTsns);
dupTSN++, tsnNo++)
printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
(u_int32_t)ntohl(*dupTSN));
break;
}
case SCTP_HEARTBEAT_REQUEST :
{
struct sctpHBsender *hb;
hb=(struct sctpHBsender*)chunkDescPtr;
printf("[HB REQ] ");
break;
}
case SCTP_HEARTBEAT_ACK :
printf("[HB ACK] ");
break;
case SCTP_ABORT_ASSOCIATION :
printf("[ABORT] ");
break;
case SCTP_SHUTDOWN :
printf("[SHUTDOWN] ");
break;
case SCTP_SHUTDOWN_ACK :
printf("[SHUTDOWN ACK] ");
break;
case SCTP_OPERATION_ERR :
printf("[OP ERR] ");
break;
case SCTP_COOKIE_ECHO :
printf("[COOKIE ECHO] ");
break;
case SCTP_COOKIE_ACK :
printf("[COOKIE ACK] ");
break;
case SCTP_ECN_ECHO :
printf("[ECN ECHO] ");
break;
case SCTP_ECN_CWR :
printf("[ECN CWR] ");
break;
case SCTP_SHUTDOWN_COMPLETE :
printf("[SHUTDOWN COMPLETE] ");
break;
case SCTP_FORWARD_CUM_TSN :
printf("[FOR CUM TSN] ");
break;
case SCTP_RELIABLE_CNTL :
printf("[REL CTRL] ");
break;
case SCTP_RELIABLE_CNTL_ACK :
printf("[REL CTRL ACK] ");
break;
default :
printf("[Unknown chunk type: 0x%x]", chunkDescPtr->chunkID);
return;
}
}
}

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.56 2000/10/10 05:06:10 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.57 2001/07/05 18:54:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -60,6 +60,7 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
register u_int length = h->len;
register const struct ip *ip;
++infodelay;
ts_print(&h->ts);
if (caplen < SLIP_HDRLEN) {
@ -98,6 +99,9 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
default_print((u_char *)ip, caplen - SLIP_HDRLEN);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}
@ -108,6 +112,7 @@ sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
register u_int length = h->len;
register const struct ip *ip;
++infodelay;
ts_print(&h->ts);
if (caplen < SLIP_HDRLEN) {
@ -137,6 +142,9 @@ sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
default_print((u_char *)ip, caplen - SLIP_HDRLEN);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}
static void

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.3 2000/12/23 20:49:34 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.6 2001/07/05 18:54:18 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -47,9 +47,6 @@ struct rtentry;
#include "ether.h"
#include "sll.h"
const u_char *packetp;
const u_char *snapend;
static inline void
sll_print(register const struct sll_header *sllp, u_int length)
{
@ -113,6 +110,7 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_short ether_type;
u_short extracted_ethertype;
++infodelay;
ts_print(&h->ts);
if (caplen < SLL_HDR_LEN) {
@ -200,6 +198,13 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
*/
switch (ether_type) {
case LINUX_SLL_P_802_3:
/*
* Ethernet_802.3 IPX frame.
*/
ipx_print(p, length);
break;
case LINUX_SLL_P_802_2:
/*
* 802.2.
@ -235,4 +240,7 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
default_print(p, caplen);
out:
putchar('\n');
--infodelay;
if (infoprint)
info(0);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,29 @@
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
* John Robert LoVerso. 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.
*
* 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.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by John Robert LoVerso.
* 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.
*
* This implementation has been influenced by the CMU SNMP release,
* by Steve Waldbusser. However, this shares no code with that system.
@ -45,7 +58,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.44 2000/11/10 17:34:10 fenner Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.50 2001/09/17 22:16:53 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -428,16 +441,11 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
elem->form = form;
elem->class = class;
elem->id = id;
if (vflag > 1)
printf("|%.2x", *p);
p++; len--; hdr = 1;
/* extended tag field */
if (id == ASN_ID_EXT) {
for (id = 0; *p & ASN_BIT8 && len > 0; len--, hdr++, p++) {
if (vflag > 1)
printf("|%.2x", *p);
for (id = 0; *p & ASN_BIT8 && len > 0; len--, hdr++, p++)
id = (id << 7) | (*p & ~ASN_BIT8);
}
if (len == 0 && *p & ASN_BIT8) {
ifNotTruncated fputs("[Xtagfield?]", stdout);
return -1;
@ -452,8 +460,6 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
return -1;
}
elem->asnlen = *p;
if (vflag > 1)
printf("|%.2x", *p);
p++; len--; hdr++;
if (elem->asnlen & ASN_BIT8) {
int noct = elem->asnlen % ASN_BIT8;
@ -462,11 +468,8 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
ifNotTruncated printf("[asnlen? %d<%d]", len, noct);
return -1;
}
for (; noct-- > 0; len--, hdr++) {
if (vflag > 1)
printf("|%.2x", *p);
for (; noct-- > 0; len--, hdr++)
elem->asnlen = (elem->asnlen << ASN_SHIFT8) | *p++;
}
}
if (len < elem->asnlen) {
if (!truncated) {
@ -720,7 +723,7 @@ asn1_print(struct be *elem)
d = elem->data.uns64.high * 4294967296.0; /* 2^32 */
if (elem->data.uns64.high <= 0x1fffff) {
d += elem->data.uns64.low;
#if 0 /*is looks illegal, but what is the intention???*/
#if 0 /*is looks illegal, but what is the intention?*/
printf("%.f", d);
#else
printf("%f", d);
@ -728,7 +731,7 @@ asn1_print(struct be *elem)
break;
}
d += (elem->data.uns64.low & 0xfffff000);
#if 0 /*is looks illegal, but what is the intention???*/
#if 0 /*is looks illegal, but what is the intention?*/
snprintf(first, sizeof(first), "%.f", d);
#else
snprintf(first, sizeof(first), "%f", d);
@ -837,25 +840,6 @@ asn1_decode(u_char *p, u_int length)
#ifdef LIBSMI
#if (SMI_VERSION_MAJOR == 0 && SMI_VERSION_MINOR >= 2) || (SMI_VERSION_MAJOR > 0)
#define LIBSMI_API_V2
#else
#define LIBSMI_API_V1
#endif
#ifdef LIBSMI_API_V1
/* Some of the API revisions introduced new calls that can be
* represented by macros.
*/
#define smiGetNodeType(n) smiGetType((n)->typemodule, (n)->typename)
#else
/* These calls in the V1 API were removed in V2. */
#define smiFreeRange(r)
#define smiFreeType(r)
#define smiFreeNode(r)
#endif
struct smi2be {
SmiBasetype basetype;
int be;
@ -878,7 +862,7 @@ static struct smi2be smi2betab[] = {
};
static void smi_decode_oid(struct be *elem, unsigned int *oid,
unsigned int *oidlen)
unsigned int oidsize, unsigned int *oidlen)
{
u_char *p = (u_char *)elem->data.raw;
u_int32_t asnlen = elem->asnlen;
@ -894,10 +878,14 @@ static void smi_decode_oid(struct be *elem, unsigned int *oid,
*/
if (first < 0) {
first = 0;
oid[(*oidlen)++] = o/OIDMUX;
if (*oidlen < oidsize) {
oid[(*oidlen)++] = o/OIDMUX;
}
o %= OIDMUX;
}
oid[(*oidlen)++] = o;
if (*oidlen < oidsize) {
oid[(*oidlen)++] = o;
}
o = 0;
}
}
@ -966,37 +954,22 @@ static int smi_check_range(SmiType *smiType, struct be *elem)
SmiRange *smiRange;
int ok = 1;
#ifdef LIBSMI_API_V1
for (smiRange = smiGetFirstRange(smiType->module, smiType->name);
#else
for (smiRange = smiGetFirstRange(smiType);
#endif
smiRange;
smiRange = smiGetNextRange(smiRange)) {
ok = smi_check_a_range(smiType, smiRange, elem);
if (ok) {
smiFreeRange(smiRange);
break;
}
}
if (ok
#ifdef LIBSMI_API_V1
&& smiType->parentmodule && smiType->parentname
#endif
) {
if (ok) {
SmiType *parentType;
#ifdef LIBSMI_API_V1
parentType = smiGetType(smiType->parentmodule,
smiType->parentname);
#else
parentType = smiGetParentType(smiType);
#endif
if (parentType) {
ok = smi_check_range(parentType, elem);
smiFreeType(parentType);
}
}
@ -1009,18 +982,14 @@ static SmiNode *smi_print_variable(struct be *elem)
SmiNode *smiNode = NULL;
int i;
smi_decode_oid(elem, oid, &oidlen);
smi_decode_oid(elem, oid, sizeof(oid)/sizeof(unsigned int), &oidlen);
smiNode = smiGetNodeByOID(oidlen, oid);
if (! smiNode) {
asn1_print(elem);
return NULL;
}
if (vflag) {
#ifdef LIBSMI_API_V1
fputs(smiNode->module, stdout);
#else
fputs(smiGetNodeModule(smiNode)->name, stdout);
#endif
fputs("::", stdout);
}
fputs(smiNode->name, stdout);
@ -1069,26 +1038,18 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
fputs("[noAccess]", stdout);
}
#ifdef LIBSMI_API_V1
smiType = smiGetType(smiNode->typemodule, smiNode->typename);
#else
smiType = smiGetNodeType(smiNode);
#endif
if (! smiType) {
asn1_print(elem);
return;
}
#ifdef LIBSMI_API_V1
if (! smi_check_type(smiNode->basetype, elem->type)) {
#else
if (! smi_check_type(smiType->basetype, elem->type)) {
#endif
fputs("[wrongType]", stdout);
}
if (! smi_check_range(smiType, elem)) {
fputs("[wrongLength]", stdout);
fputs("[outOfRange]", stdout);
}
/* resolve bits to named bits */
@ -1104,15 +1065,13 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
if (smiType->basetype == SMI_BASETYPE_BITS) {
/* print bit labels */
} else {
smi_decode_oid(elem, oid, &oidlen);
smi_decode_oid(elem, oid,
sizeof(oid)/sizeof(unsigned int),
&oidlen);
smiNode = smiGetNodeByOID(oidlen, oid);
if (smiNode) {
if (vflag) {
#ifdef LIBSMI_API_V1
fputs(smiNode->module, stdout);
#else
fputs(smiGetNodeModule(smiNode)->name, stdout);
#endif
fputs("::", stdout);
}
fputs(smiNode->name, stdout);
@ -1128,15 +1087,8 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
break;
case BE_INT:
#ifdef LIBSMI_API_V1
if (smiNode->basetype == SMI_BASETYPE_ENUM
&& smiNode->typemodule && smiNode->typename) {
for (nn = smiGetFirstNamedNumber(smiNode->typemodule,
smiNode->typename);
#else
if (smiType->basetype == SMI_BASETYPE_ENUM) {
for (nn = smiGetFirstNamedNumber(smiType);
#endif
nn;
nn = smiGetNextNamedNumber(nn)) {
if (nn->value.value.integer32
@ -1154,10 +1106,6 @@ static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
if (! done) {
asn1_print(elem);
}
if (smiType) {
smiFreeType(smiType);
}
}
#endif
@ -1273,7 +1221,6 @@ varbind_print(u_char pduid, const u_char *np, u_int length)
if (elem.type != BE_NULL) {
#ifdef LIBSMI
smi_print_value(smiNode, pduid, &elem);
smiFreeNode(smiNode);
#else
asn1_print(&elem);
#endif

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.81 2000/12/23 20:55:22 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.95 2001/12/10 08:21:24 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -52,49 +52,12 @@ static const char rcsid[] =
#include "ip6.h"
#endif
#include "nameser.h"
static void print_tcp_rst_data(register const u_char *sp, u_int length);
#define MAX_RST_DATA_LEN 30
/* Compatibility */
#ifndef TCPOPT_WSCALE
#define TCPOPT_WSCALE 3 /* window scale factor (rfc1072) */
#endif
#ifndef TCPOPT_SACKOK
#define TCPOPT_SACKOK 4 /* selective ack ok (rfc1072) */
#endif
#ifndef TCPOPT_SACK
#define TCPOPT_SACK 5 /* selective ack (rfc1072) */
#endif
#ifndef TCPOPT_ECHO
#define TCPOPT_ECHO 6 /* echo (rfc1072) */
#endif
#ifndef TCPOPT_ECHOREPLY
#define TCPOPT_ECHOREPLY 7 /* echo (rfc1072) */
#endif
#ifndef TCPOPT_TIMESTAMP
#define TCPOPT_TIMESTAMP 8 /* timestamps (rfc1323) */
#endif
#ifndef TCPOPT_CC
#define TCPOPT_CC 11 /* T/TCP CC options (rfc1644) */
#endif
#ifndef TCPOPT_CCNEW
#define TCPOPT_CCNEW 12 /* T/TCP CC options (rfc1644) */
#endif
#ifndef TCPOPT_CCECHO
#define TCPOPT_CCECHO 13 /* T/TCP CC options (rfc1644) */
#endif
/*
* Definitions required for ECN
* for use if the OS running tcpdump does not have ECN
*/
#ifndef TH_ECNECHO
#define TH_ECNECHO 0x40 /* ECN Echo in tcp header */
#endif
#ifndef TH_CWR
#define TH_CWR 0x80 /* ECN Cwnd Reduced in tcp header*/
#endif
struct tha {
#ifndef INET6
@ -129,16 +92,19 @@ static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE];
#define BGP_PORT 179
#endif
#define NETBIOS_SSN_PORT 139
#define BXXP_PORT 10288
#ifndef PPTP_PORT
#define PPTP_PORT 1723
#endif
#define BEEP_PORT 10288
#ifndef NFS_PORT
#define NFS_PORT 2049
#endif
#define MSDP_PORT 639
static int tcp_cksum(register const struct ip *ip,
register const struct tcphdr *tp,
register int len)
{
int i, tlen;
union phu {
struct phdr {
u_int32_t src;
@ -149,34 +115,18 @@ static int tcp_cksum(register const struct ip *ip,
} ph;
u_int16_t pa[6];
} phu;
register const u_int16_t *sp;
u_int32_t sum;
tlen = ntohs(ip->ip_len) - ((const char *)tp-(const char*)ip);
const u_int16_t *sp;
/* pseudo-header.. */
phu.ph.len = htons(tlen);
phu.ph.len = htons(len); /* XXX */
phu.ph.mbz = 0;
phu.ph.proto = IPPROTO_TCP;
memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
sp = &phu.pa[0];
sum = sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5];
sp = (const u_int16_t *)tp;
for (i=0; i<(tlen&~1); i+= 2)
sum += *sp++;
if (tlen & 1) {
sum += htons( (*(const u_int8_t *)sp) << 8);
}
while (sum > 0xffff)
sum = (sum & 0xffff) + (sum >> 16);
sum = ~sum & 0xffff;
return (sum);
return in_cksum((u_short *)tp, len,
sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]);
}
#ifdef INET6
@ -262,7 +212,6 @@ tcp_print(register const u_char *bp, register u_int length,
sport = ntohs(tp->th_sport);
dport = ntohs(tp->th_dport);
hlen = TH_OFF(tp) * 4;
/*
@ -273,13 +222,13 @@ tcp_print(register const u_char *bp, register u_int length,
if (!qflag) {
if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend &&
dport == NFS_PORT) {
nfsreq_print((u_char *)tp + hlen + 4, length-hlen,
nfsreq_print((u_char *)tp + hlen + 4, length - hlen,
(u_char *)ip);
return;
} else if ((u_char *)tp + 4 + sizeof(struct rpc_msg)
<= snapend &&
sport == NFS_PORT) {
nfsreply_print((u_char *)tp + hlen + 4,length-hlen,
nfsreply_print((u_char *)tp + hlen + 4, length - hlen,
(u_char *)ip);
return;
}
@ -353,18 +302,18 @@ tcp_print(register const u_char *bp, register u_int length,
memset(&tha, 0, sizeof(tha));
rev = 0;
if (ip6) {
if (sport > dport) {
if (sport > dport)
rev = 1;
} else if (sport == dport) {
int i;
else if (sport == dport) {
int i;
for (i = 0; i < 4; i++) {
if (((u_int32_t *)(&ip6->ip6_src))[i] >
((u_int32_t *)(&ip6->ip6_dst))[i]) {
rev = 1;
break;
for (i = 0; i < 4; i++) {
if (((u_int32_t *)(&ip6->ip6_src))[i] >
((u_int32_t *)(&ip6->ip6_dst))[i]) {
rev = 1;
break;
}
}
}
}
if (rev) {
tha.src = ip6->ip6_dst;
@ -425,7 +374,6 @@ tcp_print(register const u_char *bp, register u_int length,
th->ack = seq, th->seq = ack - 1;
else
th->seq = seq, th->ack = ack - 1;
} else {
if (rev)
seq -= th->ack, ack -= th->seq;
@ -469,7 +417,7 @@ tcp_print(register const u_char *bp, register u_int length,
length -= hlen;
if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST))
(void)printf(" %u:%u(%d)", seq, seq + length, length);
(void)printf(" %u:%u(%u)", seq, seq + length, length);
if (flags & TH_ACK)
(void)printf(" ack %u", ack);
@ -649,10 +597,24 @@ tcp_print(register const u_char *bp, register u_int length,
telnet_print(bp, length);
} else if (sport == BGP_PORT || dport == BGP_PORT)
bgp_print(bp, length);
else if (sport == PPTP_PORT || dport == PPTP_PORT)
pptp_print(bp, length);
#ifdef TCPDUMP_DO_SMB
else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
nbt_tcp_print(bp, length);
else if (sport == BXXP_PORT || dport == BXXP_PORT)
bxxp_print(bp, length);
#endif
else if (sport == BEEP_PORT || dport == BEEP_PORT)
beep_print(bp, length);
else if (length > 2 &&
(sport == NAMESERVER_PORT || dport == NAMESERVER_PORT)) {
/*
* TCP DNS query has 2byte length at the head.
* XXX packet could be unaligned, it can go strange
*/
ns_print(bp + 2, length - 2);
} else if (sport == MSDP_PORT || dport == MSDP_PORT) {
msdp_print(bp, length);
}
}
return;
bad:
@ -697,10 +659,7 @@ print_tcp_rst_data(register const u_char *sp, u_int length)
putchar(' ');
while (length-- && sp <= snapend) {
c = *sp++;
if (isprint(c))
putchar(c);
else
putchar('.');
safeputchar(c);
}
putchar(']');
}

View File

@ -51,7 +51,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.12 2000/09/29 04:58:51 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.18 2001/09/10 06:40:08 fenner Exp $";
#endif
#include <sys/param.h>
@ -61,10 +61,6 @@ static const char rcsid[] =
#include <netinet/in.h>
#define TELCMDS
#define TELOPTS
#include <arpa/telnet.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -73,110 +69,199 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
#ifndef TELCMD_FIRST
# define TELCMD_FIRST SE
#endif
#define TELCMDS
#define TELOPTS
#include "telnet.h"
void
telnet_print(register const u_char *sp, u_int length)
/* normal */
static const char *cmds[] = {
"IS", "SEND", "INFO",
};
/* 37: Authentication */
static const char *authcmd[] = {
"IS", "SEND", "REPLY", "NAME",
};
static const char *authtype[] = {
"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK",
"SRP", "RSA", "SSL", NULL, NULL,
"LOKI", "SSA", "KEA_SJ", "KEA_SJ_INTEG", "DSS",
"NTLM",
};
/* 38: Encryption */
static const char *enccmd[] = {
"IS", "SUPPORT", "REPLY", "START", "END",
"REQUEST-START", "REQUEST-END", "END_KEYID", "DEC_KEYID",
};
static const char *enctype[] = {
"NULL", "DES_CFB64", "DES_OFB64", "DES3_CFB64", "DES3_OFB64",
NULL, "CAST5_40_CFB64", "CAST5_40_OFB64", "CAST128_CFB64", "CAST128_OFB64",
};
#define STR_OR_ID(x, tab) \
(((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x))
static char *
numstr(int x)
{
static char tnet[128];
register int i, c, x;
register u_char *rcp;
int off, first = 1;
u_char *osp;
static char buf[20];
off = 0;
x = 0;
while (length > 0 && *sp == IAC) {
osp = (u_char *) sp;
tnet[0] = '\0';
c = *sp++;
length--;
switch (*sp) {
case IAC: /* <IAC><IAC>! */
if (length > 1 && sp[1] == IAC) {
(void)strcpy(tnet, "IAC IAC");
} else {
length = 0;
continue;
}
snprintf(buf, sizeof(buf), "%#x", x);
return buf;
}
/* sp points to IAC byte */
static int
telnet_parse(const u_char *sp, u_int length, int print)
{
int i, c, x;
const u_char *osp, *p;
#define FETCH(c, sp, length) \
do { \
if (length < 1) \
goto pktend; \
TCHECK(*sp); \
c = *sp++; \
length--; \
} while (0)
osp = sp;
FETCH(c, sp, length);
if (c != IAC)
goto pktend;
FETCH(c, sp, length);
if (c == IAC) { /* <IAC><IAC>! */
if (print)
printf("IAC IAC");
goto done;
}
i = c - TELCMD_FIRST;
if (i < 0 || i > IAC - TELCMD_FIRST)
goto pktend;
switch (c) {
case DONT:
case DO:
case WONT:
case WILL:
case SB:
/* DONT/DO/WONT/WILL x */
FETCH(x, sp, length);
if (x >= 0 && x < NTELOPTS) {
if (print)
(void)printf("%s %s", telcmds[i], telopts[x]);
} else {
if (print)
(void)printf("%s %#x", telcmds[i], x);
}
if (c != SB)
break;
/* IAC SB .... IAC SE */
p = sp;
while (length > p + 1 - sp) {
if (p[0] == IAC && p[1] == SE)
break;
p++;
}
if (*p != IAC)
goto pktend;
switch (x) {
case TELOPT_AUTHENTICATION:
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
(void)printf(" %s", STR_OR_ID(c, authcmd));
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
(void)printf(" %s", STR_OR_ID(c, authtype));
break;
case TELOPT_ENCRYPT:
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
(void)printf(" %s", STR_OR_ID(c, enccmd));
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
(void)printf(" %s", STR_OR_ID(c, enctype));
break;
default:
c = *sp++;
length--;
if ((i = c - TELCMD_FIRST) < 0
|| i > IAC - TELCMD_FIRST) {
(void)printf("unknown: ff%02x\n", c);
return;
}
switch (c) {
case DONT:
case DO:
case WONT:
case WILL:
case SB:
x = *sp++; /* option */
length--;
if (x >= 0 && x < NTELOPTS) {
(void)snprintf(tnet, sizeof(tnet),
"%s %s", telcmds[i], telopts[x]);
} else {
(void)snprintf(tnet, sizeof(tnet),
"%s %#x", telcmds[i], x);
}
if (p <= sp)
break;
default:
(void)snprintf(tnet, sizeof(tnet), "%s",
telcmds[i]);
}
if (c == SB) {
c = *sp++;
length--;
(void)strcat(tnet, c ? " SEND" : " IS '");
rcp = (u_char *) sp;
i = strlen(tnet);
while (length > 0 && (x = *sp++) != IAC)
--length;
if (x == IAC) {
if (2 < vflag
&& i + 16 + sp - rcp < sizeof(tnet)) {
(void)strncpy(&tnet[i], rcp, sp - rcp);
i += (sp - rcp) - 1;
tnet[i] = '\0';
} else if (i + 8 < sizeof(tnet)) {
(void)strcat(&tnet[i], "...");
}
if (*sp++ == SE
&& i + 4 < sizeof(tnet))
(void)strcat(tnet, c ? " SE" : "' SE");
} else if (i + 16 < sizeof(tnet)) {
(void)strcat(tnet, " truncated!");
}
}
FETCH(c, sp, length);
if (print)
(void)printf(" %s", STR_OR_ID(c, cmds));
break;
}
while (p > sp) {
FETCH(x, sp, length);
if (print)
(void)printf(" %#x", x);
}
/* terminating IAC SE */
if (print)
(void)printf(" SE");
sp += 2;
length -= 2;
break;
default:
if (print)
(void)printf("%s", telcmds[i]);
goto done;
}
done:
return sp - osp;
trunc:
(void)printf("[|telnet]");
pktend:
return -1;
#undef FETCH
}
void
telnet_print(const u_char *sp, u_int length)
{
int first = 1;
const u_char *osp;
int l;
osp = sp;
while (length > 0 && *sp == IAC) {
l = telnet_parse(sp, length, 0);
if (l < 0)
break;
/*
* now print it
*/
if (Xflag && 2 < vflag) {
if (first)
printf("\nTelnet:\n");
i = sp - osp;
hex_print_with_offset(osp, i, off);
off += i;
if (i > 8)
printf("\nTelnet:");
hex_print_with_offset(sp, l, sp - osp);
if (l > 8)
printf("\n\t\t\t\t");
else
printf("%*s\t", (8 - i) * 3, "");
safeputs(tnet);
} else {
printf("%*s\t", (8 - l) * 3, "");
} else
printf("%s", (first) ? " [telnet " : ", ");
safeputs(tnet);
}
(void)telnet_parse(sp, length, 1);
first = 0;
sp += l;
length -= l;
}
if (!first) {
if (Xflag && 2 < vflag)

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.1 2000/10/06 05:35:37 guy Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.3 2001/05/17 18:33:23 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@ -30,20 +30,12 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/time.h>
#include <netinet/in.h>
#include "ip.h"
#include "udp.h"
#include "tcp.h"
#include "timed.h"
#include <stdio.h>
#include <string.h>
#include "timed.h"
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
static char *tsptype[TSPTYPENUMBER] =
{ "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",

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