This commit was generated by cvs2svn to compensate for changes in r56893,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
Bill Fenner 2000-01-30 00:45:58 +00:00
commit 623fbbc49c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56894
102 changed files with 20094 additions and 462 deletions

View file

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

View file

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

View file

@ -17,7 +17,7 @@
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#) $Header: Makefile.in,v 1.207 97/08/17 13:53:29 leres Exp $ (LBL)
# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.219 1999/12/22 15:44:09 itojun Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@ -43,7 +43,7 @@ CC = @CC@
PROG = tcpdump
CCOPT = @V_CCOPT@
INCLS = -I. @V_INCLS@
DEFS = @DEFS@ -DHAVE_FDDI
DEFS = @DEFS@
# Standard CFLAGS
CFLAGS = $(CCOPT) $(DEFS) $(INCLS)
@ -72,9 +72,14 @@ CSRC = tcpdump.c \
print-pim.c print-ppp.c print-raw.c print-rip.c print-sl.c \
print-snmp.c print-sunrpc.c print-tcp.c print-tftp.c print-udp.c \
print-wb.c addrtoname.c bpf_dump.c gmt2local.c machdep.c \
parsenfsfh.c util.c savestr.c setsignal.c
LOCALSRC =
parsenfsfh.c util.c savestr.c setsignal.c \
print-esp.c print-ah.c print-vjc.c print-isakmp.c print-chdlc.c \
print-ipcomp.c print-mobile.c print-l2tp.c print-bgp.c print-rx.c \
print-lane.c print-cip.c print-pppoe.c print-lcp.c \
print-smb.c smbutil.c print-ascii.c print-telnet.c
LOCALSRC = @LOCALSRC@
GENSRC = version.c
LIBOBJS = @LIBOBJS@
SRC = $(CSRC) $(GENSRC) $(LOCALSRC)
@ -82,9 +87,11 @@ SRC = $(CSRC) $(GENSRC) $(LOCALSRC)
# hack the extra indirection
OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LOCALSRC:.c=.o) @LIBOBJS@
HDR = addrtoname.h appletalk.h bootp.h decnet.h \
ethertype.h extract.h fddi.h gmt2local.h interface.h igrp.h \
ethertype.h extract.h fddi.h gmt2local.h igrp.h interface.h \
ipx.h llc.h machdep.h mib.h nfsfh.h nfsv2.h ntp.h ospf.h \
savestr.c setsignal.h
savestr.c setsignal.h \
gnuc.h ipsec_doi.h isakmp.h l2tp.h netbios.h oakley.h ospf6.h ppp.h \
route6d.h
TAGHDR = \
/usr/include/arpa/tftp.h \
@ -107,16 +114,31 @@ $(PROG): $(OBJ) @V_PCAPDEP@
@rm -f $@
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
getnameinfo.o: $(srcdir)/missing/getnameinfo.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getaddrinfo.c
inet_pton.o: $(srcdir)/missing/inet_pton.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c
inet_ntop.o: $(srcdir)/missing/inet_ntop.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c
inet_aton.o: $(srcdir)/missing/inet_aton.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
version.o: version.c
$(CC) $(CFLAGS) -c version.c
version.c: $(srcdir)/VERSION
@rm -f $@
sed -e 's/.*/char version[] = "&";/' $(srcdir)/VERSION > $@
install: force
[ -d $(DESTDIR)$(BINDEST) ] || mkdir -p $(DESTDIR)$(BINDEST)
$(INSTALL) -m 550 -o bin -g @V_GROUP@ $(PROG) \
$(DESTDIR)$(BINDEST)/$(PROG)
install-man: force
[ -d $(DESTDIR)$(MANDEST)/man1 ] || mkdir -p $(DESTDIR)$(MANDEST)/man1
$(INSTALL) -m 444 -o bin -g bin $(srcdir)/$(PROG).1 \
$(DESTDIR)$(MANDEST)/man1/$(PROG).1
@ -130,7 +152,7 @@ clean:
distclean:
rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
gnuc.h os-proto.h
config.h gnuc.h os-proto.h
tags: $(TAGFILES)
ctags -wtd $(TAGFILES)

View file

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

View file

@ -1 +1 @@
3.4
3.5

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

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

View file

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: addrtoname.h,v 1.15 97/01/01 21:01:16 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.16 1999/10/30 05:11:07 itojun Exp $ (LBL)
*/
/* Name to address translation routines. */
@ -28,9 +28,18 @@ extern char *etherproto_string(u_short);
extern char *tcpport_string(u_short);
extern char *udpport_string(u_short);
extern char *getname(const u_char *);
#ifdef INET6
extern char *getname6(const u_char *);
#endif
extern char *intoa(u_int32_t);
extern void init_addrtoname(u_int32_t, u_int32_t);
extern struct hnamemem *newhnamemem(void);
#ifdef INET6
extern struct h6namemem *newh6namemem(void);
#endif
#define ipaddr_string(p) getname((const u_char *)(p))
#ifdef INET6
#define ip6addr_string(p) getname6((const u_char *)(p))
#endif

View file

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

View file

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

View file

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

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

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

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
dnl @(#) $Header: configure.in,v 1.71 97/07/27 22:17:59 leres Exp $ (LBL)
dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.87.2.4 2000/01/25 18:39:02 itojun Exp $ (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@ -17,6 +17,7 @@ if test -z "$PWD" ; then
fi
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_C_INLINE
AC_CHECK_HEADERS(fcntl.h malloc.h memory.h rpc/rpcent.h)
AC_HEADER_TIME
@ -40,14 +41,404 @@ linux*)
;;
esac
AC_CHECK_HEADERS(smi.h)
AC_CHECK_LIB(smi, main)
AC_MSG_CHECKING([whether to enable libsmi])
AC_TRY_RUN([ /* libsmi available check */
#include <smi.h>
main()
{
if (smiInit(""))
exit(1);
else
exit(0);
}
],
[ AC_MSG_RESULT(yes)
AC_DEFINE(LIBSMI)
libsmi=yes],
[ AC_MSG_RESULT(no)
libsmi=no]
)
CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len"
AC_MSG_CHECKING([whether to enable ipv6])
AC_ARG_ENABLE(ipv6,
[ --enable-ipv6 enable ipv6 (with ipv4) support
--disable-ipv6 disable ipv6 support],
[ case "$enableval" in
yes) AC_MSG_RESULT(yes)
AC_DEFINE(ENABLE_IPV6)
LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
AC_DEFINE(INET6)
ipv6=yes
;;
*)
AC_MSG_RESULT(no)
ipv6=no
;;
esac ],
AC_TRY_RUN([ /* AF_INET6 available check */
#include <sys/types.h>
#include <sys/socket.h>
main()
{
if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
exit(1);
else
exit(0);
}
],
[ AC_MSG_RESULT(yes)
AC_DEFINE(ENABLE_IPV6)
LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
AC_DEFINE(INET6)
ipv6=yes],
[ AC_MSG_RESULT(no)
ipv6=no],
[ AC_MSG_RESULT(no)
ipv6=no]
))
ipv6type=unknown
ipv6lib=none
ipv6trylibc=no
if test "$ipv6" = "yes"; then
AC_MSG_CHECKING([ipv6 stack type])
for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
case $i in
inria)
dnl http://www.kame.net/
AC_EGREP_CPP(yes, [dnl
#include <netinet/in.h>
#ifdef IPV6_INRIA_VERSION
yes
#endif],
[ipv6type=$i;
CFLAGS="-DINET6 $CFLAGS"])
;;
kame)
dnl http://www.kame.net/
AC_EGREP_CPP(yes, [dnl
#include <netinet/in.h>
#ifdef __KAME__
yes
#endif],
[ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
ipv6trylibc=yes;
CFLAGS="-DINET6 $CFLAGS"])
;;
linux-glibc)
dnl http://www.v6.linux.or.jp/
AC_EGREP_CPP(yes, [dnl
#include <features.h>
#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
yes
#endif],
[ipv6type=$i;
CFLAGS="-DINET6 $CFLAGS"])
;;
linux-libinet6)
dnl http://www.v6.linux.or.jp/
if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
ipv6type=$i
ipv6lib=inet6
ipv6libdir=/usr/inet6/lib
ipv6trylibc=yes;
CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
fi
;;
toshiba)
AC_EGREP_CPP(yes, [dnl
#include <sys/param.h>
#ifdef _TOSHIBA_INET6
yes
#endif],
[ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
CFLAGS="-DINET6 $CFLAGS"])
;;
v6d)
AC_EGREP_CPP(yes, [dnl
#include </usr/local/v6/include/sys/v6config.h>
#ifdef __V6D__
yes
#endif],
[ipv6type=$i;
ipv6lib=v6;
ipv6libdir=/usr/local/v6/lib;
CFLAGS="-I/usr/local/v6/include $CFLAGS"])
;;
zeta)
AC_EGREP_CPP(yes, [dnl
#include <sys/param.h>
#ifdef _ZETA_MINAMI_INET6
yes
#endif],
[ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
CFLAGS="-DINET6 $CFLAGS"])
;;
esac
if test "$ipv6type" != "unknown"; then
break
fi
done
AC_MSG_RESULT($ipv6type)
fi
if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
echo "You have $ipv6lib library, using it"
else
if test "$ipv6trylibc" = "yes"; then
echo "You do not have $ipv6lib library, using libc"
else
echo 'Fatal: no $ipv6lib library found. cannot continue.'
echo "You need to fetch lib$ipv6lib.a from appropriate"
echo 'ipv6 kit and compile beforehand.'
exit 1
fi
fi
fi
if test "$ipv6" = "yes"; then
AC_CHECK_FUNCS(getaddrinfo, [dnl
AC_MSG_CHECKING(getaddrinfo bug)
AC_TRY_RUN([
#include <sys/types.h>
#include <netdb.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
main()
{
int passive, gaierr, inet4 = 0, inet6 = 0;
struct addrinfo hints, *ai, *aitop;
char straddr[INET6_ADDRSTRLEN], strport[16];
for (passive = 0; passive <= 1; passive++) {
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_flags = passive ? AI_PASSIVE : 0;
hints.ai_socktype = SOCK_STREAM;
if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
(void)gai_strerror(gaierr);
goto bad;
}
for (ai = aitop; ai; ai = ai->ai_next) {
if (ai->ai_addr == NULL ||
ai->ai_addrlen == 0 ||
getnameinfo(ai->ai_addr, ai->ai_addrlen,
straddr, sizeof(straddr), strport, sizeof(strport),
NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
goto bad;
}
switch (ai->ai_family) {
case AF_INET:
if (strcmp(strport, "54321") != 0) {
goto bad;
}
if (passive) {
if (strcmp(straddr, "0.0.0.0") != 0) {
goto bad;
}
} else {
if (strcmp(straddr, "127.0.0.1") != 0) {
goto bad;
}
}
inet4++;
break;
case AF_INET6:
if (strcmp(strport, "54321") != 0) {
goto bad;
}
if (passive) {
if (strcmp(straddr, "::") != 0) {
goto bad;
}
} else {
if (strcmp(straddr, "::1") != 0) {
goto bad;
}
}
inet6++;
break;
case AF_UNSPEC:
goto bad;
break;
#ifdef AF_UNIX
case AF_UNIX:
#else
#ifdef AF_LOCAL
case AF_LOCAL:
#endif
#endif
default:
/* another family support? */
break;
}
}
}
/* supported family should be 2, unsupported family should be 0 */
if (!(inet4 == 0 || inet4 == 2))
goto bad;
if (!(inet6 == 0 || inet6 == 2))
goto bad;
if (aitop)
freeaddrinfo(aitop);
exit(0);
bad:
if (aitop)
freeaddrinfo(aitop);
exit(1);
}
],
AC_MSG_RESULT(good)
buggygetaddrinfo=no,
AC_MSG_RESULT(buggy)
buggygetaddrinfo=yes,
AC_MSG_RESULT(buggy)
buggygetaddrinfo=yes)], [buggygetaddrinfo=yes])
if test "$buggygetaddrinfo" = "yes"; then
if test "$ipv6type" != "linux"; then
echo 'Fatal: You must get working getaddrinfo() function.'
echo ' or you can specify "--disable-ipv6"'.
exit 1
else
echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
echo ' Better upgreade your system library to newest version'
echo ' of GNU C library (aka glibc).'
fi
fi
AC_REPLACE_FUNCS(getaddrinfo getnameinfo)
fi
AC_REPLACE_FUNCS(inet_ntop inet_pton inet_aton)
dnl portability macros for getaddrinfo/getnameinfo
dnl
dnl Check for sa_len
AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
if test "$ac_cv_sockaddr_has_sa_len" = no; then
missing_includes=yes
fi
dnl
dnl check __P macro
AC_CHECK_PORTABLE_PROTO(ac_cv_portable_proto)
if test "$ac_cv_portable_proto" = no; then
missing_includes=yes
fi
dnl
dnl check sizeof basic types.
dnl They're very likely to be wrong for cross-compiling.
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
dnl
dnl Checks for u_intXX_t
dnl AC_CHECK_BITTYPES(ac_cv_bittypes)
dnl if test "$ac_cv_bittypes" = no; then
dnl missing_includes=yes
dnl fi
dnl
dnl Checks for addrinfo structure
AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
if test "$ac_cv_addrinfo" = no; then
missing_includes=yes
fi
dnl
dnl Checks for NI_MAXSERV
AC_NI_MAXSERV(ac_cv_maxserv)
if test "$ac_cv_maxserv" = no; then
missing_includes=yes
fi
dnl
dnl Checks for NI_NAMEREQD
AC_NI_NAMEREQD(ac_cv_namereqd)
if test "$ac_cv_namereqd" = no; then
missing_includes=yes
fi
dnl
dnl Checks for sockaddr_storage structure
AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
if test "$ac_cv_sa_storage" = no; then
missing_includes=yes
fi
dnl
dnl Checks for IN[6]ADDRSZ
AC_CHECK_ADDRSZ(ac_cv_addrsz)
if test "$ac_cv_addrsz" = no; then
missing_includes=yes
fi
dnl
dnl Checks for RES_USE_INET6
AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
if test "$ac_cv_res_inet6" = no; then
missing_includes=yes
fi
dnl
dnl Checks for AAAA
AC_CHECK_AAAA(ac_cv_aaaa)
if test "$ac_cv_aaaa" = no; then
AC_DEFINE(T_AAAA, 28)
fi
dnl
dnl Checks for res_state_ext structure
AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
if test "$ac_cv_res_state_ext" = no; then
missing_includes=yes
fi
dnl
dnl Checks if res_state structure has nsort member.
AC_STRUCT_RES_STATE(ac_cv_res_state)
dnl
dnl set additional include path if necessary
if test "$missing_includes" = "yes"; then
CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing"
V_INCLS="$V_INCLS -I\$(srcdir)/missing"
fi
AC_REPLACE_FUNCS(vfprintf strcasecmp)
AC_CHECK_FUNCS(ether_ntoa setlinebuf)
AC_CHECK_FUNCS(ether_ntohost setlinebuf gethostbyname2)
dnl The following generates a warning from autoconf...
AC_C_BIGENDIAN
AC_CHECK_LIB(dnet, main)
AC_CHECK_LIB(rpc, main)
AC_CHECK_LIB(z, uncompress)
AC_CHECK_HEADERS(zlib.h)
AC_LBL_TYPE_SIGNAL
@ -69,7 +460,7 @@ irix*)
;;
linux*)
V_INCLS="$V_INCLS -Ilinux-include"
V_INCLS="$V_INCLS -I\$(srcdir)/linux-include"
;;
osf*)
@ -87,6 +478,9 @@ if test -f /dev/bpf0 ; then
V_GROUP=bpf
fi
AC_LBL_CHECK_TYPE(u_int8_t, u_char)
AC_LBL_CHECK_TYPE(int16_t, short)
AC_LBL_CHECK_TYPE(u_int16_t, u_short)
AC_LBL_CHECK_TYPE(int32_t, int)
AC_LBL_CHECK_TYPE(u_int32_t, u_int)
@ -170,24 +564,96 @@ fi
AC_LBL_UNALIGNED_ACCESS
if test "${srcdir}" = "." ; then
srcdirprefix=""
else
srcdirprefix="./"
AC_VAR_H_ERRNO
AC_MSG_CHECKING(for SSLeay)
ac_cv_ssleay_path=no
incdir=no
for dir in /usr/local /usr/local/ssl /usr/pkg; do
if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then
ac_cv_ssleay_path=$dir
fi
if test -d $dir/include -a -f $dir/include/des.h; then
incdir="-I$dir/include"
else
if test -d $dir/include/ssleay -a -f $dir/include/ssleay/des.h; then
incdir="-I$dir/include/ssleay"
elif test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then
incdir="-I$dir/include -I$dir/include/openssl"
fi
fi
if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then
break;
else
ac_cv_ssleay_path=no
incdir=no
fi
done
AC_MSG_RESULT($ac_cv_ssleay_path)
if test "$ac_cv_ssleay_path" != no; then
V_INCLS="$V_INCLS $incdir"
LIBS="$LIBS -L$dir/lib"
if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then
LIBS="$LIBS -lRSAglue"
fi
if test -f $ac_cv_ssleay_path/lib/librsaref.a; then
LIBS="$LIBS -lrsaref"
fi
AC_CHECK_LIB(crypto, des_cbc_encrypt)
AC_DEFINE(CRYPTO)
bak_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_HEADERS(cast.h rc5.h)
if test "$ac_cv_header_cast_h" = "yes"; then
AC_MSG_CHECKING(for buggy CAST128)
AC_TRY_RUN(dnl
[
#include <cast.h>
main()
{
unsigned char key[] = {0x01,0x23,0x45,0x67,0x12};
unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
unsigned char out[sizeof(in)];
unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E};
CAST_KEY ks;
CAST_set_key(&ks, sizeof(key), key);
CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT);
if (memcmp(out, ok, sizeof(ok)) != 0)
return 0;
else
return 1;
}],
[buggy_cast128=yes],
[buggy_cast128=no],
[buggy_cast128="cross-compiling, assume yes"])
AC_MSG_RESULT($buggy_cast128)
if test "$buggy_cast128" != no; then
echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine."
echo "disabling CAST128 support."
AC_DEFINE(HAVE_BUGGY_CAST128)
fi
fi
CPPFLAGS=$bak_CPPFLAGS
fi
if test -r ${srcdirprefix}lbl/gnuc.h ; then
if test -r ${srcdir}/lbl/gnuc.h ; then
rm -f gnuc.h
ln -s ${srcdirprefix}lbl/gnuc.h gnuc.h
ln -s ${srcdir}/lbl/gnuc.h gnuc.h
fi
AC_SUBST(V_CCOPT)
AC_SUBST(V_GROUP)
AC_SUBST(V_INCLS)
AC_SUBST(V_PCAPDEP)
AC_SUBST(LOCALSRC)
AC_PROG_INSTALL
AC_CONFIG_HEADER(config.h)
AC_OUTPUT(Makefile)
if test -f .devel ; then

View file

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

191
contrib/tcpdump/dhcp6.h Normal file
View file

@ -0,0 +1,191 @@
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* draft-ietf-dhc-dhcpv6-14
*/
#ifndef __DHCP6_H_DEFINED
#define __DHCP6_H_DEFINED
/* Error Values */
#define DH6ERR_FAILURE 16
#define DH6ERR_AUTHFAIL 17
#define DH6ERR_POORLYFORMED 18
#define DH6ERR_UNAVAIL 19
#define DH6ERR_NOBINDING 20
#define DH6ERR_INVALIDSOURCE 21
#define DH6ERR_NOSERVER 23
#define DH6ERR_ICMPERROR 64
/* Message type */
#define DH6_SOLICIT 1
#define DH6_ADVERT 2
#define DH6_REQUEST 3
#define DH6_REPLY 4
#define DH6_RELEASE 5
#define DH6_RECONFIG 6
/* Predefined addresses */
#define DH6ADDR_ALLAGENT "ff02::1:2"
#define DH6ADDR_ALLSERVER "ff05::1:3"
#define DH6ADDR_ALLRELAY "ff05::1:4"
#define DH6PORT_DOWNSTREAM "546"
#define DH6PORT_UPSTREAM "547"
/* Protocol constants */
#define ADV_CLIENT_WAIT 2 /* sec */
#define DEFAULT_SOLICIT_HOPCOUNT 4
#define SERVER_MIN_ADV_DELAY 100 /* msec */
#define SERVER_MAX_ADV_DELAY 1000 /* msec */
#define REPLY_MSG_TIMEOUT 2 /* sec */
#define REQUEST_MSG_MIN_RETRANS 10 /* retransmissions */
#define RECONF_MSG_MIN_RETRANS 10 /* retransmissions */
#define RECONF_MSG_RETRANS_INTERVAL 12 /* sec */
#define RECONF_MMSG_MIN_RESP 2 /* sec */
#define RECONF_MMSG_MAX_RESP 10 /* sec */
#define RECONF_MULTICAST_REQUEST_WAIT 120 /* sec */
#define MIN_SOLICIT_DELAY 1 /* sec */
#define MAX_SOLICIT_DELAY 5 /* sec */
#define XID_TIMEOUT 600 /* sec */
/* DHCP6 base packet format */
struct dhcp6_solicit {
u_int8_t dh6sol_msgtype; /* DH6_SOLICIT */
u_int8_t dh6sol_flags;
#define DH6SOL_CLOSE 0x80
u_int8_t dh6sol_pad;
u_int8_t dh6sol_prefixsiz; /* prefix-size */
struct in6_addr dh6sol_cliaddr; /* client's lladdr */
struct in6_addr dh6sol_relayaddr; /* relay agent's lladdr */
};
/* NOTE: dhcpv6-12 and dhcpv6-13+n are not compatible at all */
struct dhcp6_advert {
u_int8_t dh6adv_msgtype; /* DH6_ADVERT */
u_int8_t dh6adv_flags;
#define DH6ADV_SERVPRESENT 0x80
u_int8_t dh6adv_pad;
u_int8_t dh6adv_pref;
struct in6_addr dh6adv_cliaddr; /* client's lladdr */
struct in6_addr dh6adv_relayaddr; /* relay agent's (non-ll) addr */
struct in6_addr dh6adv_serveraddr; /* server's addr */
/* extensions */
};
struct dhcp6_request {
u_int8_t dh6req_msgtype; /* DH6_REQUEST */
u_int8_t dh6req_flags;
#define DH6REQ_CLOSE 0x80
#define DH6REQ_SERVPRESENT 0x40
#define DH6REQ_REBOOT 0x20
u_int16_t dh6req_xid; /* transaction-ID */
struct in6_addr dh6req_cliaddr; /* client's lladdr */
struct in6_addr dh6req_relayaddr; /* relay agent's (non-ll) addr */
/* struct in6_addr dh6req_serveraddr; optional: server's addr */
/* extensions */
};
struct dhcp6_reply {
u_int8_t dh6rep_msgtype; /* DH6_REPLY */
u_int8_t dh6rep_flagandstat;
#define DH6REP_CLIPRESENT 0x80
#define DH6REP_STATMASK 0x7f
u_int16_t dh6rep_xid; /* transaction-ID */
/* struct in6_addr dh6rep_cliaddr; optional: client's lladdr */
/* extensions */
};
struct dhcp6_release {
u_int8_t dh6rel_msgtype; /* DH6_RELEASE */
u_int8_t dh6rel_flags;
#define DH6REL_DIRECT 0x80
u_int16_t dh6rel_xid; /* transaction-ID */
struct in6_addr dh6rel_cliaddr; /* client's lladdr */
struct in6_addr dh6rel_relayaddr; /* relay agent's (non-ll) addr */
struct in6_addr dh6rel_reladdr; /* server's addr to be released */
/* extensions */
};
struct dhcp6_reconfig {
u_int8_t dh6cfg_msgtype; /* DH6_RECONFIG */
u_int8_t dh6cfg_flags;
#define DH6REP_NOREPLY 0x80
u_int16_t dh6cfg_xid; /* transaction-ID */
struct in6_addr dh6cfg_servaddr; /* server's addr */
/* extensions */
};
union dhcp6 {
u_int8_t dh6_msgtype;
struct dhcp6_solicit dh6_sol;
struct dhcp6_advert dh6_adv;
struct dhcp6_request dh6_req;
struct dhcp6_reply dh6_rep;
struct dhcp6_release dh6_rel;
struct dhcp6_reconfig dh6_cfg;
};
/* DHCP6 extension */
struct dhcp6e_ipaddr {
u_int16_t dh6eip_type;
u_int16_t dh6eip_len;
u_int8_t dh6eip_status;
#define DH6EX_IP_SUCCESS 0 /* request granted, no errors */
#define DH6EX_IP_SECFAIL 18 /* Security parameters failed */
#define DH6EX_IP_AAAAFAIL 20 /* AAAA Record Parameter Problem */
#define DH6EX_IP_PTRFAIL 21 /* PTR Record Parameter Problem */
#define DH6EX_IP_PARAMFAIL 22 /* Unable to honor required params */
#define DH6EX_IP_DNSNAMEFAIL 23 /* DNS name string error */
#define DH6EX_IP_NODYNDNS 24 /* dynDNS Not Implemented */
#define DH6EX_IP_NOAUTHDNS 25 /* Authoritative DNS Server not found */
#define DH6EX_IP_DNSFORMFAIL 33 /* DNS format error */
#define DH6EX_IP_SERVFAIL 34 /* dynDNS unavailable at this time */
#define DH6EX_IP_NXDOMAIN 35 /* name does not exist */
#define DH6EX_IP_NOTIMP 36 /* DNS does not support the Opcode */
#define DH6EX_IP_REFUSED 37 /* DNS refuses specified operation */
#define DH6EX_IP_YXDOMAIN 38 /* name does not exist */
#define DH6EX_IP_YXRRSET 39 /* RRset does not exist */
#define DH6EX_IP_NXRRSET 40 /* RRset does not exist */
#define DH6EX_IP_NOTAUTH 41 /* non authoritative name server */
#define DH6EX_IP_NOTZONE 42 /* prerequisite out of zone */
u_int8_t dh6eip_flags;
#define DH6EX_IP_CLIANTADDR 0x80 /* C: cliant's addr */
#define DH6EX_IP_LIFETIME 0x40 /* L: preferred/valid lifetime */
#define DH6EX_IP_FORCEOPTS 0x20 /* Q: options are mandatory */
#define DH6EX_IP_AAAA 0x10 /* A: DNS dynamic update for AAAA */
#define DH6EX_IP_PTR 0x08 /* P: DNS dynamic update for PTR*/
u_int8_t dh6eip_pad;
u_int8_t dh6eip_prefixlen;
/* struct in6_addr: client's address (if C bit = 1) */
/* u_int: preferred lifetime (if L bit = 1) */
/* u_int: valid lifetime (if L bit = 1) */
/* string: DNS name */
};
#endif /*__DHCP6_H_DEFINED*/

View file

@ -0,0 +1,80 @@
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* draft-ietf-dhc-v6exts-11
*/
#ifndef __DHCP6OPT_H_DEFINED
#define __DHCP6OPT_H_DEFINED
#define OL6_N -1
#define OL6_16N -2
#define OL6_Z -3
#define OT6_NONE 0
#define OT6_V6 1
#define OT6_STR 2
#define OT6_NUM 3
struct dhcp6_opt {
u_int code;
int len;
char *name;
int type;
};
/* index to parameters */
#define DH6T_CLIENT_ADV_WAIT 1 /* milliseconds */
#define DH6T_DEFAULT_SOLICIT_HOPCOUNT 2 /* times */
#define DH6T_SERVER_MIN_ADV_DELAY 3 /* milliseconds */
#define DH6T_SERVER_MAX_ADV_DELAY 4 /* milliseconds */
#define DH6T_REQUEST_MSG_MIN_RETRANS 5 /* retransmissions */
#define DH6T_REPLY_MSG_TIMEOUT 6 /* milliseconds */
#define DH6T_REPLY_MSG_RETRANS_INTERVAL 7 /* milliseconds */
#define DH6T_RECONF_MSG_TIMEOUT 8 /* milliseconds */
#define DH6T_RECONF_MSG_MIN_RETRANS 9 /* retransmissions */
#define DH6T_RECONF_MSG_RETRANS_INTERVAL 10 /* milliseconds */
#define DH6T_RECONF_MMSG_MIN_RESP 11 /* milliseconds */
#define DH6T_RECONF_MMSG_MAX_RESP 12 /* milliseconds */
#define DH6T_MIN_SOLICIT_DELAY 13 /* milliseconds */
#define DH6T_MAX_SOLICIT_DELAY 14 /* milliseconds */
#define DH6T_XID_TIMEOUT 15 /* milliseconds */
#define DH6T_RECONF_MULTICAST_REQUEST_WAIT 16 /* milliseconds */
#if 0
extern struct dhcp6_opt *dh6o_pad;
extern struct dhcp6_opt *dh6o_end;
extern int dhcp6_param[];
extern void dhcp6opttab_init __P((void));
extern struct dhcp6_opt *dhcp6opttab_byname __P((char *));
extern struct dhcp6_opt *dhcp6opttab_bycode __P((u_int));
#endif
#endif /*__DHCP6OPT_H_DEFINED*/

View file

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

View file

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

View file

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

View file

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

View file

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

164
contrib/tcpdump/ipsec_doi.h Normal file
View file

