merge conflicts

This commit is contained in:
christos 2013-04-06 19:33:07 +00:00
parent 9546e36db8
commit 0e9868ba9d
178 changed files with 4421 additions and 29341 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.7 2011/08/17 10:48:02 christos Exp $
# $NetBSD: Makefile,v 1.8 2013/04/06 19:33:07 christos Exp $
WARNS?= 1 # XXX: need to cleanup later
@ -16,40 +16,127 @@ PROG= tcpdump
MAN= tcpdump.8
SRCS= addrtoname.c cpack.c gmpls.c gmt2local.c machdep.c oui.c parsenfsfh.c \
pf_print_state.c \
print-802_11.c print-ah.c print-aodv.c print-ap1394.c print-arcnet.c \
print-arp.c \
print-ascii.c print-atalk.c print-atm.c print-bfd.c print-bgp.c \
print-bootp.c print-beep.c print-cdp.c print-chdlc.c \
print-cip.c print-cnfp.c print-decnet.c print-domain.c \
print-dvmrp.c print-egp.c print-enc.c print-esp.c print-ether.c \
print-fddi.c print-fr.c print-gre.c print-hsrp.c print-icmp.c \
print-igmp.c print-igrp.c print-ip.c print-ipcomp.c print-ipfc.c \
print-ipx.c print-isakmp.c print-isoclns.c print-krb.c \
print-l2tp.c print-lane.c print-ldp.c print-llc.c print-lwres.c \
print-msdp.c print-mobile.c print-mobility.c print-mpls.c print-nfs.c \
print-ntp.c print-null.c print-ospf.c print-pflog.c print-pfsync.c \
print-pim.c print-ppp.c print-pppoe.c print-pptp.c \
print-radius.c print-raw.c print-rip.c print-rsvp.c print-rx.c \
print-sctp.c print-sl.c print-sll.c print-smb.c print-snmp.c \
print-stp.c print-sunatm.c print-sunrpc.c print-tcp.c \
print-telnet.c print-tftp.c print-timed.c print-token.c \
print-udp.c print-vjc.c print-vrrp.c print-wb.c print-zephyr.c \
setsignal.c smbutil.c tcpdump.c util.c checksum.c signature.c
SRCS+= print-eigrp.c l2vpn.c print-slow.c print-eap.c nlpid.c print-dccp.c \
print-pgm.c ipproto.c print-syslog.c print-sip.c print-lmp.c \
print-lspping.c print-symantec.c print-juniper.c af.c print-olsr.c \
print-sflow.c print-vqp.c print-lwapp.c print-ipnet.c print-forces.c \
print-vtp.c print-udld.c print-dtp.c print-rrcp.c print-mpcp.c \
print-lldp.c print-cfm.c
setsignal.c smbutil.c tcpdump.c util.c checksum.c signature.c \
l2vpn.c nlpid.c ipproto.c af.c in_cksum.c pf_print_state.c
SRCS+= bpf_dump.c
SRCS+= version.c
# disabled for now
#SRCS+= print-smb.c smbutil.c
SRCS+= \
print-802_11.c \
print-802_15_4.c \
print-ah.c \
print-aodv.c \
print-ap1394.c \
print-arcnet.c \
print-arp.c \
print-ascii.c \
print-atalk.c \
print-atm.c \
print-babel.c \
print-beep.c \
print-bfd.c \
print-bgp.c \
print-bootp.c \
print-bt.c \
print-carp.c \
print-cdp.c \
print-cfm.c \
print-chdlc.c \
print-cip.c \
print-cnfp.c \
print-dccp.c \
print-decnet.c \
print-domain.c \
print-dtp.c \
print-dvmrp.c \
print-eap.c \
print-egp.c \
print-eigrp.c \
print-enc.c \
print-esp.c \
print-ether.c \
print-fddi.c \
print-forces.c \
print-fr.c \
print-frag6.c \
print-gre.c \
print-hsrp.c \
print-icmp.c \
print-igmp.c \
print-igrp.c \
print-ip.c \
print-ipcomp.c \
print-ipfc.c \
print-ipnet.c \
print-ipx.c \
print-isakmp.c \
print-isoclns.c \
print-juniper.c \
print-krb.c \
print-l2tp.c \
print-lane.c \
print-ldp.c \
print-llc.c \
print-lldp.c \
print-lmp.c \
print-lspping.c \
print-lwapp.c \
print-lwres.c \
print-mobile.c \
print-mobility.c \
print-mpcp.c \
print-mpls.c \
print-msdp.c \
print-nfs.c \
print-ntp.c \
print-null.c \
print-olsr.c \
print-ospf.c \
print-pflog.c \
print-pfsync.c \
print-pgm.c \
print-pim.c \
print-ppi.c \
print-ppp.c \
print-pppoe.c \
print-pptp.c \
print-radius.c \
print-raw.c \
print-rip.c \
print-ripng.c \
print-rpki-rtr.c \
print-rrcp.c \
print-rsvp.c \
print-rx.c \
print-sctp.c \
print-sflow.c \
print-sip.c \
print-sl.c \
print-sll.c \
print-slow.c \
print-smb.c \
print-snmp.c \
print-stp.c \
print-sunatm.c \
print-sunrpc.c \
print-symantec.c \
print-syslog.c \
print-tcp.c \
print-telnet.c \
print-tftp.c \
print-timed.c \
print-tipc.c \
print-token.c \
print-udld.c \
print-udp.c \
print-usb.c \
print-vjc.c \
print-vqp.c \
print-vrrp.c \
print-vtp.c \
print-wb.c \
print-zephyr.c
version.c: VERSION
${_MKTARGET_CREATE}
@ -58,7 +145,7 @@ version.c: VERSION
LDADD+= -lpcap -ll
DPADD+= ${LIBPCAP} ${LIBL}
CPPFLAGS+= -I${.CURDIR}/../include -I${.CURDIR} -I${SRCDIR}
CPPFLAGS+= -I${.CURDIR}/../include -I${.CURDIR} -I${SRCDIR} -DHAVE_CONFIG_H
CPPFLAGS+= -I${NETBSDSRCDIR}/dist/pf/sbin/pfctl \
-I${NETBSDSRCDIR}/sys/dist/pf
@ -70,8 +157,8 @@ CPPFLAGS+=-DWITH_USER=\"_tcpdump\"
CPPFLAGS+=-DWITH_CHROOT=\"/var/chroot/tcpdump\"
.if (${USE_INET6} != "no")
SRCS+= print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c \
print-rt6.c print-ospf6.c print-dhcp6.c
SRCS+= print-ip6.c print-ip6opts.c print-icmp6.c \
print-rt6.c print-dhcp6.c print-ospf6.c
CPPFLAGS+=-DINET6=1 -DHAVE_RES_USE_INET6=1
.endif

View File

@ -25,10 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.119 2007-08-08 14:06:34 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: addrtoname.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
"@(#) Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.119 2007-08-08 14:06:34 hannes Exp (LBL)";
#endif
__RCSID("$NetBSD: addrtoname.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#ifdef HAVE_CONFIG_H
@ -512,6 +511,34 @@ etheraddr_string(register const u_char *ep)
return (tp->e_name);
}
const char *
le64addr_string(const u_char *ep)
{
const unsigned int len = 8;
register u_int i;
register char *cp;
register struct enamemem *tp;
char buf[BUFSIZE];
tp = lookup_bytestring(ep, len);
if (tp->e_name)
return (tp->e_name);
cp = buf;
for (i = len; i > 0 ; --i) {
*cp++ = hex[*(ep + i - 1) >> 4];
*cp++ = hex[*(ep + i - 1) & 0xf];
*cp++ = ':';
}
cp --;
*cp = '\0';
tp->e_name = strdup(buf);
return (tp->e_name);
}
const char *
linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int len)
{

View File

@ -19,9 +19,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/af.c,v 1.3 2006-03-23 14:58:44 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/af.c,v 1.3 2006-03-23 14:58:44 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: af.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: af.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#endif

View File

@ -22,9 +22,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.17 2008-02-14 20:53:49 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.17 2008-02-14 20:53:49 guy Exp (LBL)";
#else
__RCSID("$NetBSD: bpf_dump.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: bpf_dump.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#endif

View File

@ -21,9 +21,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/checksum.c,v 1.4 2006-09-25 09:23:32 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/checksum.c,v 1.4 2006-09-25 09:23:32 hannes Exp ";
#else
__RCSID("$NetBSD: checksum.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: checksum.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
dnl @(#) Header: /tcpdump/master/tcpdump/configure.in,v 1.204 2008-11-18 07:39:20 guy Exp (LBL)
dnl @(#) Header: /tcpdump/master/tcpdump/configure.in,v 1.204 2008-11-18 07:39:20 guy Exp (LBL)
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
@ -15,7 +15,7 @@ dnl
# config.sub.
#
AC_REVISION($Revision: 1.2 $)
AC_REVISION(Revision: 1.204 )
AC_PREREQ(2.50)
AC_INIT(tcpdump.c)
@ -29,7 +29,7 @@ AC_C___ATTRIBUTE__
if test "$ac_cv___attribute__" = "yes"; then
AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
fi
AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netdnet/dnetdb.h)
AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>])
@ -60,6 +60,33 @@ AC_HEADER_TIME
case "$host_os" in
darwin*)
AC_ARG_ENABLE(universal,
AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
if test "$enable_universal" != "no"; then
case "$host_os" in
darwin9.*)
#
# Leopard. Build for x86 and 32-bit PowerPC, with
# x86 first. (That's what Apple does.)
#
V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
;;
darwin10.*)
#
# Snow Leopard. Build for x86-64 and x86, with
# x86-64 first. (That's what Apple does.)
#
V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
;;
esac
fi
;;
linux*)
AC_MSG_CHECKING(Linux kernel version)
if test "$cross_compiling" = yes; then
@ -172,7 +199,7 @@ AC_ARG_ENABLE(ipv6,
--disable-ipv6 disable ipv6 support],
[ case "$enableval" in
yes) AC_MSG_RESULT(yes)
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
AC_DEFINE(INET6)
ipv6=yes
;;
@ -194,7 +221,7 @@ main()
}
],
[ AC_MSG_RESULT(yes)
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
AC_DEFINE(INET6)
ipv6=yes],
[ AC_MSG_RESULT(no)
@ -467,15 +494,6 @@ if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA)
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)
AC_CHECK_SIZEOF(long long, 8)
dnl
dnl Checks for addrinfo structure
AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
@ -504,34 +522,8 @@ 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 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)
AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
AC_CHECK_FUNCS(strftime)
AC_CHECK_FUNCS(fork vfork strftime)
AC_CHECK_FUNCS(setlinebuf alarm)
needsnprintf=no
@ -723,15 +715,24 @@ fi
#
# Do we have the new open API? Check for pcap_create, and assume that,
# if we do, we also have pcap_activate() and the other new routines.
# if we do, we also have pcap_activate() and the other new routines
# introduced in libpcap 1.0.0.
#
AC_CHECK_FUNCS(pcap_create)
if test $ac_cv_func_pcap_create = "yes" ; then
#
# OK, do we have pcap_set_tstamp_type? If so, assume we have
# pcap_list_tstamp_types and pcap_free_tstamp_types as well.
#
AC_CHECK_FUNCS(pcap_set_tstamp_type)
fi
AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version)
if test $ac_cv_func_pcap_findalldevs = "yes" ; then
dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
dnl have pcap_if_t.
savedppflags="$CPPLAGS"
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
CPPFLAGS="$savedcppflags"
@ -803,7 +804,7 @@ case "$host_os" in
aix*)
dnl Workaround to enable certain features
AC_DEFINE(_SUN)
AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
;;
hpux*)
@ -849,16 +850,6 @@ if test -f /dev/bpf -o -f /dev/bpf0; then
V_GROUP=bpf
fi
#
# Check for some headers introduced in later versions of libpcap
# and used by some printers.
#
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_HEADERS(pcap/bluetooth.h)
AC_CHECK_HEADERS(pcap/usb.h)
CPPFLAGS="$savedcppflags"
AC_CHECK_HEADERS(sys/bitypes.h)
AC_CHECK_TYPE([int8_t], ,
@ -980,6 +971,19 @@ if test "$ac_lbl_inttypes_h_defines_formats" = no; then
])
fi
#
# Check for some headers introduced in later versions of libpcap
# and used by some printers.
#
# Those headers use the {u_}intN_t types, so we must do this after
# we check for what's needed to get them defined.
#
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include <tcpdump-stdinc.h>])
AC_CHECK_HEADERS(pcap/usb.h,,,[#include <tcpdump-stdinc.h>])
CPPFLAGS="$savedcppflags"
AC_PROG_RANLIB
AC_LBL_DEVEL(V_CCOPT)
@ -1063,8 +1067,10 @@ if test "$want_libcrypto" != "no"; then
fi
AC_CHECK_LIB(crypto, DES_cbc_encrypt)
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_HEADERS(openssl/evp.h)
CPPFLAGS="$savedcppflags"
else
#
# Not found. Did the user explicitly ask for it?
@ -1079,8 +1085,8 @@ fi
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"
CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
V_INCLS="$V_INCLS -I$srcdir/missing"
fi
AC_SUBST(V_CCOPT)

View File

@ -35,7 +35,7 @@
#include "cpack.h"
#include "extract.h"
static u_int8_t *
u_int8_t *
cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
{
size_t misalignment = (size_t)(p - buf) % alignment;
@ -50,7 +50,7 @@ cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
* wordsize bytes remain in the buffer after the boundary. Otherwise,
* return a pointer to the boundary.
*/
static u_int8_t *
u_int8_t *
cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
{
u_int8_t *next;

View File

@ -40,6 +40,9 @@ int cpack_uint16(struct cpack_state *, u_int16_t *);
int cpack_uint32(struct cpack_state *, u_int32_t *);
int cpack_uint64(struct cpack_state *, u_int64_t *);
u_int8_t *cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment);
u_int8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
#define cpack_int8(__s, __p) cpack_uint8((__s), (u_int8_t*)(__p))
#define cpack_int16(__s, __p) cpack_uint16((__s), (u_int16_t*)(__p))
#define cpack_int32(__s, __p) cpack_uint32((__s), (u_int32_t*)(__p))

View File

@ -1,3 +1,4 @@
/* @(#) Header: /tcpdump/master/tcpdump/ether.h,v 1.8 2002-12-11 07:13:51 guy Exp (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) Header: /tcpdump/master/tcpdump/extract.h,v 1.25 2006-01-30 16:20:07 hannes Exp (LBL)
* @(#) Header: /tcpdump/master/tcpdump/extract.h,v 1.25 2006-01-30 16:20:07 hannes Exp (LBL)
*/
#ifdef __NetBSD__

View File

@ -17,9 +17,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/gmpls.c,v 1.7 2006-04-14 07:11:59 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/gmpls.c,v 1.7 2006-04-14 07:11:59 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: gmpls.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: gmpls.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.9 2003-11-16 09:36:09 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.9 2003-11-16 09:36:09 guy Exp (LBL)";
#else
__RCSID("$NetBSD: gmt2local.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: gmt2local.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#endif

View File

@ -1,4 +1,4 @@
/* @(#) Header: /tcpdump/master/tcpdump/icmp6.h,v 1.18 2007-08-29 02:31:44 mcr Exp (LBL) */
/* @(#) Header: /tcpdump/master/tcpdump/icmp6.h,v 1.18 2007-08-29 02:31:44 mcr Exp (LBL) */
/* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */

View File

@ -1,6 +1,6 @@
/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
/* Header: /tcpdump/master/tcpdump/ieee802_11_radio.h,v 1.3 2007-08-29 02:31:44 mcr Exp */
/* Header: /tcpdump/master/tcpdump/ieee802_11_radio.h,v 1.3 2007-08-29 02:31:44 mcr Exp */
/*-
* Copyright (c) 2003, 2004 David Young. All rights reserved.
@ -155,6 +155,10 @@ struct ieee80211_radiotap_header {
* Unitless indication of the Rx/Tx antenna for this packet.
* The first antenna is antenna 0.
*
* IEEE80211_RADIOTAP_RX_FLAGS u_int16_t bitmap
*
* Properties of received frames. See flags defined below.
*
* IEEE80211_RADIOTAP_XCHANNEL u_int32_t bitmap
* u_int16_t MHz
* u_int8_t channel number
@ -165,6 +169,25 @@ struct ieee80211_radiotap_header {
* finally the maximum regulatory transmit power cap in .5 dBm
* units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
* and only one of the two should be present.
*
* IEEE80211_RADIOTAP_MCS u_int8_t known
* u_int8_t flags
* u_int8_t mcs
*
* Bitset indicating which fields have known values, followed
* by bitset of flag values, followed by the MCS rate index as
* in IEEE 802.11n.
*
* IEEE80211_RADIOTAP_VENDOR_NAMESPACE
* u_int8_t OUI[3]
* u_int8_t subspace
* u_int16_t length
*
* The Vendor Namespace Field contains three sub-fields. The first
* sub-field is 3 bytes long. It contains the vendor's IEEE 802
* Organizationally Unique Identifier (OUI). The fourth byte is a
* vendor-specific "namespace selector."
*
*/
enum ieee80211_radiotap_type {
IEEE80211_RADIOTAP_TSFT = 0,
@ -181,8 +204,12 @@ enum ieee80211_radiotap_type {
IEEE80211_RADIOTAP_ANTENNA = 11,
IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
IEEE80211_RADIOTAP_RX_FLAGS = 14,
/* NB: gap for netbsd definitions */
IEEE80211_RADIOTAP_XCHANNEL = 18,
IEEE80211_RADIOTAP_MCS = 19,
IEEE80211_RADIOTAP_NAMESPACE = 29,
IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
IEEE80211_RADIOTAP_EXT = 31
};
@ -203,6 +230,19 @@ enum ieee80211_radiotap_type {
#define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
#define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
/* Useful combinations of channel characteristics, borrowed from Ethereal */
#define IEEE80211_CHAN_A \
(IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
#define IEEE80211_CHAN_B \
(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
#define IEEE80211_CHAN_G \
(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
#define IEEE80211_CHAN_TA \
(IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
#define IEEE80211_CHAN_TG \
(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO)
/* For IEEE80211_RADIOTAP_FLAGS */
#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
* during CFP
@ -223,6 +263,26 @@ enum ieee80211_radiotap_type {
* (to 32-bit boundary)
*/
#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
#define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */
/* For IEEE80211_RADIOTAP_RX_FLAGS */
#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */
/* For IEEE80211_RADIOTAP_MCS known */
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01
#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */
#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04
#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08
#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10
/* For IEEE80211_RADIOTAP_MCS flags */
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3
#define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */
#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08
#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */

View File

@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) Header: /tcpdump/master/tcpdump/interface.h,v 1.285 2008-08-16 11:36:20 hannes Exp (LBL)
* @(#) Header: /tcpdump/master/tcpdump/interface.h,v 1.285 2008-08-16 11:36:20 hannes Exp (LBL)
*/
#ifndef tcpdump_interface_h
@ -28,10 +28,6 @@
#include "os-proto.h"
#endif
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#endif
/* snprintf et al */
#include <stdarg.h>
@ -74,6 +70,7 @@ extern char *strsep(char **, const char *);
#define PT_CNFP 7 /* Cisco NetFlow protocol */
#define PT_TFTP 8 /* trivial file transfer protocol */
#define PT_AODV 9 /* Ad-hoc On-demand Distance Vector Protocol */
#define PT_CARP 10 /* Common Address Redundancy Protocol */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
@ -166,7 +163,6 @@ extern void hex_and_ascii_print(const char *, const u_char *, u_int);
extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
extern void hex_print(const char *, const u_char *, u_int);
extern void telnet_print(const u_char *, u_int);
extern int ethertype_print(u_short, const u_char *, u_int, u_int);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
const u_char *, u_short *);
extern int snap_print(const u_char *, u_int, u_int, u_int);
@ -191,9 +187,6 @@ extern u_int pfsync_if_print(const struct pcap_pkthdr *, const u_char *);
extern void pfsync_ip_print(const u_char*, u_int, const u_char *);
extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
extern void ether_print(const u_char *, u_int, u_int,
void (*)(const u_char *), const u_char *);
extern u_int ether_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int token_print(const u_char *, u_int, u_int);
extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
extern void fddi_print(const u_char *, u_int, u_int);
@ -233,6 +226,7 @@ extern void cisco_autorp_print(const u_char *, u_int);
extern void rsvp_print(const u_char *, u_int);
extern void ldp_print(const u_char *, u_int);
extern void lldp_print(const u_char *, u_int);
extern void rpki_rtr_print(const u_char *, u_int);
extern void lmp_print(const u_char *, u_int);
extern void lspping_print(const u_char *, u_int);
extern void lwapp_control_print(const u_char *, u_int, int);
@ -299,6 +293,7 @@ extern const char *nt_errstr(u_int32_t);
extern void print_data(const unsigned char *, int);
extern void l2tp_print(const u_char *, u_int);
extern void vrrp_print(const u_char *, u_int, int);
extern void carp_print(const u_char *, u_int, int);
extern void slow_print(const u_char *, u_int);
extern void sflow_print(const u_char *, u_int);
extern void mpcp_print(const u_char *, u_int);
@ -324,10 +319,9 @@ extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *);
extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
#ifdef INET6
extern void ip6_print(const u_char *, u_int);
extern void ip6_opt_print(const u_char *, int);
extern int nextproto6_cksum(const struct ip6_hdr *, const u_short *, u_int, u_int);
extern int hbhopt_print(const u_char *);
extern int dstopt_print(const u_char *);
extern int frag6_print(const u_char *, const u_char *);
@ -336,9 +330,15 @@ extern void ripng_print(const u_char *, unsigned int);
extern int rt6_print(const u_char *, const u_char *);
extern void ospf6_print(const u_char *, u_int);
extern void dhcp6_print(const u_char *, u_int);
extern void babel_print(const u_char *, u_int);
extern int mask62plen(const u_char *);
#endif /*INET6*/
extern u_short in_cksum(const u_short *, register u_int, int);
struct cksum_vec {
const u_int8_t *ptr;
int len;
};
extern u_int16_t in_cksum(const struct cksum_vec *, int);
extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
#ifndef HAVE_BPF_DUMP
@ -358,6 +358,7 @@ extern netdissect_options *gndo;
#define bflag gndo->ndo_bflag
#define eflag gndo->ndo_eflag
#define fflag gndo->ndo_fflag
#define jflag gndo->ndo_jflag
#define Kflag gndo->ndo_Kflag
#define nflag gndo->ndo_nflag
#define Nflag gndo->ndo_Nflag
@ -386,6 +387,7 @@ extern netdissect_options *gndo;
#define Cflag_count gndo->ndo_Cflag_count
#define Gflag_count gndo->ndo_Gflag_count
#define Gflag_time gndo->ndo_Gflag_time
#define Hflag gndo->ndo_Hflag
#define snaplen gndo->ndo_snaplen
#define snapend gndo->ndo_snapend

View File

@ -1,4 +1,4 @@
/* @(#) Header: /tcpdump/master/tcpdump/ip.h,v 1.12 2007-09-14 01:29:28 guy Exp (LBL) */
/* @(#) Header: /tcpdump/master/tcpdump/ip.h,v 1.12 2007-09-14 01:29:28 guy Exp (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@ -58,7 +58,7 @@ struct ip {
u_int8_t ip_p; /* protocol */
u_int16_t ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
};
} UNALIGNED;
#define IP_MAXPACKET 65535 /* maximum packet size */
@ -130,7 +130,7 @@ struct ip_timestamp {
u_int32_t ipt_time;
} ipt_ta[1];
} ipt_timestamp;
};
} UNALIGNED;
/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY 0 /* timestamps only */
@ -157,4 +157,4 @@ struct ip_timestamp {
#define IP_MSS 576 /* default maximum segment size */
/* in print-ip.c */
extern u_int32_t ip_finddst(const struct ip *);
extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);

View File

@ -1,4 +1,4 @@
/* @(#) Header: /tcpdump/master/tcpdump/ip6.h,v 1.8 2007-08-29 02:31:44 mcr Exp (LBL) */
/* @(#) Header: /tcpdump/master/tcpdump/ip6.h,v 1.8 2007-08-29 02:31:44 mcr Exp (LBL) */
/* NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp */
/* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */
@ -82,21 +82,7 @@ struct ip6_hdr {
} ip6_ctlun;
struct in6_addr ip6_src; /* source address */
struct in6_addr ip6_dst; /* destination address */
};
/*
* Pseudo header, used for higher layer checksumming.
*/
union ip6_pseudo_hdr {
struct {
struct in6_addr ph_src;
struct in6_addr ph_dst;
u_int32_t ph_len;
u_int8_t ph_zero[3];
u_int8_t ph_nxt;
} ph;
u_int16_t pa[20];
};
} UNALIGNED;
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
@ -119,25 +105,23 @@ union ip6_pseudo_hdr {
*/
struct ip6_ext {
u_char ip6e_nxt;
u_char ip6e_len;
};
u_int8_t ip6e_nxt;
u_int8_t ip6e_len;
} UNALIGNED;
/* Hop-by-Hop options header */
/* XXX should we pad it to force alignment on an 8-byte boundary? */
struct ip6_hbh {
u_int8_t ip6h_nxt; /* next header */
u_int8_t ip6h_len; /* length in units of 8 octets */
/* followed by options */
};
} UNALIGNED;
/* Destination options header */
/* XXX should we pad it to force alignment on an 8-byte boundary? */
struct ip6_dest {
u_int8_t ip6d_nxt; /* next header */
u_int8_t ip6d_len; /* length in units of 8 octets */
/* followed by options */
};
} UNALIGNED;
/* Option types and related macros */
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
@ -173,7 +157,7 @@ struct ip6_rthdr {
u_int8_t ip6r_type; /* routing type */
u_int8_t ip6r_segleft; /* segments left */
/* followed by routing type specific data */
};
} UNALIGNED;
/* Type 0 Routing header */
struct ip6_rthdr0 {
@ -184,7 +168,7 @@ struct ip6_rthdr0 {
u_int8_t ip6r0_reserved; /* reserved field */
u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */
struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
};
} UNALIGNED;
/* Fragment header */
struct ip6_frag {
@ -192,10 +176,13 @@ struct ip6_frag {
u_int8_t ip6f_reserved; /* reserved field */
u_int16_t ip6f_offlg; /* offset, reserved, and flag */
u_int32_t ip6f_ident; /* identification */
};
} UNALIGNED;
#define IP6F_OFF_MASK 0xfff8 /* mask out offset from ip6f_offlg */
#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
/* in print-ip6.c */
extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
#endif /* not _NETINET_IP6_H_ */