@ -0,0 +1,164 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* YIPS @(#)$Id: ipsec_doi.h,v 1.1 1999/10/30 05:11:09 itojun Exp $ */
/* refer to RFC 2407 */
#if !defined(_IPSEC_DOI_H_)
#define _IPSEC_DOI_H_
#define IPSEC_DOI 1
/* 4.2 IPSEC Situation Definition */
#define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001
#define IPSECDOI_SIT_SECRECY 0x00000002
#define IPSECDOI_SIT_INTEGRITY 0x00000004
/* 4.4.1 IPSEC Security Protocol Identifiers */
/* 4.4.2 IPSEC ISAKMP Transform Values */
#define IPSECDOI_PROTO_ISAKMP 1
#define IPSECDOI_KEY_IKE 1
/* 4.4.1 IPSEC Security Protocol Identifiers */
#define IPSECDOI_PROTO_IPSEC_AH 2
/* 4.4.3 IPSEC AH Transform Values */
#define IPSECDOI_AH_MD5 2
#define IPSECDOI_AH_SHA 3
#define IPSECDOI_AH_DES 4
/* 4.4.1 IPSEC Security Protocol Identifiers */
#define IPSECDOI_PROTO_IPSEC_ESP 3
/* 4.4.4 IPSEC ESP Transform Identifiers */
#define IPSECDOI_ESP_DES_IV64 1
#define IPSECDOI_ESP_DES 2
#define IPSECDOI_ESP_3DES 3
#define IPSECDOI_ESP_RC5 4
#define IPSECDOI_ESP_IDEA 5
#define IPSECDOI_ESP_CAST 6
#define IPSECDOI_ESP_BLOWFISH 7
#define IPSECDOI_ESP_3IDEA 8
#define IPSECDOI_ESP_DES_IV32 9
#define IPSECDOI_ESP_RC4 10
#define IPSECDOI_ESP_NULL 11
/* 4.4.1 IPSEC Security Protocol Identifiers */
#define IPSECDOI_PROTO_IPCOMP 4
/* 4.4.5 IPSEC IPCOMP Transform Identifiers */
#define IPSECDOI_IPCOMP_OUI 1
#define IPSECDOI_IPCOMP_DEFLATE 2
#define IPSECDOI_IPCOMP_LZS 3
#define IPSECDOI_IPCOMP_V42BIS 4
/* 4.5 IPSEC Security Association Attributes */
#define IPSECDOI_ATTR_SA_LTYPE 1 /* B */
#define IPSECDOI_ATTR_SA_LTYPE_DEFAULT 1
#define IPSECDOI_ATTR_SA_LTYPE_SEC 1
#define IPSECDOI_ATTR_SA_LTYPE_KB 2
#define IPSECDOI_ATTR_SA_LDUR 2 /* V */
#define IPSECDOI_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
#define IPSECDOI_ATTR_GRP_DESC 3 /* B */
#define IPSECDOI_ATTR_ENC_MODE 4 /* B */
/* default value: host dependent */
#define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1
#define IPSECDOI_ATTR_ENC_MODE_TRNS 2
#define IPSECDOI_ATTR_AUTH 5 /* B */
#define IPSECDOI_ATTR_AUTH_HMAC_MD5 1
#define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2
#define IPSECDOI_ATTR_AUTH_DES_MAC 3
#define IPSECDOI_ATTR_AUTH_KPDK 4
/*
When negotiating ESP without authentication, the Auth
Algorithm attribute MUST NOT be included in the proposal.
When negotiating ESP without confidentiality, the Auth
Algorithm attribute MUST be included in the proposal and
the ESP transform ID must be ESP_NULL.
*/
#define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */
#define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */
#define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */
#define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */
/* 4.6.1 Security Association Payload */
struct ipsecdoi_sa {
struct isakmp_gen h;
u_int32_t doi; /* Domain of Interpretation */
u_int32_t sit; /* Situation */
};
struct ipsecdoi_secrecy_h {
u_int16_t len;
u_int16_t reserved;
};
/* 4.6.2.1 Identification Type Values */
struct ipsecdoi_id {
struct isakmp_gen h;
u_int8_t type; /* ID Type */
u_int8_t proto_id; /* Protocol ID */
u_int16_t port; /* Port */
/* Identification Data */
};
#define IPSECDOI_ID_IPV4_ADDR 1
#define IPSECDOI_ID_FQDN 2
#define IPSECDOI_ID_USER_FQDN 3
#define IPSECDOI_ID_IPV4_ADDR_SUBNET 4
#define IPSECDOI_ID_IPV6_ADDR 5
#define IPSECDOI_ID_IPV6_ADDR_SUBNET 6
#define IPSECDOI_ID_IPV4_ADDR_RANGE 7
#define IPSECDOI_ID_IPV6_ADDR_RANGE 8
#define IPSECDOI_ID_DER_ASN1_DN 9
#define IPSECDOI_ID_DER_ASN1_GN 10
#define IPSECDOI_ID_KEY_ID 11
/* 4.6.3 IPSEC DOI Notify Message Types */
/* Notify Messages - Status Types */
#define IPSECDOI_NTYPE_RESPONDER_LIFETIME 24576
#define IPSECDOI_NTYPE_REPLAY_STATUS 24577
#define IPSECDOI_NTYPE_INITIAL_CONTACT 24578
#if 0
/* ipsec sa structure */
struct ipsec_sa {
u_int8_t proto_id; /* Protocol id */
vchar_t *spi; /* spi to receive, network byte order */
vchar_t *spi_p; /* spi to send, network byte order */
vchar_t *keymat; /* KEYMAT */
u_int8_t t_id; /* transform id */
u_int8_t enc_t; /* type of cipher */
u_int8_t mode_t; /* tunnel or transport */
u_int8_t hash_t; /* type of hash */
u_int8_t life_t; /* type of duration of lifetime */
u_int32_t ldur; /* life duration */
u_int8_t dhgrp; /* DH; group */
struct ipsec_sa *next;
};
#endif
#endif /* !defined(_IPSEC_DOI_H_) */

View file

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

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

@ -0,0 +1,447 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* YIPS @(#)$Id: isakmp.h,v 1.4.2.1 2000/01/14 19:19:56 mcr Exp $ */
/* refer to RFC 2408 */
/* must include <netinet/in.h> */
#if !defined(_ISAKMP_H_)
#define _ISAKMP_H_
typedef u_char cookie_t[8];
typedef u_char msgid_t[4];
typedef struct { /* i_cookie + r_cookie */
cookie_t i_ck;
cookie_t r_ck;
} isakmp_index;
#define INITIATOR 1
#define RESPONDER 2
#define PORT_ISAKMP 500
#define GENERATE 1
#define VALIDATE 0
/* Phase of oakley definition */
/*
0000 0000 0000 0000
| |||| ||||
| |||| ++++--> negosiation number in phase
| ++++-------> phase number
+---------------> expire ?
*/
#define ISAKMP_PH1 0x0010
#define ISAKMP_PH2 0x0020
#define ISAKMP_EXPIRED 0x0100
#define ISAKMP_NGP_0 0x0000
#define ISAKMP_NGP_1 0x0001
#define ISAKMP_NGP_2 0x0002
#define ISAKMP_NGP_3 0x0003
#define ISAKMP_NGP_4 0x0004
#define ISAKMP_PH1_N (ISAKMP_PH1 | ISAKMP_NGP_0) /* i.e. spawn */
#define ISAKMP_PH1_1 (ISAKMP_PH1 | ISAKMP_NGP_1)
#define ISAKMP_PH1_2 (ISAKMP_PH1 | ISAKMP_NGP_2)
#define ISAKMP_PH1_3 (ISAKMP_PH1 | ISAKMP_NGP_3)
#define ISAKMP_PH2_N (ISAKMP_PH2 | ISAKMP_NGP_0)
#define ISAKMP_PH2_1 (ISAKMP_PH2 | ISAKMP_NGP_1)
#define ISAKMP_PH2_2 (ISAKMP_PH2 | ISAKMP_NGP_2)
#define ISAKMP_PH2_3 (ISAKMP_PH2 | ISAKMP_NGP_3)
#define ISAKMP_TIMER_DEFAULT 10 /* seconds */
#define ISAKMP_TRY_DEFAULT 3 /* times */
/* 3.1 ISAKMP Header Format
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Initiator !
! Cookie !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Responder !
! Cookie !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Message ID !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct isakmp {
cookie_t i_ck; /* Initiator Cookie */
cookie_t r_ck; /* Responder Cookie */
u_int8_t np; /* Next Payload Type */
u_int8_t vers;
#define ISAKMP_VERS_MAJOR 0xf0
#define ISAKMP_VERS_MAJOR_SHIFT 4
#define ISAKMP_VERS_MINOR 0x0f
#define ISAKMP_VERS_MINOR_SHIFT 0
u_int8_t etype; /* Exchange Type */
u_int8_t flags; /* Flags */
msgid_t msgid;
u_int32_t len; /* Length */
};
/* Next Payload Type */
#define ISAKMP_NPTYPE_NONE 0 /* NONE*/
#define ISAKMP_NPTYPE_SA 1 /* Security Association */
#define ISAKMP_NPTYPE_P 2 /* Proposal */
#define ISAKMP_NPTYPE_T 3 /* Transform */
#define ISAKMP_NPTYPE_KE 4 /* Key Exchange */
#define ISAKMP_NPTYPE_ID 5 /* Identification */
#define ISAKMP_NPTYPE_CERT 6 /* Certificate */
#define ISAKMP_NPTYPE_CR 7 /* Certificate Request */
#define ISAKMP_NPTYPE_HASH 8 /* Hash */
#define ISAKMP_NPTYPE_SIG 9 /* Signature */
#define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
#define ISAKMP_NPTYPE_N 11 /* Notification */
#define ISAKMP_NPTYPE_D 12 /* Delete */
#define ISAKMP_NPTYPE_VID 13 /* Vendor ID */
#define ISAKMP_MAJOR_VERSION 1
#define ISAKMP_MINOR_VERSION 0
/* Exchange Type */
#define ISAKMP_ETYPE_NONE 0 /* NONE */
#define ISAKMP_ETYPE_BASE 1 /* Base */
#define ISAKMP_ETYPE_IDENT 2 /* Identity Proteciton */
#define ISAKMP_ETYPE_AUTH 3 /* Authentication Only */
#define ISAKMP_ETYPE_AGG 4 /* Aggressive */
#define ISAKMP_ETYPE_INF 5 /* Informational */
/* Flags */
#define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
#define ISAKMP_FLAG_C 0x02 /* Commit Bit */
/* 3.2 Payload Generic Header
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
! Next Payload ! RESERVED ! Payload Length !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct isakmp_gen {
u_int8_t np; /* Next Payload */
u_int8_t reserved; /* RESERVED, unused, must set to 0 */
u_int16_t len; /* Payload Length */
};
/* 3.3 Data Attributes
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
!A! Attribute Type ! AF=0 Attribute Length !
!F! ! AF=1 Attribute Value !
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
. AF=0 Attribute Value .
. AF=1 Not Transmitted .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct isakmp_data {
u_int16_t type; /* defined by DOI-spec, and Attribute Format */
u_int16_t lorv; /* if f equal 1, Attribute Length */
/* if f equal 0, Attribute Value */
/* if f equal 1, Attribute Value */
};
#define ISAKMP_GEN_TLV 0x0000
#define ISAKMP_GEN_TV 0x8000
/* mask for type of attribute format */
#define ISAKMP_GEN_MASK 0x8000
/* 3.4 Security Association Payload */
/* MAY NOT be used, because of being defined in ipsec-doi. */
/*
If the current payload is the last in the message,
then the value of the next payload field will be 0.
This field MUST NOT contain the
values for the Proposal or Transform payloads as they are considered
part of the security association negotiation. For example, this
field would contain the value "10" (Nonce payload) in the first
message of a Base Exchange (see Section 4.4) and the value "0" in the
first message of an Identity Protect Exchange (see Section 4.5).
*/
struct isakmp_pl_sa {
struct isakmp_gen h;
u_int32_t doi; /* Domain of Interpretation */
u_int32_t sit; /* Situation */
};
/* 3.5 Proposal Payload */
/*
The value of the next payload field MUST only contain the value "2"
or "0". If there are additional Proposal payloads in the message,
then this field will be 2. If the current Proposal payload is the
last within the security association proposal, then this field will
be 0.
*/
struct isakmp_pl_p {
struct isakmp_gen h;
u_int8_t p_no; /* Proposal # */
u_int8_t prot_id; /* Protocol */
u_int8_t spi_size; /* SPI Size */
u_int8_t num_t; /* Number of Transforms */
/* SPI */
};
/* 3.6 Transform Payload */
/*
The value of the next payload field MUST only contain the value "3"
or "0". If there are additional Transform payloads in the proposal,
then this field will be 3. If the current Transform payload is the
last within the proposal, then this field will be 0.
*/
struct isakmp_pl_t {
struct isakmp_gen h;
u_int8_t t_no; /* Transform # */
u_int8_t t_id; /* Transform-Id */
u_int16_t reserved; /* RESERVED2 */
/* SA Attributes */
};
/* 3.7 Key Exchange Payload */
struct isakmp_pl_ke {
struct isakmp_gen h;
/* Key Exchange Data */
};
/* 3.8 Identification Payload */
/* MUST NOT to be used, because of being defined in ipsec-doi. */
struct isakmp_pl_id {
struct isakmp_gen h;
union {
u_int8_t id_type; /* ID Type */
u_int32_t doi_data; /* DOI Specific ID Data */
} d;
/* Identification Data */
};
/* 3.9 Certificate Payload */
struct isakmp_pl_cert {
struct isakmp_gen h;
u_int8_t encode; /* Cert Encoding */
char cert; /* Certificate Data */
/*
This field indicates the type of
certificate or certificate-related information contained in the
Certificate Data field.
*/
};
/* Certificate Type */
#define ISAKMP_CERT_NONE 0
#define ISAKMP_CERT_PKCS 1
#define ISAKMP_CERT_PGP 2
#define ISAKMP_CERT_DNS 3
#define ISAKMP_CERT_SIGN 4
#define ISAKMP_CERT_KE 5
#define ISAKMP_CERT_KT 6
#define ISAKMP_CERT_CRL 7
#define ISAKMP_CERT_ARL 8
#define ISAKMP_CERT_SPKI 9
/* 3.10 Certificate Request Payload */
struct isakmp_pl_cr {
struct isakmp_gen h;
u_int8_t num_cert; /* # Cert. Types */
/*
Certificate Types (variable length)
-- Contains a list of the types of certificates requested,
sorted in order of preference. Each individual certificate
type is 1 octet. This field is NOT requiredo
*/
/* # Certificate Authorities (1 octet) */
/* Certificate Authorities (variable length) */
};
/* 3.11 Hash Payload */
/* may not be used, because of having only data. */
struct isakmp_pl_hash {
struct isakmp_gen h;
/* Hash Data */
};
/* 3.12 Signature Payload */
/* may not be used, because of having only data. */
struct isakmp_pl_sig {
struct isakmp_gen h;
/* Signature Data */
};
/* 3.13 Nonce Payload */
/* may not be used, because of having only data. */
struct isakmp_pl_nonce {
struct isakmp_gen h;
/* Nonce Data */
};
/* 3.14 Notification Payload */
struct isakmp_pl_n {
struct isakmp_gen h;
u_int32_t doi; /* Domain of Interpretation */
u_int8_t prot_id; /* Protocol-ID */
u_int8_t spi_size; /* SPI Size */
u_int16_t type; /* Notify Message Type */
/* SPI */
/* Notification Data */
};
/* 3.14.1 Notify Message Types */
/* NOTIFY MESSAGES - ERROR TYPES */
#define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1
#define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2
#define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3
#define ISAKMP_NTYPE_INVALID_COOKIE 4
#define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5
#define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6
#define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7
#define ISAKMP_NTYPE_INVALID_FLAGS 8
#define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9
#define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10
#define ISAKMP_NTYPE_INVALID_SPI 11
#define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12
#define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13
#define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14
#define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15
#define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16
#define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17
#define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18
#define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19
#define ISAKMP_NTYPE_INVALID_CERTIFICATE 20
#define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21
#define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22
#define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23
#define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24
#define ISAKMP_NTYPE_INVALID_SIGNATURE 25
#define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26
/* NOTIFY MESSAGES - STATUS TYPES */
#define ISAKMP_NTYPE_CONNECTED 16384
/* using only to log */
#define ISAKMP_LOG_RETRY_LIMIT_REACHED 65530
/* 3.15 Delete Payload */
struct isakmp_pl_d {
struct isakmp_gen h;
u_int32_t doi; /* Domain of Interpretation */
u_int8_t prot_id; /* Protocol-Id */
u_int8_t spi_size; /* SPI Size */
u_int16_t num_spi; /* # of SPIs */
/* SPI(es) */
};
struct isakmp_ph1tab {
struct isakmp_ph1 *head;
struct isakmp_ph1 *tail;
int len;
};
struct isakmp_ph2tab {
struct isakmp_ph2 *head;
struct isakmp_ph2 *tail;
int len;
};
#if 0
/* isakmp status structure */
struct isakmp_ph1 {
isakmp_index index;
u_int8_t dir; /* INITIATOR or RESPONDER */
u_int16_t status; /* status of this SA */
u_int16_t etype;
u_int32_t doi;
u_int32_t sit;
vchar_t *dhp; /* DH; prime, static value */
vchar_t *dhpriv; /* DH; private value */
vchar_t *dhpub; /* DH; public value */
vchar_t *dhpub_p; /* DH; partner's public value */
vchar_t *dhgxy; /* DH; shared secret */
vchar_t *nonce; /* nonce value */
vchar_t *nonce_p; /* partner's nonce value */
vchar_t *skeyid; /* SKEYID */
vchar_t *skeyid_d; /* SKEYID_d */
vchar_t *skeyid_a; /* SKEYID_a, i.e. hash */
vchar_t *skeyid_e; /* SKEYID_e, i.e. encryption */
vchar_t *key; /* cipher key */
vchar_t *hash; /* HASH minus general header */
vchar_t *iv; /* IV */
vchar_t *ive; /* new IV to encrypt next packet */
vchar_t *ivd; /* new IV to decrypt next packet */
vchar_t *sa; /* SA minus general header including p,t.*/
vchar_t *id; /* ID minus general header */
vchar_t *id_p; /* partner's ID minus general header */
struct sockaddr *local; /* pointer to the my sockaddr */
struct sockaddr *remote; /* partner's sockaddr */
struct oakley_sa *isa; /* Is it good that caddr_t ? */
struct sched *sc; /* back pointer to the record in schedule
used to resend. */
struct isakmp_ph1 *next;
struct isakmp_ph1 *prev;
struct isakmp_conf *cfp; /* pointer to isakmp configuration */
struct isakmp_ph2tab ph2tab; /* list on negotiating Phase 2 */
u_int32_t msgid2; /* XXX: msgid counter for Phase 2 */
};
struct isakmp_ph2 {
msgid_t msgid;
u_int8_t dir; /* INITIATOR or RESPONDER */
u_int16_t status; /* status of this SA */
vchar_t *dhp; /* DH; prime, static value */
vchar_t *dhpriv; /* DH; private value */
vchar_t *dhpub; /* DH; public value */
vchar_t *dhpub_p; /* DH; partner's public value */
vchar_t *dhgxy; /* DH; shared secret */
vchar_t *id; /* ID */
vchar_t *id_p; /* ID for peer */
vchar_t *nonce; /* nonce value in phase 2 */
vchar_t *nonce_p; /* partner's nonce value in phase 2 */
vchar_t *hash; /* HASH2 minus general header */
vchar_t *iv; /* IV for Phase 2 */
vchar_t *ive; /* new IV to encrypt next packet */
vchar_t *ivd; /* new IV to decrypt next packet */
struct isakmp_ph1 *ph1; /* back pointer to isakmp status */
struct sched *sc; /* back pointer to the schedule using resend */
struct pfkey_st *pst; /* pointer to the pfkey status record.
is only used by initiator. */
u_int8_t proxy; /* is proxy or not ?. */
vchar_t *sa; /* SA payload */
struct ipsec_sa *isa; /* values of SA to use, same SA in use. */
struct isakmp_ph2 *next;
struct isakmp_ph2 *prev;
};
#endif
#define EXCHANGE_PROXY 1
#define EXCHANGE_MYSELF 0
#define PFS_NEED 1
#define PFS_NONEED 0
#endif /* !defined(_ISAKMP_H_) */

82
contrib/tcpdump/l2tp.h Normal file
View file

@ -0,0 +1,82 @@
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* L2TP support contributed by Motonori Shindo (mshindo@ascend.co.jp)
*/
#define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */
#define L2TP_FLAG_LENGTH 0x4000 /* Length */
#define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */
#define L2TP_FLAG_OFFSET 0x0200 /* Offset */
#define L2TP_FLAG_PRIORITY 0x0100 /* Priority */
#define L2TP_VERSION_MASK 0x000f /* Version Mask */
#define L2TP_VERSION_L2F 0x0001 /* L2F */
#define L2TP_VERSION_L2TP 0x0002 /* L2TP */
#define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */
#define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */
#define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */
#define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */
#define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */
#define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */
#define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */
#define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */
#define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */
#define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */
#define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */
/* Authen Type */
#define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */
#define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */
#define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */
#define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */
#define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */
#define L2TP_AUTHEN_TYPE_MSCHAP 0x0005 /* MSCHAPv1 */
#define L2TP_PROXY_AUTH_ID_MASK 0x00ff
struct l2tp_avp_vec {
const char *name;
void (*print)(const u_char *, u_int);
};
struct l2tp_call_errors {
u_short reserved;
u_int crc_errs;
u_int framing_errs;
u_int hardware_overruns;
u_int buffer_overruns;
u_int timeout_errs;
u_int alignment_errs;
};
struct l2tp_accm {
u_short reserved;
u_int send_accm;
u_int recv_accm;
};

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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,122 @@
/*
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* $Id: addrinfo.h,v 1.2 1999/11/21 01:35:41 assar Exp $ */
#ifndef HAVE_ADDRINFO
/*
* Error return codes from getaddrinfo()
*/
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
#define EAI_AGAIN 2 /* temporary failure in name resolution */
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /* ai_family not supported */
#define EAI_MEMORY 6 /* memory allocation failure */
#define EAI_NODATA 7 /* no address associated with hostname */
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
#define EAI_SYSTEM 11 /* system error returned in errno */
#define EAI_BADHINTS 12
#define EAI_PROTOCOL 13
#define EAI_MAX 14
/* internal error */
#define NETDB_INTERNAL -1 /* see errno */
/*
* Flag values for getaddrinfo()
*/
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
/* valid flags for addrinfo */
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
/* special recommended flags for getipnodebyname */
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
size_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for hostname */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
extern void freeaddrinfo __P((struct addrinfo *));
extern void freehostent __P((struct hostent *));
extern char *gai_strerror __P((int));
extern int getaddrinfo __P((const char *, const char *,
const struct addrinfo *, struct addrinfo **));
extern int getnameinfo __P((const struct sockaddr *, size_t, char *,
size_t, char *, size_t, int));
extern struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *));
extern struct hostent *getipnodebyname __P((const char *, int, int, int *));
extern int inet_pton __P((int, const char *, void *));
extern const char *inet_ntop __P((int, const void *, char *, size_t));
#endif /* HAVE_ADDRINFO */
/*
* Constants for getnameinfo()
*/
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
#ifndef NI_MAXSERV
#define NI_MAXSERV 32
#endif
/*
* Flag values for getnameinfo()
*/
#ifndef NI_NOFQDN
#define NI_NOFQDN 0x00000001
#endif
#ifndef NI_NUMERICHOST
#define NI_NUMERICHOST 0x00000002
#endif
#ifndef NI_NAMEREQD
#define NI_NAMEREQD 0x00000004
#endif
#ifndef NI_NUMERICSERV
#define NI_NUMERICSERV 0x00000008
#endif
#ifndef NI_DGRAM
#define NI_DGRAM 0x00000010
#endif

View file

@ -0,0 +1,36 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef INADDRSZ
#define INADDRSZ 4 /* IPv4 T_A */
#endif
#ifndef IN6ADDRSZ
#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
#endif

View file

@ -0,0 +1,67 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef HAVE_U_INT8_T
#if SIZEOF_CHAR == 1
typedef unsigned char u_int8_t;
#elif SIZEOF_INT == 1
typedef unsigned int u_int8_t;
#else /* XXX */
#error "there's no appropriate type for u_int8_t"
#endif
#endif /* HAVE_U_INT8_T */
#ifndef HAVE_U_INT16_T
#if SIZEOF_SHORT == 2
typedef unsigned short u_int16_t;
#elif SIZEOF_INT == 2
typedef unsigned int u_int16_t;
#elif SIZEOF_CHAR == 2
typedef unsigned char u_int16_t;
#else /* XXX */
#error "there's no appropriate type for u_int16_t"
#endif
#endif /* HAVE_U_INT16_T */
#ifndef HAVE_U_INT32_T
#if SIZEOF_INT == 4
typedef unsigned int u_int32_t;
#elif SIZEOF_LONG == 4
typedef unsigned long u_int32_t;
#elif SIZEOF_SHORT == 4
typedef unsigned short u_int32_t;
#else /* XXX */
#error "there's no appropriate type for u_int32_t"
#endif
#endif /* HAVE_U_INT32_T */

View file

@ -0,0 +1,37 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef HAVE_PORTABLE_PROTOTYPE
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos /* full-blown ANSI C */
#else
#define __P(protos) () /* traditional C preprocessor */
#endif
#endif /* !HAVE_PORTABLE_PROTOTYPE */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,285 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Issues to be discussed:
* - Thread safe-ness must be checked
* - Return values. There seems to be no standard for return value (RFC2553)
* but INRIA implementation returns EAI_xxx defined for getaddrinfo().
* - RFC2553 says that we should raise error on short buffer. X/Open says
* we need to truncate the result. We obey RFC2553 (and X/Open should be
* modified).
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.3.2.2 2000/01/25 18:39:03 itojun Exp $";
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <netdb.h>
#include <resolv.h>
#include <string.h>
#include <stddef.h>
#include <errno.h>
#ifndef HAVE_PORTABLE_PROTOTYPE
#include "cdecl_ext.h"
#endif
#ifdef NEED_ADDRINFO_H
#include "addrinfo.h"
#endif
#define SUCCESS 0
#define ANY 0
#define YES 1
#define NO 0
static struct afd {
int a_af;
int a_addrlen;
int a_socklen;
int a_off;
} afdl [] = {
#ifdef INET6
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
offsetof(struct sockaddr_in6, sin6_addr)},
#endif
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
offsetof(struct sockaddr_in, sin_addr)},
{0, 0, 0},
};
struct sockinet {
u_char si_len;
u_char si_family;
u_short si_port;
};
#define ENI_NOSOCKET 0
#define ENI_NOSERVNAME 1
#define ENI_NOHOSTNAME 2
#define ENI_MEMORY 3
#define ENI_SYSTEM 4
#define ENI_FAMILY 5
#define ENI_SALEN 6
int
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
const struct sockaddr *sa;
size_t salen;
char *host;
size_t hostlen;
char *serv;
size_t servlen;
int flags;
{
struct afd *afd;
struct servent *sp;
struct hostent *hp;
u_short port;
int family, i;
char *addr, *p;
u_int32_t v4a;
int h_error;
char numserv[512];
char numaddr[512];
if (sa == NULL)
return ENI_NOSOCKET;
#ifdef HAVE_SA_LEN /*XXX*/
if (sa->sa_len != salen)
return ENI_SALEN;
#endif
family = sa->sa_family;
for (i = 0; afdl[i].a_af; i++)
if (afdl[i].a_af == family) {
afd = &afdl[i];
goto found;
}
return ENI_FAMILY;
found:
if (salen != afd->a_socklen)
return ENI_SALEN;
port = ((struct sockinet *)sa)->si_port; /* network byte order */
addr = (char *)sa + afd->a_off;
if (serv == NULL || servlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC2553 says that serv == NULL OR servlen == 0
* means that the caller does not want the result.
*/
} else {
if (flags & NI_NUMERICSERV)
sp = NULL;
else {
sp = getservbyport(port,
(flags & NI_DGRAM) ? "udp" : "tcp");
}
if (sp) {
if (strlen(sp->s_name) > servlen)
return ENI_MEMORY;
strcpy(serv, sp->s_name);
} else {
sprintf(numserv, "%d", ntohs(port));
if (strlen(numserv) > servlen)
return ENI_MEMORY;
strcpy(serv, numserv);
}
}
switch (sa->sa_family) {
case AF_INET:
v4a = (u_int32_t)
ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
flags |= NI_NUMERICHOST;
v4a >>= IN_CLASSA_NSHIFT;
if (v4a == 0)
flags |= NI_NUMERICHOST;
break;
#ifdef INET6
case AF_INET6:
{
struct sockaddr_in6 *sin6;
sin6 = (struct sockaddr_in6 *)sa;
switch (sin6->sin6_addr.s6_addr[0]) {
case 0x00:
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
;
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
;
else
flags |= NI_NUMERICHOST;
break;
default:
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
flags |= NI_NUMERICHOST;
}
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
break;
}
}
break;
#endif
}
if (host == NULL || hostlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC2553 says that host == NULL OR hostlen == 0
* means that the caller does not want the result.
*/
} else if (flags & NI_NUMERICHOST) {
/* NUMERICHOST and NAMEREQD conflicts with each other */
if (flags & NI_NAMEREQD)
return ENI_NOHOSTNAME;
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return ENI_SYSTEM;
if (strlen(numaddr) > hostlen)
return ENI_MEMORY;
strcpy(host, numaddr);
#if defined(INET6) && defined(NI_WITHSCOPEID)
if (afd->a_af == AF_INET6 &&
(IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) ||
IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) &&
((struct sockaddr_in6 *)sa)->sin6_scope_id) {
#ifndef ALWAYS_WITHSCOPE
if (flags & NI_WITHSCOPEID)
#endif /* !ALWAYS_WITHSCOPE */
{
char *ep = strchr(host, '\0');
unsigned int ifindex =
((struct sockaddr_in6 *)sa)->sin6_scope_id;
*ep = SCOPE_DELIMITER;
if ((if_indextoname(ifindex, ep + 1)) == NULL)
/* XXX what should we do? */
strncpy(ep + 1, "???", 3);
}
}
#endif /* INET6 */
} else {
#ifdef USE_GETIPNODEBY
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
#else
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
#ifdef HAVE_H_ERRNO
h_error = h_errno;
#else
h_error = EINVAL;
#endif
#endif
if (hp) {
if (flags & NI_NOFQDN) {
p = strchr(hp->h_name, '.');
if (p) *p = '\0';
}
if (strlen(hp->h_name) > hostlen) {
#ifdef USE_GETIPNODEBY
freehostent(hp);
#endif
return ENI_MEMORY;
}
strcpy(host, hp->h_name);
#ifdef USE_GETIPNODEBY
freehostent(hp);
#endif
} else {
if (flags & NI_NAMEREQD)
return ENI_NOHOSTNAME;
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return ENI_NOHOSTNAME;
if (strlen(numaddr) > hostlen)
return ENI_MEMORY;
strcpy(host, numaddr);
}
}
return SUCCESS;
}

View file

@ -0,0 +1,63 @@
/*
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* $Id: inet_aton.c,v 1.1.2.1 2000/01/11 06:58:29 fenner Exp $ */
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.1.2.1 2000/01/11 06:58:29 fenner Exp $";
#endif
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
/* Minimal implementation of inet_aton.
* Cannot distinguish between failure and a local broadcast address. */
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
int
inet_aton(const char *cp, struct in_addr *addr)
{
addr->s_addr = inet_addr(cp);
return (addr->s_addr == INADDR_NONE) ? 0 : 1;
}

View file

@ -0,0 +1,105 @@
/*
* Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* $Id: inet_ntop.c,v 1.2.2.1 2000/01/11 06:58:30 fenner Exp $ */
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.2.2.1 2000/01/11 06:58:30 fenner Exp $";
#endif
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
/*
*
*/
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
static const char *
inet_ntop_v4 (const void *src, char *dst, size_t size)
{
const char digits[] = "0123456789";
int i;
struct in_addr *addr = (struct in_addr *)src;
u_long a = ntohl(addr->s_addr);
const char *orig_dst = dst;
if (size < INET_ADDRSTRLEN) {
errno = ENOSPC;
return NULL;
}
for (i = 0; i < 4; ++i) {
int n = (a >> (24 - i * 8)) & 0xFF;
int non_zerop = 0;
if (non_zerop || n / 100 > 0) {
*dst++ = digits[n / 100];
n %= 100;
non_zerop = 1;
}
if (non_zerop || n / 10 > 0) {
*dst++ = digits[n / 10];
n %= 10;
non_zerop = 1;
}
*dst++ = digits[n];
if (i != 3)
*dst++ = '.';
}
*dst++ = '\0';
return orig_dst;
}
const char *
inet_ntop(int af, const void *src, char *dst, size_t size)
{
switch (af) {
case AF_INET :
return inet_ntop_v4 (src, dst, size);
default :
errno = EAFNOSUPPORT;
return NULL;
}
}

View file

@ -0,0 +1,59 @@
/*
* Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* $Id: inet_pton.c,v 1.1.2.1 2000/01/11 06:58:30 fenner Exp $ */
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.1.2.1 2000/01/11 06:58:30 fenner Exp $";
#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int
inet_pton(int af, const char *src, void *dst)
{
if (af != AF_INET) {
errno = EAFNOSUPPORT;
return -1;
}
return inet_aton (src, dst);
}

View file

@ -0,0 +1,36 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Resolver options for IPv6.
* XXX: this should be in an offical include file. There may be conflicts...
*/
#ifndef HAVE_RES_USE_INET6
#define RES_USE_INET6 0x80000000 /* use/map IPv6 in gethostbyname() */
#endif

View file

@ -0,0 +1,49 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef MAXRESOLVSORT /* XXX */
#define MAXRESOLVSORT 10 /* number of net to sort on */
#endif
#ifndef HAVE_RES_STATE_EXT
struct __res_state_ext {
struct sockaddr_storage nsaddr_list[MAXNS];
struct {
int af; /* address family for addr, mask */
union {
struct in_addr ina;
#ifdef INET6
struct in6_addr in6a;
#endif
} addr, mask;
} sort_list[MAXRESOLVSORT];
};
#endif
extern struct __res_state_ext _res_ext;

View file

@ -0,0 +1,38 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
struct sockaddr_storage {
#ifdef HAVE_SOCKADDR_SA_LEN
u_int8_t __ss_len;
u_int8_t __ss_family;
u_int8_t fill[126];
#else
u_int8_t __ss_family;
u_int8_t fill[127];
#endif /* HAVE_SOCKADDR_SA_LEN */
};

View file

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

View file

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

126
contrib/tcpdump/oakley.h Normal file
View file

@ -0,0 +1,126 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* YIPS @(#)$Id: oakley.h,v 1.1 1999/10/30 05:11:10 itojun Exp $ */
/* refer to RFC 2409 */
#if !defined(_ISAKMP_OAKLEY_H_)
#define _ISAKMP_OAKLEY_H_
/* Attribute Classes */
#define OAKLEY_ATTR_ENC_ALG 1 /* B */
#define OAKLEY_ATTR_ENC_ALG_DES 1
#define OAKLEY_ATTR_ENC_ALG_IDEA 2
#define OAKLEY_ATTR_ENC_ALG_BL 3
#define OAKLEY_ATTR_ENC_ALG_RC5 4
#define OAKLEY_ATTR_ENC_ALG_3DES 5
#define OAKLEY_ATTR_ENC_ALG_CAST 6
#define OAKLEY_ATTR_HASH_ALG 2 /* B */
#define OAKLEY_ATTR_HASH_ALG_MD5 1
#define OAKLEY_ATTR_HASH_ALG_SHA 2
#define OAKLEY_ATTR_HASH_ALG_TIGER 3
#define OAKLEY_ATTR_AUTH_METHOD 3 /* B */
#define OAKLEY_ATTR_AUTH_METHOD_PSKEY 1
#define OAKLEY_ATTR_AUTH_METHOD_DSS 2
#define OAKLEY_ATTR_AUTH_METHOD_RSA 3
#define OAKLEY_ATTR_AUTH_METHOD_RSAENC 4
#define OAKLEY_ATTR_AUTH_METHOD_RSAREV 5
#define OAKLEY_ATTR_GRP_DESC 4 /* B */
#define OAKLEY_ATTR_GRP_DESC_MODP768 1
#define OAKLEY_ATTR_GRP_DESC_MODP1024 2
#define OAKLEY_ATTR_GRP_DESC_EC2N155 3
#define OAKLEY_ATTR_GRP_DESC_EC2N185 4
#define OAKLEY_ATTR_GRP_TYPE 5 /* B */
#define OAKLEY_ATTR_GRP_TYPE_MODP 1
#define OAKLEY_ATTR_GRP_TYPE_ECP 2
#define OAKLEY_ATTR_GRP_TYPE_EC2N 3
#define OAKLEY_ATTR_GRP_PI 6 /* V */
#define OAKLEY_ATTR_GRP_GEN_ONE 7 /* V */
#define OAKLEY_ATTR_GRP_GEN_TWO 8 /* V */
#define OAKLEY_ATTR_GRP_CURVE_A 9 /* V */
#define OAKLEY_ATTR_GRP_CURVE_B 10 /* V */
#define OAKLEY_ATTR_SA_LTYPE 11 /* B */
#define OAKLEY_ATTR_SA_LTYPE_DEFAULT 1
#define OAKLEY_ATTR_SA_LTYPE_SEC 1
#define OAKLEY_ATTR_SA_LTYPE_KB 2
#define OAKLEY_ATTR_SA_LDUR 12 /* V */
#define OAKLEY_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
#define OAKLEY_ATTR_PRF 13 /* B */
#define OAKLEY_ATTR_KEY_LEN 14 /* B */
#define OAKLEY_ATTR_FIELD_SIZE 15 /* B */
#define OAKLEY_ATTR_GRP_ORDER 16 /* V */
#define OAKLEY_ID_IPV4_ADDR 0
#define OAKLEY_ID_IPV4_ADDR_SUBNET 1
#define OAKLEY_ID_IPV6_ADDR 2
#define OAKLEY_ID_IPV6_ADDR_SUBNET 3
/* Additional Exchange Type */
#define ISAKMP_ETYPE_QUICK 32
#define ISAKMP_ETYPE_NEWGRP 33
/* The use for checking proposal payload. This is not exchange type. */
#define OAKLEY_MAIN_MODE 0
#define OAKLEY_QUICK_MODE 1
#define OAKLEY_PRIME_MODP768 "\
FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF"
#define OAKLEY_PRIME_MODP1024 "\
FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED \
EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 \
FFFFFFFF FFFFFFFF"
#define DEFAULTSECRETSIZE ( 128 / 8 ) /* 128 bits */
#define DEFAULTNONCESIZE ( 128 / 8 ) /* 128 bits */
#define MAXPADLWORD 20
#if 0
/* isakmp sa structure */
struct oakley_sa {
u_int8_t proto_id; /* OAKLEY */
vchar_t *spi; /* spi */
u_int8_t dhgrp; /* DH; group */
u_int8_t auth_t; /* method of authentication */
u_int8_t prf_t; /* type of prf */
u_int8_t hash_t; /* type of hash */
u_int8_t enc_t; /* type of cipher */
u_int8_t life_t; /* type of duration of lifetime */
u_int32_t ldur; /* life duration */
};
#endif
#endif /* !defined(_ISAKMP_OAKLEY_H_) */

280
contrib/tcpdump/ospf6.h Normal file
View file

@ -0,0 +1,280 @@
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
*/
#define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */
#define OSPF_TYPE_HELLO 1 /* Hello */
#define OSPF_TYPE_DB 2 /* Database Description */
#define OSPF_TYPE_LSR 3 /* Link State Request */
#define OSPF_TYPE_LSU 4 /* Link State Update */
#define OSPF_TYPE_LSA 5 /* Link State Ack */
#define OSPF_TYPE_MAX 6
/* Options *_options */
#define OSPF6_OPTION_V6 0x01 /* V6 bit: A bit for peeping tom */
#define OSPF6_OPTION_E 0x02 /* E bit: External routes advertised */
#define OSPF6_OPTION_MC 0x04 /* MC bit: Multicast capable */
#define OSPF6_OPTION_N 0x08 /* N bit: For type-7 LSA */
#define OSPF6_OPTION_R 0x10 /* R bit: Router bit */
#define OSPF6_OPTION_DC 0x20 /* DC bit: Demand circuits */
/* db_flags */
#define OSPF6_DB_INIT 0x04 /* */
#define OSPF6_DB_MORE 0x02
#define OSPF6_DB_MASTER 0x01
/* ls_type */
#define LS_TYPE_ROUTER 1 /* router link */
#define LS_TYPE_NETWORK 2 /* network link */
#define LS_TYPE_INTER_AP 3 /* Inter-Area-Prefix */
#define LS_TYPE_INTER_AR 4 /* Inter-Area-Router */
#define LS_TYPE_ASE 5 /* ASE */
#define LS_TYPE_GROUP 6 /* Group membership */
#define LS_TYPE_TYPE7 7 /* Type 7 LSA */
#define LS_TYPE_LINK 8 /* Link LSA */
#define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */
#define LS_TYPE_MAX 10
#define LS_TYPE_MASK 0x1fff
#define LS_SCOPE_LINKLOCAL 0x0000
#define LS_SCOPE_AREA 0x2000
#define LS_SCOPE_AS 0x4000
#define LS_SCOPE_MASK 0x6000
/*************************************************
*
* is the above a bug in the documentation?
*
*************************************************/
/* rla_link.link_type */
#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */
#define RLA_TYPE_TRANSIT 2 /* connection to transit network */
#define RLA_TYPE_VIRTUAL 4 /* virtual link */
/* rla_flags */
#define RLA_FLAG_B 0x01
#define RLA_FLAG_E 0x02
#define RLA_FLAG_V 0x04
#define RLA_FLAG_W 0x08
/* sla_tosmetric breakdown */
#define SLA_MASK_TOS 0x7f000000
#define SLA_MASK_METRIC 0x00ffffff
#define SLA_SHIFT_TOS 24
/* asla_tosmetric breakdown */
#define ASLA_FLAG_EXTERNAL 0x80000000
#define ASLA_MASK_TOS 0x7f000000
#define ASLA_SHIFT_TOS 24
#define ASLA_MASK_METRIC 0x00ffffff
/* multicast vertex type */
#define MCLA_VERTEX_ROUTER 1
#define MCLA_VERTEX_NETWORK 2
typedef u_int32_t rtrid_t;
/* link state advertisement header */
struct lsa_hdr {
u_int16_t ls_age;
u_int16_t ls_type;
rtrid_t ls_stateid;
rtrid_t ls_router;
u_int32_t ls_seq;
u_int16_t ls_chksum;
u_int16_t ls_length;
} ;
struct lsa_prefix {
u_int8_t lsa_p_len;
u_int8_t lsa_p_opt;
u_int16_t lsa_p_mbz;
u_int8_t lsa_p_prefix[4];
};
/* link state advertisement */
struct lsa {
struct lsa_hdr ls_hdr;
/* Link state types */
union {
/* Router links advertisements */
struct {
union {
u_int8_t flg;
u_int32_t opt;
} rla_flgandopt;
#define rla_flags rla_flgandopt.flg
#define rla_options rla_flgandopt.opt
struct rlalink {
u_int8_t link_type;
u_int8_t link_zero[1];
u_int16_t link_metric;
u_int32_t link_ifid;
u_int32_t link_nifid;
rtrid_t link_nrtid;
} rla_link[1]; /* may repeat */
} un_rla;
/* Network links advertisements */
struct {
u_int32_t nla_options;
rtrid_t nla_router[1]; /* may repeat */
} un_nla;
/* Inter Area Prefix LSA */
struct {
u_int32_t inter_ap_metric;
struct lsa_prefix inter_ap_prefix[1];
} un_inter_ap;
#if 0
/* Summary links advertisements */
struct {
struct in_addr sla_mask;
u_int32_t sla_tosmetric[1]; /* may repeat */
} un_sla;
/* AS external links advertisements */
struct {
struct in_addr asla_mask;
struct aslametric {
u_int32_t asla_tosmetric;
struct in_addr asla_forward;
struct in_addr asla_tag;
} asla_metric[1]; /* may repeat */
} un_asla;
/* Multicast group membership */
struct mcla {
u_int32_t mcla_vtype;
struct in_addr mcla_vid;
} un_mcla[1];
#endif
/* Type 7 LSA */
/* Link LSA */
struct llsa {
union {
u_int8_t pri;
u_int32_t opt;
} llsa_priandopt;
#define llsa_priority llsa_priandopt.pri
#define llsa_options llsa_priandopt.opt
struct in6_addr llsa_lladdr;
u_int32_t llsa_nprefix;
struct lsa_prefix llsa_prefix[1];
} un_llsa;
/* Intra-Area-Prefix */
struct {
u_int16_t intra_ap_nprefix;
u_int16_t intra_ap_lstype;
rtrid_t intra_ap_lsid;
rtrid_t intra_ap_rtid;
struct lsa_prefix intra_ap_prefix[1];
} un_intra_ap;
} lsa_un;
} ;
/*
* TOS metric struct (will be 0 or more in router links update)
*/
struct tos_metric {
u_int8_t tos_type;
u_int8_t tos_zero;
u_int16_t tos_metric;
} ;
#define OSPF_AUTH_SIZE 8
/*
* the main header
*/
struct ospf6hdr {
u_int8_t ospf6_version;
u_int8_t ospf6_type;
u_int16_t ospf6_len;
rtrid_t ospf6_routerid;
rtrid_t ospf6_areaid;
u_int16_t ospf6_chksum;
u_int8_t ospf6_instanceid;
u_int8_t ospf6_rsvd;
union {
/* Hello packet */
struct {
u_int32_t hello_ifid;
union {
u_int8_t pri;
u_int32_t opt;
} hello_priandopt;
#define hello_priority hello_priandopt.pri
#define hello_options hello_priandopt.opt
u_int16_t hello_helloint;
u_int16_t hello_deadint;
rtrid_t hello_dr;
rtrid_t hello_bdr;
rtrid_t hello_neighbor[1]; /* may repeat */
} un_hello;
/* Database Description packet */
struct {
u_int32_t db_options;
u_int16_t db_mtu;
u_int8_t db_mbz;
u_int8_t db_flags;
u_int32_t db_seq;
struct lsa_hdr db_lshdr[1]; /* may repeat */
} un_db;
/* Link State Request */
struct lsr {
u_int16_t ls_mbz;
u_int16_t ls_type;
rtrid_t ls_stateid;
rtrid_t ls_router;
} un_lsr[1]; /* may repeat */
/* Link State Update */
struct {
u_int32_t lsu_count;
struct lsa lsu_lsa[1]; /* may repeat */
} un_lsu;
/* Link State Acknowledgement */
struct {
struct lsa_hdr lsa_lshdr[1]; /* may repeat */
} un_lsa ;
} ospf6_un ;
} ;
#define ospf6_hello ospf6_un.un_hello
#define ospf6_db ospf6_un.un_db
#define ospf6_lsr ospf6_un.un_lsr
#define ospf6_lsu ospf6_un.un_lsu
#define ospf6_lsa ospf6_un.un_lsa

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

@ -0,0 +1,103 @@
/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.5 1999/12/15 08:10:17 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
/* there's no standard definition so we are on our own */
struct ah {
u_int8_t ah_nxt; /* Next Header */
u_int8_t ah_len; /* Length of data, in 32bit */
u_int16_t ah_reserve; /* Reserved for future use */
u_int32_t ah_spi; /* Security parameter index */
/* variable size, 32bit bound*/ /* Authentication data */
};
struct newah {
u_int8_t ah_nxt; /* Next Header */
u_int8_t ah_len; /* Length of data + 1, in 32bit */
u_int16_t ah_reserve; /* Reserved for future use */
u_int32_t ah_spi; /* Security parameter index */
u_int32_t ah_seq; /* Sequence number field */
/* variable size, 32bit bound*/ /* Authentication data */
};
#include "interface.h"
#include "addrtoname.h"
int
ah_print(register const u_char *bp, register const u_char *bp2)
{
register const struct ah *ah;
register const u_char *ep;
int sumlen;
u_int32_t spi;
ah = (struct ah *)bp;
ep = snapend; /* 'ep' points to the end of avaible data. */
if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
goto trunc;
sumlen = ah->ah_len << 2;
spi = (u_int32_t)ntohl(ah->ah_spi);
printf("AH(spi=%u", spi);
if (vflag)
printf(",sumlen=%d", sumlen);
printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));
if (bp + sizeof(struct ah) + sumlen > ep)
fputs("[truncated]", stdout);
fputs("): ", stdout);
return sizeof(struct ah) + sumlen;
trunc:
fputs("[|AH]", stdout);
return 65535;
}

View file