View File

@ -17,9 +17,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/ipproto.c,v 1.6 2005-09-20 06:01:22 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/ipproto.c,v 1.6 2005-09-20 06:01:22 guy Exp (LBL)";
#else
__RCSID("$NetBSD: ipproto.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: ipproto.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#endif
@ -61,6 +61,7 @@ const struct tok ipproto_values[] = {
{ IPPROTO_SCTP, "SCTP" },
{ IPPROTO_MOBILITY, "Mobility" },
{ IPPROTO_PFSYNC, "PFSYNC" },
{ IPPROTO_CARP, "CARP" },
{ 0, NULL }
};

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#) Header: /tcpdump/master/tcpdump/ipproto.h,v 1.6 2005-09-20 06:01:22 guy Exp (LBL)
* @(#) Header: /tcpdump/master/tcpdump/ipproto.h,v 1.6 2005-09-20 06:01:22 guy Exp (LBL)
*
* From:
* @(#)in.h 8.3 (Berkeley) 1/3/94
@ -129,6 +129,9 @@ extern const struct tok ipproto_values[];
#ifndef IPPROTO_VRRP
#define IPPROTO_VRRP 112
#endif
#ifndef IPPROTO_CARP
#define IPPROTO_CARP 112
#endif
#ifndef IPPROTO_PGM
#define IPPROTO_PGM 113
#endif

View File

@ -17,9 +17,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/l2vpn.c,v 1.1 2004-06-15 09:42:40 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/l2vpn.c,v 1.1 2004-06-15 09:42:40 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: l2vpn.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: l2vpn.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/machdep.c,v 1.13 2003-12-15 03:53:21 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/machdep.c,v 1.13 2003-12-15 03:53:21 guy Exp (LBL)";
#else
__RCSID("$NetBSD: machdep.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: machdep.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#endif

View File

@ -1,36 +0,0 @@
/*
* 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

@ -1,117 +0,0 @@
/*
* 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 */
#ifndef HAVE_U_INT64_T
#if SIZEOF_LONG_LONG == 8
typedef unsigned long long u_int64_t;
#elif defined(_MSC_EXTENSIONS)
typedef unsigned _int64 u_int64_t;
#elif SIZEOF_INT == 8
typedef unsigned int u_int64_t;
#elif SIZEOF_LONG == 8
typedef unsigned long u_int64_t;
#elif SIZEOF_SHORT == 8
typedef unsigned short u_int64_t;
#else /* XXX */
#error "there's no appropriate type for u_int64_t"
#endif
#endif /* HAVE_U_INT64_T */
#ifndef PRId64
#ifdef _MSC_EXTENSIONS
#define PRId64 "I64d"
#else /* _MSC_EXTENSIONS */
#define PRId64 "lld"
#endif /* _MSC_EXTENSIONS */
#endif /* PRId64 */
#ifndef PRIo64
#ifdef _MSC_EXTENSIONS
#define PRIo64 "I64o"
#else /* _MSC_EXTENSIONS */
#define PRIo64 "llo"
#endif /* _MSC_EXTENSIONS */
#endif /* PRIo64 */
#ifndef PRIx64
#ifdef _MSC_EXTENSIONS
#define PRIx64 "I64x"
#else /* _MSC_EXTENSIONS */
#define PRIx64 "llx"
#endif /* _MSC_EXTENSIONS */
#endif /* PRIx64 */
#ifndef PRIu64
#ifdef _MSC_EXTENSIONS
#define PRIu64 "I64u"
#else /* _MSC_EXTENSIONS */
#define PRIu64 "llu"
#endif /* _MSC_EXTENSIONS */
#endif /* PRIu64 */

View File

@ -1,36 +0,0 @@
/*
* 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

@ -1,49 +0,0 @@
/*
* 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

@ -1,4 +1,4 @@
/* @(#) Header: /tcpdump/master/tcpdump/nameser.h,v 1.16 2006-11-10 03:18:21 guy Exp (LBL) */
/* @(#) Header: /tcpdump/master/tcpdump/nameser.h,v 1.16 2006-11-10 03:18:21 guy Exp (LBL) */
/*
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.

View File

@ -1,4 +1,4 @@
/* @(#) Header: /tcpdump/master/tcpdump/nfs.h,v 1.9 2007-11-18 03:24:38 guy Exp (LBL) */
/* @(#) Header: /tcpdump/master/tcpdump/nfs.h,v 1.9 2007-11-18 03:24:38 guy Exp (LBL) */
/* NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp */
/*

View File

@ -17,9 +17,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/nlpid.c,v 1.4 2004-10-19 15:27:55 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/nlpid.c,v 1.4 2004-10-19 15:27:55 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: nlpid.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: nlpid.c,v 1.3 2013/04/06 19:33:07 christos Exp $");
#endif
#endif

View File

@ -17,9 +17,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/oui.c,v 1.9 2008-01-09 09:40:47 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/oui.c,v 1.9 2008-01-09 09:40:47 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: oui.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: oui.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -47,6 +47,7 @@ const struct tok oui_values[] = {
{ OUI_IEEE_8021_PRIVATE, "IEEE 802.1 Private"},
{ OUI_IEEE_8023_PRIVATE, "IEEE 802.3 Private"},
{ OUI_TIA, "ANSI/TIA"},
{ OUI_DCBX, "DCBX"},
{ 0, NULL }
};

View File

@ -44,9 +44,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.29 2006-06-13 22:21:38 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.29 2006-06-13 22:21:38 guy Exp (LBL)";
#else
__RCSID("$NetBSD: parsenfsfh.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: parsenfsfh.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/pcap_dump_ftell.c,v 1.1 2005-06-03 22:08:52 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/pcap_dump_ftell.c,v 1.1 2005-06-03 22:08:52 guy Exp (LBL)";
#else
__RCSID("$NetBSD: pcap_dump_ftell.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: pcap_dump_ftell.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -24,9 +24,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.49 2007-12-29 23:25:02 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.49 2007-12-29 23:25:02 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-802_11.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-802_11.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -51,6 +51,15 @@ __RCSID("$NetBSD: print-802_11.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
#include "ieee802_11.h"
#include "ieee802_11_radio.h"
/* Radiotap state */
/* This is used to save state when parsing/processing parameters */
struct radiotap_state
{
u_int32_t present;
u_int8_t rate;
};
#define PRINT_SSID(p) \
if (p.ssid_present) { \
printf(" ("); \
@ -79,32 +88,409 @@ __RCSID("$NetBSD: print-802_11.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
printf("%s", \
CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "" );
static const int ieee80211_htrates[16] = {
13, /* IFM_IEEE80211_MCS0 */
26, /* IFM_IEEE80211_MCS1 */
39, /* IFM_IEEE80211_MCS2 */
52, /* IFM_IEEE80211_MCS3 */
78, /* IFM_IEEE80211_MCS4 */
104, /* IFM_IEEE80211_MCS5 */
117, /* IFM_IEEE80211_MCS6 */
130, /* IFM_IEEE80211_MCS7 */
26, /* IFM_IEEE80211_MCS8 */
52, /* IFM_IEEE80211_MCS9 */
78, /* IFM_IEEE80211_MCS10 */
104, /* IFM_IEEE80211_MCS11 */
156, /* IFM_IEEE80211_MCS12 */
208, /* IFM_IEEE80211_MCS13 */
234, /* IFM_IEEE80211_MCS14 */
260, /* IFM_IEEE80211_MCS15 */
#define MAX_MCS_INDEX 76
/*
* Indices are:
*
* the MCS index (0-76);
*
* 0 for 20 MHz, 1 for 40 MHz;
*
* 0 for a long guard interval, 1 for a short guard interval.
*/
static const float ieee80211_float_htrates[MAX_MCS_INDEX+1][2][2] = {
/* MCS 0 */
{ /* 20 Mhz */ { 6.5, /* SGI */ 7.2, },
/* 40 Mhz */ { 13.5, /* SGI */ 15.0, },
},
/* MCS 1 */
{ /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
/* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
},
/* MCS 2 */
{ /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
/* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
},
/* MCS 3 */
{ /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
/* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
},
/* MCS 4 */
{ /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
/* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
},
/* MCS 5 */
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
},
/* MCS 6 */
{ /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
/* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
},
/* MCS 7 */
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
},
/* MCS 8 */
{ /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
/* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
},
/* MCS 9 */
{ /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
/* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
},
/* MCS 10 */
{ /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
/* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
},
/* MCS 11 */
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
},
/* MCS 12 */
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
},
/* MCS 13 */
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
},
/* MCS 14 */
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
},
/* MCS 15 */
{ /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
/* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
},
/* MCS 16 */
{ /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
/* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
},
/* MCS 17 */
{ /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
/* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
},
/* MCS 18 */
{ /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
/* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
},
/* MCS 19 */
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
},
/* MCS 20 */
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
},
/* MCS 21 */
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
},
/* MCS 22 */
{ /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
/* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
},
/* MCS 23 */
{ /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
/* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
},
/* MCS 24 */
{ /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
/* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
},
/* MCS 25 */
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
},
/* MCS 26 */
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
},
/* MCS 27 */
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
},
/* MCS 28 */
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
},
/* MCS 29 */
{ /* 20 Mhz */ { 208.0, /* SGI */ 231.1, },
/* 40 Mhz */ { 432.0, /* SGI */ 480.0, },
},
/* MCS 30 */
{ /* 20 Mhz */ { 234.0, /* SGI */ 260.0, },
/* 40 Mhz */ { 486.0, /* SGI */ 540.0, },
},
/* MCS 31 */
{ /* 20 Mhz */ { 260.0, /* SGI */ 288.9, },
/* 40 Mhz */ { 540.0, /* SGI */ 600.0, },
},
/* MCS 32 */
{ /* 20 Mhz */ { 0.0, /* SGI */ 0.0, }, /* not valid */
/* 40 Mhz */ { 6.0, /* SGI */ 6.7, },
},
/* MCS 33 */
{ /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
/* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
},
/* MCS 34 */
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
},
/* MCS 35 */
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
},
/* MCS 36 */
{ /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
/* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
},
/* MCS 37 */
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
},
/* MCS 38 */
{ /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
/* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
},
/* MCS 39 */
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
},
/* MCS 40 */
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
},
/* MCS 41 */
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
},
/* MCS 42 */
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
},
/* MCS 43 */
{ /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
/* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
},
/* MCS 44 */
{ /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
/* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
},
/* MCS 45 */
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
},
/* MCS 46 */
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
},
/* MCS 47 */
{ /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
/* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
},
/* MCS 48 */
{ /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
/* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
},
/* MCS 49 */
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
},
/* MCS 50 */
{ /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
/* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
},
/* MCS 51 */
{ /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
/* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
},
/* MCS 52 */
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
},
/* MCS 53 */
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
},
/* MCS 54 */
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
},
/* MCS 55 */
{ /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
/* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
},
/* MCS 56 */
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
},
/* MCS 57 */
{ /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
/* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
},
/* MCS 58 */
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
},
/* MCS 59 */
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
},
/* MCS 60 */
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
},
/* MCS 61 */
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
},
/* MCS 62 */
{ /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
/* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
},
/* MCS 63 */
{ /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
/* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
},
/* MCS 64 */
{ /* 20 Mhz */ { 143.0, /* SGI */ 158.9, },
/* 40 Mhz */ { 297.0, /* SGI */ 330.0, },
},
/* MCS 65 */
{ /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
/* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
},
/* MCS 66 */
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
},
/* MCS 67 */
{ /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
/* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
},
/* MCS 68 */
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
},
/* MCS 69 */
{ /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
/* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
},
/* MCS 70 */
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
},
/* MCS 71 */
{ /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
/* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
},
/* MCS 72 */
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
},
/* MCS 73 */
{ /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
/* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
},
/* MCS 74 */
{ /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
/* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
},
/* MCS 75 */
{ /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
/* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
},
/* MCS 76 */
{ /* 20 Mhz */ { 214.5, /* SGI */ 238.3, },
/* 40 Mhz */ { 445.5, /* SGI */ 495.0, },
},
};
#define PRINT_HT_RATE(_sep, _r, _suf) \
printf("%s%.1f%s", _sep, (.5 * ieee80211_htrates[(_r) & 0xf]), _suf)
static const char *auth_alg_text[]={"Open System","Shared Key","EAP"};
#define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0])
static const char *status_text[] = {
"Succesful", /* 0 */
"Successful", /* 0 */
"Unspecified failure", /* 1 */
"Reserved", /* 2 */
"Reserved", /* 3 */
@ -274,6 +660,7 @@ static int
parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
u_int length)
{
u_int elementlen;
struct ssid_t ssid;
struct challenge_t challenge;
struct rates_t rates;
@ -492,12 +879,13 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
return 0;
if (length < 2)
return 0;
if (!TTEST2(*(p + offset + 2), *(p + offset + 1)))
elementlen = *(p + offset + 1);
if (!TTEST2(*(p + offset + 2), elementlen))
return 0;
if (length < (u_int)(*(p + offset + 1) + 2))
if (length < elementlen + 2)
return 0;
offset += *(p + offset + 1) + 2;
length -= *(p + offset + 1) + 2;
offset += elementlen + 2;
length -= elementlen + 2;
break;
}
}
@ -1326,7 +1714,8 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
hdrlen = extract_header_length(fc);
if (pad)
hdrlen = roundup2(hdrlen, 4);
if (FC_TYPE(fc) == T_DATA && DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
if (Hflag && FC_TYPE(fc) == T_DATA &&
DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
meshdrlen = extract_mesh_header_length(p+hdrlen);
hdrlen += meshdrlen;
} else
@ -1466,7 +1855,8 @@ print_chaninfo(int freq, int flags)
}
static int
print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
struct radiotap_state *state, u_int32_t presentflags)
{
union {
int8_t i8;
@ -1481,9 +1871,18 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
switch (bit) {
case IEEE80211_RADIOTAP_FLAGS:
rc = cpack_uint8(s, &u.u8);
if (rc != 0)
break;
*flags = u.u8;
break;
case IEEE80211_RADIOTAP_RATE:
rc = cpack_uint8(s, &u.u8);
if (rc != 0)
break;
/* Save state rate */
state->rate = u.u8;
break;
case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
case IEEE80211_RADIOTAP_DB_ANTNOISE:
case IEEE80211_RADIOTAP_ANTENNA:
@ -1502,6 +1901,7 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
case IEEE80211_RADIOTAP_FHSS:
case IEEE80211_RADIOTAP_LOCK_QUALITY:
case IEEE80211_RADIOTAP_TX_ATTENUATION:
case IEEE80211_RADIOTAP_RX_FLAGS:
rc = cpack_uint16(s, &u.u16);
break;
case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
@ -1525,6 +1925,45 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
break;
rc = cpack_uint8(s, &u4.u8);
break;
case IEEE80211_RADIOTAP_MCS:
rc = cpack_uint8(s, &u.u8);
if (rc != 0)
break;
rc = cpack_uint8(s, &u2.u8);
if (rc != 0)
break;
rc = cpack_uint8(s, &u3.u8);
break;
case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: {
u_int8_t vns[3];
u_int16_t length;
u_int8_t subspace;
if ((cpack_align_and_reserve(s, 2)) == NULL) {
rc = -1;
break;
}
rc = cpack_uint8(s, &vns[0]);
if (rc != 0)
break;
rc = cpack_uint8(s, &vns[1]);
if (rc != 0)
break;
rc = cpack_uint8(s, &vns[2]);
if (rc != 0)
break;
rc = cpack_uint8(s, &subspace);
if (rc != 0)
break;
rc = cpack_uint16(s, &length);
if (rc != 0)
break;
/* Skip up to length */
s->c_next += length;
break;
}
default:
/* this bit indicates a field whose
* size we do not know, so we cannot
@ -1539,18 +1978,64 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
return rc;
}
/* Preserve the state present flags */
state->present = presentflags;
switch (bit) {
case IEEE80211_RADIOTAP_CHANNEL:
/*
* If CHANNEL and XCHANNEL are both present, skip
* CHANNEL.
*/
if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL))
break;
print_chaninfo(u.u16, u2.u16);
break;
case IEEE80211_RADIOTAP_FHSS:
printf("fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff);
break;
case IEEE80211_RADIOTAP_RATE:
if (u.u8 & 0x80)
PRINT_HT_RATE("", u.u8, " Mb/s ");
else
PRINT_RATE("", u.u8, " Mb/s ");
/*
* XXX On FreeBSD rate & 0x80 means we have an MCS. On
* Linux and AirPcap it does not. (What about
* Mac OS X, NetBSD, OpenBSD, and DragonFly BSD?)
*
* This is an issue either for proprietary extensions
* to 11a or 11g, which do exist, or for 11n
* implementations that stuff a rate value into
* this field, which also appear to exist.
*
* We currently handle that by assuming that
* if the 0x80 bit is set *and* the remaining
* bits have a value between 0 and 15 it's
* an MCS value, otherwise it's a rate. If
* there are cases where systems that use
* "0x80 + MCS index" for MCS indices > 15,
* or stuff a rate value here between 64 and
* 71.5 Mb/s in here, we'll need a preference
* setting. Such rates do exist, e.g. 11n
* MCS 7 at 20 MHz with a long guard interval.
*/
if (u.u8 >= 0x80 && u.u8 <= 0x8f) {
/*
* XXX - we don't know the channel width
* or guard interval length, so we can't
* convert this to a data rate.
*
* If you want us to show a data rate,
* use the MCS field, not the Rate field;
* the MCS field includes not only the
* MCS index, it also includes bandwidth
* and guard interval information.
*
* XXX - can we get the channel width
* from XChannel and the guard interval
* information from Flags, at least on
* FreeBSD?
*/
printf("MCS %u ", u.u8 & 0x7f);
} else
printf("%2.1f Mb/s ", .5*u.u8);
break;
case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
printf("%ddB signal ", u.i8);
@ -1594,9 +2079,89 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
case IEEE80211_RADIOTAP_TSFT:
printf("%" PRIu64 "us tsft ", u.u64);
break;
case IEEE80211_RADIOTAP_RX_FLAGS:
/* Do nothing for now */
break;
case IEEE80211_RADIOTAP_XCHANNEL:
print_chaninfo(u2.u16, u.u32);
break;
case IEEE80211_RADIOTAP_MCS: {
static const char *bandwidth[4] = {
"20 MHz",
"40 MHz",
"20 MHz (L)",
"20 MHz (U)"
};
float htrate;
if (u.u8 & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) {
/*
* We know the MCS index.
*/
if (u3.u8 <= MAX_MCS_INDEX) {
/*
* And it's in-range.
*/
if (u.u8 & (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN)) {
/*
* And we know both the bandwidth and
* the guard interval, so we can look
* up the rate.
*/
htrate =
ieee80211_float_htrates \
[u3.u8] \
[((u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \
[((u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? 1 : 0)];
} else {
/*
* We don't know both the bandwidth
* and the guard interval, so we can
* only report the MCS index.
*/
htrate = 0.0;
}
} else {
/*
* The MCS value is out of range.
*/
htrate = 0.0;
}
if (htrate != 0.0) {
/*
* We have the rate.
* Print it.
*/
printf("%.1f Mb/s MCS %u ", htrate, u3.u8);
} else {
/*
* We at least have the MCS index.
* Print it.
*/
printf("MCS %u ", u3.u8);
}
}
if (u.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
printf("%s ",
bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]);
}
if (u.u8 & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
printf("%s GI ",
(u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
"short" : "lon");
}
if (u.u8 & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
printf("%s ",
(u2.u8 & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
"greenfield" : "mixed");
}
if (u.u8 & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
printf("%s FEC ",
(u2.u8 & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
"LDPC" : "BCC");
}
break;
}
}
return 0;
}
@ -1616,6 +2181,7 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
struct cpack_state cpacker;
struct ieee80211_radiotap_header *hdr;
u_int32_t present, next_present;
u_int32_t presentflags = 0;
u_int32_t *presentp, *last_presentp;
enum ieee80211_radiotap_type bit;
int bit0;
@ -1624,6 +2190,7 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
u_int8_t flags;
int pad;
u_int fcslen;
struct radiotap_state state;
if (caplen < sizeof(*hdr)) {
printf("[|802.11]");
@ -1665,6 +2232,11 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
fcslen = 0;
for (bit0 = 0, presentp = &hdr->it_present; presentp <= last_presentp;
presentp++, bit0 += 32) {
presentflags = EXTRACT_LE_32BITS(presentp);
/* Clear state. */
memset(&state, 0, sizeof(state));
for (present = EXTRACT_LE_32BITS(presentp); present;
present = next_present) {
/* clear the least significant bit that is set */
@ -1674,16 +2246,16 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
bit = (enum ieee80211_radiotap_type)
(bit0 + BITNO_32(present ^ next_present));
if (print_radiotap_field(&cpacker, bit, &flags) != 0)
if (print_radiotap_field(&cpacker, bit, &flags, &state, presentflags) != 0)
goto out;
}
}
out:
if (flags & IEEE80211_RADIOTAP_F_DATAPAD)
pad = 1; /* Atheros padding */
if (flags & IEEE80211_RADIOTAP_F_FCS)
fcslen = 4; /* FCS at end of packet */
out:
return len + ieee802_11_print(p + len, length - len, caplen - len, pad,
fcslen);
#undef BITNO_32

View File

@ -25,9 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ah.c,v 1.22 2003-11-19 00:36:06 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-ah.c,v 1.22 2003-11-19 00:36:06 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-ah.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ah.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -34,9 +34,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.11 2004-03-24 00:30:19 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.11 2004-03-24 00:30:19 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-aodv.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-aodv.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -22,9 +22,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.5 2006-02-11 22:12:06 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.5 2006-02-11 22:12:06 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-ap1394.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ap1394.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -111,7 +111,7 @@ ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
p += FIREWIRE_HDRLEN;
ether_type = EXTRACT_16BITS(&fp->firewire_type);
if (ethertype_print(ether_type, p, length, caplen) == 0) {
if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN);

View File

@ -24,9 +24,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.20 2005-04-06 21:32:38 mcr Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.20 2005-04-06 21:32:38 mcr Exp (LBL)";
#else
__RCSID("$NetBSD: print-arcnet.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-arcnet.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -270,14 +270,14 @@ arcnet_encap_print(u_char arctype, const u_char *p,
#ifdef INET6
case ARCTYPE_INET6:
ip6_print(p, length);
ip6_print(gndo, p, length);
return (1);
#endif /*INET6*/
case ARCTYPE_ARP_OLD:
case ARCTYPE_ARP:
case ARCTYPE_REVARP:
arp_print(gndo, p, length, caplen);
arp_print(gndo, p, length, caplen);
return (1);
case ARCTYPE_ATALK: /* XXX was this ever used? */

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-arp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-arp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -323,6 +323,7 @@ arp_print(netdissect_options *ndo,
return;
case ARPHRD_FRELAY:
linkaddr = LINKADDR_FRELAY;
break;
default:
linkaddr = LINKADDR_ETHER;
break;

View File

@ -37,9 +37,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.17 2005-07-06 20:53:32 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.17 2005-07-06 20:53:32 guy Exp ";
#else
__RCSID("$NetBSD: print-ascii.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ascii.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
#include <tcpdump-stdinc.h>

View File

@ -25,9 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004-05-01 09:41:50 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004-05-01 09:41:50 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-atalk.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-atalk.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -104,14 +104,10 @@ llap_print(register const u_char *bp, u_int length)
u_short snet;
u_int hdrlen;
/*
* Our packet is on a 4-byte boundary, as we're either called
* directly from a top-level link-layer printer (ltalk_if_print)
* or from the UDP printer. The LLAP+DDP header is a multiple
* of 4 bytes in length, so the DDP payload is also on a 4-byte
* boundary, and we don't need to align it before calling
* "ddp_print()".
*/
if (length < sizeof(*lp)) {
(void)printf(" [|llap %u]", length);
return (length);
}
lp = (const struct LAP *)bp;
bp += sizeof(*lp);
length -= sizeof(*lp);
@ -120,7 +116,7 @@ llap_print(register const u_char *bp, u_int length)
case lapShortDDP:
if (length < ddpSSize) {
(void)printf(" [|sddp %d]", length);
(void)printf(" [|sddp %u]", length);
return (length);
}
sdp = (const struct atShortDDP *)bp;
@ -136,7 +132,7 @@ llap_print(register const u_char *bp, u_int length)
case lapDDP:
if (length < ddpSize) {
(void)printf(" [|ddp %d]", length);
(void)printf(" [|ddp %u]", length);
return (length);
}
dp = (const struct atDDP *)bp;
@ -159,7 +155,7 @@ llap_print(register const u_char *bp, u_int length)
#endif
default:
printf("%d > %d at-lap#%d %d",
printf("%d > %d at-lap#%d %u",
lp->src, lp->dst, lp->type, length);
break;
}
@ -181,7 +177,7 @@ atalk_print(register const u_char *bp, u_int length)
printf("AT ");
if (length < ddpSize) {
(void)printf(" [|ddp %d]", length);
(void)printf(" [|ddp %u]", length);
return;
}
dp = (const struct atDDP *)bp;
@ -270,6 +266,10 @@ atp_print(register const struct atATP *ap, u_int length)
fputs(tstr, stdout);
return;
}
if (length < sizeof(*ap)) {
(void)printf(" [|atp %u]", length);
return;
}
length -= sizeof(*ap);
switch (ap->control & 0xc0) {
@ -281,7 +281,7 @@ atp_print(register const struct atATP *ap, u_int length)
atp_bitmap_print(ap->bitmap);
if (length != 0)
(void)printf(" [len=%d]", length);
(void)printf(" [len=%u]", length);
switch (ap->control & (atpEOM|atpSTS)) {
case atpEOM:
@ -297,7 +297,7 @@ atp_print(register const struct atATP *ap, u_int length)
break;
case atpRspCode:
(void)printf(" atp-resp%s%d:%d (%d)",
(void)printf(" atp-resp%s%d:%d (%u)",
ap->control & atpEOM? "*" : " ",
EXTRACT_16BITS(&ap->transID), ap->bitmap, length);
switch (ap->control & (atpXO|atpSTS)) {
@ -320,7 +320,7 @@ atp_print(register const struct atATP *ap, u_int length)
/* length should be zero */
if (length)
(void)printf(" [len=%d]", length);
(void)printf(" [len=%u]", length);
/* there shouldn't be any control flags */
if (ap->control & (atpXO|atpEOM|atpSTS)) {
@ -342,7 +342,7 @@ atp_print(register const struct atATP *ap, u_int length)
break;
default:
(void)printf(" atp-0x%x %d (%d)", ap->control,
(void)printf(" atp-0x%x %d (%u)", ap->control,
EXTRACT_16BITS(&ap->transID), length);
break;
}
@ -392,14 +392,14 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
const u_char *ep;
if (length < nbpHeaderSize) {
(void)printf(" truncated-nbp %d", length);
(void)printf(" truncated-nbp %u", length);
return;
}
length -= nbpHeaderSize;
if (length < 8) {
/* must be room for at least one tuple */
(void)printf(" truncated-nbp %d", length + nbpHeaderSize);
(void)printf(" truncated-nbp %u", length + nbpHeaderSize);
return;
}
/* ep points to end of available data */
@ -444,7 +444,7 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
break;
default:
(void)printf(" nbp-0x%x %d (%d)", np->control, np->id,
(void)printf(" nbp-0x%x %d (%u)", np->control, np->id,
length);
break;
}
@ -556,26 +556,24 @@ ataddr_string(u_short atnet, u_char athost)
if (first && (first = 0, !nflag)
&& (fp = fopen("/etc/atalk.names", "r"))) {
char line[256];
int i1, i2, i3;
int i1, i2;
while (fgets(line, sizeof(line), fp)) {
if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
continue;
if (sscanf(line, "%d.%d.%d %256s", &i1, &i2, &i3,
nambuf) == 4)
if (sscanf(line, "%d.%d %256s", &i1, &i2, nambuf) == 3)
/* got a hostname. */
i3 |= ((i1 << 8) | i2) << 8;
else if (sscanf(line, "%d.%d %256s", &i1, &i2,
nambuf) == 3)
i2 |= (i1 << 8);
else if (sscanf(line, "%d %256s", &i1, nambuf) == 2)
/* got a net name */
i3 = (((i1 << 8) | i2) << 8) | 255;
i2 = (i1 << 8) | 255;
else
continue;
for (tp = &hnametable[i3 & (HASHNAMESIZE-1)];
for (tp = &hnametable[i2 & (HASHNAMESIZE-1)];
tp->nxt; tp = tp->nxt)
;
tp->addr = i3;
tp->addr = i2;
tp->nxt = newhnamemem();
tp->name = strdup(nambuf);
}
@ -601,11 +599,9 @@ ataddr_string(u_short atnet, u_char athost)
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem();
if (athost != 255)
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d.%d",
atnet >> 8, atnet & 0xff, athost);
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet, athost);
else
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8,
atnet & 0xff);
(void)snprintf(nambuf, sizeof(nambuf), "%d", atnet);
tp->name = strdup(nambuf);
return (tp->name);

View File

@ -22,9 +22,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-atm.c,v 1.49 2007-10-22 19:37:51 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-atm.c,v 1.49 2007-10-22 19:37:51 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-atm.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-atm.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -275,10 +275,12 @@ sig_print(const u_char *p, int caplen)
printf(":%s ",
tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
if (caplen < CALL_REF_POS+3) {
printf("[|atm]");
return;
}
/*
* The call reference comes before the message type,
* so if we know we have the message type, which we
* do from the caplen test above, we also know we have
* the call reference.
*/
call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
printf("CALL_REF:0x%06x", call_ref);
} else {

View File

@ -13,9 +13,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-beep.c,v 1.6 2003-11-16 09:36:13 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-beep.c,v 1.6 2003-11-16 09:36:13 guy Exp ";
#else
__RCSID("$NetBSD: print-beep.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-beep.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -17,9 +17,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.10 2006-02-02 06:35:52 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.10 2006-02-02 06:35:52 hannes Exp ";
#else
__RCSID("$NetBSD: print-bfd.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-bfd.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -24,9 +24,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.89 2008-04-22 09:45:08 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.89 2008-04-22 09:45:08 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-bootp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-bootp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -21,9 +21,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-bt.c,v 1.2 2008-09-25 21:45:50 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-bt.c,v 1.2 2008-09-25 21:45:50 guy Exp ";
#else
__RCSID("$NetBSD: print-bt.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-bt.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -28,9 +28,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.25 2004-10-07 14:53:11 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.25 2004-10-07 14:53:11 hannes Exp ";
#else
__RCSID("$NetBSD: print-cdp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-cdp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -129,7 +129,7 @@ cdp_print(const u_char *pptr, u_int length, u_int caplen)
tok2str(cdp_tlv_values,"unknown field type", type),
type,
len,
len>1 ? "s" : ""); /* plural */
PLURAL_SUFFIX(len)); /* plural */
switch (type) {

View File

@ -21,9 +21,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-cfm.c,v 1.5 2007-07-24 16:01:42 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-cfm.c,v 1.5 2007-07-24 16:01:42 hannes Exp ";
#else
__RCSID("$NetBSD: print-cfm.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-cfm.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.43 2005-11-29 08:56:19 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.43 2005-11-29 08:56:19 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-chdlc.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-chdlc.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -90,7 +90,7 @@ chdlc_print(register const u_char *p, u_int length) {
break;
#ifdef INET6
case ETHERTYPE_IPV6:
ip6_print(p, length);
ip6_print(gndo, p, length);
break;
#endif
case CHDLC_TYPE_SLARP:

View File

@ -24,9 +24,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-cip.c,v 1.26 2005-07-07 01:22:17 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-cip.c,v 1.26 2005-07-07 01:22:17 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-cip.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-cip.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -31,9 +31,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.17 2005-04-20 20:53:18 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.17 2005-04-20 20:53:18 guy Exp ";
#else
__RCSID("$NetBSD: print-cnfp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-cnfp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -11,9 +11,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.8 2007-11-09 00:44:09 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.8 2007-11-09 00:44:09 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-dccp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-dccp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -65,7 +65,7 @@ static const char *dccp_feature_nums[] = {
"check data checksum",
};
static inline int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
{
u_int cov;
@ -78,61 +78,15 @@ static inline int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
static int dccp_cksum(const struct ip *ip,
const struct dccp_hdr *dh, u_int len)
{
int cov = dccp_csum_coverage(dh, len);
union phu {
struct phdr {
u_int32_t src;
u_int32_t dst;
u_char mbz;
u_char proto;
u_int16_t len;
} ph;
u_int16_t pa[6];
} phu;
const u_int16_t *sp;
/* pseudo-header.. */
phu.ph.mbz = 0;
phu.ph.len = htons(len);
phu.ph.proto = IPPROTO_DCCP;
memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
if (IP_HL(ip) == 5)
memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
else
phu.ph.dst = ip_finddst(ip);
sp = &phu.pa[0];
return in_cksum((u_short *)dh, cov, sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]);
return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh,
dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
#ifdef INET6
static int dccp6_cksum(const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_int len)
{
size_t i;
u_int32_t sum = 0;
int cov = dccp_csum_coverage(dh, len);
union {
struct {
struct in6_addr ph_src;
struct in6_addr ph_dst;
u_int32_t ph_len;
u_int8_t ph_zero[3];
u_int8_t ph_nxt;
} ph;
u_int16_t pa[20];
} phu;
/* pseudo-header */
memset(&phu, 0, sizeof(phu));
phu.ph.ph_src = ip6->ip6_src;
phu.ph.ph_dst = ip6->ip6_dst;
phu.ph.ph_len = htonl(len);
phu.ph.ph_nxt = IPPROTO_DCCP;
for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
sum += phu.pa[i];
return in_cksum((u_short *)dh, cov, sum);
return nextproto6_cksum(ip6, (const u_int8_t *)(void *)dh,
dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.39 2005-05-06 02:16:26 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.39 2005-05-06 02:16:26 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-decnet.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-decnet.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -42,9 +42,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.37 2008-02-06 10:26:09 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.37 2008-02-06 10:26:09 guy Exp ";
#else
__RCSID("$NetBSD: print-dhcp6.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-dhcp6.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -234,15 +234,15 @@ dhcp6opt_name(int type)
case DH6OPT_SIP_SERVER_A:
return "SIP-servers-address";
case DH6OPT_DNS:
return "DNS";
return "DNS-server";
case DH6OPT_DNSNAME:
return "DNS-name";
return "DNS-search-list";
case DH6OPT_IA_PD:
return "IA_PD";
case DH6OPT_IA_PD_PREFIX:
return "IA_PD-prefix";
case DH6OPT_NTP_SERVERS:
return "NTP-Server";
return "NTP-server";
case DH6OPT_LIFETIME:
return "lifetime";
case DH6OPT_NIS_SERVERS:

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-domain.c,v 1.98 2007-12-09 01:40:32 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-domain.c,v 1.98 2007-12-09 01:40:32 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-domain.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-domain.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.27 2003-11-19 09:42:04 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.27 2003-11-19 09:42:04 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-dvmrp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-dvmrp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -25,9 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-eap.c,v 1.5 2007-10-04 16:41:33 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-eap.c,v 1.5 2007-10-04 16:41:33 hannes Exp ";
#else
__RCSID("$NetBSD: print-eap.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-eap.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -22,9 +22,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-egp.c,v 1.38 2006-02-11 22:13:24 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-egp.c,v 1.38 2006-02-11 22:13:24 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-egp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-egp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -18,9 +18,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.7 2005-05-06 02:53:26 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.7 2005-05-06 02:53:26 guy Exp ";
#else
__RCSID("$NetBSD: print-eigrp.c,v 1.3 2012/01/16 17:34:18 christos Exp $");
__RCSID("$NetBSD: print-eigrp.c,v 1.4 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -25,9 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-enc.c,v 1.6 2008-11-18 07:35:32 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-enc.c,v 1.6 2008-11-18 07:35:32 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-enc.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-enc.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -85,7 +85,7 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
break;
#ifdef INET6
case AF_INET6:
ip6_print(p, length);
ip6_print(gndo, p, length);
break;
#endif /*INET6*/
}

View File

@ -25,9 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-esp.c,v 1.58 2007-12-07 00:03:07 mcr Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-esp.c,v 1.58 2007-12-07 00:03:07 mcr Exp (LBL)";
#else
__RCSID("$NetBSD: print-esp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-esp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -22,12 +22,13 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-ether.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ether.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -41,7 +42,6 @@ __RCSID("$NetBSD: print-ether.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "ether.h"
const struct tok ethertype_values[] = {
@ -50,6 +50,9 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_MPLS_MULTI, "MPLS multicast" },
{ ETHERTYPE_IPV6, "IPv6" },
{ ETHERTYPE_8021Q, "802.1Q" },
{ ETHERTYPE_8021Q9100, "802.1Q-9100" },
{ ETHERTYPE_8021QinQ, "802.1Q-QinQ" },
{ ETHERTYPE_8021Q9200, "802.1Q-9200" },
{ ETHERTYPE_VMAN, "VMAN" },
{ ETHERTYPE_PUP, "PUP" },
{ ETHERTYPE_ARP, "ARP"},
@ -85,37 +88,39 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_CFM_OLD, "CFM (old)" },
{ ETHERTYPE_CFM, "CFM" },
{ ETHERTYPE_LLDP, "LLDP" },
{ ETHERTYPE_TIPC, "TIPC"},
{ 0, NULL}
};
static inline void
ether_hdr_print(register const u_char *bp, u_int length)
ether_hdr_print(netdissect_options *ndo,
const u_char *bp, u_int length)
{
register const struct ether_header *ep;
u_int16_t ether_type;
ep = (const struct ether_header *)bp;
(void)printf("%s > %s",
(void)ND_PRINT((ndo, "%s > %s",
etheraddr_string(ESRC(ep)),
etheraddr_string(EDST(ep)));
etheraddr_string(EDST(ep))));
ether_type = EXTRACT_16BITS(&ep->ether_type);
if (!qflag) {
if (!ndo->ndo_qflag) {
if (ether_type <= ETHERMTU)
(void)printf(", 802.3");
(void)ND_PRINT((ndo, ", 802.3"));
else
(void)printf(", ethertype %s (0x%04x)",
(void)ND_PRINT((ndo, ", ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", ether_type),
ether_type);
ether_type));
} else {
if (ether_type <= ETHERMTU)
(void)printf(", 802.3");
(void)ND_PRINT((ndo, ", 802.3"));
else
(void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type));
(void)ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type)));
}
(void)printf(", length %u: ", length);
(void)ND_PRINT((ndo, ", length %u: ", length));
}
/*
@ -125,8 +130,9 @@ ether_hdr_print(register const u_char *bp, u_int length)
* frame's protocol, and an argument to pass to that function.
*/
void
ether_print(const u_char *p, u_int length, u_int caplen,
void (*print_encap_header)(const u_char *), const u_char *encap_header_arg)
ether_print(netdissect_options *ndo,
const u_char *p, u_int length, u_int caplen,
void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
{
struct ether_header *ep;
u_int orig_length;
@ -134,14 +140,14 @@ ether_print(const u_char *p, u_int length, u_int caplen,
u_short extracted_ether_type;
if (caplen < ETHER_HDRLEN || length < ETHER_HDRLEN) {
printf("[|ether]");
ND_PRINT((ndo, "[|ether]"));
return;
}
if (eflag) {
if (ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(encap_header_arg);
ether_hdr_print(p, length);
(*print_encap_header)(ndo, encap_header_arg);
ether_hdr_print(ndo, p, length);
}
orig_length = length;
@ -161,36 +167,39 @@ recurse:
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ether_type) == 0) {
/* ether_type not known, print raw packet */
if (!eflag) {
if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(encap_header_arg);
ether_hdr_print((u_char *)ep, orig_length);
(*print_encap_header)(ndo, encap_header_arg);
ether_hdr_print(ndo, (u_char *)ep, orig_length);
}
if (!suppress_default_print)
default_print(p, caplen);
if (!ndo->ndo_suppress_default_print)
ndo->ndo_default_print(ndo, p, caplen);
}
} else if (ether_type == ETHERTYPE_8021Q) {
} else if (ether_type == ETHERTYPE_8021Q ||
ether_type == ETHERTYPE_8021Q9100 ||
ether_type == ETHERTYPE_8021Q9200 ||
ether_type == ETHERTYPE_8021QinQ) {
/*
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
if (caplen < 4 || length < 4) {
printf("[|vlan]");
ND_PRINT((ndo, "[|vlan]"));
return;
}
if (eflag) {
if (ndo->ndo_eflag) {
u_int16_t tag = EXTRACT_16BITS(p);
printf("vlan %u, p %u%s, ",
ND_PRINT((ndo, "vlan %u, p %u%s, ",
tag & 0xfff,
tag >> 13,
(tag & 0x1000) ? ", CFI" : "");
(tag & 0x1000) ? ", CFI" : ""));
}
ether_type = EXTRACT_16BITS(p + 2);
if (eflag && ether_type > ETHERMTU)
printf("ethertype %s, ", tok2str(ethertype_values,"0x%04x", ether_type));
if (ndo->ndo_eflag && ether_type > ETHERMTU)
ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", ether_type)));
p += 4;
length -= 4;
caplen -= 4;
@ -209,26 +218,26 @@ recurse:
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ether_type) == 0) {
/* ether_type not known, print raw packet */
if (!eflag) {
if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(encap_header_arg);
ether_hdr_print((u_char *)ep, orig_length);
(*print_encap_header)(ndo, encap_header_arg);
ether_hdr_print(ndo, (u_char *)ep, orig_length);
}
if (!suppress_default_print)
default_print(p, caplen);
if (!ndo->ndo_suppress_default_print)
ndo->ndo_default_print(ndo, p, caplen);
}
} else {
if (ethertype_print(ether_type, p, length, caplen) == 0) {
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag) {
if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(encap_header_arg);
ether_hdr_print((u_char *)ep, orig_length);
(*print_encap_header)(ndo, encap_header_arg);
ether_hdr_print(ndo, (u_char *)ep, orig_length);
}
if (!suppress_default_print)
default_print(p, caplen);
if (!ndo->ndo_suppress_default_print)
ndo->ndo_default_print(ndo, p, caplen);
}
}
}
@ -240,13 +249,71 @@ recurse:
* is the number of bytes actually captured.
*/
u_int
ether_if_print(const struct pcap_pkthdr *h, const u_char *p)
ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
const u_char *p)
{
ether_print(p, h->len, h->caplen, NULL, NULL);
ether_print(ndo, p, h->len, h->caplen, NULL, NULL);
return (ETHER_HDRLEN);
}
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*
* This is for DLT_NETANALYZER, which has a 4-byte pseudo-header
* before the Ethernet header.
*/
u_int
netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
const u_char *p)
{
/*
* Fail if we don't have enough data for the Hilscher pseudo-header.
*/
if (h->len < 4 || h->caplen < 4) {
printf("[|netanalyzer]");
return (h->caplen);
}
/* Skip the pseudo-header. */
ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL);
return (4 + ETHER_HDRLEN);
}
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*
* This is for DLT_NETANALYZER_TRANSPARENT, which has a 4-byte
* pseudo-header, a 7-byte Ethernet preamble, and a 1-byte Ethernet SOF
* before the Ethernet header.
*/
u_int
netanalyzer_transparent_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h,
const u_char *p)
{
/*
* Fail if we don't have enough data for the Hilscher pseudo-header,
* preamble, and SOF.
*/
if (h->len < 12 || h->caplen < 12) {
printf("[|netanalyzer-transparent]");
return (h->caplen);
}
/* Skip the pseudo-header, preamble, and SOF. */
ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL);
return (12 + ETHER_HDRLEN);
}
/*
* Prints the packet payload, given an Ethernet type code for the payload's
* protocol.
@ -255,85 +322,87 @@ ether_if_print(const struct pcap_pkthdr *h, const u_char *p)
*/
int
ethertype_print(u_short ether_type, const u_char *p, u_int length, u_int caplen)
ethertype_print(netdissect_options *ndo,
u_short ether_type, const u_char *p,
u_int length, u_int caplen)
{
switch (ether_type) {
case ETHERTYPE_IP:
ip_print(gndo, p, length);
ip_print(ndo, p, length);
return (1);
#ifdef INET6
case ETHERTYPE_IPV6:
ip6_print(p, length);
ip6_print(ndo, p, length);
return (1);
#endif /*INET6*/
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
arp_print(gndo, p, length, caplen);
arp_print(ndo, p, length, caplen);
return (1);
case ETHERTYPE_DN:
decnet_print(p, length, caplen);
decnet_print(/*ndo,*/p, length, caplen);
return (1);
case ETHERTYPE_ATALK:
if (vflag)
if (ndo->ndo_vflag)
fputs("et1 ", stdout);
atalk_print(p, length);
atalk_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_AARP:
aarp_print(p, length);
aarp_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_IPX:
printf("(NOV-ETHII) ");
ipx_print(p, length);
ND_PRINT((ndo, "(NOV-ETHII) "));
ipx_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_ISO:
isoclns_print(p+1, length-1, length-1);
isoclns_print(/*ndo,*/p+1, length-1, length-1);
return(1);
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
case ETHERTYPE_PPPOED2:
case ETHERTYPE_PPPOES2:
pppoe_print(p, length);
pppoe_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_EAPOL:
eap_print(gndo, p, length);
eap_print(ndo, p, length);
return (1);
case ETHERTYPE_RRCP:
rrcp_print(gndo, p - 14 , length + 14);
rrcp_print(ndo, p - 14 , length + 14);
return (1);
case ETHERTYPE_PPP:
if (length) {
printf(": ");
ppp_print(p, length);
ppp_print(/*ndo,*/p, length);
}
return (1);
case ETHERTYPE_MPCP:
mpcp_print(p, length);
mpcp_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_SLOW:
slow_print(p, length);
slow_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_CFM:
case ETHERTYPE_CFM_OLD:
cfm_print(p, length);
cfm_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_LLDP:
lldp_print(p, length);
lldp_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_LOOPBACK:
@ -341,7 +410,11 @@ ethertype_print(u_short ether_type, const u_char *p, u_int length, u_int caplen)
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
mpls_print(p, length);
mpls_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_TIPC:
tipc_print(ndo, p, length, caplen);
return (1);
case ETHERTYPE_LAT:

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.66 2005-11-13 12:12:41 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.66 2005-11-13 12:12:41 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-fddi.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-fddi.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#)Header: /tcpdump/master/tcpdump/print-fr.c,v 1.51 2006-06-23 22:20:32 hannes Exp (LBL)";
"@(#)Header: /tcpdump/master/tcpdump/print-fr.c,v 1.51 2006-06-23 22:20:32 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-fr.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-fr.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -261,7 +261,7 @@ fr_print(register const u_char *p, u_int length)
if (eflag)
fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
if (ethertype_print(extracted_ethertype,
if (ethertype_print(gndo, extracted_ethertype,
p+addr_len+ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN) == 0)
@ -291,7 +291,7 @@ fr_print(register const u_char *p, u_int length)
#ifdef INET6
case NLPID_IP6:
ip6_print(p, length);
ip6_print(gndo, p, length);
break;
#endif
case NLPID_CLNP:

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.20 2005-04-20 22:33:06 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.20 2005-04-20 22:33:06 guy Exp ";
#else
__RCSID("$NetBSD: print-frag6.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-frag6.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -40,9 +40,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-gre.c,v 1.28 2005-04-06 21:32:39 mcr Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-gre.c,v 1.28 2005-04-06 21:32:39 mcr Exp (LBL)";
#else
__RCSID("$NetBSD: print-gre.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-gre.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -215,7 +215,7 @@ gre_print_0(const u_char *bp, u_int length)
break;
#ifdef INET6
case ETHERTYPE_IPV6:
ip6_print(bp, len);
ip6_print(gndo, bp, len);
break;
#endif
case ETHERTYPE_MPLS:
@ -231,7 +231,7 @@ gre_print_0(const u_char *bp, u_int length)
isoclns_print(bp, len, len);
break;
case ETHERTYPE_TEB:
ether_print(bp, len, len, NULL, NULL);
ether_print(gndo, bp, len, len, NULL, NULL);
break;
default:
printf("gre-proto-0x%x", prot);

View File

@ -33,9 +33,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.10 2005-05-06 07:56:52 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.10 2005-05-06 07:56:52 guy Exp ";
#else
__RCSID("$NetBSD: print-hsrp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-hsrp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.87 2007-09-13 17:42:31 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.87 2007-09-13 17:42:31 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-icmp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-icmp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -351,6 +351,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header;
u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype;
char buf[MAXHOSTNAMELEN + 100];
struct cksum_vec vec[1];
dp = (struct icmp *)bp;
ext_dp = (struct icmp_ext_t *)bp;
@ -565,8 +566,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
(void)printf("ICMP %s, length %u", str, plen);
if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
u_int16_t sum, icmp_sum;
struct cksum_vec vec[1];
if (TTEST2(*bp, plen)) {
sum = in_cksum((u_short*)dp, plen, 0);
vec[0].ptr = (const u_int8_t *)(void *)dp;
vec[0].len = plen;
sum = in_cksum(vec, 1);
if (sum != 0) {
icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum);
(void)printf(" (wrong icmp cksum %x (->%x)!)",
@ -603,10 +607,12 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
* to check if an extension header is present. This is expedient,
* however not all implementations set the length field proper.
*/
if (!ext_dp->icmp_length &&
in_cksum((const u_short *)&ext_dp->icmp_ext_version_res,
plen - ICMP_EXTD_MINLEN, 0)) {
return;
if (!ext_dp->icmp_length) {
vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
vec[0].len = plen - ICMP_EXTD_MINLEN;
if (in_cksum(vec, 1)) {
return;
}
}
printf("\n\tMPLS extension v%u",
@ -622,10 +628,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
}
hlen = plen - ICMP_EXTD_MINLEN;
vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
vec[0].len = hlen;
printf(", checksum 0x%04x (%scorrect), length %u",
EXTRACT_16BITS(ext_dp->icmp_ext_checksum),
in_cksum((const u_short *)&ext_dp->icmp_ext_version_res,
plen - ICMP_EXTD_MINLEN, 0) ? "in" : "",
in_cksum(vec, 1) ? "in" : "",
hlen);
hlen -= 4; /* subtract common header size */

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.86 2008-02-05 19:36:13 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.86 2008-02-05 19:36:13 guy Exp ";
#else
__RCSID("$NetBSD: print-icmp6.c,v 1.3 2011/12/27 15:12:45 christos Exp $");
__RCSID("$NetBSD: print-icmp6.c,v 1.4 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -202,50 +202,20 @@ print_lladdr(const u_int8_t *p, size_t l)
static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp,
u_int len)
{
size_t i;
register const u_int16_t *sp;
u_int32_t sum;
union {
struct {
struct in6_addr ph_src;
struct in6_addr ph_dst;
u_int32_t ph_len;
u_int8_t ph_zero[3];
u_int8_t ph_nxt;
} ph;
u_int16_t pa[20];
} phu;
/* pseudo-header */
memset(&phu, 0, sizeof(phu));
phu.ph.ph_src = ip6->ip6_src;
phu.ph.ph_dst = ip6->ip6_dst;
phu.ph.ph_len = htonl(len);
phu.ph.ph_nxt = IPPROTO_ICMPV6;
sum = 0;
for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
sum += phu.pa[i];
sp = (const u_int16_t *)icp;
for (i = 0; i < (len & ~1); i += 2)
sum += *sp++;
if (len & 1)
sum += htons((*(const u_int8_t *)sp) << 8);
while (sum > 0xffff)
sum = (sum & 0xffff) + (sum >> 16);
sum = ~sum & 0xffff;
return (sum);
return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)icp, len,
IPPROTO_ICMPV6));
}
enum ND_RPL_CODE {
ND_RPL_DAG_IS=0x01,
ND_RPL_DAG_IO=0x02,
ND_RPL_DAO =0x04
ND_RPL_DIS =0x00,
ND_RPL_DIO =0x01,
ND_RPL_DAO =0x02,
ND_RPL_DAO_ACK=0x03,
ND_RPL_SDIS =0x80,
ND_RPL_SDIO =0x81,
ND_RPL_SDAO =0x82,
ND_RPL_SDAO_ACK=0x83,
ND_RPL_SCC =0x8A,
};
enum ND_RPL_DIO_FLAGS {
@ -271,17 +241,25 @@ rpl_print(netdissect_options *ndo,
const u_char *bp, u_int length _U_)
{
struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp;
int secured = hdr->icmp6_code & 0x80;
int basecode= hdr->icmp6_code & 0x7f;
ND_TCHECK(dio->rpl_dagid);
switch(hdr->icmp6_code) {
case ND_RPL_DAG_IS:
ND_PRINT((ndo, ", DAG Information Solicitation"));
if(secured) {
ND_PRINT((ndo, ", (SEC)"));
} else {
ND_PRINT((ndo, ", (CLR)"));
}
switch(basecode) {
case ND_RPL_DIS:
ND_PRINT((ndo, "DODAG Information Solicitation"));
if(ndo->ndo_vflag) {
}
break;
case ND_RPL_DAG_IO:
ND_PRINT((ndo, ", DAG Information Object"));
case ND_RPL_DIO:
ND_PRINT((ndo, "DODAG Information Object"));
if(ndo->ndo_vflag) {
char dagid[65];
char *d = dagid;
@ -304,12 +282,17 @@ rpl_print(netdissect_options *ndo,
}
break;
case ND_RPL_DAO:
ND_PRINT((ndo, ", Destination Advertisement Object"));
ND_PRINT((ndo, "Destination Advertisement Object"));
if(ndo->ndo_vflag) {
}
break;
case ND_RPL_DAO_ACK:
ND_PRINT((ndo, "Destination Advertisement Object Ack"));
if(ndo->ndo_vflag) {
}
break;
default:
ND_PRINT((ndo, ", RPL message, unknown code %u",hdr->icmp6_code));
ND_PRINT((ndo, "RPL message, unknown code %u",hdr->icmp6_code));
break;
}
return;
@ -341,12 +324,15 @@ icmp6_print(netdissect_options *ndo,
TCHECK(dp->icmp6_cksum);
if (vflag && !fragmented) {
int sum = dp->icmp6_cksum;
u_int16_t sum, udp_sum;
if (TTEST2(bp[0], length)) {
udp_sum = EXTRACT_16BITS(&dp->icmp6_cksum);
sum = icmp6_cksum(ip, dp, length);
if (sum != 0)
(void)printf("[bad icmp6 cksum %x!] ", sum);
(void)printf("[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
udp_sum,
in_cksum_shouldbe(udp_sum, sum));
else
(void)printf("[icmp6 sum ok] ");
}
@ -356,14 +342,14 @@ icmp6_print(netdissect_options *ndo,
/* display cosmetics: print the packet length for printer that use the vflag now */
if (vflag)
switch (dp->icmp6_type) {
switch (dp->icmp6_type) {
case ND_ROUTER_SOLICIT:
case ND_ROUTER_ADVERT:
case ND_NEIGHBOR_ADVERT:
case ND_NEIGHBOR_SOLICIT:
case ND_REDIRECT:
case ICMP6_HADISCOV_REPLY:
case ICMP6_MOBILEPREFIX_ADVERT:
case ND_ROUTER_ADVERT:
case ND_NEIGHBOR_ADVERT:
case ND_NEIGHBOR_SOLICIT:
case ND_REDIRECT:
case ICMP6_HADISCOV_REPLY:
case ICMP6_MOBILEPREFIX_ADVERT:
printf(", length %u", length);
break;
default:
@ -777,7 +763,7 @@ icmp6_opt_print(const u_char *bp, int resid)
case ND_OPT_ADVINTERVAL:
opa = (struct nd_opt_advinterval *)op;
TCHECK(opa->nd_opt_adv_interval);
printf(" %us", EXTRACT_32BITS(&opa->nd_opt_adv_interval));
printf(" %ums", EXTRACT_32BITS(&opa->nd_opt_adv_interval));
break;
case ND_OPT_HOMEAGENT_INFO:
oph = (struct nd_opt_homeagent_info *)op;

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.15 2004-03-24 00:59:16 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.15 2004-03-24 00:59:16 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-igmp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-igmp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -232,7 +232,11 @@ print_igmpv3_query(register const u_char *bp, register u_int len)
}
if (mrc != 100) {
(void)printf(" [max resp time ");
relts_print(mrt);
if (mrt < 600) {
(void)printf("%.1fs", mrt * 0.1);
} else {
relts_print(mrt / 10);
}
(void)printf("]");
}
TCHECK2(bp[4], 4);
@ -264,6 +268,8 @@ trunc:
void
igmp_print(register const u_char *bp, register u_int len)
{
struct cksum_vec vec[1];
if (qflag) {
(void)printf("igmp");
return;
@ -332,7 +338,9 @@ igmp_print(register const u_char *bp, register u_int len)
if (vflag && TTEST2(bp[0], len)) {
/* Check the IGMP checksum */
if (in_cksum((const u_short*)bp, len, 0))
vec[0].ptr = bp;
vec[0].len = len;
if (in_cksum(vec, 1))
printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
}
return;

View File

@ -25,9 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.21 2005-04-20 21:01:56 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.21 2005-04-20 21:01:56 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-igrp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-igrp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ip.c,v 1.159 2007-09-14 01:29:28 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-ip.c,v 1.159 2007-09-14 01:29:28 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-ip.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ip.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -92,7 +92,7 @@ ip_printroute(register const u_char *cp, u_int length)
* This is used for UDP and TCP pseudo-header in the checksum
* calculation.
*/
u_int32_t
static u_int32_t
ip_finddst(const struct ip *ip)
{
int length;
@ -134,6 +134,39 @@ trunc:
return retval;
}
/*
* Compute a V4-style checksum by building a pseudoheader.
*/
int
nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
u_int len, u_int next_proto)
{
struct phdr {
u_int32_t src;
u_int32_t dst;
u_char mbz;
u_char proto;
u_int16_t len;
} ph;
struct cksum_vec vec[2];
/* pseudo-header.. */
ph.len = htons((u_int16_t)len);
ph.mbz = 0;
ph.proto = next_proto;
memcpy(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
if (IP_HL(ip) == 5)
memcpy(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
else
ph.dst = ip_finddst(ip);
vec[0].ptr = (const u_int8_t *)(void *)&ph;
vec[0].len = sizeof(ph);
vec[1].ptr = data;
vec[1].len = len;
return (in_cksum(vec, 2));
}
static void
ip_printts(register const u_char *cp, u_int length)
{
@ -273,92 +306,6 @@ trunc:
printf("[|ip]");
}
/*
* compute an IP header checksum.
* don't modifiy the packet.
*/
u_short
in_cksum(const u_short *addr, register u_int len, int csum)
{
int nleft = len;
const u_short *w = addr;
u_short answer;
int sum = csum;
/*
* Our algorithm is simple, using a 32 bit accumulator (sum),
* we add sequential 16 bit words to it, and at the end, fold
* back all the carry bits from the top 16 bits into the lower
* 16 bits.
*/
while (nleft > 1) {
sum += *w++;
nleft -= 2;
}
if (nleft == 1)
sum += htons(*(u_char *)w<<8);
/*
* add back carry outs from top 16 bits to low 16 bits
*/
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
sum += (sum >> 16); /* add carry */
answer = ~sum; /* truncate to 16 bits */
return (answer);
}
/*
* Given the host-byte-order value of the checksum field in a packet
* header, and the network-byte-order computed checksum of the data
* that the checksum covers (including the checksum itself), compute
* what the checksum field *should* have been.
*/
u_int16_t
in_cksum_shouldbe(u_int16_t sum, u_int16_t computed_sum)
{
u_int32_t shouldbe;
/*
* The value that should have gone into the checksum field
* is the negative of the value gotten by summing up everything
* *but* the checksum field.
*
* We can compute that by subtracting the value of the checksum
* field from the sum of all the data in the packet, and then
* computing the negative of that value.
*
* "sum" is the value of the checksum field, and "computed_sum"
* is the negative of the sum of all the data in the packets,
* so that's -(-computed_sum - sum), or (sum + computed_sum).
*
* All the arithmetic in question is one's complement, so the
* addition must include an end-around carry; we do this by
* doing the arithmetic in 32 bits (with no sign-extension),
* and then adding the upper 16 bits of the sum, which contain
* the carry, to the lower 16 bits of the sum, and then do it
* again in case *that* sum produced a carry.
*
* As RFC 1071 notes, the checksum can be computed without
* byte-swapping the 16-bit words; summing 16-bit words
* on a big-endian machine gives a big-endian checksum, which
* can be directly stuffed into the big-endian checksum fields
* in protocol headers, and summing words on a little-endian
* machine gives a little-endian checksum, which must be
* byte-swapped before being stuffed into a big-endian checksum
* field.
*
* "computed_sum" is a network-byte-order value, so we must put
* it in host byte order before subtracting it from the
* host-byte-order value from the header; the adjusted checksum
* will be in host byte order, which is what we'll return.
*/
shouldbe = sum;
shouldbe += ntohs(computed_sum);
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
return shouldbe;
}
#define IP_RES 0x8000
static struct tok ip_frag_values[] = {
@ -381,6 +328,7 @@ ip_print_demux(netdissect_options *ndo,
struct ip_print_demux_state *ipds)
{
struct protoent *proto;
struct cksum_vec vec[1];
again:
switch (ipds->nh) {
@ -407,7 +355,7 @@ again:
ipds->nh = enh & 0xff;
goto again;
}
case IPPROTO_IPCOMP:
{
int enh;
@ -427,25 +375,25 @@ again:
case IPPROTO_DCCP:
dccp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
break;
case IPPROTO_TCP:
/* pass on the MF bit plus the offset to detect fragments */
tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
ipds->off & (IP_MF|IP_OFFMASK));
break;
case IPPROTO_UDP:
/* pass on the MF bit plus the offset to detect fragments */
udp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
ipds->off & (IP_MF|IP_OFFMASK));
break;
case IPPROTO_ICMP:
/* pass on the MF bit plus the offset to detect fragments */
icmp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
ipds->off & (IP_MF|IP_OFFMASK));
break;
case IPPROTO_PIGP:
/*
* XXX - the current IANA protocol number assignments
@ -462,11 +410,11 @@ again:
*/
igrp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
case IPPROTO_EIGRP:
eigrp_print(ipds->cp, ipds->len);
break;
case IPPROTO_ND:
ND_PRINT((ndo, " nd %d", ipds->len));
break;
@ -485,17 +433,17 @@ again:
case IPPROTO_IPV4:
/* DVMRP multicast tunnel (ip-in-ip encapsulation) */
ip_print(gndo, ipds->cp, ipds->len);
ip_print(ndo, ipds->cp, ipds->len);
if (! vflag) {
ND_PRINT((ndo, " (ipip-proto-4)"));
return;
}
break;
#ifdef INET6
case IPPROTO_IPV6:
/* ip6-in-ip encapsulation */
ip6_print(ipds->cp, ipds->len);
ip6_print(ndo, ipds->cp, ipds->len);
break;
#endif /*INET6*/
@ -513,12 +461,25 @@ again:
break;
case IPPROTO_PIM:
pim_print(ipds->cp, ipds->len,
in_cksum((const u_short*)ipds->cp, ipds->len, 0));
vec[0].ptr = ipds->cp;
vec[0].len = ipds->len;
pim_print(ipds->cp, ipds->len, in_cksum(vec, 1));
break;
case IPPROTO_VRRP:
vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
if (packettype == PT_CARP) {
if (vflag)
(void)printf("carp %s > %s: ",
ipaddr_string(&ipds->ip->ip_src),
ipaddr_string(&ipds->ip->ip_dst));
carp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
} else {
if (vflag)
(void)printf("vrrp %s > %s: ",
ipaddr_string(&ipds->ip->ip_src),
ipaddr_string(&ipds->ip->ip_dst));
vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
}
break;
case IPPROTO_PGM:
@ -530,7 +491,7 @@ again:
break;
default:
if ((proto = getprotobynumber(ipds->nh)) != NULL)
if (ndo->ndo_nflag==0 && (proto = getprotobynumber(ipds->nh)) != NULL)
ND_PRINT((ndo, " %s", proto->p_name));
else
ND_PRINT((ndo, " ip-proto-%d", ipds->nh));
@ -538,7 +499,7 @@ again:
break;
}
}
void
ip_print_inner(netdissect_options *ndo,
const u_char *bp,
@ -570,6 +531,7 @@ ip_print(netdissect_options *ndo,
struct ip_print_demux_state *ipds=&ipd;
const u_char *ipend;
u_int hlen;
struct cksum_vec vec[1];
u_int16_t sum, ip_sum;
struct protoent *proto;
@ -582,7 +544,7 @@ ip_print(netdissect_options *ndo,
else if (!eflag)
printf("IP ");
if ((u_char *)(ipds->ip + 1) > snapend) {
if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) {
printf("[|ip]");
return;
}
@ -620,8 +582,8 @@ ip_print(netdissect_options *ndo,
* Cut off the snapshot length to the end of the IP payload.
*/
ipend = bp + ipds->len;
if (ipend < snapend)
snapend = ipend;
if (ipend < ndo->ndo_snapend)
ndo->ndo_snapend = ipend;
ipds->len -= hlen;
@ -644,7 +606,7 @@ ip_print(netdissect_options *ndo,
}
if (ipds->ip->ip_ttl >= 1)
(void)printf(", ttl %u", ipds->ip->ip_ttl);
(void)printf(", ttl %u", ipds->ip->ip_ttl);
/*
* for the firewall guys, print id, offset.
@ -667,8 +629,10 @@ ip_print(netdissect_options *ndo,
printf(")");
}
if (!Kflag && (u_char *)ipds->ip + hlen <= snapend) {
sum = in_cksum((const u_short *)ipds->ip, hlen, 0);
if (!Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
vec[0].ptr = (const u_int8_t *)(void *)ipds->ip;
vec[0].len = hlen;
sum = in_cksum(vec, 1);
if (sum != 0) {
ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
(void)printf(", bad cksum %x (->%x)!", ip_sum,
@ -706,11 +670,11 @@ ip_print(netdissect_options *ndo,
if (ipds->off & 0x1fff) {
(void)printf("%s > %s:", ipaddr_string(&ipds->ip->ip_src),
ipaddr_string(&ipds->ip->ip_dst));
if ((proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
if (!ndo->ndo_nflag && (proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
(void)printf(" %s", proto->p_name);
else
(void)printf(" ip-proto-%d", ipds->ip->ip_p);
}
}
}
}
@ -731,7 +695,7 @@ ipN_print(register const u_char *bp, register u_int length)
return;
#ifdef INET6
case 6:
ip6_print (bp, length);
ip6_print (gndo, bp, length);
return;
#endif
default:

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.52 2007-09-21 07:05:33 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.52 2007-09-21 07:05:33 hannes Exp ";
#else
__RCSID("$NetBSD: print-ip6.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ip6.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -53,32 +53,38 @@ __RCSID("$NetBSD: print-ip6.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
* Compute a V6-style checksum by building a pseudoheader.
*/
int
nextproto6_cksum(const struct ip6_hdr *ip6, const u_short *data,
nextproto6_cksum(const struct ip6_hdr *ip6, const u_int8_t *data,
u_int len, u_int next_proto)
{
size_t i;
u_int32_t sum = 0;
union ip6_pseudo_hdr phu;
struct {
struct in6_addr ph_src;
struct in6_addr ph_dst;
u_int32_t ph_len;
u_int8_t ph_zero[3];
u_int8_t ph_nxt;
} ph;
struct cksum_vec vec[2];
/* pseudo-header */
memset(&phu, 0, sizeof(phu));
phu.ph.ph_src = ip6->ip6_src;
phu.ph.ph_dst = ip6->ip6_dst;
phu.ph.ph_len = htonl(len);
phu.ph.ph_nxt = next_proto;
memset(&ph, 0, sizeof(ph));
ph.ph_src = ip6->ip6_src;
ph.ph_dst = ip6->ip6_dst;
ph.ph_len = htonl(len);
ph.ph_nxt = next_proto;
for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) {
sum += phu.pa[i];
}
vec[0].ptr = (const u_int8_t *)(void *)&ph;
vec[0].len = sizeof(ph);
vec[1].ptr = data;
vec[1].len = len;
return in_cksum(data, len, sum);
return in_cksum(vec, 2);
}
/*
* print an IP6 datagram.
*/
void
ip6_print(register const u_char *bp, register u_int length)
ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
register const struct ip6_hdr *ip6;
register int advance;
@ -94,62 +100,62 @@ ip6_print(register const u_char *bp, register u_int length)
TCHECK(*ip6);
if (length < sizeof (struct ip6_hdr)) {
(void)printf("truncated-ip6 %u", length);
(void)ND_PRINT((ndo, "truncated-ip6 %u", length));
return;
}
if (!eflag)
printf("IP6 ");
if (!ndo->ndo_eflag)
ND_PRINT((ndo, "IP6 "));
payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
len = payload_len + sizeof(struct ip6_hdr);
if (length < len)
(void)printf("truncated-ip6 - %u bytes missing!",
len - length);
(void)ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
len - length));
if (vflag) {
if (ndo->ndo_vflag) {
flow = EXTRACT_32BITS(&ip6->ip6_flow);
printf("(");
ND_PRINT((ndo, "("));
#if 0
/* rfc1883 */
if (flow & 0x0f000000)
(void)printf("pri 0x%02x, ", (flow & 0x0f000000) >> 24);
(void)ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
if (flow & 0x00ffffff)
(void)printf("flowlabel 0x%06x, ", flow & 0x00ffffff);
(void)ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
#else
/* RFC 2460 */
if (flow & 0x0ff00000)
(void)printf("class 0x%02x, ", (flow & 0x0ff00000) >> 20);
(void)ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
if (flow & 0x000fffff)
(void)printf("flowlabel 0x%05x, ", flow & 0x000fffff);
(void)ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
#endif
(void)printf("hlim %u, next-header %s (%u) payload length: %u) ",
(void)ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
ip6->ip6_hlim,
tok2str(ipproto_values,"unknown",ip6->ip6_nxt),
ip6->ip6_nxt,
payload_len);
payload_len));
}
/*
* Cut off the snapshot length to the end of the IP payload.
*/
ipend = bp + len;
if (ipend < snapend)
snapend = ipend;
if (ipend < ndo->ndo_snapend)
ndo->ndo_snapend = ipend;
cp = (const u_char *)ip6;
advance = sizeof(struct ip6_hdr);
nh = ip6->ip6_nxt;
while (cp < snapend && advance > 0) {
while (cp < ndo->ndo_snapend && advance > 0) {
cp += advance;
len -= advance;
if (cp == (const u_char *)(ip6 + 1) &&
nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) {
(void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src),
ip6addr_string(&ip6->ip6_dst));
(void)ND_PRINT((ndo, "%s > %s: ", ip6addr_string(&ip6->ip6_src),
ip6addr_string(&ip6->ip6_dst)));
}
switch (nh) {
@ -163,7 +169,7 @@ ip6_print(register const u_char *bp, register u_int length)
break;
case IPPROTO_FRAGMENT:
advance = frag6_print(cp, (const u_char *)ip6);
if (snapend <= cp + advance)
if (ndo->ndo_snapend <= cp + advance)
return;
nh = *cp;
fragmented = 1;
@ -201,7 +207,7 @@ ip6_print(register const u_char *bp, register u_int length)
udp_print(cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_ICMPV6:
icmp6_print(gndo, cp, len, (const u_char *)ip6, fragmented);
icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_AH:
advance = ah_print(cp);
@ -210,7 +216,7 @@ ip6_print(register const u_char *bp, register u_int length)
case IPPROTO_ESP:
{
int enh, padlen;
advance = esp_print(gndo, cp, len, (const u_char *)ip6, &enh, &padlen);
advance = esp_print(ndo, cp, len, (const u_char *)ip6, &enh, &padlen);
nh = enh & 0xff;
len -= padlen;
break;
@ -224,7 +230,7 @@ ip6_print(register const u_char *bp, register u_int length)
}
case IPPROTO_PIM:
pim_print(cp, len, nextproto6_cksum(ip6, (u_short *)cp, len,
pim_print(cp, len, nextproto6_cksum(ip6, cp, len,
IPPROTO_PIM));
return;
@ -233,11 +239,11 @@ ip6_print(register const u_char *bp, register u_int length)
return;
case IPPROTO_IPV6:
ip6_print(cp, len);
ip6_print(ndo, cp, len);
return;
case IPPROTO_IPV4:
ip_print(gndo, cp, len);
ip_print(ndo, cp, len);
return;
case IPPROTO_PGM:
@ -253,18 +259,18 @@ ip6_print(register const u_char *bp, register u_int length)
return;
case IPPROTO_NONE:
(void)printf("no next header");
(void)ND_PRINT((ndo, "no next header"));
return;
default:
(void)printf("ip-proto-%d %d", nh, len);
(void)ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
return;
}
}
return;
trunc:
(void)printf("[|ip6]");
(void)ND_PRINT((ndo, "[|ip6]"));
}
#endif /* INET6 */

View File

@ -35,9 +35,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.18 2005-04-20 22:18:50 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.18 2005-04-20 22:18:50 guy Exp ";
#else
__RCSID("$NetBSD: print-ip6opts.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ip6opts.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -146,6 +146,8 @@ ip6_opt_print(const u_char *bp, int len)
int i;
int optlen = 0;
if (len == 0)
return;
for (i = 0; i < len; i += optlen) {
if (bp[i] == IP6OPT_PAD1)
optlen = 1;
@ -276,10 +278,11 @@ ip6_opt_print(const u_char *bp, int len)
printf("(type %d: trunc)", bp[i]);
goto trunc;
}
printf("(opt_type 0x%02x: len=%d) ", bp[i], bp[i + 1]);
printf("(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]);
break;
}
}
printf(" ");
#if 0
end:

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.20 2003-11-19 00:36:08 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.20 2003-11-19 00:36:08 guy Exp ";
#else
__RCSID("$NetBSD: print-ipcomp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ipcomp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.9 2005-11-13 12:12:42 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.9 2005-11-13 12:12:42 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-ipfc.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ipfc.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -26,9 +26,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.42 2005-05-06 08:26:44 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.42 2005-05-06 08:26:44 guy Exp ";
#else
__RCSID("$NetBSD: print-ipx.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ipx.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -201,7 +201,7 @@ ipx_rip_print(const u_short *ipx, u_int length)
(void)printf("ipx-rip-req");
if (length > 0) {
TCHECK(ipx[3]);
(void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]),
(void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
}
break;
@ -209,7 +209,7 @@ ipx_rip_print(const u_short *ipx, u_int length)
(void)printf("ipx-rip-resp");
for (i = 0; i < 50 && length > 0; i++) {
TCHECK(ipx[3]);
(void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]),
(void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
ipx += 4;

View File

@ -32,9 +32,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-isakmp.c,v 1.3 2011/08/17 10:48:02 christos Exp $");
__RCSID("$NetBSD: print-isakmp.c,v 1.4 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -28,9 +28,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.165 2008-08-16 13:38:15 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.165 2008-08-16 13:38:15 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-isoclns.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-isoclns.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -398,12 +398,14 @@ static struct tok isis_subtlv_link_attribute_values[] = {
};
#define ISIS_SUBTLV_AUTH_SIMPLE 1
#define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */
#define ISIS_SUBTLV_AUTH_MD5 54
#define ISIS_SUBTLV_AUTH_MD5_LEN 16
#define ISIS_SUBTLV_AUTH_PRIVATE 255
static struct tok isis_subtlv_auth_values[] = {
{ ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
{ ISIS_SUBTLV_AUTH_GENERIC, "Generic Crypto key-id"},
{ ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
{ ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
{ 0, NULL }
@ -444,8 +446,8 @@ static struct tok clnp_flag_values[] = {
#define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
static struct tok isis_mt_flag_values[] = {
{ 0x4000, "sub-TLVs present"},
{ 0x8000, "ATT bit set"},
{ 0x4000, "ATT bit set"},
{ 0x8000, "Overload bit set"},
{ 0, NULL}
};
@ -621,10 +623,6 @@ struct isis_tlv_lsp {
void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
{
const struct isis_common_header *header;
header = (const struct isis_common_header *)p;
if (caplen <= 1) { /* enough bytes on the wire ? */
printf("|OSI");
return;
@ -667,7 +665,7 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
#ifdef INET6
case NLPID_IP6:
ip6_print(p+1, length-1);
ip6_print(gndo, p+1, length-1);
break;
#endif
@ -1182,15 +1180,15 @@ esis_print(const u_int8_t *pptr, u_int length)
}
/* now walk the options */
while (li >= 2) {
while (li != 0) {
u_int op, opli;
const u_int8_t *tptr;
TCHECK2(*pptr, 2);
if (li < 2) {
printf(", bad opts/li");
return;
}
TCHECK2(*pptr, 2);
op = *pptr++;
opli = *pptr++;
li -= 2;
@ -1209,8 +1207,11 @@ esis_print(const u_int8_t *pptr, u_int length)
switch (op) {
case ESIS_OPTION_ES_CONF_TIME:
TCHECK2(*pptr, 2);
printf("%us", EXTRACT_16BITS(tptr));
if (opli == 2) {
TCHECK2(*pptr, 2);
printf("%us", EXTRACT_16BITS(tptr));
} else
printf("(bad length)");
break;
case ESIS_OPTION_PROTOCOLS:
@ -1782,7 +1783,7 @@ static int isis_print (const u_int8_t *p, u_int length)
u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
u_int8_t ext_is_len, ext_ip_len, mt_len;
const u_int8_t *optr, *pptr, *tptr;
u_short packet_len,pdu_len;
u_short packet_len,pdu_len, key_id;
u_int i,vendor_id;
int sigcheck;
@ -2381,6 +2382,15 @@ static int isis_print (const u_int8_t *p, u_int length)
printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
break;
case ISIS_SUBTLV_AUTH_GENERIC:
key_id = EXTRACT_16BITS((tptr+1));
printf("%u, password: ", key_id);
for(i=1 + sizeof(u_int16_t);i<tlv_len;i++) {
if (!TTEST2(*(tptr+i), 1))
goto trunctlv;
printf("%02x",*(tptr+i));
}
break;
case ISIS_SUBTLV_AUTH_PRIVATE:
default:
if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))

View File

@ -19,9 +19,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.34 2007-08-29 02:31:44 mcr Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.34 2007-08-29 02:31:44 mcr Exp (LBL)";
#else
__RCSID("$NetBSD: print-juniper.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-juniper.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -489,7 +489,7 @@ juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p)
break;
#ifdef INET6
case JUNIPER_PROTO_IPV6:
ip6_print(p, l2info.length);
ip6_print(gndo, p, l2info.length);
break;
#endif /* INET6 */
default:
@ -650,7 +650,7 @@ juniper_pppoe_print(const struct pcap_pkthdr *h, register const u_char *p)
p+=l2info.header_len;
/* this DLT contains nothing but raw ethernet frames */
ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
@ -667,7 +667,7 @@ juniper_ether_print(const struct pcap_pkthdr *h, register const u_char *p)
p+=l2info.header_len;
/* this DLT contains nothing but raw Ethernet frames */
ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
@ -739,7 +739,7 @@ juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p)
extracted_ethertype = EXTRACT_16BITS(p);
/* this DLT contains nothing but raw PPPoE frames,
* prepended with a type field*/
if (ethertype_print(extracted_ethertype,
if (ethertype_print(gndo, extracted_ethertype,
p+ETHERTYPE_LEN,
l2info.length-ETHERTYPE_LEN,
l2info.caplen-ETHERTYPE_LEN) == 0)
@ -782,7 +782,7 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
return l2info.header_len;
#ifdef INET6
case JUNIPER_LSQ_L3_PROTO_IPV6:
ip6_print(p,l2info.length);
ip6_print(gndo, p,l2info.length);
return l2info.header_len;
#endif
case JUNIPER_LSQ_L3_PROTO_MPLS:
@ -837,7 +837,7 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
return l2info.header_len;
#ifdef INET6
case JUNIPER_LSQ_L3_PROTO_IPV6:
ip6_print(p,l2info.length);
ip6_print(gndo, p,l2info.length);
return l2info.header_len;
#endif
case JUNIPER_LSQ_L3_PROTO_MPLS:
@ -990,7 +990,7 @@ juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
(EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
@ -1076,7 +1076,7 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
case 0x6d:
case 0x6e:
case 0x6f:
ip6_print(p, length);
ip6_print(gndo, p, length);
break;
#endif
default:

View File

@ -25,9 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-krb.c,v 1.23 2003-11-16 09:36:26 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-krb.c,v 1.23 2003-11-16 09:36:26 guy Exp ";
#else
__RCSID("$NetBSD: print-krb.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-krb.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -25,9 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.20 2006-06-23 02:03:09 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.20 2006-06-23 02:03:09 hannes Exp ";
#else
__RCSID("$NetBSD: print-l2tp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-l2tp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -24,9 +24,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-lane.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-lane.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -66,9 +66,9 @@ static const struct tok lecop2str[] = {
};
static void
lane_hdr_print(const u_char *bp)
lane_hdr_print(netdissect_options *ndo, const u_char *bp)
{
(void)printf("lecid:%x ", EXTRACT_16BITS(bp));
(void)ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
}
/*
@ -111,7 +111,7 @@ lane_print(const u_char *p, u_int length, u_int caplen)
* Now print the encapsulated frame, under the assumption
* that it's an Ethernet frame.
*/
ether_print(p, length, caplen, lane_hdr_print, p - 2);
ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2);
}
u_int

View File

@ -18,9 +18,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.20 2006-06-23 02:03:09 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.20 2006-06-23 02:03:09 hannes Exp ";
#else
__RCSID("$NetBSD: print-ldp.c,v 1.3 2012/01/16 17:34:18 christos Exp $");
__RCSID("$NetBSD: print-ldp.c,v 1.4 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -185,7 +185,7 @@ static const struct tok ldp_tlv_values[] = {
#define LDP_FEC_WILDCARD 0x01
#define LDP_FEC_PREFIX 0x02
#define LDP_FEC_HOSTADDRESS 0x03
/* From draft-martini-l2circuit-trans-mpls-13.txt */
/* From RFC 4906; should probably be updated to RFC 4447 (e.g., VC -> PW) */
#define LDP_FEC_MARTINI_VC 0x80
static const struct tok ldp_fec_values[] = {
@ -243,6 +243,9 @@ int ldp_tlv_print(register const u_char *);
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define TLV_TCHECK(minlen) \
TCHECK2(*tptr, minlen); if (tlv_tlen < minlen) goto badtlv;
int
ldp_tlv_print(register const u_char *tptr) {
@ -278,6 +281,7 @@ ldp_tlv_print(register const u_char *tptr) {
switch(tlv_type) {
case LDP_TLV_COMMON_HELLO:
TLV_TCHECK(4);
printf("\n\t Hold Time: %us, Flags: [%s Hello%s]",
EXTRACT_16BITS(tptr),
(EXTRACT_16BITS(tptr+2)&0x8000) ? "Targeted" : "Link",
@ -285,18 +289,22 @@ ldp_tlv_print(register const u_char *tptr) {
break;
case LDP_TLV_IPV4_TRANSPORT_ADDR:
TLV_TCHECK(4);
printf("\n\t IPv4 Transport Address: %s", ipaddr_string(tptr));
break;
#ifdef INET6
case LDP_TLV_IPV6_TRANSPORT_ADDR:
TLV_TCHECK(16);
printf("\n\t IPv6 Transport Address: %s", ip6addr_string(tptr));
break;
#endif
case LDP_TLV_CONFIG_SEQ_NUMBER:
TLV_TCHECK(4);
printf("\n\t Sequence Number: %u", EXTRACT_32BITS(tptr));
break;
case LDP_TLV_ADDRESS_LIST:
TLV_TCHECK(LDP_TLV_ADDRESS_LIST_AFNUM_LEN);
af = EXTRACT_16BITS(tptr);
tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
tlv_tlen -= LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
@ -305,6 +313,7 @@ ldp_tlv_print(register const u_char *tptr) {
switch (af) {
case AFNUM_INET:
while(tlv_tlen >= sizeof(struct in_addr)) {
TCHECK2(*tptr, sizeof(struct in_addr));
printf(" %s",ipaddr_string(tptr));
tlv_tlen-=sizeof(struct in_addr);
tptr+=sizeof(struct in_addr);
@ -313,6 +322,7 @@ ldp_tlv_print(register const u_char *tptr) {
#ifdef INET6
case AFNUM_INET6:
while(tlv_tlen >= sizeof(struct in6_addr)) {
TCHECK2(*tptr, sizeof(struct in6_addr));
printf(" %s",ip6addr_string(tptr));
tlv_tlen-=sizeof(struct in6_addr);
tptr+=sizeof(struct in6_addr);
@ -326,6 +336,7 @@ ldp_tlv_print(register const u_char *tptr) {
break;
case LDP_TLV_COMMON_SESSION:
TLV_TCHECK(8);
printf("\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
EXTRACT_16BITS(tptr), EXTRACT_16BITS(tptr+2),
(EXTRACT_16BITS(tptr+6)&0x8000) ? "On Demand" : "Unsolicited",
@ -334,50 +345,86 @@ ldp_tlv_print(register const u_char *tptr) {
break;
case LDP_TLV_FEC:
TLV_TCHECK(1);
fec_type = *tptr;
printf("\n\t %s FEC (0x%02x)",
tok2str(ldp_fec_values, "Unknown", fec_type),
fec_type);
tptr+=1;
tlv_tlen-=1;
switch(fec_type) {
case LDP_FEC_WILDCARD:
break;
case LDP_FEC_PREFIX:
TLV_TCHECK(2);
af = EXTRACT_16BITS(tptr);
tptr+=2;
tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
tlv_tlen-=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
if (af == AFNUM_INET) {
i=decode_prefix4(tptr,buf,sizeof(buf));
printf(": IPv4 prefix %s",buf);
i=decode_prefix4(tptr,tlv_tlen,buf,sizeof(buf));
if (i == -2)
goto trunc;
if (i == -3)
printf(": IPv4 prefix (goes past end of TLV)");
else if (i == -1)
printf(": IPv4 prefix (invalid length)");
else
printf(": IPv4 prefix %s",buf);
}
#ifdef INET6
else if (af == AFNUM_INET6) {
i=decode_prefix6(tptr,buf,sizeof(buf));
printf(": IPv6 prefix %s",buf);
i=decode_prefix6(tptr,tlv_tlen,buf,sizeof(buf));
if (i == -2)
goto trunc;
if (i == -3)
printf(": IPv4 prefix (goes past end of TLV)");
else if (i == -1)
printf(": IPv6 prefix (invalid length)");
else
printf(": IPv6 prefix %s",buf);
}
#endif
else
printf(": Address family %u prefix", af);
break;
case LDP_FEC_HOSTADDRESS:
break;
case LDP_FEC_MARTINI_VC:
if (!TTEST2(*tptr, 11))
goto trunc;
/*
* According to RFC 4908, the VC info Length field can be zero,
* in which case not only are there no interface parameters,
* there's no VC ID.
*/
TLV_TCHECK(7);
vc_info_len = *(tptr+2);
if (vc_info_len == 0) {
printf(": %s, %scontrol word, group-ID %u, VC-info-length: %u",
tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
EXTRACT_32BITS(tptr+3),
vc_info_len);
break;
}
/* Make sure we have the VC ID as well */
TLV_TCHECK(11);
printf(": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
EXTRACT_32BITS(tptr+3),
EXTRACT_32BITS(tptr+7),
vc_info_len);
if (vc_info_len < 4)
goto trunc; /* minimum 4, for the VC ID */
vc_info_len -= 4; /* subtract out the VC ID, giving the length of the interface parameters */
if (vc_info_len == 0) /* infinite loop protection */
break;
/* Skip past the fixed information and the VC ID */
tptr+=11;
if (!TTEST2(*tptr, vc_info_len))
goto trunc;
tlv_tlen-=11;
TLV_TCHECK(vc_info_len);
while (vc_info_len > 2) {
vc_info_tlv_type = *tptr;
@ -426,10 +473,12 @@ ldp_tlv_print(register const u_char *tptr) {
break;
case LDP_TLV_GENERIC_LABEL:
TLV_TCHECK(4);
printf("\n\t Label: %u", EXTRACT_32BITS(tptr) & 0xfffff);
break;
case LDP_TLV_STATUS:
TLV_TCHECK(8);
ui = EXTRACT_32BITS(tptr);
tptr+=4;
printf("\n\t Status: 0x%02x, Flags: [%s and %s forward]",
@ -443,6 +492,7 @@ ldp_tlv_print(register const u_char *tptr) {
break;
case LDP_TLV_FT_SESSION:
TLV_TCHECK(8);
ft_flags = EXTRACT_16BITS(tptr);
printf("\n\t Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
ft_flags&0x8000 ? "" : "No ",
@ -461,6 +511,7 @@ ldp_tlv_print(register const u_char *tptr) {
break;
case LDP_TLV_MTU:
TLV_TCHECK(2);
printf("\n\t MTU: %u", EXTRACT_16BITS(tptr));
break;
@ -491,6 +542,10 @@ ldp_tlv_print(register const u_char *tptr) {
trunc:
printf("\n\t\t packet exceeded snapshot");
return 0;
badtlv:
printf("\n\t\t TLV contents go past end of TLV");
return(tlv_len+4); /* Type & Length fields not included */
}
void
@ -551,8 +606,7 @@ ldp_msg_print(register const u_char *pptr) {
while(tlen>0) {
/* did we capture enough for fully decoding the msg header ? */
if (!TTEST2(*tptr, sizeof(struct ldp_msg_header)))
goto trunc;
TCHECK2(*tptr, sizeof(struct ldp_msg_header));
ldp_msg_header = (const struct ldp_msg_header *)tptr;
msg_len=EXTRACT_16BITS(ldp_msg_header->length);
@ -575,8 +629,7 @@ ldp_msg_print(register const u_char *pptr) {
msg_tlen=msg_len-sizeof(struct ldp_msg_header)+4; /* Type & Length fields not included */
/* did we capture enough for fully decoding the message ? */
if (!TTEST2(*tptr, msg_len))
goto trunc;
TCHECK2(*tptr, msg_len);
hexdump=FALSE;
switch(msg_type) {

View File

@ -26,9 +26,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-llc.c,v 1.75 2007-04-13 09:43:11 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-llc.c,v 1.75 2007-04-13 09:43:11 hannes Exp ";
#else
__RCSID("$NetBSD: print-llc.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-llc.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -422,7 +422,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* Cisco hardware; the protocol ID is
* an Ethernet protocol type.
*/
ret = ethertype_print(et, p, length, caplen);
ret = ethertype_print(gndo, et, p, length, caplen);
if (ret)
return (ret);
break;
@ -437,7 +437,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* but used 0x000000 and an Ethernet
* packet type for AARP packets.
*/
ret = ethertype_print(et, p, length, caplen);
ret = ethertype_print(gndo, et, p, length, caplen);
if (ret)
return (ret);
}
@ -484,7 +484,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
/*
* What remains is an Ethernet packet.
*/
ether_print(p, length, caplen, NULL, NULL);
ether_print(gndo, p, length, caplen, NULL, NULL);
return (1);
case PID_RFC2684_802_5_FCS:

View File

@ -12,19 +12,20 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* support for the IEEE Link Discovery Protocol as per 802.1ab
* support for the IEEE Link Discovery Protocol as per 802.1AB
*
* Original code by Hannes Gredler (hannes@juniper.net)
* IEEE and TIA extensions by Carles Kishimoto <carles.kishimoto@gmail.com>
* DCBX extensions by Kaladhar Musunuru <kaladharm@sourceforge.net>
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.10 2008-03-20 09:30:56 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.10 2008-03-20 09:30:56 hannes Exp ";
#else
__RCSID("$NetBSD: print-lldp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-lldp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -389,9 +390,9 @@ static const struct tok lldp_tia_application_type_values[] = {
{ 0, NULL}
};
#define LLDP_TIA_NETWORK_POLICY_U_BIT (1 << 5)
#define LLDP_TIA_NETWORK_POLICY_X_BIT (1 << 5)
#define LLDP_TIA_NETWORK_POLICY_T_BIT (1 << 6)
#define LLDP_TIA_NETWORK_POLICY_X_BIT (1 << 7)
#define LLDP_TIA_NETWORK_POLICY_U_BIT (1 << 7)
static const struct tok lldp_tia_network_policy_bits_values[] = {
{ LLDP_TIA_NETWORK_POLICY_U_BIT, "Unknown"},
@ -546,6 +547,23 @@ static const struct tok lldp_aggregation_values[] = {
{ 0, NULL}
};
/*
* DCBX protocol subtypes.
*/
#define LLDP_DCBX_SUBTYPE_1 1
#define LLDP_DCBX_SUBTYPE_2 2
static const struct tok lldp_dcbx_subtype_values[] = {
{ LLDP_DCBX_SUBTYPE_1, "DCB Capability Exchange Protocol Rev 1" },
{ LLDP_DCBX_SUBTYPE_2, "DCB Capability Exchange Protocol Rev 1.01" },
{ 0, NULL}
};
#define LLDP_DCBX_CONTROL_TLV 1
#define LLDP_DCBX_PRIORITY_GROUPS_TLV 2
#define LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV 3
#define LLDP_DCBX_APPLICATION_TLV 4
/*
* Interface numbering subtypes.
*/
@ -561,13 +579,17 @@ static const struct tok lldp_intf_numb_subtype_values[] = {
#define LLDP_INTF_NUM_LEN 5
/*
* Print IEEE private extensions. (802.1 annex F)
* Print IEEE 802.1 private extensions. (802.1AB annex E)
*/
static int
lldp_private_8021_print(const u_char *tptr)
lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
{
int subtype, hexdump = FALSE;
u_int sublen;
if (tlv_len < 4) {
return hexdump;
}
subtype = *(tptr+3);
printf("\n\t %s Subtype (%u)",
@ -576,24 +598,47 @@ lldp_private_8021_print(const u_char *tptr)
switch (subtype) {
case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID:
if (tlv_len < 6) {
return hexdump;
}
printf("\n\t port vlan id (PVID): %u",
EXTRACT_16BITS(tptr+4));
break;
case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID:
if (tlv_len < 7) {
return hexdump;
}
printf("\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
EXTRACT_16BITS(tptr+5),
bittok2str(lldp_8021_port_protocol_id_values, "none", *(tptr+4)),
*(tptr+4));
break;
case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME:
if (tlv_len < 6) {
return hexdump;
}
printf("\n\t vlan id (VID): %u",
EXTRACT_16BITS(tptr+4));
if (tlv_len < 7) {
return hexdump;
}
sublen = *(tptr+6);
if (tlv_len < 7+sublen) {
return hexdump;
}
printf("\n\t vlan name: ");
safeputs((const char *)tptr+7, *(tptr+6));
safeputs((const char *)tptr+7, sublen);
break;
case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY:
if (tlv_len < 5) {
return hexdump;
}
sublen = *(tptr+4);
if (tlv_len < 5+sublen) {
return hexdump;
}
printf("\n\t protocol identity: ");
safeputs((const char *)tptr+5, *(tptr+4));
safeputs((const char *)tptr+5, sublen);
break;
default:
@ -605,13 +650,16 @@ lldp_private_8021_print(const u_char *tptr)
}
/*
* Print IEEE private extensions. (802.3)
* Print IEEE 802.3 private extensions. (802.3bc)
*/
static int
lldp_private_8023_print(const u_char *tptr)
lldp_private_8023_print(const u_char *tptr, u_int tlv_len)
{
int subtype, hexdump = FALSE;
if (tlv_len < 4) {
return hexdump;
}
subtype = *(tptr+3);
printf("\n\t %s Subtype (%u)",
@ -620,6 +668,9 @@ lldp_private_8023_print(const u_char *tptr)
switch (subtype) {
case LLDP_PRIVATE_8023_SUBTYPE_MACPHY:
if (tlv_len < 9) {
return hexdump;
}
printf("\n\t autonegotiation [%s] (0x%02x)",
bittok2str(lldp_8023_autonegotiation_values, "none", *(tptr+4)),
*(tptr+4));
@ -632,6 +683,9 @@ lldp_private_8023_print(const u_char *tptr)
break;
case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER:
if (tlv_len < 7) {
return hexdump;
}
printf("\n\t MDI power support [%s], power pair %s, power class %s",
bittok2str(lldp_mdi_values, "none", *(tptr+4)),
tok2str(lldp_mdi_power_pairs_values, "unknown", *(tptr+5)),
@ -639,6 +693,9 @@ lldp_private_8023_print(const u_char *tptr)
break;
case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR:
if (tlv_len < 9) {
return hexdump;
}
printf("\n\t aggregation status [%s], aggregation port ID %u",
bittok2str(lldp_aggregation_values, "none", *(tptr+4)),
EXTRACT_32BITS(tptr+5));
@ -679,8 +736,12 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
int subtype, hexdump = FALSE;
u_int8_t location_format;
u_int16_t power_val;
u_int8_t lci_len, ca_type, ca_len;
u_int lci_len;
u_int8_t ca_type, ca_len;
if (tlv_len < 4) {
return hexdump;
}
subtype = *(tptr+3);
printf("\n\t %s Subtype (%u)",
@ -689,6 +750,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
switch (subtype) {
case LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES:
if (tlv_len < 7) {
return hexdump;
}
printf("\n\t Media capabilities [%s] (0x%04x)",
bittok2str(lldp_tia_capabilities_values, "none",
EXTRACT_16BITS(tptr+4)), EXTRACT_16BITS(tptr+4));
@ -698,6 +762,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
break;
case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY:
if (tlv_len < 8) {
return hexdump;
}
printf("\n\t Application type [%s] (0x%02x)",
tok2str(lldp_tia_application_type_values, "none", *(tptr+4)),
*(tptr+4));
@ -712,6 +779,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
break;
case LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID:
if (tlv_len < 5) {
return hexdump;
}
location_format = *(tptr+4);
printf("\n\t Location data format %s (0x%02x)",
tok2str(lldp_tia_location_data_format_values, "unknown", location_format),
@ -719,6 +789,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
switch (location_format) {
case LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED:
if (tlv_len < 21) {
return hexdump;
}
printf("\n\t Latitude resolution %u, latitude value %" PRIu64,
(*(tptr+5)>>2), lldp_extract_latlon(tptr+5));
printf("\n\t Longitude resolution %u, longitude value %" PRIu64,
@ -735,7 +808,16 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
break;
case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS:
if (tlv_len < 6) {
return hexdump;
}
lci_len = *(tptr+5);
if (lci_len < 3) {
return hexdump;
}
if (tlv_len < 7+lci_len) {
return hexdump;
}
printf("\n\t LCI length %u, LCI what %s (0x%02x), Country-code ",
lci_len,
tok2str(lldp_tia_location_lci_what_values, "unknown", *(tptr+6)),
@ -749,6 +831,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
/* Decode each civic address element */
while (lci_len > 0) {
if (lci_len < 2) {
return hexdump;
}
ca_type = *(tptr);
ca_len = *(tptr+1);
@ -763,6 +848,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
if ( ca_type == 0 || ca_len == 0) {
return hexdump;
}
if (lci_len < ca_len) {
return hexdump;
}
safeputs((const char *)tptr, ca_len);
tptr += ca_len;
@ -782,6 +870,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
break;
case LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI:
if (tlv_len < 7) {
return hexdump;
}
printf("\n\t Power type [%s]",
(*(tptr+4)&0xC0>>6) ? "PD device" : "PSE device");
printf(", Power source [%s]",
@ -817,24 +908,196 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
return hexdump;
}
/*
* Print DCBX Protocol fields (V 1.01).
*/
static int
lldp_private_dcbx_print(const u_char *pptr, u_int len)
{
int subtype, hexdump = FALSE;
u_int8_t tval;
u_int16_t tlv;
u_int32_t i, pgval, uval;
u_int tlen, tlv_type, tlv_len;
const u_char *tptr, *mptr;
if (len < 4) {
return hexdump;
}
subtype = *(pptr+3);
printf("\n\t %s Subtype (%u)",
tok2str(lldp_dcbx_subtype_values, "unknown", subtype),
subtype);
/* by passing old version */
if (subtype == LLDP_DCBX_SUBTYPE_1)
return TRUE;
tptr = pptr + 4;
tlen = len - 4;
while (tlen >= sizeof(tlv)) {
TCHECK2(*tptr, sizeof(tlv));
tlv = EXTRACT_16BITS(tptr);
tlv_type = LLDP_EXTRACT_TYPE(tlv);
tlv_len = LLDP_EXTRACT_LEN(tlv);
hexdump = FALSE;
tlen -= sizeof(tlv);
tptr += sizeof(tlv);
/* loop check */
if (!tlv_type || !tlv_len) {
break;
}
TCHECK2(*tptr, tlv_len);
if (tlen < tlv_len) {
goto trunc;
}
/* decode every tlv */
switch (tlv_type) {
case LLDP_DCBX_CONTROL_TLV:
if (tlv_len < 10) {
goto trunc;
}
printf("\n\t Control - Protocol Control (type 0x%x, length %d)",
LLDP_DCBX_CONTROL_TLV, tlv_len);
printf("\n\t Oper_Version: %d", *tptr);
printf("\n\t Max_Version: %d", *(tptr+1));
printf("\n\t Sequence Number: %d", EXTRACT_32BITS(tptr+2));
printf("\n\t Acknowledgement Number: %d",
EXTRACT_32BITS(tptr+6));
break;
case LLDP_DCBX_PRIORITY_GROUPS_TLV:
if (tlv_len < 17) {
goto trunc;
}
printf("\n\t Feature - Priority Group (type 0x%x, length %d)",
LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len);
printf("\n\t Oper_Version: %d", *tptr);
printf("\n\t Max_Version: %d", *(tptr+1));
printf("\n\t Info block(0x%02X): ", *(tptr+2));
tval = *(tptr+2);
printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
(tval & 0x20) ? 1 : 0);
printf("\n\t SubType: %d", *(tptr+3));
printf("\n\t Priority Allocation");
pgval = EXTRACT_32BITS(tptr+4);
for (i = 0; i <= 7; i++) {
tval = *(tptr+4+(i/2));
printf("\n\t PgId_%d: %d",
i, (pgval >> (28-4*i)) & 0xF);
}
printf("\n\t Priority Group Allocation");
for (i = 0; i <= 7; i++)
printf("\n\t Pg percentage[%d]: %d", i, *(tptr+8+i));
printf("\n\t NumTCsSupported: %d", *(tptr+8+8));
break;
case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV:
if (tlv_len < 6) {
goto trunc;
}
printf("\n\t Feature - Priority Flow Control");
printf(" (type 0x%x, length %d)",
LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len);
printf("\n\t Oper_Version: %d", *tptr);
printf("\n\t Max_Version: %d", *(tptr+1));
printf("\n\t Info block(0x%02X): ", *(tptr+2));
tval = *(tptr+2);
printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
(tval & 0x20) ? 1 : 0);
printf("\n\t SubType: %d", *(tptr+3));
tval = *(tptr+4);
printf("\n\t PFC Config (0x%02X)", *(tptr+4));
for (i = 0; i <= 7; i++)
printf("\n\t Priority Bit %d: %s",
i, (tval & (1 << i)) ? "Enabled" : "Disabled");
printf("\n\t NumTCPFCSupported: %d", *(tptr+5));
break;
case LLDP_DCBX_APPLICATION_TLV:
if (tlv_len < 4) {
goto trunc;
}
printf("\n\t Feature - Application (type 0x%x, length %d)",
LLDP_DCBX_APPLICATION_TLV, tlv_len);
printf("\n\t Oper_Version: %d", *tptr);
printf("\n\t Max_Version: %d", *(tptr+1));
printf("\n\t Info block(0x%02X): ", *(tptr+2));
tval = *(tptr+2);
printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
(tval & 0x20) ? 1 : 0);
printf("\n\t SubType: %d", *(tptr+3));
tval = tlv_len - 4;
mptr = tptr + 4;
while (tval >= 6) {
printf("\n\t Application Value");
printf("\n\t Application Protocol ID: 0x%04x",
EXTRACT_16BITS(mptr));
uval = EXTRACT_24BITS(mptr+2);
printf("\n\t SF (0x%x) Application Protocol ID is %s",
(uval >> 22),
(uval >> 22) ? "Socket Number" : "L2 EtherType");
printf("\n\t OUI: 0x%06x", uval & 0x3fffff);
printf("\n\t User Priority Map: 0x%02x", *(mptr+5));
tval = tval - 6;
mptr = mptr + 6;
}
break;
default:
hexdump = TRUE;
break;
}
/* do we also want to see a hex dump ? */
if (vflag > 1 || (vflag && hexdump)) {
print_unknown_data(tptr,"\n\t ", tlv_len);
}
tlen -= tlv_len;
tptr += tlv_len;
}
trunc:
return hexdump;
}
static char *
lldp_network_addr_print(const u_char *tptr) {
lldp_network_addr_print(const u_char *tptr, u_int len) {
u_int8_t af;
static char buf[BUFSIZE];
const char * (*pfunc)(const u_char *);
if (len < 1)
return NULL;
len--;
af = *tptr;
switch (af) {
case AFNUM_INET:
if (len < 4)
return NULL;
pfunc = getname;
break;
#ifdef INET6
case AFNUM_INET6:
if (len < 16)
return NULL;
pfunc = getname6;
break;
#endif
case AFNUM_802:
if (len < 6)
return NULL;
pfunc = etheraddr_string;
break;
default:
@ -859,10 +1122,14 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
u_int8_t mgmt_addr_len, intf_num_subtype, oid_len;
const u_char *tptr;
u_int tlen;
char *mgmt_addr;
tlen = len;
tptr = pptr;
if (tlen < 1) {
return 0;
}
mgmt_addr_len = *tptr++;
tlen--;
@ -870,9 +1137,12 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
return 0;
}
mgmt_addr = lldp_network_addr_print(tptr, mgmt_addr_len);
if (mgmt_addr == NULL) {
return 0;
}
printf("\n\t Management Address length %u, %s",
mgmt_addr_len,
lldp_network_addr_print(tptr));
mgmt_addr_len, mgmt_addr);
tptr += mgmt_addr_len;
tlen -= mgmt_addr_len;
@ -895,6 +1165,9 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
if (tlen) {
oid_len = *tptr;
if (tlen < oid_len) {
return 0;
}
if (oid_len) {
printf("\n\t OID length %u", oid_len);
safeputs((const char *)tptr+1, oid_len);
@ -911,6 +1184,7 @@ lldp_print(register const u_char *pptr, register u_int len) {
u_int16_t tlv, cap, ena_cap;
u_int oui, tlen, hexdump, tlv_type, tlv_len;
const u_char *tptr;
char *network_addr;
tptr = pptr;
tlen = len;
@ -944,16 +1218,111 @@ lldp_print(register const u_char *pptr, register u_int len) {
}
TCHECK2(*tptr, tlv_len);
if (tlen < tlv_len) {
goto trunc;
}
switch (tlv_type) {
case LLDP_CHASSIS_ID_TLV:
if (vflag) {
if (tlv_len < 2) {
goto trunc;
}
subtype = *tptr;
printf("\n\t Subtype %s (%u): ",
tok2str(lldp_chassis_subtype_values, "Unknown", subtype),
subtype);
switch (subtype) {
case LLDP_CHASSIS_MAC_ADDR_SUBTYPE:
if (tlv_len < 1+6) {
goto trunc;
}
printf("%s", etheraddr_string(tptr+1));
break;
case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */
case LLDP_CHASSIS_LOCAL_SUBTYPE:
case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE:
case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE:
case LLDP_CHASSIS_PORT_COMP_SUBTYPE:
safeputs((const char *)tptr+1, tlv_len-1);
break;
case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE:
network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
if (network_addr == NULL) {
goto trunc;
}
printf("%s", network_addr);
break;
default:
hexdump = TRUE;
break;
}
}
break;
case LLDP_PORT_ID_TLV:
if (vflag) {
if (tlv_len < 2) {
goto trunc;
}
subtype = *tptr;
printf("\n\t Subtype %s (%u): ",
tok2str(lldp_port_subtype_values, "Unknown", subtype),
subtype);
switch (subtype) {
case LLDP_PORT_MAC_ADDR_SUBTYPE:
if (tlv_len < 1+6) {
goto trunc;
}
printf("%s", etheraddr_string(tptr+1));
break;
case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */
case LLDP_PORT_LOCAL_SUBTYPE:
case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE:
case LLDP_PORT_INTF_ALIAS_SUBTYPE:
case LLDP_PORT_PORT_COMP_SUBTYPE:
safeputs((const char *)tptr+1, tlv_len-1);
break;
case LLDP_PORT_NETWORK_ADDR_SUBTYPE:
network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
if (network_addr == NULL) {
goto trunc;
}
printf("%s", network_addr);
break;
default:
hexdump = TRUE;
break;
}
}
break;
case LLDP_TTL_TLV:
if (vflag) {
if (tlv_len < 2) {
goto trunc;
}
printf(": TTL %us", EXTRACT_16BITS(tptr));
}
break;
case LLDP_SYSTEM_NAME_TLV:
case LLDP_PORT_DESCR_TLV:
if (vflag) {
printf(": ");
safeputs((const char *)tptr, tlv_len);
}
break;
case LLDP_SYSTEM_NAME_TLV:
/*
* The system name is also print in non-verbose mode
* similar to the CDP printer.
@ -968,13 +1337,6 @@ lldp_print(register const u_char *pptr, register u_int len) {
}
break;
case LLDP_PORT_DESCR_TLV:
if (vflag) {
printf(": ");
safeputs((const char *)tptr, tlv_len);
}
break;
case LLDP_SYSTEM_DESCR_TLV:
if (vflag) {
printf("\n\t ");
@ -982,93 +1344,17 @@ lldp_print(register const u_char *pptr, register u_int len) {
}
break;
case LLDP_CHASSIS_ID_TLV:
if (vflag) {
subtype = *tptr;
printf("\n\t Subtype %s (%u): ",
tok2str(lldp_chassis_subtype_values, "Unknown", subtype),
subtype);
switch (subtype) {
case LLDP_CHASSIS_MAC_ADDR_SUBTYPE:
printf("%s", etheraddr_string(tptr+1));
break;
case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */
case LLDP_CHASSIS_LOCAL_SUBTYPE:
case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE:
case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE:
case LLDP_CHASSIS_PORT_COMP_SUBTYPE:
safeputs((const char *)tptr+1, tlv_len-1);
break;
case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE:
printf("%s", lldp_network_addr_print(tptr+1));
break;
default:
hexdump = TRUE;
break;
}
}
break;
case LLDP_PORT_ID_TLV:
if (vflag) {
subtype = *tptr;
printf("\n\t Subtype %s (%u): ",
tok2str(lldp_port_subtype_values, "Unknown", subtype),
subtype);
switch (subtype) {
case LLDP_PORT_MAC_ADDR_SUBTYPE:
printf("%s", etheraddr_string(tptr+1));
break;
case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */
case LLDP_PORT_LOCAL_SUBTYPE:
case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE:
case LLDP_PORT_INTF_ALIAS_SUBTYPE:
case LLDP_PORT_PORT_COMP_SUBTYPE:
safeputs((const char *)tptr+1, tlv_len-1);
break;
case LLDP_PORT_NETWORK_ADDR_SUBTYPE:
printf("%s", lldp_network_addr_print(tptr+1));
break;
default:
hexdump = TRUE;
break;
}
}
break;
case LLDP_PRIVATE_TLV:
if (vflag) {
oui = EXTRACT_24BITS(tptr);
printf(": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui);
switch (oui) {
case OUI_IEEE_8021_PRIVATE:
hexdump = lldp_private_8021_print(tptr);
break;
case OUI_IEEE_8023_PRIVATE:
hexdump = lldp_private_8023_print(tptr);
break;
case OUI_TIA:
hexdump = lldp_private_tia_print(tptr, tlv_len);
break;
default:
hexdump = TRUE;
break;
}
}
break;
case LLDP_SYSTEM_CAP_TLV:
if (vflag) {
/*
* XXX - IEEE Std 802.1AB-2009 says the first octet
* if a chassis ID subtype, with the system
* capabilities and enabled capabilities following
* it.
*/
if (tlv_len < 4) {
goto trunc;
}
cap = EXTRACT_16BITS(tptr);
ena_cap = EXTRACT_16BITS(tptr+2);
printf("\n\t System Capabilities [%s] (0x%04x)",
@ -1080,12 +1366,40 @@ lldp_print(register const u_char *pptr, register u_int len) {
case LLDP_MGMT_ADDR_TLV:
if (vflag) {
if (!lldp_mgmt_addr_tlv_print(tptr, tlen)) {
if (!lldp_mgmt_addr_tlv_print(tptr, tlv_len)) {
goto trunc;
}
}
break;
case LLDP_PRIVATE_TLV:
if (vflag) {
if (tlv_len < 3) {
goto trunc;
}
oui = EXTRACT_24BITS(tptr);
printf(": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui);
switch (oui) {
case OUI_IEEE_8021_PRIVATE:
hexdump = lldp_private_8021_print(tptr, tlv_len);
break;
case OUI_IEEE_8023_PRIVATE:
hexdump = lldp_private_8023_print(tptr, tlv_len);
break;
case OUI_TIA:
hexdump = lldp_private_tia_print(tptr, tlv_len);
break;
case OUI_DCBX:
hexdump = lldp_private_dcbx_print(tptr, tlv_len);
break;
default:
hexdump = TRUE;
break;
}
}
break;
default:
hexdump = TRUE;
break;

View File

@ -21,9 +21,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.11 2007-08-02 17:32:49 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.11 2007-08-02 17:32:49 hannes Exp ";
#else
__RCSID("$NetBSD: print-lmp.c,v 1.3 2012/01/16 17:34:18 christos Exp $");
__RCSID("$NetBSD: print-lmp.c,v 1.4 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -17,9 +17,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.20 2008-01-28 14:20:43 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.20 2008-01-28 14:20:43 hannes Exp ";
#else
__RCSID("$NetBSD: print-lspping.c,v 1.3 2012/01/16 17:34:18 christos Exp $");
__RCSID("$NetBSD: print-lspping.c,v 1.4 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -21,9 +21,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-lwapp.c,v 1.1 2007-07-24 16:07:30 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-lwapp.c,v 1.1 2007-07-24 16:07:30 hannes Exp ";
#else
__RCSID("$NetBSD: print-lwapp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-lwapp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -179,7 +179,7 @@ lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
const struct lwapp_transport_header *lwapp_trans_header;
const struct lwapp_control_header *lwapp_control_header;
const u_char *tptr;
int hexdump,tlen;
int tlen;
int msg_tlen;
tptr=pptr;
@ -252,7 +252,6 @@ lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
/* did we capture enough for fully decoding the message */
if (!TTEST2(*tptr, msg_tlen))
goto trunc;
hexdump=FALSE;
/* XXX - Decode sub messages for each message */
switch(lwapp_control_header->msg_type) {

View File

@ -31,9 +31,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.13 2004-03-24 01:54:29 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.13 2004-03-24 01:54:29 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-lwres.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-lwres.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -44,9 +44,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.15 2004-03-24 01:58:14 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.15 2004-03-24 01:58:14 guy Exp ";
#else
__RCSID("$NetBSD: print-mobile.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-mobile.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -77,6 +77,7 @@ mobile_print(const u_char *bp, u_int length)
{
const u_char *cp = bp +8 ;
const struct mobile_ip *mob;
struct cksum_vec vec[1];
u_short proto,crc;
u_char osp =0; /* old source address present */
@ -106,7 +107,9 @@ mobile_print(const u_char *bp, u_int length)
(void)printf("> %s ",ipaddr_string(&mob->odst));
(void)printf("(oproto=%d)",proto>>8);
}
if (in_cksum((u_short *)mob, osp ? 12 : 8, 0)!=0) {
vec[0].ptr = (const u_int8_t *)(void *)mob;
vec[0].len = osp ? 12 : 8;
if (in_cksum(vec, 1)!=0) {
(void)printf(" (bad checksum %d)",crc);
}

View File

@ -35,9 +35,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.12 2005-04-20 22:21:00 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.12 2005-04-20 22:21:00 guy Exp ";
#else
__RCSID("$NetBSD: print-mobility.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-mobility.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -21,9 +21,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-mpcp.c,v 1.2 2006-02-10 17:24:55 hannes Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-mpcp.c,v 1.2 2006-02-10 17:24:55 hannes Exp ";
#else
__RCSID("$NetBSD: print-mpcp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-mpcp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -30,9 +30,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.14 2005-07-05 09:38:19 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.14 2005-07-05 09:38:19 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-mpls.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-mpls.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -59,6 +59,13 @@ static const char *mpls_labelname[] = {
/*15*/ "rsvd",
};
enum mpls_packet_type {
PT_UNKNOWN,
PT_IPV4,
PT_IPV6,
PT_OSI
};
/*
* RFC3032: MPLS label stack encoding
*/
@ -67,7 +74,8 @@ mpls_print(const u_char *bp, u_int length)
{
const u_char *p;
u_int32_t label_entry;
u_int16_t label_stack_depth = 0;
u_int16_t label_stack_depth = 0;
enum mpls_packet_type pt = PT_UNKNOWN;
p = bp;
printf("MPLS");
@ -75,9 +83,9 @@ mpls_print(const u_char *bp, u_int length)
TCHECK2(*p, sizeof(label_entry));
label_entry = EXTRACT_32BITS(p);
printf("%s(label %u",
label_stack_depth ? "\n\t" : " ",
MPLS_LABEL(label_entry));
label_stack_depth++;
(label_stack_depth && vflag) ? "\n\t" : " ",
MPLS_LABEL(label_entry));
label_stack_depth++;
if (vflag &&
MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))
printf(" (%s)", mpls_labelname[MPLS_LABEL(label_entry)]);
@ -89,98 +97,128 @@ mpls_print(const u_char *bp, u_int length)
p += sizeof(label_entry);
} while (!MPLS_STACK(label_entry));
/*
* Try to figure out the packet type.
*/
switch (MPLS_LABEL(label_entry)) {
case 0: /* IPv4 explicit NULL label */
case 3: /* IPv4 implicit NULL label */
if (vflag>0) {
printf("\n\t");
ip_print(gndo, p, length - (p - bp));
}
else printf(", IP, length: %u",length);
case 3: /* IPv4 implicit NULL label */
pt = PT_IPV4;
break;
#ifdef INET6
case 2: /* IPv6 explicit NULL label */
if (vflag>0) {
printf("\n\t");
ip6_print(p, length - (p - bp));
}
else printf(", IPv6, length: %u",length);
pt = PT_IPV6;
break;
#endif
default:
/*
* Generally there's no indication of protocol in MPLS label
* encoding, however draft-hsmit-isis-aal5mux-00.txt describes
* a technique that looks at the first payload byte if the BOS (bottom of stack)
* bit is set and tries to determine the network layer protocol
* 0x45-0x4f is IPv4
* 0x60-0x6f is IPv6
* 0x81-0x83 is OSI (CLNP,ES-IS,IS-IS)
* this technique is sometimes known as NULL encapsulation
* and decoding is particularly useful for control-plane traffic [BGP]
* which cisco by default sends MPLS encapsulated
* encoding.
*
* However, draft-hsmit-isis-aal5mux-00.txt describes a
* technique for encapsulating IS-IS and IP traffic on the
* same ATM virtual circuit; you look at the first payload
* byte to determine the network layer protocol, based on
* the fact that
*
* 1) the first byte of an IP header is 0x45-0x4f
* for IPv4 and 0x60-0x6f for IPv6;
*
* 2) the first byte of an OSI CLNP packet is 0x81,
* the first byte of an OSI ES-IS packet is 0x82,
* and the first byte of an OSI IS-IS packet is
* 0x83;
*
* so the network layer protocol can be inferred from the
* first byte of the packet, if the protocol is one of the
* ones listed above.
*
* Cisco sends control-plane traffic MPLS-encapsulated in
* this fashion.
*/
switch(*p) {
if (MPLS_STACK(label_entry)) { /* only do this if the stack bit is set */
switch(*p) {
case 0x45:
case 0x46:
case 0x47:
case 0x48:
case 0x49:
case 0x4a:
case 0x4b:
case 0x4c:
case 0x4d:
case 0x4e:
case 0x4f:
if (vflag>0) {
printf("\n\t");
ip_print(gndo, p, length - (p - bp));
}
else printf(", IP, length: %u",length);
break;
#ifdef INET6
case 0x60:
case 0x61:
case 0x62:
case 0x63:
case 0x64:
case 0x65:
case 0x66:
case 0x67:
case 0x68:
case 0x69:
case 0x6a:
case 0x6b:
case 0x6c:
case 0x6d:
case 0x6e:
case 0x6f:
if (vflag>0) {
printf("\n\t");
ip6_print(p, length - (p - bp));
}
else printf(", IPv6, length: %u",length);
break;
#endif
case 0x81:
case 0x82:
case 0x83:
if (vflag>0) {
printf("\n\t");
isoclns_print(p, length - (p - bp), length - (p - bp));
}
else printf(", OSI, length: %u",length);
break;
default:
/* ok bail out - we did not figure out what it is*/
break;
}
}
return;
case 0x45:
case 0x46:
case 0x47:
case 0x48:
case 0x49:
case 0x4a:
case 0x4b:
case 0x4c:
case 0x4d:
case 0x4e:
case 0x4f:
pt = PT_IPV4;
break;
case 0x60:
case 0x61:
case 0x62:
case 0x63:
case 0x64:
case 0x65:
case 0x66:
case 0x67:
case 0x68:
case 0x69:
case 0x6a:
case 0x6b:
case 0x6c:
case 0x6d:
case 0x6e:
case 0x6f:
pt = PT_IPV6;
break;
case 0x81:
case 0x82:
case 0x83:
pt = PT_OSI;
break;
default:
/* ok bail out - we did not figure out what it is*/
break;
}
}
/*
* Print the payload.
*/
if (pt == PT_UNKNOWN) {
if (!suppress_default_print)
default_print(p, length - (p - bp));
return;
}
if (vflag)
printf("\n\t");
else
printf(" ");
switch (pt) {
case PT_IPV4:
ip_print(gndo, p, length - (p - bp));
break;
case PT_IPV6:
#ifdef INET6
ip6_print(gndo, p, length - (p - bp));
#else
printf("IPv6, length: %u", length);
#endif
break;
case PT_OSI:
isoclns_print(p, length - (p - bp), length - (p - bp));
break;
default:
break;
}
return;
trunc:
printf("[|MPLS]");
}

View File

@ -19,9 +19,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.7 2005-04-06 21:32:41 mcr Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.7 2005-04-06 21:32:41 mcr Exp ";
#else
__RCSID("$NetBSD: print-msdp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-msdp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -26,9 +26,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.20 2003-11-16 09:36:29 guy Exp";
"@(#) Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.20 2003-11-16 09:36:29 guy Exp ";
#else
__RCSID("$NetBSD: print-netbios.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-netbios.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.111 2007-12-22 03:08:04 guy Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.111 2007-12-22 03:08:04 guy Exp (LBL)";
#else
__RCSID("$NetBSD: print-nfs.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-nfs.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -27,9 +27,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.43 2007-11-30 13:45:10 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.43 2007-11-30 13:45:10 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-ntp.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ntp.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-null.c,v 1.57 2006-03-23 14:58:44 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-null.c,v 1.57 2006-03-23 14:58:44 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-null.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-null.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -130,7 +130,7 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
case BSD_AFNUM_INET6_BSD:
case BSD_AFNUM_INET6_FREEBSD:
case BSD_AFNUM_INET6_DARWIN:
ip6_print(p, length);
ip6_print(gndo, p, length);
break;
#endif

View File

@ -25,9 +25,9 @@
#ifndef lint
#if 0
static const char rcsid[] _U_ =
"@(#) Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.66 2007-10-08 07:53:21 hannes Exp (LBL)";
"@(#) Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.66 2007-10-08 07:53:21 hannes Exp (LBL)";
#else
__RCSID("$NetBSD: print-ospf.c,v 1.2 2010/12/05 05:11:30 christos Exp $");
__RCSID("$NetBSD: print-ospf.c,v 1.3 2013/04/06 19:33:08 christos Exp $");
#endif
#endif
@ -202,7 +202,7 @@ static int ospf_decode_v2(const struct ospfhdr *, const u_char *);
static int ospf_decode_lls(const struct ospfhdr *, register u_int);
int
ospf_print_grace_lsa (u_int8_t *tptr, u_int ls_length) {
ospf_print_grace_lsa (const u_int8_t *tptr, u_int ls_length) {
u_int tlv_type, tlv_length;
@ -284,7 +284,7 @@ trunc:
}
int
ospf_print_te_lsa (u_int8_t *tptr, u_int ls_length) {
ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
u_int tlv_type, tlv_length, subtlv_type, subtlv_length;
u_int priority_level, te_class, count_srlg;
@ -1033,7 +1033,7 @@ ospf_decode_v2(register const struct ospfhdr *op,
lsap = op->ospf_lsu.lsu_lsa;
TCHECK(op->ospf_lsu.lsu_count);
lsa_count_max = EXTRACT_32BITS(&op->ospf_lsu.lsu_count);
printf(", %d LSA%s",lsa_count_max, lsa_count_max > 1 ? "s" : "");
printf(", %d LSA%s",lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
printf("\n\t LSA #%u",lsa_count);
lsap = (const struct lsa *)ospf_print_lsa(lsap);

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