@ -0,0 +1,158 @@
/* $NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Alan Barrett and Simon J. Gerraty.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.2.2.2 2000/01/11 06:58:23 fenner Exp $";
#endif
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
#include "interface.h"
#define HEXDUMP_BYTES_PER_LINE 16
#define HEXDUMP_SHORTS_PER_LINE (HEXDUMP_BYTES_PER_LINE / 2)
#define HEXDUMP_HEXSTUFF_PER_SHORT 5 /* 4 hex digits and a space */
#define HEXDUMP_HEXSTUFF_PER_LINE \
(HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
void
ascii_print_with_offset(register const u_char *cp, register u_int length,
register u_int oset)
{
register u_int i;
register int s1, s2;
register int nshorts;
char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
char asciistuff[HEXDUMP_BYTES_PER_LINE+1], *asp;
nshorts = length / sizeof(u_short);
i = 0;
hsp = hexstuff; asp = asciistuff;
while (--nshorts >= 0) {
s1 = *cp++;
s2 = *cp++;
(void)sprintf(hsp, " %02x%02x", s1, s2);
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
*(asp++) = (isgraph(s1) ? s1 : '.');
*(asp++) = (isgraph(s2) ? s2 : '.');
if (++i >= HEXDUMP_SHORTS_PER_LINE) {
*hsp = *asp = '\0';
(void)printf("\n0x%04x\t%-*s\t%s",
oset, HEXDUMP_HEXSTUFF_PER_LINE,
hexstuff, asciistuff);
i = 0; hsp = hexstuff; asp = asciistuff;
oset += HEXDUMP_BYTES_PER_LINE;
}
}
if (length & 1) {
s1 = *cp++;
(void)sprintf(hsp, " %02x", s1);
hsp += 3;
*(asp++) = (isgraph(s1) ? s1 : '.');
++i;
}
if (i > 0) {
*hsp = *asp = '\0';
(void)printf("\n0x%04x\t%-*s\t%s",
oset, HEXDUMP_HEXSTUFF_PER_LINE,
hexstuff, asciistuff);
}
}
void
ascii_print(register const u_char *cp, register u_int length)
{
ascii_print_with_offset(cp, length, 0);
}
/*
* telnet_print() wants this. It is essentially default_print_unaligned()
*/
void
hex_print_with_offset(register const u_char *cp, register u_int length,
register u_int oset)
{
register u_int i, s;
register int nshorts;
nshorts = (u_int) length / sizeof(u_short);
i = 0;
while (--nshorts >= 0) {
if ((i++ % 8) == 0) {
(void)printf("\n0x%04x\t", oset);
oset += HEXDUMP_BYTES_PER_LINE;
}
s = *cp++;
(void)printf(" %02x%02x", s, *cp++);
}
if (length & 1) {
if ((i % 8) == 0)
(void)printf("\n0x%04x\t", oset);
(void)printf(" %02x", *cp);
}
}
/*
* just for completeness
*/
void
hex_print(register const u_char *cp, register u_int length)
{
hex_print_with_offset(cp, length, 0);
}
#ifdef MAIN
int
main(int argc, char *argv[])
{
hex_print("Hello, World!\n", 14);
printf("\n");
ascii_print("Hello, World!\n", 14);
printf("\n");
#define TMSG "Now is the winter of our discontent...\n"
ascii_print_with_offset(TMSG, sizeof(TMSG) - 1, 0x100);
printf("\n");
exit(0);
}
#endif /* MAIN */

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

@ -0,0 +1,727 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.9.2.2 2000/01/25 18:32:53 itojun Exp $";
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
struct bgp {
u_int8_t bgp_marker[16];
u_int16_t bgp_len;
u_int8_t bgp_type;
};
#define BGP_SIZE 19 /* unaligned */
#define BGP_OPEN 1
#define BGP_UPDATE 2
#define BGP_NOTIFICATION 3
#define BGP_KEEPALIVE 4
struct bgp_open {
u_int8_t bgpo_marker[16];
u_int16_t bgpo_len;
u_int8_t bgpo_type;
u_int8_t bgpo_version;
u_int16_t bgpo_myas;
u_int16_t bgpo_holdtime;
u_int32_t bgpo_id;
u_int8_t bgpo_optlen;
/* options should follow */
};
struct bgp_opt {
u_int8_t bgpopt_type;
u_int8_t bgpopt_len;
/* variable length */
};
struct bgp_notification {
u_int8_t bgpn_marker[16];
u_int16_t bgpn_len;
u_int8_t bgpn_type;
u_int8_t bgpn_major;
u_int8_t bgpn_minor;
/* data should follow */
};
struct bgp_attr {
u_int8_t bgpa_flags;
u_int8_t bgpa_type;
union {
u_int8_t len;
u_int16_t elen;
} bgpa_len;
#define bgp_attr_len(p) \
(((p)->bgpa_flags & 0x10) ? \
ntohs((p)->bgpa_len.elen) : (p)->bgpa_len.len)
#define bgp_attr_off(p) \
(((p)->bgpa_flags & 0x10) ? 4 : 3)
};
#define BGPTYPE_ORIGIN 1
#define BGPTYPE_AS_PATH 2
#define BGPTYPE_NEXT_HOP 3
#define BGPTYPE_MULTI_EXIT_DISC 4
#define BGPTYPE_LOCAL_PREF 5
#define BGPTYPE_ATOMIC_AGGREGATE 6
#define BGPTYPE_AGGREGATOR 7
#define BGPTYPE_COMMUNITIES 8 /* RFC1997 */
#define BGPTYPE_ORIGINATOR_ID 9 /* RFC1998 */
#define BGPTYPE_CLUSTER_LIST 10 /* RFC1998 */
#define BGPTYPE_DPA 11 /* work in progress */
#define BGPTYPE_ADVERTISERS 12 /* RFC1863 */
#define BGPTYPE_RCID_PATH 13 /* RFC1863 */
#define BGPTYPE_MP_REACH_NLRI 14 /* RFC2283 */
#define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2283 */
static const char *bgptype[] = {
NULL, "OPEN", "UPDATE", "NOTIFICATION", "KEEPALIVE",
};
#define bgp_type(x) num_or_str(bgptype, sizeof(bgptype)/sizeof(bgptype[0]), (x))
static const char *bgpopt_type[] = {
NULL, "Authentication Information",
};
#define bgp_opttype(x) \
num_or_str(bgpopt_type, sizeof(bgpopt_type)/sizeof(bgpopt_type[0]), (x))
static const char *bgpnotify_major[] = {
NULL, "Message Header Error",
"OPEN Message Error", "UPDATE Message Error",
"Hold Timer Expired", "Finite State Machine Error",
"Cease",
};
#define bgp_notify_major(x) \
num_or_str(bgpnotify_major, \
sizeof(bgpnotify_major)/sizeof(bgpnotify_major[0]), (x))
static const char *bgpnotify_minor_1[] = {
NULL, "Connection Not Synchronized",
"Bad Message Length", "Bad Message Type",
};
static const char *bgpnotify_minor_2[] = {
NULL, "Unsupported Version Number",
"Bad Peer AS", "Bad BGP Identifier",
"Unsupported Optional Parameter", "Authentication Failure",
"Unacceptable Hold Time",
};
static const char *bgpnotify_minor_3[] = {
NULL, "Malformed Attribute List",
"Unrecognized Well-known Attribute", "Missing Well-known Attribute",
"Attribute Flags Error", "Attribute Length Error",
"Invalid ORIGIN Attribute", "AS Routing Loop",
"Invalid NEXT_HOP Attribute", "Optional Attribute Error",
"Invalid Network Field", "Malformed AS_PATH",
};
static const char **bgpnotify_minor[] = {
NULL, bgpnotify_minor_1, bgpnotify_minor_2, bgpnotify_minor_3,
};
static const int bgpnotify_minor_siz[] = {
0, sizeof(bgpnotify_minor_1)/sizeof(bgpnotify_minor_1[0]),
sizeof(bgpnotify_minor_2)/sizeof(bgpnotify_minor_2[0]),
sizeof(bgpnotify_minor_3)/sizeof(bgpnotify_minor_3[0]),
};
static const char *bgpattr_origin[] = {
"IGP", "EGP", "INCOMPLETE",
};
#define bgp_attr_origin(x) \
num_or_str(bgpattr_origin, \
sizeof(bgpattr_origin)/sizeof(bgpattr_origin[0]), (x))
static const char *bgpattr_type[] = {
NULL, "ORIGIN", "AS_PATH", "NEXT_HOP",
"MULTI_EXIT_DISC", "LOCAL_PREF", "ATOMIC_AGGREGATE", "AGGREGATOR",
"COMMUNITIES", "ORIGINATOR_ID", "CLUSTER_LIST", "DPA",
"ADVERTISERS", "RCID_PATH", "MP_REACH_NLRI", "MP_UNREACH_NLRI",
};
#define bgp_attr_type(x) \
num_or_str(bgpattr_type, \
sizeof(bgpattr_type)/sizeof(bgpattr_type[0]), (x))
/* Subsequent address family identifier, RFC2283 section 7 */
static const char *bgpattr_nlri_safi[] = {
"Reserved", "Unicast", "Multicast", "Unicast+Multicast",
};
#define bgp_attr_nlri_safi(x) \
num_or_str(bgpattr_nlri_safi, \
sizeof(bgpattr_nlri_safi)/sizeof(bgpattr_nlri_safi[0]), (x))
/* well-known community */
#define BGP_COMMUNITY_NO_EXPORT 0xffffff01
#define BGP_COMMUNITY_NO_ADVERT 0xffffff02
#define BGP_COMMUNITY_NO_EXPORT_SUBCONFED 0xffffff03
/* RFC1700 address family numbers */
#define AFNUM_INET 1
#define AFNUM_INET6 2
#define AFNUM_NSAP 3
#define AFNUM_HDLC 4
#define AFNUM_BBN1822 5
#define AFNUM_802 6
#define AFNUM_E163 7
#define AFNUM_E164 8
#define AFNUM_F69 9
#define AFNUM_X121 10
#define AFNUM_IPX 11
#define AFNUM_ATALK 12
#define AFNUM_DECNET 13
#define AFNUM_BANYAN 14
#define AFNUM_E164NSAP 15
static const char *afnumber[] = {
"Reserved", "IPv4", "IPv6", "NSAP", "HDLC",
"BBN 1822", "802", "E.163", "E.164", "F.69",
"X.121", "IPX", "Appletalk", "Decnet IV", "Banyan Vines",
"E.164 with NSAP subaddress",
};
#define af_name(x) \
(((x) == 65535) ? afnumber[0] : \
num_or_str(afnumber, \
sizeof(afnumber)/sizeof(afnumber[0]), (x)))
static const char *
num_or_str(const char **table, size_t siz, int value)
{
static char buf[20];
if (value < 0 || siz <= value || table[value] == NULL) {
sprintf(buf, "#%d", value);
return buf;
} else
return table[value];
}
static const char *
bgp_notify_minor(int major, int minor)
{
static const char **table;
int siz;
static char buf[20];
const char *p;
if (0 <= major
&& major < sizeof(bgpnotify_minor)/sizeof(bgpnotify_minor[0])
&& bgpnotify_minor[major]) {
table = bgpnotify_minor[major];
siz = bgpnotify_minor_siz[major];
if (0 <= minor && minor < siz && table[minor])
p = table[minor];
else
p = NULL;
} else
p = NULL;
if (p == NULL) {
sprintf(buf, "#%d", minor);
return buf;
} else
return p;
}
static int
decode_prefix4(const u_char *pd, char *buf, int buflen)
{
struct in_addr addr;
int plen;
plen = pd[0];
if (plen < 0 || 32 < plen)
return -1;
memset(&addr, 0, sizeof(addr));
memcpy(&addr, &pd[1], (plen + 7) / 8);
if (plen % 8) {
((u_char *)&addr)[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
sprintf(buf, "%s/%d", getname((char *)&addr), plen);
return 1 + (plen + 7) / 8;
}
#ifdef INET6
static int
decode_prefix6(const u_char *pd, char *buf, int buflen)
{
struct in6_addr addr;
int plen;
plen = pd[0];
if (plen < 0 || 128 < plen)
return -1;
memset(&addr, 0, sizeof(addr));
memcpy(&addr, &pd[1], (plen + 7) / 8);
if (plen % 8) {
addr.s6_addr[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
sprintf(buf, "%s/%d", getname6((char *)&addr), plen);
return 1 + (plen + 7) / 8;
}
#endif
static void
bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
{
int i;
u_int16_t af;
u_int8_t safi, snpa;
int advance;
int tlen;
const u_char *p;
char buf[256];
p = dat;
switch (attr->bgpa_type) {
case BGPTYPE_ORIGIN:
if (len != 1)
printf(" invalid len");
else
printf(" %s", bgp_attr_origin(p[0]));
break;
case BGPTYPE_AS_PATH:
if (len % 2) {
printf(" invalid len");
break;
}
while (p < dat + len) {
/*
* under RFC1965, p[0] means:
* 1: AS_SET 2: AS_SEQUENCE
* 3: AS_CONFED_SET 4: AS_CONFED_SEQUENCE
*/
printf(" ");
if (p[0] == 3 || p[0] == 4)
printf("confed");
printf("%s", (p[0] & 1) ? "{" : "");
for (i = 0; i < p[1]; i += 2) {
printf("%s%u", i == 0 ? "" : " ",
ntohs(*(u_int16_t *)&p[2 + i]));
}
printf("%s", (p[0] & 1) ? "}" : "");
p += 2 + p[1] * 2;
}
break;
case BGPTYPE_NEXT_HOP:
if (len != 4)
printf(" invalid len");
else
printf(" %s", getname(p));
break;
case BGPTYPE_MULTI_EXIT_DISC:
case BGPTYPE_LOCAL_PREF:
if (len != 4)
printf(" invalid len");
else
printf(" %u", (u_int32_t)ntohl(*(u_int32_t *)p));
break;
case BGPTYPE_ATOMIC_AGGREGATE:
if (len != 0)
printf(" invalid len");
break;
case BGPTYPE_AGGREGATOR:
if (len != 6) {
printf(" invalid len");
break;
}
printf(" AS #%u, origin %s", ntohs(*(u_int16_t *)p),
getname(p + 2));
break;
case BGPTYPE_COMMUNITIES:
if (len % 4) {
printf(" invalid len");
break;
}
for (i = 0; i < len; i += 4) {
u_int32_t comm;
comm = (u_int32_t)ntohl(*(u_int32_t *)&p[i]);
switch (comm) {
case BGP_COMMUNITY_NO_EXPORT:
printf(" NO_EXPORT");
break;
case BGP_COMMUNITY_NO_ADVERT:
printf(" NO_ADVERTISE");
break;
case BGP_COMMUNITY_NO_EXPORT_SUBCONFED:
printf(" NO_EXPORT_SUBCONFED");
break;
default:
printf(" (AS #%d value 0x%04x)",
(comm >> 16) & 0xffff, comm & 0xffff);
break;
}
}
break;
case BGPTYPE_MP_REACH_NLRI:
af = ntohs(*(u_int16_t *)p);
safi = p[2];
if (safi >= 128)
printf(" %s vendor specific,", af_name(af));
else {
printf(" %s %s,", af_name(af),
bgp_attr_nlri_safi(safi));
}
p += 3;
if (af == AFNUM_INET)
;
#ifdef INET6
else if (af == AFNUM_INET6)
;
#endif
else
break;
tlen = p[0];
if (tlen) {
printf(" nexthop");
if (af == AFNUM_INET)
advance = 4;
#ifdef INET6
else if (af == AFNUM_INET6)
advance = 16;
#endif
for (i = 0; i < tlen; i += advance) {
if (af == AFNUM_INET)
printf(" %s", getname(p + 1 + i));
#ifdef INET6
else if (af == AFNUM_INET6)
printf(" %s", getname6(p + 1 + i));
#endif
}
printf(",");
}
p += 1 + tlen;
snpa = p[0];
p++;
if (snpa) {
printf(" %u snpa", snpa);
for (/*nothing*/; snpa > 0; snpa--) {
printf("(%d bytes)", p[0]);
p += p[0] + 1;
}
printf(",");
}
printf(" NLRI");
while (len - (p - dat) > 0) {
if (af == AFNUM_INET)
advance = decode_prefix4(p, buf, sizeof(buf));
#ifdef INET6
else if (af == AFNUM_INET6)
advance = decode_prefix6(p, buf, sizeof(buf));
#endif
printf(" %s", buf);
p += advance;
}
break;
case BGPTYPE_MP_UNREACH_NLRI:
af = ntohs(*(u_int16_t *)p);
safi = p[2];
if (safi >= 128)
printf(" %s vendor specific,", af_name(af));
else {
printf(" %s %s,", af_name(af),
bgp_attr_nlri_safi(safi));
}
p += 3;
printf(" Withdraw");
while (len - (p - dat) > 0) {
if (af == AFNUM_INET)
advance = decode_prefix4(p, buf, sizeof(buf));
#ifdef INET6
else if (af == AFNUM_INET6)
advance = decode_prefix6(p, buf, sizeof(buf));
#endif
printf(" %s", buf);
p += advance;
}
break;
default:
break;
}
}
static void
bgp_open_print(const u_char *dat, int length)
{
struct bgp_open bgpo;
struct bgp_opt bgpopt;
int hlen;
const u_char *opt;
int i;
memcpy(&bgpo, dat, sizeof(bgpo));
hlen = ntohs(bgpo.bgpo_len);
printf(": Version %d,", bgpo.bgpo_version);
printf(" AS #%u,", ntohs(bgpo.bgpo_myas));
printf(" Holdtime %u,", ntohs(bgpo.bgpo_holdtime));
printf(" ID %s,", getname((char *)&bgpo.bgpo_id));
printf(" Option length %u", bgpo.bgpo_optlen);
/* ugly! */
opt = &((struct bgp_open *)dat)->bgpo_optlen;
opt++;
for (i = 0; i < bgpo.bgpo_optlen; i++) {
memcpy(&bgpopt, &opt[i], sizeof(bgpopt));
if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
printf(" [|opt %d %d]", bgpopt.bgpopt_len, bgpopt.bgpopt_type);
break;
}
printf(" (option %s, len=%d)", bgp_opttype(bgpopt.bgpopt_type),
bgpopt.bgpopt_len);
i += sizeof(bgpopt) + bgpopt.bgpopt_len;
}
}
static void
bgp_update_print(const u_char *dat, int length)
{
struct bgp bgp;
struct bgp_attr bgpa;
int hlen;
const u_char *p;
int len;
int i;
int newline;
memcpy(&bgp, dat, sizeof(bgp));
hlen = ntohs(bgp.bgp_len);
p = dat + BGP_SIZE; /*XXX*/
printf(":");
/* Unfeasible routes */
len = ntohs(*(u_int16_t *)p);
if (len) {
printf(" (Withdrawn routes: %d bytes)", len);
}
p += 2 + len;
len = ntohs(*(u_int16_t *)p);
if (len) {
/* do something more useful!*/
i = 2;
printf(" (Path attributes:"); /* ) */
newline = 0;
while (i < 2 + len) {
int alen, aoff;
memcpy(&bgpa, &p[i], sizeof(bgpa));
alen = bgp_attr_len(&bgpa);
aoff = bgp_attr_off(&bgpa);
if (vflag && newline)
printf("\n\t\t");
else
printf(" ");
printf("("); /* ) */
printf("%s", bgp_attr_type(bgpa.bgpa_type));
if (bgpa.bgpa_flags) {
printf("[%s%s%s%s]",
bgpa.bgpa_flags & 0x80 ? "O" : "",
bgpa.bgpa_flags & 0x40 ? "T" : "",
bgpa.bgpa_flags & 0x20 ? "P" : "",
bgpa.bgpa_flags & 0x00 ? "E" : "");
}
bgp_attr_print(&bgpa, &p[i + aoff], alen);
newline = 1;
/* ( */
printf(")");
i += aoff + alen;
}
/* ( */
printf(")");
}
p += 2 + len;
if (len && dat + length > p)
printf("\n\t\t");
if (dat + length > p) {
printf("(NLRI:"); /* ) */
while (dat + length > p) {
char buf[256];
i = decode_prefix4(p, buf, sizeof(buf));
printf(" %s", buf);
if (i < 0)
break;
p += i;
}
/* ( */
printf(")");
}
}
static void
bgp_notification_print(const u_char *dat, int length)
{
struct bgp_notification bgpn;
int hlen;
memcpy(&bgpn, dat, sizeof(bgpn));
hlen = ntohs(bgpn.bgpn_len);
printf(": error %s,", bgp_notify_major(bgpn.bgpn_major));
printf(" subcode %s",
bgp_notify_minor(bgpn.bgpn_major, bgpn.bgpn_minor));
}
static void
bgp_header_print(const u_char *dat, int length)
{
struct bgp bgp;
memcpy(&bgp, dat, sizeof(bgp));
printf("(%s", bgp_type(bgp.bgp_type)); /* ) */
switch (bgp.bgp_type) {
case BGP_OPEN:
bgp_open_print(dat, length);
break;
case BGP_UPDATE:
bgp_update_print(dat, length);
break;
case BGP_NOTIFICATION:
bgp_notification_print(dat, length);
break;
}
/* ( */
printf(")");
}
void
bgp_print(const u_char *dat, int length)
{
const u_char *p;
const u_char *ep;
const u_char *start;
const u_char marker[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
struct bgp bgp;
u_int16_t hlen;
int newline;
ep = dat + length;
if (snapend < dat + length)
ep = snapend;
printf(": BGP");
p = dat;
newline = 0;
start = p;
while (p < snapend) {
if (!TTEST2(p[0], 1))
break;
if (p[0] != 0xff) {
p++;
continue;
}
if (!TTEST2(p[0], sizeof(marker)))
break;
if (memcmp(p, marker, sizeof(marker)) != 0) {
p++;
continue;
}
/* found BGP header */
TCHECK2(p[0], BGP_SIZE); /*XXX*/
memcpy(&bgp, p, sizeof(bgp));
if (start != p)
printf(" [|BGP]");
hlen = ntohs(bgp.bgp_len);
if (vflag && newline)
printf("\n\t");
else
printf(" ");
if (TTEST2(p[0], hlen)) {
bgp_header_print(p, hlen);
newline = 1;
p += hlen;
start = p;
} else {
printf("[|BGP %s]", bgp_type(bgp.bgp_type));
break;
}
}
return;
trunc:
printf(" [|BGP]");
}

View file

@ -0,0 +1,196 @@
/* maybe it should be merged into print-ppp.c */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.2 1999/11/21 09:36:49 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#if __STDC__
struct mbuf;
struct rtentry;
#endif
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/if_ether.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <stdio.h>
#ifdef __bsdi__
#include <net/slcompress.h>
#include <net/if_ppp.h>
#endif
#include "interface.h"
#include "addrtoname.h"
#include "ppp.h"
/* XXX This goes somewhere else. */
#define CHDLC_HDRLEN 4
#define CHDLC_UNICAST 0x0f
#define CHDLC_BCAST 0x8f
#define CHDLC_TYPE_SLARP 0x8035
#define CHDLC_TYPE_CDP 0x2000
static void chdlc_slarp_print(const u_char *, u_int);
/* Standard CHDLC printer */
void
chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
const struct ip *ip;
u_int proto;
ts_print(&h->ts);
if (caplen < CHDLC_HDRLEN) {
printf("[|chdlc]");
goto out;
}
/*
* Some printers want to get back at the link level addresses,
* and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
proto = ntohs(*(u_short *)&p[2]);
packetp = p;
snapend = p + caplen;
if (eflag) {
switch (p[0]) {
case CHDLC_UNICAST:
printf("unicast ");
break;
case CHDLC_BCAST:
printf("bcast ");
break;
default:
printf("0x%02x ", p[0]);
break;
}
printf("%d %04x: ", length, proto);
}
length -= CHDLC_HDRLEN;
ip = (struct ip *)(p + CHDLC_HDRLEN);
switch(proto) {
case ETHERTYPE_IP:
ip_print((const u_char *)ip, length);
break;
#ifdef INET6
case ETHERTYPE_IPV6:
ip6_print((const u_char *)ip, length);
break;
#endif
case CHDLC_TYPE_SLARP:
chdlc_slarp_print((const u_char *)ip, length);
break;
#if 0
case CHDLC_TYPE_CDP:
chdlc_cdp_print((const u_char *)ip, length);
break;
#endif
}
if (xflag)
default_print((const u_char *)ip, caplen - CHDLC_HDRLEN);
out:
putchar('\n');
}
struct cisco_slarp {
long code;
#define SLARP_REQUEST 0
#define SLARP_REPLY 1
#define SLARP_KEEPALIVE 2
union {
struct {
struct in_addr addr;
struct in_addr mask;
u_short unused[3];
} addr;
struct {
long myseq;
long yourseq;
short rel;
short t1;
short t2;
} keep;
} un;
};
#define SLARP_LEN 18
static void
chdlc_slarp_print(const u_char *cp, u_int length)
{
struct cisco_slarp *slarp;
if (length < SLARP_LEN) {
printf("[|slarp]");
return;
}
slarp = (struct cisco_slarp *)cp;
switch (ntohl(slarp->code)) {
case SLARP_REQUEST:
printf("slarp-request");
break;
case SLARP_REPLY:
printf("slarp-reply %s/%s",
ipaddr_string(&slarp->un.addr.addr),
ipaddr_string(&slarp->un.addr.mask));
break;
case SLARP_KEEPALIVE:
printf("slarp-keepalive my=0x%x your=0x%x ",
(u_int32_t)ntohl(slarp->un.keep.myseq),
(u_int32_t)ntohl(slarp->un.keep.yourseq));
printf("reliability=0x%04x t1=%d.%d",
ntohs(slarp->un.keep.rel), ntohs(slarp->un.keep.t1),
ntohs(slarp->un.keep.t2));
break;
default:
printf("slarp-0x%x unknown", (u_int32_t)ntohl(slarp->code));
break;
}
if (SLARP_LEN < length && vflag)
printf("(trailing junk: %d bytes)", length - SLARP_LEN);
}

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

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

View file

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

View file

@ -0,0 +1,342 @@
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.3 1999/12/22 06:27:20 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#if __STDC__
struct mbuf;
struct rtentry;
#endif
#include <net/if.h>
#include <netinet/in.h>
#include <ctype.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include "interface.h"
#include "addrtoname.h"
#include "dhcp6.h"
#include "dhcp6opt.h"
#if 0
static void dhcp6opttab_init __P((void));
static struct dhcp6_opt *dhcp6opttab_byname __P((char *));
#endif
static struct dhcp6_opt *dhcp6opttab_bycode __P((u_int));
static char tstr[] = " [|dhcp6]";
static struct dhcp6_opt dh6opttab[] = {
/* IP Address Extension */
{ 1, OL6_N, "IP Address", OT6_NONE, },
/* General Extension */
{ 2, 4, "Time Offset", OT6_NUM, },
{ 3, OL6_N, "IEEE 1003.1 POSIX Timezone", OT6_STR, },
{ 6, OL6_16N, "Domain Name Server", OT6_V6, },
{ 10, OL6_N, "Domain Name", OT6_STR, },
/* Application and Service Parameters */
{ 16, OL6_N, "Directory Agent", OT6_NONE, },
{ 17, OL6_N, "Service Scope" , OT6_NONE, },
{ 18, OL6_16N, "Network Time Protocol Servers", OT6_V6, },
{ 19, OL6_N, "NIS Domain", OT6_STR, },
{ 20, OL6_16N, "NIS Servers", OT6_V6, },
{ 21, OL6_N, "NIS+ Domain", OT6_STR, },
{ 22, OL6_16N, "NIS+ Servers", OT6_V6, },
/* TCP Parameters */
{ 32, 4, "TCP Keepalive Interval", OT6_NUM, },
/* DHCPv6 Extensions */
{ 40, 4, "Maximum DHCPv6 Message Size", OT6_NUM, },
{ 41, OL6_N, "DHCP Retransmission and Configuration Parameter",
OT6_NONE, },
{ 48, OL6_N, "Platform Specific Information", OT6_NONE, },
{ 49, OL6_N, "Platform Class Identifier", OT6_STR, },
{ 64, OL6_N, "Class Identifier", OT6_STR, },
{ 66, 16, "Reconfigure Multicast Address", OT6_V6, },
{ 67, 16, "Renumber DHCPv6 Server Address",
OT6_V6, },
{ 68, OL6_N, "DHCP Relay ICMP Error Message", OT6_NONE, },
{ 84, OL6_N, "Client-Server Authentication", OT6_NONE, },
{ 85, 4, "Client Key Selection", OT6_NUM, },
/* End Extension */
{ 65536, OL6_Z, "End", OT6_NONE, },
{ 0 },
};
#if 0
static struct dhcp6_opt *dh6o_pad;
static struct dhcp6_opt *dh6o_end;
static void
dhcp6opttab_init()
{
dh6o_pad = dhcp6opttab_bycode(0);
dh6o_end = dhcp6opttab_bycode(65536);
}
#endif
#if 0
static struct dhcp6_opt *
dhcp6opttab_byname(name)
char *name;
{
struct dhcp6_opt *p;
for (p = dh6opttab; p->code; p++)
if (strcmp(name, p->name) == 0)
return p;
return NULL;
}
#endif
static struct dhcp6_opt *
dhcp6opttab_bycode(code)
u_int code;
{
struct dhcp6_opt *p;
for (p = dh6opttab; p->code; p++)
if (p->code == code)
return p;
return NULL;
}
static void
dhcp6ext_print(u_char *cp, u_char *ep)
{
u_int16_t code, len;
struct dhcp6_opt *p;
char buf[BUFSIZ];
int i;
if (cp == ep)
return;
printf(" ");
while (cp < ep) {
code = ntohs(*(u_int16_t *)&cp[0]);
if (code != 65535)
len = ntohs(*(u_int16_t *)&cp[2]);
else
len = 0;
p = dhcp6opttab_bycode(code);
if (p == NULL) {
printf("(unknown, len=%d)", len);
cp += len + 4;
continue;
}
/* sanity check on length */
switch (p->len) {
case OL6_N:
break;
case OL6_16N:
if (len % 16 != 0)
goto trunc;
break;
case OL6_Z:
if (len != 0)
goto trunc;
break;
default:
if (len != p->len)
goto trunc;
break;
}
if (cp + 4 + len > ep) {
printf("[|%s]", p->name);
return;
}
printf("(%s, ", p->name);
switch (p->type) {
case OT6_V6:
for (i = 0; i < len; i += 16) {
inet_ntop(AF_INET6, &cp[4 + i], buf,
sizeof(buf));
if (i != 0)
printf(",");
printf("%s", buf);
}
break;
case OT6_STR:
memset(&buf, 0, sizeof(buf));
strncpy(buf, &cp[4], len);
printf("%s", buf);
break;
case OT6_NUM:
printf("%d", (u_int32_t)ntohl(*(u_int32_t *)&cp[4]));
break;
default:
for (i = 0; i < len; i++)
printf("%02x", cp[4 + i] & 0xff);
}
printf(")");
cp += len + 4;
}
return;
trunc:
printf("[|dhcp6ext]");
}
/*
* Print dhcp6 requests
*/
void
dhcp6_print(register const u_char *cp, u_int length,
u_short sport, u_short dport)
{
union dhcp6 *dh6;
u_char *ep;
u_char *extp;
printf("dhcp6");
ep = (u_char *)snapend;
dh6 = (union dhcp6 *)cp;
TCHECK(dh6->dh6_msgtype);
switch (dh6->dh6_msgtype) {
case DH6_SOLICIT:
if (vflag && TTEST(dh6->dh6_sol.dh6sol_relayaddr)) {
printf(" solicit(");
if ((dh6->dh6_sol.dh6sol_flags & DH6SOL_CLOSE) != 0)
printf("C");
if (dh6->dh6_sol.dh6sol_flags != 0)
printf(" ");
printf("cliaddr=%s",
ip6addr_string(&dh6->dh6_sol.dh6sol_cliaddr));
printf(" relayaddr=%s",
ip6addr_string(&dh6->dh6_sol.dh6sol_relayaddr));
printf(")");
} else
printf(" solicit");
break;
case DH6_ADVERT:
if (!(vflag && TTEST(dh6->dh6_adv.dh6adv_serveraddr))) {
printf(" advert");
break;
}
printf(" advert(");
if ((dh6->dh6_adv.dh6adv_flags & DH6ADV_SERVPRESENT) != 0)
printf("S");
if (dh6->dh6_adv.dh6adv_flags != 0)
printf(" ");
printf("pref=%u", dh6->dh6_adv.dh6adv_pref);
printf(" cliaddr=%s",
ip6addr_string(&dh6->dh6_adv.dh6adv_cliaddr));
printf(" relayaddr=%s",
ip6addr_string(&dh6->dh6_adv.dh6adv_relayaddr));
printf(" servaddr=%s",
ip6addr_string(&dh6->dh6_adv.dh6adv_serveraddr));
extp = (u_char *)((&dh6->dh6_adv) + 1);
dhcp6ext_print(extp, ep);
printf(")");
break;
case DH6_REQUEST:
if (!(vflag && TTEST(dh6->dh6_req.dh6req_relayaddr))) {
printf(" request");
break;
}
printf(" request(");
if ((dh6->dh6_req.dh6req_flags & DH6REQ_CLOSE) != 0)
printf("C");
if ((dh6->dh6_req.dh6req_flags & DH6REQ_SERVPRESENT) != 0)
printf("S");
if ((dh6->dh6_req.dh6req_flags & DH6REQ_REBOOT) != 0)
printf("R");
if (dh6->dh6_req.dh6req_flags != 0)
printf(" ");
printf("xid=0x%04x", dh6->dh6_req.dh6req_xid);
printf(" cliaddr=%s",
ip6addr_string(&dh6->dh6_req.dh6req_cliaddr));
printf(" relayaddr=%s",
ip6addr_string(&dh6->dh6_req.dh6req_relayaddr));
extp = (char *)((&dh6->dh6_req) + 1);
if ((dh6->dh6_req.dh6req_flags & DH6REQ_SERVPRESENT) != 0) {
printf(" servaddr=%s", ip6addr_string(extp));
extp += 16;
}
dhcp6ext_print(extp, ep);
printf(")");
break;
case DH6_REPLY:
if (!(vflag && TTEST(dh6->dh6_rep.dh6rep_xid))) {
printf(" reply");
break;
}
printf(" reply(");
if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_CLIPRESENT) != 0)
printf("C");
if (dh6->dh6_rep.dh6rep_flagandstat != 0)
printf(" ");
printf("stat=0x%02x",
dh6->dh6_rep.dh6rep_flagandstat & DH6REP_STATMASK);
extp = (u_char *)((&dh6->dh6_rep) + 1);
if ((dh6->dh6_rep.dh6rep_flagandstat & DH6REP_CLIPRESENT) != 0) {
printf(" cliaddr=%s", ip6addr_string(extp));
extp += 16;
}
dhcp6ext_print(extp, ep);
printf(")");
break;
case DH6_RELEASE:
printf(" release");
break;
case DH6_RECONFIG:
printf(" reconfig");
break;
}
return;
trunc:
printf("%s", tstr);
}

View file

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-dvmrp.c,v 1.13 96/12/10 23:16:30 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.17 1999/11/22 04:30:34 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -35,7 +39,6 @@ static const char rcsid[] =
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <stdio.h>
#include <string.h>
@ -43,6 +46,7 @@ static const char rcsid[] =
#include <unistd.h>
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
/*
@ -209,15 +213,13 @@ print_report(register const u_char *bp, register const u_char *ep,
}
}
#define GET_ADDR(to) (memcpy((char *)to, (char *)bp, 4), bp += 4)
static void
print_probe(register const u_char *bp, register const u_char *ep,
register u_int len)
{
register u_int32_t genid;
u_char neighbor[4];
TCHECK2(bp[0], 4);
if ((len < 4) || ((bp + 4) > ep)) {
/* { (ctags) */
printf(" [|}");
@ -229,50 +231,51 @@ print_probe(register const u_char *bp, register const u_char *ep,
printf("\n\tgenid %u", genid);
while ((len > 0) && (bp < ep)) {
if ((len < 4) || ((bp + 4) > ep)) {
printf(" [|]");
return;
}
GET_ADDR(neighbor);
len -= 4;
printf("\n\tneighbor %s", ipaddr_string(neighbor));
TCHECK2(bp[0], 4);
printf("\n\tneighbor %s", ipaddr_string(bp));
bp += 4; len -= 4;
}
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_neighbors(register const u_char *bp, register const u_char *ep,
register u_int len)
{
u_char laddr[4], neighbor[4];
const u_char *laddr;
register u_char metric;
register u_char thresh;
register int ncount;
while (len > 0 && bp < ep) {
if (len < 7 || (bp + 7) >= ep) {
printf(" [|]");
return;
}
GET_ADDR(laddr);
TCHECK2(bp[0], 7);
laddr = bp;
bp += 4;
metric = *bp++;
thresh = *bp++;
ncount = *bp++;
len -= 7;
while (--ncount >= 0 && (len >= 4) && (bp + 4) < ep) {
GET_ADDR(neighbor);
while (--ncount >= 0) {
TCHECK2(bp[0], 4);
printf(" [%s ->", ipaddr_string(laddr));
printf(" %s, (%d/%d)]",
ipaddr_string(neighbor), metric, thresh);
ipaddr_string(bp), metric, thresh);
bp += 4;
len -= 4;
}
}
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_neighbors2(register const u_char *bp, register const u_char *ep,
register u_int len)
{
u_char laddr[4], neighbor[4];
const u_char *laddr;
register u_char metric, thresh, flags;
register int ncount;
@ -281,20 +284,17 @@ print_neighbors2(register const u_char *bp, register const u_char *ep,
(int)(target_level >> 8) & 0xff);
while (len > 0 && bp < ep) {
if (len < 8 || (bp + 8) >= ep) {
printf(" [|]");
return;
}
GET_ADDR(laddr);
TCHECK2(bp[0], 8);
laddr = bp;
bp += 4;
metric = *bp++;
thresh = *bp++;
flags = *bp++;
ncount = *bp++;
len -= 8;
while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) {
GET_ADDR(neighbor);
printf(" [%s -> ", ipaddr_string(laddr));
printf("%s (%d/%d", ipaddr_string(neighbor),
printf("%s (%d/%d", ipaddr_string(bp),
metric, thresh);
if (flags & DVMRP_NF_TUNNEL)
printf("/tunnel");
@ -307,6 +307,7 @@ print_neighbors2(register const u_char *bp, register const u_char *ep,
if (flags & DVMRP_NF_DOWN)
printf("/down");
printf(")]");
bp += 4;
len -= 4;
}
if (ncount != -1) {
@ -314,47 +315,43 @@ print_neighbors2(register const u_char *bp, register const u_char *ep,
return;
}
}
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_prune(register const u_char *bp, register const u_char *ep,
register u_int len)
{
union a {
u_char b[4];
u_int32_t i;
} prune_timer;
if (len < 12 || (bp + 12) > ep) {
printf(" [|]");
return;
}
TCHECK2(bp[0], 12);
printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
bp += 8;
GET_ADDR(prune_timer.b);
printf(" timer %d", (int)ntohl(prune_timer.i));
(void)printf(" timer ");
relts_print(EXTRACT_32BITS(bp));
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_graft(register const u_char *bp, register const u_char *ep,
register u_int len)
{
if (len < 8 || (bp + 8) > ep) {
printf(" [|]");
return;
}
TCHECK2(bp[0], 8);
printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
return;
trunc:
(void)printf("[|dvmrp]");
}
static void
print_graft_ack(register const u_char *bp, register const u_char *ep,
register u_int len)
{
if (len < 8 || (bp + 8) > ep) {
printf(" [|]");
return;
}
TCHECK2(bp[0], 8);
printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
return;
trunc:
(void)printf("[|dvmrp]");
}

View file

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

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

@ -0,0 +1,336 @@
/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.5 1999/12/15 08:10:18 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#ifdef CRYPTO
#include <des.h>
#include <blowfish.h>
#ifdef HAVE_RC5_H
#include <rc5.h>
#endif
#ifdef HAVE_CAST_H
#include <cast.h>
#endif
#endif
#include <stdio.h>
#ifdef INET6
#include <netinet/ip6.h>
#endif
/* there's no standard definition so we are on our own */
struct esp {
u_int32_t esp_spi; /* ESP */
/*variable size, 32bit bound*/ /* Initialization Vector */
/*variable size*/ /* Payload data */
/*variable size*/ /* padding */
/*8bit*/ /* pad size */
/*8bit*/ /* next header */
/*8bit*/ /* next header */
/*variable size, 32bit bound*/ /* Authentication data (new IPsec) */
};
struct newesp {
u_int32_t esp_spi; /* ESP */
u_int32_t esp_seq; /* Sequence number */
/*variable size*/ /* (IV and) Payload data */
/*variable size*/ /* padding */
/*8bit*/ /* pad size */
/*8bit*/ /* next header */
/*8bit*/ /* next header */
/*variable size, 32bit bound*/ /* Authentication data */
};
#include "interface.h"
#include "addrtoname.h"
int
esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
{
register const struct esp *esp;
register const u_char *ep;
u_int32_t spi;
enum { NONE, DESCBC, BLOWFISH, RC5, CAST128, DES3CBC } algo = NONE;
struct ip *ip = NULL;
#ifdef INET6
struct ip6_hdr *ip6 = NULL;
#endif
int advance;
int len;
char *secret = NULL;
int ivlen = 0;
u_char *ivoff;
esp = (struct esp *)bp;
spi = (u_int32_t)ntohl(esp->esp_spi);
/* 'ep' points to the end of avaible data. */
ep = snapend;
if ((u_char *)(esp + 1) >= ep - sizeof(struct esp)) {
fputs("[|ESP]", stdout);
goto fail;
}
printf("ESP(spi=%u", spi);
printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(esp + 1)));
printf(")");
/* if we don't have decryption key, we can't decrypt this packet. */
if (!espsecret)
goto fail;
if (strncmp(espsecret, "des-cbc:", 8) == 0
&& strlen(espsecret + 8) == 8) {
algo = DESCBC;
ivlen = 8;
secret = espsecret + 8;
} else if (strncmp(espsecret, "blowfish-cbc:", 13) == 0) {
algo = BLOWFISH;
ivlen = 8;
secret = espsecret + 13;
} else if (strncmp(espsecret, "rc5-cbc:", 8) == 0) {
algo = RC5;
ivlen = 8;
secret = espsecret + 8;
} else if (strncmp(espsecret, "cast128-cbc:", 12) == 0) {
algo = CAST128;
ivlen = 8;
secret = espsecret + 12;
} else if (strncmp(espsecret, "3des-cbc:", 9) == 0
&& strlen(espsecret + 9) == 24) {
algo = DES3CBC;
ivlen = 8;
secret = espsecret + 9;
} else if (strncmp(espsecret, "none:", 5) == 0) {
algo = NONE;
ivlen = 0;
secret = espsecret + 5;
} else if (strlen(espsecret) == 8) {
algo = DESCBC;
ivlen = 8;
secret = espsecret;
} else {
algo = NONE;
ivlen = 0;
secret = espsecret;
}
ip = (struct ip *)bp2;
switch (ip->ip_v) {
#ifdef INET6
case 6:
ip6 = (struct ip6_hdr *)bp2;
ip = NULL;
/* we do not attempt to decrypt jumbograms */
if (!ntohs(ip6->ip6_plen))
goto fail;
/* if we can't get nexthdr, we do not need to decrypt it */
len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen);
break;
#endif /*INET6*/
case 4:
#ifdef INET6
ip6 = NULL;
#endif
len = ntohs(ip->ip_len);
break;
default:
goto fail;
}
/* if we can't get nexthdr, we do not need to decrypt it */
if (ep - bp2 < len)
goto fail;
if (Rflag)
ivoff = (u_char *)(esp + 1) + sizeof(u_int32_t);
else
ivoff = (u_char *)(esp + 1);
switch (algo) {
case DESCBC:
#ifdef CRYPTO
{
u_char iv[8];
des_key_schedule schedule;
u_char *p;
switch (ivlen) {
case 4:
memcpy(iv, ivoff, 4);
memcpy(&iv[4], ivoff, 4);
p = &iv[4];
*p++ ^= 0xff;
*p++ ^= 0xff;
*p++ ^= 0xff;
*p++ ^= 0xff;
break;
case 8:
memcpy(iv, ivoff, 8);
break;
default:
goto fail;
}
des_check_key = 0;
des_set_key((void *)secret, schedule);
p = ivoff + ivlen;
des_cbc_encrypt((void *)p, (void *)p,
(long)(ep - p), schedule, (void *)iv,
DES_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
#else
goto fail;
#endif /*CRYPTO*/
case BLOWFISH:
#ifdef CRYPTO
{
BF_KEY schedule;
u_char *p;
BF_set_key(&schedule, strlen(secret), secret);
p = ivoff + ivlen;
BF_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff,
BF_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
#else
goto fail;
#endif /*CRYPTO*/
case RC5:
#if defined(CRYPTO) && defined(HAVE_RC5_H)
{
RC5_32_KEY schedule;
u_char *p;
RC5_32_set_key(&schedule, strlen(secret), secret,
RC5_16_ROUNDS);
p = ivoff + ivlen;
RC5_32_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff,
RC5_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
#else
goto fail;
#endif /*CRYPTO*/
case CAST128:
#if defined(CRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128)
{
CAST_KEY schedule;
u_char *p;
CAST_set_key(&schedule, strlen(secret), secret);
p = ivoff + ivlen;
CAST_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff,
CAST_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
#else
goto fail;
#endif /*CRYPTO*/
case DES3CBC:
#if defined(CRYPTO)
{
des_key_schedule s1, s2, s3;
u_char *p;
des_check_key = 0;
des_set_key((void *)secret, s1);
des_set_key((void *)(secret + 8), s2);
des_set_key((void *)(secret + 16), s3);
p = ivoff + ivlen;
des_ede3_cbc_encrypt((void *)p, (void *)p,
(long)(ep - p), s1, s2, s3, (void *)ivoff, DES_DECRYPT);
advance = ivoff - (u_char *)esp + ivlen;
break;
}
#else
goto fail;
#endif /*CRYPTO*/
case NONE:
default:
if (Rflag)
advance = sizeof(struct esp) + sizeof(u_int32_t);
else
advance = sizeof(struct esp);
break;
}
/* sanity check for pad length */
if (ep - bp < *(ep - 2))
goto fail;
if (nhdr)
*nhdr = *(ep - 1);
printf(": ");
return advance;
fail:
if (nhdr)
*nhdr = -1;
return 65536;
}

View file

@ -0,0 +1,104 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.3.2.1 2000/01/11 06:58:24 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef INET6
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <netinet/ip6.h>
#include "interface.h"
#include "addrtoname.h"
int
frag6_print(register const u_char *bp, register const u_char *bp2)
{
register const struct ip6_frag *dp;
register const struct ip6_hdr *ip6;
register const u_char *ep;
#if 0
#define TCHECK(var) if ((u_char *)&(var) >= ep - sizeof(var)) goto trunc
#endif
dp = (struct ip6_frag *)bp;
ip6 = (struct ip6_hdr *)bp2;
/* 'ep' points to the end of avaible data. */
ep = snapend;
TCHECK(dp->ip6f_offlg);
if (vflag) {
printf("frag (0x%08x:%d|%ld)",
(u_int32_t)ntohl(dp->ip6f_ident),
ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
(long)(bp - bp2) - sizeof(struct ip6_frag));
} else {
printf("frag (%d|%ld)",
ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
(long)(bp - bp2) - sizeof(struct ip6_frag));
}
#if 0
/* it is meaningless to decode non-first fragment */
if (ntohs(dp->ip6f_offlg & IP6F_OFF_MASK) != 0)
return 65535;
else
#endif
{
fputs(" ", stdout);
return sizeof(struct ip6_frag);
}
trunc:
fputs("[|frag]", stdout);
return 65535;
#undef TCHECK
}
#endif /* INET6 */

View file

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

View file

@ -0,0 +1,574 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.2.2.1 2000/01/11 06:58:24 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef INET6
#include <ctype.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include "interface.h"
#include "addrtoname.h"
void icmp6_opt_print(const u_char *, int);
void mld6_print(const u_char *);
void
icmp6_print(register const u_char *bp, register const u_char *bp2)
{
register const struct icmp6_hdr *dp;
register const struct ip6_hdr *ip;
register const char *str;
register const struct ip6_hdr *oip;
register const struct udphdr *ouh;
register int hlen, dport;
register const u_char *ep;
char buf[256];
int icmp6len;
#if 0
#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
#endif
dp = (struct icmp6_hdr *)bp;
ip = (struct ip6_hdr *)bp2;
oip = (struct ip6_hdr *)(dp + 1);
str = buf;
/* 'ep' points to the end of avaible data. */
ep = snapend;
if (ip->ip6_plen)
icmp6len = (ntohs(ip->ip6_plen) + sizeof(struct ip6_hdr) -
(bp - bp2));
else /* XXX: jumbo payload case... */
icmp6len = snapend - bp;
#if 0
(void)printf("%s > %s: ",
ip6addr_string(&ip->ip6_src),
ip6addr_string(&ip->ip6_dst));
#endif
TCHECK(dp->icmp6_code);
switch(dp->icmp6_type) {
case ICMP6_DST_UNREACH:
TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
case ICMP6_DST_UNREACH_NOROUTE:
printf("icmp6: %s unreachable route",
ip6addr_string(&oip->ip6_dst));
break;
case ICMP6_DST_UNREACH_ADMIN:
printf("icmp6: %s unreachable prohibited",
ip6addr_string(&oip->ip6_dst));
break;
#ifdef ICMP6_DST_UNREACH_BEYONDSCOPE
case ICMP6_DST_UNREACH_BEYONDSCOPE:
#else
case ICMP6_DST_UNREACH_NOTNEIGHBOR:
#endif
printf("icmp6: %s beyond scope of source address %s",
ip6addr_string(&oip->ip6_dst),
ip6addr_string(&oip->ip6_src));
break;
case ICMP6_DST_UNREACH_ADDR:
printf("icmp6: %s unreachable address",
ip6addr_string(&oip->ip6_dst));
break;
case ICMP6_DST_UNREACH_NOPORT:
TCHECK(oip->ip6_nxt);
hlen = sizeof(struct ip6_hdr);
ouh = (struct udphdr *)(((u_char *)oip) + hlen);
dport = ntohs(ouh->uh_dport);
switch (oip->ip6_nxt) {
case IPPROTO_TCP:
printf("icmp6: %s tcp port %s unreachable",
ip6addr_string(&oip->ip6_dst),
tcpport_string(dport));
break;
case IPPROTO_UDP:
printf("icmp6: %s udp port %s unreachable",
ip6addr_string(&oip->ip6_dst),
udpport_string(dport));
break;
default:
printf("icmp6: %s protocol %d port %d unreachable",
ip6addr_string(&oip->ip6_dst),
oip->ip6_nxt, dport);
break;
}
break;
default:
printf("icmp6: %s unreachable code-#%d",
ip6addr_string(&oip->ip6_dst),
dp->icmp6_code);
break;
}
break;
case ICMP6_PACKET_TOO_BIG:
TCHECK(dp->icmp6_mtu);
printf("icmp6: too big %u\n", (u_int32_t)ntohl(dp->icmp6_mtu));
break;
case ICMP6_TIME_EXCEEDED:
TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
case ICMP6_TIME_EXCEED_TRANSIT:
printf("icmp6: time exceeded in-transit for %s",
ip6addr_string(&oip->ip6_dst));
break;
case ICMP6_TIME_EXCEED_REASSEMBLY:
printf("icmp6: ip6 reassembly time exceeded");
break;
default:
printf("icmp6: time exceeded code-#%d",
dp->icmp6_code);
break;
}
break;
case ICMP6_PARAM_PROB:
TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
case ICMP6_PARAMPROB_HEADER:
printf("icmp6: parameter problem errorneous - octet %u\n",
(u_int32_t)ntohl(dp->icmp6_pptr));
break;
case ICMP6_PARAMPROB_NEXTHEADER:
printf("icmp6: parameter problem next header - octet %u\n",
(u_int32_t)ntohl(dp->icmp6_pptr));
break;
case ICMP6_PARAMPROB_OPTION:
printf("icmp6: parameter problem option - octet %u\n",
(u_int32_t)ntohl(dp->icmp6_pptr));
break;
default:
printf("icmp6: parameter problem code-#%d",
dp->icmp6_code);
break;
}
break;
case ICMP6_ECHO_REQUEST:
printf("icmp6: echo request");
break;
case ICMP6_ECHO_REPLY:
printf("icmp6: echo reply");
break;
case ICMP6_MEMBERSHIP_QUERY:
printf("icmp6: multicast listener query ");
mld6_print((const u_char *)dp);
break;
case ICMP6_MEMBERSHIP_REPORT:
printf("icmp6: multicast listener report ");
mld6_print((const u_char *)dp);
break;
case ICMP6_MEMBERSHIP_REDUCTION:
printf("icmp6: multicast listener done ");
mld6_print((const u_char *)dp);
break;
case ND_ROUTER_SOLICIT:
printf("icmp6: router solicitation ");
if (vflag) {
#define RTSOLLEN 8
icmp6_opt_print((const u_char *)dp + RTSOLLEN,
icmp6len - RTSOLLEN);
}
break;
case ND_ROUTER_ADVERT:
printf("icmp6: router advertisement");
if (vflag) {
struct nd_router_advert *p;
p = (struct nd_router_advert *)dp;
TCHECK(p->nd_ra_retransmit);
printf("(chlim=%d, ", (int)p->nd_ra_curhoplimit);
if (p->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED)
printf("M");
if (p->nd_ra_flags_reserved & ND_RA_FLAG_OTHER)
printf("O");
if (p->nd_ra_flags_reserved != 0)
printf(" ");
printf("router_ltime=%d, ", ntohs(p->nd_ra_router_lifetime));
printf("reachable_time=%u, ",
(u_int32_t)ntohl(p->nd_ra_reachable));
printf("retrans_time=%u)",
(u_int32_t)ntohl(p->nd_ra_retransmit));
#define RTADVLEN 16
icmp6_opt_print((const u_char *)dp + RTADVLEN,
icmp6len - RTADVLEN);
}
break;
case ND_NEIGHBOR_SOLICIT:
{
struct nd_neighbor_solicit *p;
p = (struct nd_neighbor_solicit *)dp;
TCHECK(p->nd_ns_target);
printf("icmp6: neighbor sol: who has %s",
ip6addr_string(&p->nd_ns_target));
if (vflag) {
#define NDSOLLEN 24
icmp6_opt_print((const u_char *)dp + NDSOLLEN,
icmp6len - NDSOLLEN);
}
}
break;
case ND_NEIGHBOR_ADVERT:
{
struct nd_neighbor_advert *p;
p = (struct nd_neighbor_advert *)dp;
TCHECK(p->nd_na_target);
printf("icmp6: neighbor adv: tgt is %s",
ip6addr_string(&p->nd_na_target));
if (vflag) {
#define ND_NA_FLAG_ALL \
(ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
/* we don't need ntohl() here. see advanced-api-04. */
if (p->nd_na_flags_reserved & ND_NA_FLAG_ALL) {
#undef ND_NA_FLAG_ALL
u_int32_t flags;
flags = p->nd_na_flags_reserved;
printf("(");
if (flags & ND_NA_FLAG_ROUTER)
printf("R");
if (flags & ND_NA_FLAG_SOLICITED)
printf("S");
if (flags & ND_NA_FLAG_OVERRIDE)
printf("O");
printf(")");
}
#define NDADVLEN 24
icmp6_opt_print((const u_char *)dp + NDADVLEN,
icmp6len - NDADVLEN);
}
}
break;
case ND_REDIRECT:
{
#define RDR(i) ((struct nd_redirect *)(i))
char tgtbuf[INET6_ADDRSTRLEN], dstbuf[INET6_ADDRSTRLEN];
TCHECK(RDR(dp)->nd_rd_dst);
inet_ntop(AF_INET6, &RDR(dp)->nd_rd_target,
tgtbuf, INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &RDR(dp)->nd_rd_dst,
dstbuf, INET6_ADDRSTRLEN);
printf("icmp6: redirect %s to %s", dstbuf, tgtbuf);
#define REDIRECTLEN 40
if (vflag) {
icmp6_opt_print((const u_char *)dp + REDIRECTLEN,
icmp6len - REDIRECTLEN);
}
break;
}
case ICMP6_ROUTER_RENUMBERING:
switch (dp->icmp6_code) {
case ICMP6_ROUTER_RENUMBERING_COMMAND:
printf("icmp6: router renum command");
break;
case ICMP6_ROUTER_RENUMBERING_RESULT:
printf("icmp6: router renum result");
break;
default:
printf("icmp6: router renum code-#%d", dp->icmp6_code);
break;
}
break;
#ifdef ICMP6_WRUREQUEST
case ICMP6_WRUREQUEST: /*ICMP6_FQDN_QUERY*/
{
int siz;
siz = ep - (u_char *)(dp + 1);
if (siz == 4)
printf("icmp6: who-are-you request");
else {
printf("icmp6: FQDN request");
if (vflag) {
if (siz < 8)
printf("?(icmp6_data %d bytes)", siz);
else if (8 < siz)
printf("?(extra %d bytes)", siz - 8);
}
}
break;
}
#endif /*ICMP6_WRUREQUEST*/
#ifdef ICMP6_WRUREPLY
case ICMP6_WRUREPLY: /*ICMP6_FQDN_REPLY*/
{
enum { UNKNOWN, WRU, FQDN } mode = UNKNOWN;
u_char const *buf;
u_char const *cp = NULL;
buf = (u_char *)(dp + 1);
/* fair guess */
if (buf[12] == ep - buf - 13)
mode = FQDN;
else if (dp->icmp6_code == 1)
mode = FQDN;
/* wild guess */
if (mode == UNKNOWN) {
cp = buf + 4;
while (cp < ep) {
if (!isprint(*cp++))
mode = FQDN;
}
}
#ifndef abs
#define abs(a) ((0 < (a)) ? (a) : -(a))
#endif
if (mode == UNKNOWN && 2 < abs(buf[12] - (ep - buf - 13)))
mode = WRU;
if (mode == UNKNOWN)
mode = FQDN;
if (mode == WRU) {
cp = buf + 4;
printf("icmp6: who-are-you reply(\"");
} else if (mode == FQDN) {
cp = buf + 13;
printf("icmp6: FQDN reply(\"");
}
for (; cp < ep; cp++)
printf((isprint(*cp) ? "%c" : "\\%03o"), *cp);
printf("\"");
if (vflag) {
printf(",%s", mode == FQDN ? "FQDN" : "WRU");
if (mode == FQDN) {
long ttl;
ttl = (long)ntohl(*(u_long *)&buf[8]);
if (dp->icmp6_code == 1)
printf(",TTL=unknown");
else if (ttl < 0)
printf(",TTL=%ld:invalid", ttl);
else
printf(",TTL=%ld", ttl);
if (buf[12] != ep - buf - 13) {
(void)printf(",invalid namelen:%d/%u",
buf[12],
(unsigned int)(ep - buf - 13));
}
}
}
printf(")");
break;
}
#endif /*ICMP6_WRUREPLY*/
default:
printf("icmp6: type-#%d", dp->icmp6_type);
break;
}
return;
trunc:
fputs("[|icmp6]", stdout);
#if 0
#undef TCHECK
#endif
}
void
icmp6_opt_print(register const u_char *bp, int resid)
{
register const struct nd_opt_hdr *op;
register const struct nd_opt_hdr *opl; /* why there's no struct? */
register const struct nd_opt_prefix_info *opp;
register const struct icmp6_opts_redirect *opr;
register const struct nd_opt_mtu *opm;
register const u_char *ep;
int opts_len;
#if 0
register const struct ip6_hdr *ip;
register const char *str;
register const struct ip6_hdr *oip;
register const struct udphdr *ouh;
register int hlen, dport;
char buf[256];
#endif
#if 0
#define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
#endif
#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
op = (struct nd_opt_hdr *)bp;
#if 0
ip = (struct ip6_hdr *)bp2;
oip = &dp->icmp6_ip6;
str = buf;
#endif
/* 'ep' points to the end of avaible data. */
ep = snapend;
ECHECK(op->nd_opt_len);
if (resid <= 0)
return;
switch(op->nd_opt_type) {
case ND_OPT_SOURCE_LINKADDR:
opl = (struct nd_opt_hdr *)op;
#if 1
if ((u_char *)opl + (opl->nd_opt_len << 3) > ep)
goto trunc;
#else
TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
#endif
printf("(src lladdr: %s",
etheraddr_string((u_char *)(opl + 1)));
if (opl->nd_opt_len != 1)
printf("!");
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
case ND_OPT_TARGET_LINKADDR:
opl = (struct nd_opt_hdr *)op;
#if 1
if ((u_char *)opl + (opl->nd_opt_len << 3) > ep)
goto trunc;
#else
TCHECK((u_char *)opl + (opl->nd_opt_len << 3) - 1);
#endif
printf("(tgt lladdr: %s",
etheraddr_string((u_char *)(opl + 1)));
if (opl->nd_opt_len != 1)
printf("!");
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
case ND_OPT_PREFIX_INFORMATION:
opp = (struct nd_opt_prefix_info *)op;
TCHECK(opp->nd_opt_pi_prefix);
printf("(prefix info: ");
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)
printf("L");
if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)
printf("A");
if (opp->nd_opt_pi_flags_reserved)
printf(" ");
printf("valid_ltime=");
if ((u_int32_t)ntohl(opp->nd_opt_pi_valid_time) == ~0U)
printf("infinity");
else {
printf("%u", (u_int32_t)ntohl(opp->nd_opt_pi_valid_time));
}
printf(", ");
printf("preffered_ltime=");
if ((u_int32_t)ntohl(opp->nd_opt_pi_preferred_time) == ~0U)
printf("infinity");
else {
printf("%u", (u_int32_t)ntohl(opp->nd_opt_pi_preferred_time));
}
printf(", ");
printf("prefix=%s/%d", ip6addr_string(&opp->nd_opt_pi_prefix),
opp->nd_opt_pi_prefix_len);
if (opp->nd_opt_pi_len != 4)
printf("!");
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
case ND_OPT_REDIRECTED_HEADER:
opr = (struct icmp6_opts_redirect *)op;
printf("(redirect)");
/* xxx */
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
case ND_OPT_MTU:
opm = (struct nd_opt_mtu *)op;
TCHECK(opm->nd_opt_mtu_mtu);
printf("(mtu: ");
printf("mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu));
if (opm->nd_opt_mtu_len != 1)
printf("!");
printf(")");
icmp6_opt_print((const u_char *)op + (op->nd_opt_len << 3),
resid - (op->nd_opt_len << 3));
break;
default:
opts_len = op->nd_opt_len;
printf("(unknwon opt_type=%d, opt_len=%d)",
op->nd_opt_type, opts_len);
if (opts_len == 0)
opts_len = 1; /* XXX */
icmp6_opt_print((const u_char *)op + (opts_len << 3),
resid - (opts_len << 3));
break;
}
return;
trunc:
fputs("[ndp opt]", stdout);
return;
#if 0
#undef TCHECK
#endif
#undef ECHECK
}
void
mld6_print(register const u_char *bp)
{
register struct mld6_hdr *mp = (struct mld6_hdr *)bp;
register const u_char *ep;
/* 'ep' points to the end of avaible data. */
ep = snapend;
if ((u_char *)mp + sizeof(*mp) > ep)
return;
printf("max resp delay: %d ", ntohs(mp->mld6_maxdelay));
printf("addr: %s", ip6addr_string(&mp->mld6_addr));
return;
}
#endif /* INET6 */

View file

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

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

@ -0,0 +1,228 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.2.2.1 2000/01/11 06:58:25 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef INET6
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
#ifdef __STDC__
#include <stdlib.h>
#endif
#include <unistd.h>
#include "interface.h"
#include "addrtoname.h"
#include <netinet/ip6.h>
/*
* print an IP6 datagram.
*/
void
ip6_print(register const u_char *bp, register int length)
{
register const struct ip6_hdr *ip6;
register int hlen;
register int len;
register const u_char *cp;
int nh;
u_int flow;
ip6 = (const struct ip6_hdr *)bp;
#ifdef TCPDUMP_ALIGN
/*
* The IP header is not word aligned, so copy into abuf.
* This will never happen with BPF. It does happen raw packet
* dumps from -r.
*/
if ((int)ip & (sizeof(long)-1)) {
static u_char *abuf;
if (abuf == 0)
abuf = (u_char *)malloc(snaplen);
bcopy((char *)ip, (char *)abuf, min(length, snaplen));
snapend += abuf - (u_char *)ip;
packetp = abuf;
ip = (struct ip6_hdr *)abuf;
}
#endif
if ((u_char *)(ip6 + 1) > snapend) {
printf("[|ip6]");
return;
}
if (length < sizeof (struct ip6_hdr)) {
(void)printf("truncated-ip6 %d", length);
return;
}
hlen = sizeof(struct ip6_hdr);
len = ntohs(ip6->ip6_plen);
if (length < len + hlen)
(void)printf("truncated-ip6 - %d bytes missing!",
len + hlen - length);
cp = (const u_char *)ip6;
nh = ip6->ip6_nxt;
while (cp < snapend) {
cp += hlen;
if (cp == (u_char *)(ip6 + 1)
&& nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
(void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src),
ip6addr_string(&ip6->ip6_dst));
}
switch (nh) {
case IPPROTO_HOPOPTS:
hlen = hbhopt_print(cp);
nh = *cp;
break;
case IPPROTO_DSTOPTS:
hlen = dstopt_print(cp);
nh = *cp;
break;
case IPPROTO_FRAGMENT:
hlen = frag6_print(cp, (const u_char *)ip6);
if (snapend <= cp + hlen)
goto end;
nh = *cp;
break;
case IPPROTO_ROUTING:
hlen = rt6_print(cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_TCP:
tcp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
(const u_char *)ip6);
goto end;
case IPPROTO_UDP:
udp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
(const u_char *)ip6);
goto end;
case IPPROTO_ICMPV6:
icmp6_print(cp, (const u_char *)ip6);
goto end;
case IPPROTO_AH:
hlen = ah_print(cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_ESP:
{
int enh;
cp += esp_print(cp, (const u_char *)ip6, &enh);
if (enh < 0)
goto end;
nh = enh & 0xff;
break;
}
#ifndef IPPROTO_IPCOMP
#define IPPROTO_IPCOMP 108
#endif
case IPPROTO_IPCOMP:
{
int enh;
cp += ipcomp_print(cp, (const u_char *)ip6, &enh);
if (enh < 0)
goto end;
nh = enh & 0xff;
break;
}
case IPPROTO_PIM:
(void)printf("PIM");
pim_print(cp, len);
goto end;
#ifndef IPPROTO_OSPF
#define IPPROTO_OSPF 89
#endif
case IPPROTO_OSPF:
ospf6_print(cp, len);
goto end;
case IPPROTO_IPV6:
ip6_print(cp, len);
goto end;
#ifndef IPPROTO_IPV4
#define IPPROTO_IPV4 4
#endif
case IPPROTO_IPV4:
ip_print(cp, len);
goto end;
case IPPROTO_NONE:
(void)printf("no next header");
goto end;
default:
(void)printf("ip-proto-%d %d", ip6->ip6_nxt, len);
goto end;
}
}
end:
flow = ntohl(ip6->ip6_flow);
#if 0
/* rfc1883 */
if (flow & 0x0f000000)
(void)printf(" [pri 0x%x]", (flow & 0x0f000000) >> 24);
if (flow & 0x00ffffff)
(void)printf(" [flowlabel 0x%x]", flow & 0x00ffffff);
#else
/* RFC 2460 */
if (flow & 0x0ff00000)
(void)printf(" [class 0x%x]", (flow & 0x0ff00000) >> 20);
if (flow & 0x000fffff)
(void)printf(" [flowlabel 0x%x]", flow & 0x000fffff);
#endif
if (ip6->ip6_hlim <= 1)
(void)printf(" [hlim %d]", (int)ip6->ip6_hlim);
if (vflag) {
printf(" (");
(void)printf("len %d", len);
if (ip6->ip6_hlim > 1)
(void)printf(", hlim %d", (int)ip6->ip6_hlim);
printf(")");
}
}
#endif /* INET6 */

View file

@ -0,0 +1,162 @@
/*
* Copyright (C) 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.2.2.1 2000/01/11 06:58:25 fenner Exp $";
#endif
#ifdef INET6
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <stdio.h>
#include "interface.h"
#include "addrtoname.h"
void
ip6_opt_print(const u_char *bp, int len)
{
int i;
int optlen;
for (i = 0; i < len; i += optlen) {
switch (bp[i]) {
case IP6OPT_PAD1:
optlen = 1;
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
printf("(padn: trunc)");
goto trunc;
}
optlen = bp[i + 1] + 2;
break;
case IP6OPT_RTALERT:
if (len - i < IP6OPT_RTALERT_LEN) {
printf("(rtalert: trunc)");
goto trunc;
}
if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) {
printf("(rtalert: invalid len %d)", bp[i + 1]);
goto trunc;
}
printf("(rtalert: 0x%04x) ", ntohs(*(u_short *)&bp[i + 2]));
optlen = IP6OPT_RTALERT_LEN;
break;
case IP6OPT_JUMBO:
if (len - i < IP6OPT_JUMBO_LEN) {
printf("(jumbo: trunc)");
goto trunc;
}
if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) {
printf("(jumbo: invalid len %d)", bp[i + 1]);
goto trunc;
}
printf("(jumbo: %u) ", (u_int32_t)ntohl(*(u_int *)&bp[i + 2]));
optlen = IP6OPT_JUMBO_LEN;
break;
default:
if (len - i < IP6OPT_MINLEN) {
printf("(type %d: trunc)", bp[i]);
goto trunc;
}
printf("(type 0x%02x: len=%d) ", bp[i], bp[i + 1]);
optlen = bp[i + 1] + 2;
break;
}
}
#if 0
end:
#endif
return;
trunc:
printf("[trunc] ");
}
int
hbhopt_print(register const u_char *bp)
{
const struct ip6_hbh *dp = (struct ip6_hbh *)bp;
register const u_char *ep;
int hbhlen = 0;
/* 'ep' points to the end of avaible data. */
ep = snapend;
TCHECK(dp->ip6h_len);
hbhlen = (int)((dp->ip6h_len + 1) << 3);
TCHECK2(dp, hbhlen);
printf("HBH ");
if (vflag)
ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
return(hbhlen);
trunc:
fputs("[|HBH]", stdout);
return(hbhlen);
}
int
dstopt_print(register const u_char *bp)
{
const struct ip6_dest *dp = (struct ip6_dest *)bp;
register const u_char *ep;
int dstoptlen = 0;
/* 'ep' points to the end of avaible data. */
ep = snapend;
TCHECK(dp->ip6d_len);
dstoptlen = (int)((dp->ip6d_len + 1) << 3);
TCHECK2(dp, dstoptlen);
printf("DSTOPT ");
if (vflag) {
ip6_opt_print((const u_char *)dp + sizeof(*dp),
dstoptlen - sizeof(*dp));
}
return(dstoptlen);
trunc:
fputs("[|DSTOPT]", stdout);
return(dstoptlen);
}
#endif /* INET6 */

View file

@ -0,0 +1,112 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.2.2.2 2000/01/25 18:31:10 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
#ifdef INET6
#include <netinet/ip6.h>
#endif
struct ipcomp {
u_int8_t comp_nxt; /* Next Header */
u_int8_t comp_flags; /* Length of data, in 32bit */
u_int16_t comp_cpi; /* Compression parameter index */
};
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
#include <zlib.h>
#endif
#include "interface.h"
#include "addrtoname.h"
int
ipcomp_print(register const u_char *bp, register const u_char *bp2, int *nhdr)
{
register const struct ipcomp *ipcomp;
register const u_char *ep;
u_int16_t cpi;
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
int advance;
#endif
ipcomp = (struct ipcomp *)bp;
cpi = (u_int16_t)ntohs(ipcomp->comp_cpi);
/* 'ep' points to the end of avaible data. */
ep = snapend;
if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
fputs("[|IPCOMP]", stdout);
goto fail;
}
printf("IPComp(cpi=%u)", cpi);
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
if (1)
goto fail;
/*
* We may want to decompress the packet here. Packet buffer
* management is a headache (if we decompress, packet will become
* larger).
*/
if (nhdr)
*nhdr = ipcomp->comp_nxt;
advance = sizeof(struct ipcomp);
printf(": ");
return advance;
#endif
fail:
if (nhdr)
*nhdr = -1;
return 65536;
}

File diff suppressed because it is too large Load diff

View file

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

View file

@ -0,0 +1,716 @@
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* L2TP support contributed by Motonori Shindo (mshindo@ascend.co.jp)
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.6 1999/12/22 06:27:21 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "l2tp.h"
#include "interface.h"
static char tstr[] = " [|l2tp]";
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
static char *l2tp_message_type_string[] = {
"RESERVED_0", /* 0 Reserved */
"SCCRQ", /* 1 Start-Control-Connection-Request */
"SCCRP", /* 2 Start-Control-Connection-Reply */
"SCCCN", /* 3 Start-Control-Connection-Connected */
"StopCCN", /* 4 Stop-Control-Connection-Notification */
"RESERVED_5", /* 5 Reserved */
"HELLO", /* 6 Hello */
"OCRQ", /* 7 Outgoing-Call-Request */
"OCRP", /* 8 Outgoing-Call-Reply */
"OCCN", /* 9 Outgoing-Call-Connected */
"ICRQ", /* 10 Incoming-Call-Request */
"ICRP", /* 11 Incoming-Call-Reply */
"ICCN", /* 12 Incoming-Call-Connected */
"RESERVED_13", /* 13 Reserved */
"CDN", /* 14 Call-Disconnect-Notify */
"WEN", /* 15 WAN-Error-Notify */
"SLI" /* 16 Set-Link-Info */
#define L2TP_MAX_MSGTYPE_INDEX 17
};
static void l2tp_msgtype_print(const u_char *dat, u_int length);
static void l2tp_result_code_print(const u_char *dat, u_int length);
static void l2tp_proto_ver_print(const u_char *dat, u_int length);
static void l2tp_framing_cap_print(const u_char *dat, u_int length);
static void l2tp_bearer_cap_print(const u_char *dat, u_int length);
static void l2tp_tie_breaker_print(const u_char *dat, u_int length);
static void l2tp_firm_ver_print(const u_char *dat, u_int length);
static void l2tp_host_name_print(const u_char *dat, u_int length);
static void l2tp_vendor_name_print(const u_char *dat, u_int length);
static void l2tp_assnd_tun_id_print(const u_char *dat, u_int length);
static void l2tp_recv_win_size_print(const u_char *dat, u_int length);
static void l2tp_challenge_print(const u_char *dat, u_int length);
static void l2tp_q931_cc_print(const u_char *dat, u_int length);
static void l2tp_challenge_resp_print(const u_char *dat, u_int length);
static void l2tp_assnd_sess_id_print(const u_char *dat, u_int length);
static void l2tp_call_ser_num_print(const u_char *dat, u_int length);
static void l2tp_minimum_bps_print(const u_char *dat, u_int length);
static void l2tp_maximum_bps_print(const u_char *dat, u_int length);
static void l2tp_bearer_type_print(const u_char *dat, u_int length);
static void l2tp_framing_type_print(const u_char *dat, u_int length);
static void l2tp_packet_proc_delay_print(const u_char *dat, u_int length);
static void l2tp_called_number_print(const u_char *dat, u_int length);
static void l2tp_calling_number_print(const u_char *dat, u_int length);
static void l2tp_sub_address_print(const u_char *dat, u_int length);
static void l2tp_tx_conn_speed_print(const u_char *dat, u_int length);
static void l2tp_phy_channel_id_print(const u_char *dat, u_int length);
static void l2tp_ini_recv_lcp_print(const u_char *dat, u_int length);
static void l2tp_last_sent_lcp_print(const u_char *dat, u_int length);
static void l2tp_last_recv_lcp_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_type_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_name_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_chal_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_id_print(const u_char *dat, u_int length);
static void l2tp_proxy_auth_resp_print(const u_char *dat, u_int length);
static void l2tp_call_errors_print(const u_char *dat, u_int length);
static void l2tp_accm_print(const u_char *dat, u_int length);
static void l2tp_random_vector_print(const u_char *dat, u_int length);
static void l2tp_private_grp_id_print(const u_char *dat, u_int length);
static void l2tp_rx_conn_speed_print(const u_char *dat, u_int length);
static void l2tp_seq_required_print(const u_char *dat, u_int length);
static void l2tp_avp_print(const u_char *dat, u_int length);
static struct l2tp_avp_vec l2tp_avp[] = {
{"MSGTYPE", l2tp_msgtype_print}, /* 0 Message Type */
{"RESULT_CODE", l2tp_result_code_print}, /* 1 Result Code */
{"PROTO_VER", l2tp_proto_ver_print}, /* 2 Protocol Version */
{"FRAMING_CAP", l2tp_framing_cap_print}, /* 3 Framing Capabilities */
{"BEARER_CAP", l2tp_bearer_cap_print}, /* 4 Bearer Capabilities */
{"TIE_BREAKER", l2tp_tie_breaker_print}, /* 5 Tie Breaker */
{"FIRM_VER", l2tp_firm_ver_print}, /* 6 Firmware Revision */
{"HOST_NAME", l2tp_host_name_print}, /* 7 Host Name */
{"VENDOR_NAME", l2tp_vendor_name_print}, /* 8 Vendor Name */
{"ASSND_TUN_ID", l2tp_assnd_tun_id_print}, /* 9 Assigned Tunnel ID */
{"RECV_WIN_SIZE", l2tp_recv_win_size_print}, /* 10 Receive Window Size */
{"CHALLENGE", l2tp_challenge_print}, /* 11 Challenge */
{"Q931_CC", l2tp_q931_cc_print}, /* 12 Q.931 Cause Code */
{"CHALLENGE_RESP", l2tp_challenge_resp_print},/* 13 Challenge Response */
{"ASSND_SESS_ID", l2tp_assnd_sess_id_print}, /* 14 Assigned Session ID */
{"CALL_SER_NUM", l2tp_call_ser_num_print}, /* 15 Call Serial Number */
{"MINIMUM_BPS", l2tp_minimum_bps_print},/* 16 Minimum BPS */
{"MAXIMUM_BPS", l2tp_maximum_bps_print}, /* 17 Maximum BPS */
{"BEARER_TYPE", l2tp_bearer_type_print},/* 18 Bearer Type */
{"FRAMING_TYPE", l2tp_framing_type_print}, /* 19 Framing Type */
{"PACKET_PROC_DELAY", l2tp_packet_proc_delay_print}, /* 20 Packet Processing Delay (OBSOLETE) */
{"CALLED_NUMBER", l2tp_called_number_print}, /* 21 Called Number */
{"CALLING_NUMBER", l2tp_calling_number_print},/* 22 Calling Number */
{"SUB_ADDRESS", l2tp_sub_address_print},/* 23 Sub-Address */
{"TX_CONN_SPEED", l2tp_tx_conn_speed_print}, /* 24 (Tx) Connect Speed */
{"PHY_CHANNEL_ID", l2tp_phy_channel_id_print},/* 25 Physical Channel ID */
{"INI_RECV_LCP", l2tp_ini_recv_lcp_print}, /* 26 Initial Received LCP CONFREQ */
{"LAST_SENT_LCP", l2tp_last_sent_lcp_print}, /* 27 Last Sent LCP CONFREQ */
{"LAST_RECV_LCP", l2tp_last_recv_lcp_print}, /* 28 Last Received LCP CONFREQ */
{"PROXY_AUTH_TYPE", l2tp_proxy_auth_type_print},/* 29 Proxy Authen Type */
{"PROXY_AUTH_NAME", l2tp_proxy_auth_name_print},/* 30 Proxy Authen Name */
{"PROXY_AUTH_CHAL", l2tp_proxy_auth_chal_print},/* 31 Proxy Authen Challenge */
{"PROXY_AUTH_ID", l2tp_proxy_auth_id_print}, /* 32 Proxy Authen ID */
{"PROXY_AUTH_RESP", l2tp_proxy_auth_resp_print},/* 33 Proxy Authen Response */
{"CALL_ERRORS", l2tp_call_errors_print}, /* 34 Call Errors */
{"ACCM", l2tp_accm_print}, /* 35 ACCM */
{"RANDOM_VECTOR", l2tp_random_vector_print}, /* 36 Random Vector */
{"PRIVATE_GRP_ID", l2tp_private_grp_id_print},/* 37 Private Group ID */
{"RX_CONN_SPEED", l2tp_rx_conn_speed_print}, /* 38 (Rx) Connect Speed */
{"SEQ_REQUIRED", l2tp_seq_required_print}, /* 39 Sequencing Required */
#define L2TP_MAX_AVP_INDEX 40
};
#if 0
static char *l2tp_result_code_StopCCN[] = {
"Reserved",
"General request to clear control connection",
"General error--Error Code indicates the problem",
"Control channel already exists",
"Requester is not authorized to establish a control channel",
"The protocol version of the requester is not supported",
"Requester is being shut down",
"Finite State Machine error"
#define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8
};
#endif
#if 0
static char *l2tp_result_code_CDN[] = {
"Reserved",
"Call disconnected due to loss of carrier",
"Call disconnected for the reason indicated in error code",
"Call disconnected for administrative reasons",
"Call failed due to lack of appropriate facilities being " \
"available (temporary condition)",
"Call failed due to lack of appropriate facilities being " \
"available (permanent condition)",
"Invalid destination",
"Call failed due to no carrier detected",
"Call failed due to detection of a busy signal",
"Call failed due to lack of a dial tone",
"Call was not established within time allotted by LAC",
"Call was connected but no appropriate framing was detected"
#define L2TP_MAX_RESULT_CODE_CDN_INDEX 12
};
#endif
#if 0
static char *l2tp_error_code_general[] = {
"No general error",
"No control connection exists yet for this LAC-LNS pair",
"Length is wrong",
"One of the field values was out of range or " \
"reserved field was non-zero"
"Insufficient resources to handle this operation now",
"The Session ID is invalid in this context",
"A generic vendor-specific error occurred in the LAC",
"Try another"
#define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8
};
#endif
/******************************/
/* generic print out routines */
/******************************/
static void
print_string(const u_char *dat, u_int length)
{
int i;
for (i=0; i<length; i++) {
printf("%c", *dat++);
}
}
static void
print_octets(const u_char *dat, u_int length)
{
int i;
for (i=0; i<length; i++) {
printf("%02x", *dat++);
}
}
static void
print_short(const u_short *dat)
{
printf("%u", ntohs(*dat));
}
static void
print_int(const u_int *dat)
{
printf("%lu", (u_long)ntohl(*dat));
}
/**********************************/
/* AVP-specific print out routines*/
/**********************************/
static void
l2tp_msgtype_print(const u_char *dat, u_int length)
{
u_short *ptr = (u_short *)dat;
if (ntohs(*ptr) < L2TP_MAX_MSGTYPE_INDEX) {
printf("%s", l2tp_message_type_string[ntohs(*ptr)]);
}
}
static void
l2tp_result_code_print(const u_char *dat, u_int length)
{
/* we just print out the result and error code number */
u_short *ptr = (u_short *)dat;
if (length == 2) { /* result code */
printf("%u", ntohs(*ptr));
} else if (length == 4) { /* result & error code */
printf("%u/%u", ntohs(*ptr), ntohs(*(ptr+1)));
} else if (length > 4) { /* result & error code & msg */
printf("%u/%u ", ntohs(*ptr), ntohs(*(ptr+1)));
print_string((u_char *)(ptr+2), length - 4);
}
}
static void
l2tp_proto_ver_print(const u_char *dat, u_int length)
{
printf("%d.%d", *dat, *(dat+1));
}
static void
l2tp_framing_cap_print(const u_char *dat, u_int length)
{
u_int *ptr = (u_int *)dat;
if (ntohl(*ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) {
printf("A");
}
if (ntohl(*ptr) & L2TP_FRAMING_CAP_SYNC_MASK) {
printf("S");
}
}
static void
l2tp_bearer_cap_print(const u_char *dat, u_int length)
{
u_int *ptr = (u_int *)dat;
if (ntohl(*ptr) & L2TP_BEARER_CAP_ANALOG_MASK) {
printf("A");
}
if (ntohl(*ptr) & L2TP_BEARER_CAP_DIGITAL_MASK) {
printf("D");
}
}
static void
l2tp_tie_breaker_print(const u_char *dat, u_int length)
{
printf("%lx", *(u_long *)dat); /* XXX */
}
static void
l2tp_firm_ver_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
}
static void
l2tp_host_name_print(const u_char *dat, u_int length)
{
print_string(dat, length);
}
static void
l2tp_vendor_name_print(const u_char *dat, u_int length)
{
print_string(dat, length);
}
static void
l2tp_assnd_tun_id_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
}
static void
l2tp_recv_win_size_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
}
static void
l2tp_challenge_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_q931_cc_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
printf(", %02x", dat[2]);
if (length > 3) {
printf(" ");
print_string(dat+3, length-3);
}
}
static void
l2tp_challenge_resp_print(const u_char *dat, u_int length)
{
print_octets(dat, 16); /* XXX length should be 16? */
}
static void
l2tp_assnd_sess_id_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
}
static void
l2tp_call_ser_num_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_minimum_bps_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_maximum_bps_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_bearer_type_print(const u_char *dat, u_int length)
{
u_int *ptr = (u_int *)dat;
if (ntohl(*ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) {
printf("A");
}
if (ntohl(*ptr) & L2TP_BEARER_TYPE_DIGITAL_MASK) {
printf("D");
}
}
static void
l2tp_framing_type_print(const u_char *dat, u_int length)
{
u_int *ptr = (u_int *)dat;
if (ntohl(*ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
printf("A");
}
if (ntohl(*ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) {
printf("S");
}
}
static void
l2tp_packet_proc_delay_print(const u_char *dat, u_int length)
{
printf("obsolete");
}
static void
l2tp_called_number_print(const u_char *dat, u_int length)
{
print_string(dat, length);
}
static void
l2tp_calling_number_print(const u_char *dat, u_int length)
{
print_string(dat, length);
}
static void
l2tp_sub_address_print(const u_char *dat, u_int length)
{
print_string(dat, length);
}
static void
l2tp_tx_conn_speed_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_phy_channel_id_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_ini_recv_lcp_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_last_sent_lcp_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_last_recv_lcp_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_proxy_auth_type_print(const u_char *dat, u_int length)
{
u_short *ptr = (u_short *)dat;
switch (ntohs(*ptr)) {
case L2TP_AUTHEN_TYPE_RESERVED:
printf("Reserved");
break;
case L2TP_AUTHEN_TYPE_TEXTUAL:
printf("Textual");
break;
case L2TP_AUTHEN_TYPE_CHAP:
printf("CHAP");
break;
case L2TP_AUTHEN_TYPE_PAP:
printf("PAP");
break;
case L2TP_AUTHEN_TYPE_NO_AUTH:
printf("No Auth");
break;
case L2TP_AUTHEN_TYPE_MSCHAP:
printf("MS-CHAP");
break;
default:
printf("unknown");
}
}
static void
l2tp_proxy_auth_name_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_proxy_auth_chal_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_proxy_auth_id_print(const u_char *dat, u_int length)
{
u_short *ptr = (u_short *)dat;
printf("%u", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);
}
static void
l2tp_proxy_auth_resp_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_call_errors_print(const u_char *dat, u_int length)
{
struct l2tp_call_errors *ptr = (struct l2tp_call_errors *)dat;
printf("CRCErr=%d FrameErr=%d HardOver=%d BufOver=%d ",
ptr->crc_errs,
ptr->framing_errs,
ptr->hardware_overruns,
ptr->buffer_overruns);
printf("Timeout=%d AlingErr=%d",
ptr->timeout_errs,
ptr->alignment_errs);
}
static void
l2tp_accm_print(const u_char *dat, u_int length)
{
struct l2tp_accm *ptr = (struct l2tp_accm *)dat;
printf("send=%x recv=%x", ptr->send_accm, ptr->recv_accm);
}
static void
l2tp_random_vector_print(const u_char *dat, u_int length)
{
print_octets(dat, length);
}
static void
l2tp_private_grp_id_print(const u_char *dat, u_int length)
{
print_string(dat, length);
/* XXX print_octets is more appropriate?? */
}
static void
l2tp_rx_conn_speed_print(const u_char *dat, u_int length)
{
print_int((u_int *)dat);
}
static void
l2tp_seq_required_print(const u_char *dat, u_int length)
{
return;
}
static void
l2tp_avp_print(const u_char *dat, u_int length)
{
u_int len;
const u_short *ptr = (u_short *)dat;
int hidden = FALSE;
printf(" ");
if (length > 0 && (snapend - dat) >= 2) {
/* there must be at least two octets for the length
to be decoded */
if ((len = (ntohs(*ptr) & L2TP_AVP_HDR_LEN_MASK)) <=
(snapend - dat)) {
if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
printf("*");
}
if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
hidden = TRUE;
printf("?");
}
} else {
printf("|...");
return;
}
ptr++;
if (ntohs(*ptr)) { /* IETF == 0 */
printf("vendor=%04x", ntohs(*ptr));
}
ptr++;
if (ntohs(*ptr) < L2TP_MAX_AVP_INDEX) {
printf("%s", l2tp_avp[ntohs(*ptr)].name);
printf("(");
if (!hidden) {
(l2tp_avp[ntohs(*ptr)].print)
((u_char *)ptr+2, len-6);
} else {
printf("???");
}
printf(")");
} else {
printf(" invalid AVP %u", ntohs(*ptr));
}
l2tp_avp_print(dat + len, length - len);
} else if (length == 0) {
return;
} else {
printf("|...");
}
}
void
l2tp_print(const u_char *dat, u_int length)
{
const u_short *ptr = (u_short *)dat;
u_int cnt = 0; /* total octets consumed */
u_short pad;
int flag_t, flag_l, flag_s, flag_o, flag_p;
u_short l2tp_len;
flag_t = flag_l = flag_s = flag_o = flag_p = FALSE;
if (min(length, snapend - dat) - 6 < 0) {
/* flag/ver, tunnel_id, session_id must be present for
this packet to be properly decoded */
printf("%s", tstr);
return;
}
if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
printf(" l2tp:");
} else if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
printf(" l2f:");
return; /* nothing to do */
} else {
printf(" Unknown Version, neither L2F(1) nor L2TP(2)");
return; /* nothing we can do */
}
printf("[");
if (ntohs(*ptr) & L2TP_FLAG_TYPE) {
flag_t = TRUE;
printf("T");
}
if (ntohs(*ptr) & L2TP_FLAG_LENGTH) {
flag_l = TRUE;
printf("L");
}
if (ntohs(*ptr) & L2TP_FLAG_SEQUENCE) {
flag_s = TRUE;
printf("S");
}
if (ntohs(*ptr) & L2TP_FLAG_OFFSET) {
flag_o = TRUE;
printf("O");
}
if (ntohs(*ptr) & L2TP_FLAG_PRIORITY) {
flag_p = TRUE;
printf("P");
}
printf("]");
ptr++;
cnt += 2;
if (flag_l) {
l2tp_len = ntohs(*ptr++); /* XXX need to consider
truncation ?? */
cnt += 2;
} else {
l2tp_len = 0;
}
printf("(%u/", ntohs(*ptr++)); /* Tunnel ID */
printf("%u)", ntohs(*ptr++)); /* Session ID */
cnt += 4;
if (flag_s) {
printf("Ns=%u,", ntohs(*ptr++));
printf("Nr=%u", ntohs(*ptr++));
cnt += 4;
}
if (flag_o) {
pad = ntohs(*ptr++);
ptr += pad / sizeof(*ptr);
cnt += (2 + pad);
}
if (flag_t) {
if (length - cnt == 0) {
printf(" ZLB");
} else {
l2tp_avp_print((u_char *)ptr, length - cnt);
}
} else {
#if 0
printf(" {");
ppp_hdlc_print((u_char *)ptr, length - cnt);
printf("}");
#else
printf("[hdlc|]");
#endif
}
}

View file

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

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

@ -0,0 +1,226 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-lcp.c,v 1.3 1999/12/15 07:55:42 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#if __STDC__
struct mbuf;
struct rtentry;
#endif
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#include "ppp.h"
/* Codes */
enum {
LCP_CONFREQ = 1,
LCP_CONFACK = 2,
LCP_CONFNAK = 3,
LCP_CONFREJ = 4,
LCP_TERMREQ = 5,
LCP_TERMACK = 6,
LCP_CODEREJ = 7,
LCP_PROTREJ = 8,
LCP_ECHOREQ = 9,
LCP_ECHOREP = 10,
LCP_DISCARD = 11
};
static struct tok lcpcode2str[] = {
{ LCP_CONFREQ, "ConfReq" },
{ LCP_CONFACK, "ConfAck" },
{ LCP_CONFNAK, "ConfNak" },
{ LCP_CONFREJ, "ConfRej" },
{ LCP_TERMREQ, "TermReq" },
{ LCP_TERMACK, "TermAck" },
{ LCP_CODEREJ, "CodeRej" },
{ LCP_PROTREJ, "ProtRej" },
{ LCP_ECHOREQ, "EchoReq" },
{ LCP_ECHOREP, "EchoRep" },
{ LCP_DISCARD, "Discard" },
{ 0, NULL }
};
enum {
LCP_RESERVED = 0,
LCP_MRU = 1,
LCP_ASYNCMAP = 2,
LCP_AUTHPROTO = 3,
LCP_QUALPROTO = 4,
LCP_MAGICNUM = 5,
LCP_PCOMP = 7,
LCP_ACFCOMP = 8,
LCP_CALLBACK = 13
};
static struct tok lcpoption2str[] = {
{ LCP_RESERVED, "reserved"},
{ LCP_MRU, "mru"},
{ LCP_ASYNCMAP, "asyncmap"},
{ LCP_AUTHPROTO, "auth"},
{ LCP_QUALPROTO, "qual"},
{ LCP_MAGICNUM, "magic"},
{ LCP_PCOMP, "pcomp"},
{ LCP_ACFCOMP, "acfcomp"},
{ LCP_CALLBACK, "callback"},
{ 0, NULL }
};
static struct tok lcpauth2str[] = {
{0xc023, "PAP"},
{0xc223, "CHAP"},
{ 0, NULL }
};
static struct tok lcpqual2str[] = {
{0xc025, "LQR"},
{ 0, NULL }
};
static struct tok lcpchap2str[] = {
{0x05, "MD5"},
{0x80, "MS"},
{ 0, NULL }
};
void
lcp_print(register const u_char *bp, u_int length)
{
u_short lcp_code, lcp_id, lcp_length;
const u_char *lcp_data;
lcp_data = bp+4;
if (snapend < lcp_data) {
printf(" [LCP|]");
return;
}
lcp_code = bp[0];
lcp_id = bp[1];
lcp_length = EXTRACT_16BITS(bp+2);
printf("LCP %s id=0x%x", tok2str(lcpcode2str, "LCP-#%d", lcp_code), lcp_id);
switch(lcp_code) {
case LCP_CONFREQ:
case LCP_CONFACK:
case LCP_CONFNAK:
case LCP_CONFREJ:
/* Print Options */
{
u_char lcpopt_type, lcpopt_length;
const u_char *p=lcp_data;
while (p+2 < lcp_data+lcp_length && p+2 < snapend) {
lcpopt_type = p[0];
lcpopt_length = p[1];
p+=2;
printf(" <%s ",tok2str(lcpoption2str, "option-#%d", lcpopt_type));
if (lcpopt_length)
switch (lcpopt_type) {
case LCP_MRU:
if (snapend < p+2) return;
printf("%d",ntohs(*(u_short*)p));
if (lcpopt_length != 4) printf(" len=%d!",lcpopt_length);
break;
case LCP_AUTHPROTO:
if (snapend < p+2) return;
printf("%s",tok2str(lcpauth2str, "AUTH-%#x", ntohs(*(u_short*)p)));
if (lcpopt_length < 4) printf(" len=%d!",lcpopt_length);
if (lcpopt_length >= 5 && p < snapend)
printf(" %s",tok2str(lcpchap2str, "%#x", p[0]));
break;
case LCP_QUALPROTO:
if (snapend < p+2) return;
printf("%s",tok2str(lcpqual2str, "QUAL-%#x", ntohs(*(u_short*)p)));
if (lcpopt_length < 4) printf(" len=%d!",lcpopt_length);
/* Print data field of auth? */
break;
case LCP_ASYNCMAP:
case LCP_MAGICNUM:
if (snapend < p+4) return;
printf("%#x",ntohl(*(u_long*)p));
if (lcpopt_length != 6) printf(" len=%d!",lcpopt_length);
break;
case LCP_PCOMP:
case LCP_ACFCOMP:
case LCP_RESERVED:
if (lcpopt_length != 2) printf(" len=%d!",lcpopt_length);
break;
default:
if (lcpopt_length != 2) printf(" len=%d",lcpopt_length);
break;
}
printf(">");
p+=lcpopt_length-2;
}
}
break;
case LCP_ECHOREQ:
case LCP_ECHOREP:
case LCP_DISCARD:
if (snapend < lcp_data+4) return;
printf(" magic=%#x", ntohl(*(u_long *) lcp_data));
lcp_data +=4;
break;
case LCP_PROTREJ:
if (snapend < lcp_data+2) return;
printf(" prot=%s", tok2str(ppptype2str, "PROT-%#x", ntohs(*(u_short *) lcp_data)));
/* TODO print rejected packet too ? */
break;
case LCP_CODEREJ:
if (snapend < lcp_data+4) return;
printf(" ");
lcp_print(lcp_data, (lcp_length+lcp_data > snapend ? snapend-lcp_data : lcp_length));
break;
case LCP_TERMREQ:
case LCP_TERMACK:
break;
default:
break;
}
return;
}

View file

@ -0,0 +1,143 @@
/* $NetBSD: print-mobile.c,v 1.2 1998/09/30 08:57:01 hwr Exp $ */
/*
* (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Heiko W.Rupp <hwr@pilhuhn.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.2.2.1 2000/01/11 06:58:26 fenner Exp $";
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netdb.h>
#include <stdio.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#define MOBILE_SIZE (8)
struct mobile_ip {
u_int16_t proto;
u_int16_t hcheck;
u_int32_t odst;
u_int32_t osrc;
};
#define OSRC_PRES 0x0080 /* old source is present */
static u_int16_t mob_in_cksum(u_short *p, int len);
/*
* Deencapsulate and print a mobile-tunneled IP datagram
*/
void
mobile_print(const u_char *bp, u_int length)
{
const u_char *cp = bp +8 ;
const struct mobile_ip *mob;
u_short proto,crc;
u_char osp =0; /* old source address present */
mob = (const struct mobile_ip *)bp;
if (length < MOBILE_SIZE) {
fputs("[|mobile]", stdout);
return;
}
proto = EXTRACT_16BITS(&mob->proto);
crc = EXTRACT_16BITS(&mob->hcheck);
if (proto & OSRC_PRES) {
osp=1;
cp +=4 ;
}
if (osp) {
fputs("[S] ",stdout);
if (vflag)
(void)printf("%s ",ipaddr_string(&mob->osrc));
} else {
fputs("[] ",stdout);
}
if (vflag) {
(void)printf("> %s ",ipaddr_string(&mob->odst));
(void)printf("(oproto=%d)",proto>>8);
}
if (mob_in_cksum((u_short *)mob, osp ? 12 : 8)!=0) {
(void)printf(" (bad checksum %d)",crc);
}
return;
}
static u_int16_t mob_in_cksum(u_short *p, int len)
{
u_int32_t sum = 0;
int nwords = len >> 1;
while (nwords-- != 0)
sum += *p++;
if (len & 1) {
union {
u_int16_t w;
u_int8_t c[2];
} u;
u.c[0] = *(u_char *)p;
u.c[1] = 0;
sum += u.w;
}
/* end-around-carry */
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
return (~sum);
}

View file

@ -24,7 +24,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-netbios.c,v 1.10 96/12/10 23:25:12 leres Exp $";
"@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.13 1999/11/21 09:36:57 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>

View file

@ -23,7 +23,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-ospf.c,v 1.24 97/04/26 13:31:46 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.27 1999/11/21 09:36:58 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -507,9 +511,11 @@ ospf_print(register const u_char *bp, register u_int length,
op = (struct ospfhdr *)bp;
ip = (struct ip *)bp2;
/* Print the source and destination address */
#if 0
(void) printf("%s > %s:",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
#endif
/* XXX Before we do anything else, strip off the MD5 trailer */
TCHECK(op->ospf_authtype);

View file

@ -0,0 +1,668 @@
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.2 1999/11/21 09:36:58 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "ospf6.h"
struct bits {
u_int32_t bit;
const char *str;
};
static const struct bits ospf6_option_bits[] = {
{ OSPF6_OPTION_V6, "V6" },
{ OSPF6_OPTION_E, "E" },
{ OSPF6_OPTION_MC, "MC" },
{ OSPF6_OPTION_N, "N" },
{ OSPF6_OPTION_R, "R" },
{ OSPF6_OPTION_DC, "DC" },
{ 0, NULL }
};
static const struct bits ospf6_rla_flag_bits[] = {
{ RLA_FLAG_B, "B" },
{ RLA_FLAG_E, "E" },
{ RLA_FLAG_V, "V" },
{ RLA_FLAG_W, "W" },
{ 0, NULL }
};
static struct tok type2str[] = {
{ OSPF_TYPE_UMD, "umd" },
{ OSPF_TYPE_HELLO, "hello" },
{ OSPF_TYPE_DB, "dd" },
{ OSPF_TYPE_LSR, "ls_req" },
{ OSPF_TYPE_LSU, "ls_upd" },
{ OSPF_TYPE_LSA, "ls_ack" },
{ 0, NULL }
};
static char tstr[] = " [|ospf]";
/* Forwards */
static inline void ospf6_print_seqage(u_int32_t, time_t);
static inline void ospf6_print_bits(const struct bits *, u_char);
static void ospf6_print_ls_type(u_int, const rtrid_t *,
const rtrid_t *, const char *);
static int ospf6_print_lshdr(const struct lsa_hdr *);
static int ospf6_print_lsa(const struct lsa *);
static int ospf6_decode_v3(const struct ospf6hdr *, const u_char *);
static inline void
ospf6_print_seqage(register u_int32_t seq, register time_t us)
{
register time_t sec = us % 60;
register time_t mins = (us / 60) % 60;
register time_t hour = us / 3600;
printf(" S %X age ", seq);
if (hour)
printf("%u:%02u:%02u",
(u_int32_t) hour, (u_int32_t) mins, (u_int32_t) sec);
else if (mins)
printf("%u:%02u", (u_int32_t) mins, (u_int32_t) sec);
else
printf("%u", (u_int32_t) sec);
}
static inline void
ospf6_print_bits(register const struct bits *bp, register u_char options)
{
register char sep = ' ';
do {
if (options & bp->bit) {
printf("%c%s", sep, bp->str);
sep = '/';
}
} while ((++bp)->bit);
}
static void
ospf6_print_ls_type(register u_int ls_type,
register const rtrid_t *ls_stateid,
register const rtrid_t *ls_router, register const char *fmt)
{
char *scope;
switch (ls_type & LS_SCOPE_MASK) {
case LS_SCOPE_LINKLOCAL:
scope = "linklocal-";
break;
case LS_SCOPE_AREA:
scope = "area-";
break;
case LS_SCOPE_AS:
scope = "AS-";
break;
default:
scope = "";
break;
}
switch (ls_type & LS_TYPE_MASK) {
case LS_TYPE_ROUTER:
printf(" %srtr %s", scope, ipaddr_string(ls_router));
break;
case LS_TYPE_NETWORK:
printf(" %snet dr %s if %s", scope,
ipaddr_string(ls_router),
ipaddr_string(ls_stateid));
break;
case LS_TYPE_INTER_AP:
printf(" %sinter-area-prefix %s abr %s", scope,
ipaddr_string(ls_stateid),
ipaddr_string(ls_router));
break;
case LS_TYPE_INTER_AR:
printf(" %sinter-area-router %s rtr %s", scope,
ipaddr_string(ls_router),
ipaddr_string(ls_stateid));
break;
case LS_TYPE_ASE:
printf(" %sase %s asbr %s", scope,
ipaddr_string(ls_stateid),
ipaddr_string(ls_router));
break;
case LS_TYPE_GROUP:
printf(" %sgroup %s rtr %s", scope,
ipaddr_string(ls_stateid),
ipaddr_string(ls_router));
break;
case LS_TYPE_TYPE7:
printf(" %stype7 %s rtr %s", scope,
ipaddr_string(ls_stateid),
ipaddr_string(ls_router));
break;
case LS_TYPE_LINK:
printf(" %slink %s rtr %s", scope,
ipaddr_string(ls_stateid),
ipaddr_string(ls_router));
break;
case LS_TYPE_INTRA_AP:
printf(" %sintra-area-prefix %s rtr %s", scope,
ipaddr_string(ls_stateid),
ipaddr_string(ls_router));
break;
default:
printf(" %s", scope);
printf(fmt, ls_type);
break;
}
}
static int
ospf6_print_lshdr(register const struct lsa_hdr *lshp)
{
TCHECK(lshp->ls_type);
printf(" {"); /* } (ctags) */
TCHECK(lshp->ls_seq);
ospf6_print_seqage(ntohl(lshp->ls_seq), ntohs(lshp->ls_age));
ospf6_print_ls_type(ntohs(lshp->ls_type), &lshp->ls_stateid,
&lshp->ls_router, "ls_type %d");
return (0);
trunc:
return (1);
}
static int
ospf6_print_lsaprefix(register const struct lsa_prefix *lsapp)
{
int k;
struct in6_addr prefix;
TCHECK(*lsapp);
k = (lsapp->lsa_p_len + 31) / 32;
if (k * 4 > sizeof(struct in6_addr)) {
printf("??prefixlen %d??", lsapp->lsa_p_len);
goto trunc;
}
memset(&prefix, 0, sizeof(prefix));
memcpy(&prefix, lsapp->lsa_p_prefix, k * 4);
printf(" %s/%d", ip6addr_string(&prefix),
lsapp->lsa_p_len);
if (lsapp->lsa_p_opt)
printf("(opt=%x)", lsapp->lsa_p_opt);
return sizeof(*lsapp) - 4 + k * 4;
trunc:
return -1;
}
/*
* Print a single link state advertisement. If truncated return 1, else 0.
*/
static int
ospf6_print_lsa(register const struct lsa *lsap)
{
register const u_char *ls_end;
register const struct rlalink *rlp;
#if 0
register const struct tos_metric *tosp;
#endif
register const rtrid_t *ap;
#if 0
register const struct aslametric *almp;
register const struct mcla *mcp;
#endif
register const struct llsa *llsap;
register const struct lsa_prefix *lsapp;
#if 0
register const u_int32_t *lp;
#endif
register int j, k;
if (ospf6_print_lshdr(&lsap->ls_hdr))
return (1);
TCHECK(lsap->ls_hdr.ls_length);
ls_end = (u_char *)lsap + ntohs(lsap->ls_hdr.ls_length);
switch (ntohs(lsap->ls_hdr.ls_type)) {
case LS_TYPE_ROUTER | LS_SCOPE_AREA:
TCHECK(lsap->lsa_un.un_rla.rla_flags);
ospf6_print_bits(ospf6_rla_flag_bits,
lsap->lsa_un.un_rla.rla_flags);
TCHECK(lsap->lsa_un.un_rla.rla_options);
ospf6_print_bits(ospf6_option_bits,
ntohl(lsap->lsa_un.un_rla.rla_options));
TCHECK(lsap->lsa_un.un_rla.rla_link);
rlp = lsap->lsa_un.un_rla.rla_link;
while (rlp + sizeof(*rlp) <= (struct rlalink *)ls_end) {
TCHECK(*rlp);
printf(" {"); /* } (ctags) */
switch (rlp->link_type) {
case RLA_TYPE_VIRTUAL:
printf(" virt");
/* Fall through */
case RLA_TYPE_ROUTER:
printf(" nbrid %s nbrif %s if %s",
ipaddr_string(&rlp->link_nrtid),
ipaddr_string(&rlp->link_nifid),
ipaddr_string(&rlp->link_ifid));
break;
case RLA_TYPE_TRANSIT:
printf(" dr %s drif %s if %s",
ipaddr_string(&rlp->link_nrtid),
ipaddr_string(&rlp->link_nifid),
ipaddr_string(&rlp->link_ifid));
break;
default:
/* { (ctags) */
printf(" ??RouterLinksType 0x%02x?? }",
rlp->link_type);
return (0);
}
printf(" metric %d", ntohs(rlp->link_metric));
/* { (ctags) */
printf(" }");
rlp++;
}
break;
case LS_TYPE_NETWORK | LS_SCOPE_AREA:
TCHECK(lsap->lsa_un.un_nla.nla_options);
ospf6_print_bits(ospf6_option_bits,
ntohl(lsap->lsa_un.un_nla.nla_options));
printf(" rtrs");
ap = lsap->lsa_un.un_nla.nla_router;
while ((u_char *)ap < ls_end) {
TCHECK(*ap);
printf(" %s", ipaddr_string(ap));
++ap;
}
break;
case LS_TYPE_INTER_AP | LS_SCOPE_AREA:
TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
printf(" metric %u",
(u_int32_t)ntohl(lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC);
lsapp = lsap->lsa_un.un_inter_ap.inter_ap_prefix;
while (lsapp + sizeof(lsapp) <= (struct lsa_prefix *)ls_end) {
k = ospf6_print_lsaprefix(lsapp);
if (k < 0)
goto trunc;
lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
}
break;
#if 0
case LS_TYPE_SUM_ABR:
TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
lp = lsap->lsa_un.un_sla.sla_tosmetric;
while ((u_char *)lp < ls_end) {
register u_int32_t ul;
TCHECK(*lp);
ul = ntohl(*lp);
printf(" tos %d metric %d",
(ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS,
ul & SLA_MASK_METRIC);
++lp;
}
break;
case LS_TYPE_ASE:
TCHECK(lsap->lsa_un.un_nla.nla_mask);
printf(" mask %s",
ipaddr_string(&lsap->lsa_un.un_asla.asla_mask));
TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
almp = lsap->lsa_un.un_asla.asla_metric;
while ((u_char *)almp < ls_end) {
register u_int32_t ul;
TCHECK(almp->asla_tosmetric);
ul = ntohl(almp->asla_tosmetric);
printf(" type %d tos %d metric %d",
(ul & ASLA_FLAG_EXTERNAL) ? 2 : 1,
(ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS,
(ul & ASLA_MASK_METRIC));
TCHECK(almp->asla_forward);
if (almp->asla_forward.s_addr) {
printf(" forward %s",
ipaddr_string(&almp->asla_forward));
}
TCHECK(almp->asla_tag);
if (almp->asla_tag.s_addr) {
printf(" tag %s",
ipaddr_string(&almp->asla_tag));
}
++almp;
}
break;
case LS_TYPE_GROUP:
/* Multicast extensions as of 23 July 1991 */
mcp = lsap->lsa_un.un_mcla;
while ((u_char *)mcp < ls_end) {
TCHECK(mcp->mcla_vid);
switch (ntohl(mcp->mcla_vtype)) {
case MCLA_VERTEX_ROUTER:
printf(" rtr rtrid %s",
ipaddr_string(&mcp->mcla_vid));
break;
case MCLA_VERTEX_NETWORK:
printf(" net dr %s",
ipaddr_string(&mcp->mcla_vid));
break;
default:
printf(" ??VertexType %u??",
(u_int32_t)ntohl(mcp->mcla_vtype));
break;
}
++mcp;
}
#endif
case LS_TYPE_LINK:
/* Link LSA */
llsap = &lsap->lsa_un.un_llsa;
TCHECK(llsap->llsa_options);
ospf6_print_bits(ospf6_option_bits, ntohl(llsap->llsa_options));
TCHECK(llsap->llsa_nprefix);
printf(" pri %d lladdr %s npref %d", llsap->llsa_priority,
ip6addr_string(&llsap->llsa_lladdr),
(u_int32_t)ntohl(llsap->llsa_nprefix));
lsapp = llsap->llsa_prefix;
for (j = 0; j < ntohl(llsap->llsa_nprefix); j++) {
k = ospf6_print_lsaprefix(lsapp);
if (k < 0)
goto trunc;
lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
}
break;
case LS_TYPE_INTRA_AP | LS_SCOPE_AREA:
/* Intra-Area-Prefix LSA */
TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
ospf6_print_ls_type(
ntohs(lsap->lsa_un.un_intra_ap.intra_ap_lstype),
&lsap->lsa_un.un_intra_ap.intra_ap_lsid,
&lsap->lsa_un.un_intra_ap.intra_ap_rtid,
"LinkStateType %d");
TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
printf(" npref %d",
ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix));
lsapp = lsap->lsa_un.un_intra_ap.intra_ap_prefix;
for (j = 0;
j < ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
j++) {
k = ospf6_print_lsaprefix(lsapp);
if (k < 0)
goto trunc;
lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k);
}
break;
default:
printf(" ??LinkStateType 0x%04x??",
ntohs(lsap->ls_hdr.ls_type));
}
/* { (ctags) */
fputs(" }", stdout);
return (0);
trunc:
fputs(" }", stdout);
return (1);
}
static int
ospf6_decode_v3(register const struct ospf6hdr *op,
register const u_char *dataend)
{
register const rtrid_t *ap;
register const struct lsr *lsrp;
register const struct lsa_hdr *lshp;
register const struct lsa *lsap;
register char sep;
register int i;
switch (op->ospf6_type) {
case OSPF_TYPE_UMD:
/*
* Rob Coltun's special monitoring packets;
* do nothing
*/
break;
case OSPF_TYPE_HELLO:
if (vflag) {
TCHECK(op->ospf6_hello.hello_deadint);
ospf6_print_bits(ospf6_option_bits,
ntohl(op->ospf6_hello.hello_options));
printf(" ifid %s pri %d int %d dead %u",
ipaddr_string(&op->ospf6_hello.hello_ifid),
op->ospf6_hello.hello_priority,
ntohs(op->ospf6_hello.hello_helloint),
ntohs(op->ospf6_hello.hello_deadint));
}
TCHECK(op->ospf6_hello.hello_dr);
if (op->ospf6_hello.hello_dr != 0)
printf(" dr %s",
ipaddr_string(&op->ospf6_hello.hello_dr));
TCHECK(op->ospf6_hello.hello_bdr);
if (op->ospf6_hello.hello_bdr != 0)
printf(" bdr %s",
ipaddr_string(&op->ospf6_hello.hello_bdr));
if (vflag) {
printf(" nbrs");
ap = op->ospf6_hello.hello_neighbor;
while ((u_char *)ap < dataend) {
TCHECK(*ap);
printf(" %s", ipaddr_string(ap));
++ap;
}
}
break; /* HELLO */
case OSPF_TYPE_DB:
TCHECK(op->ospf6_db.db_options);
ospf6_print_bits(ospf6_option_bits,
ntohl(op->ospf6_db.db_options));
sep = ' ';
TCHECK(op->ospf6_db.db_flags);
if (op->ospf6_db.db_flags & OSPF6_DB_INIT) {
printf("%cI", sep);
sep = '/';
}
if (op->ospf6_db.db_flags & OSPF6_DB_MORE) {
printf("%cM", sep);
sep = '/';
}
if (op->ospf6_db.db_flags & OSPF6_DB_MASTER) {
printf("%cMS", sep);
sep = '/';
}
TCHECK(op->ospf6_db.db_seq);
printf(" mtu %u S %X", ntohs(op->ospf6_db.db_mtu),
(u_int32_t)ntohl(op->ospf6_db.db_seq));
if (vflag) {
/* Print all the LS adv's */
lshp = op->ospf6_db.db_lshdr;
while (!ospf6_print_lshdr(lshp)) {
/* { (ctags) */
printf(" }");
++lshp;
}
}
break;
case OSPF_TYPE_LSR:
if (vflag) {
lsrp = op->ospf6_lsr;
while ((u_char *)lsrp < dataend) {
TCHECK(*lsrp);
printf(" {"); /* } (ctags) */
ospf6_print_ls_type(ntohs(lsrp->ls_type),
&lsrp->ls_stateid,
&lsrp->ls_router,
"LinkStateType %d");
/* { (ctags) */
printf(" }");
++lsrp;
}
}
break;
case OSPF_TYPE_LSU:
if (vflag) {
lsap = op->ospf6_lsu.lsu_lsa;
TCHECK(op->ospf6_lsu.lsu_count);
i = ntohl(op->ospf6_lsu.lsu_count);
while (i--) {
if (ospf6_print_lsa(lsap))
goto trunc;
lsap = (struct lsa *)((u_char *)lsap +
ntohs(lsap->ls_hdr.ls_length));
}
}
break;
case OSPF_TYPE_LSA:
if (vflag) {
lshp = op->ospf6_lsa.lsa_lshdr;
while (!ospf6_print_lshdr(lshp)) {
/* { (ctags) */
printf(" }");
++lshp;
}
}
break;
default:
printf("v3 type %d", op->ospf6_type);
break;
}
return (0);
trunc:
return (1);
}
void
ospf6_print(register const u_char *bp, register u_int length)
{
register const struct ospf6hdr *op;
register const u_char *dataend;
register const char *cp;
op = (struct ospf6hdr *)bp;
/* If the type is valid translate it, or just print the type */
/* value. If it's not valid, say so and return */
TCHECK(op->ospf6_type);
cp = tok2str(type2str, "type%d", op->ospf6_type);
printf(" OSPFv%d-%s %d:", op->ospf6_version, cp, length);
if (*cp == 't')
return;
TCHECK(op->ospf6_len);
if (length != ntohs(op->ospf6_len)) {
printf(" [len %d]", ntohs(op->ospf6_len));
return;
}
dataend = bp + length;
/* Print the routerid if it is not the same as the source */
TCHECK(op->ospf6_routerid);
printf(" rtrid %s", ipaddr_string(&op->ospf6_routerid));
TCHECK(op->ospf6_areaid);
if (op->ospf6_areaid != 0)
printf(" area %s", ipaddr_string(&op->ospf6_areaid));
else
printf(" backbone");
TCHECK(op->ospf6_instanceid);
if (op->ospf6_instanceid)
printf(" instance %u", op->ospf6_instanceid);
/* Do rest according to version. */
switch (op->ospf6_version) {
case 3:
/* ospf version 3 */
if (ospf6_decode_v3(op, dataend))
goto trunc;
break;
default:
printf(" ospf [version %d]", op->ospf6_version);
break;
} /* end switch on version */
return;
trunc:
fputs(tstr, stdout);
}

View file

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-pim.c,v 1.7 96/09/26 23:36:48 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.15.2.1 2000/01/25 18:29:05 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -31,11 +35,26 @@ static const char rcsid[] =
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
/*
* XXX: We consider a case where IPv6 is not ready yet for portability,
* but PIM dependent defintions should be independent of IPv6...
*/
struct pim {
u_int8_t pim_typever;
/* upper 4bit: the PIM message type, currently they are:
* Hello, Register, Register-Stop, Join/Prune,
* Bootstrap, Assert, Graft (PIM-DM only),
* Graft-Ack (PIM-DM only), C-RP-Adv
*/
/* lower 4bit: PIM version number; 2 for PIMv2 */
#define PIM_TYPE(x) (((x) & 0xf0) >> 4)
#define PIM_VER(x) ((x) & 0x0f)
u_char pim_rsv; /* Reserved */
u_short pim_cksum; /* IP style check sum */
};
#include <stdio.h>
#include <stdlib.h>
@ -43,9 +62,86 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
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;
/* 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",
(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;
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;
}
}
return;
trunc:
(void)printf("[|pim]");
return;
}
void
pim_print(register const u_char *bp, register u_int len)
pimv1_print(register const u_char *bp, register u_int len)
{
register const u_char *ep;
register u_char type;
@ -59,34 +155,87 @@ pim_print(register const u_char *bp, register u_int len)
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");
break;
case 2: (void)printf(" Sparse-Dense-mode");
break;
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;
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]));
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 7:
(void)printf(" Graft-ACK");
if (vflag) {
pimv1_join_prune_print(&bp[8], len - 8);
}
break;
case 8:
@ -97,4 +246,694 @@ pim_print(register const u_char *bp, register u_int len)
(void)printf(" [type %d]", type);
break;
}
if ((bp[4] >> 4) != 1)
(void)printf(" [v%d]", bp[4] >> 4);
return;
trunc:
(void)printf("[|pim]");
return;
}
/*
* auto-RP is a cisco protocol, documented at
* ftp://ftpeng.cisco.com/ipmulticast/pim-autorp-spec01.txt
*/
void
cisco_autorp_print(register const u_char *bp, register u_int len)
{
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?");
break;
case 1: printf(" PIMv1");
break;
case 2: printf(" PIMv2");
break;
case 3: printf(" PIMv1+2");
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;
}
}
return;
trunc:
(void)printf("[|autorp]");
return;
}
void
pim_print(register const u_char *bp, register u_int len)
{
register const u_char *ep;
register struct pim *pim = (struct pim *)bp;
ep = (const u_char *)snapend;
if (bp >= ep)
return;
#ifdef notyet /* currently we see only version and type */
TCHECK(pim->pim_rsv);
#endif
switch(PIM_VER(pim->pim_typever)) {
case 2: /* avoid hardcoding? */
(void)printf("v2");
pimv2_print(bp, len);
break;
default:
(void)printf("v%d", PIM_VER(pim->pim_typever));
break;
}
return;
}
/*
* PIMv2 uses encoded address representations.
*
* The last PIM-SM I-D before RFC2117 was published specified the
* following representation for unicast addresses. However, RFC2117
* specified no encoding for unicast addresses with the unicast
* address length specified in the header. Therefore, we have to
* guess which encoding is being used (Cisco's PIMv2 implementation
* uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
* field into a 'unicast-address-length-in-bytes' field. We guess
* that it's the draft encoding if this reserved field is zero.
*
* RFC2362 goes back to the encoded format, and calls the addr length
* field "reserved" again.
*
* The first byte is the address family, from:
*
* 0 Reserved
* 1 IP (IP version 4)
* 2 IP6 (IP version 6)
* 3 NSAP
* 4 HDLC (8-bit multidrop)
* 5 BBN 1822
* 6 802 (includes all 802 media plus Ethernet "canonical format")
* 7 E.163
* 8 E.164 (SMDS, Frame Relay, ATM)
* 9 F.69 (Telex)
* 10 X.121 (X.25, Frame Relay)
* 11 IPX
* 12 Appletalk
* 13 Decnet IV
* 14 Banyan Vines
* 15 E.164 with NSAP format subaddress
*
* In addition, the second byte is an "Encoding". 0 is the default
* encoding for the address family, and no other encodings are currently
* specified.
*
*/
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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Addr Family | Encoding Type | Unicast Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Addr Family | Encoding Type | Reserved | Mask Len |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Group multicast Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Source Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
static int
pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
{
int af;
char *afstr;
int len, hdrlen;
TCHECK(bp[0]);
if (pimv2_addr_len == 0) {
TCHECK(bp[1]);
switch (bp[0]) {
case 1:
af = AF_INET;
afstr = "IPv4";
len = 4;
break;
#ifdef INET6
case 2:
af = AF_INET6;
afstr = "IPv6";
len = 16;
break;
#endif
default:
return -1;
}
if (bp[1] != 0)
return -1;
hdrlen = 2;
} else {
switch (pimv2_addr_len) {
case 4:
af = AF_INET;
afstr = "IPv4";
break;
#ifdef INET6
case 16:
af = AF_INET6;
afstr = "IPv6";
break;
#endif
default:
return -1;
break;
}
len = pimv2_addr_len;
hdrlen = 0;
}
bp += hdrlen;
switch (at) {
case pimv2_unicast:
TCHECK2(bp[0], len);
if (af == AF_INET) {
if (!silent)
(void)printf("%s", ipaddr_string(bp));
}
#ifdef INET6
else if (af == AF_INET6) {
if (!silent)
(void)printf("%s", ip6addr_string(bp));
}
#endif
return hdrlen + len;
case pimv2_group:
case pimv2_source:
TCHECK2(bp[0], len + 2);
if (af == AF_INET) {
if (!silent) {
(void)printf("%s", ipaddr_string(bp + 2));
if (bp[1] != 32)
(void)printf("/%u", bp[1]);
}
}
#ifdef INET6
else if (af == AF_INET6) {
if (!silent) {
(void)printf("%s", ip6addr_string(bp + 2));
if (bp[1] != 128)
(void)printf("/%u", bp[1]);
}
}
#endif
if (bp[0] && !silent) {
if (at == pimv2_group) {
(void)printf("(0x%02x)", bp[0]);
} else {
(void)printf("(%s%s%s",
bp[0] & 0x04 ? "S" : "",
bp[0] & 0x02 ? "W" : "",
bp[0] & 0x01 ? "R" : "");
if (bp[0] & 0xf8) {
(void) printf("+0x%02x", bp[0] & 0xf8);
}
(void)printf(")");
}
}
return hdrlen + 2 + len;
default:
return -1;
}
trunc:
return -1;
}
static void
pimv2_print(register const u_char *bp, register u_int len)
{
register const u_char *ep;
register struct pim *pim = (struct pim *)bp;
int advance;
ep = (const u_char *)snapend;
if (bp >= ep)
return;
TCHECK(pim->pim_rsv);
pimv2_addr_len = pim->pim_rsv;
if (pimv2_addr_len != 0)
(void)printf("[RFC2117-encoding] ");
switch (PIM_TYPE(pim->pim_typever)) {
case 0:
{
u_int16_t otype, olen;
(void)printf(" Hello");
bp += 4;
while (bp < ep) {
TCHECK2(bp[0], 4);
otype = EXTRACT_16BITS(&bp[0]);
olen = EXTRACT_16BITS(&bp[2]);
TCHECK2(bp[0], 4 + olen);
switch (otype) {
case 1: /* Hold time */
(void)printf(" (Hold-time ");
relts_print(EXTRACT_16BITS(&bp[4]));
(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)");
break;
case 20:
(void)printf(" (Genid: 0x%08x)", EXTRACT_32BITS(&bp[4]));
break;
case 21:
(void)printf(" (State Refresh Capable");
if (EXTRACT_32BITS(&bp[4]) != 1) {
(void)printf(" ?0x%x?", EXTRACT_32BITS(&bp[4]));
}
(void)printf(")");
break;
default:
if (vflag)
(void)printf(" [Hello option %d]", otype);
}
bp += 4 + olen;
}
break;
}
case 1:
{
struct ip *ip;
(void)printf(" Register");
if (vflag && bp + 8 <= ep) {
(void)printf(" %s%s", bp[4] & 0x80 ? "B" : "",
bp[4] & 0x40 ? "N" : "");
}
bp += 8; len -= 8;
/* encapsulated multicast packet */
if (bp >= ep)
break;
ip = (struct ip *)bp;
switch(ip->ip_v) {
case 4: /* IPv4 */
printf(" ");
ip_print(bp, len);
break;
#ifdef INET6
case 6: /* IPv6 */
printf(" ");
ip6_print(bp, len);
break;
#endif
default:
(void)printf(" IP ver %d", ip->ip_v);
break;
}
break;
}
case 2:
(void)printf(" Register-Stop");
bp += 4; len -= 4;
if (bp >= ep)
break;
(void)printf(" group=");
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance; len -= advance;
if (bp >= ep)
break;
(void)printf(" source=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance; len -= advance;
break;
case 3:
case 6:
case 7:
{
u_int8_t ngroup;
u_int16_t holdtime;
u_int16_t njoin;
u_int16_t nprune;
int i, j;
switch (PIM_TYPE(pim->pim_typever)) {
case 3:
(void)printf(" Join/Prune");
break;
case 6:
(void)printf(" Graft");
break;
case 7:
(void)printf(" Graft-ACK");
break;
}
bp += 4; len -= 4;
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
if (bp >= ep)
break;
(void)printf(" upstream-neighbor=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance; len -= advance;
}
if (bp + 4 > ep)
break;
ngroup = bp[1];
holdtime = EXTRACT_16BITS(&bp[2]);
(void)printf(" groups=%u", ngroup);
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
(void)printf(" holdtime=");
if (holdtime == 0xffff)
(void)printf("infty");
else
relts_print(holdtime);
}
bp += 4; len -= 4;
for (i = 0; i < ngroup; i++) {
if (bp >= ep)
goto jp_done;
(void)printf(" (group%d: ", i);
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
(void)printf("...)");
goto jp_done;
}
bp += advance; len -= advance;
if (bp + 4 > ep) {
(void)printf("...)");
goto jp_done;
}
njoin = EXTRACT_16BITS(&bp[0]);
nprune = EXTRACT_16BITS(&bp[2]);
(void)printf(" join=%u", njoin);
bp += 4; len -= 4;
for (j = 0; j < njoin; j++) {
(void)printf(" ");
if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
(void)printf("...)");
goto jp_done;
}
bp += advance; len -= advance;
}
(void)printf(" prune=%u", nprune);
for (j = 0; j < nprune; j++) {
(void)printf(" ");
if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
(void)printf("...)");
goto jp_done;
}
bp += advance; len -= advance;
}
(void)printf(")");
}
jp_done:
break;
}
case 4:
{
int i, j, frpcnt;
(void)printf(" Bootstrap");
bp += 4;
/* Fragment Tag, Hash Mask len, and BSR-priority */
if (bp + sizeof(u_int16_t) >= ep) break;
(void)printf(" tag=%x", EXTRACT_16BITS(bp));
bp += sizeof(u_int16_t);
if (bp >= ep) break;
(void)printf(" hashmlen=%d", bp[0]);
if (bp + 1 >= ep) break;
(void)printf(" BSRprio=%d", bp[1]);
bp += 2;
/* Encoded-Unicast-BSR-Address */
if (bp >= ep) break;
(void)printf(" BSR=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance;
for (i = 0; bp < ep; i++) {
/* Encoded-Group Address */
(void)printf(" (group%d: ", i);
if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
< 0) {
(void)printf("...)");
goto bs_done;
}
bp += advance;
/* RP-Count, Frag RP-Cnt, and rsvd */
if (bp >= ep) {
(void)printf("...)");
goto bs_done;
}
(void)printf(" RPcnt=%d", frpcnt = bp[0]);
if (bp + 1 >= ep) {
(void)printf("...)");
goto bs_done;
}
(void)printf(" FRPcnt=%d", bp[1]);
bp += 4;
for (j = 0; j < frpcnt && bp < ep; j++) {
/* each RP info */
(void)printf(" RP%d=", j);
if ((advance = pimv2_addr_print(bp,
pimv2_unicast,
0)) < 0) {
(void)printf("...)");
goto bs_done;
}
bp += advance;
if (bp + 1 >= ep) {
(void)printf("...)");
goto bs_done;
}
(void)printf(",holdtime=");
relts_print(EXTRACT_16BITS(bp));
if (bp + 2 >= ep) {
(void)printf("...)");
goto bs_done;
}
(void)printf(",prio=%d", bp[2]);
bp += 4;
}
(void)printf(")");
}
bs_done:
break;
}
case 5:
(void)printf(" Assert");
bp += 4; len -= 4;
if (bp >= ep)
break;
(void)printf(" group=");
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance; len -= advance;
if (bp >= ep)
break;
(void)printf(" src=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance; len -= advance;
if (bp + 8 > ep)
break;
if (bp[0] & 0x80)
(void)printf(" RPT");
(void)printf(" pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff);
(void)printf(" metric=%u", EXTRACT_32BITS(&bp[4]));
break;
case 8:
{
int i, pfxcnt;
(void)printf(" Candidate-RP-Advertisement");
bp += 4;
/* Prefix-Cnt, Priority, and Holdtime */
if (bp >= ep) break;
(void)printf(" prefix-cnt=%d", bp[0]);
pfxcnt = bp[0];
if (bp + 1 >= ep) break;
(void)printf(" prio=%d", bp[1]);
if (bp + 3 >= ep) break;
(void)printf(" holdtime=");
relts_print(EXTRACT_16BITS(&bp[2]));
bp += 4;
/* Encoded-Unicast-RP-Address */
if (bp >= ep) break;
(void)printf(" RP=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance;
/* Encoded-Group Addresses */
for (i = 0; i < pfxcnt && bp < ep; i++) {
(void)printf(" Group%d=", i);
if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
< 0) {
(void)printf("...");
break;
}
bp += advance;
}
break;
}
case 9:
(void)printf(" Prune-Refresh");
(void)printf(" src=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance;
(void)printf(" grp=");
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance;
(void)printf(" forwarder=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
break;
}
bp += advance;
TCHECK2(bp[0], 2);
(void)printf(" TUNR ");
relts_print(EXTRACT_16BITS(bp));
break;
default:
(void)printf(" [type %d]", PIM_TYPE(pim->pim_typever));
break;
}
return;
trunc:
(void)printf("[|pim]");
}

View file

@ -0,0 +1,224 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.3 1999/12/15 00:23:06 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#if __STDC__
struct mbuf;
struct rtentry;
#endif
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "ppp.h"
#include "ethertype.h"
#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
};
static struct tok pppoecode2str[] = {
{ 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,
};
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}
};
#define PPPOE_HDRLEN 6
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;
eh = (struct ether_header *)packetp;
pppoe_packet = packetp+sizeof(struct ether_header);
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);
}
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 (pppoe_code) {
/* PPP session packets don't contain tags */
u_short tag_type = -1, tag_len;
const u_char *p = pppoe_payload;
/* loop invariant:
p points to next tag,
tag_type is previous tag or -1 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;
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 {
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));
}
return;
}

View file

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-raw.c,v 1.22 96/12/10 23:18:58 leres Locked $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.25 1999/11/21 09:37:00 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -44,7 +48,6 @@ struct rtentry;
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <pcap.h>
#include <stdio.h>

View file

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-rip.c,v 1.36 96/11/29 01:22:50 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.40 1999/11/22 04:24:28 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -100,8 +104,10 @@ rip_print(const u_char *dat, u_int length)
register int i, j, trunc;
i = min(length, snapend - dat) - sizeof(*rp);
if (i < 0)
if (i < 0) {
printf(" [|rip]");
return;
}
rp = (struct rip *)dat;
switch (rp->rip_cmd) {
@ -116,7 +122,7 @@ rip_print(const u_char *dat, u_int length)
printf(" rip-resp %d[%d]:", j, length);
else
printf(" rip-resp %d:", j);
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
trunc = (i / sizeof(*ni)) != j;
ni = (struct rip_netinfo *)(rp + 1);
for (; (i -= sizeof(*ni)) >= 0; ++ni)
rip_entry_print(rp->rip_vers, ni);

View file

@ -0,0 +1,127 @@
/*
* Copyright (c) 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.2.2.1 2000/01/11 06:58:26 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef INET6
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <errno.h>
#include <stdio.h>
#include <netinet/ip6.h>
#include "route6d.h"
#include "interface.h"
#include "addrtoname.h"
static int
rip6_entry_print(register const struct netinfo6 *ni, int metric)
{
int l;
l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen);
if (ni->rip6_tag)
l += printf(" [%d]", ntohs(ni->rip6_tag));
if (metric)
l += printf(" (%d)", ni->rip6_metric);
return l;
}
void
ripng_print(const u_char *dat, int length)
{
register const struct rip6 *rp = (struct rip6 *)dat;
register const struct netinfo6 *ni;
register int amt = snapend - dat;
register int i = min(length, amt) -
(sizeof(struct rip6) - sizeof(struct netinfo6));
int j;
int trunc;
if (i < 0)
return;
switch (rp->rip6_cmd) {
case RIP6_REQUEST:
j = length / sizeof(*ni);
if (j == 1
&& rp->rip6_nets->rip6_metric == HOPCNT_INFINITY6
&& IN6_IS_ADDR_UNSPECIFIED(&rp->rip6_nets->rip6_dest)) {
printf(" ripng-req dump");
break;
}
if (j * sizeof(*ni) != length - 4)
printf(" ripng-req %d[%d]:", j, length);
else
printf(" ripng-req %d:", j);
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
if (vflag)
printf("\n\t");
else
printf(" ");
rip6_entry_print(ni, 0);
}
break;
case RIP6_RESPONSE:
j = length / sizeof(*ni);
if (j * sizeof(*ni) != length - 4)
printf(" ripng-resp %d[%d]:", j, length);
else
printf(" ripng-resp %d:", j);
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
if (vflag)
printf("\n\t");
else
printf(" ");
rip6_entry_print(ni, ni->rip6_metric);
}
if (trunc)
printf("[|rip]");
break;
default:
printf(" ripng-%d ?? %d", rp->rip6_cmd, length);
break;
}
if (rp->rip6_vers != RIP6_VERSION)
printf(" [vers %d]", rp->rip6_vers);
}
#endif /* INET6 */

120
contrib/tcpdump/print-rt6.c Normal file
View file

@ -0,0 +1,120 @@
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.3.2.1 2000/01/11 06:58:26 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef INET6
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <netinet/ip6.h>
#include "interface.h"
#include "addrtoname.h"
int
rt6_print(register const u_char *bp, register const u_char *bp2)
{
register const struct ip6_rthdr *dp;
register const struct ip6_rthdr0 *dp0;
register const struct ip6_hdr *ip;
register const u_char *ep;
int i, len;
dp = (struct ip6_rthdr *)bp;
ip = (struct ip6_hdr *)bp2;
len = dp->ip6r_len;
/* 'ep' points to the end of avaible data. */
ep = snapend;
printf("%s > %s: ",
ip6addr_string(&ip->ip6_src),
ip6addr_string(&ip->ip6_dst));
TCHECK(dp->ip6r_segleft);
printf("srcrt (len=%d, ", dp->ip6r_len);
printf("type=%d, ", dp->ip6r_type);
printf("segleft=%d, ", dp->ip6r_segleft);
switch(dp->ip6r_type) {
case IPV6_RTHDR_TYPE_0:
dp0 = (struct ip6_rthdr0 *)dp;
TCHECK(dp0->ip6r0_reserved);
if (dp0->ip6r0_reserved || vflag) {
printf("rsv=0x%0x, ",
(u_int32_t)ntohl(dp0->ip6r0_reserved));
}
if (len % 2 == 1)
goto trunc;
len >>= 1;
for (i = 0; i < len; i++) {
struct in6_addr *addr;
addr = ((struct in6_addr *)(dp0 + 1)) + i;
if ((u_char *)addr > ep - sizeof(*addr))
goto trunc;
printf("[%d]%s", i, ip6addr_string((u_char *)addr));
if (i != len - 1)
printf(", ");
}
printf(")");
return((dp0->ip6r0_len + 1) << 3);
break;
default:
goto trunc;
break;
}
trunc:
fputs("[|srcrt]", stdout);
return 65535; /* XXX */
}
#endif /* INET6 */

2190
contrib/tcpdump/print-rx.c Normal file

File diff suppressed because it is too large Load diff

1008
contrib/tcpdump/print-smb.c Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-tcp.c,v 1.55 97/06/15 13:20:28 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.63 1999/12/22 15:44:10 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/param.h>
@ -32,7 +36,6 @@ static const char rcsid[] =
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
@ -42,6 +45,10 @@ static const char rcsid[] =
#include <string.h>
#include <unistd.h>
#ifdef INET6
#include <netinet/ip6.h>
#endif
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
@ -76,8 +83,13 @@ static const char rcsid[] =
#endif
struct tha {
#ifndef INET6
struct in_addr src;
struct in_addr dst;
#else
struct in6_addr src;
struct in6_addr dst;
#endif /*INET6*/
u_int port;
};
@ -96,6 +108,14 @@ struct tcp_seq_hash {
static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE];
#ifndef TELNET_PORT
#define TELNET_PORT 23
#endif
#ifndef BGP_PORT
#define BGP_PORT 179
#endif
#define NETBIOS_SSN_PORT 139
void
tcp_print(register const u_char *bp, register u_int length,
register const u_char *bp2)
@ -106,33 +126,75 @@ tcp_print(register const u_char *bp, register u_int length,
register int hlen;
register char ch;
u_short sport, dport, win, urp;
u_int32_t seq, ack;
u_int32_t seq, ack, thseq, thack;
int threv;
#ifdef INET6
register const struct ip6_hdr *ip6;
#endif
tp = (struct tcphdr *)bp;
ip = (struct ip *)bp2;
#ifdef INET6
if (ip->ip_v == 6)
ip6 = (struct ip6_hdr *)bp2;
else
ip6 = NULL;
#endif /*INET6*/
ch = '\0';
TCHECK(*tp);
if (length < sizeof(*tp)) {
(void)printf("truncated-tcp %d", length);
if (!TTEST(tp->th_dport)) {
(void)printf("%s > %s: [|tcp]",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
return;
}
sport = ntohs(tp->th_sport);
dport = ntohs(tp->th_dport);
#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_TCP) {
(void)printf("%s.%s > %s.%s: ",
ip6addr_string(&ip6->ip6_src),
tcpport_string(sport),
ip6addr_string(&ip6->ip6_dst),
tcpport_string(dport));
} else {
(void)printf("%s > %s: ",
tcpport_string(sport), tcpport_string(dport));
}
} else
#endif /*INET6*/
{
if (ip->ip_p == IPPROTO_TCP) {
(void)printf("%s.%s > %s.%s: ",
ipaddr_string(&ip->ip_src),
tcpport_string(sport),
ipaddr_string(&ip->ip_dst),
tcpport_string(dport));
} else {
(void)printf("%s > %s: ",
tcpport_string(sport), tcpport_string(dport));
}
}
TCHECK(*tp);
seq = ntohl(tp->th_seq);
ack = ntohl(tp->th_ack);
win = ntohs(tp->th_win);
urp = ntohs(tp->th_urp);
(void)printf("%s.%s > %s.%s: ",
ipaddr_string(&ip->ip_src), tcpport_string(sport),
ipaddr_string(&ip->ip_dst), tcpport_string(dport));
if (qflag) {
(void)printf("tcp %d", length - tp->th_off * 4);
return;
}
if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH)) {
#ifdef TH_ECN
if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH|TH_ECN))
#else
if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH))
#endif
{
if (flags & TH_SYN)
putchar('S');
if (flags & TH_FIN)
@ -141,9 +203,22 @@ tcp_print(register const u_char *bp, register u_int length,
putchar('R');
if (flags & TH_PUSH)
putchar('P');
#ifdef TH_ECN
if (flags & TH_ECN)
putchar('C');
#endif
} else
putchar('.');
if (flags&0xc0) {
printf(" [");
if (flags&0x40)
printf("ECN-Echo");
if (flags&0x80)
printf("%sCWR", (flags&0x40) ? "," : "");
printf("]");
}
if (!Sflag && (flags & TH_ACK)) {
register struct tcp_seq_hash *th;
register int rev;
@ -154,6 +229,49 @@ tcp_print(register const u_char *bp, register u_int length,
* collating order so there's only one entry for
* both directions).
*/
#ifdef INET6
bzero(&tha, sizeof(tha));
rev = 0;
if (ip6) {
if (sport > dport) {
rev = 1;
} else if (sport == dport) {
int i;
for (i = 0; i < 4; i++) {
if (((u_int32_t *)(&ip6->ip6_src))[i] >
((u_int32_t *)(&ip6->ip6_dst))[i]) {
rev = 1;
break;
}
}
}
if (rev) {
tha.src = ip6->ip6_dst;
tha.dst = ip6->ip6_src;
tha.port = dport << 16 | sport;
} else {
tha.dst = ip6->ip6_dst;
tha.src = ip6->ip6_src;
tha.port = sport << 16 | dport;
}
} else {
if (sport > dport ||
(sport == dport &&
ip->ip_src.s_addr > ip->ip_dst.s_addr)) {
rev = 1;
}
if (rev) {
*(struct in_addr *)&tha.src = ip->ip_dst;
*(struct in_addr *)&tha.dst = ip->ip_src;
tha.port = dport << 16 | sport;
} else {
*(struct in_addr *)&tha.dst = ip->ip_dst;
*(struct in_addr *)&tha.src = ip->ip_src;
tha.port = sport << 16 | dport;
}
}
#else
if (sport < dport ||
(sport == dport &&
ip->ip_src.s_addr < ip->ip_dst.s_addr)) {
@ -165,7 +283,9 @@ tcp_print(register const u_char *bp, register u_int length,
tha.port = dport << 16 | sport;
rev = 1;
}
#endif
threv = rev;
for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE];
th->nxt; th = th->nxt)
if (!memcmp((char *)&tha, (char *)&th->addr,
@ -186,6 +306,10 @@ tcp_print(register const u_char *bp, register u_int length,
else
th->seq = seq, th->ack = ack - 1;
} else {
thseq = th->seq;
thack = th->ack;
if (rev)
seq -= th->ack, ack -= th->seq;
else
@ -198,7 +322,7 @@ tcp_print(register const u_char *bp, register u_int length,
return;
}
length -= hlen;
if (length > 0 || flags & (TH_SYN | TH_FIN | TH_RST))
if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST))
(void)printf(" %u:%u(%d)", seq, seq + length, length);
if (flags & TH_ACK)
(void)printf(" ack %u", ack);
@ -268,15 +392,28 @@ tcp_print(register const u_char *bp, register u_int length,
case TCPOPT_SACK:
(void)printf("sack");
datalen = len - 2;
for (i = 0; i < datalen; i += 4) {
LENCHECK(i + 4);
/* block-size@relative-origin */
(void)printf(" %u@%u",
EXTRACT_16BITS(cp + i + 2),
EXTRACT_16BITS(cp + i));
if (datalen % 8 != 0) {
(void)printf(" malformed sack ");
} else {
u_int32_t s, e;
(void)printf(" sack %d ", datalen / 8);
for (i = 0; i < datalen; i += 8) {
LENCHECK(i + 4);
s = EXTRACT_32BITS(cp + i);
LENCHECK(i + 8);
e = EXTRACT_32BITS(cp + i + 4);
if (threv) {
s -= thseq;
e -= thseq;
} else {
s -= thack;
e -= thack;
}
(void)printf("{%u:%u}", s, e);
}
(void)printf(" ");
}
if (datalen % 4)
(void)printf("[len %d]", len);
break;
case TCPOPT_ECHO:
@ -349,6 +486,21 @@ tcp_print(register const u_char *bp, register u_int length,
}
putchar('>');
}
if (length <= 0)
return;
/*
* Decode payload if necessary.
*/
bp += (tp->th_off * 4);
if (!qflag && vflag && length > 0
&& (sport == TELNET_PORT || dport == TELNET_PORT))
telnet_print(bp, length);
else if (sport == BGP_PORT || dport == BGP_PORT)
bgp_print(bp, length);
else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
nbt_tcp_print(bp, length);
return;
bad:
fputs("[bad opt]", stdout);

View file

@ -0,0 +1,191 @@
/* $NetBSD: print-telnet.c,v 1.2 1999/10/11 12:40:12 sjg Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Simon J. Gerraty.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* @(#)Copyright (c) 1994, Simon J. Gerraty.
*
* This is free software. It comes with NO WARRANTY.
* Permission to use, modify and distribute this source code
* is granted subject to the following conditions.
* 1/ that the above copyright notice and this notice
* are preserved in all copies.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.2.2.2 2000/01/11 06:58:28 fenner Exp $";
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#define TELCMDS
#define TELOPTS
#include <arpa/telnet.h>
#include <stdio.h>
#ifdef __STDC__
#include <stdlib.h>
#endif
#include <unistd.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#ifndef TELCMD_FIRST
# define TELCMD_FIRST SE
#endif
void
telnet_print(register const u_char *sp, u_int length)
{
static char tnet[128];
register int i, c, x;
register u_char *rcp;
int off, first = 1;
u_char *osp;
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;
}
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)sprintf(tnet, "%s %s",
telcmds[i], telopts[x]);
} else {
(void)sprintf(tnet, "%s %#x",
telcmds[i], x);
}
break;
default:
(void)strcpy(tnet, 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!");
}
}
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("\n\t\t\t\t%s", tnet);
else
printf("%*s\t%s", (8 - i) * 3, "", tnet);
} else {
printf("%s%s", (first) ? " [telnet " : ", ", tnet);
}
first = 0;
}
if (!first) {
if (Xflag && 2 < vflag)
printf("\n");
else
printf("]");
}
}

View file

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

104
contrib/tcpdump/print-vjc.c Normal file
View file

@ -0,0 +1,104 @@
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if defined(__bsdi__)
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.2.2.1 2000/01/11 06:58:28 fenner Exp $ (LBL)";
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#if __STDC__
struct mbuf;
struct rtentry;
#endif
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/if_ether.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <stdio.h>
#if defined(__NetBSD__)
#include <sys/mbuf.h>
#include <net/ppp_defs.h>
#endif
#if defined(__bsdi__) || defined(__NetBSD__)
#include <net/if_ppp.h>
#include <net/slcompress.h>
#endif
#include "interface.h"
#include "addrtoname.h"
int
vjc_print(register const char *bp, register u_int length, u_short proto)
{
int i;
switch (bp[0] & 0xf0) {
case TYPE_IP:
if (eflag)
printf("(vjc type=IP) ");
return PPP_IP;
case TYPE_UNCOMPRESSED_TCP:
if (eflag)
printf("(vjc type=raw TCP) ");
return PPP_IP;
case TYPE_COMPRESSED_TCP:
if (eflag)
printf("(vjc type=compressed TCP) ");
for (i = 0; i < 8; i++) {
if (bp[1] & (0x80 >> i))
printf("%c", "?CI?SAWU"[i]);
}
if (bp[1])
printf(" ");
printf("C=0x%02x ", bp[2]);
printf("sum=0x%04x ", *(u_short *)&bp[3]);
return -1;
case TYPE_ERROR:
if (eflag)
printf("(vjc type=error) ");
return -1;
default:
if (eflag)
printf("(vjc type=0x%02x) ", bp[0] & 0xf0);
return -1;
}
}
#endif /* defined(__bsdi__) || defined(__NetBSD__) */

View file

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: print-wb.c,v 1.24 96/12/31 21:27:44 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.25 1999/11/21 09:37:03 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>

49
contrib/tcpdump/route6d.h Normal file
View file

@ -0,0 +1,49 @@
/*
* $Header: /tcpdump/master/tcpdump/route6d.h,v 1.1 1999/10/30 05:11:22 itojun Exp $
*/
#define RIP6_VERSION 1
#define RIP6_REQUEST 1
#define RIP6_RESPONSE 2
struct netinfo6 {
struct in6_addr rip6_dest;
u_short rip6_tag;
u_char rip6_plen;
u_char rip6_metric;
};
struct rip6 {
u_char rip6_cmd;
u_char rip6_vers;
u_char rip6_res1[2];
union {
struct netinfo6 ru6_nets[1];
char ru6_tracefile[1];
} rip6un;
#define rip6_nets rip6un.ru6_nets
#define rip6_tracefile rip6un.ru6_tracefile
};
#define HOPCNT_INFINITY6 16
#define MAXRTE 24
#define NEXTHOP_METRIC 0xff
#ifndef DEBUG
#define SUPPLY_INTERVAL6 30
#define RIP_LIFETIME 180
#define RIP_HOLDDOWN 120
#define RIP_TRIG_INTERVAL6 5
#define RIP_TRIG_INTERVAL6_MIN 1
#else
/* only for debugging; can not wait for 30sec to appear a bug */
#define SUPPLY_INTERVAL6 10
#define RIP_LIFETIME 60
#define RIP_HOLDDOWN 40
#define RIP_TRIG_INTERVAL6 5
#define RIP_TRIG_INTERVAL6_MIN 1
#endif
#define RIP6_PORT 521
#define RIP6_DEST "ff02::9"

68
contrib/tcpdump/rx.h Normal file
View file

@ -0,0 +1,68 @@
/*
* Rx protocol format
*
* $Id: rx.h,v 1.1 1999/11/17 05:45:58 assar Exp $
*/
#define FS_RX_PORT 7000
#define CB_RX_PORT 7001
#define PROT_RX_PORT 7002
#define VLDB_RX_PORT 7003
#define KAUTH_RX_PORT 7004
#define VOL_RX_PORT 7005
#define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
#define BOS_RX_PORT 7007
#ifndef AFSNAMEMAX
#define AFSNAMEMAX 256
#endif
#ifndef AFSOPAQUEMAX
#define AFSOPAQUEMAX 1024
#endif
#define PRNAMEMAX 64
#define VLNAMEMAX 65
#define KANAMEMAX 64
#define BOSNAMEMAX 256
#define PRSFS_READ 1 /* Read files */
#define PRSFS_WRITE 2 /* Write files */
#define PRSFS_INSERT 4 /* Insert files into a directory */
#define PRSFS_LOOKUP 8 /* Lookup files into a directory */
#define PRSFS_DELETE 16 /* Delete files */
#define PRSFS_LOCK 32 /* Lock files */
#define PRSFS_ADMINISTER 64 /* Change ACL's */
struct rx_header {
u_int32_t epoch;
u_int32_t cid;
u_int32_t callNumber;
u_int32_t seq;
u_int32_t serial;
u_char type;
#define RX_PACKET_TYPE_DATA 1
#define RX_PACKET_TYPE_ACK 2
#define RX_PACKET_TYPE_BUSY 3
#define RX_PACKET_TYPE_ABORT 4
#define RX_PACKET_TYPE_ACKALL 5
#define RX_PACKET_TYPE_CHALLENGE 6
#define RX_PACKET_TYPE_RESPONSE 7
#define RX_PACKET_TYPE_DEBUG 8
#define RX_PACKET_TYPE_PARAMS 9
#define RX_PACKET_TYPE_VERSION 13
u_char flags;
#define RX_CLIENT_INITIATED 1
#define RX_REQUEST_ACK 2
#define RX_LAST_PACKET 4
#define RX_MORE_PACKETS 8
#define RX_FREE_PACKET 16
u_char userStatus;
u_char securityIndex;
u_short spare; /* How clever: even though the AFS */
u_short serviceId; /* header files indicate that the */
}; /* serviceId is first, it's really */
/* encoded _after_ the spare field */
/* I wasted a day figuring that out! */
#define NUM_RX_FLAGS 5

View file

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: savestr.c,v 1.2 97/05/09 14:52:31 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/savestr.c,v 1.4 1999/11/21 09:37:04 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
@ -31,6 +35,7 @@ static const char rcsid[] =
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H

View file

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: savestr.h,v 1.1 97/04/22 13:30:21 leres Exp $ (LBL)
* @(#) $Header: /tcpdump/master/tcpdump/savestr.h,v 1.1.1.1 1999/10/07 23:47:12 mcr Exp $ (LBL)
*/
extern char *savestr(const char *);

View file

@ -21,7 +21,11 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: setsignal.c,v 1.4 97/06/15 13:20:29 leres Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.5 1999/11/21 09:37:04 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>

View file

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

152
contrib/tcpdump/smb.h Normal file
View file

@ -0,0 +1,152 @@
/*
Copyright (C) Andrew Tridgell 1995-1999
This software may be distributed either under the terms of the
BSD-style license that accompanies tcpdump or the GNU GPL version 2
or later */
#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
#define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
#define SVALS(buf,pos) ((int16)SVAL(buf,pos))
#define IVALS(buf,pos) ((int32)IVAL(buf,pos))
#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
/* now the reverse routines - these are used in nmb packets (mostly) */
#define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
#define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
#define RSVAL(buf,pos) SREV(SVAL(buf,pos))
#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
#define uint16 unsigned short
#define uint32 unsigned int
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
/* the complete */
#define SMBmkdir 0x00 /* create directory */
#define SMBrmdir 0x01 /* delete directory */
#define SMBopen 0x02 /* open file */
#define SMBcreate 0x03 /* create file */
#define SMBclose 0x04 /* close file */
#define SMBflush 0x05 /* flush file */
#define SMBunlink 0x06 /* delete file */
#define SMBmv 0x07 /* rename file */
#define SMBgetatr 0x08 /* get file attributes */
#define SMBsetatr 0x09 /* set file attributes */
#define SMBread 0x0A /* read from file */
#define SMBwrite 0x0B /* write to file */
#define SMBlock 0x0C /* lock byte range */
#define SMBunlock 0x0D /* unlock byte range */
#define SMBctemp 0x0E /* create temporary file */
#define SMBmknew 0x0F /* make new file */
#define SMBchkpth 0x10 /* check directory path */
#define SMBexit 0x11 /* process exit */
#define SMBlseek 0x12 /* seek */
#define SMBtcon 0x70 /* tree connect */
#define SMBtconX 0x75 /* tree connect and X*/
#define SMBtdis 0x71 /* tree disconnect */
#define SMBnegprot 0x72 /* negotiate protocol */
#define SMBdskattr 0x80 /* get disk attributes */
#define SMBsearch 0x81 /* search directory */
#define SMBsplopen 0xC0 /* open print spool file */
#define SMBsplwr 0xC1 /* write to print spool file */
#define SMBsplclose 0xC2 /* close print spool file */
#define SMBsplretq 0xC3 /* return print queue */
#define SMBsends 0xD0 /* send single block message */
#define SMBsendb 0xD1 /* send broadcast message */
#define SMBfwdname 0xD2 /* forward user name */
#define SMBcancelf 0xD3 /* cancel forward */
#define SMBgetmac 0xD4 /* get machine name */
#define SMBsendstrt 0xD5 /* send start of multi-block message */
#define SMBsendend 0xD6 /* send end of multi-block message */
#define SMBsendtxt 0xD7 /* send text of multi-block message */
/* Core+ protocol */
#define SMBlockread 0x13 /* Lock a range and read */
#define SMBwriteunlock 0x14 /* Unlock a range then write */
#define SMBreadbraw 0x1a /* read a block of data with no smb header */
#define SMBwritebraw 0x1d /* write a block of data with no smb header */
#define SMBwritec 0x20 /* secondary write request */
#define SMBwriteclose 0x2c /* write a file then close it */
/* dos extended protocol */
#define SMBreadBraw 0x1A /* read block raw */
#define SMBreadBmpx 0x1B /* read block multiplexed */
#define SMBreadBs 0x1C /* read block (secondary response) */
#define SMBwriteBraw 0x1D /* write block raw */
#define SMBwriteBmpx 0x1E /* write block multiplexed */
#define SMBwriteBs 0x1F /* write block (secondary request) */
#define SMBwriteC 0x20 /* write complete response */
#define SMBsetattrE 0x22 /* set file attributes expanded */
#define SMBgetattrE 0x23 /* get file attributes expanded */
#define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
#define SMBtrans 0x25 /* transaction - name, bytes in/out */
#define SMBtranss 0x26 /* transaction (secondary request/response) */
#define SMBioctl 0x27 /* IOCTL */
#define SMBioctls 0x28 /* IOCTL (secondary request/response) */
#define SMBcopy 0x29 /* copy */
#define SMBmove 0x2A /* move */
#define SMBecho 0x2B /* echo */
#define SMBopenX 0x2D /* open and X */
#define SMBreadX 0x2E /* read and X */
#define SMBwriteX 0x2F /* write and X */
#define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
#define SMBffirst 0x82 /* find first */
#define SMBfunique 0x83 /* find unique */
#define SMBfclose 0x84 /* find close */
#define SMBinvalid 0xFE /* invalid command */
/* Extended 2.0 protocol */
#define SMBtrans2 0x32 /* TRANS2 protocol set */
#define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
#define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
#define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
#define SMBulogoffX 0x74 /* user logoff */
/* NT SMB extensions. */
#define SMBnttrans 0xA0 /* NT transact */
#define SMBnttranss 0xA1 /* NT transact secondary */
#define SMBntcreateX 0xA2 /* NT create and X */
#define SMBntcancel 0xA4 /* NT cancel */
/* pathworks special */
#define pSETDIR '\377'
/* these are the TRANS2 sub commands */
#define TRANSACT2_OPEN 0
#define TRANSACT2_FINDFIRST 1
#define TRANSACT2_FINDNEXT 2
#define TRANSACT2_QFSINFO 3
#define TRANSACT2_SETFSINFO 4
#define TRANSACT2_QPATHINFO 5
#define TRANSACT2_SETPATHINFO 6
#define TRANSACT2_QFILEINFO 7
#define TRANSACT2_SETFILEINFO 8
#define TRANSACT2_FSCTL 9
#define TRANSACT2_IOCTL 10
#define TRANSACT2_FINDNOTIFYFIRST 11
#define TRANSACT2_FINDNOTIFYNEXT 12
#define TRANSACT2_MKDIR 13
#define PTR_DIFF(p1,p2) ((unsigned long)(((char *)(p1)) - (char *)(p2)))
/* some protos */
const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf);

698
contrib/tcpdump/smbutil.c Normal file
View file

@ -0,0 +1,698 @@
/*
Copyright (C) Andrew Tridgell 1995-1999
This software may be distributed either under the terms of the
BSD-style license that accompanies tcpdump or the GNU GPL version 2
or later */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.4.2.1 2000/01/11 06:58:28 fenner Exp $";
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "interface.h"
#include "smb.h"
extern uchar *startbuf;
/*******************************************************************
interpret a 32 bit dos packed date/time to some parameters
********************************************************************/
static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *hour,int *minute,int *second)
{
uint32 p0,p1,p2,p3;
p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF;
p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
*second = 2*(p0 & 0x1F);
*minute = ((p0>>5)&0xFF) + ((p1&0x7)<<3);
*hour = (p1>>3)&0xFF;
*day = (p2&0x1F);
*month = ((p2>>5)&0xFF) + ((p3&0x1)<<3) - 1;
*year = ((p3>>1)&0xFF) + 80;
}
/*******************************************************************
create a unix date from a dos date
********************************************************************/
static time_t make_unix_date(const void *date_ptr)
{
uint32 dos_date=0;
struct tm t;
dos_date = IVAL(date_ptr,0);
if (dos_date == 0) return(0);
interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
t.tm_wday = 1;
t.tm_yday = 1;
t.tm_isdst = 0;
return (mktime(&t));
}
/*******************************************************************
create a unix date from a dos date
********************************************************************/
static time_t make_unix_date2(const void *date_ptr)
{
uint32 x,x2;
x = IVAL(date_ptr,0);
x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
SIVAL(&x,0,x2);
return(make_unix_date((void *)&x));
}
/****************************************************************************
interpret an 8 byte "filetime" structure to a time_t
It's originally in "100ns units since jan 1st 1601"
****************************************************************************/
static time_t interpret_long_date(const char *p)
{
double d;
time_t ret;
/* this gives us seconds since jan 1st 1601 (approx) */
d = (IVAL(p,4)*256.0 + CVAL(p,3)) * (1.0e-7 * (1<<24));
/* now adjust by 369 years to make the secs since 1970 */
d -= 369.0*365.25*24*60*60;
/* and a fudge factor as we got it wrong by a few days */
d += (3*24*60*60 + 6*60*60 + 2);
if (d<0)
return(0);
ret = (time_t)d;
return(ret);
}
/****************************************************************************
interpret the weird netbios "name". Return the name type
****************************************************************************/
static int name_interpret(char *in,char *out)
{
int ret;
int len = (*in++) / 2;
*out=0;
if (len > 30 || len<1) return(0);
while (len--)
{
if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') {
*out = 0;
return(0);
}
*out = ((in[0]-'A')<<4) + (in[1]-'A');
in += 2;
out++;
}
*out = 0;
ret = out[-1];
return(ret);
}
/****************************************************************************
find a pointer to a netbios name
****************************************************************************/
static char *name_ptr(char *buf,int ofs)
{
unsigned char c = *(unsigned char *)(buf+ofs);
if ((c & 0xC0) == 0xC0)
{
uint16 l = RSVAL(buf, ofs) & 0x3FFF;
return(buf + l);
}
else
return(buf+ofs);
}
/****************************************************************************
extract a netbios name from a buf
****************************************************************************/
static int name_extract(char *buf,int ofs,char *name)
{
char *p = name_ptr(buf,ofs);
strcpy(name,"");
return(name_interpret(p,name));
}
/****************************************************************************
return the total storage length of a mangled name
****************************************************************************/
static int name_len(const unsigned char *s)
{
const char *s0 = s;
unsigned char c = *(unsigned char *)s;
if ((c & 0xC0) == 0xC0)
return(2);
while (*s) s += (*s)+1;
return(PTR_DIFF(s,s0)+1);
}
static void print_asc(const unsigned char *buf,int len)
{
int i;
for (i=0;i<len;i++)
printf("%c",isprint(buf[i])?buf[i]:'.');
}
static char *name_type_str(int name_type)
{
static char *f = NULL;
switch (name_type) {
case 0: f = "Workstation"; break;
case 0x03: f = "Client?"; break;
case 0x20: f = "Server"; break;
case 0x1d: f = "Master Browser"; break;
case 0x1b: f = "Domain Controller"; break;
case 0x1e: f = "Browser Server"; break;
default: f = "Unknown"; break;
}
return(f);
}
void print_data(const unsigned char *buf, int len)
{
int i=0;
if (len<=0) return;
printf("[%03X] ",i);
for (i=0;i<len;) {
printf("%02X ",(int)buf[i]);
i++;
if (i%8 == 0) printf(" ");
if (i%16 == 0) {
print_asc(&buf[i-16],8); printf(" ");
print_asc(&buf[i-8],8); printf("\n");
if (i<len) printf("[%03X] ",i);
}
}
if (i%16) {
int n;
n = 16 - (i%16);
printf(" ");
if (n>8) printf(" ");
while (n--) printf(" ");
n = MIN(8,i%16);
print_asc(&buf[i-(i%16)],n); printf(" ");
n = (i%16) - n;
if (n>0) print_asc(&buf[i-n],n);
printf("\n");
}
}
static void write_bits(unsigned int val,char *fmt)
{
char *p = fmt;
int i=0;
while ((p=strchr(fmt,'|'))) {
int l = PTR_DIFF(p,fmt);
if (l && (val & (1<<i)))
printf("%.*s ",l,fmt);
fmt = p+1;
i++;
}
}
/* convert a unicode string */
static const char *unistr(const char *s, int *len)
{
static char buf[1000];
int l=0;
static int use_unicode = -1;
if (use_unicode == -1) {
char *p = getenv("USE_UNICODE");
if (p && (atoi(p) == 1))
use_unicode = 1;
else
use_unicode = 0;
}
/* maybe it isn't unicode - a cheap trick */
if (!use_unicode || (s[0] && s[1])) {
*len = strlen(s)+1;
return s;
}
*len = 0;
if (s[0] == 0 && s[1] != 0) {
s++;
*len = 1;
}
while (l < (sizeof(buf)-1) && s[0] && s[1] == 0) {
buf[l] = s[0];
s += 2; l++;
*len += 2;
}
buf[l] = 0;
*len += 2;
return buf;
}
static const uchar *fdata1(const uchar *buf, const char *fmt, const uchar *maxbuf)
{
int reverse=0;
char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
int len;
while (*fmt && buf<maxbuf) {
switch (*fmt) {
case 'a':
write_bits(CVAL(buf,0),attrib_fmt);
buf++; fmt++;
break;
case 'A':
write_bits(SVAL(buf,0),attrib_fmt);
buf+=2; fmt++;
break;
case '{':
{
char bitfmt[128];
char *p = strchr(++fmt,'}');
int l = PTR_DIFF(p,fmt);
strncpy(bitfmt,fmt,l);
bitfmt[l]=0;
fmt = p+1;
write_bits(CVAL(buf,0),bitfmt);
buf++;
break;
}
case 'P':
{
int l = atoi(fmt+1);
buf += l;
fmt++;
while (isdigit(*fmt)) fmt++;
break;
}
case 'r':
reverse = !reverse;
fmt++;
break;
case 'D':
{
unsigned int x = reverse?RIVAL(buf,0):IVAL(buf,0);
printf("%d (0x%x)",x, x);
buf += 4;
fmt++;
break;
}
case 'L':
{
unsigned int x1 = reverse?RIVAL(buf,0):IVAL(buf,0);
unsigned int x2 = reverse?RIVAL(buf,4):IVAL(buf,4);
if (x2) {
printf("0x%08x:%08x",x2, x1);
} else {
printf("%d (0x%08x%08x)",x1, x2, x1);
}
buf += 8;
fmt++;
break;
}
case 'd':
{
unsigned int x = reverse?RSVAL(buf,0):SVAL(buf,0);
printf("%d (0x%x)",x, x);
buf += 2;
fmt++;
break;
}
case 'W':
{
unsigned int x = reverse?RIVAL(buf,0):IVAL(buf,0);
printf("0x%X",x);
buf += 4;
fmt++;
break;
}
case 'w':
{
unsigned int x = reverse?RSVAL(buf,0):SVAL(buf,0);
printf("0x%X",x);
buf += 2;
fmt++;
break;
}
case 'B':
{
unsigned int x = CVAL(buf,0);
printf("0x%X",x);
buf += 1;
fmt++;
break;
}
case 'b':
{
unsigned int x = CVAL(buf,0);
printf("%d (0x%x)",x, x);
buf += 1;
fmt++;
break;
}
case 'S':
{
printf("%.*s",(int)PTR_DIFF(maxbuf,buf),unistr(buf, &len));
buf += len;
fmt++;
break;
}
case 'Z':
{
if (*buf != 4 && *buf != 2)
printf("Error! ASCIIZ buffer of type %d (safety=%d)\n",
*buf,(int)PTR_DIFF(maxbuf,buf));
printf("%.*s",(int)PTR_DIFF(maxbuf,buf+1),unistr(buf+1, &len));
buf += len+1;
fmt++;
break;
}
case 's':
{
int l = atoi(fmt+1);
printf("%-*.*s",l,l,buf);
buf += l;
fmt++; while (isdigit(*fmt)) fmt++;
break;
}
case 'h':
{
int l = atoi(fmt+1);
while (l--) printf("%02x",*buf++);
fmt++; while (isdigit(*fmt)) fmt++;
break;
}
case 'n':
{
int t = atoi(fmt+1);
char nbuf[255];
int name_type;
switch (t) {
case 1:
name_type = name_extract(startbuf,PTR_DIFF(buf,startbuf),nbuf);
buf += name_len(buf);
printf("%-15.15s NameType=0x%02X (%s)",
nbuf,name_type,name_type_str(name_type));
break;
case 2:
name_type = buf[15];
printf("%-15.15s NameType=0x%02X (%s)",
buf,name_type,name_type_str(name_type));
buf += 16;
break;
}
fmt++; while (isdigit(*fmt)) fmt++;
break;
}
case 'T':
{
time_t t;
int x = IVAL(buf,0);
switch (atoi(fmt+1)) {
case 1:
if (x==0 || x==-1 || x==0xFFFFFFFF)
t = 0;
else
t = make_unix_date(buf);
buf+=4;
break;
case 2:
if (x==0 || x==-1 || x==0xFFFFFFFF)
t = 0;
else
t = make_unix_date2(buf);
buf+=4;
break;
case 3:
t = interpret_long_date(buf);
buf+=8;
break;
}
printf("%s",t?asctime(localtime(&t)):"NULL\n");
fmt++; while (isdigit(*fmt)) fmt++;
break;
}
default:
putchar(*fmt);
fmt++;
break;
}
}
if (buf>=maxbuf && *fmt)
printf("END OF BUFFER\n");
return(buf);
}
const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
{
static int depth=0;
char s[128];
char *p;
while (*fmt) {
switch (*fmt) {
case '*':
fmt++;
while (buf < maxbuf) {
const uchar *buf2;
depth++;
buf2 = fdata(buf,fmt,maxbuf);
depth--;
if (buf2 == buf) return(buf);
buf = buf2;
}
break;
case '|':
fmt++;
if (buf>=maxbuf) return(buf);
break;
case '%':
fmt++;
buf=maxbuf;
break;
case '#':
fmt++;
return(buf);
break;
case '[':
fmt++;
if (buf>=maxbuf) return(buf);
bzero(s,sizeof(s));
p = strchr(fmt,']');
strncpy(s,fmt,p-fmt);
fmt = p+1;
buf = fdata1(buf,s,maxbuf);
break;
default:
putchar(*fmt); fmt++;
fflush(stdout);
break;
}
}
if (!depth && buf<maxbuf) {
int len = PTR_DIFF(maxbuf,buf);
printf("Data: (%d bytes)\n",len);
print_data(buf,len);
return(buf+len);
}
return(buf);
}
typedef struct
{
char *name;
int code;
char *message;
} err_code_struct;
/* Dos Error Messages */
static err_code_struct dos_msgs[] = {
{"ERRbadfunc",1,"Invalid function."},
{"ERRbadfile",2,"File not found."},
{"ERRbadpath",3,"Directory invalid."},
{"ERRnofids",4,"No file descriptors available"},
{"ERRnoaccess",5,"Access denied."},
{"ERRbadfid",6,"Invalid file handle."},
{"ERRbadmcb",7,"Memory control blocks destroyed."},
{"ERRnomem",8,"Insufficient server memory to perform the requested function."},
{"ERRbadmem",9,"Invalid memory block address."},
{"ERRbadenv",10,"Invalid environment."},
{"ERRbadformat",11,"Invalid format."},
{"ERRbadaccess",12,"Invalid open mode."},
{"ERRbaddata",13,"Invalid data."},
{"ERR",14,"reserved."},
{"ERRbaddrive",15,"Invalid drive specified."},
{"ERRremcd",16,"A Delete Directory request attempted to remove the server's current directory."},
{"ERRdiffdevice",17,"Not same device."},
{"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."},
{"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
{"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
{"ERRfilexists",80,"The file named in a Create Directory, Make New File or Link request already exists."},
{"ERRbadpipe",230,"Pipe invalid."},
{"ERRpipebusy",231,"All instances of the requested pipe are busy."},
{"ERRpipeclosing",232,"Pipe close in progress."},
{"ERRnotconnected",233,"No process on other end of pipe."},
{"ERRmoredata",234,"There is more data to be returned."},
{NULL,-1,NULL}};
/* Server Error Messages */
err_code_struct server_msgs[] = {
{"ERRerror",1,"Non-specific error code."},
{"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
{"ERRbadtype",3,"reserved."},
{"ERRaccess",4,"The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."},
{"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
{"ERRinvnetname",6,"Invalid network name in tree connect."},
{"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
{"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
{"ERRqtoobig",50,"Print queue full -- no space."},
{"ERRqeof",51,"EOF on print queue dump."},
{"ERRinvpfid",52,"Invalid print file FID."},
{"ERRsmbcmd",64,"The server did not recognize the command received."},
{"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
{"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
{"ERRreserved",68,"reserved."},
{"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
{"ERRreserved",70,"reserved."},
{"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
{"ERRpaused",81,"Server is paused."},
{"ERRmsgoff",82,"Not receiving messages."},
{"ERRnoroom",83,"No room to buffer message."},
{"ERRrmuns",87,"Too many remote user names."},
{"ERRtimeout",88,"Operation timed out."},
{"ERRnoresource",89,"No resources currently available for request."},
{"ERRtoomanyuids",90,"Too many UIDs active on this session."},
{"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
{"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
{"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
{"ERRcontmpx",252,"Continue in MPX mode."},
{"ERRreserved",253,"reserved."},
{"ERRreserved",254,"reserved."},
{"ERRnosupport",0xFFFF,"Function not supported."},
{NULL,-1,NULL}};
/* Hard Error Messages */
err_code_struct hard_msgs[] = {
{"ERRnowrite",19,"Attempt to write on write-protected diskette."},
{"ERRbadunit",20,"Unknown unit."},
{"ERRnotready",21,"Drive not ready."},
{"ERRbadcmd",22,"Unknown command."},
{"ERRdata",23,"Data error (CRC)."},
{"ERRbadreq",24,"Bad request structure length."},
{"ERRseek",25 ,"Seek error."},
{"ERRbadmedia",26,"Unknown media type."},
{"ERRbadsector",27,"Sector not found."},
{"ERRnopaper",28,"Printer out of paper."},
{"ERRwrite",29,"Write fault."},
{"ERRread",30,"Read fault."},
{"ERRgeneral",31,"General failure."},
{"ERRbadshare",32,"A open conflicts with an existing open."},
{"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
{"ERRwrongdisk",34,"The wrong disk was found in a drive."},
{"ERRFCBUnavail",35,"No FCBs are available to process request."},
{"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
{NULL,-1,NULL}};
static struct
{
int code;
char *class;
err_code_struct *err_msgs;
} err_classes[] = {
{0,"SUCCESS",NULL},
{0x01,"ERRDOS",dos_msgs},
{0x02,"ERRSRV",server_msgs},
{0x03,"ERRHRD",hard_msgs},
{0x04,"ERRXOS",NULL},
{0xE1,"ERRRMX1",NULL},
{0xE2,"ERRRMX2",NULL},
{0xE3,"ERRRMX3",NULL},
{0xFF,"ERRCMD",NULL},
{-1,NULL,NULL}};
/****************************************************************************
return a SMB error string from a SMB buffer
****************************************************************************/
char *smb_errstr(int class,int num)
{
static char ret[128];
int i,j;
ret[0]=0;
for (i=0;err_classes[i].class;i++)
if (err_classes[i].code == class)
{
if (err_classes[i].err_msgs)
{
err_code_struct *err = err_classes[i].err_msgs;
for (j=0;err[j].name;j++)
if (num == err[j].code)
{
sprintf(ret,"%s - %s (%s)",err_classes[i].class,
err[j].name,err[j].message);
return ret;
}
}
sprintf(ret,"%s - %d",err_classes[i].class,num);
return ret;
}
sprintf(ret,"ERROR: Unknown error (%d,%d)",class,num);
return(ret);
}

View file

@ -10,9 +10,9 @@
* is provided ``as is'' without express or implied warranty.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
#endif /* LIBC_SCCS and not lint */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>

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