tcpdump-3.7.2/0040755000076500000240000000000007627064051012352 5ustar fennerstafftcpdump-3.7.2/.cvsignore0100644000076500000240000000016607037741244014353 0ustar fennerstaffversion.c Makefile Makefile-devel.in config.status config.log config.cache config.h .devel stamp-h stamp-h.in tcpdump tcpdump-3.7.2/acconfig.h0100644000076500000240000000475507374047473014314 0ustar fennerstaff/* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in -- * make them to acconfig.h and rerun autoheader */ @TOP@ /* Define if you have SSLeay 0.9.0b with the buggy cast128. */ #undef HAVE_BUGGY_CAST128 /* Define if you enable IPv6 support */ #undef INET6 /* Define if you enable support for the libsmi. */ #undef LIBSMI /* Define if you have the header file. */ #undef HAVE_SMI_H /* define if you have struct __res_state_ext */ #undef HAVE_RES_STATE_EXT /* define if your struct __res_state has the nsort member */ #undef HAVE_NEW_RES_STATE /* * define if struct ether_header.ether_dhost is a struct with ether_addr_octet */ #undef ETHER_HEADER_HAS_EA /* define if struct ether_arp contains arp_xsha */ #undef ETHER_ARP_HAS_X /* define if you have the addrinfo function. */ #undef HAVE_ADDRINFO /* define if you need to include missing/addrinfoh.h. */ #undef NEED_ADDRINFO_H /* define ifyou have the h_errno variable. */ #undef HAVE_H_ERRNO /* define if IN6ADDRSZ is defined (XXX not used!) */ #undef HAVE_IN6ADDRSZ /* define if INADDRSZ is defined (XXX not used!) */ #undef HAVE_INADDRSZ /* define if this is a development version, to use additional prototypes. */ #undef HAVE_OS_PROTO_H /* define if defines __P() */ #undef HAVE_PORTABLE_PROTOTYPE /* define if RES_USE_INET6 is defined */ #undef HAVE_RES_USE_INET6 /* define if struct sockaddr has the sa_len member */ #undef HAVE_SOCKADDR_SA_LEN /* define if you have struct sockaddr_storage */ #undef HAVE_SOCKADDR_STORAGE /* define if you have both getipnodebyname() and getipnodebyaddr() */ #undef USE_GETIPNODEBY /* define if you have ether_ntohost() and it works */ #undef USE_ETHER_NTOHOST /* define if unaligned memory accesses fail */ #undef LBL_ALIGN /* The successful return value from signal (?)XXX */ #undef RETSIGVAL /* Define this on IRIX */ #undef _BSD_SIGNALS /* For HP/UX ANSI compiler? */ #undef _HPUX_SOURCE /* AIX hack. */ #undef _SUN /* Workaround for missing sized types */ /* XXX this should move to the more standard uint*_t */ #undef int16_t #undef int32_t #undef u_int16_t #undef u_int32_t #undef u_int8_t /* Whether or not to include the possibly-buggy SMB printer */ #undef TCPDUMP_DO_SMB /* Long story short: aclocal.m4 depends on autoconf 2.13 * implementation details wrt "const"; newer versions * have different implementation details so for now we * put "const" here. This may cause duplicate definitions * in config.h but that should be OK since they're the same. */ #undef const tcpdump-3.7.2/aclocal.m40100644000076500000240000006736707627054622014235 0ustar fennerstaffdnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.80.2.4 2002/07/13 09:38:53 guy Exp $ (LBL) dnl dnl Copyright (c) 1995, 1996, 1997, 1998 dnl The Regents of the University of California. All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without dnl modification, are permitted provided that: (1) source code distributions dnl retain the above copyright notice and this paragraph in its entirety, (2) dnl distributions including binary code include the above copyright notice and dnl this paragraph in its entirety in the documentation or other materials dnl provided with the distribution, and (3) all advertising materials mentioning dnl features or use of this software display the following acknowledgement: dnl ``This product includes software developed by the University of California, dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of dnl the University nor the names of its contributors may be used to endorse dnl or promote products derived from this software without specific prior dnl written permission. dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. dnl dnl LBL autoconf macros dnl dnl dnl Determine which compiler we're using (cc or gcc) dnl If using gcc, determine the version number dnl If using cc, require that it support ansi prototypes dnl If using gcc, use -O2 (otherwise use -O) dnl If using cc, explicitly specify /usr/local/include dnl dnl usage: dnl dnl AC_LBL_C_INIT(copt, incls) dnl dnl results: dnl dnl $1 (copt set) dnl $2 (incls set) dnl CC dnl LDFLAGS dnl ac_cv_lbl_gcc_vers dnl LBL_CFLAGS dnl AC_DEFUN(AC_LBL_C_INIT, [AC_PREREQ(2.12) AC_BEFORE([$0], [AC_PROG_CC]) AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) AC_BEFORE([$0], [AC_LBL_DEVEL]) AC_ARG_WITH(gcc, [ --without-gcc don't use gcc]) $1="-O" $2="" if test "${srcdir}" != "." ; then $2="-I\$(srcdir)" fi if test "${CFLAGS+set}" = set; then LBL_CFLAGS="$CFLAGS" fi if test -z "$CC" ; then case "$host_os" in bsdi*) AC_CHECK_PROG(SHLICC2, shlicc2, yes, no) if test $SHLICC2 = yes ; then CC=shlicc2 export CC fi ;; esac fi if test -z "$CC" -a "$with_gcc" = no ; then CC=cc export CC fi AC_PROG_CC if test "$GCC" = yes ; then if test "$SHLICC2" = yes ; then ac_cv_lbl_gcc_vers=2 $1="-O2" else AC_MSG_CHECKING(gcc version) AC_CACHE_VAL(ac_cv_lbl_gcc_vers, ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \ sed -e '/^gcc version /!d' \ -e 's/^gcc version //' \ -e 's/ .*//' -e 's/^[[[^0-9]]]*//' \ -e 's/\..*//'`) AC_MSG_RESULT($ac_cv_lbl_gcc_vers) if test $ac_cv_lbl_gcc_vers -gt 1 ; then $1="-O2" fi fi else AC_MSG_CHECKING(that $CC handles ansi prototypes) AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes, AC_TRY_COMPILE( [#include ], [int frob(int, char *)], ac_cv_lbl_cc_ansi_prototypes=yes, ac_cv_lbl_cc_ansi_prototypes=no)) AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes) if test $ac_cv_lbl_cc_ansi_prototypes = no ; then case "$host_os" in hpux*) AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)) savedcflags="$CFLAGS" CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa, AC_TRY_COMPILE( [#include ], [int frob(int, char *)], ac_cv_lbl_cc_hpux_cc_aa=yes, ac_cv_lbl_cc_hpux_cc_aa=no)) AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa) if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then AC_MSG_ERROR(see the INSTALL doc for more info) fi CFLAGS="$savedcflags" V_CCOPT="-Aa $V_CCOPT" AC_DEFINE(_HPUX_SOURCE) ;; *) AC_MSG_ERROR(see the INSTALL doc for more info) ;; esac fi $2="$$2 -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" case "$host_os" in irix*) V_CCOPT="$V_CCOPT -xansi -signed -O" ;; osf*) V_CCOPT="$V_CCOPT -std1 -O" ;; ultrix*) AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes) AC_CACHE_VAL(ac_cv_lbl_cc_const_proto, AC_TRY_COMPILE( [#include ], [struct a { int b; }; void c(const struct a *)], ac_cv_lbl_cc_const_proto=yes, ac_cv_lbl_cc_const_proto=no)) AC_MSG_RESULT($ac_cv_lbl_cc_const_proto) if test $ac_cv_lbl_cc_const_proto = no ; then AC_DEFINE(const,) fi ;; esac fi ]) # # Try compiling a sample of the type of code that appears in # gencode.c with "inline", "__inline__", and "__inline". # # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough, # as it just tests whether a function returning "int" can be inlined; # at least some versions of HP's C compiler can inline that, but can't # inline a function that returns a struct pointer. # AC_DEFUN(AC_LBL_C_INLINE, [AC_MSG_CHECKING(for inline) AC_CACHE_VAL(ac_cv_lbl_inline, [ ac_cv_lbl_inline="" ac_lbl_cc_inline=no for ac_lbl_inline in inline __inline__ __inline do AC_TRY_COMPILE( [#define inline $ac_lbl_inline static inline struct iltest *foo(void); struct iltest { int iltest1; int iltest2; }; static inline struct iltest * foo() { static struct iltest xxx; return &xxx; }],,ac_lbl_cc_inline=yes,) if test "$ac_lbl_cc_inline" = yes ; then break; fi done if test "$ac_lbl_cc_inline" = yes ; then ac_cv_lbl_inline=$ac_lbl_inline fi]) if test ! -z "$ac_cv_lbl_inline" ; then AC_MSG_RESULT($ac_cv_lbl_inline) else AC_MSG_RESULT(no) fi AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])]) dnl dnl Use pfopen.c if available and pfopen() not in standard libraries dnl Require libpcap dnl Look for libpcap in .. dnl Use the installed libpcap if there is no local version dnl dnl usage: dnl dnl AC_LBL_LIBPCAP(pcapdep, incls) dnl dnl results: dnl dnl $1 (pcapdep set) dnl $2 (incls appended) dnl LIBS dnl LBL_LIBS dnl AC_DEFUN(AC_LBL_LIBPCAP, [AC_REQUIRE([AC_LBL_LIBRARY_NET]) dnl dnl save a copy before locating libpcap.a dnl LBL_LIBS="$LIBS" pfopen=/usr/examples/packetfilter/pfopen.c if test -f $pfopen ; then AC_CHECK_FUNCS(pfopen) if test $ac_cv_func_pfopen = "no" ; then AC_MSG_RESULT(Using $pfopen) LIBS="$LIBS $pfopen" fi fi AC_MSG_CHECKING(for local pcap library) libpcap=FAIL lastdir=FAIL places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \ egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'` for dir in $places ../libpcap libpcap ; do basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'` if test $lastdir = $basedir ; then dnl skip alphas when an actual release is present continue; fi lastdir=$dir if test -r $dir/libpcap.a ; then libpcap=$dir/libpcap.a d=$dir dnl continue and select the last one that exists fi done if test $libpcap = FAIL ; then AC_MSG_RESULT(not found) AC_CHECK_LIB(pcap, main, libpcap="-lpcap") if test $libpcap = FAIL ; then AC_MSG_ERROR(see the INSTALL doc for more info) fi else $1=$libpcap places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'` if test -r $d/pcap.h; then $2="-I$d $$2" elif test -r $places/pcap.h; then $2="-I$places $$2" else AC_MSG_ERROR(cannot find pcap.h, see INSTALL) fi AC_MSG_RESULT($libpcap) fi LIBS="$libpcap $LIBS" case "$host_os" in aix*) pseexe="/lib/pse.exp" AC_MSG_CHECKING(for $pseexe) if test -f $pseexe ; then AC_MSG_RESULT(yes) LIBS="$LIBS -I:$pseexe" fi ;; esac]) dnl dnl Define RETSIGTYPE and RETSIGVAL dnl dnl usage: dnl dnl AC_LBL_TYPE_SIGNAL dnl dnl results: dnl dnl RETSIGTYPE (defined) dnl RETSIGVAL (defined) dnl AC_DEFUN(AC_LBL_TYPE_SIGNAL, [AC_BEFORE([$0], [AC_LBL_LIBPCAP]) AC_TYPE_SIGNAL if test "$ac_cv_type_signal" = void ; then AC_DEFINE(RETSIGVAL,) else AC_DEFINE(RETSIGVAL,(0)) fi case "$host_os" in irix*) AC_DEFINE(_BSD_SIGNALS) ;; *) dnl prefer sigset() to sigaction() AC_CHECK_FUNCS(sigset) if test $ac_cv_func_sigset = no ; then AC_CHECK_FUNCS(sigaction) fi ;; esac]) dnl dnl If using gcc, make sure we have ANSI ioctl definitions dnl dnl usage: dnl dnl AC_LBL_FIXINCLUDES dnl AC_DEFUN(AC_LBL_FIXINCLUDES, [if test "$GCC" = yes ; then AC_MSG_CHECKING(for ANSI ioctl definitions) AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes, AC_TRY_COMPILE( [/* * This generates a "duplicate case value" when fixincludes * has not be run. */ # include # include # include # ifdef HAVE_SYS_IOCCOM_H # include # endif], [switch (0) { case _IO('A', 1):; case _IO('B', 1):; }], ac_cv_lbl_gcc_fixincludes=yes, ac_cv_lbl_gcc_fixincludes=no)) AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes) if test $ac_cv_lbl_gcc_fixincludes = no ; then # Don't cache failure unset ac_cv_lbl_gcc_fixincludes AC_MSG_ERROR(see the INSTALL for more info) fi fi]) dnl dnl Check for flex, default to lex dnl Require flex 2.4 or higher dnl Check for bison, default to yacc dnl Default to lex/yacc if both flex and bison are not available dnl Define the yy prefix string if using flex and bison dnl dnl usage: dnl dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix) dnl dnl results: dnl dnl $1 (lex set) dnl $2 (yacc appended) dnl $3 (optional flex and bison -P prefix) dnl AC_DEFUN(AC_LBL_LEX_AND_YACC, [AC_ARG_WITH(flex, [ --without-flex don't use flex]) AC_ARG_WITH(bison, [ --without-bison don't use bison]) if test "$with_flex" = no ; then $1=lex else AC_CHECK_PROGS($1, flex, lex) fi if test "$$1" = flex ; then # The -V flag was added in 2.4 AC_MSG_CHECKING(for flex 2.4 or higher) AC_CACHE_VAL(ac_cv_lbl_flex_v24, if flex -V >/dev/null 2>&1; then ac_cv_lbl_flex_v24=yes else ac_cv_lbl_flex_v24=no fi) AC_MSG_RESULT($ac_cv_lbl_flex_v24) if test $ac_cv_lbl_flex_v24 = no ; then s="2.4 or higher required" AC_MSG_WARN(ignoring obsolete flex executable ($s)) $1=lex fi fi if test "$with_bison" = no ; then $2=yacc else AC_CHECK_PROGS($2, bison, yacc) fi if test "$$2" = bison ; then $2="$$2 -y" fi if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc) $1=lex $2=yacc fi if test "$$1" = flex -a -n "$3" ; then $1="$$1 -P$3" $2="$$2 -p $3" fi]) dnl dnl Checks to see if union wait is used with WEXITSTATUS() dnl dnl usage: dnl dnl AC_LBL_UNION_WAIT dnl dnl results: dnl dnl DECLWAITSTATUS (defined) dnl AC_DEFUN(AC_LBL_UNION_WAIT, [AC_MSG_CHECKING(if union wait is used) AC_CACHE_VAL(ac_cv_lbl_union_wait, AC_TRY_COMPILE([ # include # include ], [int status; u_int i = WEXITSTATUS(status); u_int j = waitpid(0, &status, 0);], ac_cv_lbl_union_wait=no, ac_cv_lbl_union_wait=yes)) AC_MSG_RESULT($ac_cv_lbl_union_wait) if test $ac_cv_lbl_union_wait = yes ; then AC_DEFINE(DECLWAITSTATUS,union wait) else AC_DEFINE(DECLWAITSTATUS,int) fi]) dnl dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member dnl dnl usage: dnl dnl AC_LBL_SOCKADDR_SA_LEN dnl dnl results: dnl dnl HAVE_SOCKADDR_SA_LEN (defined) dnl AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN, [AC_MSG_CHECKING(if sockaddr struct has sa_len member) AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len, AC_TRY_COMPILE([ # include # include ], [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], ac_cv_lbl_sockaddr_has_sa_len=yes, ac_cv_lbl_sockaddr_has_sa_len=no)) AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len) if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then AC_DEFINE(HAVE_SOCKADDR_SA_LEN) fi]) dnl dnl Checks to see if -R is used dnl dnl usage: dnl dnl AC_LBL_HAVE_RUN_PATH dnl dnl results: dnl dnl ac_cv_lbl_have_run_path (yes or no) dnl AC_DEFUN(AC_LBL_HAVE_RUN_PATH, [AC_MSG_CHECKING(for ${CC-cc} -R) AC_CACHE_VAL(ac_cv_lbl_have_run_path, [echo 'main(){}' > conftest.c ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1 if test ! -s conftest.out ; then ac_cv_lbl_have_run_path=yes else ac_cv_lbl_have_run_path=no fi rm -f conftest*]) AC_MSG_RESULT($ac_cv_lbl_have_run_path) ]) dnl dnl Due to the stupid way it's implemented, AC_CHECK_TYPE is nearly useless. dnl dnl usage: dnl dnl AC_LBL_CHECK_TYPE dnl dnl results: dnl dnl int32_t (defined) dnl u_int32_t (defined) dnl AC_DEFUN(AC_LBL_CHECK_TYPE, [AC_MSG_CHECKING(for $1 using $CC) AC_CACHE_VAL(ac_cv_lbl_have_$1, AC_TRY_COMPILE([ # include "confdefs.h" # include # if STDC_HEADERS # include # include # endif], [$1 i], ac_cv_lbl_have_$1=yes, ac_cv_lbl_have_$1=no)) AC_MSG_RESULT($ac_cv_lbl_have_$1) if test $ac_cv_lbl_have_$1 = no ; then AC_DEFINE($1, $2) fi]) dnl dnl Checks to see if unaligned memory accesses fail dnl dnl usage: dnl dnl AC_LBL_UNALIGNED_ACCESS dnl dnl results: dnl dnl LBL_ALIGN (DEFINED) dnl AC_DEFUN(AC_LBL_UNALIGNED_ACCESS, [AC_MSG_CHECKING(if unaligned accesses fail) AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, [case "$host_cpu" in # XXX: should also check that they don't do weird things (like on arm) alpha*|arm*|hp*|mips*|sparc*|ia64) ac_cv_lbl_unaligned_fail=yes ;; *) cat >conftest.c < # include # include unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; main() { unsigned int i; pid_t pid; int status; /* avoid "core dumped" message */ pid = fork(); if (pid < 0) exit(2); if (pid > 0) { /* parent */ pid = waitpid(pid, &status, 0); if (pid < 0) exit(3); exit(!WIFEXITED(status)); } /* child */ i = *(unsigned int *)&a[[1]]; printf("%d\n", i); exit(0); } EOF ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ conftest.c $LIBS >/dev/null 2>&1 if test ! -x conftest ; then dnl failed to compile for some reason ac_cv_lbl_unaligned_fail=yes else ./conftest >conftest.out if test ! -s conftest.out ; then ac_cv_lbl_unaligned_fail=yes else ac_cv_lbl_unaligned_fail=no fi fi rm -f conftest* core core.conftest ;; esac]) AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) if test $ac_cv_lbl_unaligned_fail = yes ; then AC_DEFINE(LBL_ALIGN) fi]) dnl dnl If using gcc and the file .devel exists: dnl Compile with -g (if supported) and -Wall dnl If using gcc 2, do extra prototype checking dnl If an os prototype include exists, symlink os-proto.h to it dnl dnl usage: dnl dnl AC_LBL_DEVEL(copt) dnl dnl results: dnl dnl $1 (copt appended) dnl HAVE_OS_PROTO_H (defined) dnl os-proto.h (symlinked) dnl AC_DEFUN(AC_LBL_DEVEL, [rm -f os-proto.h if test "${LBL_CFLAGS+set}" = set; then $1="$$1 ${LBL_CFLAGS}" fi if test -f .devel ; then if test "$GCC" = yes ; then if test "${LBL_CFLAGS+set}" != set; then if test "$ac_cv_prog_cc_g" = yes ; then $1="-g $$1" fi $1="$$1 -Wall" if test $ac_cv_lbl_gcc_vers -gt 1 ; then $1="$$1 -Wmissing-prototypes -Wstrict-prototypes" fi fi else case "$host_os" in irix6*) V_CCOPT="$V_CCOPT -n32" ;; *) ;; esac fi os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'` name="lbl/os-$os.h" if test -f $name ; then ln -s $name os-proto.h AC_DEFINE(HAVE_OS_PROTO_H) else AC_MSG_WARN(can't find $name) fi fi]) dnl dnl Improved version of AC_CHECK_LIB dnl dnl Thanks to John Hawkinson (jhawk@mit.edu) dnl dnl usage: dnl dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) dnl dnl results: dnl dnl LIBS dnl define(AC_LBL_CHECK_LIB, [AC_MSG_CHECKING([for $2 in -l$1]) dnl Use a cache variable name containing the library, function dnl name, and extra libraries to link with, because the test really is dnl for library $1 defining function $2, when linked with potinal dnl library $5, not just for library $1. Separate tests with the same dnl $1 and different $2's or $5's may have different results. ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'` AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var, [ac_save_LIBS="$LIBS" LIBS="-l$1 $5 $LIBS" AC_TRY_LINK(dnl ifelse([$2], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus extern "C" #endif ])dnl [/* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $2(); ]), [$2()], eval "ac_cv_lbl_lib_$ac_lib_var=yes", eval "ac_cv_lbl_lib_$ac_lib_var=no") LIBS="$ac_save_LIBS" ])dnl if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then AC_MSG_RESULT(yes) ifelse([$3], , [changequote(, )dnl ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` changequote([, ])dnl AC_DEFINE_UNQUOTED($ac_tr_lib) LIBS="-l$1 $LIBS" ], [$3]) else AC_MSG_RESULT(no) ifelse([$4], , , [$4 ])dnl fi ]) dnl dnl AC_LBL_LIBRARY_NET dnl dnl This test is for network applications that need socket() and dnl gethostbyname() -ish functions. Under Solaris, those applications dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link dnl with "-lnsl" but should *not* link with "-lsocket" because dnl libsocket.a breaks a number of things (for instance: dnl gethostbyname() under IRIX 5.2, and snoop sockets under most dnl versions of IRIX). dnl dnl Unfortunately, many application developers are not aware of this, dnl and mistakenly write tests that cause -lsocket to be used under dnl IRIX. It is also easy to write tests that cause -lnsl to be used dnl under operating systems where neither are necessary (or useful), dnl such as SunOS 4.1.4, which uses -lnsl for TLI. dnl dnl This test exists so that every application developer does not test dnl this in a different, and subtly broken fashion. dnl It has been argued that this test should be broken up into two dnl seperate tests, one for the resolver libraries, and one for the dnl libraries necessary for using Sockets API. Unfortunately, the two dnl are carefully intertwined and allowing the autoconf user to use dnl them independantly potentially results in unfortunate ordering dnl dependancies -- as such, such component macros would have to dnl carefully use indirection and be aware if the other components were dnl executed. Since other autoconf macros do not go to this trouble, dnl and almost no applications use sockets without the resolver, this dnl complexity has not been implemented. dnl dnl The check for libresolv is in case you are attempting to link dnl statically and happen to have a libresolv.a lying around (and no dnl libnsl.a). dnl AC_DEFUN(AC_LBL_LIBRARY_NET, [ # Most operating systems have gethostbyname() in the default searched # libraries (i.e. libc): # Some OSes (eg. Solaris) place it in libnsl # Some strange OSes (SINIX) have it in libsocket: AC_SEARCH_LIBS(gethostbyname, nsl socket resolv) # Unfortunately libsocket sometimes depends on libnsl and # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this. if test "$ac_cv_search_gethostbyname" = "no" then AC_CHECK_LIB(socket, gethostbyname, LIBS="-lsocket -lnsl $LIBS", , -lnsl) fi AC_SEARCH_LIBS(socket, socket, , AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)) # DLPI needs putmsg under HPUX so test for -lstr while we're at it AC_SEARCH_LIBS(putmsg, str) ]) dnl Copyright (c) 1999 WIDE Project. All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without dnl modification, are permitted provided that the following conditions dnl are met: dnl 1. Redistributions of source code must retain the above copyright dnl notice, this list of conditions and the following disclaimer. dnl 2. Redistributions in binary form must reproduce the above copyright dnl notice, this list of conditions and the following disclaimer in the dnl documentation and/or other materials provided with the distribution. dnl 3. Neither the name of the project nor the names of its contributors dnl may be used to endorse or promote products derived from this software dnl without specific prior written permission. dnl dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE dnl ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF dnl SUCH DAMAGE. dnl dnl Checks to see if AF_INET6 is defined AC_DEFUN(AC_CHECK_AF_INET6, [ AC_MSG_CHECKING(for AF_INET6) AC_CACHE_VAL($1, AC_TRY_COMPILE([ # include # include ], [int a = AF_INET6], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 = yes ; then AC_DEFINE(HAVE_AF_INET6) fi ]) dnl dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member dnl borrowed from LBL libpcap AC_DEFUN(AC_CHECK_SA_LEN, [ AC_MSG_CHECKING(if sockaddr struct has sa_len member) AC_CACHE_VAL($1, AC_TRY_COMPILE([ # include # include ], [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 = yes ; then AC_DEFINE(HAVE_SOCKADDR_SA_LEN) fi ]) dnl dnl Checks for portable prototype declaration macro AC_DEFUN(AC_CHECK_PORTABLE_PROTO, [ AC_MSG_CHECKING(for __P) AC_CACHE_VAL($1, AC_TRY_COMPILE([ # include ], [int f __P(())], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 = yes; then AC_DEFINE(HAVE_PORTABLE_PROTOTYPE) fi ]) dnl checks for u_intXX_t AC_DEFUN(AC_CHECK_BITTYPES, [ $1=yes dnl check for u_int8_t AC_MSG_CHECKING(for u_int8_t) AC_CACHE_VAL(ac_cv_u_int8_t, AC_TRY_COMPILE([ # include ], [u_int8_t i], ac_cv_u_int8_t=yes, ac_cv_u_int8_t=no)) AC_MSG_RESULT($ac_cv_u_int8_t) if test $ac_cv_u_int8_t = yes; then AC_DEFINE(HAVE_U_INT8_T) else $1=no fi dnl check for u_int16_t AC_MSG_CHECKING(for u_int16_t) AC_CACHE_VAL(ac_cv_u_int16_t, AC_TRY_COMPILE([ # include ], [u_int16_t i], ac_cv_u_int16_t=yes, ac_cv_u_int16_t=no)) AC_MSG_RESULT($ac_cv_u_int16_t) if test $ac_cv_u_int16_t = yes; then AC_DEFINE(HAVE_U_INT16_T) else $1=no fi dnl check for u_int32_t AC_MSG_CHECKING(for u_int32_t) AC_CACHE_VAL(ac_cv_u_int32_t, AC_TRY_COMPILE([ # include ], [u_int32_t i], ac_cv_u_int32_t=yes, ac_cv_u_int32_t=no)) AC_MSG_RESULT($ac_cv_u_int32_t) if test $ac_cv_u_int32_t = yes; then AC_DEFINE(HAVE_U_INT32_T) else $1=no fi ]) dnl dnl Checks for addrinfo structure AC_DEFUN(AC_STRUCT_ADDRINFO, [ AC_MSG_CHECKING(for addrinfo) AC_CACHE_VAL($1, AC_TRY_COMPILE([ # include ], [struct addrinfo a], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 = yes; then AC_DEFINE(HAVE_ADDRINFO) else AC_DEFINE(NEED_ADDRINFO_H) fi ]) dnl dnl Checks for NI_MAXSERV AC_DEFUN(AC_NI_MAXSERV, [ AC_MSG_CHECKING(for NI_MAXSERV) AC_CACHE_VAL($1, AC_EGREP_CPP(yes, [#include #ifdef NI_MAXSERV yes #endif], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 != yes; then AC_DEFINE(NEED_ADDRINFO_H) fi ]) dnl dnl Checks for NI_NAMEREQD AC_DEFUN(AC_NI_NAMEREQD, [ AC_MSG_CHECKING(for NI_NAMEREQD) AC_CACHE_VAL($1, AC_EGREP_CPP(yes, [#include #ifdef NI_NOFQDN yes #endif], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 != yes; then AC_DEFINE(NEED_ADDRINFO_H) fi ]) dnl dnl Checks for sockaddr_storage structure AC_DEFUN(AC_STRUCT_SA_STORAGE, [ AC_MSG_CHECKING(for sockaddr_storage) AC_CACHE_VAL($1, AC_TRY_COMPILE([ # include # include ], [struct sockaddr_storage s], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 = yes; then AC_DEFINE(HAVE_SOCKADDR_STORAGE) fi ]) dnl dnl Checks for macro of IP address size AC_DEFUN(AC_CHECK_ADDRSZ, [ $1=yes dnl check for INADDRSZ AC_MSG_CHECKING(for INADDRSZ) AC_CACHE_VAL(ac_cv_inaddrsz, AC_TRY_COMPILE([ # include ], [int a = INADDRSZ], ac_cv_inaddrsz=yes, ac_cv_inaddrsz=no)) AC_MSG_RESULT($ac_cv_inaddrsz) if test $ac_cv_inaddrsz = yes; then AC_DEFINE(HAVE_INADDRSZ) else $1=no fi dnl check for IN6ADDRSZ AC_MSG_CHECKING(for IN6ADDRSZ) AC_CACHE_VAL(ac_cv_in6addrsz, AC_TRY_COMPILE([ # include ], [int a = IN6ADDRSZ], ac_cv_in6addrsz=yes, ac_cv_in6addrsz=no)) AC_MSG_RESULT($ac_cv_in6addrsz) if test $ac_cv_in6addrsz = yes; then AC_DEFINE(HAVE_IN6ADDRSZ) else $1=no fi ]) dnl dnl check for RES_USE_INET6 AC_DEFUN(AC_CHECK_RES_USE_INET6, [ AC_MSG_CHECKING(for RES_USE_INET6) AC_CACHE_VAL($1, AC_TRY_COMPILE([ # include # include # include ], [int a = RES_USE_INET6], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 = yes; then AC_DEFINE(HAVE_RES_USE_INET6) fi ]) dnl dnl check for AAAA AC_DEFUN(AC_CHECK_AAAA, [ AC_MSG_CHECKING(for AAAA) AC_CACHE_VAL($1, AC_TRY_COMPILE([ # include # include ], [int a = T_AAAA], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 = yes; then AC_DEFINE(HAVE_AAAA) fi ]) dnl dnl check for struct res_state_ext AC_DEFUN(AC_STRUCT_RES_STATE_EXT, [ AC_MSG_CHECKING(for res_state_ext) AC_CACHE_VAL($1, AC_TRY_COMPILE([ # include # include # include # include ], [struct __res_state_ext e], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 = yes; then AC_DEFINE(HAVE_RES_STATE_EXT) fi ]) dnl dnl check for struct res_state_ext AC_DEFUN(AC_STRUCT_RES_STATE, [ AC_MSG_CHECKING(for nsort in res_state) AC_CACHE_VAL($1, AC_TRY_COMPILE([ # include # include # include # include ], [struct __res_state e; e.nsort = 0], $1=yes, $1=no)) AC_MSG_RESULT($$1) if test $$1 = yes; then AC_DEFINE(HAVE_NEW_RES_STATE) fi ]) dnl dnl check for h_errno AC_DEFUN(AC_VAR_H_ERRNO, [ AC_MSG_CHECKING(for h_errno) AC_CACHE_VAL(ac_cv_var_h_errno, AC_TRY_COMPILE([ # include # include ], [int foo = h_errno;], ac_cv_var_h_errno=yes, ac_cv_var_h_errno=no)) AC_MSG_RESULT($ac_cv_var_h_errno) if test "$ac_cv_var_h_errno" = "yes"; then AC_DEFINE(HAVE_H_ERRNO) fi ]) dnl dnl Test for __attribute__ dnl AC_DEFUN(AC_C___ATTRIBUTE__, [ AC_MSG_CHECKING(for __attribute__) AC_CACHE_VAL(ac_cv___attribute__, [ AC_TRY_COMPILE([ #include ], [ static void foo(void) __attribute__ ((noreturn)); static void foo(void) { exit(1); } ], ac_cv___attribute__=yes, ac_cv___attribute__=no)]) if test "$ac_cv___attribute__" = "yes"; then AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__]) fi AC_MSG_RESULT($ac_cv___attribute__) ]) tcpdump-3.7.2/addrtoname.c0100644000076500000240000005130107627054622014634 0ustar fennerstaff/* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Internet, ethernet, port, and protocol string to address * and address to string conversion routines */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.83.4.1 2002/06/02 00:08:07 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #ifdef USE_ETHER_NTOHOST #ifdef HAVE_NETINET_IF_ETHER_H struct mbuf; /* Squelch compiler warnings on some platforms for */ struct rtentry; /* declarations in */ #include /* for "struct ifnet" in "struct arpcom" on Solaris */ #include #endif /* HAVE_NETINET_IF_ETHER_H */ #endif /* USE_ETHER_NTOHOST */ #include #include #include #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "llc.h" #include "setsignal.h" /* Forwards */ static RETSIGTYPE nohostname(int); /* * hash tables for whatever-to-name translations */ #define HASHNAMESIZE 4096 struct hnamemem { u_int32_t addr; const char *name; struct hnamemem *nxt; }; struct hnamemem hnametable[HASHNAMESIZE]; struct hnamemem tporttable[HASHNAMESIZE]; struct hnamemem uporttable[HASHNAMESIZE]; struct hnamemem eprototable[HASHNAMESIZE]; struct hnamemem dnaddrtable[HASHNAMESIZE]; struct hnamemem llcsaptable[HASHNAMESIZE]; #ifdef INET6 struct h6namemem { struct in6_addr addr; char *name; struct h6namemem *nxt; }; struct h6namemem h6nametable[HASHNAMESIZE]; #endif /* INET6 */ struct enamemem { u_short e_addr0; u_short e_addr1; u_short e_addr2; const char *e_name; u_char *e_nsap; /* used only for nsaptable[] */ #define e_bs e_nsap /* for bytestringtable */ struct enamemem *e_nxt; }; struct enamemem enametable[HASHNAMESIZE]; struct enamemem nsaptable[HASHNAMESIZE]; struct enamemem bytestringtable[HASHNAMESIZE]; struct protoidmem { u_int32_t p_oui; u_short p_proto; const char *p_name; struct protoidmem *p_nxt; }; struct protoidmem protoidtable[HASHNAMESIZE]; /* * A faster replacement for inet_ntoa(). */ const char * intoa(u_int32_t addr) { register char *cp; register u_int byte; register int n; static char buf[sizeof(".xxx.xxx.xxx.xxx")]; NTOHL(addr); cp = &buf[sizeof buf]; *--cp = '\0'; n = 4; do { byte = addr & 0xff; *--cp = byte % 10 + '0'; byte /= 10; if (byte > 0) { *--cp = byte % 10 + '0'; byte /= 10; if (byte > 0) *--cp = byte + '0'; } *--cp = '.'; addr >>= 8; } while (--n > 0); return cp + 1; } static u_int32_t f_netmask; static u_int32_t f_localnet; static u_int32_t netmask; /* * "getname" is written in this atrocious way to make sure we don't * wait forever while trying to get hostnames from yp. */ #include jmp_buf getname_env; static RETSIGTYPE nohostname(int signo) { longjmp(getname_env, 1); } /* * Return a name for the IP address pointed to by ap. This address * is assumed to be in network byte order. */ const char * getname(const u_char *ap) { register struct hostent *hp; u_int32_t addr; static struct hnamemem *p; /* static for longjmp() */ memcpy(&addr, ap, sizeof(addr)); p = &hnametable[addr & (HASHNAMESIZE-1)]; for (; p->nxt; p = p->nxt) { if (p->addr == addr) return (p->name); } p->addr = addr; p->nxt = newhnamemem(); /* * Only print names when: * (1) -n was not given. * (2) Address is foreign and -f was given. (If -f was not * give, f_netmask and f_local are 0 and the test * evaluates to true) * (3) -a was given or the host portion is not all ones * nor all zeros (i.e. not a network or broadcast address) */ if (!nflag && (addr & f_netmask) == f_localnet && (aflag || !((addr & ~netmask) == 0 || (addr | netmask) == 0xffffffff))) { if (!setjmp(getname_env)) { (void)setsignal(SIGALRM, nohostname); (void)alarm(20); hp = gethostbyaddr((char *)&addr, 4, AF_INET); (void)alarm(0); if (hp) { char *dotp; p->name = strdup(hp->h_name); if (Nflag) { /* Remove domain qualifications */ dotp = strchr(p->name, '.'); if (dotp) *dotp = '\0'; } return (p->name); } } } p->name = strdup(intoa(addr)); return (p->name); } #ifdef INET6 /* * Return a name for the IP6 address pointed to by ap. This address * is assumed to be in network byte order. */ const char * getname6(const u_char *ap) { register struct hostent *hp; struct in6_addr addr; static struct h6namemem *p; /* static for longjmp() */ register const char *cp; char ntop_buf[INET6_ADDRSTRLEN]; memcpy(&addr, ap, sizeof(addr)); p = &h6nametable[*(u_int16_t *)&addr.s6_addr[14] & (HASHNAMESIZE-1)]; for (; p->nxt; p = p->nxt) { if (memcmp(&p->addr, &addr, sizeof(addr)) == 0) return (p->name); } p->addr = addr; p->nxt = newh6namemem(); /* * Only print names when: * (1) -n was not given. * (2) Address is foreign and -f was given. (If -f was not * give, f_netmask and f_local are 0 and the test * evaluates to true) * (3) -a was given or the host portion is not all ones * nor all zeros (i.e. not a network or broadcast address) */ if (!nflag #if 0 && (addr & f_netmask) == f_localnet && (aflag || !((addr & ~netmask) == 0 || (addr | netmask) == 0xffffffff)) #endif ) { if (!setjmp(getname_env)) { (void)setsignal(SIGALRM, nohostname); (void)alarm(20); hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET6); (void)alarm(0); if (hp) { char *dotp; p->name = strdup(hp->h_name); if (Nflag) { /* Remove domain qualifications */ dotp = strchr(p->name, '.'); if (dotp) *dotp = '\0'; } return (p->name); } } } cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf)); p->name = strdup(cp); return (p->name); } #endif /* INET6 */ static char hex[] = "0123456789abcdef"; /* Find the hash node that corresponds the ether address 'ep' */ static inline struct enamemem * lookup_emem(const u_char *ep) { register u_int i, j, k; struct enamemem *tp; k = (ep[0] << 8) | ep[1]; j = (ep[2] << 8) | ep[3]; i = (ep[4] << 8) | ep[5]; tp = &enametable[(i ^ j) & (HASHNAMESIZE-1)]; while (tp->e_nxt) if (tp->e_addr0 == i && tp->e_addr1 == j && tp->e_addr2 == k) return tp; else tp = tp->e_nxt; tp->e_addr0 = i; tp->e_addr1 = j; tp->e_addr2 = k; tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp)); if (tp->e_nxt == NULL) error("lookup_emem: calloc"); return tp; } /* * Find the hash node that corresponds to the bytestring 'bs' * with length 'nlen' */ static inline struct enamemem * lookup_bytestring(register const u_char *bs, const unsigned int nlen) { struct enamemem *tp; register u_int i, j, k; if (nlen >= 6) { k = (bs[0] << 8) | bs[1]; j = (bs[2] << 8) | bs[3]; i = (bs[4] << 8) | bs[5]; } else if (nlen >= 4) { k = (bs[0] << 8) | bs[1]; j = (bs[2] << 8) | bs[3]; i = 0; } else i = j = k = 0; tp = &bytestringtable[(i ^ j) & (HASHNAMESIZE-1)]; while (tp->e_nxt) if (tp->e_addr0 == i && tp->e_addr1 == j && tp->e_addr2 == k && memcmp((const char *)bs, (const char *)(tp->e_bs), nlen) == 0) return tp; else tp = tp->e_nxt; tp->e_addr0 = i; tp->e_addr1 = j; tp->e_addr2 = k; tp->e_bs = (u_char *) calloc(1, nlen + 1); memcpy(tp->e_bs, bs, nlen); tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp)); if (tp->e_nxt == NULL) error("lookup_bytestring: calloc"); return tp; } /* Find the hash node that corresponds the NSAP 'nsap' */ static inline struct enamemem * lookup_nsap(register const u_char *nsap) { register u_int i, j, k; unsigned int nlen = *nsap; struct enamemem *tp; const u_char *ensap = nsap + nlen - 6; if (nlen > 6) { k = (ensap[0] << 8) | ensap[1]; j = (ensap[2] << 8) | ensap[3]; i = (ensap[4] << 8) | ensap[5]; } else i = j = k = 0; tp = &nsaptable[(i ^ j) & (HASHNAMESIZE-1)]; while (tp->e_nxt) if (tp->e_addr0 == i && tp->e_addr1 == j && tp->e_addr2 == k && tp->e_nsap[0] == nlen && memcmp((const char *)&(nsap[1]), (char *)&(tp->e_nsap[1]), nlen) == 0) return tp; else tp = tp->e_nxt; tp->e_addr0 = i; tp->e_addr1 = j; tp->e_addr2 = k; tp->e_nsap = (u_char *)malloc(nlen + 1); if (tp->e_nsap == NULL) error("lookup_nsap: malloc"); memcpy((char *)tp->e_nsap, (const char *)nsap, nlen + 1); tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp)); if (tp->e_nxt == NULL) error("lookup_nsap: calloc"); return tp; } /* Find the hash node that corresponds the protoid 'pi'. */ static inline struct protoidmem * lookup_protoid(const u_char *pi) { register u_int i, j; struct protoidmem *tp; /* 5 octets won't be aligned */ i = (((pi[0] << 8) + pi[1]) << 8) + pi[2]; j = (pi[3] << 8) + pi[4]; /* XXX should be endian-insensitive, but do big-endian testing XXX */ tp = &protoidtable[(i ^ j) & (HASHNAMESIZE-1)]; while (tp->p_nxt) if (tp->p_oui == i && tp->p_proto == j) return tp; else tp = tp->p_nxt; tp->p_oui = i; tp->p_proto = j; tp->p_nxt = (struct protoidmem *)calloc(1, sizeof(*tp)); if (tp->p_nxt == NULL) error("lookup_protoid: calloc"); return tp; } const char * etheraddr_string(register const u_char *ep) { register u_int i, j; register char *cp; register struct enamemem *tp; char buf[sizeof("00:00:00:00:00:00")]; tp = lookup_emem(ep); if (tp->e_name) return (tp->e_name); #ifdef USE_ETHER_NTOHOST if (!nflag) { char buf[128]; if (ether_ntohost(buf, (const struct ether_addr *)ep) == 0) { tp->e_name = strdup(buf); return (tp->e_name); } } #endif cp = buf; if ((j = *ep >> 4) != 0) *cp++ = hex[j]; *cp++ = hex[*ep++ & 0xf]; for (i = 5; (int)--i >= 0;) { *cp++ = ':'; if ((j = *ep >> 4) != 0) *cp++ = hex[j]; *cp++ = hex[*ep++ & 0xf]; } *cp = '\0'; tp->e_name = strdup(buf); return (tp->e_name); } const char * linkaddr_string(const u_char *ep, const unsigned int len) { register u_int i, j; register char *cp; register struct enamemem *tp; if (len == 6) /* XXX not totally correct... */ return etheraddr_string(ep); tp = lookup_bytestring(ep, len); if (tp->e_name) return (tp->e_name); tp->e_name = cp = (char *)malloc(len*3); if (tp->e_name == NULL) error("linkaddr_string: malloc"); if ((j = *ep >> 4) != 0) *cp++ = hex[j]; *cp++ = hex[*ep++ & 0xf]; for (i = len-1; i > 0 ; --i) { *cp++ = ':'; if ((j = *ep >> 4) != 0) *cp++ = hex[j]; *cp++ = hex[*ep++ & 0xf]; } *cp = '\0'; return (tp->e_name); } const char * etherproto_string(u_short port) { register char *cp; register struct hnamemem *tp; register u_int32_t i = port; char buf[sizeof("0000")]; for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); tp->addr = i; tp->nxt = newhnamemem(); cp = buf; NTOHS(port); *cp++ = hex[port >> 12 & 0xf]; *cp++ = hex[port >> 8 & 0xf]; *cp++ = hex[port >> 4 & 0xf]; *cp++ = hex[port & 0xf]; *cp++ = '\0'; tp->name = strdup(buf); return (tp->name); } const char * protoid_string(register const u_char *pi) { register u_int i, j; register char *cp; register struct protoidmem *tp; char buf[sizeof("00:00:00:00:00")]; tp = lookup_protoid(pi); if (tp->p_name) return tp->p_name; cp = buf; if ((j = *pi >> 4) != 0) *cp++ = hex[j]; *cp++ = hex[*pi++ & 0xf]; for (i = 4; (int)--i >= 0;) { *cp++ = ':'; if ((j = *pi >> 4) != 0) *cp++ = hex[j]; *cp++ = hex[*pi++ & 0xf]; } *cp = '\0'; tp->p_name = strdup(buf); return (tp->p_name); } const char * llcsap_string(u_char sap) { register struct hnamemem *tp; register u_int32_t i = sap; char buf[sizeof("sap 00")]; for (tp = &llcsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); tp->addr = i; tp->nxt = newhnamemem(); snprintf(buf, sizeof(buf), "sap %02x", sap & 0xff); tp->name = strdup(buf); return (tp->name); } const char * isonsap_string(const u_char *nsap) { register u_int i, nlen = nsap[0]; register char *cp; register struct enamemem *tp; tp = lookup_nsap(nsap); if (tp->e_name) return tp->e_name; tp->e_name = cp = (char *)malloc(nlen * 2 + 2); if (cp == NULL) error("isonsap_string: malloc"); nsap++; *cp++ = '/'; for (i = nlen; (int)--i >= 0;) { *cp++ = hex[*nsap >> 4]; *cp++ = hex[*nsap++ & 0xf]; } *cp = '\0'; return (tp->e_name); } const char * tcpport_string(u_short port) { register struct hnamemem *tp; register u_int32_t i = port; char buf[sizeof("00000")]; for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); tp->addr = i; tp->nxt = newhnamemem(); (void)snprintf(buf, sizeof(buf), "%u", i); tp->name = strdup(buf); return (tp->name); } const char * udpport_string(register u_short port) { register struct hnamemem *tp; register u_int32_t i = port; char buf[sizeof("00000")]; for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); tp->addr = i; tp->nxt = newhnamemem(); (void)snprintf(buf, sizeof(buf), "%u", i); tp->name = strdup(buf); return (tp->name); } static void init_servarray(void) { struct servent *sv; register struct hnamemem *table; register int i; char buf[sizeof("0000000000")]; while ((sv = getservent()) != NULL) { int port = ntohs(sv->s_port); i = port & (HASHNAMESIZE-1); if (strcmp(sv->s_proto, "tcp") == 0) table = &tporttable[i]; else if (strcmp(sv->s_proto, "udp") == 0) table = &uporttable[i]; else continue; while (table->name) table = table->nxt; if (nflag) { (void)snprintf(buf, sizeof(buf), "%d", port); table->name = strdup(buf); } else table->name = strdup(sv->s_name); table->addr = port; table->nxt = newhnamemem(); } endservent(); } /*XXX from libbpfc.a */ extern struct eproto { char *s; u_short p; } eproto_db[]; static void init_eprotoarray(void) { register int i; register struct hnamemem *table; for (i = 0; eproto_db[i].s; i++) { int j = ntohs(eproto_db[i].p) & (HASHNAMESIZE-1); table = &eprototable[j]; while (table->name) table = table->nxt; table->name = eproto_db[i].s; table->addr = ntohs(eproto_db[i].p); table->nxt = newhnamemem(); } } static struct protoidlist { const u_char protoid[5]; const char *name; } protoidlist[] = { {{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" }, {{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" }, {{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" }, {{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" }, {{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" }, {{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } }; /* * SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet * types. */ static void init_protoidarray(void) { register int i; register struct protoidmem *tp; struct protoidlist *pl; u_char protoid[5]; protoid[0] = 0; protoid[1] = 0; protoid[2] = 0; for (i = 0; eproto_db[i].s; i++) { u_short etype = htons(eproto_db[i].p); memcpy((char *)&protoid[3], (char *)&etype, 2); tp = lookup_protoid(protoid); tp->p_name = strdup(eproto_db[i].s); } /* Hardwire some SNAP proto ID names */ for (pl = protoidlist; pl->name != NULL; ++pl) { tp = lookup_protoid(pl->protoid); /* Don't override existing name */ if (tp->p_name != NULL) continue; tp->p_name = pl->name; } } static struct etherlist { const u_char addr[6]; const char *name; } etherlist[] = { {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" }, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } }; /* * Initialize the ethers hash table. We take two different approaches * depending on whether or not the system provides the ethers name * service. If it does, we just wire in a few names at startup, * and etheraddr_string() fills in the table on demand. If it doesn't, * then we suck in the entire /etc/ethers file at startup. The idea * is that parsing the local file will be fast, but spinning through * all the ethers entries via NIS & next_etherent might be very slow. * * XXX pcap_next_etherent doesn't belong in the pcap interface, but * since the pcap module already does name-to-address translation, * it's already does most of the work for the ethernet address-to-name * translation, so we just pcap_next_etherent as a convenience. */ static void init_etherarray(void) { register struct etherlist *el; register struct enamemem *tp; #ifdef USE_ETHER_NTOHOST char name[256]; #else register struct pcap_etherent *ep; register FILE *fp; /* Suck in entire ethers file */ fp = fopen(PCAP_ETHERS_FILE, "r"); if (fp != NULL) { while ((ep = pcap_next_etherent(fp)) != NULL) { tp = lookup_emem(ep->addr); tp->e_name = strdup(ep->name); } (void)fclose(fp); } #endif /* Hardwire some ethernet names */ for (el = etherlist; el->name != NULL; ++el) { tp = lookup_emem(el->addr); /* Don't override existing name */ if (tp->e_name != NULL) continue; #ifdef USE_ETHER_NTOHOST /* Use yp/nis version of name if available */ if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) { tp->e_name = strdup(name); continue; } #endif tp->e_name = el->name; } } static struct tok llcsap_db[] = { { LLCSAP_NULL, "null" }, { LLCSAP_8021B_I, "802.1b-gsap" }, { LLCSAP_8021B_G, "802.1b-isap" }, { LLCSAP_IP, "ip-sap" }, { LLCSAP_PROWAYNM, "proway-nm" }, { LLCSAP_8021D, "802.1d" }, { LLCSAP_RS511, "eia-rs511" }, { LLCSAP_ISO8208, "x.25/llc2" }, { LLCSAP_PROWAY, "proway" }, { LLCSAP_SNAP, "snap" }, { LLCSAP_IPX, "IPX" }, { LLCSAP_NETBEUI, "netbeui" }, { LLCSAP_ISONS, "iso-clns" }, { LLCSAP_GLOBAL, "global" }, { 0, NULL } }; static void init_llcsaparray(void) { register int i; register struct hnamemem *table; for (i = 0; llcsap_db[i].s != NULL; i++) { table = &llcsaptable[llcsap_db[i].v]; while (table->name) table = table->nxt; table->name = llcsap_db[i].s; table->addr = llcsap_db[i].v; table->nxt = newhnamemem(); } } /* * Initialize the address to name translation machinery. We map all * non-local IP addresses to numeric addresses if fflag is true (i.e., * to prevent blocking on the nameserver). localnet is the IP address * of the local network. mask is its subnet mask. */ void init_addrtoname(u_int32_t localnet, u_int32_t mask) { netmask = mask; if (fflag) { f_localnet = localnet; f_netmask = mask; } if (nflag) /* * Simplest way to suppress names. */ return; init_etherarray(); init_servarray(); init_eprotoarray(); init_llcsaparray(); init_protoidarray(); } const char * dnaddr_string(u_short dnaddr) { register struct hnamemem *tp; for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != 0; tp = tp->nxt) if (tp->addr == dnaddr) return (tp->name); tp->addr = dnaddr; tp->nxt = newhnamemem(); if (nflag) tp->name = dnnum_string(dnaddr); else tp->name = dnname_string(dnaddr); return(tp->name); } /* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */ struct hnamemem * newhnamemem(void) { register struct hnamemem *p; static struct hnamemem *ptr = NULL; static u_int num = 0; if (num <= 0) { num = 64; ptr = (struct hnamemem *)calloc(num, sizeof (*ptr)); if (ptr == NULL) error("newhnamemem: calloc"); } --num; p = ptr++; return (p); } #ifdef INET6 /* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */ struct h6namemem * newh6namemem(void) { register struct h6namemem *p; static struct h6namemem *ptr = NULL; static u_int num = 0; if (num <= 0) { num = 64; ptr = (struct h6namemem *)calloc(num, sizeof (*ptr)); if (ptr == NULL) error("newh6namemem: calloc"); } --num; p = ptr++; return (p); } #endif /* INET6 */ tcpdump-3.7.2/addrtoname.h0100644000076500000240000000377307351470737014656 0ustar fennerstaff/* * Copyright (c) 1990, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.18 2001/09/17 21:57:51 fenner Exp $ (LBL) */ /* Name to address translation routines. */ extern const char *linkaddr_string(const u_char *, const unsigned int); extern const char *etheraddr_string(const u_char *); extern const char *etherproto_string(u_short); extern const char *tcpport_string(u_short); extern const char *udpport_string(u_short); extern const char *getname(const u_char *); #ifdef INET6 extern const char *getname6(const u_char *); #endif extern const char *intoa(u_int32_t); extern void init_addrtoname(u_int32_t, u_int32_t); extern struct hnamemem *newhnamemem(void); #ifdef INET6 extern struct h6namemem *newh6namemem(void); #endif #define ipaddr_string(p) getname((const u_char *)(p)) #ifdef INET6 #define ip6addr_string(p) getname6((const u_char *)(p)) #endif tcpdump-3.7.2/ah.h0100644000076500000240000000454507167334102013114 0ustar fennerstaff/* $NetBSD: ah.h,v 1.12 2000/07/23 05:23:04 itojun Exp $ */ /* $KAME: ah.h,v 1.12 2000/07/20 17:41:01 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * RFC1826/2402 authentication header. */ #ifndef _NETINET6_AH_H_ #define _NETINET6_AH_H_ struct ah { u_int8_t ah_nxt; /* Next Header */ u_int8_t ah_len; /* Length of data, in 32bit */ u_int16_t ah_reserve; /* Reserved for future use */ u_int32_t ah_spi; /* Security parameter index */ /* variable size, 32bit bound*/ /* Authentication data */ }; struct newah { u_int8_t ah_nxt; /* Next Header */ u_int8_t ah_len; /* Length of data + 1, in 32bit */ u_int16_t ah_reserve; /* Reserved for future use */ u_int32_t ah_spi; /* Security parameter index */ u_int32_t ah_seq; /* Sequence number field */ /* variable size, 32bit bound*/ /* Authentication data */ }; #endif /*_NETINET6_AH_H_*/ tcpdump-3.7.2/appletalk.h0100644000076500000240000001016007166245176014502 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX). * * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.13 2000/10/03 02:54:54 itojun Exp $ (LBL) */ struct LAP { u_int8_t dst; u_int8_t src; u_int8_t type; }; #define lapShortDDP 1 /* short DDP type */ #define lapDDP 2 /* DDP type */ #define lapKLAP 'K' /* Kinetics KLAP type */ /* Datagram Delivery Protocol */ struct atDDP { u_int16_t length; u_int16_t checksum; u_int16_t dstNet; u_int16_t srcNet; u_int8_t dstNode; u_int8_t srcNode; u_int8_t dstSkt; u_int8_t srcSkt; u_int8_t type; }; struct atShortDDP { u_int16_t length; u_int8_t dstSkt; u_int8_t srcSkt; u_int8_t type; }; #define ddpMaxWKS 0x7F #define ddpMaxData 586 #define ddpLengthMask 0x3FF #define ddpHopShift 10 #define ddpSize 13 /* size of DDP header (avoid struct padding) */ #define ddpSSize 5 #define ddpWKS 128 /* boundary of DDP well known sockets */ #define ddpRTMP 1 /* RTMP type */ #define ddpRTMPrequest 5 /* RTMP request type */ #define ddpNBP 2 /* NBP type */ #define ddpATP 3 /* ATP type */ #define ddpECHO 4 /* ECHO type */ #define ddpIP 22 /* IP type */ #define ddpARP 23 /* ARP type */ #define ddpKLAP 0x4b /* Kinetics KLAP type */ /* AppleTalk Transaction Protocol */ struct atATP { u_int8_t control; u_int8_t bitmap; u_int16_t transID; int32_t userData; }; #define atpReqCode 0x40 #define atpRspCode 0x80 #define atpRelCode 0xC0 #define atpXO 0x20 #define atpEOM 0x10 #define atpSTS 0x08 #define atpFlagMask 0x3F #define atpControlMask 0xF8 #define atpMaxNum 8 #define atpMaxData 578 /* AppleTalk Echo Protocol */ struct atEcho { u_int8_t echoFunction; u_int8_t *echoData; }; #define echoSkt 4 /* the echoer socket */ #define echoSize 1 /* size of echo header */ #define echoRequest 1 /* echo request */ #define echoReply 2 /* echo request */ /* Name Binding Protocol */ struct atNBP { u_int8_t control; u_int8_t id; }; struct atNBPtuple { u_int16_t net; u_int8_t node; u_int8_t skt; u_int8_t enumerator; }; #define nbpBrRq 0x10 #define nbpLkUp 0x20 #define nbpLkUpReply 0x30 #define nbpNIS 2 #define nbpTupleMax 15 #define nbpHeaderSize 2 #define nbpTupleSize 5 #define nbpSkt 2 /* NIS */ /* Routing Table Maint. Protocol */ #define rtmpSkt 1 /* number of RTMP socket */ #define rtmpSize 4 /* minimum size */ #define rtmpTupleSize 3 /* Zone Information Protocol */ struct zipHeader { u_int8_t command; u_int8_t netcount; }; #define zipHeaderSize 2 #define zipQuery 1 #define zipReply 2 #define zipTakedown 3 #define zipBringup 4 #define ddpZIP 6 #define zipSkt 6 #define GetMyZone 7 #define GetZoneList 8 /* * UDP port range used for ddp-in-udp encapsulation is 16512-16639 * for client sockets (128-255) and 200-327 for server sockets * (0-127). We also try to recognize the pre-April 88 server * socket range of 768-895. */ #define atalk_port(p) \ (((unsigned)((p) - 16512) < 128) || \ ((unsigned)((p) - 200) < 128) || \ ((unsigned)((p) - 768) < 128)) tcpdump-3.7.2/arcnet.h0100644000076500000240000000613307267000466013777 0ustar fennerstaff/* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#) $Id: arcnet.h,v 1.1 2001/04/17 08:39:18 guy Exp $ (LBL) * * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp */ /* * Structure of a 2.5MB/s Arcnet header. * as given to interface code. */ struct arc_header { u_int8_t arc_shost; u_int8_t arc_dhost; u_int8_t arc_type; /* * only present for newstyle encoding with LL fragmentation. * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead. */ u_int8_t arc_flag; u_int16_t arc_seqid; /* * only present in exception packets (arc_flag == 0xff) */ u_int8_t arc_type2; /* same as arc_type */ u_int8_t arc_flag2; /* real flag value */ u_int16_t arc_seqid2; /* real seqid value */ } __attribute__((__packed__)); #define ARC_HDRLEN 3 #define ARC_HDRNEWLEN 6 #define ARC_HDRNEWLEN_EXC 10 /* RFC 1051 */ #define ARCTYPE_IP_OLD 240 /* IP protocol */ #define ARCTYPE_ARP_OLD 241 /* address resolution protocol */ /* RFC 1201 */ #define ARCTYPE_IP 212 /* IP protocol */ #define ARCTYPE_ARP 213 /* address resolution protocol */ #define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */ #define ARCTYPE_ATALK 221 /* Appletalk */ #define ARCTYPE_BANIAN 247 /* Banyan Vines */ #define ARCTYPE_IPX 250 /* Novell IPX */ #define ARCTYPE_INET6 0xc4 /* IPng */ #define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */ tcpdump-3.7.2/atime.awk0100644000076500000240000000102106777230375014155 0ustar fennerstaff$6 ~ /^ack/ && $5 !~ /[SFR]/ { # given a tcpdump ftp trace, output one line for each ack # in the form # # where is the time packet was acked (in seconds with # zero at time of first packet) and is the tcp sequence # number of the ack divided by 1024 (i.e., Kbytes acked). # # convert time to seconds n = split ($1,t,":") tim = t[1]*3600 + t[2]*60 + t[3] if (! tzero) { tzero = tim OFS = "\t" } # get packet sequence number printf "%7.2f\t%g\n", tim-tzero, $7/1024 } tcpdump-3.7.2/bootp.h0100644000076500000240000001722507226540041013643 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.11 2001/01/09 07:39:13 fenner Exp $ (LBL) */ /* * Bootstrap Protocol (BOOTP). RFC951 and RFC1048. * * This file specifies the "implementation-independent" BOOTP protocol * information which is common to both client and server. * * Copyright 1988 by Carnegie Mellon. * * Permission to use, copy, modify, and distribute this program for any * purpose and without fee is hereby granted, provided that this copyright * and permission notice appear on all copies and supporting documentation, * the name of Carnegie Mellon not be used in advertising or publicity * pertaining to distribution of the program without specific prior * permission, and notice be given in supporting documentation that copying * and distribution is by permission of Carnegie Mellon and Stanford * University. Carnegie Mellon makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ struct bootp { u_int8_t bp_op; /* packet opcode type */ u_int8_t bp_htype; /* hardware addr type */ u_int8_t bp_hlen; /* hardware addr length */ u_int8_t bp_hops; /* gateway hops */ u_int32_t bp_xid; /* transaction ID */ u_int16_t bp_secs; /* seconds since boot began */ u_int16_t bp_flags; /* flags: 0x8000 is broadcast */ struct in_addr bp_ciaddr; /* client IP address */ struct in_addr bp_yiaddr; /* 'your' IP address */ struct in_addr bp_siaddr; /* server IP address */ struct in_addr bp_giaddr; /* gateway IP address */ u_int8_t bp_chaddr[16]; /* client hardware address */ u_int8_t bp_sname[64]; /* server host name */ u_int8_t bp_file[128]; /* boot file name */ u_int8_t bp_vend[64]; /* vendor-specific area */ }; /* * UDP port numbers, server and client. */ #define IPPORT_BOOTPS 67 #define IPPORT_BOOTPC 68 #define BOOTREPLY 2 #define BOOTREQUEST 1 /* * Vendor magic cookie (v_magic) for CMU */ #define VM_CMU "CMU" /* * Vendor magic cookie (v_magic) for RFC1048 */ #define VM_RFC1048 { 99, 130, 83, 99 } /* * RFC1048 tag values used to specify what information is being supplied in * the vendor field of the packet. */ #define TAG_PAD ((u_int8_t) 0) #define TAG_SUBNET_MASK ((u_int8_t) 1) #define TAG_TIME_OFFSET ((u_int8_t) 2) #define TAG_GATEWAY ((u_int8_t) 3) #define TAG_TIME_SERVER ((u_int8_t) 4) #define TAG_NAME_SERVER ((u_int8_t) 5) #define TAG_DOMAIN_SERVER ((u_int8_t) 6) #define TAG_LOG_SERVER ((u_int8_t) 7) #define TAG_COOKIE_SERVER ((u_int8_t) 8) #define TAG_LPR_SERVER ((u_int8_t) 9) #define TAG_IMPRESS_SERVER ((u_int8_t) 10) #define TAG_RLP_SERVER ((u_int8_t) 11) #define TAG_HOSTNAME ((u_int8_t) 12) #define TAG_BOOTSIZE ((u_int8_t) 13) #define TAG_END ((u_int8_t) 255) /* RFC1497 tags */ #define TAG_DUMPPATH ((u_int8_t) 14) #define TAG_DOMAINNAME ((u_int8_t) 15) #define TAG_SWAP_SERVER ((u_int8_t) 16) #define TAG_ROOTPATH ((u_int8_t) 17) #define TAG_EXTPATH ((u_int8_t) 18) /* RFC2132 */ #define TAG_IP_FORWARD ((u_int8_t) 19) #define TAG_NL_SRCRT ((u_int8_t) 20) #define TAG_PFILTERS ((u_int8_t) 21) #define TAG_REASS_SIZE ((u_int8_t) 22) #define TAG_DEF_TTL ((u_int8_t) 23) #define TAG_MTU_TIMEOUT ((u_int8_t) 24) #define TAG_MTU_TABLE ((u_int8_t) 25) #define TAG_INT_MTU ((u_int8_t) 26) #define TAG_LOCAL_SUBNETS ((u_int8_t) 27) #define TAG_BROAD_ADDR ((u_int8_t) 28) #define TAG_DO_MASK_DISC ((u_int8_t) 29) #define TAG_SUPPLY_MASK ((u_int8_t) 30) #define TAG_DO_RDISC ((u_int8_t) 31) #define TAG_RTR_SOL_ADDR ((u_int8_t) 32) #define TAG_STATIC_ROUTE ((u_int8_t) 33) #define TAG_USE_TRAILERS ((u_int8_t) 34) #define TAG_ARP_TIMEOUT ((u_int8_t) 35) #define TAG_ETH_ENCAP ((u_int8_t) 36) #define TAG_TCP_TTL ((u_int8_t) 37) #define TAG_TCP_KEEPALIVE ((u_int8_t) 38) #define TAG_KEEPALIVE_GO ((u_int8_t) 39) #define TAG_NIS_DOMAIN ((u_int8_t) 40) #define TAG_NIS_SERVERS ((u_int8_t) 41) #define TAG_NTP_SERVERS ((u_int8_t) 42) #define TAG_VENDOR_OPTS ((u_int8_t) 43) #define TAG_NETBIOS_NS ((u_int8_t) 44) #define TAG_NETBIOS_DDS ((u_int8_t) 45) #define TAG_NETBIOS_NODE ((u_int8_t) 46) #define TAG_NETBIOS_SCOPE ((u_int8_t) 47) #define TAG_XWIN_FS ((u_int8_t) 48) #define TAG_XWIN_DM ((u_int8_t) 49) #define TAG_NIS_P_DOMAIN ((u_int8_t) 64) #define TAG_NIS_P_SERVERS ((u_int8_t) 65) #define TAG_MOBILE_HOME ((u_int8_t) 68) #define TAG_SMPT_SERVER ((u_int8_t) 69) #define TAG_POP3_SERVER ((u_int8_t) 70) #define TAG_NNTP_SERVER ((u_int8_t) 71) #define TAG_WWW_SERVER ((u_int8_t) 72) #define TAG_FINGER_SERVER ((u_int8_t) 73) #define TAG_IRC_SERVER ((u_int8_t) 74) #define TAG_STREETTALK_SRVR ((u_int8_t) 75) #define TAG_STREETTALK_STDA ((u_int8_t) 76) /* DHCP options */ #define TAG_REQUESTED_IP ((u_int8_t) 50) #define TAG_IP_LEASE ((u_int8_t) 51) #define TAG_OPT_OVERLOAD ((u_int8_t) 52) #define TAG_TFTP_SERVER ((u_int8_t) 66) #define TAG_BOOTFILENAME ((u_int8_t) 67) #define TAG_DHCP_MESSAGE ((u_int8_t) 53) #define TAG_SERVER_ID ((u_int8_t) 54) #define TAG_PARM_REQUEST ((u_int8_t) 55) #define TAG_MESSAGE ((u_int8_t) 56) #define TAG_MAX_MSG_SIZE ((u_int8_t) 57) #define TAG_RENEWAL_TIME ((u_int8_t) 58) #define TAG_REBIND_TIME ((u_int8_t) 59) #define TAG_VENDOR_CLASS ((u_int8_t) 60) #define TAG_CLIENT_ID ((u_int8_t) 61) /* RFC 2241 */ #define TAG_NDS_SERVERS ((u_int8_t) 85) #define TAG_NDS_TREE_NAME ((u_int8_t) 86) #define TAG_NDS_CONTEXT ((u_int8_t) 87) /* RFC 2242 */ #define TAG_NDS_IPDOMAIN ((u_int8_t) 62) #define TAG_NDS_IPINFO ((u_int8_t) 63) /* RFC 2485 */ #define TAG_OPEN_GROUP_UAP ((u_int8_t) 98) /* RFC 2563 */ #define TAG_DISABLE_AUTOCONF ((u_int8_t) 116) /* RFC 2610 */ #define TAG_SLP_DA ((u_int8_t) 78) #define TAG_SLP_SCOPE ((u_int8_t) 79) /* RFC 2937 */ #define TAG_NS_SEARCH ((u_int8_t) 117) /* RFC 3011 */ #define TAG_IP4_SUBNET_SELECT ((u_int8_t) 118) /* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */ #define TAG_USER_CLASS ((u_int8_t) 77) #define TAG_SLP_NAMING_AUTH ((u_int8_t) 80) #define TAG_CLIENT_FQDN ((u_int8_t) 81) #define TAG_AGENT_CIRCUIT ((u_int8_t) 82) #define TAG_AGENT_REMOTE ((u_int8_t) 83) #define TAG_AGENT_MASK ((u_int8_t) 84) #define TAG_TZ_STRING ((u_int8_t) 88) #define TAG_FQDN_OPTION ((u_int8_t) 89) #define TAG_AUTH ((u_int8_t) 90) #define TAG_VINES_SERVERS ((u_int8_t) 91) #define TAG_SERVER_RANK ((u_int8_t) 92) #define TAG_CLIENT_ARCH ((u_int8_t) 93) #define TAG_CLIENT_NDI ((u_int8_t) 94) #define TAG_CLIENT_GUID ((u_int8_t) 97) #define TAG_LDAP_URL ((u_int8_t) 95) #define TAG_6OVER4 ((u_int8_t) 96) #define TAG_PRINTER_NAME ((u_int8_t) 100) #define TAG_MDHCP_SERVER ((u_int8_t) 101) #define TAG_IPX_COMPAT ((u_int8_t) 110) #define TAG_NETINFO_PARENT ((u_int8_t) 112) #define TAG_NETINFO_PARENT_TAG ((u_int8_t) 113) #define TAG_URL ((u_int8_t) 114) #define TAG_FAILOVER ((u_int8_t) 115) #define TAG_EXTENDED_REQUEST ((u_int8_t) 126) #define TAG_EXTENDED_OPTION ((u_int8_t) 127) /* DHCP Message types (values for TAG_DHCP_MESSAGE option) */ #define DHCPDISCOVER 1 #define DHCPOFFER 2 #define DHCPREQUEST 3 #define DHCPDECLINE 4 #define DHCPACK 5 #define DHCPNAK 6 #define DHCPRELEASE 7 #define DHCPINFORM 8 /* * "vendor" data permitted for CMU bootp clients. */ struct cmu_vend { u_int8_t v_magic[4]; /* magic number */ u_int32_t v_flags; /* flags/opcodes, etc. */ struct in_addr v_smask; /* Subnet mask */ struct in_addr v_dgate; /* Default gateway */ struct in_addr v_dns1, v_dns2; /* Domain name servers */ struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */ struct in_addr v_ts1, v_ts2; /* Time servers */ u_int8_t v_unused[24]; /* currently unused */ }; /* v_flags values */ #define VF_SMASK 1 /* Subnet mask field contains valid data */ tcpdump-3.7.2/bpf_dump.c0100644000076500000240000000410407214317745014311 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.13 2000/12/09 02:58:45 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "interface.h" void bpf_dump(struct bpf_program *p, int option) { struct bpf_insn *insn; int i; int n = p->bf_len; insn = p->bf_insns; if (option > 2) { printf("%d\n", n); for (i = 0; i < n; ++insn, ++i) { printf("%u %u %u %u\n", insn->code, insn->jt, insn->jf, insn->k); } return ; } if (option > 1) { for (i = 0; i < n; ++insn, ++i) printf("{ 0x%x, %d, %d, 0x%08x },\n", insn->code, insn->jt, insn->jf, insn->k); return; } for (i = 0; i < n; ++insn, ++i) { #ifdef BDEBUG extern int bids[]; printf(bids[i] > 0 ? "[%02d]" : " -- ", bids[i] - 1); #endif puts(bpf_image(insn, i)); } } tcpdump-3.7.2/CHANGES0100644000076500000240000005777707627064040013367 0ustar fennerstaff$Header: /tcpdump/master/tcpdump/CHANGES,v 1.81.2.1 2003/02/26 07:08:58 fenner Exp $ Tuesday, February 25, 2003. fenner@research.att.com. 3.7.2 release Fixed infinite loop when parsing malformed isakmp packets. (reported by iDefense; already fixed in CVS) Fixed infinite loop when parsing malformed BGP packets. Fixed buffer overflow with certain malformed NFS packets. Pretty-print unprintable network names in 802.11 printer. Handle truncated nbp (appletalk) packets. Updated DHCPv6 printer to match draft-ietf-dhc-dhcpv6-22.txt Print IP protocol name even if we don't have a printer for it. Print IP protocol name or number for fragments. Print the whole MPLS label stack, not just the top label. Print request header and file handle for NFS v3 FSINFO and PATHCONF requests. Fix NFS packet truncation checks. Handle "old" DR-Priority and Bidir-Capable PIM HELLO options. Handle unknown RADIUS attributes properly. Fix an ASN.1 parsing error that would cause e.g. the OID 2.100.3 to be misrepresented as 4.20.3 . Monday, January 21, 2002. mcr@sandelman.ottawa.on.ca. Summary for 3.7 release see http://www.tcpdump.org/cvs-log/2002-01-21.10:16:48.html for commit log. keyword "ipx" added. Better OSI/802.2 support on Linux. IEEE 802.11 support, from clenahan@fortresstech.com, achirica@ttd.net. LLC SAP support for FDDI/token ring/RFC-1483 style ATM BXXP protocol was replaced by the BEEP protocol; improvements to SNAP demux. Changes to "any" interface documentation. Documentation on pcap_stats() counters. Fix a memory leak found by Miklos Szeredi - pcap_ether_aton(). Added MPLS encapsulation decoding per RFC3032. DNS dissector handles TKEY, TSIG and IXFR. adaptive SLIP interface patch from Igor Khristophorov SMB printing has much improved bounds checks OUI 0x0000f8 decoded as encapsulated ethernet for Cisco-custom bridging Zephyr support, from Nickolai Zeldovich . Solaris - devices with digits in them. Stefan Hudson IPX socket 0x85be is for Cisco EIGRP over IPX. Improvements to fragmented ESP handling. SCTP support from Armando L. Caro Jr. Linux ARPHDR_ATM support fixed. Added a "netbeui" keyword, which selects NetBEUI packets. IPv6 ND improvements, MobileIP dissector, 2292bis-02 for RA option. Handle ARPHDR_HDLC from Marcus Felipe Pereira . Handle IPX socket 0x553 -> NetBIOS-over-IPX socket, "nwlink-dgm" Better Linux libc5 compat. BIND9 lwres dissector added. MIPS and SPARC get strict alignment macros (affects print-bgp.c) Apple LocalTalk LINKTYPE_ reserved. New time stamp formats documented. DHCP6 updated to draft-22.txt spec. ICMP types/codes now accept symbolic names. Add SIGINFO handler from LBL encrypted CIPE tunnels in IRIX, from Franz Schaefer . now we are -Wstrict-prototype clean. NetBSD DLT_PPP_ETHER; adapted from Martin Husemann . PPPoE dissector cleaned up. Support for LocalTalk hardware, from Uns Lider . In dissector, now the caller prints the IP addresses rather than proto. cjclark@alum.mit.edu: print the IP proto for non-initial fragments. LLC frames with a DSAP and LSAP of 0xe0 are IPX frames. Linux cooked frames with a type value of LINUX_SLL_P_802_3 are IPX. captures on the "any" device won't be done in promiscuous mode Token Ring support on DLPI - Onno van der Linden ARCNet support, from NetBSD. HSRP dissector, from Julian Cowley . Handle (GRE-encapsulated) PPTP added -C option to rotate save file every optarg * 1,000,000 bytes. support for "vrrp" name - NetBSD, by Klaus Klein . PPTP support, from Motonori Shindo . IS-IS over PPP support, from Hannes Gredler . CNFP support for IPv6,format. Harry Raaymakers . ESP printing updated to RFC2406. HP-UX can now handle large number of PPAs. MSDP printer added. L2TP dissector improvements from Motonori Shindo. Tuesday January 9, 2001. mcr@sandelman.ottawa.on.ca. Summary for 3.6 release Cleaned up documentation. Promisc mode fixes for Linux IPsec changes/cleanups. Alignment fixes for picky architectures Removed dependency on native headers for packet dissectors. Removed Linux specific headers that were shipped libpcap changes provide for exchanging capture files between systems. Save files now have well known PACKET_ values instead of depending upon system dependant mappings of DLT_* types. Support for computing/checking IP and UDP/TCP checksums. Updated autoconf stock files. IPv6 improvements: dhcp (draft-15), mobile-ip6, ppp, ospf6, Added dissector support for: ISOCLNS, Token Ring, IGMPv3, bxxp, timed, vrrp, radius, chdlc, cnfp, cdp, IEEE802.1d, raw-AppleTalk Added filtering support for: VLANs, ESIS, ISIS Improvements to: print-telnet, IPTalk, bootp/dhcp, ECN, PPP, L2TP, PPPoE HP-UX 11.0 -- find the right dlpi device. Solaris 8 - IPv6 works Linux - Added support for an "any" device to capture on all interfaces Security fixes: buffer overrun audit done. Strcpy replaced with strlcpy, sprintf replaced with snprintf. Look for lex problems, and warn about them. v3.5 Fri Jan 28 18:00:00 PST 2000 Bill Fenner - switch to config.h for autoconf - unify RCSID strings - Updated PIMv1, PIMv2, DVMRP, IGMP parsers, add Cisco Auto-RP parser - Really fix the RIP printer - Fix MAC address -> name translation. - some -Wall -Wformat fixes - update makemib to parse much of SMIv2 - Print TCP sequence # with -vv even if you normally wouldn't - Print as much of IP/TCP/UDP headers as possible even if truncated. itojun@iijlab.net - -X will make a ascii dump. from netbsd. - telnet command sequence decoder (ff xx xx). from netbsd. - print-bgp.c: improve options printing. ugly code exists for unaligned option parsing (need some fix). - const poisoning in SMB decoder. - -Wall -Werror clean checks. - bring in KAME IPv6/IPsec decoding code. Assar Westerlund - SNMPv2 and SNMPv3 printer - If compiled with libsmi, tcpdump can load MIBs on the fly to decode SNMP packets. - Incorporate NFS parsing code from NetBSD. Adds support for nfsv3. - portability fixes - permit building in different directories. Ken Hornstein - bring in code at /afs/transarc.com/public/afs-contrib/tools/tcpdump for parsing AFS3 packets Andrew Tridgell - SMB printing code Love - print-rx.c: add code for printing MakeDir and StoreStatus. Also change date format to the right one. Michael C. Richardson - Created tcpdump.org repository v3.4 Sat Jul 25 12:40:55 PDT 1998 - Hardwire Linux slip support since it's too hard to detect. - Redo configuration of "network" libraries (-lsocket and -lnsl) to deal with IRIX. Thanks to John Hawkinson (jhawk@mit.edu) - Added -a which tries to translate network and broadcast addresses to names. Suggested by Rob van Nieuwkerk (robn@verdi.et.tudelft.nl) - Added a configure option to disable gcc. - Added a "raw" packet printer. - Not having an interface address is no longer fatal. Requested by John Hawkinson. - Rework signal setup to accommodate Linux. - OSPF truncation check fix. Also display the type of OSPF packets using MD5 authentication. Thanks to Brian Wellington (bwelling@tis.com) - Fix truncation check bugs in the Kerberos printer. Reported by Ezra Peisach (epeisach@mit.edu) - Don't catch SIGHUP when invoked with nohup(1). Thanks to Dave Plonka (plonka@mfa.com) - Specify full install target as a way of detecting if install directory does not exist. Thanks to Dave Plonka. - Bit-swap FDDI addresses for BSD/OS too. Thanks to Paul Vixie (paul@vix.com) - Fix off-by-one bug when testing size of ethernet packets. Thanks to Marty Leisner (leisner@sdsp.mc.xerox.com) - Add a local autoconf macro to check for routines in libraries; the autoconf version is broken (it only puts the library name in the cache variable name). Thanks to John Hawkinson. - Add a local autoconf macro to check for types; the autoconf version is broken (it uses grep instead of actually compiling a code fragment). - Modified to support the new BSD/OS 2.1 PPP and SLIP link layer header formats. - Extend OSF ip header workaround to versions 1 and 2. - Fix some signed problems in the nfs printer. As reported by David Sacerdote (davids@silence.secnet.com) - Detect group wheel and use it as the default since BSD/OS' install can't hack numeric groups. Reported by David Sacerdote. - AIX needs special loader options. Thanks to Jonathan I. Kamens (jik@cam.ov.com) - Fixed the nfs printer to print port numbers in decimal. Thanks to Kent Vander Velden (graphix@iastate.edu) - Find installed libpcap in /usr/local/lib when not using gcc. - Disallow network masks with non-network bits set. - Attempt to detect "egcs" versions of gcc. - Add missing closing double quotes when displaying bootp strings. Reported by Viet-Trung Luu (vluu@picard.math.uwaterloo.ca) v3.3 Sat Nov 30 20:56:27 PST 1996 - Added Linux support. - GRE encapsulated packet printer thanks to John Hawkinson (jhawk@mit.edu) - Rewrite gmt2local() to avoid problematic os dependencies. - Suppress nfs truncation message on errors. - Add missing m4 quoting in AC_LBL_UNALIGNED_ACCESS autoconf macro. Reported by Joachim Ott (ott@ardala.han.de) - Enable "ip_hl vs. ip_vhl" workaround for OSF4 too. - Print arp hardware type in host order. Thanks to Onno van der Linden (onno@simplex.nl) - Avoid solaris compiler warnings. Thanks to Bruce Barnett (barnett@grymoire.crd.ge.com) - Fix rip printer to not print one more route than is actually in the packet. Thanks to Jean-Luc Richier (Jean-Luc.Richier@imag.fr) and Bill Fenner (fenner@parc.xerox.com) - Use autoconf endian detection since BYTE_ORDER isn't defined on all systems. - Fix dvmrp printer truncation checks and add a dvmrp probe printer. Thanks to Danny J. Mitzel (mitzel@ipsilon.com) - Rewrite ospf printer to improve truncation checks. - Don't parse tcp options past the EOL. As noted by David Sacerdote (davids@secnet.com). Also, check tcp options to make sure they ar actually in the tcp header (in addition to the normal truncation checks). Fix the SACK code to print the N blocks (instead of the first block N times). - Don't say really small UDP packets are truncated just because they aren't big enough to be a RPC. As noted by David Sacerdote. v3.2.1 Sun Jul 14 03:02:26 PDT 1996 - Added rfc1716 icmp codes as suggested by Martin Fredriksson (martin@msp.se) - Print mtu for icmp unreach need frag packets. Thanks to John Hawkinson (jhawk@mit.edu) - Decode icmp router discovery messages. Thanks to Jeffrey Honig (jch@bsdi.com) - Added a printer entry for DLT_IEEE802 as suggested by Tak Kushida (kushida@trl.ibm.co.jp) - Check igmp checksum if possible. Thanks to John Hawkinson. - Made changes for SINIX. Thanks to Andrej Borsenkow (borsenkow.msk@sni.de) - Use autoconf's idea of the top level directory in install targets. Thanks to John Hawkinson. - Avoid infinite loop in tcp options printing code. Thanks to Jeffrey Mogul (mogul@pa.dec.com) - Avoid using -lsocket in IRIX 5.2 and earlier since it breaks snoop. Thanks to John Hawkinson. - Added some more packet truncation checks. - On systems that have it, use sigset() instead of signal() since signal() has different semantics on these systems. - Fixed some more alignment problems on the alpha. - Add code to massage unprintable characters in the domain and ipx printers. Thanks to John Hawkinson. - Added explicit netmask support. Thanks to Steve Nuchia (steve@research.oknet.com) - Add "sca" keyword (for DEC cluster services) as suggested by Terry Kennedy (terry@spcvxa.spc.edu) - Add "atalk" keyword as suggested by John Hawkinson. - Added an igrp printer. Thanks to Francis Dupont (francis.dupont@inria.fr) - Print IPX net numbers in hex a la Novell Netware. Thanks to Terry Kennedy (terry@spcvxa.spc.edu) - Fixed snmp extended tag field parsing bug. Thanks to Pascal Hennequin (pascal.hennequin@hugo.int-evry.fr) - Added some ETHERTYPEs missing on some systems. - Added truncated packet macros and various checks. - Fixed endian problems with the DECnet printer. - Use $CC when checking gcc version. Thanks to Carl Lindberg (carl_lindberg@blacksmith.com) - Fixes for AIX (although this system is not yet supported). Thanks to John Hawkinson. - Fix bugs in the autoconf misaligned accesses code fragment. - Include sys/param.h to get BYTE_ORDER in a few places. Thanks to Pavlin Ivanov Radoslavov (pavlin@cs.titech.ac.jp) v3.2 Sun Jun 23 02:28:10 PDT 1996 - Print new icmp unreachable codes as suggested by Martin Fredriksson (martin@msp.se). Also print code value when unknown for icmp redirect and time exceeded. - Fix an alignment endian bug in getname(). Thanks to John Hawkinson. - Define "new" domain record types if not found in arpa/nameserv.h. Resulted from a suggestion from John Hawkinson (jhawk@mit.edu). Also fixed an endian bug when printing mx record and added some new record types. - Added RIP V2 support. Thanks to Jeffrey Honig (jch@bsdi.com) - Added T/TCP options printing. As suggested by Richard Stevens (rstevens@noao.edu) - Use autoconf to detect architectures that can't handle misaligned accesses. v3.1 Thu Jun 13 20:59:32 PDT 1996 - Changed u_int32/int32 to u_int32_t/int32_t to be consistent with bsd and bind (as suggested by Charles Hannum). - Port to GNU autoconf. - Add support for printing DVMRP and PIM traffic thanks to Havard Eidnes (Havard.Eidnes@runit.sintef.no). - Fix AppleTalk, IPX and DECnet byte order problems due to wrong endian define being referenced. Reported by Terry Kennedy. - Minor fixes to the man page thanks to Mark Andrews. - Endian fixes to RTP and vat packet dumpers, thanks to Bruce Mah (bmah@cs.berkeley.edu). - Added support for new dns types, thanks to Rainer Orth. - Fixed tftp_print() to print the block number for ACKs. - Document -dd and -ddd. Resulted from a bug report from Charlie Slater (cslater@imatek.com). - Check return status from malloc/calloc/etc. - Check return status from pcap_loop() so we can print an error and exit with a bad status if there were problems. - Bail if ip option length is <= 0. Resulted from a bug report from Darren Reed (darrenr@vitruvius.arbld.unimelb.edu.au). - Print out a little more information for sun rpc packets. - Add suport for Kerberos 4 thanks to John Hawkinson (jhawk@mit.edu). - Fixed the Fix EXTRACT_SHORT() and EXTRACT_LONG() macros (which were wrong on little endian machines). - Fixed alignment bug in ipx_decode(). Thanks to Matt Crawford (crawdad@fnal.gov). - Fix ntp_print() to not print garbage when the stratum is "unspecified." Thanks to Deus Ex Machina (root@belle.bork.com). - Rewrote tcp options printer code to check for truncation. Added selective acknowledgment case. - Fixed an endian bug in the ospf printer. Thanks to Jeffrey C Honig (jch@bsdi.com) - Fix rip printer to handle 4.4 BSD sockaddr struct which only uses one octet for the sa_family member. Thanks to Yoshitaka Tokugawa (toku@dit.co.jp) - Don't checksum ip header if we don't have all of it. Thanks to John Hawkinson (jhawk@mit.edu). - Print out hostnames if possible in egp printer. Thanks to Jeffrey Honig (jhc@bsdi.com) v3.1a1 Wed May 3 19:21:11 PDT 1995 - Include time.h when SVR4 is defined to avoid problems under Solaris 2.3. - Fix etheraddr_string() in the ETHER_SERVICE to return the saved strings, not the local buffer. Thanks to Stefan Petri (petri@ibr.cs.tu-bs.de). - Detect when pcap raises the snaplen (e.g. with snit). Print a warning that the selected value was not used. Thanks to Pascal Hennequin (Pascal.Hennequin@hugo.int-evry.fr). - Add a truncated packet test to print-nfs.c. Thanks to Pascal Hennequin. - BYTEORDER -> BYTE_ORDER Thanks to Terry Kennedy (terry@spcvxa.spc.edu). v3.0.3 Sun Oct 1 18:35:00 GMT 1995 - Although there never was a 3.0.3 release, the linux boys cleverly "released" one in late 1995. v3.0.2 Thu Apr 20 21:28:16 PDT 1995 - Change configuration to not use gcc v2 flags with gcc v1. - Redo gmt2local() so that it works under BSDI (which seems to return an empty timezone struct from gettimeofday()). Based on report from Terry Kennedy (terry@spcvxa.spc.edu). - Change configure to recognize IP[0-9]* as "mips" SGI hardware. Based on report from Mark Andrews (mandrews@alias.com). - Don't pass cc flags to gcc. Resulted from a bug report from Rainer Orth (ro@techfak.uni-bielefeld.de). - Fixed printout of connection id for uncompressed tcp slip packets. Resulted from a bug report from Richard Stevens (rstevens@noao.edu). - Hack around deficiency in Ultrix's make. - Add ETHERTYPE_TRAIL define which is missing from irix5. v3.0.1 Wed Aug 31 22:42:26 PDT 1994 - Fix problems with gcc2 vs. malloc() and read() prototypes under SunOS 4. v3.0 Mon Jun 20 19:23:27 PDT 1994 - Added support for printing tcp option timestamps thanks to Mark Andrews (mandrews@alias.com). - Reorganize protocol dumpers to take const pointers to packets so they never change the contents (i.e., they used to do endian conversions in place). Previously, whenever more than one pass was taken over the packet, the packet contents would be dumped incorrectly (i.e., the output form -x would be wrong on little endian machines because the protocol dumpers would modify the data). Thanks to Charles Hannum (mycroft@gnu.ai.mit.edu) for reporting this problem. - Added support for decnet protocol dumping thanks to Jeff Mogul (mogul@pa.dec.com). - Fix bug that caused length of packet to be incorrectly printed (off by ether header size) for unknown ethernet types thanks to Greg Miller (gmiller@kayak.mitre.org). - Added support for IPX protocol dumping thanks to Brad Parker (brad@fcr.com). - Added check to verify IP header checksum under -v thanks to Brad Parker (brad@fcr.com). - Move packet capture code to new libpcap library (which is packaged separately). - Prototype everything and assume an ansi compiler. - print-arp.c: Print hardware ethernet addresses if they're not what we expect. - print-bootp.c: Decode the cmu vendor field. Add RFC1497 tags. Many helpful suggestions from Gordon Ross (gwr@jericho.mc.com). - print-fddi.c: Improvements. Thanks to Jeffrey Mogul (mogul@pa.dec.com). - print-icmp.c: Byte swap netmask before printing. Thanks to Richard Stevens (rstevens@noao.edu). Print icmp type when unknown. - print-ip.c: Print the inner ip datagram of ip-in-ip encapsulated packets. By default, only the inner packet is dumped, appended with the token "(encap)". Under -v, both the inner and output packets are dumped (on the same line). Note that the filter applies to the original packet, not the encapsulated packet. So if you run tcpdump on a net with an IP Multicast tunnel, you cannot filter out the datagrams using the conventional syntax. (You can filter away all the ip-in-ip traffic with "not ip proto 4".) - print-nfs.c: Keep pending rpc's in circular table. Add generic nfs header and remove os dependences. Thanks to Jeffrey Mogul. - print-ospf.c: Improvements. Thanks to Jeffrey Mogul. - tcpdump.c: Add -T flag allows interpretation of "vat", "wb", "rpc" (sunrpc) and rtp packets. Added "inbound" and "outbound" keywords Add && and || operators v2.2.1 Tue Jun 6 17:57:22 PDT 1992 - Fix bug with -c flag. v2.2 Fri May 22 17:19:41 PDT 1992 - savefile.c: Remove hack that shouldn't have been exported. Add truncate checks. - Added the 'icmp' keyword. For example, 'icmp[0] != 8 and icmp[0] != 0' matches non-echo/reply ICMP packets. - Many improvements to filter code optimizer. - Added 'multicast' keyword and extended the 'broadcast' keyword can now be so that protocol qualifications are allowed. For example, "ip broadcast" and "ether multicast" are valid filters. - Added support for monitoring the loopback interface (i.e. 'tcpdump -i lo'). Jeffrey Honig (jch@MITCHELL.CIT.CORNELL.EDU) contributed the kernel patches to netinet/if_loop.c. - Added support for the Ungermann-Bass Ethernet on IBM/PC-RTs running AOS. Contact Jeffrey Honig (jch@MITCHELL.CIT.CORNELL.EDU) for the diffs. - Added EGP and OSPF printers, thanks to Jeffrey Honig. v2.1 Tue Jan 28 11:00:14 PST 1992 - Internal release (never publically exported). v2.0.1 Sun Jan 26 21:10:10 PDT - Various byte ordering fixes. - Add truncation checks. - inet.c: Support BSD style SIOCGIFCONF. - nametoaddr.c: Handle multi addresses for single host. - optimize.c: Rewritten. - pcap-bpf.c: don't choke when we get ptraced. only set promiscuous for broadcast nets. - print-atal.c: Fix an alignment bug (thanks to stanonik@nprdc.navy.mil) Add missing printf() argument. - print-bootp.c: First attempt at decoding the vendor buffer. - print-domain.c: Fix truncation checks. - print-icmp.c: Calculate length of packets from the ip header. - print-ip.c: Print frag id in decimal (so it's easier to match up with non-frags). Add support for ospf, egp and igmp. - print-nfs.c: Lots of changes. - print-ntp.c: Make some verbose output depend on -v. - print-snmp.c: New version from John LoVerso. - print-tcp.c: Print rfc1072 tcp options. - tcpdump.c: Print "0x" prefix for %x formats. Always print 6 digits (microseconds) worth of precision. Fix uid bugs. - A packet dumper has been added (thanks to Jeff Mogul of DECWRL). With this option, you can create an architecture independent binary trace file in real time, without the overhead of the packet printer. At a later time, the packets can be filtered (again) and printed. - BSD is supported. You must have BPF in your kernel. Since the filtering is now done in the kernel, fewer packets are dropped. In fact, with BPF and the packet dumper option, a measly Sun 3/50 can keep up with a busy network. - Compressed SLIP packets can now be dumped, provided you use our SLIP software and BPF. These packets are dumped as any other IP packet; the compressed headers are dumped with the '-e' option. - Machines with little-endian byte ordering are supported (thanks to Jeff Mogul). - Ultrix 4.0 is supported (also thanks to Jeff Mogul). - IBM RT and Stanford Enetfilter support has been added by Rayan Zachariassen . Tcpdump has been tested under both the vanilla Enetfilter interface, and the extended interface (#ifdef'd by IBMRTPC) present in the MERIT version of the Enetfilter. - TFTP packets are now printed (requests only). - BOOTP packets are now printed. - SNMP packets are now printed. (thanks to John LoVerso of Xylogics). - Sparc architectures, including the Sparcstation-1, are now supported thanks to Steve McCanne and Craig Leres. - SunOS 4 is now supported thanks to Micky Liu of Columbia University (micky@cunixc.cc.columbia.edu). - IP options are now printed. - RIP packets are now printed. - There's a -v flag that prints out more information than the default (e.g., it will enable printing of IP ttl, tos and id) and -q flag that prints out less (e.g., it will disable interpretation of AppleTalk-in-UDP). - The grammar has undergone substantial changes (if you have an earlier version of tcpdump, you should re-read the manual entry). The most useful change is the addition of an expression syntax that lets you filter on arbitrary fields or values in the packet. E.g., "ip[0] > 0x45" would print only packets with IP options, "tcp[13] & 3 != 0" would print only TCP SYN and FIN packets. The most painful change is that concatenation no longer means "and" -- e.g., you have to say "host foo and port bar" instead of "host foo port bar". The up side to this down is that repeated qualifiers can be omitted, making most filter expressions shorter. E.g., you can now say "ip host foo and (bar or baz)" to look at ip traffic between hosts foo and bar or between hosts foo and baz. [The old way of saying this was "ip host foo and (ip host bar or ip host baz)".] v2.0 Sun Jan 13 12:20:40 PST 1991 - Initial public release. @(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.81.2.1 2003/02/26 07:08:58 fenner Exp $ (LBL) tcpdump-3.7.2/chdlc.h0100644000076500000240000000263207161322017013570 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/chdlc.h,v 1.1 2000/09/18 05:11:43 guy Exp $ (LBL) */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #define CHDLC_HDRLEN 4 #define CHDLC_UNICAST 0x0f #define CHDLC_BCAST 0x8f #define CHDLC_TYPE_SLARP 0x8035 #define CHDLC_TYPE_CDP 0x2000 tcpdump-3.7.2/config.guess0100755000076500000240000011461707275064137014705 0ustar fennerstaff#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. timestamp='2001-04-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . # Please send patches to . # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi dummy=dummy-$$ trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int dummy(){}" > $dummy.c for c in cc gcc c89 ; do ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 if test $? = 0 ; then CC_FOR_BUILD="$c"; break fi done rm -f $dummy.c $dummy.o $dummy.rel if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 8/24/94.) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # Netbsd (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # Determine the machine/vendor (is the vendor relevant). case "${UNAME_MACHINE}" in amiga) machine=m68k-unknown ;; arm32) machine=arm-unknown ;; atari*) machine=m68k-atari ;; sun3*) machine=m68k-sun ;; mac68k) machine=m68k-apple ;; macppc) machine=powerpc-apple ;; hp3[0-9][05]) machine=m68k-hp ;; ibmrt|romp-ibm) machine=romp-ibm ;; *) machine=${UNAME_MACHINE}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE}" in i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. cat <$dummy.s .data \$Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d80 # implver \$0 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,\$Lformat mov \$0,\$17 not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `./$dummy` in 0-0) UNAME_MACHINE="alpha" ;; 1-0) UNAME_MACHINE="alphaev5" ;; 1-1) UNAME_MACHINE="alphaev56" ;; 1-101) UNAME_MACHINE="alphapca56" ;; 2-303) UNAME_MACHINE="alphaev6" ;; 2-307) UNAME_MACHINE="alphaev67" ;; esac fi rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; arc64:OpenBSD:*:*) echo mips64el-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hkmips:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; atari*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; sun3*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD $dummy.c -o $dummy \ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) case "${HPUX_REV}" in 11.[0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; esac ;; esac fi ;; esac if [ "${HP_ARCH}" = "" ]; then sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi rm -f $dummy.c $dummy fi ;; esac echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; hppa*:OpenBSD:*:*) echo hppa-unknown-openbsd exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*X-MP:*:*:*) echo xmp-cray-unicos exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3D:*:*:*) echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i386-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) cat >$dummy.c < /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #ifdef __MIPSEB__ printf ("%s-unknown-linux-gnu\n", argv[1]); #endif #ifdef __MIPSEL__ printf ("%sel-unknown-linux-gnu\n", argv[1]); #endif return 0; } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy ;; ppc:Linux:*:*) # Determine Lib Version cat >$dummy.c < #if defined(__GLIBC__) extern char __libc_version[]; extern char __libc_release[]; #endif main(argc, argv) int argc; char *argv[]; { #if defined(__GLIBC__) printf("%s %s\n", __libc_version, __libc_release); #else printf("unknown\n"); #endif return 0; } EOF LIBC="" $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null if test "$?" = 0 ; then ./$dummy | grep 1\.99 > /dev/null if test "$?" = 0 ; then LIBC="libc1" ; fi fi rm -f $dummy.c $dummy echo powerpc-unknown-linux-gnu${LIBC} exit 0 ;; alpha:Linux:*:*) cat <$dummy.s .data \$Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d80 # implver \$0 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,\$Lformat mov \$0,\$17 not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF LIBC="" $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `./$dummy` in 0-0) UNAME_MACHINE="alpha" ;; 1-0) UNAME_MACHINE="alphaev5" ;; 1-1) UNAME_MACHINE="alphaev56" ;; 1-101) UNAME_MACHINE="alphapca56" ;; 2-303) UNAME_MACHINE="alphaev6" ;; 2-307) UNAME_MACHINE="alphaev67" ;; esac objdump --private-headers $dummy | \ grep ld.so.1 > /dev/null if test "$?" = 0 ; then LIBC="libc1" fi fi rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. ld_supported_emulations=`cd /; ld --help 2>&1 \ | sed -ne '/supported emulations:/!d s/[ ][ ]*/ /g s/.*supported emulations: *// s/ .*// p'` case "$ld_supported_emulations" in i*86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; elf_i*86) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; i*86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; esac # Either a pre-BFD a.out linker (linux-gnuoldld) # or one that does not give us useful --help. # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. # If ld does not provide *any* "supported emulations:" # that means it is gnuoldld. test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 case "${UNAME_MACHINE}" in i*86) VENDOR=pc; ;; *) VENDOR=unknown; ;; esac # Determine whether the default compiler is a.out or elf cat >$dummy.c < #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); # else printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); # endif # else printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); # endif #else printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); #endif return 0; } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions # are messed up and put the nodename in both sysname and nodename. i*86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:7*) # Fixed at (any) Pentium or better UNAME_MACHINE=i586 if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} fi exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) echo `uname -p`-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) if test "${UNAME_MACHINE}" = "x86pc"; then UNAME_MACHINE=pc fi echo `uname -p`-${UNAME_MACHINE}-nto-qnx exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[KW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: tcpdump-3.7.2/config.h.in0100644000076500000240000001142007627054622014373 0ustar fennerstaff/* config.h.in. Generated automatically from configure.in by autoheader. */ /* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in -- * make them to acconfig.h and rerun autoheader */ /* Define to empty if the keyword does not work. */ #undef const /* Define as the return type of signal handlers (int or void). */ #undef RETSIGTYPE /* Define if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define if you have SSLeay 0.9.0b with the buggy cast128. */ #undef HAVE_BUGGY_CAST128 /* Define if you enable IPv6 support */ #undef INET6 /* Define if you enable support for the libsmi. */ #undef LIBSMI /* define if you have struct __res_state_ext */ #undef HAVE_RES_STATE_EXT /* define if your struct __res_state has the nsort member */ #undef HAVE_NEW_RES_STATE /* define if you have the addrinfo function. */ #undef HAVE_ADDRINFO /* define if you need to include missing/addrinfoh.h. */ #undef NEED_ADDRINFO_H /* define ifyou have the h_errno variable. */ #undef HAVE_H_ERRNO /* define if IN6ADDRSZ is defined (XXX not used!) */ #undef HAVE_IN6ADDRSZ /* define if INADDRSZ is defined (XXX not used!) */ #undef HAVE_INADDRSZ /* define if this is a development version, to use additional prototypes. */ #undef HAVE_OS_PROTO_H /* define if RES_USE_INET6 is defined */ #undef HAVE_RES_USE_INET6 /* define if struct sockaddr has the sa_len member */ #undef HAVE_SOCKADDR_SA_LEN /* define if you have struct sockaddr_storage */ #undef HAVE_SOCKADDR_STORAGE /* define if you have ether_ntohost() and it works */ #undef USE_ETHER_NTOHOST /* define if unaligned memory accesses fail */ #undef LBL_ALIGN /* The successful return value from signal (?)XXX */ #undef RETSIGVAL /* Define this on IRIX */ #undef _BSD_SIGNALS /* For HP/UX ANSI compiler? */ #undef _HPUX_SOURCE /* AIX hack. */ #undef _SUN /* Workaround for missing sized types */ /* XXX this should move to the more standard uint*_t */ #undef int16_t #undef int32_t #undef u_int16_t #undef u_int32_t #undef u_int8_t /* Whether or not to include the possibly-buggy SMB printer */ #undef TCPDUMP_DO_SMB /* Long story short: aclocal.m4 depends on autoconf 2.13 * implementation details wrt "const"; newer versions * have different implementation details so for now we * put "const" here. This may cause duplicate definitions * in config.h but that should be OK since they're the same. */ #undef const /* The number of bytes in a char. */ #undef SIZEOF_CHAR /* The number of bytes in a int. */ #undef SIZEOF_INT /* The number of bytes in a long. */ #undef SIZEOF_LONG /* The number of bytes in a short. */ #undef SIZEOF_SHORT /* Define if you have the bpf_dump function. */ #undef HAVE_BPF_DUMP /* Define if you have the ether_ntohost function. */ #undef HAVE_ETHER_NTOHOST /* Define if you have the getaddrinfo function. */ #undef HAVE_GETADDRINFO /* Define if you have the getnameinfo function. */ #undef HAVE_GETNAMEINFO /* Define if you have the inet_aton function. */ #undef HAVE_INET_ATON /* Define if you have the inet_ntop function. */ #undef HAVE_INET_NTOP /* Define if you have the inet_pton function. */ #undef HAVE_INET_PTON /* Define if you have the pfopen function. */ #undef HAVE_PFOPEN /* Define if you have the setlinebuf function. */ #undef HAVE_SETLINEBUF /* Define if you have the sigaction function. */ #undef HAVE_SIGACTION /* Define if you have the sigset function. */ #undef HAVE_SIGSET /* Define if you have the snprintf function. */ #undef HAVE_SNPRINTF /* Define if you have the strcasecmp function. */ #undef HAVE_STRCASECMP /* Define if you have the strdup function. */ #undef HAVE_STRDUP /* Define if you have the strlcat function. */ #undef HAVE_STRLCAT /* Define if you have the strlcpy function. */ #undef HAVE_STRLCPY /* Define if you have the vfprintf function. */ #undef HAVE_VFPRINTF /* Define if you have the vsnprintf function. */ #undef HAVE_VSNPRINTF /* Define if you have the header file. */ #undef HAVE_CAST_H /* Define if you have the header file. */ #undef HAVE_FCNTL_H /* Define if you have the header file. */ #undef HAVE_NETINET_IF_ETHER_H /* Define if you have the header file. */ #undef HAVE_RC5_H /* Define if you have the header file. */ #undef HAVE_RPC_RPCENT_H /* Define if you have the header file. */ #undef HAVE_SMI_H /* Define if you have the crypto library (-lcrypto). */ #undef HAVE_LIBCRYPTO /* Define if you have the dnet library (-ldnet). */ #undef HAVE_LIBDNET /* Define if you have the rpc library (-lrpc). */ #undef HAVE_LIBRPC /* Define if you have the smi library (-lsmi). */ #undef HAVE_LIBSMI /* Define as token for inline if inlining supported */ #undef inline /* define if your compiler has __attribute__ */ #undef HAVE___ATTRIBUTE__ tcpdump-3.7.2/config.sub0100755000076500000240000006571207275064140014343 0ustar fennerstaff#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. timestamp='2001-04-20' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \ | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \ | pyramid | mn10200 | mn10300 | tron | a29k \ | 580 | i960 | h8300 \ | x86 | ppcbe | mipsbe | mipsle | shbe | shle \ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ | hppa64 \ | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ | alphaev6[78] \ | we32k | ns16k | clipper | i370 | sh | sh[34] \ | powerpc | powerpcle \ | 1750a | dsp16xx | pdp10 | pdp11 \ | mips16 | mips64 | mipsel | mips64el \ | mips64orion | mips64orionel | mipstx39 | mipstx39el \ | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \ | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \ | v850 | c4x \ | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \ | pj | pjl | h8500) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. # FIXME: clean up the formatting here. vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \ | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ | xmp-* | ymp-* \ | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \ | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \ | hppa2.0n-* | hppa64-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ | alphaev6[78]-* \ | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ | clipper-* | orion-* \ | sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \ | mips16-* | mips64-* | mipsel-* \ | mips64el-* | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ | mipstx39-* | mipstx39el-* | mcore-* \ | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \ | [cjt]90-* \ | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \ | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | ymp) basic_machine=ymp-cray os=-unicos ;; cray2) basic_machine=cray2-cray os=-unicos ;; [cjt]90) basic_machine=${basic_machine}-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mipsel*-linux*) basic_machine=mipsel-unknown os=-linux-gnu ;; mips*-linux*) basic_machine=mips-unknown os=-linux-gnu ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=t3e-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xmp) basic_machine=xmp-cray os=-unicos ;; xps | xps100) basic_machine=xps100-honeywell ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; mips) if [ x$os = x-linux-gnu ]; then basic_machine=mips-unknown else basic_machine=mips-mips fi ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4) basic_machine=sh-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; c4x*) basic_machine=c4x-none os=-coff ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: tcpdump-3.7.2/configure0100755000076500000240000041063607627054624014275 0ustar fennerstaff#! /bin/sh # From configure.in Revision: 1.145.2.1 # # Try compiling a sample of the type of code that appears in # gencode.c with "inline", "__inline__", and "__inline". # # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough, # as it just tests whether a function returning "int" can be inlined; # at least some versions of HP's C compiler can inline that, but can't # inline a function that returns a struct pointer. # # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help --without-gcc don't use gcc" ac_help="$ac_help --enable-smb enable possibly-buggy SMB printer [default=yes] --disable-smb disable possibly-buggy SMB printer" ac_help="$ac_help --enable-ipv6 enable ipv6 (with ipv4) support --disable-ipv6 disable ipv6 support" ac_help="$ac_help --without-crypto disable crypto support" # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=tcpdump.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # Make sure we can run config.sub. if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 echo "configure:635: checking host system type" >&5 host_alias=$host case "$host_alias" in NONE) case $nonopt in NONE) if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } fi ;; *) host_alias=$nonopt ;; esac ;; esac host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 # Check whether --with-gcc or --without-gcc was given. if test "${with_gcc+set}" = set; then withval="$with_gcc" : fi V_CCOPT="-O" V_INCLS="" if test "${srcdir}" != "." ; then V_INCLS="-I\$(srcdir)" fi if test "${CFLAGS+set}" = set; then LBL_CFLAGS="$CFLAGS" fi if test -z "$CC" ; then case "$host_os" in bsdi*) # Extract the first word of "shlicc2", so it can be a program name with args. set dummy shlicc2; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:681: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_SHLICC2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$SHLICC2"; then ac_cv_prog_SHLICC2="$SHLICC2" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_SHLICC2="yes" break fi done IFS="$ac_save_ifs" test -z "$ac_cv_prog_SHLICC2" && ac_cv_prog_SHLICC2="no" fi fi SHLICC2="$ac_cv_prog_SHLICC2" if test -n "$SHLICC2"; then echo "$ac_t""$SHLICC2" 1>&6 else echo "$ac_t""no" 1>&6 fi if test $SHLICC2 = yes ; then CC=shlicc2 export CC fi ;; esac fi if test -z "$CC" -a "$with_gcc" = no ; then CC=cc export CC fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:722: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:752: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:803: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:835: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 846 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:877: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:882: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:910: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi if test "$GCC" = yes ; then if test "$SHLICC2" = yes ; then ac_cv_lbl_gcc_vers=2 V_CCOPT="-O2" else echo $ac_n "checking gcc version""... $ac_c" 1>&6 echo "configure:947: checking gcc version" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_gcc_vers'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \ sed -e '/^gcc version /!d' \ -e 's/^gcc version //' \ -e 's/ .*//' -e 's/^[^0-9]*//' \ -e 's/\..*//'` fi echo "$ac_t""$ac_cv_lbl_gcc_vers" 1>&6 if test $ac_cv_lbl_gcc_vers -gt 1 ; then V_CCOPT="-O2" fi fi else echo $ac_n "checking that $CC handles ansi prototypes""... $ac_c" 1>&6 echo "configure:965: checking that $CC handles ansi prototypes" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_cc_ansi_prototypes'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { int frob(int, char *) ; return 0; } EOF if { (eval echo configure:977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_cc_ansi_prototypes=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_lbl_cc_ansi_prototypes=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_lbl_cc_ansi_prototypes" 1>&6 if test $ac_cv_lbl_cc_ansi_prototypes = no ; then case "$host_os" in hpux*) echo $ac_n "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)""... $ac_c" 1>&6 echo "configure:995: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5 savedcflags="$CFLAGS" CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" if eval "test \"`echo '$''{'ac_cv_lbl_cc_hpux_cc_aa'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { int frob(int, char *) ; return 0; } EOF if { (eval echo configure:1009: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_cc_hpux_cc_aa=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_lbl_cc_hpux_cc_aa=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_lbl_cc_hpux_cc_aa" 1>&6 if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then { echo "configure: error: see the INSTALL doc for more info" 1>&2; exit 1; } fi CFLAGS="$savedcflags" V_CCOPT="-Aa $V_CCOPT" cat >> confdefs.h <<\EOF #define _HPUX_SOURCE 1 EOF ;; *) { echo "configure: error: see the INSTALL doc for more info" 1>&2; exit 1; } ;; esac fi V_INCLS="$V_INCLS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" case "$host_os" in irix*) V_CCOPT="$V_CCOPT -xansi -signed -O" ;; osf*) V_CCOPT="$V_CCOPT -std1 -O" ;; ultrix*) echo $ac_n "checking that Ultrix $CC hacks const in prototypes""... $ac_c" 1>&6 echo "configure:1053: checking that Ultrix $CC hacks const in prototypes" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_cc_const_proto'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { struct a { int b; }; void c(const struct a *) ; return 0; } EOF if { (eval echo configure:1066: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_cc_const_proto=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_lbl_cc_const_proto=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_lbl_cc_const_proto" 1>&6 if test $ac_cv_lbl_cc_const_proto = no ; then cat >> confdefs.h <<\EOF #define const EOF fi ;; esac fi echo $ac_n "checking for inline""... $ac_c" 1>&6 echo "configure:1090: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_lbl_inline="" ac_lbl_cc_inline=no for ac_lbl_inline in inline __inline__ __inline do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_lbl_cc_inline=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* if test "$ac_lbl_cc_inline" = yes ; then break; fi done if test "$ac_lbl_cc_inline" = yes ; then ac_cv_lbl_inline=$ac_lbl_inline fi fi if test ! -z "$ac_cv_lbl_inline" ; then echo "$ac_t""$ac_cv_lbl_inline" 1>&6 else echo "$ac_t""no" 1>&6 fi cat >> confdefs.h <&6 echo "configure:1148: checking for __attribute__" >&5 if eval "test \"`echo '$''{'ac_cv___attribute__'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { static void foo(void) __attribute__ ((noreturn)); static void foo(void) { exit(1); } ; return 0; } EOF if { (eval echo configure:1171: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv___attribute__=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv___attribute__=no fi rm -f conftest* fi if test "$ac_cv___attribute__" = "yes"; then cat >> confdefs.h <<\EOF #define HAVE___ATTRIBUTE__ 1 EOF fi echo "$ac_t""$ac_cv___attribute__" 1>&6 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:1193: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1214: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1231: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 for ac_hdr in fcntl.h rpc/rpcent.h netinet/if_ether.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1276: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1286: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 echo "configure:1313: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include int main() { struct tm *tp; ; return 0; } EOF if { (eval echo configure:1327: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_time=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_header_time" 1>&6 if test $ac_cv_header_time = yes; then cat >> confdefs.h <<\EOF #define TIME_WITH_SYS_TIME 1 EOF fi case "$host_os" in linux*) echo $ac_n "checking Linux kernel version""... $ac_c" 1>&6 echo "configure:1352: checking Linux kernel version" >&5 if test "$cross_compiling" = yes; then if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_linux_vers=unknown fi else if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_linux_vers=`uname -r 2>&1 | \ sed -n -e '$s/.* //' -e '$s/\..*//p'` fi fi echo "$ac_t""$ac_cv_linux_vers" 1>&6 if test $ac_cv_linux_vers = unknown ; then { echo "configure: error: cannot determine linux version when cross-compiling" 1>&2; exit 1; } fi if test $ac_cv_linux_vers -lt 2 ; then { echo "configure: error: version 2 or higher required; see the INSTALL doc for more info" 1>&2; exit 1; } fi ;; *) ;; esac for ac_hdr in smi.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1387: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1397: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for smiInit in -lsmi""... $ac_c" 1>&6 echo "configure:1424: checking for smiInit in -lsmi" >&5 ac_lib_var=`echo smi'_'smiInit | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsmi $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo smi | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes then echo $ac_n "checking whether to enable libsmi""... $ac_c" 1>&6 echo "configure:1473: checking whether to enable libsmi" >&5 if test "$cross_compiling" = yes; then echo "$ac_t""not when cross-compiling" 1>&6 libsmi=no else cat > conftest.$ac_ext < main() { int current, revision, age, n; const int required = 2; if (smiInit("")) exit(1); if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) exit(2); n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age); if (n != 3) exit(3); if (required < current - age || required > current) exit(4); exit(0); } EOF if { (eval echo configure:1501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define LIBSMI 1 EOF libsmi=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* case $? in 1) echo "$ac_t""no - smiInit failed" 1>&6 ;; 2) echo "$ac_t""no - header/library version mismatch" 1>&6 ;; 3) echo "$ac_t""no - can't determine library version" 1>&6 ;; 4) echo "$ac_t""no - too old" 1>&6 ;; *) echo "$ac_t""no" 1>&6 ;; esac libsmi=no fi rm -fr conftest* fi fi echo $ac_n "checking whether to enable the possibly-buggy SMB printer""... $ac_c" 1>&6 echo "configure:1528: checking whether to enable the possibly-buggy SMB printer" >&5 # Check whether --enable-smb or --disable-smb was given. if test "${enable_smb+set}" = set; then enableval="$enable_smb" : else enableval=yes fi case "$enableval" in yes) echo "$ac_t""yes" 1>&6 echo "configure: warning: The SMB printer may have exploitable buffer overflows!!!" 1>&2 cat >> confdefs.h <<\EOF #define TCPDUMP_DO_SMB 1 EOF LOCALSRC="print-smb.c smbutil.c $LOCALSRC" ;; *) echo "$ac_t""no" 1>&6 ;; esac CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len" echo $ac_n "checking whether to enable ipv6""... $ac_c" 1>&6 echo "configure:1552: checking whether to enable ipv6" >&5 # Check whether --enable-ipv6 or --disable-ipv6 was given. if test "${enable_ipv6+set}" = set; then enableval="$enable_ipv6" case "$enableval" in yes) echo "$ac_t""yes" 1>&6 LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" cat >> confdefs.h <<\EOF #define INET6 1 EOF ipv6=yes ;; *) echo "$ac_t""no" 1>&6 ipv6=no ;; esac else if test "$cross_compiling" = yes; then echo "$ac_t""no" 1>&6 ipv6=no else cat > conftest.$ac_ext < #include main() { if (socket(AF_INET6, SOCK_STREAM, 0) < 0) exit(1); else exit(0); } EOF if { (eval echo configure:1591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""yes" 1>&6 LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" cat >> confdefs.h <<\EOF #define INET6 1 EOF ipv6=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* echo "$ac_t""no" 1>&6 ipv6=no fi rm -fr conftest* fi fi ipv6type=unknown ipv6lib=none ipv6trylibc=no if test "$ipv6" = "yes"; then echo $ac_n "checking ipv6 stack type""... $ac_c" 1>&6 echo "configure:1619: checking ipv6 stack type" >&5 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do case $i in inria) cat > conftest.$ac_ext < #ifdef IPV6_INRIA_VERSION yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* ipv6type=$i; CFLAGS="-DINET6 $CFLAGS" fi rm -f conftest* ;; kame) cat > conftest.$ac_ext < #ifdef __KAME__ yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; ipv6trylibc=yes; CFLAGS="-DINET6 $CFLAGS" fi rm -f conftest* ;; linux-glibc) cat > conftest.$ac_ext < #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* ipv6type=$i; CFLAGS="-DINET6 $CFLAGS" fi rm -f conftest* ;; linux-libinet6) if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then ipv6type=$i ipv6lib=inet6 ipv6libdir=/usr/inet6/lib ipv6trylibc=yes; CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS" fi ;; toshiba) cat > conftest.$ac_ext < #ifdef _TOSHIBA_INET6 yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; CFLAGS="-DINET6 $CFLAGS" fi rm -f conftest* ;; v6d) cat > conftest.$ac_ext < #ifdef __V6D__ yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* ipv6type=$i; ipv6lib=v6; ipv6libdir=/usr/local/v6/lib; CFLAGS="-I/usr/local/v6/include $CFLAGS" fi rm -f conftest* ;; zeta) cat > conftest.$ac_ext < #ifdef _ZETA_MINAMI_INET6 yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; CFLAGS="-DINET6 $CFLAGS" fi rm -f conftest* ;; esac if test "$ipv6type" != "unknown"; then break fi done echo "$ac_t""$ipv6type" 1>&6 fi if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" echo "You have $ipv6lib library, using it" else if test "$ipv6trylibc" = "yes"; then echo "You do not have $ipv6lib library, using libc" else echo 'Fatal: no $ipv6lib library found. cannot continue.' echo "You need to fetch lib$ipv6lib.a from appropriate" echo 'ipv6 kit and compile beforehand.' exit 1 fi fi fi if test "$ipv6" = "yes"; then echo $ac_n "checking for library containing getaddrinfo""... $ac_c" 1>&6 echo "configure:1782: checking for library containing getaddrinfo" >&5 if eval "test \"`echo '$''{'ac_cv_search_getaddrinfo'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_func_search_save_LIBS="$LIBS" ac_cv_search_getaddrinfo="no" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_getaddrinfo="none required" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* test "$ac_cv_search_getaddrinfo" = "no" && for i in socket; do LIBS="-l$i $ac_func_search_save_LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_getaddrinfo="-l$i" break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done LIBS="$ac_func_search_save_LIBS" fi echo "$ac_t""$ac_cv_search_getaddrinfo" 1>&6 if test "$ac_cv_search_getaddrinfo" != "no"; then test "$ac_cv_search_getaddrinfo" = "none required" || LIBS="$ac_cv_search_getaddrinfo $LIBS" echo $ac_n "checking getaddrinfo bug""... $ac_c" 1>&6 echo "configure:1839: checking getaddrinfo bug" >&5 if test "$cross_compiling" = yes; then echo "$ac_t""buggy" 1>&6 buggygetaddrinfo=yes else cat > conftest.$ac_ext < #include #include #include #include main() { int passive, gaierr, inet4 = 0, inet6 = 0; struct addrinfo hints, *ai, *aitop; char straddr[INET6_ADDRSTRLEN], strport[16]; for (passive = 0; passive <= 1; passive++) { memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_flags = passive ? AI_PASSIVE : 0; hints.ai_socktype = SOCK_STREAM; if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { (void)gai_strerror(gaierr); goto bad; } for (ai = aitop; ai; ai = ai->ai_next) { if (ai->ai_addr == NULL || ai->ai_addrlen == 0 || getnameinfo(ai->ai_addr, ai->ai_addrlen, straddr, sizeof(straddr), strport, sizeof(strport), NI_NUMERICHOST|NI_NUMERICSERV) != 0) { goto bad; } switch (ai->ai_family) { case AF_INET: if (strcmp(strport, "54321") != 0) { goto bad; } if (passive) { if (strcmp(straddr, "0.0.0.0") != 0) { goto bad; } } else { if (strcmp(straddr, "127.0.0.1") != 0) { goto bad; } } inet4++; break; case AF_INET6: if (strcmp(strport, "54321") != 0) { goto bad; } if (passive) { if (strcmp(straddr, "::") != 0) { goto bad; } } else { if (strcmp(straddr, "::1") != 0) { goto bad; } } inet6++; break; case AF_UNSPEC: goto bad; break; #ifdef AF_UNIX case AF_UNIX: #else #ifdef AF_LOCAL case AF_LOCAL: #endif #endif default: /* another family support? */ break; } } } /* supported family should be 2, unsupported family should be 0 */ if (!(inet4 == 0 || inet4 == 2)) goto bad; if (!(inet6 == 0 || inet6 == 2)) goto bad; if (aitop) freeaddrinfo(aitop); exit(0); bad: if (aitop) freeaddrinfo(aitop); exit(1); } EOF if { (eval echo configure:1942: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""good" 1>&6 buggygetaddrinfo=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* echo "$ac_t""buggy" 1>&6 buggygetaddrinfo=yes fi rm -fr conftest* fi else : buggygetaddrinfo=yes fi if test "$buggygetaddrinfo" = "yes"; then if test "$ipv6type" != "linux"; then echo 'Fatal: You must get working getaddrinfo() function.' echo ' or you can specify "--disable-ipv6"'. exit 1 else echo 'Warning: getaddrinfo() implementation on your system seems be buggy.' echo ' Better upgreade your system library to newest version' echo ' of GNU C library (aka glibc).' fi fi for ac_func in getaddrinfo getnameinfo do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1974: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" fi done fi echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6 echo "configure:2030: checking for inet_ntop" >&5 cat > conftest.$ac_ext < #include #include #include int main() { char src[4], dst[128]; inet_ntop(AF_INET, src, dst, sizeof(dst)); ; return 0; } EOF if { (eval echo configure:2043: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 for ac_func in inet_ntop do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2054: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" fi done fi rm -f conftest* echo $ac_n "checking for inet_pton""... $ac_c" 1>&6 echo "configure:2111: checking for inet_pton" >&5 cat > conftest.$ac_ext < #include #include #include int main() { char src[128], dst[4]; inet_pton(AF_INET, src, dst); ; return 0; } EOF if { (eval echo configure:2124: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 for ac_func in inet_pton do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2135: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" fi done fi rm -f conftest* echo $ac_n "checking for inet_aton""... $ac_c" 1>&6 echo "configure:2192: checking for inet_aton" >&5 cat > conftest.$ac_ext < #include #include int main() { char src[128]; struct in_addr dst; inet_aton(src, &dst); ; return 0; } EOF if { (eval echo configure:2205: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 for ac_func in inet_aton do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2216: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" fi done fi rm -f conftest* echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6 echo "configure:2275: checking if sockaddr struct has sa_len member" >&5 if eval "test \"`echo '$''{'ac_cv_sockaddr_has_sa_len'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # include int main() { u_int i = sizeof(((struct sockaddr *)0)->sa_len) ; return 0; } EOF if { (eval echo configure:2289: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sockaddr_has_sa_len=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_sockaddr_has_sa_len=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_sockaddr_has_sa_len" 1>&6 if test $ac_cv_sockaddr_has_sa_len = yes ; then cat >> confdefs.h <<\EOF #define HAVE_SOCKADDR_SA_LEN 1 EOF fi if test "$ac_cv_sockaddr_has_sa_len" = no; then missing_includes=yes fi echo $ac_n "checking size of char""... $ac_c" 1>&6 echo "configure:2314: checking size of char" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then ac_cv_sizeof_char=1 else cat > conftest.$ac_ext < main() { FILE *f=fopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(char)); exit(0); } EOF if { (eval echo configure:2333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_char=`cat conftestval` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_sizeof_char=0 fi rm -fr conftest* fi fi echo "$ac_t""$ac_cv_sizeof_char" 1>&6 cat >> confdefs.h <&6 echo "configure:2353: checking size of short" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then ac_cv_sizeof_short=2 else cat > conftest.$ac_ext < main() { FILE *f=fopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(short)); exit(0); } EOF if { (eval echo configure:2372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_short=`cat conftestval` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_sizeof_short=0 fi rm -fr conftest* fi fi echo "$ac_t""$ac_cv_sizeof_short" 1>&6 cat >> confdefs.h <&6 echo "configure:2392: checking size of int" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then ac_cv_sizeof_int=4 else cat > conftest.$ac_ext < main() { FILE *f=fopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(int)); exit(0); } EOF if { (eval echo configure:2411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int=`cat conftestval` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_sizeof_int=0 fi rm -fr conftest* fi fi echo "$ac_t""$ac_cv_sizeof_int" 1>&6 cat >> confdefs.h <&6 echo "configure:2431: checking size of long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then ac_cv_sizeof_long=4 else cat > conftest.$ac_ext < main() { FILE *f=fopen("conftestval", "w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof(long)); exit(0); } EOF if { (eval echo configure:2450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_sizeof_long=0 fi rm -fr conftest* fi fi echo "$ac_t""$ac_cv_sizeof_long" 1>&6 cat >> confdefs.h <&6 echo "configure:2473: checking for addrinfo" >&5 if eval "test \"`echo '$''{'ac_cv_addrinfo'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { struct addrinfo a ; return 0; } EOF if { (eval echo configure:2486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_addrinfo=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_addrinfo=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_addrinfo" 1>&6 if test $ac_cv_addrinfo = yes; then cat >> confdefs.h <<\EOF #define HAVE_ADDRINFO 1 EOF else cat >> confdefs.h <<\EOF #define NEED_ADDRINFO_H 1 EOF fi if test "$ac_cv_addrinfo" = no; then missing_includes=yes fi echo $ac_n "checking for NI_MAXSERV""... $ac_c" 1>&6 echo "configure:2517: checking for NI_MAXSERV" >&5 if eval "test \"`echo '$''{'ac_cv_maxserv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifdef NI_MAXSERV yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* ac_cv_maxserv=yes else rm -rf conftest* ac_cv_maxserv=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_maxserv" 1>&6 if test $ac_cv_maxserv != yes; then cat >> confdefs.h <<\EOF #define NEED_ADDRINFO_H 1 EOF fi if test "$ac_cv_maxserv" = no; then missing_includes=yes fi echo $ac_n "checking for NI_NAMEREQD""... $ac_c" 1>&6 echo "configure:2555: checking for NI_NAMEREQD" >&5 if eval "test \"`echo '$''{'ac_cv_namereqd'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifdef NI_NOFQDN yes #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "yes" >/dev/null 2>&1; then rm -rf conftest* ac_cv_namereqd=yes else rm -rf conftest* ac_cv_namereqd=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_namereqd" 1>&6 if test $ac_cv_namereqd != yes; then cat >> confdefs.h <<\EOF #define NEED_ADDRINFO_H 1 EOF fi if test "$ac_cv_namereqd" = no; then missing_includes=yes fi echo $ac_n "checking for sockaddr_storage""... $ac_c" 1>&6 echo "configure:2593: checking for sockaddr_storage" >&5 if eval "test \"`echo '$''{'ac_cv_sa_storage'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # include int main() { struct sockaddr_storage s ; return 0; } EOF if { (eval echo configure:2607: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sa_storage=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_sa_storage=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_sa_storage" 1>&6 if test $ac_cv_sa_storage = yes; then cat >> confdefs.h <<\EOF #define HAVE_SOCKADDR_STORAGE 1 EOF fi if test "$ac_cv_sa_storage" = no; then missing_includes=yes fi ac_cv_addrsz=yes echo $ac_n "checking for INADDRSZ""... $ac_c" 1>&6 echo "configure:2634: checking for INADDRSZ" >&5 if eval "test \"`echo '$''{'ac_cv_inaddrsz'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { int a = INADDRSZ ; return 0; } EOF if { (eval echo configure:2647: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_inaddrsz=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_inaddrsz=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_inaddrsz" 1>&6 if test $ac_cv_inaddrsz = yes; then cat >> confdefs.h <<\EOF #define HAVE_INADDRSZ 1 EOF else ac_cv_addrsz=no fi echo $ac_n "checking for IN6ADDRSZ""... $ac_c" 1>&6 echo "configure:2669: checking for IN6ADDRSZ" >&5 if eval "test \"`echo '$''{'ac_cv_in6addrsz'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { int a = IN6ADDRSZ ; return 0; } EOF if { (eval echo configure:2682: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_in6addrsz=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_in6addrsz=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_in6addrsz" 1>&6 if test $ac_cv_in6addrsz = yes; then cat >> confdefs.h <<\EOF #define HAVE_IN6ADDRSZ 1 EOF else ac_cv_addrsz=no fi if test "$ac_cv_addrsz" = no; then missing_includes=yes fi echo $ac_n "checking for RES_USE_INET6""... $ac_c" 1>&6 echo "configure:2710: checking for RES_USE_INET6" >&5 if eval "test \"`echo '$''{'ac_cv_res_inet6'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # include # include int main() { int a = RES_USE_INET6 ; return 0; } EOF if { (eval echo configure:2725: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_res_inet6=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_res_inet6=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_res_inet6" 1>&6 if test $ac_cv_res_inet6 = yes; then cat >> confdefs.h <<\EOF #define HAVE_RES_USE_INET6 1 EOF fi if test "$ac_cv_res_inet6" = no; then missing_includes=yes fi echo $ac_n "checking for res_state_ext""... $ac_c" 1>&6 echo "configure:2751: checking for res_state_ext" >&5 if eval "test \"`echo '$''{'ac_cv_res_state_ext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # include # include # include int main() { struct __res_state_ext e ; return 0; } EOF if { (eval echo configure:2767: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_res_state_ext=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_res_state_ext=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_res_state_ext" 1>&6 if test $ac_cv_res_state_ext = yes; then cat >> confdefs.h <<\EOF #define HAVE_RES_STATE_EXT 1 EOF fi if test "$ac_cv_res_state_ext" = no; then missing_includes=yes fi echo $ac_n "checking for nsort in res_state""... $ac_c" 1>&6 echo "configure:2793: checking for nsort in res_state" >&5 if eval "test \"`echo '$''{'ac_cv_res_state'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # include # include # include int main() { struct __res_state e; e.nsort = 0 ; return 0; } EOF if { (eval echo configure:2809: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_res_state=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_res_state=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_res_state" 1>&6 if test $ac_cv_res_state = yes; then cat >> confdefs.h <<\EOF #define HAVE_NEW_RES_STATE 1 EOF fi if test "$missing_includes" = "yes"; then CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing" V_INCLS="$V_INCLS -I\$(srcdir)/missing" fi for ac_func in vfprintf strcasecmp strlcat strlcpy strdup do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2839: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" fi done for ac_func in ether_ntohost do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2896: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2924: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 echo "configure:2944: checking for buggy ether_ntohost" >&5 if eval "test \"`echo '$''{'ac_cv_buggy_ether_ntohost'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then ac_cv_buggy_ether_ntohost=not while cross-compiling else cat > conftest.$ac_ext < #include #include #include int main(int argc, char **argv) { u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff }; char name[MAXHOSTNAMELEN]; ether_ntohost(name, (struct ether_addr *)ea); exit(0); } EOF if { (eval echo configure:2972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_buggy_ether_ntohost=no else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_buggy_ether_ntohost=yes fi rm -fr conftest* fi fi echo "$ac_t""$ac_cv_buggy_ether_ntohost" 1>&6 if test "$ac_cv_buggy_ether_ntohost" = "no"; then cat >> confdefs.h <<\EOF #define USE_ETHER_NTOHOST 1 EOF fi else echo "$ac_t""no" 1>&6 fi done for ac_func in setlinebuf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3002: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:3030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done needsnprintf=no for ac_func in vsnprintf snprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3059: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:3087: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 needsnprintf=yes fi done if test $needsnprintf = yes; then LIBOBJS="$LIBOBJS snprintf.o" fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 echo "configure:3118: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #ifdef signal #undef signal #endif #ifdef __cplusplus extern "C" void (*signal (int, void (*)(int)))(int); #else void (*signal ()) (); #endif int main() { int i; ; return 0; } EOF if { (eval echo configure:3140: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_type_signal=int fi rm -f conftest* fi echo "$ac_t""$ac_cv_type_signal" 1>&6 cat >> confdefs.h <> confdefs.h <<\EOF #define RETSIGVAL EOF else cat >> confdefs.h <<\EOF #define RETSIGVAL (0) EOF fi case "$host_os" in irix*) cat >> confdefs.h <<\EOF #define _BSD_SIGNALS 1 EOF ;; *) for ac_func in sigset do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3182: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:3210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done if test $ac_cv_func_sigset = no ; then for ac_func in sigaction do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3238: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:3266: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done fi ;; esac echo $ac_n "checking for dnet_htoa in -ldnet""... $ac_c" 1>&6 echo "configure:3295: checking for dnet_htoa in -ldnet" >&5 ac_lib_var=`echo dnet'_'dnet_htoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo dnet | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi echo $ac_n "checking for main in -lrpc""... $ac_c" 1>&6 echo "configure:3343: checking for main in -lrpc" >&5 ac_lib_var=`echo rpc'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lrpc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo rpc | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi echo $ac_n "checking for library containing getrpcbynumber""... $ac_c" 1>&6 echo "configure:3387: checking for library containing getrpcbynumber" >&5 if eval "test \"`echo '$''{'ac_cv_search_getrpcbynumber'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_func_search_save_LIBS="$LIBS" ac_cv_search_getrpcbynumber="no" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_getrpcbynumber="none required" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* test "$ac_cv_search_getrpcbynumber" = "no" && for i in nsl; do LIBS="-l$i $ac_func_search_save_LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_getrpcbynumber="-l$i" break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done LIBS="$ac_func_search_save_LIBS" fi echo "$ac_t""$ac_cv_search_getrpcbynumber" 1>&6 if test "$ac_cv_search_getrpcbynumber" != "no"; then test "$ac_cv_search_getrpcbynumber" = "none required" || LIBS="$ac_cv_search_getrpcbynumber $LIBS" else : fi # Most operating systems have gethostbyname() in the default searched # libraries (i.e. libc): # Some OSes (eg. Solaris) place it in libnsl # Some strange OSes (SINIX) have it in libsocket: echo $ac_n "checking for library containing gethostbyname""... $ac_c" 1>&6 echo "configure:3456: checking for library containing gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_search_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_func_search_save_LIBS="$LIBS" ac_cv_search_gethostbyname="no" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_gethostbyname="none required" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* test "$ac_cv_search_gethostbyname" = "no" && for i in nsl socket resolv; do LIBS="-l$i $ac_func_search_save_LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_gethostbyname="-l$i" break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done LIBS="$ac_func_search_save_LIBS" fi echo "$ac_t""$ac_cv_search_gethostbyname" 1>&6 if test "$ac_cv_search_gethostbyname" != "no"; then test "$ac_cv_search_gethostbyname" = "none required" || LIBS="$ac_cv_search_gethostbyname $LIBS" else : fi # Unfortunately libsocket sometimes depends on libnsl and # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this. if test "$ac_cv_search_gethostbyname" = "no" then echo $ac_n "checking for gethostbyname in -lsocket""... $ac_c" 1>&6 echo "configure:3521: checking for gethostbyname in -lsocket" >&5 ac_lib_var=`echo socket'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsocket -lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="-lsocket -lnsl $LIBS" else echo "$ac_t""no" 1>&6 fi fi echo $ac_n "checking for library containing socket""... $ac_c" 1>&6 echo "configure:3563: checking for library containing socket" >&5 if eval "test \"`echo '$''{'ac_cv_search_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_func_search_save_LIBS="$LIBS" ac_cv_search_socket="no" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_socket="none required" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* test "$ac_cv_search_socket" = "no" && for i in socket; do LIBS="-l$i $ac_func_search_save_LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_socket="-l$i" break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done LIBS="$ac_func_search_save_LIBS" fi echo "$ac_t""$ac_cv_search_socket" 1>&6 if test "$ac_cv_search_socket" != "no"; then test "$ac_cv_search_socket" = "none required" || LIBS="$ac_cv_search_socket $LIBS" else : echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 echo "configure:3622: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsocket -lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="-lsocket -lnsl $LIBS" else echo "$ac_t""no" 1>&6 fi fi # DLPI needs putmsg under HPUX so test for -lstr while we're at it echo $ac_n "checking for library containing putmsg""... $ac_c" 1>&6 echo "configure:3665: checking for library containing putmsg" >&5 if eval "test \"`echo '$''{'ac_cv_search_putmsg'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_func_search_save_LIBS="$LIBS" ac_cv_search_putmsg="no" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_putmsg="none required" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* test "$ac_cv_search_putmsg" = "no" && for i in str; do LIBS="-l$i $ac_func_search_save_LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_search_putmsg="-l$i" break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done LIBS="$ac_func_search_save_LIBS" fi echo "$ac_t""$ac_cv_search_putmsg" 1>&6 if test "$ac_cv_search_putmsg" != "no"; then test "$ac_cv_search_putmsg" = "none required" || LIBS="$ac_cv_search_putmsg $LIBS" else : fi LBL_LIBS="$LIBS" pfopen=/usr/examples/packetfilter/pfopen.c if test -f $pfopen ; then for ac_func in pfopen do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3733: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:3761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done if test $ac_cv_func_pfopen = "no" ; then echo "$ac_t""Using $pfopen" 1>&6 LIBS="$LIBS $pfopen" fi fi echo $ac_n "checking for local pcap library""... $ac_c" 1>&6 echo "configure:3791: checking for local pcap library" >&5 libpcap=FAIL lastdir=FAIL places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \ egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'` for dir in $places ../libpcap libpcap ; do basedir=`echo $dir | sed -e 's/[ab][0-9]*$//'` if test $lastdir = $basedir ; then continue; fi lastdir=$dir if test -r $dir/libpcap.a ; then libpcap=$dir/libpcap.a d=$dir fi done if test $libpcap = FAIL ; then echo "$ac_t""not found" 1>&6 echo $ac_n "checking for main in -lpcap""... $ac_c" 1>&6 echo "configure:3810: checking for main in -lpcap" >&5 ac_lib_var=`echo pcap'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lpcap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 libpcap="-lpcap" else echo "$ac_t""no" 1>&6 fi if test $libpcap = FAIL ; then { echo "configure: error: see the INSTALL doc for more info" 1>&2; exit 1; } fi else V_PCAPDEP=$libpcap places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'` if test -r $d/pcap.h; then V_INCLS="-I$d $V_INCLS" elif test -r $places/pcap.h; then V_INCLS="-I$places $V_INCLS" else { echo "configure: error: cannot find pcap.h" 1>&2; exit 1; } fi echo "$ac_t""$libpcap" 1>&6 fi LIBS="$libpcap $LIBS" case "$host_os" in aix*) pseexe="/lib/pse.exp" echo $ac_n "checking for $pseexe""... $ac_c" 1>&6 echo "configure:3867: checking for $pseexe" >&5 if test -f $pseexe ; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -I:$pseexe" fi ;; esac for ac_func in bpf_dump do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3878: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:3906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" fi done V_GROUP=0 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then V_GROUP=wheel fi case "$host_os" in aix*) cat >> confdefs.h <<\EOF #define _SUN 1 EOF ;; irix*) V_GROUP=sys ;; osf*) V_GROUP=system ;; solaris*) V_GROUP=sys ;; esac if test -f /dev/bpf0 ; then V_GROUP=bpf fi echo $ac_n "checking for u_int8_t using $CC""... $ac_c" 1>&6 echo "configure:3963: checking for u_int8_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int8_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # if STDC_HEADERS # include # include # endif int main() { u_int8_t i ; return 0; } EOF if { (eval echo configure:3981: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_u_int8_t=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_lbl_have_u_int8_t=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_lbl_have_u_int8_t" 1>&6 if test $ac_cv_lbl_have_u_int8_t = no ; then cat >> confdefs.h <<\EOF #define u_int8_t u_char EOF fi echo $ac_n "checking for int16_t using $CC""... $ac_c" 1>&6 echo "configure:4001: checking for int16_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_int16_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # if STDC_HEADERS # include # include # endif int main() { int16_t i ; return 0; } EOF if { (eval echo configure:4019: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_int16_t=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_lbl_have_int16_t=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_lbl_have_int16_t" 1>&6 if test $ac_cv_lbl_have_int16_t = no ; then cat >> confdefs.h <<\EOF #define int16_t short EOF fi echo $ac_n "checking for u_int16_t using $CC""... $ac_c" 1>&6 echo "configure:4039: checking for u_int16_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int16_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # if STDC_HEADERS # include # include # endif int main() { u_int16_t i ; return 0; } EOF if { (eval echo configure:4057: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_u_int16_t=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_lbl_have_u_int16_t=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_lbl_have_u_int16_t" 1>&6 if test $ac_cv_lbl_have_u_int16_t = no ; then cat >> confdefs.h <<\EOF #define u_int16_t u_short EOF fi echo $ac_n "checking for int32_t using $CC""... $ac_c" 1>&6 echo "configure:4077: checking for int32_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_int32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # if STDC_HEADERS # include # include # endif int main() { int32_t i ; return 0; } EOF if { (eval echo configure:4095: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_int32_t=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_lbl_have_int32_t=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_lbl_have_int32_t" 1>&6 if test $ac_cv_lbl_have_int32_t = no ; then cat >> confdefs.h <<\EOF #define int32_t int EOF fi echo $ac_n "checking for u_int32_t using $CC""... $ac_c" 1>&6 echo "configure:4115: checking for u_int32_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # if STDC_HEADERS # include # include # endif int main() { u_int32_t i ; return 0; } EOF if { (eval echo configure:4133: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_u_int32_t=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_lbl_have_u_int32_t=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_lbl_have_u_int32_t" 1>&6 if test $ac_cv_lbl_have_u_int32_t = no ; then cat >> confdefs.h <<\EOF #define u_int32_t u_int EOF fi rm -f os-proto.h if test "${LBL_CFLAGS+set}" = set; then V_CCOPT="$V_CCOPT ${LBL_CFLAGS}" fi if test -f .devel ; then if test "$GCC" = yes ; then if test "${LBL_CFLAGS+set}" != set; then if test "$ac_cv_prog_cc_g" = yes ; then V_CCOPT="-g $V_CCOPT" fi V_CCOPT="$V_CCOPT -Wall" if test $ac_cv_lbl_gcc_vers -gt 1 ; then V_CCOPT="$V_CCOPT -Wmissing-prototypes -Wstrict-prototypes" fi fi else case "$host_os" in irix6*) V_CCOPT="$V_CCOPT -n32" ;; *) ;; esac fi os=`echo $host_os | sed -e 's/\([0-9][0-9]*\)[^0-9].*$/\1/'` name="lbl/os-$os.h" if test -f $name ; then ln -s $name os-proto.h cat >> confdefs.h <<\EOF #define HAVE_OS_PROTO_H 1 EOF else echo "configure: warning: can't find $name" 1>&2 fi fi echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6 echo "configure:4193: checking if sockaddr struct has sa_len member" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # include int main() { u_int i = sizeof(((struct sockaddr *)0)->sa_len) ; return 0; } EOF if { (eval echo configure:4207: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_sockaddr_has_sa_len=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_lbl_sockaddr_has_sa_len=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_lbl_sockaddr_has_sa_len" 1>&6 if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then cat >> confdefs.h <<\EOF #define HAVE_SOCKADDR_SA_LEN 1 EOF fi echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6 echo "configure:4228: checking if unaligned accesses fail" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$host_cpu" in # XXX: should also check that they don't do weird things (like on arm) alpha*|arm*|hp*|mips*|sparc*|ia64) ac_cv_lbl_unaligned_fail=yes ;; *) cat >conftest.c < # include # include unsigned char a[5] = { 1, 2, 3, 4, 5 }; main() { unsigned int i; pid_t pid; int status; /* avoid "core dumped" message */ pid = fork(); if (pid < 0) exit(2); if (pid > 0) { /* parent */ pid = waitpid(pid, &status, 0); if (pid < 0) exit(3); exit(!WIFEXITED(status)); } /* child */ i = *(unsigned int *)&a[1]; printf("%d\n", i); exit(0); } EOF ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ conftest.c $LIBS >/dev/null 2>&1 if test ! -x conftest ; then ac_cv_lbl_unaligned_fail=yes else ./conftest >conftest.out if test ! -s conftest.out ; then ac_cv_lbl_unaligned_fail=yes else ac_cv_lbl_unaligned_fail=no fi fi rm -f conftest* core core.conftest ;; esac fi echo "$ac_t""$ac_cv_lbl_unaligned_fail" 1>&6 if test $ac_cv_lbl_unaligned_fail = yes ; then cat >> confdefs.h <<\EOF #define LBL_ALIGN 1 EOF fi echo $ac_n "checking for h_errno""... $ac_c" 1>&6 echo "configure:4293: checking for h_errno" >&5 if eval "test \"`echo '$''{'ac_cv_var_h_errno'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # include int main() { int foo = h_errno; ; return 0; } EOF if { (eval echo configure:4307: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_var_h_errno=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_var_h_errno=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_var_h_errno" 1>&6 if test "$ac_cv_var_h_errno" = "yes"; then cat >> confdefs.h <<\EOF #define HAVE_H_ERRNO 1 EOF fi # Check whether --with-crypto or --without-crypto was given. if test "${with_crypto+set}" = set; then withval="$with_crypto" : else echo $ac_n "checking for SSLeay""... $ac_c" 1>&6 echo "configure:4335: checking for SSLeay" >&5 ac_cv_ssleay_path=no incdir=no for dir in /usr /usr/local /usr/local/ssl /usr/pkg; do if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then ac_cv_ssleay_path=$dir fi if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then incdir="-I$dir/include" fi if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then break; else ac_cv_ssleay_path=no incdir=no fi done echo "$ac_t""$ac_cv_ssleay_path" 1>&6 if test "$ac_cv_ssleay_path" != no; then V_INCLS="$V_INCLS $incdir" LDFLAGS="-L$dir/lib $LDFLAGS" if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then LIBS="$LIBS -lRSAglue" fi if test -f $ac_cv_ssleay_path/lib/librsaref.a; then LIBS="$LIBS -lrsaref" fi echo $ac_n "checking for des_cbc_encrypt in -lcrypto""... $ac_c" 1>&6 echo "configure:4363: checking for des_cbc_encrypt in -lcrypto" >&5 ac_lib_var=`echo crypto'_'des_cbc_encrypt | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lcrypto $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo crypto | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi bak_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $V_INCLS" for ac_hdr in cast.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:4416: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:4426: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done if test "$ac_cv_header_cast_h" = "yes"; then echo $ac_n "checking for buggy CAST128""... $ac_c" 1>&6 echo "configure:4455: checking for buggy CAST128" >&5 if test "$cross_compiling" = yes; then buggy_cast128="cross-compiling, assume yes" else cat > conftest.$ac_ext < main() { unsigned char key[] = {0x01,0x23,0x45,0x67,0x12}; unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; unsigned char out[sizeof(in)]; unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E}; CAST_KEY ks; CAST_set_key(&ks, sizeof(key), key); CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT); if (memcmp(out, ok, sizeof(ok)) != 0) return 0; else return 1; } EOF if { (eval echo configure:4479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then buggy_cast128=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* buggy_cast128=no fi rm -fr conftest* fi echo "$ac_t""$buggy_cast128" 1>&6 if test "$buggy_cast128" != no; then echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine." echo "disabling CAST128 support." cat >> confdefs.h <<\EOF #define HAVE_BUGGY_CAST128 1 EOF fi fi CPPFLAGS=$bak_CPPFLAGS fi fi for ac_hdr in rc5.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:4511: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:4521: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:4566: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@host@%$host%g s%@host_alias@%$host_alias%g s%@host_cpu@%$host_cpu%g s%@host_vendor@%$host_vendor%g s%@host_os@%$host_os%g s%@SHLICC2@%$SHLICC2%g s%@CC@%$CC%g s%@CPP@%$CPP%g s%@LIBOBJS@%$LIBOBJS%g s%@V_CCOPT@%$V_CCOPT%g s%@V_GROUP@%$V_GROUP%g s%@V_INCLS@%$V_INCLS%g s%@V_PCAPDEP@%$V_PCAPDEP%g s%@LOCALSRC@%$LOCALSRC%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' ac_dC='\3' ac_dD='%g' # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='\([ ]\)%\1#\2define\3' ac_uC=' ' ac_uD='\4%g' # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_eB='$%\1#\2define\3' ac_eC=' ' ac_eD='%g' if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac echo creating $ac_file rm -f conftest.frag conftest.in conftest.out ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` cat $ac_file_inputs > conftest.in EOF # Transform confdefs.h into a sed script conftest.vals that substitutes # the proper values into config.h.in to produce config.h. And first: # Protect against being on the right side of a sed subst in config.status. # Protect against being in an unquoted here document in config.status. rm -f conftest.vals cat > conftest.hdr <<\EOF s/[\\&%]/\\&/g s%[\\$`]%\\&%g s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp s%ac_d%ac_u%gp s%ac_u%ac_e%gp EOF sed -n -f conftest.hdr confdefs.h > conftest.vals rm -f conftest.hdr # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >> conftest.vals <<\EOF s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% EOF # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail while : do ac_lines=`grep -c . conftest.vals` # grep -c gives empty output for an empty file on some AIX systems. if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi # Write a limited-size here document to conftest.frag. echo ' cat > conftest.frag <> $CONFIG_STATUS sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS echo 'CEOF sed -f conftest.frag conftest.in > conftest.out rm -f conftest.in mv conftest.out conftest.in ' >> $CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals cat >> $CONFIG_STATUS <<\EOF rm -f conftest.frag conftest.h echo "/* $ac_file. Generated automatically by configure. */" > conftest.h cat conftest.in >> conftest.h rm -f conftest.in if cmp -s $ac_file conftest.h 2>/dev/null; then echo "$ac_file is unchanged" rm -f conftest.h else # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi rm -f $ac_file mv conftest.h $ac_file fi fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF if test -f .devel; then echo timestamp > stamp-h cat Makefile-devel-adds >> Makefile make depend fi exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 exit 0 tcpdump-3.7.2/configure.in0100644000076500000240000003611707627054624014675 0ustar fennerstaffdnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.145.2.1 2002/06/28 10:48:31 guy Exp $ (LBL) dnl dnl Copyright (c) 1994, 1995, 1996, 1997 dnl The Regents of the University of California. All rights reserved. dnl dnl Process this file with autoconf to produce a configure script. dnl AC_REVISION($Revision: 1.145.2.1 $) AC_PREREQ(2.13) AC_INIT(tcpdump.c) AC_CANONICAL_HOST AC_LBL_C_INIT(V_CCOPT, V_INCLS) AC_LBL_C_INLINE AC_C___ATTRIBUTE__ AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netinet/if_ether.h) AC_HEADER_TIME case "$host_os" in linux*) AC_MSG_CHECKING(Linux kernel version) if test "$cross_compiling" = yes; then AC_CACHE_VAL(ac_cv_linux_vers, ac_cv_linux_vers=unknown) else AC_CACHE_VAL(ac_cv_linux_vers, ac_cv_linux_vers=`uname -r 2>&1 | \ sed -n -e '$s/.* //' -e '$s/\..*//p'`) fi AC_MSG_RESULT($ac_cv_linux_vers) if test $ac_cv_linux_vers = unknown ; then AC_MSG_ERROR(cannot determine linux version when cross-compiling) fi if test $ac_cv_linux_vers -lt 2 ; then AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info) fi ;; *) ;; esac AC_CHECK_HEADERS(smi.h) AC_CHECK_LIB(smi, smiInit) if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes then AC_MSG_CHECKING([whether to enable libsmi]) AC_TRY_RUN([ /* libsmi available check */ #include main() { int current, revision, age, n; const int required = 2; if (smiInit("")) exit(1); if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) exit(2); n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age); if (n != 3) exit(3); if (required < current - age || required > current) exit(4); exit(0); } ], [ AC_MSG_RESULT(yes) AC_DEFINE(LIBSMI) libsmi=yes], dnl autoconf documentation says that $? contains the exit value. dnl reality is that it does not. We leave this in just in case dnl autoconf ever comes back to match the documentation. [ case $? in 1) AC_MSG_RESULT(no - smiInit failed) ;; 2) AC_MSG_RESULT(no - header/library version mismatch) ;; 3) AC_MSG_RESULT(no - can't determine library version) ;; 4) AC_MSG_RESULT(no - too old) ;; *) AC_MSG_RESULT(no) ;; esac libsmi=no], [ AC_MSG_RESULT(not when cross-compiling) libsmi=no] ) fi AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer]) AC_ARG_ENABLE(smb, [ --enable-smb enable possibly-buggy SMB printer [default=yes] --disable-smb disable possibly-buggy SMB printer],, enableval=yes) case "$enableval" in yes) AC_MSG_RESULT(yes) AC_WARN([The SMB printer may have exploitable buffer overflows!!!]) AC_DEFINE(TCPDUMP_DO_SMB) LOCALSRC="print-smb.c smbutil.c $LOCALSRC" ;; *) AC_MSG_RESULT(no) ;; esac CFLAGS="$CFLAGS -Dss_family=__ss_family -Dss_len=__ss_len" AC_MSG_CHECKING([whether to enable ipv6]) AC_ARG_ENABLE(ipv6, [ --enable-ipv6 enable ipv6 (with ipv4) support --disable-ipv6 disable ipv6 support], [ case "$enableval" in yes) AC_MSG_RESULT(yes) LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" AC_DEFINE(INET6) ipv6=yes ;; *) AC_MSG_RESULT(no) ipv6=no ;; esac ], AC_TRY_RUN([ /* AF_INET6 available check */ #include #include main() { if (socket(AF_INET6, SOCK_STREAM, 0) < 0) exit(1); else exit(0); } ], [ AC_MSG_RESULT(yes) LOCALSRC="print-ip6.c print-ip6opts.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" AC_DEFINE(INET6) ipv6=yes], [ AC_MSG_RESULT(no) ipv6=no], [ AC_MSG_RESULT(no) ipv6=no] )) ipv6type=unknown ipv6lib=none ipv6trylibc=no if test "$ipv6" = "yes"; then AC_MSG_CHECKING([ipv6 stack type]) for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do case $i in inria) dnl http://www.kame.net/ AC_EGREP_CPP(yes, [dnl #include #ifdef IPV6_INRIA_VERSION yes #endif], [ipv6type=$i; CFLAGS="-DINET6 $CFLAGS"]) ;; kame) dnl http://www.kame.net/ AC_EGREP_CPP(yes, [dnl #include #ifdef __KAME__ yes #endif], [ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; ipv6trylibc=yes; CFLAGS="-DINET6 $CFLAGS"]) ;; linux-glibc) dnl http://www.v6.linux.or.jp/ AC_EGREP_CPP(yes, [dnl #include #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 yes #endif], [ipv6type=$i; CFLAGS="-DINET6 $CFLAGS"]) ;; linux-libinet6) dnl http://www.v6.linux.or.jp/ if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then ipv6type=$i ipv6lib=inet6 ipv6libdir=/usr/inet6/lib ipv6trylibc=yes; CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS" fi ;; toshiba) AC_EGREP_CPP(yes, [dnl #include #ifdef _TOSHIBA_INET6 yes #endif], [ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; CFLAGS="-DINET6 $CFLAGS"]) ;; v6d) AC_EGREP_CPP(yes, [dnl #include #ifdef __V6D__ yes #endif], [ipv6type=$i; ipv6lib=v6; ipv6libdir=/usr/local/v6/lib; CFLAGS="-I/usr/local/v6/include $CFLAGS"]) ;; zeta) AC_EGREP_CPP(yes, [dnl #include #ifdef _ZETA_MINAMI_INET6 yes #endif], [ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; CFLAGS="-DINET6 $CFLAGS"]) ;; esac if test "$ipv6type" != "unknown"; then break fi done AC_MSG_RESULT($ipv6type) fi if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" echo "You have $ipv6lib library, using it" else if test "$ipv6trylibc" = "yes"; then echo "You do not have $ipv6lib library, using libc" else echo 'Fatal: no $ipv6lib library found. cannot continue.' echo "You need to fetch lib$ipv6lib.a from appropriate" echo 'ipv6 kit and compile beforehand.' exit 1 fi fi fi if test "$ipv6" = "yes"; then AC_SEARCH_LIBS(getaddrinfo, socket, [dnl AC_MSG_CHECKING(getaddrinfo bug) AC_TRY_RUN([ #include #include #include #include #include main() { int passive, gaierr, inet4 = 0, inet6 = 0; struct addrinfo hints, *ai, *aitop; char straddr[INET6_ADDRSTRLEN], strport[16]; for (passive = 0; passive <= 1; passive++) { memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_flags = passive ? AI_PASSIVE : 0; hints.ai_socktype = SOCK_STREAM; if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { (void)gai_strerror(gaierr); goto bad; } for (ai = aitop; ai; ai = ai->ai_next) { if (ai->ai_addr == NULL || ai->ai_addrlen == 0 || getnameinfo(ai->ai_addr, ai->ai_addrlen, straddr, sizeof(straddr), strport, sizeof(strport), NI_NUMERICHOST|NI_NUMERICSERV) != 0) { goto bad; } switch (ai->ai_family) { case AF_INET: if (strcmp(strport, "54321") != 0) { goto bad; } if (passive) { if (strcmp(straddr, "0.0.0.0") != 0) { goto bad; } } else { if (strcmp(straddr, "127.0.0.1") != 0) { goto bad; } } inet4++; break; case AF_INET6: if (strcmp(strport, "54321") != 0) { goto bad; } if (passive) { if (strcmp(straddr, "::") != 0) { goto bad; } } else { if (strcmp(straddr, "::1") != 0) { goto bad; } } inet6++; break; case AF_UNSPEC: goto bad; break; #ifdef AF_UNIX case AF_UNIX: #else #ifdef AF_LOCAL case AF_LOCAL: #endif #endif default: /* another family support? */ break; } } } /* supported family should be 2, unsupported family should be 0 */ if (!(inet4 == 0 || inet4 == 2)) goto bad; if (!(inet6 == 0 || inet6 == 2)) goto bad; if (aitop) freeaddrinfo(aitop); exit(0); bad: if (aitop) freeaddrinfo(aitop); exit(1); } ], AC_MSG_RESULT(good) buggygetaddrinfo=no, AC_MSG_RESULT(buggy) buggygetaddrinfo=yes, AC_MSG_RESULT(buggy) buggygetaddrinfo=yes)], [buggygetaddrinfo=yes]) if test "$buggygetaddrinfo" = "yes"; then if test "$ipv6type" != "linux"; then echo 'Fatal: You must get working getaddrinfo() function.' echo ' or you can specify "--disable-ipv6"'. exit 1 else echo 'Warning: getaddrinfo() implementation on your system seems be buggy.' echo ' Better upgreade your system library to newest version' echo ' of GNU C library (aka glibc).' fi fi AC_REPLACE_FUNCS(getaddrinfo getnameinfo) fi dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton) AC_MSG_CHECKING(for inet_ntop) AC_TRY_COMPILE([#include #include #include #include ], [char src[4], dst[128]; inet_ntop(AF_INET, src, dst, sizeof(dst));], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) AC_REPLACE_FUNCS(inet_ntop)]) AC_MSG_CHECKING(for inet_pton) AC_TRY_COMPILE([#include #include #include #include ], [char src[128], dst[4]; inet_pton(AF_INET, src, dst);], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) AC_REPLACE_FUNCS(inet_pton)]) AC_MSG_CHECKING(for inet_aton) AC_TRY_COMPILE([#include #include #include ], [char src[128]; struct in_addr dst; inet_aton(src, &dst);], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) AC_REPLACE_FUNCS(inet_aton)]) dnl portability macros for getaddrinfo/getnameinfo dnl dnl Check for sa_len AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len) if test "$ac_cv_sockaddr_has_sa_len" = no; then missing_includes=yes fi dnl dnl check sizeof basic types. dnl They're very likely to be wrong for cross-compiling. AC_CHECK_SIZEOF(char, 1) AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(long, 4) dnl dnl Checks for u_intXX_t dnl AC_CHECK_BITTYPES(ac_cv_bittypes) dnl if test "$ac_cv_bittypes" = no; then dnl missing_includes=yes dnl fi dnl dnl Checks for addrinfo structure AC_STRUCT_ADDRINFO(ac_cv_addrinfo) if test "$ac_cv_addrinfo" = no; then missing_includes=yes fi dnl dnl Checks for NI_MAXSERV AC_NI_MAXSERV(ac_cv_maxserv) if test "$ac_cv_maxserv" = no; then missing_includes=yes fi dnl dnl Checks for NI_NAMEREQD AC_NI_NAMEREQD(ac_cv_namereqd) if test "$ac_cv_namereqd" = no; then missing_includes=yes fi dnl dnl Checks for sockaddr_storage structure AC_STRUCT_SA_STORAGE(ac_cv_sa_storage) if test "$ac_cv_sa_storage" = no; then missing_includes=yes fi dnl dnl Checks for IN[6]ADDRSZ AC_CHECK_ADDRSZ(ac_cv_addrsz) if test "$ac_cv_addrsz" = no; then missing_includes=yes fi dnl dnl Checks for RES_USE_INET6 AC_CHECK_RES_USE_INET6(ac_cv_res_inet6) if test "$ac_cv_res_inet6" = no; then missing_includes=yes fi dnl dnl Checks for res_state_ext structure AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext) if test "$ac_cv_res_state_ext" = no; then missing_includes=yes fi dnl dnl Checks if res_state structure has nsort member. AC_STRUCT_RES_STATE(ac_cv_res_state) dnl dnl set additional include path if necessary if test "$missing_includes" = "yes"; then CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing" V_INCLS="$V_INCLS -I\$(srcdir)/missing" fi AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup) AC_CHECK_FUNCS(ether_ntohost, [ AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [ AC_TRY_RUN([ #include #include #include #include int main(int argc, char **argv) { u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff }; char name[MAXHOSTNAMELEN]; ether_ntohost(name, (struct ether_addr *)ea); exit(0); } ], [ac_cv_buggy_ether_ntohost=no], [ac_cv_buggy_ether_ntohost=yes], [ac_cv_buggy_ether_ntohost=not while cross-compiling])]) if test "$ac_cv_buggy_ether_ntohost" = "no"; then AC_DEFINE(USE_ETHER_NTOHOST) fi ]) AC_CHECK_FUNCS(setlinebuf) needsnprintf=no AC_CHECK_FUNCS(vsnprintf snprintf,, [needsnprintf=yes]) if test $needsnprintf = yes; then LIBOBJS="$LIBOBJS snprintf.o" fi AC_LBL_TYPE_SIGNAL AC_CHECK_LIB(dnet, dnet_htoa) AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc dnl HP/UX may need -lnsl for getrpcbynumber. AC_SEARCH_LIBS(getrpcbynumber, nsl) dnl AC_CHECK_LIB(z, uncompress) dnl AC_CHECK_HEADERS(zlib.h) AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS) AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6 V_GROUP=0 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then V_GROUP=wheel fi case "$host_os" in aix*) dnl Workaround to enable certain features AC_DEFINE(_SUN) ;; irix*) V_GROUP=sys ;; osf*) V_GROUP=system ;; solaris*) V_GROUP=sys ;; esac if test -f /dev/bpf0 ; then V_GROUP=bpf fi AC_LBL_CHECK_TYPE(u_int8_t, u_char) AC_LBL_CHECK_TYPE(int16_t, short) AC_LBL_CHECK_TYPE(u_int16_t, u_short) AC_LBL_CHECK_TYPE(int32_t, int) AC_LBL_CHECK_TYPE(u_int32_t, u_int) AC_LBL_DEVEL(V_CCOPT) AC_LBL_SOCKADDR_SA_LEN AC_LBL_UNALIGNED_ACCESS AC_VAR_H_ERRNO AC_ARG_WITH(crypto, [ --without-crypto disable crypto support], [], [ AC_MSG_CHECKING(for SSLeay) ac_cv_ssleay_path=no incdir=no for dir in /usr /usr/local /usr/local/ssl /usr/pkg; do if test -d $dir/lib -a -f $dir/lib/libcrypto.a; then ac_cv_ssleay_path=$dir fi if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then incdir="-I$dir/include" fi if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then break; else ac_cv_ssleay_path=no incdir=no fi done AC_MSG_RESULT($ac_cv_ssleay_path) if test "$ac_cv_ssleay_path" != no; then V_INCLS="$V_INCLS $incdir" LDFLAGS="-L$dir/lib $LDFLAGS" if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then LIBS="$LIBS -lRSAglue" fi if test -f $ac_cv_ssleay_path/lib/librsaref.a; then LIBS="$LIBS -lrsaref" fi AC_CHECK_LIB(crypto, des_cbc_encrypt) bak_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $V_INCLS" AC_CHECK_HEADERS(cast.h) if test "$ac_cv_header_cast_h" = "yes"; then AC_MSG_CHECKING(for buggy CAST128) AC_TRY_RUN(dnl [ #include main() { unsigned char key[] = {0x01,0x23,0x45,0x67,0x12}; unsigned char in[] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; unsigned char out[sizeof(in)]; unsigned char ok[] = {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E}; CAST_KEY ks; CAST_set_key(&ks, sizeof(key), key); CAST_ecb_encrypt(in, out, &ks, CAST_ENCRYPT); if (memcmp(out, ok, sizeof(ok)) != 0) return 0; else return 1; }], [buggy_cast128=yes], [buggy_cast128=no], [buggy_cast128="cross-compiling, assume yes"]) AC_MSG_RESULT($buggy_cast128) if test "$buggy_cast128" != no; then echo "NOTE: SSLeay 0.9.0b has a bug in CAST128 en/decoding routine." echo "disabling CAST128 support." AC_DEFINE(HAVE_BUGGY_CAST128) fi fi CPPFLAGS=$bak_CPPFLAGS fi ]) AC_CHECK_HEADERS(rc5.h) AC_SUBST(V_CCOPT) AC_SUBST(V_GROUP) AC_SUBST(V_INCLS) AC_SUBST(V_PCAPDEP) AC_SUBST(LOCALSRC) AC_PROG_INSTALL AC_CONFIG_HEADER(config.h) AC_OUTPUT_COMMANDS([if test -f .devel; then echo timestamp > stamp-h cat Makefile-devel-adds >> Makefile make depend fi]) AC_OUTPUT(Makefile) exit 0 tcpdump-3.7.2/CREDITS0100644000076500000240000000642407627054621013377 0ustar fennerstaffThis file lists people who have contributed to tcpdump: The current maintainers: Bill Fenner Assar Westerlund Alexey Kuznetsov Jun-ichiro itojun Hagino Guy Harris Torsten Landschoff Michael Richardson Ken Hornstein Additional people who have contributed patches: Alfredo Andres Andrew Hintz Andrew Tridgell Arkadiusz Miskiewicz Armando L. Caro Jr. Ben Smithurst Brent L. Bates Charlie Lenahan Chris G. Demetriou Chris Jepeway Craig Rodrigues Crist J. Clark Daniel Hagerty Francisco Matias Cuenca-Acuna Frank Volf Gert Doering Gilbert Ramirez Jr. Gisle Vanem Hannes Gredler Harry Raaymakers Heinz-Ado Arnolds Hendrik Scholz Jakob Schlyter Jan Oravec Jason R. Thorpe Jefferson Ogata Jeffrey Hutzelman Jim Hutchins JINMEI Tatuya Juergen Schoenwaelder Julian Cowley Kaarthik Sivakumar Kazushi Sugyo Kelly Carmichael Ken Hornstein Kevin Steves Klaus Klein Kris Kennaway Larry Lile Lennert Buytenhek Love Hörnquist-Åstrand Maciej W. Rozycki Marc A. Lehmann Marko Kiiskila Marshall Rose Martin Husemann Michael Madore Michael Shalayeff Michael T. Stolarchuk Monroe Williams Motonori Shindo Nathan J. Williams Nathaniel Couper-Noles Nickolai Zeldovich Olaf Kirch Onno van der Linden Pascal Hennequin Pasvorn Boonmark Pekka Savola Peter Jeremy Rafal Maszkowski Rick Jones Rick Watson Roderick Schertler Sebastian Krahmer Seth Webster Timo Koskiahde Tony Li Uns Lider Wilbert de Graaf The original LBL crew: Steve McCanne Craig Leres Van Jacobson tcpdump-3.7.2/CVS/0040755000076500000240000000000007627064040013003 5ustar fennerstafftcpdump-3.7.2/CVS/Entries0100644000076500000240000002244707627064040014345 0ustar fennerstaffD/lbl//// D/missing//// /.cvsignore/1.3/Sat Jan 15 00:43:16 2000//Ttcpdump_3_7 /CREDITS/1.45.2.5/Wed Feb 26 06:07:13 2003//Ttcpdump_3_7 /FILES/1.35.2.1/Wed Feb 26 06:07:13 2003//Ttcpdump_3_7 /INSTALL/1.47.6.1/Wed Feb 26 06:07:13 2003//Ttcpdump_3_7 /LICENSE/1.1/Mon Oct 9 22:38:24 2000//Ttcpdump_3_7 /Makefile-devel-adds/1.1/Sat Jan 15 00:43:17 2000//Ttcpdump_3_7 /Makefile.in/1.260/Mon Dec 10 08:21:23 2001//Ttcpdump_3_7 /PLATFORMS/1.2/Mon Jan 21 11:16:32 2002//Ttcpdump_3_7 /TODO/1.4/Wed Jan 3 19:37:18 2001//Ttcpdump_3_7 /acconfig.h/1.17/Mon Nov 12 22:37:47 2001//Ttcpdump_3_7 /aclocal.m4/1.80.2.4/Wed Feb 26 06:07:14 2003//Ttcpdump_3_7 /addrtoname.c/1.83.4.1/Wed Feb 26 06:07:14 2003//Ttcpdump_3_7 /addrtoname.h/1.18/Mon Sep 17 21:57:51 2001//Ttcpdump_3_7 /ah.h/1.1/Fri Oct 6 11:32:18 2000//Ttcpdump_3_7 /appletalk.h/1.13/Tue Oct 3 02:54:54 2000//Ttcpdump_3_7 /arcnet.h/1.1/Tue Apr 17 08:39:18 2001//Ttcpdump_3_7 /atime.awk/1.1.1.1/Thu Oct 7 23:47:09 1999//Ttcpdump_3_7 /bootp.h/1.11/Tue Jan 9 07:39:13 2001//Ttcpdump_3_7 /bpf_dump.c/1.13/Sat Dec 9 02:58:45 2000//Ttcpdump_3_7 /chdlc.h/1.1/Mon Sep 18 05:11:43 2000//Ttcpdump_3_7 /config.guess/1.4/Sat May 5 20:53:51 2001//Ttcpdump_3_7 /config.h.in/1.35.2.1/Wed Feb 26 06:07:14 2003//Ttcpdump_3_7 /config.sub/1.4/Sat May 5 20:53:52 2001//Ttcpdump_3_7 /configure/1.73.2.4/Wed Feb 26 06:07:16 2003//Ttcpdump_3_7 /configure.in/1.145.2.1/Wed Feb 26 06:07:16 2003//Ttcpdump_3_7 /decnet.h/1.7/Tue Oct 3 02:54:55 2000//Ttcpdump_3_7 /esp.h/1.1/Fri Oct 6 11:32:18 2000//Ttcpdump_3_7 /ether.h/1.6/Mon Oct 9 03:24:24 2000//Ttcpdump_3_7 /ethertype.h/1.16/Thu Jun 21 17:56:02 2001//Ttcpdump_3_7 /extract.h/1.17/Mon Sep 17 21:57:52 2001//Ttcpdump_3_7 /fddi.h/1.9/Mon Oct 9 02:59:39 2000//Ttcpdump_3_7 /gmt2local.c/1.4.6.1/Wed Feb 26 06:07:16 2003//Ttcpdump_3_7 /gmt2local.h/1.2.1.1/Thu Oct 7 23:47:10 1999//Ttcpdump_3_7 /icmp6.h/1.11/Fri Jun 1 23:01:04 2001//Ttcpdump_3_7 /ieee802_11.h/1.3/Thu Jun 14 09:50:01 2001//Ttcpdump_3_7 /igrp.h/1.4/Sun Dec 17 23:07:49 2000//Ttcpdump_3_7 /install-sh/1.1.1.1/Thu Oct 7 23:47:10 1999//Ttcpdump_3_7 /interface.h/1.178.4.2/Wed Feb 26 06:07:16 2003//Ttcpdump_3_7 /ip.h/1.7/Tue Oct 3 09:17:40 2000//Ttcpdump_3_7 /ip6.h/1.3/Sun Dec 17 23:07:48 2000//Ttcpdump_3_7 /ipsec_doi.h/1.4/Wed Oct 4 03:00:29 2000//Ttcpdump_3_7 /ipx.h/1.4/Mon Jan 15 03:23:59 2001//Ttcpdump_3_7 /isakmp.h/1.7/Tue Oct 3 05:16:38 2000//Ttcpdump_3_7 /l2tp.h/1.5/Mon Nov 5 10:03:27 2001//Ttcpdump_3_7 /lane.h/1.3/Tue Oct 3 02:54:56 2000//Ttcpdump_3_7 /llc.h/1.13/Mon Jun 4 05:47:13 2001//Ttcpdump_3_7 /machdep.c/1.7/Wed Jun 27 05:42:04 2001//Ttcpdump_3_7 /machdep.h/1.2/Mon Jan 17 06:24:24 2000//Ttcpdump_3_7 /makemib/1.3/Mon Sep 17 22:16:52 2001//Ttcpdump_3_7 /mib.h/1.2/Sun Oct 17 21:37:11 1999//Ttcpdump_3_7 /mkdep/1.1.1.1/Thu Oct 7 23:47:10 1999//Ttcpdump_3_7 /nameser.h/1.9/Wed Jun 27 05:40:16 2001//Ttcpdump_3_7 /netbios.h/1.1.1.1/Thu Oct 7 23:47:10 1999//Ttcpdump_3_7 /nfs.h/1.4/Sat Jul 29 08:05:04 2000//Ttcpdump_3_7 /nfsfh.h/1.12/Mon Sep 17 21:57:52 2001//Ttcpdump_3_7 /ntp.h/1.4/Tue Oct 3 02:54:57 2000//Ttcpdump_3_7 /oakley.h/1.1/Sat Oct 30 05:11:10 1999//Ttcpdump_3_7 /ospf.h/1.3/Sun Dec 17 23:07:50 2000//Ttcpdump_3_7 /ospf6.h/1.3/Sun Dec 17 23:07:50 2000//Ttcpdump_3_7 /packetdat.awk/1.1.1.1/Thu Oct 7 23:47:11 1999//Ttcpdump_3_7 /parsenfsfh.c/1.23/Mon Sep 17 21:57:53 2001//Ttcpdump_3_7 /ppp.h/1.12/Sun Feb 4 02:17:55 2001//Ttcpdump_3_7 /print-802_11.c/1.6.4.1/Wed Feb 26 06:07:16 2003//Ttcpdump_3_7 /print-ah.c/1.15/Mon Sep 17 21:57:54 2001//Ttcpdump_3_7 /print-arcnet.c/1.6.4.1/Wed Feb 26 06:07:16 2003//Ttcpdump_3_7 /print-arp.c/1.51.4.2/Wed Feb 26 06:07:16 2003//Ttcpdump_3_7 /print-ascii.c/1.6/Sat Jan 29 16:47:46 2000//Ttcpdump_3_7 /print-atalk.c/1.70.2.1/Wed Feb 26 06:07:16 2003//Ttcpdump_3_7 /print-atm.c/1.21/Thu Jul 5 18:54:14 2001//Ttcpdump_3_7 /print-beep.c/1.1.2.1/Wed Feb 26 06:07:17 2003//Ttcpdump_3_7 /print-bgp.c/1.27.2.1/Wed Feb 26 06:07:17 2003//Ttcpdump_3_7 /print-bootp.c/1.60.4.2/Wed Feb 26 06:07:17 2003//Ttcpdump_3_7 /print-cdp.c/1.11/Mon Sep 17 21:57:56 2001//Ttcpdump_3_7 /print-chdlc.c/1.13/Mon Sep 17 21:57:57 2001//Ttcpdump_3_7 /print-cip.c/1.16/Sun Sep 23 21:52:38 2001//Ttcpdump_3_7 /print-cnfp.c/1.8/Mon Sep 17 21:57:58 2001//Ttcpdump_3_7 /print-decnet.c/1.33/Mon Sep 17 21:57:59 2001//Ttcpdump_3_7 /print-dhcp6.c/1.14.4.2/Wed Feb 26 06:07:17 2003//Ttcpdump_3_7 /print-domain.c/1.78/Fri Oct 19 09:00:48 2001//Ttcpdump_3_7 /print-dvmrp.c/1.21/Thu May 10 05:30:20 2001//Ttcpdump_3_7 /print-egp.c/1.28.4.1/Wed Feb 26 06:07:17 2003//Ttcpdump_3_7 /print-esp.c/1.20.4.2/Wed Feb 26 06:07:18 2003//Ttcpdump_3_7 /print-ether.c/1.65.4.1/Wed Feb 26 06:07:18 2003//Ttcpdump_3_7 /print-fddi.c/1.53.2.1/Wed Feb 26 06:07:18 2003//Ttcpdump_3_7 /print-frag6.c/1.13/Mon Sep 17 21:58:02 2001//Ttcpdump_3_7 /print-gre.c/1.13.4.1/Wed Feb 26 06:07:18 2003//Ttcpdump_3_7 /print-hsrp.c/1.2/Mon Oct 8 16:12:37 2001//Ttcpdump_3_7 /print-icmp.c/1.62.4.1/Wed Feb 26 06:07:19 2003//Ttcpdump_3_7 /print-icmp6.c/1.56.4.1/Wed Feb 26 06:07:19 2003//Ttcpdump_3_7 /print-igmp.c/1.5.4.1/Wed Feb 26 06:07:19 2003//Ttcpdump_3_7 /print-igrp.c/1.16/Fri Jun 15 22:17:32 2001//Ttcpdump_3_7 /print-ip.c/1.100.4.1/Wed Feb 26 06:07:19 2003//Ttcpdump_3_7 /print-ip6.c/1.21/Fri Nov 16 02:17:36 2001//Ttcpdump_3_7 /print-ip6opts.c/1.9/Wed May 9 02:47:26 2001//Ttcpdump_3_7 /print-ipcomp.c/1.13/Tue Dec 12 09:58:41 2000//Ttcpdump_3_7 /print-ipx.c/1.32/Mon Oct 8 21:25:20 2001//Ttcpdump_3_7 /print-isakmp.c/1.29.2.2/Wed Feb 26 06:07:19 2003//Ttcpdump_3_7 /print-isoclns.c/1.36.2.2/Wed Feb 26 06:07:20 2003//Ttcpdump_3_7 /print-krb.c/1.15/Fri Sep 29 04:58:42 2000//Ttcpdump_3_7 /print-l2tp.c/1.10.2.1/Wed Feb 26 06:07:20 2003//Ttcpdump_3_7 /print-lane.c/1.12/Thu Jul 5 18:54:15 2001//Ttcpdump_3_7 /print-lcp.c/1.9/Fri Oct 6 04:23:12 2000//Ttcpdump_3_7 /print-llc.c/1.43/Mon Oct 8 21:25:22 2001//Ttcpdump_3_7 /print-lwres.c/1.5/Tue Jun 26 06:19:05 2001//Ttcpdump_3_7 /print-mobile.c/1.7.4.1/Wed Feb 26 06:07:20 2003//Ttcpdump_3_7 /print-mpls.c/1.2.4.1/Wed Feb 26 06:07:20 2003//Ttcpdump_3_7 /print-msdp.c/1.2/Mon Dec 10 08:06:40 2001//Ttcpdump_3_7 /print-netbios.c/1.17/Fri Sep 29 04:58:43 2000//Ttcpdump_3_7 /print-nfs.c/1.89.4.2/Wed Feb 26 06:07:21 2003//Ttcpdump_3_7 /print-ntp.c/1.32.4.1/Wed Feb 26 06:07:21 2003//Ttcpdump_3_7 /print-null.c/1.41.4.1/Wed Feb 26 06:07:21 2003//Ttcpdump_3_7 /print-ospf.c/1.31/Thu Jun 28 04:34:51 2001//Ttcpdump_3_7 /print-ospf6.c/1.7/Wed May 9 01:08:03 2001//Ttcpdump_3_7 /print-pim.c/1.29.4.1/Wed Feb 26 06:07:21 2003//Ttcpdump_3_7 /print-ppp.c/1.64/Sun Sep 9 02:04:19 2001//Ttcpdump_3_7 /print-pppoe.c/1.15/Thu Jul 5 18:54:17 2001//Ttcpdump_3_7 /print-pptp.c/1.3/Wed Oct 31 08:54:31 2001//Ttcpdump_3_7 /print-radius.c/1.10.2.2/Wed Feb 26 06:07:21 2003//Ttcpdump_3_7 /print-raw.c/1.34.4.1/Wed Feb 26 06:07:21 2003//Ttcpdump_3_7 /print-rip.c/1.49/Thu May 10 05:30:22 2001//Ttcpdump_3_7 /print-ripng.c/1.10/Fri Nov 16 08:59:22 2001//Ttcpdump_3_7 /print-rt6.c/1.18/Fri Jun 15 22:17:34 2001//Ttcpdump_3_7 /print-rx.c/1.27.2.2/Wed Feb 26 06:07:22 2003//Ttcpdump_3_7 /print-sctp.c/1.7.2.1/Wed Feb 26 06:07:22 2003//Ttcpdump_3_7 /print-sl.c/1.57/Thu Jul 5 18:54:17 2001//Ttcpdump_3_7 /print-sll.c/1.6.4.1/Wed Feb 26 06:07:22 2003//Ttcpdump_3_7 /print-smb.c/1.20.2.4/Wed Feb 26 06:07:23 2003//Ttcpdump_3_7 /print-snmp.c/1.50.4.2/Wed Feb 26 06:07:23 2003//Ttcpdump_3_7 /print-stp.c/1.6.6.1/Wed Feb 26 06:07:23 2003//Ttcpdump_3_7 /print-sunrpc.c/1.39.6.1/Wed Feb 26 06:07:23 2003//Ttcpdump_3_7 /print-tcp.c/1.95/Mon Dec 10 08:21:24 2001//Ttcpdump_3_7 /print-telnet.c/1.18/Mon Sep 10 06:40:08 2001//Ttcpdump_3_7 /print-tftp.c/1.31/Sun Nov 21 09:37:03 1999//Ttcpdump_3_7 /print-timed.c/1.3/Thu May 17 18:33:23 2001//Ttcpdump_3_7 /print-token.c/1.13/Tue Sep 18 15:46:37 2001//Ttcpdump_3_7 /print-udp.c/1.101/Mon Oct 8 21:25:24 2001//Ttcpdump_3_7 /print-vjc.c/1.9/Mon Oct 9 01:53:21 2000//Ttcpdump_3_7 /print-vrrp.c/1.5/Mon Jul 23 22:27:30 2001//Ttcpdump_3_7 /print-wb.c/1.26/Wed Jun 27 05:37:19 2001//Ttcpdump_3_7 /print-zephyr.c/1.2.4.2/Wed Feb 26 06:07:23 2003//Ttcpdump_3_7 /route6d.h/1.3/Mon Oct 22 04:27:47 2001//Ttcpdump_3_7 /rx.h/1.5/Mon Oct 22 04:23:37 2001//Ttcpdump_3_7 /sctpConstants.h/1.2/Thu Jun 28 10:17:22 2001//Ttcpdump_3_7 /sctpHeader.h/1.3/Wed Aug 1 03:34:00 2001//Ttcpdump_3_7 /send-ack.awk/1.1.1.1/Thu Oct 7 23:47:12 1999//Ttcpdump_3_7 /setsignal.c/1.7/Tue Jul 11 00:49:03 2000//Ttcpdump_3_7 /setsignal.h/1.2.1.1/Thu Oct 7 23:47:13 1999//Ttcpdump_3_7 /slcompress.h/1.2/Mon Oct 9 02:03:44 2000//Ttcpdump_3_7 /slip.h/1.1/Mon Oct 9 01:53:21 2000//Ttcpdump_3_7 /sll.h/1.4/Sat Dec 23 07:52:11 2000//Ttcpdump_3_7 /smb.h/1.7/Thu Jan 17 04:38:29 2002//Ttcpdump_3_7 /smbutil.c/1.18.2.3/Wed Feb 26 06:07:24 2003//Ttcpdump_3_7 /stime.awk/1.1.1.1/Thu Oct 7 23:47:13 1999//Ttcpdump_3_7 /strcasecmp.c/1.3/Sun Jan 9 21:34:21 2000//Ttcpdump_3_7 /tcp.h/1.8/Wed May 9 01:16:57 2001//Ttcpdump_3_7 /tcpdump.1/1.114.2.7/Wed Feb 26 06:07:24 2003//Ttcpdump_3_7 /tcpdump.c/1.173/Sat Dec 22 22:12:23 2001//Ttcpdump_3_7 /telnet.h/1.3/Mon Sep 17 21:58:06 2001//Ttcpdump_3_7 /timed.h/1.3/Sun Dec 17 23:07:51 2000//Ttcpdump_3_7 /token.h/1.3/Tue Oct 3 02:55:03 2000//Ttcpdump_3_7 /udp.h/1.2/Tue Oct 3 02:55:03 2000//Ttcpdump_3_7 /util.c/1.72.2.2/Wed Feb 26 06:07:24 2003//Ttcpdump_3_7 /vfprintf.c/1.4/Sat Jul 1 03:39:12 2000//Ttcpdump_3_7 /CHANGES/1.81.2.1/Wed Feb 26 07:09:20 2003//Ttcpdump_3_7 /README/1.60.2.3/Wed Feb 26 07:09:20 2003//Ttcpdump_3_7 /VERSION/1.6.2.1/Wed Feb 26 07:09:20 2003//Ttcpdump_3_7 tcpdump-3.7.2/CVS/Entries.Log0100644000076500000240000000024607627064104015057 0ustar fennerstaffA D/debian//// A D/linux-include//// A D/packaging//// A D/tests//// A D/win32//// R D/win32//// R D/tests//// R D/packaging//// R D/linux-include//// R D/debian//// tcpdump-3.7.2/CVS/Repository0100644000076500000240000000003007423403516015072 0ustar fennerstaff/tcpdump/master/tcpdump tcpdump-3.7.2/CVS/Root0100644000076500000240000000006107423403516013642 0ustar fennerstaff:pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master tcpdump-3.7.2/CVS/Tag0100644000076500000240000000001507627054634013442 0ustar fennerstaffTtcpdump_3_7 tcpdump-3.7.2/decnet.h0100644000076500000240000003762607166245177014010 0ustar fennerstaff/* * Copyright (c) 1992, 1994, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.7 2000/10/03 02:54:55 itojun Exp $ (LBL) */ typedef u_int8_t byte[1]; /* single byte field */ typedef u_int8_t word[2]; /* 2 byte field */ typedef u_int8_t longword[4]; /* 4 bytes field */ /* * Definitions for DECNET Phase IV protocol headers */ union etheraddress { u_int8_t dne_addr[6]; /* full ethernet address */ struct { u_int8_t dne_hiord[4]; /* DECnet HIORD prefix */ u_int8_t dne_nodeaddr[2]; /* DECnet node address */ } dne_remote; }; typedef union etheraddress etheraddr; /* Ethernet address */ #define HIORD 0x000400aa /* high 32-bits of address (swapped) */ #define AREAMASK 0176000 /* mask for area field */ #define AREASHIFT 10 /* bit-offset for area field */ #define NODEMASK 01777 /* mask for node address field */ #define DN_MAXADDL 20 /* max size of DECnet address */ struct dn_naddr { u_int16_t a_len; /* length of address */ u_int8_t a_addr[DN_MAXADDL]; /* address as bytes */ }; /* * Define long and short header formats. */ struct shorthdr { byte sh_flags; /* route flags */ word sh_dst; /* destination node address */ word sh_src; /* source node address */ byte sh_visits; /* visit count */ }; struct longhdr { byte lg_flags; /* route flags */ byte lg_darea; /* destination area (reserved) */ byte lg_dsarea; /* destination subarea (reserved) */ etheraddr lg_dst; /* destination id */ byte lg_sarea; /* source area (reserved) */ byte lg_ssarea; /* source subarea (reserved) */ etheraddr lg_src; /* source id */ byte lg_nextl2; /* next level 2 router (reserved) */ byte lg_visits; /* visit count */ byte lg_service; /* service class (reserved) */ byte lg_pt; /* protocol type (reserved) */ }; union routehdr { struct shorthdr rh_short; /* short route header */ struct longhdr rh_long; /* long route header */ }; /* * Define the values of various fields in the protocol messages. * * 1. Data packet formats. */ #define RMF_MASK 7 /* mask for message type */ #define RMF_SHORT 2 /* short message format */ #define RMF_LONG 6 /* long message format */ #ifndef RMF_RQR #define RMF_RQR 010 /* request return to sender */ #define RMF_RTS 020 /* returning to sender */ #define RMF_IE 040 /* intra-ethernet packet */ #endif /* RMR_RQR */ #define RMF_FVER 0100 /* future version flag */ #define RMF_PAD 0200 /* pad field */ #define RMF_PADMASK 0177 /* pad field mask */ #define VIS_MASK 077 /* visit field mask */ /* * 2. Control packet formats. */ #define RMF_CTLMASK 017 /* mask for message type */ #define RMF_CTLMSG 01 /* control message indicator */ #define RMF_INIT 01 /* initialization message */ #define RMF_VER 03 /* verification message */ #define RMF_TEST 05 /* hello and test message */ #define RMF_L1ROUT 07 /* level 1 routing message */ #define RMF_L2ROUT 011 /* level 2 routing message */ #define RMF_RHELLO 013 /* router hello message */ #define RMF_EHELLO 015 /* endnode hello message */ #define TI_L2ROUT 01 /* level 2 router */ #define TI_L1ROUT 02 /* level 1 router */ #define TI_ENDNODE 03 /* endnode */ #define TI_VERIF 04 /* verification required */ #define TI_BLOCK 010 /* blocking requested */ #define VE_VERS 2 /* version number (2) */ #define VE_ECO 0 /* ECO number */ #define VE_UECO 0 /* user ECO number (0) */ #define P3_VERS 1 /* phase III version number (1) */ #define P3_ECO 3 /* ECO number (3) */ #define P3_UECO 0 /* user ECO number (0) */ #define II_L2ROUT 01 /* level 2 router */ #define II_L1ROUT 02 /* level 1 router */ #define II_ENDNODE 03 /* endnode */ #define II_VERIF 04 /* verification required */ #define II_NOMCAST 040 /* no multicast traffic accepted */ #define II_BLOCK 0100 /* blocking requested */ #define II_TYPEMASK 03 /* mask for node type */ #define TESTDATA 0252 /* test data bytes */ #define TESTLEN 1 /* length of transmitted test data */ /* * Define control message formats. */ struct initmsgIII /* phase III initialization message */ { byte inIII_flags; /* route flags */ word inIII_src; /* source node address */ byte inIII_info; /* routing layer information */ word inIII_blksize; /* maximum data link block size */ byte inIII_vers; /* version number */ byte inIII_eco; /* ECO number */ byte inIII_ueco; /* user ECO number */ byte inIII_rsvd; /* reserved image field */ }; struct initmsg /* initialization message */ { byte in_flags; /* route flags */ word in_src; /* source node address */ byte in_info; /* routing layer information */ word in_blksize; /* maximum data link block size */ byte in_vers; /* version number */ byte in_eco; /* ECO number */ byte in_ueco; /* user ECO number */ word in_hello; /* hello timer */ byte in_rsvd; /* reserved image field */ }; struct verifmsg /* verification message */ { byte ve_flags; /* route flags */ word ve_src; /* source node address */ byte ve_fcnval; /* function value image field */ }; struct testmsg /* hello and test message */ { byte te_flags; /* route flags */ word te_src; /* source node address */ byte te_data; /* test data image field */ }; struct l1rout /* level 1 routing message */ { byte r1_flags; /* route flags */ word r1_src; /* source node address */ byte r1_rsvd; /* reserved field */ }; struct l2rout /* level 2 routing message */ { byte r2_flags; /* route flags */ word r2_src; /* source node address */ byte r2_rsvd; /* reserved field */ }; struct rhellomsg /* router hello message */ { byte rh_flags; /* route flags */ byte rh_vers; /* version number */ byte rh_eco; /* ECO number */ byte rh_ueco; /* user ECO number */ etheraddr rh_src; /* source id */ byte rh_info; /* routing layer information */ word rh_blksize; /* maximum data link block size */ byte rh_priority; /* router's priority */ byte rh_area; /* reserved */ word rh_hello; /* hello timer */ byte rh_mpd; /* reserved */ }; struct ehellomsg /* endnode hello message */ { byte eh_flags; /* route flags */ byte eh_vers; /* version number */ byte eh_eco; /* ECO number */ byte eh_ueco; /* user ECO number */ etheraddr eh_src; /* source id */ byte eh_info; /* routing layer information */ word eh_blksize; /* maximum data link block size */ byte eh_area; /* area (reserved) */ byte eh_seed[8]; /* verification seed */ etheraddr eh_router; /* designated router */ word eh_hello; /* hello timer */ byte eh_mpd; /* (reserved) */ byte eh_data; /* test data image field */ }; union controlmsg { struct initmsg cm_init; /* initialization message */ struct verifmsg cm_ver; /* verification message */ struct testmsg cm_test; /* hello and test message */ struct l1rout cm_l1rou; /* level 1 routing message */ struct l2rout cm_l2rout; /* level 2 routing message */ struct rhellomsg cm_rhello; /* router hello message */ struct ehellomsg cm_ehello; /* endnode hello message */ }; /* Macros for decoding routing-info fields */ #define RI_COST(x) ((x)&0777) #define RI_HOPS(x) (((x)>>10)&037) /* * NSP protocol fields and values. */ #define NSP_TYPEMASK 014 /* mask to isolate type code */ #define NSP_SUBMASK 0160 /* mask to isolate subtype code */ #define NSP_SUBSHFT 4 /* shift to move subtype code */ #define MFT_DATA 0 /* data message */ #define MFT_ACK 04 /* acknowledgement message */ #define MFT_CTL 010 /* control message */ #define MFS_ILS 020 /* data or I/LS indicator */ #define MFS_BOM 040 /* beginning of message (data) */ #define MFS_MOM 0 /* middle of message (data) */ #define MFS_EOM 0100 /* end of message (data) */ #define MFS_INT 040 /* interrupt message */ #define MFS_DACK 0 /* data acknowledgement */ #define MFS_IACK 020 /* I/LS acknowledgement */ #define MFS_CACK 040 /* connect acknowledgement */ #define MFS_NOP 0 /* no operation */ #define MFS_CI 020 /* connect initiate */ #define MFS_CC 040 /* connect confirm */ #define MFS_DI 060 /* disconnect initiate */ #define MFS_DC 0100 /* disconnect confirm */ #define MFS_RCI 0140 /* retransmitted connect initiate */ #define SGQ_ACK 0100000 /* ack */ #define SGQ_NAK 0110000 /* negative ack */ #define SGQ_OACK 0120000 /* other channel ack */ #define SGQ_ONAK 0130000 /* other channel negative ack */ #define SGQ_MASK 07777 /* mask to isolate seq # */ #define SGQ_OTHER 020000 /* other channel qualifier */ #define SGQ_DELAY 010000 /* ack delay flag */ #define SGQ_EOM 0100000 /* pseudo flag for end-of-message */ #define LSM_MASK 03 /* mask for modifier field */ #define LSM_NOCHANGE 0 /* no change */ #define LSM_DONOTSEND 1 /* do not send data */ #define LSM_SEND 2 /* send data */ #define LSI_MASK 014 /* mask for interpretation field */ #define LSI_DATA 0 /* data segment or message count */ #define LSI_INTR 4 /* interrupt request count */ #define LSI_INTM 0377 /* funny marker for int. message */ #define COS_MASK 014 /* mask for flow control field */ #define COS_NONE 0 /* no flow control */ #define COS_SEGMENT 04 /* segment flow control */ #define COS_MESSAGE 010 /* message flow control */ #define COS_CRYPTSER 020 /* cryptographic services requested */ #define COS_DEFAULT 1 /* default value for field */ #define COI_MASK 3 /* mask for version field */ #define COI_32 0 /* version 3.2 */ #define COI_31 1 /* version 3.1 */ #define COI_40 2 /* version 4.0 */ #define COI_41 3 /* version 4.1 */ #define MNU_MASK 140 /* mask for session control version */ #define MNU_10 000 /* session V1.0 */ #define MNU_20 040 /* session V2.0 */ #define MNU_ACCESS 1 /* access control present */ #define MNU_USRDATA 2 /* user data field present */ #define MNU_INVKPROXY 4 /* invoke proxy field present */ #define MNU_UICPROXY 8 /* use uic-based proxy */ #define DC_NORESOURCES 1 /* no resource reason code */ #define DC_NOLINK 41 /* no link terminate reason code */ #define DC_COMPLETE 42 /* disconnect complete reason code */ #define DI_NOERROR 0 /* user disconnect */ #define DI_SHUT 3 /* node is shutting down */ #define DI_NOUSER 4 /* destination end user does not exist */ #define DI_INVDEST 5 /* invalid end user destination */ #define DI_REMRESRC 6 /* insufficient remote resources */ #define DI_TPA 8 /* third party abort */ #define DI_PROTOCOL 7 /* protocol error discovered */ #define DI_ABORT 9 /* user abort */ #define DI_LOCALRESRC 32 /* insufficient local resources */ #define DI_REMUSERRESRC 33 /* insufficient remote user resources */ #define DI_BADACCESS 34 /* bad access control information */ #define DI_BADACCNT 36 /* bad ACCOUNT information */ #define DI_CONNECTABORT 38 /* connect request cancelled */ #define DI_TIMEDOUT 38 /* remote node or user crashed */ #define DI_UNREACHABLE 39 /* local timers expired due to ... */ #define DI_BADIMAGE 43 /* bad image data in connect */ #define DI_SERVMISMATCH 54 /* cryptographic service mismatch */ #define UC_OBJREJECT 0 /* object rejected connect */ #define UC_USERDISCONNECT 0 /* user disconnect */ #define UC_RESOURCES 1 /* insufficient resources (local or remote) */ #define UC_NOSUCHNODE 2 /* unrecognized node name */ #define UC_REMOTESHUT 3 /* remote node shutting down */ #define UC_NOSUCHOBJ 4 /* unrecognized object */ #define UC_INVOBJFORMAT 5 /* invalid object name format */ #define UC_OBJTOOBUSY 6 /* object too busy */ #define UC_NETWORKABORT 8 /* network abort */ #define UC_USERABORT 9 /* user abort */ #define UC_INVNODEFORMAT 10 /* invalid node name format */ #define UC_LOCALSHUT 11 /* local node shutting down */ #define UC_ACCESSREJECT 34 /* invalid access control information */ #define UC_NORESPONSE 38 /* no response from object */ #define UC_UNREACHABLE 39 /* node unreachable */ /* * NSP message formats. */ struct nsphdr /* general nsp header */ { byte nh_flags; /* message flags */ word nh_dst; /* destination link address */ word nh_src; /* source link address */ }; struct seghdr /* data segment header */ { byte sh_flags; /* message flags */ word sh_dst; /* destination link address */ word sh_src; /* source link address */ word sh_seq[3]; /* sequence numbers */ }; struct minseghdr /* minimum data segment header */ { byte ms_flags; /* message flags */ word ms_dst; /* destination link address */ word ms_src; /* source link address */ word ms_seq; /* sequence number */ }; struct lsmsg /* link service message (after hdr) */ { byte ls_lsflags; /* link service flags */ byte ls_fcval; /* flow control value */ }; struct ackmsg /* acknowledgement message */ { byte ak_flags; /* message flags */ word ak_dst; /* destination link address */ word ak_src; /* source link address */ word ak_acknum[2]; /* acknowledgement numbers */ }; struct minackmsg /* minimum acknowledgement message */ { byte mk_flags; /* message flags */ word mk_dst; /* destination link address */ word mk_src; /* source link address */ word mk_acknum; /* acknowledgement number */ }; struct ciackmsg /* connect acknowledgement message */ { byte ck_flags; /* message flags */ word ck_dst; /* destination link address */ }; struct cimsg /* connect initiate message */ { byte ci_flags; /* message flags */ word ci_dst; /* destination link address (0) */ word ci_src; /* source link address */ byte ci_services; /* requested services */ byte ci_info; /* information */ word ci_segsize; /* maximum segment size */ }; struct ccmsg /* connect confirm message */ { byte cc_flags; /* message flags */ word cc_dst; /* destination link address */ word cc_src; /* source link address */ byte cc_services; /* requested services */ byte cc_info; /* information */ word cc_segsize; /* maximum segment size */ byte cc_optlen; /* optional data length */ }; struct cnmsg /* generic connect message */ { byte cn_flags; /* message flags */ word cn_dst; /* destination link address */ word cn_src; /* source link address */ byte cn_services; /* requested services */ byte cn_info; /* information */ word cn_segsize; /* maximum segment size */ }; struct dimsg /* disconnect initiate message */ { byte di_flags; /* message flags */ word di_dst; /* destination link address */ word di_src; /* source link address */ word di_reason; /* reason code */ byte di_optlen; /* optional data length */ }; struct dcmsg /* disconnect confirm message */ { byte dc_flags; /* message flags */ word dc_dst; /* destination link address */ word dc_src; /* source link address */ word dc_reason; /* reason code */ }; tcpdump-3.7.2/esp.h0100644000076500000240000000513507167334102013307 0ustar fennerstaff/* $NetBSD: esp.h,v 1.13 2000/09/26 08:37:38 itojun Exp $ */ /* $KAME: esp.h,v 1.15 2000/09/20 18:15:22 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * RFC1827/2406 Encapsulated Security Payload. */ #ifndef _NETINET6_ESP_H_ #define _NETINET6_ESP_H_ struct esp { u_int32_t esp_spi; /* ESP */ /*variable size, 32bit bound*/ /* Initialization Vector */ /*variable size*/ /* Payload data */ /*variable size*/ /* padding */ /*8bit*/ /* pad size */ /*8bit*/ /* next header */ /*8bit*/ /* next header */ /*variable size, 32bit bound*/ /* Authentication data (new IPsec) */ }; struct newesp { u_int32_t esp_spi; /* ESP */ u_int32_t esp_seq; /* Sequence number */ /*variable size*/ /* (IV and) Payload data */ /*variable size*/ /* padding */ /*8bit*/ /* pad size */ /*8bit*/ /* next header */ /*8bit*/ /* next header */ /*variable size, 32bit bound*/ /* Authentication data */ }; struct esptail { u_int8_t esp_padlen; /* pad length */ u_int8_t esp_nxt; /* Next header */ /*variable size, 32bit bound*/ /* Authentication data (new IPsec)*/ }; #endif /*_NETINET6_ESP_H_*/ tcpdump-3.7.2/ether.h0100644000076500000240000000475007170235150013626 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.6 2000/10/09 03:24:24 guy Exp $ (LBL) */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 */ #define ETHERMTU 1500 /* * The number of bytes in an ethernet (MAC) address. */ #define ETHER_ADDR_LEN 6 /* * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header. */ struct ether_header { u_int8_t ether_dhost[ETHER_ADDR_LEN]; u_int8_t ether_shost[ETHER_ADDR_LEN]; u_int16_t ether_type; }; /* * Length of a DEC/Intel/Xerox or 802.3 Ethernet header; note that some * compilers may pad "struct ether_header" to a multiple of 4 bytes, * for example, so "sizeof (struct ether_header)" may not give the right * answer. */ #define ETHER_HDRLEN 14 tcpdump-3.7.2/ethertype.h0100644000076500000240000000676407314432462014544 0ustar fennerstaff/* * Copyright (c) 1993, 1994, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.16 2001/06/21 17:56:02 itojun Exp $ (LBL) */ /* * Ethernet types. * * We wrap the declarations with #ifdef, so that if a file includes * , which may declare some of these, we don't * get a bunch of complaints from the C compiler about redefinitions * of these values. * * We declare all of them here so that no file has to include * if all it needs are ETHERTYPE_ values. */ #ifndef ETHERTYPE_PUP #define ETHERTYPE_PUP 0x0200 /* PUP protocol */ #endif #ifndef ETHERTYPE_IP #define ETHERTYPE_IP 0x0800 /* IP protocol */ #endif #ifndef ETHERTYPE_ARP #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */ #endif #ifndef ETHERTYPE_REVARP #define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */ #endif #ifndef ETHERTYPE_NS #define ETHERTYPE_NS 0x0600 #endif #ifndef ETHERTYPE_SPRITE #define ETHERTYPE_SPRITE 0x0500 #endif #ifndef ETHERTYPE_TRAIL #define ETHERTYPE_TRAIL 0x1000 #endif #ifndef ETHERTYPE_MOPDL #define ETHERTYPE_MOPDL 0x6001 #endif #ifndef ETHERTYPE_MOPRC #define ETHERTYPE_MOPRC 0x6002 #endif #ifndef ETHERTYPE_DN #define ETHERTYPE_DN 0x6003 #endif #ifndef ETHERTYPE_LAT #define ETHERTYPE_LAT 0x6004 #endif #ifndef ETHERTYPE_SCA #define ETHERTYPE_SCA 0x6007 #endif #ifndef ETHERTYPE_REVARP #define ETHERTYPE_REVARP 0x8035 #endif #ifndef ETHERTYPE_LANBRIDGE #define ETHERTYPE_LANBRIDGE 0x8038 #endif #ifndef ETHERTYPE_DECDNS #define ETHERTYPE_DECDNS 0x803c #endif #ifndef ETHERTYPE_DECDTS #define ETHERTYPE_DECDTS 0x803e #endif #ifndef ETHERTYPE_VEXP #define ETHERTYPE_VEXP 0x805b #endif #ifndef ETHERTYPE_VPROD #define ETHERTYPE_VPROD 0x805c #endif #ifndef ETHERTYPE_ATALK #define ETHERTYPE_ATALK 0x809b #endif #ifndef ETHERTYPE_AARP #define ETHERTYPE_AARP 0x80f3 #endif #ifndef ETHERTYPE_8021Q #define ETHERTYPE_8021Q 0x8100 #endif #ifndef ETHERTYPE_IPX #define ETHERTYPE_IPX 0x8137 #endif #ifndef ETHERTYPE_IPV6 #define ETHERTYPE_IPV6 0x86dd #endif #ifndef ETHERTYPE_PPP #define ETHERTYPE_PPP 0x880b #endif #ifndef ETHERTYPE_MPLS #define ETHERTYPE_MPLS 0x8847 #endif #ifndef ETHERTYPE_MPLS_MULTI #define ETHERTYPE_MPLS_MULTI 0x8848 #endif #ifndef ETHERTYPE_PPPOED #define ETHERTYPE_PPPOED 0x8863 #endif #ifndef ETHERTYPE_PPPOES #define ETHERTYPE_PPPOES 0x8864 #endif #ifndef ETHERTYPE_LOOPBACK #define ETHERTYPE_LOOPBACK 0x9000 #endif tcpdump-3.7.2/extract.h0100644000076500000240000000462107351470740014175 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.17 2001/09/17 21:57:52 fenner Exp $ (LBL) */ /* Network to host order macros */ #ifdef LBL_ALIGN #define EXTRACT_16BITS(p) \ ((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ (u_int16_t)*((const u_int8_t *)(p) + 1)) #define EXTRACT_32BITS(p) \ ((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ (u_int32_t)*((const u_int8_t *)(p) + 3)) #else #define EXTRACT_16BITS(p) \ ((u_int16_t)ntohs(*(const u_int16_t *)(p))) #define EXTRACT_32BITS(p) \ ((u_int32_t)ntohl(*(const u_int32_t *)(p))) #endif #define EXTRACT_24BITS(p) \ ((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ (u_int32_t)*((const u_int8_t *)(p) + 2)) /* Little endian protocol host order macros */ #define EXTRACT_LE_8BITS(p) (*(p)) #define EXTRACT_LE_16BITS(p) \ ((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ (u_int16_t)*((const u_int8_t *)(p) + 0)) #define EXTRACT_LE_32BITS(p) \ ((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ (u_int32_t)*((const u_int8_t *)(p) + 0)) tcpdump-3.7.2/fddi.h0100644000076500000240000000562007170232233013421 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.9 2000/10/09 02:59:39 guy Exp $ (LBL) */ /* * Based on Ultrix if_fddi.h */ /* * This stuff should come from a system header file, but there's no * obviously portable way to do that and it's not really going * to change from system to system (except for the padding business). */ struct fddi_header { u_char fddi_fc; /* frame control */ u_char fddi_dhost[6]; u_char fddi_shost[6]; }; /* * Length of an FDDI header; note that some compilers may pad * "struct fddi_header" to a multiple of 4 bytes, for example, so * "sizeof (struct fddi_header)" may not give the right * answer. */ #define FDDI_HDRLEN 13 /* Useful values for fddi_fc (frame control) field */ /* * FDDI Frame Control bits */ #define FDDIFC_C 0x80 /* Class bit */ #define FDDIFC_L 0x40 /* Address length bit */ #define FDDIFC_F 0x30 /* Frame format bits */ #define FDDIFC_Z 0x0f /* Control bits */ /* * FDDI Frame Control values. (48-bit addressing only). */ #define FDDIFC_VOID 0x40 /* Void frame */ #define FDDIFC_NRT 0x80 /* Nonrestricted token */ #define FDDIFC_RT 0xc0 /* Restricted token */ #define FDDIFC_SMT_INFO 0x41 /* SMT Info */ #define FDDIFC_SMT_NSA 0x4F /* SMT Next station adrs */ #define FDDIFC_MAC_BEACON 0xc2 /* MAC Beacon frame */ #define FDDIFC_MAC_CLAIM 0xc3 /* MAC Claim frame */ #define FDDIFC_LLC_ASYNC 0x50 /* Async. LLC frame */ #define FDDIFC_LLC_SYNC 0xd0 /* Sync. LLC frame */ #define FDDIFC_IMP_ASYNC 0x60 /* Implementor Async. */ #define FDDIFC_IMP_SYNC 0xe0 /* Implementor Synch. */ #define FDDIFC_SMT 0x40 /* SMT frame */ #define FDDIFC_MAC 0xc0 /* MAC frame */ #define FDDIFC_CLFF 0xF0 /* Class/Length/Format bits */ #define FDDIFC_ZZZZ 0x0F /* Control bits */ tcpdump-3.7.2/FILES0100644000076500000240000000414307627054621013140 0ustar fennerstaffCHANGES CREDITS FILES INSTALL LICENSE Makefile.in README VERSION acconfig.h aclocal.m4 addrtoname.c addrtoname.h ah.h appletalk.h arcnet.h atime.awk bootp.h bpf_dump.c chdlc.h config.guess config.h.in config.sub configure configure.in decnet.h esp.h ether.h ethertype.h extract.h fddi.h gmt2local.c gmt2local.h icmp6.h ieee802_11.h igrp.h install-sh interface.h ip.h ip6.h ipsec_doi.h ipx.h isakmp.h l2tp.h lane.h lbl/os-solaris2.h lbl/os-sunos4.h lbl/os-ultrix4.h llc.h machdep.c machdep.h makemib mib.h missing/addrinfo.h missing/addrsize.h missing/bittypes.h missing/getaddrinfo.c missing/getnameinfo.c missing/inet_aton.c missing/inet_ntop.c missing/inet_pton.c missing/resolv6.h missing/resolv_ext.h missing/snprintf.c missing/sockstorage.h missing/strdup.c missing/strlcat.c missing/strlcpy.c mkdep nameser.h netbios.h nfs.h nfsfh.h ntp.h oakley.h ospf.h ospf6.h packetdat.awk parsenfsfh.c ppp.h print-802_11.c print-ah.c print-arcnet.c print-arp.c print-ascii.c print-atalk.c print-atm.c print-bgp.c print-bootp.c print-beep.c print-cdp.c print-chdlc.c print-cip.c print-cnfp.c print-decnet.c print-dhcp6.c print-domain.c print-dvmrp.c print-egp.c print-esp.c print-ether.c print-fddi.c print-frag6.c print-gre.c print-hsrp.c print-icmp.c print-icmp6.c print-igmp.c print-igrp.c print-ip.c print-ip6.c print-ip6opts.c print-ipcomp.c print-ipx.c print-isakmp.c print-isoclns.c print-krb.c print-l2tp.c print-lane.c print-lcp.c print-llc.c print-lwres.c print-mobile.c print-mpls.c print-msdp.c print-netbios.c print-nfs.c print-ntp.c print-null.c print-ospf.c print-ospf6.c print-pim.c print-ppp.c print-pppoe.c print-pptp.c print-radius.c print-raw.c print-rip.c print-ripng.c print-rt6.c print-rx.c print-sctp.c print-sl.c print-sll.c print-smb.c print-snmp.c print-stp.c print-sunrpc.c print-tcp.c print-telnet.c print-tftp.c print-timed.c print-token.c print-udp.c print-vjc.c print-vrrp.c print-wb.c print-zephyr.c route6d.h rx.h sctpConstants.h sctpHeader.h send-ack.awk setsignal.c setsignal.h slcompress.h slip.h sll.h smb.h smbutil.c stime.awk strcasecmp.c tcp.h tcpdump.1 tcpdump.c telnet.h timed.h token.h udp.h util.c vfprintf.c tcpdump-3.7.2/gmt2local.c0100644000076500000240000000425107627054624014406 0ustar fennerstaff/* * Copyright (c) 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.4.6.1 2002/06/01 23:43:53 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #ifdef HAVE_OS_PROTO_H #include "os-proto.h" #endif #include "gmt2local.h" /* * Returns the difference between gmt and local time in seconds. * Use gmtime() and localtime() to keep things simple. */ int32_t gmt2local(time_t t) { register int dt, dir; register struct tm *gmt, *loc; struct tm sgmt; if (t == 0) t = time(NULL); gmt = &sgmt; *gmt = *gmtime(&t); loc = localtime(&t); dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 + (loc->tm_min - gmt->tm_min) * 60; /* * If the year or julian day is different, we span 00:00 GMT * and must add or subtract a day. Check the year first to * avoid problems when the julian day wraps. */ dir = loc->tm_year - gmt->tm_year; if (dir == 0) dir = loc->tm_yday - gmt->tm_yday; dt += dir * 24 * 60 * 60; return (dt); } tcpdump-3.7.2/gmt2local.h0100644000076500000240000000247206777230376014423 0ustar fennerstaff/* * Copyright (c) 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL) */ #ifndef gmt2local_h #define gmt2local_h int32_t gmt2local(time_t); #endif tcpdump-3.7.2/icmp6.h0100644000076500000240000003705007306017260013535 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.11 2001/06/01 23:01:04 itojun Exp $ (LBL) */ /* $NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp $ */ /* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_ICMP6_H_ #define _NETINET_ICMP6_H_ struct icmp6_hdr { u_int8_t icmp6_type; /* type field */ u_int8_t icmp6_code; /* code field */ u_int16_t icmp6_cksum; /* checksum field */ union { u_int32_t icmp6_un_data32[1]; /* type-specific field */ u_int16_t icmp6_un_data16[2]; /* type-specific field */ u_int8_t icmp6_un_data8[4]; /* type-specific field */ } icmp6_dataun; }; #define icmp6_data32 icmp6_dataun.icmp6_un_data32 #define icmp6_data16 icmp6_dataun.icmp6_un_data16 #define icmp6_data8 icmp6_dataun.icmp6_un_data8 #define icmp6_pptr icmp6_data32[0] /* parameter prob */ #define icmp6_mtu icmp6_data32[0] /* packet too big */ #define icmp6_id icmp6_data16[0] /* echo request/reply */ #define icmp6_seq icmp6_data16[1] /* echo request/reply */ #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */ #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */ #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */ #define ICMP6_PARAM_PROB 4 /* ip6 header bad */ #define ICMP6_ECHO_REQUEST 128 /* echo service */ #define ICMP6_ECHO_REPLY 129 /* echo reply */ #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ #define MLD6_LISTENER_QUERY 130 /* multicast listener query */ #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ #define MLD6_LISTENER_REPORT 131 /* multicast listener report */ #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ #define MLD6_LISTENER_DONE 132 /* multicast listener done */ #define ND_ROUTER_SOLICIT 133 /* router solicitation */ #define ND_ROUTER_ADVERT 134 /* router advertisment */ #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */ #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */ #define ND_REDIRECT 137 /* redirect */ #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */ #define ICMP6_WRUREQUEST 139 /* who are you request */ #define ICMP6_WRUREPLY 140 /* who are you reply */ #define ICMP6_FQDN_QUERY 139 /* FQDN query */ #define ICMP6_FQDN_REPLY 140 /* FQDN reply */ #define ICMP6_NI_QUERY 139 /* node information request */ #define ICMP6_NI_REPLY 140 /* node information reply */ /* The definitions below are experimental. TBA */ #define MLD6_MTRACE_RESP 141 /* mtrace response(to sender) */ #define MLD6_MTRACE 142 /* mtrace messages */ #define ICMP6_MAXTYPE 142 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */ #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */ #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */ #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */ #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */ #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */ #define ICMP6_NI_SUCCESS 0 /* node information successful reply */ #define ICMP6_NI_REFUSED 1 /* node information request is refused */ #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */ #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */ #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */ #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */ /* Used in kernel only */ #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */ #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */ /* * Multicast Listener Discovery */ struct mld6_hdr { struct icmp6_hdr mld6_hdr; struct in6_addr mld6_addr; /* multicast address */ }; #define mld6_type mld6_hdr.icmp6_type #define mld6_code mld6_hdr.icmp6_code #define mld6_cksum mld6_hdr.icmp6_cksum #define mld6_maxdelay mld6_hdr.icmp6_data16[0] #define mld6_reserved mld6_hdr.icmp6_data16[1] /* * Neighbor Discovery */ struct nd_router_solicit { /* router solicitation */ struct icmp6_hdr nd_rs_hdr; /* could be followed by options */ }; #define nd_rs_type nd_rs_hdr.icmp6_type #define nd_rs_code nd_rs_hdr.icmp6_code #define nd_rs_cksum nd_rs_hdr.icmp6_cksum #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] struct nd_router_advert { /* router advertisement */ struct icmp6_hdr nd_ra_hdr; u_int32_t nd_ra_reachable; /* reachable time */ u_int32_t nd_ra_retransmit; /* retransmit timer */ /* could be followed by options */ }; #define nd_ra_type nd_ra_hdr.icmp6_type #define nd_ra_code nd_ra_hdr.icmp6_code #define nd_ra_cksum nd_ra_hdr.icmp6_cksum #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] #define ND_RA_FLAG_MANAGED 0x80 #define ND_RA_FLAG_OTHER 0x40 #define ND_RA_FLAG_HOME_AGENT 0x20 /* * Router preference values based on draft-draves-ipngwg-router-selection-01. * These are non-standard definitions. */ #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */ #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */ #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] struct nd_neighbor_solicit { /* neighbor solicitation */ struct icmp6_hdr nd_ns_hdr; struct in6_addr nd_ns_target; /*target address */ /* could be followed by options */ }; #define nd_ns_type nd_ns_hdr.icmp6_type #define nd_ns_code nd_ns_hdr.icmp6_code #define nd_ns_cksum nd_ns_hdr.icmp6_cksum #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] struct nd_neighbor_advert { /* neighbor advertisement */ struct icmp6_hdr nd_na_hdr; struct in6_addr nd_na_target; /* target address */ /* could be followed by options */ }; #define nd_na_type nd_na_hdr.icmp6_type #define nd_na_code nd_na_hdr.icmp6_code #define nd_na_cksum nd_na_hdr.icmp6_cksum #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] /* netowkr endian */ #define ND_NA_FLAG_ROUTER ((u_int32_t)htonl(0x80000000)) #define ND_NA_FLAG_SOLICITED ((u_int32_t)htonl(0x40000000)) #define ND_NA_FLAG_OVERRIDE ((u_int32_t)htonl(0x20000000)) struct nd_redirect { /* redirect */ struct icmp6_hdr nd_rd_hdr; struct in6_addr nd_rd_target; /* target address */ struct in6_addr nd_rd_dst; /* destination address */ /* could be followed by options */ }; #define nd_rd_type nd_rd_hdr.icmp6_type #define nd_rd_code nd_rd_hdr.icmp6_code #define nd_rd_cksum nd_rd_hdr.icmp6_cksum #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] struct nd_opt_hdr { /* Neighbor discovery option header */ u_int8_t nd_opt_type; u_int8_t nd_opt_len; /* followed by option specific data*/ }; #define ND_OPT_SOURCE_LINKADDR 1 #define ND_OPT_TARGET_LINKADDR 2 #define ND_OPT_PREFIX_INFORMATION 3 #define ND_OPT_REDIRECTED_HEADER 4 #define ND_OPT_MTU 5 #define ND_OPT_ADVINTERVAL 7 #define ND_OPT_HOMEAGENT_INFO 8 #define ND_OPT_ROUTE_INFO 9 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */ struct nd_opt_prefix_info { /* prefix information */ u_int8_t nd_opt_pi_type; u_int8_t nd_opt_pi_len; u_int8_t nd_opt_pi_prefix_len; u_int8_t nd_opt_pi_flags_reserved; u_int32_t nd_opt_pi_valid_time; u_int32_t nd_opt_pi_preferred_time; u_int32_t nd_opt_pi_reserved2; struct in6_addr nd_opt_pi_prefix; }; #define ND_OPT_PI_FLAG_ONLINK 0x80 #define ND_OPT_PI_FLAG_AUTO 0x40 #define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/ struct nd_opt_rd_hdr { /* redirected header */ u_int8_t nd_opt_rh_type; u_int8_t nd_opt_rh_len; u_int16_t nd_opt_rh_reserved1; u_int32_t nd_opt_rh_reserved2; /* followed by IP header and data */ }; struct nd_opt_mtu { /* MTU option */ u_int8_t nd_opt_mtu_type; u_int8_t nd_opt_mtu_len; u_int16_t nd_opt_mtu_reserved; u_int32_t nd_opt_mtu_mtu; }; struct nd_opt_advinterval { /* Advertisement interval option */ u_int8_t nd_opt_adv_type; u_int8_t nd_opt_adv_len; u_int16_t nd_opt_adv_reserved; u_int32_t nd_opt_adv_interval; }; struct nd_opt_homeagent_info { /* Home Agent info */ u_int8_t nd_opt_hai_type; u_int8_t nd_opt_hai_len; u_int16_t nd_opt_hai_reserved; int16_t nd_opt_hai_preference; u_int16_t nd_opt_hai_lifetime; }; struct nd_opt_route_info { /* route info */ u_int8_t nd_opt_rti_type; u_int8_t nd_opt_rti_len; u_int8_t nd_opt_rti_prefixlen; u_int8_t nd_opt_rti_flags; u_int32_t nd_opt_rti_lifetime; /* prefix follows */ }; /* * icmp6 namelookup */ struct icmp6_namelookup { struct icmp6_hdr icmp6_nl_hdr; u_int8_t icmp6_nl_nonce[8]; int32_t icmp6_nl_ttl; #if 0 u_int8_t icmp6_nl_len; u_int8_t icmp6_nl_name[3]; #endif /* could be followed by options */ }; /* * icmp6 node information */ struct icmp6_nodeinfo { struct icmp6_hdr icmp6_ni_hdr; u_int8_t icmp6_ni_nonce[8]; /* could be followed by reply data */ }; #define ni_type icmp6_ni_hdr.icmp6_type #define ni_code icmp6_ni_hdr.icmp6_code #define ni_cksum icmp6_ni_hdr.icmp6_cksum #define ni_qtype icmp6_ni_hdr.icmp6_data16[0] #define ni_flags icmp6_ni_hdr.icmp6_data16[1] #define NI_QTYPE_NOOP 0 /* NOOP */ #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */ #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */ #define NI_QTYPE_DNSNAME 2 /* DNS Name */ #define NI_QTYPE_NODEADDR 3 /* Node Addresses */ #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */ /* network endian */ #define NI_SUPTYPE_FLAG_COMPRESS ((u_int16_t)htons(0x1)) #define NI_FQDN_FLAG_VALIDTTL ((u_int16_t)htons(0x1)) /* network endian */ #define NI_NODEADDR_FLAG_TRUNCATE ((u_int16_t)htons(0x1)) #define NI_NODEADDR_FLAG_ALL ((u_int16_t)htons(0x2)) #define NI_NODEADDR_FLAG_COMPAT ((u_int16_t)htons(0x4)) #define NI_NODEADDR_FLAG_LINKLOCAL ((u_int16_t)htons(0x8)) #define NI_NODEADDR_FLAG_SITELOCAL ((u_int16_t)htons(0x10)) #define NI_NODEADDR_FLAG_GLOBAL ((u_int16_t)htons(0x20)) #define NI_NODEADDR_FLAG_ANYCAST ((u_int16_t)htons(0x40)) /* just experimental. not in spec */ struct ni_reply_fqdn { u_int32_t ni_fqdn_ttl; /* TTL */ u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */ u_int8_t ni_fqdn_name[3]; /* XXX: alignment */ }; /* * Router Renumbering. as router-renum-08.txt */ struct icmp6_router_renum { /* router renumbering header */ struct icmp6_hdr rr_hdr; u_int8_t rr_segnum; u_int8_t rr_flags; u_int16_t rr_maxdelay; u_int32_t rr_reserved; }; #define ICMP6_RR_FLAGS_TEST 0x80 #define ICMP6_RR_FLAGS_REQRESULT 0x40 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 #define ICMP6_RR_FLAGS_SPECSITE 0x10 #define ICMP6_RR_FLAGS_PREVDONE 0x08 #define rr_type rr_hdr.icmp6_type #define rr_code rr_hdr.icmp6_code #define rr_cksum rr_hdr.icmp6_cksum #define rr_seqnum rr_hdr.icmp6_data32[0] struct rr_pco_match { /* match prefix part */ u_int8_t rpm_code; u_int8_t rpm_len; u_int8_t rpm_ordinal; u_int8_t rpm_matchlen; u_int8_t rpm_minlen; u_int8_t rpm_maxlen; u_int16_t rpm_reserved; struct in6_addr rpm_prefix; }; #define RPM_PCO_ADD 1 #define RPM_PCO_CHANGE 2 #define RPM_PCO_SETGLOBAL 3 #define RPM_PCO_MAX 4 struct rr_pco_use { /* use prefix part */ u_int8_t rpu_uselen; u_int8_t rpu_keeplen; u_int8_t rpu_ramask; u_int8_t rpu_raflags; u_int32_t rpu_vltime; u_int32_t rpu_pltime; u_int32_t rpu_flags; struct in6_addr rpu_prefix; }; #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40 /* network endian */ #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((u_int32_t)htonl(0x80000000)) #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((u_int32_t)htonl(0x40000000)) struct rr_result { /* router renumbering result message */ u_int16_t rrr_flags; u_int8_t rrr_ordinal; u_int8_t rrr_matchedlen; u_int32_t rrr_ifid; struct in6_addr rrr_prefix; }; /* network endian */ #define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002)) #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001)) #endif /* not _NETINET_ICMP6_H_ */ tcpdump-3.7.2/ieee802_11.h0100644000076500000240000001266307312104311014153 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.3 2001/06/14 09:50:01 guy Exp $ (LBL) */ /* * Copyright (c) 2001 * Fortress Technologies * Charlie Lenahan ( clenahan@fortresstech.com ) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #define IEEE802_11_FC_LEN 2 #define T_MGMT 0x0 /* management */ #define T_CTRL 0x1 /* control */ #define T_DATA 0x2 /* data */ #define T_RESV 0x3 /* reserved */ #define ST_ASSOC_REQUEST 0x0 #define ST_ASSOC_RESPONSE 0x1 #define ST_REASSOC_REQUEST 0x2 #define ST_REASSOC_RESPONSE 0x3 #define ST_PROBE_REQUEST 0x4 #define ST_PROBE_RESPONSE 0x5 /* RESERVED 0x6 */ /* RESERVED 0x7 */ #define ST_BEACON 0x8 #define ST_ATIM 0x9 #define ST_DISASSOC 0xA #define ST_AUTH 0xB #define ST_DEAUTH 0xC /* RESERVED 0xD */ /* RESERVED 0xE */ /* RESERVED 0xF */ #define CTRL_PS_POLL 0xA #define CTRL_RTS 0xB #define CTRL_CTS 0xC #define CTRL_ACK 0xD #define CTRL_CF_END 0xE #define CTRL_END_ACK 0xF /* * Bits in the frame control field. */ #define FC_VERSION(fc) ((fc) & 0x3) #define FC_TYPE(fc) (((fc) >> 2) & 0x3) #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF) #define FC_TO_DS(fc) ((fc) & 0x0100) #define FC_FROM_DS(fc) ((fc) & 0x0200) #define FC_MORE_FLAG(fc) ((fc) & 0x0400) #define FC_RETRY(fc) ((fc) & 0x0800) #define FC_POWER_MGMT(fc) ((fc) & 0x1000) #define FC_MORE_DATA(fc) ((fc) & 0x2000) #define FC_WEP(fc) ((fc) & 0x4000) #define FC_ORDER(fc) ((fc) & 0x8000) struct mgmt_header_t { u_int16_t fc; u_int16_t duration; u_int8_t da[6]; u_int8_t sa[6]; u_int8_t bssid[6]; u_int16_t seq_ctrl; }; #define MGMT_HEADER_LEN (2+2+6+6+6+2) #define CAPABILITY_ESS(cap) ((cap) & 0x0001) #define CAPABILITY_IBSS(cap) ((cap) & 0x0002) #define CAPABILITY_CFP(cap) ((cap) & 0x0004) #define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008) #define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010) struct ssid_t { u_int8_t element_id; u_int8_t length; u_char ssid[33]; /* 32 + 1 for null */ } ; struct rates_t { u_int8_t element_id; u_int8_t length; u_int8_t rate[8]; }; struct challenge_t { u_int8_t element_id; u_int8_t length; u_int8_t text[254]; /* 1-253 + 1 for null */ }; struct fh_t { u_int8_t element_id; u_int8_t length; u_int16_t dwell_time; u_int8_t hop_set; u_int8_t hop_pattern; u_int8_t hop_index; }; struct ds_t { u_int8_t element_id; u_int8_t length; u_int8_t channel; }; struct cf_t { u_int8_t element_id; u_int8_t length; u_int8_t count; u_int8_t period; u_int16_t max_duration; u_int16_t dur_remaing; }; struct tim_t { u_int8_t element_id; u_int8_t length; u_int8_t count; u_int8_t period; u_int8_t bitmap_control; u_int8_t bitmap[251]; }; #define E_SSID 0 #define E_RATES 1 #define E_FH 2 #define E_DS 3 #define E_CF 4 #define E_TIM 5 #define E_IBSS 6 /* reserved 7 */ /* reserved 8 */ /* reserved 9 */ /* reserved 10 */ /* reserved 11 */ /* reserved 12 */ /* reserved 13 */ /* reserved 14 */ /* reserved 15 */ /* reserved 16 */ #define E_CHALLENGE 16 /* reserved 17 */ /* reserved 18 */ /* reserved 19 */ /* reserved 16 */ /* reserved 16 */ struct mgmt_body_t { u_int8_t timestamp[8]; u_int16_t beacon_interval; u_int16_t listen_interval; u_int16_t status_code; u_int16_t aid; u_char ap[6]; u_int16_t reason_code; u_int16_t auth_alg; u_int16_t auth_trans_seq_num; struct challenge_t challenge; u_int16_t capability_info; struct ssid_t ssid; struct rates_t rates; struct ds_t ds; struct cf_t cf; struct fh_t fh; struct tim_t tim; }; struct ctrl_rts_t { u_int16_t fc; u_int16_t duration; u_int8_t ra[6]; u_int8_t ta[6]; u_int8_t fcs[4]; }; #define CTRL_RTS_LEN (2+2+6+6+4) struct ctrl_cts_t { u_int16_t fc; u_int16_t duration; u_int8_t ra[6]; u_int8_t fcs[4]; }; #define CTRL_CTS_LEN (2+2+6+4) struct ctrl_ack_t { u_int16_t fc; u_int16_t duration; u_int8_t ra[6]; u_int8_t fcs[4]; }; #define CTRL_ACK_LEN (2+2+6+4) struct ctrl_ps_poll_t { u_int16_t fc; u_int16_t aid; u_int8_t bssid[6]; u_int8_t ta[6]; u_int8_t fcs[4]; }; #define CTRL_PS_POLL_LEN (2+2+6+6+4) struct ctrl_end_t { u_int16_t fc; u_int16_t duration; u_int8_t ra[6]; u_int8_t bssid[6]; u_int8_t fcs[4]; }; #define CTRL_END_LEN (2+2+6+6+4) struct ctrl_end_ack_t { u_int16_t fc; u_int16_t duration; u_int8_t ra[6]; u_int8_t bssid[6]; u_int8_t fcs[4]; }; #define CTRL_END_ACK_LEN (2+2+6+6+4) #define IV_IV(iv) ((iv) & 0xFFFFFF) #define IV_PAD(iv) (((iv) >> 24) & 0x3F) #define IV_KEYID(iv) (((iv) >> 30) & 0x03) tcpdump-3.7.2/igrp.h0100644000076500000240000000211707217243505013460 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.4 2000/12/17 23:07:49 guy Exp $ (LBL) */ /* Cisco IGRP definitions */ /* IGRP Header */ struct igrphdr { u_int8_t ig_vop; /* protocol version number / opcode */ #define IGRP_V(x) (((x) & 0xf0) >> 4) #define IGRP_OP(x) ((x) & 0x0f) u_int8_t ig_ed; /* edition number */ u_int16_t ig_as; /* autonomous system number */ u_int16_t ig_ni; /* number of subnet in local net */ u_int16_t ig_ns; /* number of networks in AS */ u_int16_t ig_nx; /* number of networks ouside AS */ u_int16_t ig_sum; /* checksum of IGRP header & data */ }; #define IGRP_UPDATE 1 #define IGRP_REQUEST 2 /* IGRP routing entry */ struct igrprte { u_int8_t igr_net[3]; /* 3 significant octets of IP address */ u_int8_t igr_dly[3]; /* delay in tens of microseconds */ u_int8_t igr_bw[3]; /* bandwidth in units of 1 kb/s */ u_int8_t igr_mtu[2]; /* MTU in octets */ u_int8_t igr_rel; /* percent packets successfully tx/rx */ u_int8_t igr_ld; /* percent of channel occupied */ u_int8_t igr_hct; /* hop count */ }; #define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */ tcpdump-3.7.2/INSTALL0100644000076500000240000002241107627054621013402 0ustar fennerstaff@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.47.6.1 2002/07/16 04:41:57 guy Exp $ (LBL) If you have not built libpcap, do so first. See the README file in this directory for the ftp location. You will need an ANSI C compiler to build tcpdump. The configure script will abort if your compiler is not ANSI compliant. If this happens, use the GNU C compiler, available via anonymous ftp: ftp://ftp.gnu.org/pub/gnu/gcc/ After libpcap has been built (either install it with "make install" or make sure both the libpcap and tcpdump source trees are in the same directory), run ./configure (a shell script). "configure" will determine your system attributes and generate an appropriate Makefile from Makefile.in. Now build tcpdump by running "make". If everything builds ok, su and type "make install". This will install tcpdump and the manual entry. By default, tcpdump is installed with group execute permissions. The group used depends on your os. In addition, BPF packet access is controlled by permissions to /dev/bpf0. In any case, DO NOT give untrusted users the capability of running tcpdump. Tcpdump can capture any traffic on your net, including passwords. Note that most systems ship tcpdump, but usually an older version. Remember to remove or rename the installed binary when upgrading. If you use Linux, this version of libpcap is known to compile and run with 2.0.25 and more modern, and 2.2 and later, kernels. It is guaranteed not to work with 1.X kernels. If your system is not one which we have tested tcpdump on, you may have to modify the configure script and Makefile.in. Please send us patches for any modifications you need to make. Please see "PLATFORMS" for notes about tested platforms. FILES ----- CHANGES - description of differences between releases CREDITS - people that have helped tcpdump along FILES - list of files exported as part of the distribution INSTALL - this file LICENSE - the license under which tcpdump is distributed Makefile.in - compilation rules (input to the configure script) README - description of distribution VERSION - version of this release acconfig.h - autoconf input aclocal.m4 - autoconf macros addrtoname.c - address to hostname routines addrtoname.h - address to hostname definitions ah.h - IPSEC Authentication Header definitions appletalk.h - AppleTalk definitions arcnet.h - ARCNET definitions atime.awk - TCP ack awk script bootp.h - BOOTP definitions bpf_dump.c - BPF program printing routines, in case libpcap doesn't have them chdlc.h - Cisco HDLC definitions config.guess - autoconf support config.h.in - autoconf input config.sub - autoconf support configure - configure script (run this first) configure.in - configure script source decnet.h - DECnet definitions esp.h - IPSEC Encapsulating Security Payload definitions ether.h - Ethernet definitions ethertype.h - Ethernet type value definitions extract.h - alignment definitions fddi.h - Fiber Distributed Data Interface definitions gmt2local.c - time conversion routines gmt2local.h - time conversion prototypes icmp6.h - ICMPv6 definitiions ieee802_11.h - IEEE 802.11 definitions igrp.h - Interior Gateway Routing Protocol definitions install-sh - BSD style install script interface.h - globals, prototypes and definitions ip.h - IP definitions ip6.h - IPv6 definitions ipsec_doi.h - ISAKMP packet definitions - RFC2407 ipx.h - IPX definitions isakmp.h - ISAKMP packet definitions - RFC2408 l2tp.h - Layer Two Tunneling Protocol definitions lane.h - ATM LANE definitions lbl/os-*.h - OS-dependent defines and prototypes llc.h - LLC definitions machdep.c - machine dependent routines machdep.h - machine dependent definitions makemib - mib to header script mib.h - mib definitions missing/* - replacements for missing library functions mkdep - construct Makefile dependency list nameser.h - DNS definitions netbios.h - NETBIOS definitions nfs.h - Network File System V2 definitions nfsfh.h - Network File System file handle definitions ntp.h - Network Time Protocol definitions oakley.h - ISAKMP packet definitions - RFC2409 ospf.h - Open Shortest Path First definitions ospf6.h - IPv6 Open Shortest Path First definitions packetdat.awk - TCP chunk summary awk script parsenfsfh.c - Network File System file parser routines ppp.h - Point to Point Protocol definitions print-802_11.c - IEEE 802.11 printer routines print-ah.c - IPSEC Authentication Header printer routines print-arcnet.c - ARCNET printer routines print-arp.c - Address Resolution Protocol printer routines print-ascii.c - ASCII packet dump routines print-atalk.c - AppleTalk printer routines print-atm.c - ATM printer routines print-bgp.c - Border Gateway Protocol printer routines print-bootp.c - BOOTP and IPv4 DHCP printer routines print-beep.c - BEEP printer routines print-cdp.c - Cisco Discovery Protocol printer routines print-chdlc.c - Cisco HDLC printer routines print-cip.c - Classical-IP over ATM routines print-cnfp.c - Cisco NetFlow printer routines print-decnet.c - DECnet printer routines print-dhcp6.c - IPv6 DHCP printer routines print-domain.c - Domain Name System printer routines print-dvmrp.c - Distance Vector Multicast Routing Protocol printer routines print-egp.c - External Gateway Protocol printer routines print-esp.c - IPSEC Encapsulating Security Payload printer routines print-ether.c - Ethernet printer routines print-fddi.c - Fiber Distributed Data Interface printer routines print-frag6.c - IPv6 fragmentation header printer routines print-gre.c - Generic Routing Encapsulation printer routines print-hsrp.c - Cisco Hot Standby Router Protocol printer routines print-icmp.c - Internet Control Message Protocol printer routines print-icmp6.c - IPv6 Internet Control Message Protocol printer routines print-igmp.c - Internet Group Management Protocol printer routines print-igrp.c - Interior Gateway Routing Protocol printer routines print-ip.c - IP printer routines print-ip6.c - IPv6 printer routines print-ip6opts.c - IPv6 header option printer routines print-ipcomp.c - IP Payload Compression Protocol printer routines print-ipx.c - IPX printer routines print-isakmp.c - Internet Security Association and Key Management Protocol print-isoclns.c - ISO CLNS, ESIS, and ISIS printer routines print-krb.c - Kerberos printer routines print-l2tp.c - Layer Two Tunneling Protocol printer routines print-lane.c - ATM LANE printer routines print-lcp.c - PPP Link Control Protocol printer routines print-llc.c - IEEE 802.2 LLC printer routines print-lwres.c - Lightweight Resolver protocol printer routines print-mobile.c - IPv4 mobility printer routines print-mpls.c - Multi-Protocol Label Switching printer routines print-msdp.c - Multicast Source Discovery Protocol printer routines print-netbios.c - NetBIOS frame protocol printer routines print-nfs.c - Network File System printer routines print-ntp.c - Network Time Protocol printer routines print-null.c - BSD loopback device printer routines print-ospf.c - Open Shortest Path First printer routines print-ospf6.c - IPv6 Open Shortest Path First printer routines print-pim.c - Protocol Independent Multicast printer routines print-ppp.c - Point to Point Protocol printer routines print-pppoe.c - PPP-over-Ethernet printer routines print-pptp.c - Point-to-Point Tunnelling Protocol printer routines print-radius.c - Radius protocol printer routines print-raw.c - Raw IP printer routines print-rip.c - Routing Information Protocol printer routines print-ripng.c - IPv6 Routing Information Protocol printer routines print-rt6.c - IPv6 routing header printer routines print-rx.c - AFS RX printer routines print-sctp.c - Stream Control Transmission Protocol printer routines print-sl.c - Compressed Serial Line Internet Protocol printer routines print-sll.c - Linux "cooked" capture printer routines print-smb.c - SMB/CIFS printer routines print-snmp.c - Simple Network Management Protocol printer routines print-stp.c - IEEE 802.1d spanning tree protocol printer routines print-sunrpc.c - Sun Remote Procedure Call printer routines print-tcp.c - TCP printer routines print-telnet.c - Telnet option printer routines print-tftp.c - Trivial File Transfer Protocol printer routines print-timed.c - BSD time daemon protocol printer routines print-token.c - Token Ring printer routines print-udp.c - UDP printer routines print-vjc.c - PPP Van Jacobson compression (RFC1144) printer routines print-vrrp.c - Virtual Router Redundancy Protocol print-wb.c - White Board printer routines print-zephyr.c - Zephyr printer routines route6d.h - packet definition for IPv6 Routing Information Protocol rx.h - AFS RX definitions sctpConstants.h - Stream Control Transmission Protocol constant definitions sctpHeader.h - Stream Control Transmission Protocol packet definitions send-ack.awk - unidirectional tcp send/ack awk script setsignal.c - OS-independent signal routines setsignal.h - OS-independent signal prototypes slcompress.h - SLIP/PPP Van Jacobson compression (RFC1144) definitions slip.h - SLIP definitions sll.h - Linux "cooked" capture definitions smb.h - SMB/CIFS definitions smbutil.c - SMB/CIFS utility routines stime.awk - TCP send awk script strcasecmp.c - missing routine tcp.h - TCP definitions tcpdump.1 - manual entry tcpdump.c - main program telnet.h - Telnet definitions timed.h - BSD time daemon protocol definitions token.h - Token Ring definitions udp.h - UDP definitions util.c - utility routines vfprintf.c - emulation routine tcpdump-3.7.2/install-sh0100755000076500000240000001272106777230376014370 0ustar fennerstaff#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 tcpdump-3.7.2/interface.h0100644000076500000240000003044607627054624014474 0ustar fennerstaff/* * Copyright (c) 1988-2002 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.178.4.2 2002/07/10 07:32:17 guy Exp $ (LBL) */ #ifndef tcpdump_interface_h #define tcpdump_interface_h #ifdef HAVE_OS_PROTO_H #include "os-proto.h" #endif #include #include #ifndef HAVE___ATTRIBUTE__ #define __attribute__(x) #endif /* snprintf et al */ #include #if !defined(HAVE_SNPRINTF) int snprintf(char *, size_t, const char *, ...) __attribute__((format(printf, 3, 4))); #endif #if !defined(HAVE_VSNPRINTF) int vsnprintf(char *, size_t, const char *, va_list) __attribute__((format(printf, 3, 0))); #endif #ifndef HAVE_STRLCAT extern size_t strlcat(char *, const char *, size_t); #endif #ifndef HAVE_STRLCPY extern size_t strlcpy(char *, const char *, size_t); #endif #ifndef HAVE_STRDUP extern char *strdup(const char *); #endif struct tok { int v; /* value */ const char *s; /* string */ }; extern int aflag; /* translate network and broadcast addresses */ extern int dflag; /* print filter code */ extern int eflag; /* print ethernet header */ extern int fflag; /* don't translate "foreign" IP address */ extern int nflag; /* leave addresses as numbers */ extern int Nflag; /* remove domains from printed host names */ extern int qflag; /* quick (shorter) output */ extern int Rflag; /* print sequence # field in AH/ESP*/ extern int sflag; /* use the libsmi to translate OIDs */ extern int Sflag; /* print raw TCP sequence numbers */ extern int tflag; /* print packet arrival time */ extern int uflag; /* Print undecoded NFS handles */ extern int vflag; /* verbose */ extern int xflag; /* print packet in hex */ extern int Xflag; /* print packet in hex/ascii */ extern char *espsecret; extern int packettype; /* as specified by -T */ #define PT_VAT 1 /* Visual Audio Tool */ #define PT_WB 2 /* distributed White Board */ #define PT_RPC 3 /* Remote Procedure Call */ #define PT_RTP 4 /* Real-Time Applications protocol */ #define PT_RTCP 5 /* Real-Time Applications control protocol */ #define PT_SNMP 6 /* Simple Network Management Protocol */ #define PT_CNFP 7 /* Cisco NetFlow protocol */ #ifndef min #define min(a,b) ((a)>(b)?(b):(a)) #endif #ifndef max #define max(a,b) ((b)>(a)?(b):(a)) #endif /* * The default snapshot length. This value allows most printers to print * useful information while keeping the amount of unwanted data down. */ #ifndef INET6 #define DEFAULT_SNAPLEN 68 /* ether + IPv4 + TCP + 14 */ #else #define DEFAULT_SNAPLEN 96 /* ether + IPv6 + TCP + 22 */ #endif #ifndef BIG_ENDIAN #define BIG_ENDIAN 4321 #define LITTLE_ENDIAN 1234 #endif #define ESRC(ep) ((ep)->ether_shost) #define EDST(ep) ((ep)->ether_dhost) #ifndef NTOHL #define NTOHL(x) (x) = ntohl(x) #define NTOHS(x) (x) = ntohs(x) #define HTONL(x) (x) = htonl(x) #define HTONS(x) (x) = htons(x) #endif #endif extern char *program_name; /* used to generate self-identifying messages */ extern int32_t thiszone; /* seconds offset from gmt to local time */ extern int snaplen; /* global pointers to beginning and end of current packet (during printing) */ extern const u_char *packetp; extern const u_char *snapend; /* * True if "l" bytes of "var" were captured. * * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large * that "snapend - (l)" underflows. * * The check is for <= rather than < because "l" might be 0. */ #define TTEST2(var, l) (snapend - (l) <= snapend && \ (const u_char *)&(var) <= snapend - (l)) /* True if "var" was captured */ #define TTEST(var) TTEST2(var, sizeof(var)) /* Bail if "l" bytes of "var" were not captured */ #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc /* Bail if "var" was not captured */ #define TCHECK(var) TCHECK2(var, sizeof(var)) extern void ts_print(const struct timeval *); extern void relts_print(int); extern int fn_print(const u_char *, const u_char *); extern int fn_printn(const u_char *, u_int, const u_char *); extern const char *tok2str(const struct tok *, const char *, int); extern const char *tok2strary_internal(const char **, int, const char *, int); #define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i) extern const char *dnaddr_string(u_short); extern void info(int); extern int infodelay; extern int infoprint; extern void error(const char *, ...) __attribute__((noreturn, format (printf, 1, 2))); extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2))); extern char *read_infile(char *); extern char *copy_argv(char **); extern void safeputchar(int); extern void safeputs(const char *); extern const char *isonsap_string(const u_char *); extern const char *llcsap_string(u_char); extern const char *protoid_string(const u_char *); extern const char *ipxsap_string(u_short); extern const char *dnname_string(u_short); extern const char *dnnum_string(u_short); /* The printer routines. */ #include extern void ascii_print_with_offset(const u_char *, u_int, u_int); extern void ascii_print(const u_char *, u_int); extern void hex_print_with_offset(const u_char *, u_int, u_int); extern void telnet_print(const u_char *, u_int); extern void hex_print(const u_char *, u_int); extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *); extern int llc_print(const u_char *, u_int, u_int, const u_char *, const u_char *, u_short *); extern void aarp_print(const u_char *, u_int); extern void arp_print(const u_char *, u_int, u_int); extern void atalk_print(const u_char *, u_int); extern void atm_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void bootp_print(const u_char *, u_int, u_short, u_short); extern void bgp_print(const u_char *, int); extern void beep_print(const u_char *, u_int); extern void cnfp_print(const u_char *, u_int, const u_char *); extern void decnet_print(const u_char *, u_int, u_int); extern void default_print(const u_char *, u_int); extern void default_print_unaligned(const u_char *, u_int); extern void dvmrp_print(const u_char *, u_int); extern void egp_print(const u_char *, u_int, const u_char *); extern void arcnet_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void ether_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void token_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void fddi_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void ieee802_11_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void gre_print(const u_char *, u_int); extern void icmp_print(const u_char *, u_int, const u_char *); extern void igmp_print(const u_char *, u_int); extern void igrp_print(const u_char *, u_int, const u_char *); extern void ip_print(const u_char *, u_int); extern void ipN_print(const u_char *, u_int); extern void ipx_print(const u_char *, u_int); extern void isoclns_print(const u_char *, u_int, u_int, const u_char *, const u_char *); extern void krb_print(const u_char *, u_int); extern void llap_print(const u_char *, u_int); extern void ltalk_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void msdp_print(const unsigned char *, u_int); extern void nfsreply_print(const u_char *, u_int, const u_char *); extern void nfsreq_print(const u_char *, u_int, const u_char *); extern void ns_print(const u_char *, u_int); extern void ntp_print(const u_char *, u_int); extern void null_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void ospf_print(const u_char *, u_int, const u_char *); extern void pimv1_print(const u_char *, u_int); extern void cisco_autorp_print(const u_char *, u_int); extern void mobile_print(const u_char *, u_int); extern void pim_print(const u_char *, u_int); extern void pppoe_print(const u_char *, u_int); extern void ppp_print(register const u_char *, u_int); extern void ppp_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void ppp_hdlc_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void ppp_bsdos_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void pppoe_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern int vjc_print(register const char *, register u_int, u_short); extern void raw_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void rip_print(const u_char *, u_int); extern void sl_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void lane_if_print(u_char *, const struct pcap_pkthdr *,const u_char *); extern void cip_if_print(u_char *, const struct pcap_pkthdr *,const u_char *); extern void sl_bsdos_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void chdlc_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void chdlc_print(register const u_char *, u_int, u_int); extern void sll_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void snmp_print(const u_char *, u_int); extern void sunrpcrequest_print(const u_char *, u_int, const u_char *); extern void tcp_print(const u_char *, u_int, const u_char *, int); extern void tftp_print(const u_char *, u_int); extern void timed_print(const u_char *, u_int); extern void udp_print(const u_char *, u_int, const u_char *, int); extern void wb_print(const void *, u_int); extern int ah_print(register const u_char *, register const u_char *); extern int esp_print(register const u_char *, register const u_char *, int *, int *); extern void isakmp_print(const u_char *, u_int, const u_char *); extern int ipcomp_print(register const u_char *, register const u_char *, int *); extern void rx_print(register const u_char *, int, int, int, u_char *); extern void netbeui_print(u_short, const u_char *, int); extern void ipx_netbios_print(const u_char *, u_int); extern void nbt_tcp_print(const u_char *, int); extern void nbt_udp137_print(const u_char *, int); extern void nbt_udp138_print(const u_char *, int); extern char *smb_errstr(int, int); extern void print_data(const unsigned char *, int); extern void l2tp_print(const u_char *, u_int); extern void lcp_print(const u_char *, u_int); extern void vrrp_print(const u_char *, u_int, int); extern void cdp_print(const u_char *, u_int, u_int, const u_char *, const u_char *); extern void stp_print(const u_char *, u_int); extern void radius_print(const u_char *, u_int); extern void lwres_print(const u_char *, u_int); extern void pptp_print(const u_char *, u_int); extern void sctp_print(const u_char *, const u_char *, u_int); extern void mpls_print(const u_char *, u_int); extern void zephyr_print(const u_char *, int); extern void hsrp_print(const u_char *, u_int); #ifdef INET6 extern void ip6_print(const u_char *, u_int); extern void ip6_opt_print(const u_char *, int); extern int hbhopt_print(const u_char *); extern int dstopt_print(const u_char *); extern int frag6_print(const u_char *, const u_char *); extern void icmp6_print(const u_char *, const u_char *); extern void ripng_print(const u_char *, unsigned int); extern int rt6_print(const u_char *, const u_char *); extern void ospf6_print(const u_char *, u_int); extern void dhcp6_print(const u_char *, u_int, u_int16_t, u_int16_t); #endif /*INET6*/ extern u_short in_cksum(const u_short *, register u_int, int); #ifndef HAVE_BPF_DUMP struct bpf_program; extern void bpf_dump(struct bpf_program *, int); #endif tcpdump-3.7.2/ip.h0100644000076500000240000001314507166322064013133 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.7 2000/10/03 09:17:40 guy Exp $ (LBL) */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ip.h 8.2 (Berkeley) 6/1/94 */ /* * Definitions for internet protocol version 4. * Per RFC 791, September 1981. */ #define IPVERSION 4 /* * Structure of an internet header, naked of options. * * We declare ip_len and ip_off to be short, rather than u_short * pragmatically since otherwise unsigned comparisons can result * against negative integers quite easily, and fail in subtle ways. */ struct ip { u_int8_t ip_vhl; /* header length, version */ #define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4) #define IP_HL(ip) ((ip)->ip_vhl & 0x0f) u_int8_t ip_tos; /* type of service */ u_int16_t ip_len; /* total length */ u_int16_t ip_id; /* identification */ u_int16_t ip_off; /* fragment offset field */ #define IP_DF 0x4000 /* dont fragment flag */ #define IP_MF 0x2000 /* more fragments flag */ #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ u_int8_t ip_ttl; /* time to live */ u_int8_t ip_p; /* protocol */ u_int16_t ip_sum; /* checksum */ struct in_addr ip_src,ip_dst; /* source and dest address */ }; #define IP_MAXPACKET 65535 /* maximum packet size */ /* * Definitions for IP type of service (ip_tos) */ #define IPTOS_LOWDELAY 0x10 #define IPTOS_THROUGHPUT 0x08 #define IPTOS_RELIABILITY 0x04 /* * Definitions for IP precedence (also in ip_tos) (hopefully unused) */ #define IPTOS_PREC_NETCONTROL 0xe0 #define IPTOS_PREC_INTERNETCONTROL 0xc0 #define IPTOS_PREC_CRITIC_ECP 0xa0 #define IPTOS_PREC_FLASHOVERRIDE 0x80 #define IPTOS_PREC_FLASH 0x60 #define IPTOS_PREC_IMMEDIATE 0x40 #define IPTOS_PREC_PRIORITY 0x20 #define IPTOS_PREC_ROUTINE 0x00 /* * Definitions for options. */ #define IPOPT_COPIED(o) ((o)&0x80) #define IPOPT_CLASS(o) ((o)&0x60) #define IPOPT_NUMBER(o) ((o)&0x1f) #define IPOPT_CONTROL 0x00 #define IPOPT_RESERVED1 0x20 #define IPOPT_DEBMEAS 0x40 #define IPOPT_RESERVED2 0x60 #define IPOPT_EOL 0 /* end of option list */ #define IPOPT_NOP 1 /* no operation */ #define IPOPT_RR 7 /* record packet route */ #define IPOPT_TS 68 /* timestamp */ #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ #define IPOPT_LSRR 131 /* loose source route */ #define IPOPT_SATID 136 /* satnet id */ #define IPOPT_SSRR 137 /* strict source route */ /* * Offsets to fields in options other than EOL and NOP. */ #define IPOPT_OPTVAL 0 /* option ID */ #define IPOPT_OLEN 1 /* option length */ #define IPOPT_OFFSET 2 /* offset within option */ #define IPOPT_MINOFF 4 /* min value of above */ /* * Time stamp option structure. */ struct ip_timestamp { u_int8_t ipt_code; /* IPOPT_TS */ u_int8_t ipt_len; /* size of structure (variable) */ u_int8_t ipt_ptr; /* index of current entry */ u_int8_t ipt_oflwflg; /* flags, overflow counter */ #define IPTS_OFLW(ip) (((ipt)->ipt_oflwflg & 0xf0) >> 4) #define IPTS_FLG(ip) ((ipt)->ipt_oflwflg & 0x0f) union ipt_timestamp { u_int32_t ipt_time[1]; struct ipt_ta { struct in_addr ipt_addr; u_int32_t ipt_time; } ipt_ta[1]; } ipt_timestamp; }; /* flag bits for ipt_flg */ #define IPOPT_TS_TSONLY 0 /* timestamps only */ #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ #define IPOPT_TS_PRESPEC 3 /* specified modules only */ /* bits for security (not byte swapped) */ #define IPOPT_SECUR_UNCLASS 0x0000 #define IPOPT_SECUR_CONFID 0xf135 #define IPOPT_SECUR_EFTO 0x789a #define IPOPT_SECUR_MMMM 0xbc4d #define IPOPT_SECUR_RESTR 0xaf13 #define IPOPT_SECUR_SECRET 0xd788 #define IPOPT_SECUR_TOPSECRET 0x6bc5 /* * Internet implementation parameters. */ #define MAXTTL 255 /* maximum time to live (seconds) */ #define IPDEFTTL 64 /* default ttl, from RFC 1340 */ #define IPFRAGTTL 60 /* time to live for frags, slowhz */ #define IPTTLDEC 1 /* subtracted when forwarding */ #define IP_MSS 576 /* default maximum segment size */ tcpdump-3.7.2/ip6.h0100644000076500000240000001671307217243504013223 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.3 2000/12/17 23:07:48 guy Exp $ (LBL) */ /* $NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp $ */ /* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ip.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_IP6_H_ #define _NETINET_IP6_H_ /* * Definition for internet protocol version 6. * RFC 2460 */ struct ip6_hdr { union { struct ip6_hdrctl { u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */ u_int16_t ip6_un1_plen; /* payload length */ u_int8_t ip6_un1_nxt; /* next header */ u_int8_t ip6_un1_hlim; /* hop limit */ } ip6_un1; u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ } ip6_ctlun; struct in6_addr ip6_src; /* source address */ struct in6_addr ip6_dst; /* destination address */ }; #define ip6_vfc ip6_ctlun.ip6_un2_vfc #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim #define IPV6_VERSION 0x60 #define IPV6_VERSION_MASK 0xf0 /* in network endian */ #define IPV6_FLOWINFO_MASK ((u_int32_t)htonl(0x0fffffff)) /* flow info (28 bits) */ #define IPV6_FLOWLABEL_MASK ((u_int32_t)htonl(0x000fffff)) /* flow label (20 bits) */ #if 1 /* ECN bits proposed by Sally Floyd */ #define IP6TOS_CE 0x01 /* congestion experienced */ #define IP6TOS_ECT 0x02 /* ECN-capable transport */ #endif /* * Extension Headers */ struct ip6_ext { u_char ip6e_nxt; u_char ip6e_len; }; /* Hop-by-Hop options header */ /* XXX should we pad it to force alignment on an 8-byte boundary? */ struct ip6_hbh { u_int8_t ip6h_nxt; /* next header */ u_int8_t ip6h_len; /* length in units of 8 octets */ /* followed by options */ }; /* Destination options header */ /* XXX should we pad it to force alignment on an 8-byte boundary? */ struct ip6_dest { u_int8_t ip6d_nxt; /* next header */ u_int8_t ip6d_len; /* length in units of 8 octets */ /* followed by options */ }; /* Option types and related macros */ #define IP6OPT_PAD1 0x00 /* 00 0 00000 */ #define IP6OPT_PADN 0x01 /* 00 0 00001 */ #define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ #define IP6OPT_JUMBO_LEN 6 #define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */ #define IP6OPT_RTALERT_LEN 4 #define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ #define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ #define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ #define IP6OPT_MINLEN 2 #define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */ #define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */ #define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */ #define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ #define IP6OPT_EID 0x8a /* 10 0 01010 */ #define IP6OPT_TYPE(o) ((o) & 0xC0) #define IP6OPT_TYPE_SKIP 0x00 #define IP6OPT_TYPE_DISCARD 0x40 #define IP6OPT_TYPE_FORCEICMP 0x80 #define IP6OPT_TYPE_ICMP 0xC0 #define IP6OPT_MUTABLE 0x20 /* Routing header */ struct ip6_rthdr { u_int8_t ip6r_nxt; /* next header */ u_int8_t ip6r_len; /* length in units of 8 octets */ u_int8_t ip6r_type; /* routing type */ u_int8_t ip6r_segleft; /* segments left */ /* followed by routing type specific data */ }; /* Type 0 Routing header */ struct ip6_rthdr0 { u_int8_t ip6r0_nxt; /* next header */ u_int8_t ip6r0_len; /* length in units of 8 octets */ u_int8_t ip6r0_type; /* always zero */ u_int8_t ip6r0_segleft; /* segments left */ u_int8_t ip6r0_reserved; /* reserved field */ u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */ struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */ }; /* Fragment header */ struct ip6_frag { u_int8_t ip6f_nxt; /* next header */ u_int8_t ip6f_reserved; /* reserved field */ u_int16_t ip6f_offlg; /* offset, reserved, and flag */ u_int32_t ip6f_ident; /* identification */ }; /* network endian */ #define IP6F_OFF_MASK ((u_int16_t)htons(0xfff8)) /* mask out offset from _offlg */ #define IP6F_RESERVED_MASK ((u_int16_t)htons(0x0006)) /* reserved bits in ip6f_offlg */ #define IP6F_MORE_FRAG ((u_int16_t)htons(0x0001)) /* more-fragments flag */ #endif /* not _NETINET_IP6_H_ */ tcpdump-3.7.2/ipsec_doi.h0100644000076500000240000001500307166516515014462 0ustar fennerstaff/* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* YIPS @(#)$Id: ipsec_doi.h,v 1.4 2000/10/04 03:00:29 itojun Exp $ */ /* refer to RFC 2407 */ #if !defined(_IPSEC_DOI_H_) #define _IPSEC_DOI_H_ #define IPSEC_DOI 1 /* 4.2 IPSEC Situation Definition */ #define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001 #define IPSECDOI_SIT_SECRECY 0x00000002 #define IPSECDOI_SIT_INTEGRITY 0x00000004 /* 4.4.1 IPSEC Security Protocol Identifiers */ /* 4.4.2 IPSEC ISAKMP Transform Values */ #define IPSECDOI_PROTO_ISAKMP 1 #define IPSECDOI_KEY_IKE 1 /* 4.4.1 IPSEC Security Protocol Identifiers */ #define IPSECDOI_PROTO_IPSEC_AH 2 /* 4.4.3 IPSEC AH Transform Values */ #define IPSECDOI_AH_MD5 2 #define IPSECDOI_AH_SHA 3 #define IPSECDOI_AH_DES 4 #define IPSECDOI_AH_SHA2_256 5 #define IPSECDOI_AH_SHA2_384 6 #define IPSECDOI_AH_SHA2_512 7 /* 4.4.1 IPSEC Security Protocol Identifiers */ #define IPSECDOI_PROTO_IPSEC_ESP 3 /* 4.4.4 IPSEC ESP Transform Identifiers */ #define IPSECDOI_ESP_DES_IV64 1 #define IPSECDOI_ESP_DES 2 #define IPSECDOI_ESP_3DES 3 #define IPSECDOI_ESP_RC5 4 #define IPSECDOI_ESP_IDEA 5 #define IPSECDOI_ESP_CAST 6 #define IPSECDOI_ESP_BLOWFISH 7 #define IPSECDOI_ESP_3IDEA 8 #define IPSECDOI_ESP_DES_IV32 9 #define IPSECDOI_ESP_RC4 10 #define IPSECDOI_ESP_NULL 11 #define IPSECDOI_ESP_RIJNDAEL 12 #define IPSECDOI_ESP_AES 12 /* 4.4.1 IPSEC Security Protocol Identifiers */ #define IPSECDOI_PROTO_IPCOMP 4 /* 4.4.5 IPSEC IPCOMP Transform Identifiers */ #define IPSECDOI_IPCOMP_OUI 1 #define IPSECDOI_IPCOMP_DEFLATE 2 #define IPSECDOI_IPCOMP_LZS 3 /* 4.5 IPSEC Security Association Attributes */ #define IPSECDOI_ATTR_SA_LTYPE 1 /* B */ #define IPSECDOI_ATTR_SA_LTYPE_DEFAULT 1 #define IPSECDOI_ATTR_SA_LTYPE_SEC 1 #define IPSECDOI_ATTR_SA_LTYPE_KB 2 #define IPSECDOI_ATTR_SA_LDUR 2 /* V */ #define IPSECDOI_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */ #define IPSECDOI_ATTR_GRP_DESC 3 /* B */ #define IPSECDOI_ATTR_ENC_MODE 4 /* B */ /* default value: host dependent */ #define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1 #define IPSECDOI_ATTR_ENC_MODE_TRNS 2 #define IPSECDOI_ATTR_AUTH 5 /* B */ /* 0 means not to use authentication. */ #define IPSECDOI_ATTR_AUTH_HMAC_MD5 1 #define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2 #define IPSECDOI_ATTR_AUTH_DES_MAC 3 #define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/ /* * When negotiating ESP without authentication, the Auth * Algorithm attribute MUST NOT be included in the proposal. * When negotiating ESP without confidentiality, the Auth * Algorithm attribute MUST be included in the proposal and * the ESP transform ID must be ESP_NULL. */ #define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */ #define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */ #define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */ #define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */ /* 4.6.1 Security Association Payload */ struct ipsecdoi_sa { struct isakmp_gen h; u_int32_t doi; /* Domain of Interpretation */ u_int32_t sit; /* Situation */ }; struct ipsecdoi_secrecy_h { u_int16_t len; u_int16_t reserved; }; /* 4.6.2.1 Identification Type Values */ struct ipsecdoi_id { struct isakmp_gen h; u_int8_t type; /* ID Type */ u_int8_t proto_id; /* Protocol ID */ u_int16_t port; /* Port */ /* Identification Data */ }; #define IPSECDOI_ID_IPV4_ADDR 1 #define IPSECDOI_ID_FQDN 2 #define IPSECDOI_ID_USER_FQDN 3 #define IPSECDOI_ID_IPV4_ADDR_SUBNET 4 #define IPSECDOI_ID_IPV6_ADDR 5 #define IPSECDOI_ID_IPV6_ADDR_SUBNET 6 #define IPSECDOI_ID_IPV4_ADDR_RANGE 7 #define IPSECDOI_ID_IPV6_ADDR_RANGE 8 #define IPSECDOI_ID_DER_ASN1_DN 9 #define IPSECDOI_ID_DER_ASN1_GN 10 #define IPSECDOI_ID_KEY_ID 11 /* 4.6.3 IPSEC DOI Notify Message Types */ /* Notify Messages - Status Types */ #define IPSECDOI_NTYPE_RESPONDER_LIFETIME 24576 #define IPSECDOI_NTYPE_REPLAY_STATUS 24577 #define IPSECDOI_NTYPE_INITIAL_CONTACT 24578 #endif /* !defined(_IPSEC_DOI_H_) */ tcpdump-3.7.2/ipx.h0100644000076500000240000000174707230466517013334 0ustar fennerstaff/* * IPX protocol formats * * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.4 2001/01/15 03:23:59 guy Exp $ */ /* well-known sockets */ #define IPX_SKT_NCP 0x0451 #define IPX_SKT_SAP 0x0452 #define IPX_SKT_RIP 0x0453 #define IPX_SKT_NETBIOS 0x0455 #define IPX_SKT_DIAGNOSTICS 0x0456 #define IPX_SKT_NWLINK_DGM 0x0553 /* NWLink datagram, may contain SMB */ #define IPX_SKT_EIGRP 0x85be /* Cisco EIGRP over IPX */ /* IPX transport header */ struct ipxHdr { u_int16_t cksum; /* Checksum */ u_int16_t length; /* Length, in bytes, including header */ u_int8_t tCtl; /* Transport Control (i.e. hop count) */ u_int8_t pType; /* Packet Type (i.e. level 2 protocol) */ u_int16_t dstNet[2]; /* destination net */ u_int8_t dstNode[6]; /* destination node */ u_int16_t dstSkt; /* destination socket */ u_int16_t srcNet[2]; /* source net */ u_int8_t srcNode[6]; /* source node */ u_int16_t srcSkt; /* source socket */ } ipx_hdr_t; #define ipxSize 30 tcpdump-3.7.2/isakmp.h0100644000076500000240000003170607166265666014030 0ustar fennerstaff/* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* YIPS @(#)$Id: isakmp.h,v 1.7 2000/10/03 05:16:38 itojun Exp $ */ /* refer to RFC 2408 */ /* must include */ #if !defined(_ISAKMP_H_) #define _ISAKMP_H_ typedef u_char cookie_t[8]; typedef u_char msgid_t[4]; typedef struct { /* i_cookie + r_cookie */ cookie_t i_ck; cookie_t r_ck; } isakmp_index; #define INITIATOR 1 #define RESPONDER 2 #define PORT_ISAKMP 500 #define GENERATE 1 #define VALIDATE 0 /* Phase of oakley definition */ /* 0000 0000 0000 0000 | |||| |||| | |||| ++++--> negosiation number in phase | ++++-------> phase number +---------------> expire ? */ #define ISAKMP_PH1 0x0010 #define ISAKMP_PH2 0x0020 #define ISAKMP_EXPIRED 0x0100 #define ISAKMP_NGP_0 0x0000 #define ISAKMP_NGP_1 0x0001 #define ISAKMP_NGP_2 0x0002 #define ISAKMP_NGP_3 0x0003 #define ISAKMP_NGP_4 0x0004 #define ISAKMP_PH1_N (ISAKMP_PH1 | ISAKMP_NGP_0) /* i.e. spawn */ #define ISAKMP_PH1_1 (ISAKMP_PH1 | ISAKMP_NGP_1) #define ISAKMP_PH1_2 (ISAKMP_PH1 | ISAKMP_NGP_2) #define ISAKMP_PH1_3 (ISAKMP_PH1 | ISAKMP_NGP_3) #define ISAKMP_PH2_N (ISAKMP_PH2 | ISAKMP_NGP_0) #define ISAKMP_PH2_1 (ISAKMP_PH2 | ISAKMP_NGP_1) #define ISAKMP_PH2_2 (ISAKMP_PH2 | ISAKMP_NGP_2) #define ISAKMP_PH2_3 (ISAKMP_PH2 | ISAKMP_NGP_3) #define ISAKMP_TIMER_DEFAULT 10 /* seconds */ #define ISAKMP_TRY_DEFAULT 3 /* times */ /* 3.1 ISAKMP Header Format 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Initiator ! ! Cookie ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Responder ! ! Cookie ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Message ID ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Length ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct isakmp { cookie_t i_ck; /* Initiator Cookie */ cookie_t r_ck; /* Responder Cookie */ u_int8_t np; /* Next Payload Type */ u_int8_t vers; #define ISAKMP_VERS_MAJOR 0xf0 #define ISAKMP_VERS_MAJOR_SHIFT 4 #define ISAKMP_VERS_MINOR 0x0f #define ISAKMP_VERS_MINOR_SHIFT 0 u_int8_t etype; /* Exchange Type */ u_int8_t flags; /* Flags */ msgid_t msgid; u_int32_t len; /* Length */ }; /* Next Payload Type */ #define ISAKMP_NPTYPE_NONE 0 /* NONE*/ #define ISAKMP_NPTYPE_SA 1 /* Security Association */ #define ISAKMP_NPTYPE_P 2 /* Proposal */ #define ISAKMP_NPTYPE_T 3 /* Transform */ #define ISAKMP_NPTYPE_KE 4 /* Key Exchange */ #define ISAKMP_NPTYPE_ID 5 /* Identification */ #define ISAKMP_NPTYPE_CERT 6 /* Certificate */ #define ISAKMP_NPTYPE_CR 7 /* Certificate Request */ #define ISAKMP_NPTYPE_HASH 8 /* Hash */ #define ISAKMP_NPTYPE_SIG 9 /* Signature */ #define ISAKMP_NPTYPE_NONCE 10 /* Nonce */ #define ISAKMP_NPTYPE_N 11 /* Notification */ #define ISAKMP_NPTYPE_D 12 /* Delete */ #define ISAKMP_NPTYPE_VID 13 /* Vendor ID */ #define ISAKMP_MAJOR_VERSION 1 #define ISAKMP_MINOR_VERSION 0 /* Exchange Type */ #define ISAKMP_ETYPE_NONE 0 /* NONE */ #define ISAKMP_ETYPE_BASE 1 /* Base */ #define ISAKMP_ETYPE_IDENT 2 /* Identity Proteciton */ #define ISAKMP_ETYPE_AUTH 3 /* Authentication Only */ #define ISAKMP_ETYPE_AGG 4 /* Aggressive */ #define ISAKMP_ETYPE_INF 5 /* Informational */ /* Flags */ #define ISAKMP_FLAG_E 0x01 /* Encryption Bit */ #define ISAKMP_FLAG_C 0x02 /* Commit Bit */ /* 3.2 Payload Generic Header 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Next Payload ! RESERVED ! Payload Length ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct isakmp_gen { u_int8_t np; /* Next Payload */ u_int8_t reserved; /* RESERVED, unused, must set to 0 */ u_int16_t len; /* Payload Length */ }; /* 3.3 Data Attributes 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ !A! Attribute Type ! AF=0 Attribute Length ! !F! ! AF=1 Attribute Value ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ . AF=0 Attribute Value . . AF=1 Not Transmitted . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct isakmp_data { u_int16_t type; /* defined by DOI-spec, and Attribute Format */ u_int16_t lorv; /* if f equal 1, Attribute Length */ /* if f equal 0, Attribute Value */ /* if f equal 1, Attribute Value */ }; #define ISAKMP_GEN_TLV 0x0000 #define ISAKMP_GEN_TV 0x8000 /* mask for type of attribute format */ #define ISAKMP_GEN_MASK 0x8000 /* 3.4 Security Association Payload */ /* MAY NOT be used, because of being defined in ipsec-doi. */ /* If the current payload is the last in the message, then the value of the next payload field will be 0. This field MUST NOT contain the values for the Proposal or Transform payloads as they are considered part of the security association negotiation. For example, this field would contain the value "10" (Nonce payload) in the first message of a Base Exchange (see Section 4.4) and the value "0" in the first message of an Identity Protect Exchange (see Section 4.5). */ struct isakmp_pl_sa { struct isakmp_gen h; u_int32_t doi; /* Domain of Interpretation */ u_int32_t sit; /* Situation */ }; /* 3.5 Proposal Payload */ /* The value of the next payload field MUST only contain the value "2" or "0". If there are additional Proposal payloads in the message, then this field will be 2. If the current Proposal payload is the last within the security association proposal, then this field will be 0. */ struct isakmp_pl_p { struct isakmp_gen h; u_int8_t p_no; /* Proposal # */ u_int8_t prot_id; /* Protocol */ u_int8_t spi_size; /* SPI Size */ u_int8_t num_t; /* Number of Transforms */ /* SPI */ }; /* 3.6 Transform Payload */ /* The value of the next payload field MUST only contain the value "3" or "0". If there are additional Transform payloads in the proposal, then this field will be 3. If the current Transform payload is the last within the proposal, then this field will be 0. */ struct isakmp_pl_t { struct isakmp_gen h; u_int8_t t_no; /* Transform # */ u_int8_t t_id; /* Transform-Id */ u_int16_t reserved; /* RESERVED2 */ /* SA Attributes */ }; /* 3.7 Key Exchange Payload */ struct isakmp_pl_ke { struct isakmp_gen h; /* Key Exchange Data */ }; /* 3.8 Identification Payload */ /* MUST NOT to be used, because of being defined in ipsec-doi. */ struct isakmp_pl_id { struct isakmp_gen h; union { u_int8_t id_type; /* ID Type */ u_int32_t doi_data; /* DOI Specific ID Data */ } d; /* Identification Data */ }; /* 3.9 Certificate Payload */ struct isakmp_pl_cert { struct isakmp_gen h; u_int8_t encode; /* Cert Encoding */ char cert; /* Certificate Data */ /* This field indicates the type of certificate or certificate-related information contained in the Certificate Data field. */ }; /* Certificate Type */ #define ISAKMP_CERT_NONE 0 #define ISAKMP_CERT_PKCS 1 #define ISAKMP_CERT_PGP 2 #define ISAKMP_CERT_DNS 3 #define ISAKMP_CERT_SIGN 4 #define ISAKMP_CERT_KE 5 #define ISAKMP_CERT_KT 6 #define ISAKMP_CERT_CRL 7 #define ISAKMP_CERT_ARL 8 #define ISAKMP_CERT_SPKI 9 /* 3.10 Certificate Request Payload */ struct isakmp_pl_cr { struct isakmp_gen h; u_int8_t num_cert; /* # Cert. Types */ /* Certificate Types (variable length) -- Contains a list of the types of certificates requested, sorted in order of preference. Each individual certificate type is 1 octet. This field is NOT requiredo */ /* # Certificate Authorities (1 octet) */ /* Certificate Authorities (variable length) */ }; /* 3.11 Hash Payload */ /* may not be used, because of having only data. */ struct isakmp_pl_hash { struct isakmp_gen h; /* Hash Data */ }; /* 3.12 Signature Payload */ /* may not be used, because of having only data. */ struct isakmp_pl_sig { struct isakmp_gen h; /* Signature Data */ }; /* 3.13 Nonce Payload */ /* may not be used, because of having only data. */ struct isakmp_pl_nonce { struct isakmp_gen h; /* Nonce Data */ }; /* 3.14 Notification Payload */ struct isakmp_pl_n { struct isakmp_gen h; u_int32_t doi; /* Domain of Interpretation */ u_int8_t prot_id; /* Protocol-ID */ u_int8_t spi_size; /* SPI Size */ u_int16_t type; /* Notify Message Type */ /* SPI */ /* Notification Data */ }; /* 3.14.1 Notify Message Types */ /* NOTIFY MESSAGES - ERROR TYPES */ #define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1 #define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2 #define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3 #define ISAKMP_NTYPE_INVALID_COOKIE 4 #define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5 #define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6 #define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7 #define ISAKMP_NTYPE_INVALID_FLAGS 8 #define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9 #define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10 #define ISAKMP_NTYPE_INVALID_SPI 11 #define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12 #define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13 #define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14 #define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15 #define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16 #define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17 #define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18 #define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19 #define ISAKMP_NTYPE_INVALID_CERTIFICATE 20 #define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21 #define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22 #define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23 #define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24 #define ISAKMP_NTYPE_INVALID_SIGNATURE 25 #define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26 /* NOTIFY MESSAGES - STATUS TYPES */ #define ISAKMP_NTYPE_CONNECTED 16384 /* using only to log */ #define ISAKMP_LOG_RETRY_LIMIT_REACHED 65530 /* 3.15 Delete Payload */ struct isakmp_pl_d { struct isakmp_gen h; u_int32_t doi; /* Domain of Interpretation */ u_int8_t prot_id; /* Protocol-Id */ u_int8_t spi_size; /* SPI Size */ u_int16_t num_spi; /* # of SPIs */ /* SPI(es) */ }; struct isakmp_ph1tab { struct isakmp_ph1 *head; struct isakmp_ph1 *tail; int len; }; struct isakmp_ph2tab { struct isakmp_ph2 *head; struct isakmp_ph2 *tail; int len; }; #define EXCHANGE_PROXY 1 #define EXCHANGE_MYSELF 0 #define PFS_NEED 1 #define PFS_NONEED 0 #endif /* !defined(_ISAKMP_H_) */ tcpdump-3.7.2/l2tp.h0100644000076500000240000000546207371461757013422 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.5 2001/11/05 10:03:27 guy Exp $ (LBL) */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net) */ #define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */ #define L2TP_FLAG_LENGTH 0x4000 /* Length */ #define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */ #define L2TP_FLAG_OFFSET 0x0200 /* Offset */ #define L2TP_FLAG_PRIORITY 0x0100 /* Priority */ #define L2TP_VERSION_MASK 0x000f /* Version Mask */ #define L2TP_VERSION_L2F 0x0001 /* L2F */ #define L2TP_VERSION_L2TP 0x0002 /* L2TP */ #define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */ #define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */ #define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */ #define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */ #define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */ #define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */ #define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */ #define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */ #define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */ #define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */ #define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */ /* Authen Type */ #define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */ #define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */ #define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */ #define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */ #define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */ #define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */ #define L2TP_PROXY_AUTH_ID_MASK 0x00ff tcpdump-3.7.2/lane.h0100644000076500000240000000200007166245200013422 0ustar fennerstaff/* * Marko Kiiskila carnil@cs.tut.fi * * Tampere University of Technology - Telecommunications Laboratory * * Permission to use, copy, modify and distribute this * software and its documentation is hereby granted, * provided that both the copyright notice and this * permission notice appear in all copies of the software, * derivative works or modified versions, and any portions * thereof, that both notices appear in supporting * documentation, and that the use of this software is * acknowledged in any publications resulting from using * the software. * * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS * SOFTWARE. * */ /* $Id: lane.h,v 1.3 2000/10/03 02:54:56 itojun Exp $ */ #ifndef ETHER_ADDR_LEN #define ETHER_ADDR_LEN 6 #endif struct lecdatahdr_8023 { u_int16_t le_header; u_int8_t h_dest[ETHER_ADDR_LEN]; u_int8_t h_source[ETHER_ADDR_LEN]; u_int16_t h_type; }; tcpdump-3.7.2/lbl/0040755000076500000240000000000007423403555013123 5ustar fennerstafftcpdump-3.7.2/lbl/CVS/0040755000076500000240000000000007627054634013564 5ustar fennerstafftcpdump-3.7.2/lbl/CVS/Entries0100644000076500000240000000027007627054634015114 0ustar fennerstaff/os-solaris2.h/1.19/Wed Oct 11 04:02:15 2000//Ttcpdump_3_7 /os-sunos4.h/1.32.1.1/Thu Oct 7 23:47:13 1999//Ttcpdump_3_7 /os-ultrix4.h/1.19.1.1/Thu Oct 7 23:47:13 1999//Ttcpdump_3_7 D tcpdump-3.7.2/lbl/CVS/Repository0100644000076500000240000000003407423403554015651 0ustar fennerstaff/tcpdump/master/tcpdump/lbl tcpdump-3.7.2/lbl/CVS/Root0100644000076500000240000000006107423403554014415 0ustar fennerstaff:pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master tcpdump-3.7.2/lbl/CVS/Tag0100644000076500000240000000001507627054634014213 0ustar fennerstaffTtcpdump_3_7 tcpdump-3.7.2/lbl/os-solaris2.h0100644000076500000240000000276507170763107015461 0ustar fennerstaff/* * Copyright (c) 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-solaris2.h,v 1.19 2000/10/11 04:02:15 guy Exp $ (LBL) */ /* Prototypes missing in SunOS 5 */ #if defined(_STDIO_H) && defined(HAVE_SETLINEBUF) int setlinebuf(FILE *); #endif char *strerror(int); int snprintf(char *, size_t, const char *, ...); int strcasecmp(const char *, const char *); tcpdump-3.7.2/lbl/os-sunos4.h0100644000076500000240000001417506777230401015152 0ustar fennerstaff/* * Copyright (c) 1989, 1990, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-sunos4.h,v 1.32.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL) */ /* Prototypes missing in SunOS 4 */ #ifdef FILE int _filbuf(FILE *); int _flsbuf(u_char, FILE *); int fclose(FILE *); int fflush(FILE *); int fgetc(FILE *); int fprintf(FILE *, const char *, ...); int fputc(int, FILE *); int fputs(const char *, FILE *); u_int fread(void *, u_int, u_int, FILE *); int fseek(FILE *, long, int); u_int fwrite(const void *, u_int, u_int, FILE *); int pclose(FILE *); void rewind(FILE *); void setbuf(FILE *, char *); int setlinebuf(FILE *); int ungetc(int, FILE *); int vfprintf(FILE *, const char *, ...); int vprintf(const char *, ...); #endif #if __GNUC__ <= 1 int read(int, char *, u_int); int write(int, char *, u_int); #endif long a64l(const char *); #ifdef __STDC__ struct sockaddr; #endif int accept(int, struct sockaddr *, int *); int bind(int, struct sockaddr *, int); int bcmp(const void *, const void *, u_int); void bcopy(const void *, void *, u_int); void bzero(void *, int); int chroot(const char *); int close(int); void closelog(void); int connect(int, struct sockaddr *, int); char *crypt(const char *, const char *); int daemon(int, int); int fchmod(int, int); int fchown(int, int, int); void endgrent(void); void endpwent(void); void endservent(void); #ifdef __STDC__ struct ether_addr; #endif struct ether_addr *ether_aton(const char *); int flock(int, int); #ifdef __STDC__ struct stat; #endif int fstat(int, struct stat *); #ifdef __STDC__ struct statfs; #endif int fstatfs(int, struct statfs *); int fsync(int); #ifdef __STDC__ struct timeb; #endif int ftime(struct timeb *); int ftruncate(int, off_t); int getdtablesize(void); long gethostid(void); int gethostname(char *, int); int getopt(int, char * const *, const char *); int getpagesize(void); char *getpass(char *); int getpeername(int, struct sockaddr *, int *); int getpriority(int, int); #ifdef __STDC__ struct rlimit; #endif int getrlimit(int, struct rlimit *); int getsockname(int, struct sockaddr *, int *); int getsockopt(int, int, int, char *, int *); #ifdef __STDC__ struct timeval; struct timezone; #endif int gettimeofday(struct timeval *, struct timezone *); char *getusershell(void); char *getwd(char *); int initgroups(const char *, int); int ioctl(int, int, caddr_t); int iruserok(u_long, int, char *, char *); int isatty(int); int killpg(int, int); int listen(int, int); #ifdef __STDC__ struct utmp; #endif void login(struct utmp *); int logout(const char *); off_t lseek(int, off_t, int); int lstat(const char *, struct stat *); int mkstemp(char *); char *mktemp(char *); int munmap(caddr_t, int); void openlog(const char *, int, int); void perror(const char *); int printf(const char *, ...); int puts(const char *); long random(void); int readlink(const char *, char *, int); #ifdef __STDC__ struct iovec; #endif int readv(int, struct iovec *, int); int recv(int, char *, u_int, int); int recvfrom(int, char *, u_int, int, struct sockaddr *, int *); int rename(const char *, const char *); int rcmd(char **, u_short, char *, char *, char *, int *); int rresvport(int *); int send(int, char *, u_int, int); int sendto(int, char *, u_int, int, struct sockaddr *, int); int setenv(const char *, const char *, int); int seteuid(int); int setpriority(int, int, int); int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); int setpgrp(int, int); void setpwent(void); int setrlimit(int, struct rlimit *); void setservent(int); int setsockopt(int, int, int, char *, int); int shutdown(int, int); int sigblock(int); void (*signal (int, void (*) (int))) (int); int sigpause(int); int sigsetmask(int); #ifdef __STDC__ struct sigvec; #endif int sigvec(int, struct sigvec *, struct sigvec*); int snprintf(char *, size_t, const char *, ...); int socket(int, int, int); int socketpair(int, int, int, int *); int symlink(const char *, const char *); void srandom(int); int sscanf(char *, const char *, ...); int stat(const char *, struct stat *); int statfs(char *, struct statfs *); char *strerror(int); int strcasecmp(const char *, const char *); #ifdef __STDC__ struct tm; #endif int strftime(char *, int, char *, struct tm *); int strncasecmp(const char *, const char *, int); long strtol(const char *, char **, int); void sync(void); void syslog(int, const char *, ...); int system(const char *); long tell(int); time_t time(time_t *); char *timezone(int, int); int tolower(int); int toupper(int); int truncate(char *, off_t); void unsetenv(const char *); int vfork(void); int vsprintf(char *, const char *, ...); int writev(int, struct iovec *, int); #ifdef __STDC__ struct rusage; #endif int utimes(const char *, struct timeval *); #if __GNUC__ <= 1 int wait(int *); pid_t wait3(int *, int, struct rusage *); #endif /* Ugly signal hacking */ #ifdef SIG_ERR #undef SIG_ERR #define SIG_ERR (void (*)(int))-1 #undef SIG_DFL #define SIG_DFL (void (*)(int))0 #undef SIG_IGN #define SIG_IGN (void (*)(int))1 #ifdef KERNEL #undef SIG_CATCH #define SIG_CATCH (void (*)(int))2 #endif #undef SIG_HOLD #define SIG_HOLD (void (*)(int))3 #endif tcpdump-3.7.2/lbl/os-ultrix4.h0100644000076500000240000000335706777230401015332 0ustar fennerstaff/* * Copyright (c) 1990, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-ultrix4.h,v 1.19.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL) */ /* Prototypes missing in Ultrix 4 */ int bcmp(const char *, const char *, u_int); void bcopy(const void *, void *, u_int); void bzero(void *, u_int); void endservent(void); int getopt(int, char * const *, const char *); #ifdef __STDC__ struct timeval; struct timezone; #endif int gettimeofday(struct timeval *, struct timezone *); int ioctl(int, int, caddr_t); int pfopen(char *, int); int setlinebuf(FILE *); int socket(int, int, int); int strcasecmp(const char *, const char *); tcpdump-3.7.2/LICENSE0100644000076500000240000000155107170444340013352 0ustar fennerstaffLicense: BSD Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. tcpdump-3.7.2/llc.h0100644000076500000240000000701207306620341013264 0ustar fennerstaff/* * Copyright (c) 1993, 1994, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.13 2001/06/04 05:47:13 guy Exp $ (LBL) */ /* * This stuff should come from a system header file, but there's no * obviously portable way to do that and it's not really going * to change from system to system. */ /* * A somewhat abstracted view of the LLC header */ struct llc { u_int8_t dsap; u_int8_t ssap; union { u_int8_t u_ctl; u_int16_t is_ctl; struct { u_int8_t snap_ui; u_int8_t snap_pi[5]; } snap; struct { u_int8_t snap_ui; u_int8_t snap_orgcode[3]; u_int8_t snap_ethertype[2]; } snap_ether; } ctl; }; #define llcui ctl.snap.snap_ui #define llcpi ctl.snap.snap_pi #define llc_orgcode ctl.snap_ether.snap_orgcode #define llc_ethertype ctl.snap_ether.snap_ethertype #define llcis ctl.is_ctl #define llcu ctl.u_ctl #define LLC_U_FMT 3 #define LLC_GSAP 1 #define LLC_S_FMT 1 #define LLC_U_POLL 0x10 #define LLC_IS_POLL 0x0100 #define LLC_XID_FI 0x81 #define LLC_U_CMD(u) ((u) & 0xef) #define LLC_UI 0x03 #define LLC_UA 0x63 #define LLC_DISC 0x43 #define LLC_DM 0x0f #define LLC_SABME 0x6f #define LLC_TEST 0xe3 #define LLC_XID 0xaf #define LLC_FRMR 0x87 #define LLC_S_CMD(is) (((is) >> 1) & 0x03) #define LLC_RR 0x0001 #define LLC_RNR 0x0005 #define LLC_REJ 0x0009 #define LLC_IS_NR(is) (((is) >> 9) & 0x7f) #define LLC_I_NS(is) (((is) >> 1) & 0x7f) #ifndef LLCSAP_NULL #define LLCSAP_NULL 0x00 #endif #ifndef LLCSAP_GLOBAL #define LLCSAP_GLOBAL 0xff #endif #ifndef LLCSAP_8021B_I #define LLCSAP_8021B_I 0x02 #endif #ifndef LLCSAP_8021B_G #define LLCSAP_8021B_G 0x03 #endif #ifndef LLCSAP_IP #define LLCSAP_IP 0x06 #endif #ifndef LLCSAP_PROWAYNM #define LLCSAP_PROWAYNM 0x0e #endif #ifndef LLCSAP_8021D #define LLCSAP_8021D 0x42 #endif #ifndef LLCSAP_RS511 #define LLCSAP_RS511 0x4e #endif #ifndef LLCSAP_ISO8208 #define LLCSAP_ISO8208 0x7e #endif #ifndef LLCSAP_PROWAY #define LLCSAP_PROWAY 0x8e #endif #ifndef LLCSAP_SNAP #define LLCSAP_SNAP 0xaa #endif #ifndef LLCSAP_IPX #define LLCSAP_IPX 0xe0 #endif #ifndef LLCSAP_NETBEUI #define LLCSAP_NETBEUI 0xf0 #endif #ifndef LLCSAP_ISONS #define LLCSAP_ISONS 0xfe #endif #define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */ #define OUI_CISCO 0x00000c /* Cisco protocols */ #define ETHERTYPE_CISCO_CDP 0x2000 /* Cisco Discovery Protocol */ #define OUI_CISCO_90 0x0000f8 /* Cisco bridging */ #define OUI_APPLETALK 0x080007 /* Appletalk */ tcpdump-3.7.2/machdep.c0100644000076500000240000000374507316271054014123 0ustar fennerstaff/* * Copyright (c) 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.7 2001/06/27 05:42:04 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #ifdef __osf__ #include #include #if !defined(HAVE_SNPRINTF) #ifndef HAVE___ATTRIBUTE__ #define __attribute__(x) #endif /* HAVE___ATTRIBUTE__ */ int snprintf(char *, size_t, const char *, ...) __attribute__((format(printf, 3, 4))); #endif /* !defined(HAVE_SNPRINTF) */ #endif /* __osf__ */ #include "machdep.h" int abort_on_misalignment(char *ebuf, size_t ebufsiz) { #ifdef __osf__ static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS }; if (setsysinfo(SSI_NVPAIRS, (caddr_t)buf, 1, 0, 0) < 0) { (void)snprintf(ebuf, ebufsiz, "setsysinfo: errno %d", errno); return (-1); } #endif return (0); } tcpdump-3.7.2/machdep.h0100644000076500000240000000252307040532630014113 0ustar fennerstaff/* * Copyright (c) 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.2 2000/01/17 06:24:24 itojun Exp $ (LBL) */ #ifndef tcpdump_machdep_h #define tcpdump_machdep_h int abort_on_misalignment(char *, size_t); #endif tcpdump-3.7.2/Makefile-devel-adds0100644000076500000240000000113307037741245016015 0ustar fennerstaff# # Auto-regenerate configure script or Makefile when things change. # From autoconf.info . Works best with GNU Make. # ${srcdir}/configure: configure.in cd ${srcdir} && autoconf # autoheader might not change config.h.in, so touch a stamp file. ${srcdir}/config.h.in: ${srcdir}/stamp-h.in ${srcdir}/stamp-h.in: configure.in acconfig.h cd ${srcdir} && autoheader echo timestamp > ${srcdir}/stamp-h.in config.h: stamp-h stamp-h: ${srcdir}/config.h.in config.status ./config.status Makefile: Makefile.in config.status ./config.status config.status: ${srcdir}/configure ./config.status --recheck tcpdump-3.7.2/Makefile.in0100644000076500000240000001466607405070203014417 0ustar fennerstaff# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 # The Regents of the University of California. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that: (1) source code distributions # retain the above copyright notice and this paragraph in its entirety, (2) # distributions including binary code include the above copyright notice and # this paragraph in its entirety in the documentation or other materials # provided with the distribution, and (3) all advertising materials mentioning # features or use of this software display the following acknowledgement: # ``This product includes software developed by the University of California, # Lawrence Berkeley Laboratory and its contributors.'' Neither the name of # the University nor the names of its contributors may be used to endorse # or promote products derived from this software without specific prior # written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.260 2001/12/10 08:21:23 guy Exp $ (LBL) # # Various configurable paths (remember to edit Makefile.in, not Makefile) # # Top level hierarchy prefix = @prefix@ exec_prefix = @exec_prefix@ # Pathname of directory to install the binary sbindir = @sbindir@ # Pathname of directory to install the man page mandir = @mandir@ # VPATH srcdir = @srcdir@ VPATH = @srcdir@ # # You shouldn't need to edit anything below here. # CC = @CC@ PROG = tcpdump CCOPT = @V_CCOPT@ INCLS = -I. @V_INCLS@ DEFS = @DEFS@ # Standard CFLAGS CFLAGS = $(CCOPT) $(DEFS) $(INCLS) # Standard LDFLAGS LDFLAGS = @LDFLAGS@ # Standard LIBS LIBS = @LIBS@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ # Explicitly define compilation rule since SunOS 4's make doesn't like gcc. # Also, gcc does not remove the .o before forking 'as', which can be a # problem if you don't own the file but can write to the directory. .c.o: @rm -f $@ $(CC) $(CFLAGS) -c $(srcdir)/$*.c CSRC = addrtoname.c gmt2local.c machdep.c parsenfsfh.c \ print-802_11.c print-ah.c print-arcnet.c print-arp.c \ print-ascii.c print-atalk.c print-atm.c print-bgp.c \ print-bootp.c print-beep.c print-cdp.c print-chdlc.c \ print-cip.c print-cnfp.c print-decnet.c print-domain.c \ print-dvmrp.c print-egp.c print-esp.c print-ether.c \ print-fddi.c print-gre.c print-hsrp.c print-icmp.c \ print-igmp.c print-igrp.c print-ip.c print-ipcomp.c \ print-ipx.c print-isakmp.c print-isoclns.c print-krb.c \ print-l2tp.c print-lane.c print-lcp.c print-llc.c print-lwres.c \ print-msdp.c print-mobile.c print-mpls.c print-nfs.c \ print-ntp.c print-null.c print-ospf.c print-pim.c \ print-ppp.c print-pppoe.c print-pptp.c print-radius.c \ print-raw.c print-rip.c print-rx.c print-sctp.c \ print-sl.c print-sll.c print-snmp.c \ print-stp.c print-sunrpc.c print-tcp.c \ print-telnet.c print-tftp.c print-timed.c print-token.c \ print-udp.c print-vjc.c print-vrrp.c print-wb.c print-zephyr.c \ setsignal.c tcpdump.c util.c LOCALSRC = @LOCALSRC@ GENSRC = version.c LIBOBJS = @LIBOBJS@ SRC = $(CSRC) $(GENSRC) $(LOCALSRC) # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot # hack the extra indirection OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LOCALSRC:.c=.o) $(LIBOBJS) HDR = addrtoname.h appletalk.h bootp.h decnet.h \ ethertype.h extract.h fddi.h gmt2local.h igrp.h interface.h \ ipx.h llc.h machdep.h mib.h nfsfh.h nfsv2.h ntp.h ospf.h \ setsignal.h \ gnuc.h ipsec_doi.h isakmp.h l2tp.h nameser.h \ netbios.h oakley.h ospf6.h ppp.h route6d.h TAGHDR = \ /usr/include/arpa/tftp.h \ /usr/include/net/if_arp.h \ /usr/include/net/slip.h \ /usr/include/netinet/if_ether.h \ /usr/include/netinet/in.h \ /usr/include/netinet/ip_icmp.h \ /usr/include/netinet/tcp.h \ /usr/include/netinet/udp.h \ /usr/include/protocols/routed.h TAGFILES = $(SRC) $(HDR) $(TAGHDR) CLEANFILES = $(PROG) $(OBJ) $(GENSRC) all: $(PROG) $(PROG): $(OBJ) @V_PCAPDEP@ @rm -f $@ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) getnameinfo.o: $(srcdir)/missing/getnameinfo.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getaddrinfo.c inet_pton.o: $(srcdir)/missing/inet_pton.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c inet_ntop.o: $(srcdir)/missing/inet_ntop.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c inet_aton.o: $(srcdir)/missing/inet_aton.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c snprintf.o: $(srcdir)/missing/snprintf.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c strlcat.o: $(srcdir)/missing/strlcat.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c strlcpy.o: $(srcdir)/missing/strlcpy.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c version.o: version.c $(CC) $(CFLAGS) -c version.c version.c: $(srcdir)/VERSION @rm -f $@ sed -e 's/.*/char version[] = "&";/' $(srcdir)/VERSION > $@ install: [ -d $(DESTDIR)$(sbindir) ] || \ (mkdir -p $(DESTDIR)$(sbindir); chmod 755 $(DESTDIR)$(sbindir)) $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG) [ -d $(DESTDIR)$(mandir)/man1 ] || \ (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1) $(INSTALL_DATA) $(srcdir)/$(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1 uninstall: rm -f $(DESTDIR)$(sbindir)/$(PROG) rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1 lint: $(GENSRC) lint -hbxn $(SRC) | \ grep -v 'struct/union .* never defined' | \ grep -v 'possible pointer alignment problem' clean: rm -f $(CLEANFILES) distclean: rm -f $(CLEANFILES) Makefile config.cache config.log config.status \ config.h gnuc.h os-proto.h stamp-h stamp-h.in tags: $(TAGFILES) ctags -wtd $(TAGFILES) tar: @cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \ list="" ; tar="tar chf" ; \ for i in `cat FILES` ; do list="$$list $$name/$$i" ; done; \ echo \ "rm -f ../$$name; ln -s $$dir ../$$name" ; \ rm -f ../$$name; ln -s $$dir ../$$name ; \ echo \ "(cd .. ; $$tar - [lots of files]) | compress > /tmp/$$name.tar.Z" ; \ (cd .. ; $$tar - $$list) | compress > /tmp/$$name.tar.Z ; \ echo \ "rm -f ../$$name" ; \ rm -f ../$$name depend: $(GENSRC) ${srcdir}/mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC) tcpdump-3.7.2/makemib0100755000076500000240000001475007351473124013710 0ustar fennerstaff#!/bin/sh # # Copyright (c) 1990, 1996 # John Robert LoVerso. All rights reserved. # SMIv2 parsing copyright (c) 1999 # William C. Fenner. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notices, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notices, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # @(#) $Id: makemib,v 1.3 2001/09/17 22:16:52 fenner Exp $ (jlv) # # This script will read either ASN.1-style MIB files or the ".defs" files # created by the ISODE "mosy" program on such files. # # The output of this script is the "mib.h" file used by tcpdumps' ASN.1/SNMP # decoding code. # # This script needs to be run by "gawk" (GNU awk). "nawk" will work, but # dump will get a recursion error if you process LARGE mibs. While it would # by farily easy to rewrite this not to use recursion (and also easy to # eliminate use of gsub and functions to use classic "awk"), you have to # order the structure declarations in defined-first order for the compiler # not to barf; too bad tsort doesn't take arguments. # cat << EOF /* * This file was generated by tcpdump/makemib on `date` * You probably don't want to edit this by hand! * * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer }; */ EOF awk ' BEGIN { debug=0; # for sanity, we prep the namespace with objects from RFC-1155 # (we manually establish the root) oid["iso"]=1 oidadd("org", "iso", 3) oidadd("dod", "org", 6) oidadd("internet", "dod", 1) oidadd("directory", "internet", 1) oidadd("mgmt", "internet", 2) #XXX oidadd("mib", "mgmt", 1) oidadd("mib-2", "mgmt", 1) oidadd("experimental", "internet", 3) oidadd("private", "internet", 4) oidadd("enterprises", "private", 1) oidadd("ip", "mib-2", 4) oidadd("transmission", "mib-2", 10) holddesc="none" } # # Read mosy "*.defs" file. mosy does all the parsing work; we just read # its simple and straightforward output. It would not be too hard to make # tcpdump directly read mosy output, but... # # Ignore these unless the current file is called something.defs; false # positives are too common in DESCRIPTIONs. NF > 1 && index($2,".")>0 && FILENAME ~ /\.defs/ { # currently ignore items of the form "{ iso.3.6.1 }" if (split($2, p, ".") == 2) { oidadd($1, p[1], p[2]) } next } # # Must be a MIB file # Make it easier to parse - used to be done by sed { sub(/--\*.*\*--/, ""); sub(/--.*/, ""); gsub(/[{}]/, " & "); } # # this next section is simple and naive, but does the job ok # # foo OBJECT IDENTIFIER ::= { baz 17 } # or # foo OBJECT IDENTIFIER ::= # { baz 17 } $2$3$4 == "OBJECTIDENTIFIER::=" { holddesc="none" if (NF == 8) oidadd($1, $6, $7) if (NF == 4) holddesc=$1 next } $1 == "{" && holddesc != "none" && NF == 4 { oidadd(holddesc, $2, $3) holddesc="none" } # # foo OBJECT IDENTIFIER # ::= { bar 1 } $2$3 == "OBJECTIDENTIFIER" && $1 != "SYNTAX" && NF == 3 { holddesc=$1 } # # foo # OBJECT IDENTIFIER ::= { bar 1 } # a couple of heuristics to exclude single words in e.g. long # DESCRIPTION clauses NF == 1 && $1 ~ "[a-z][a-z]*[A-Z]" && $1 !~ /[(){}.,]/ && holddesc == "none" { holddesc=$1 } $1$2$3 == "OBJECTIDENTIFIER::=" && holddesc != "none" { oidadd(holddesc, $5, $6) holddesc="none" } # # "normal" style # foo OBJECT-TYPE ... # ... # ::= { baz 5 } $2 == "MODULE-IDENTITY" || $2 == "MODULE-COMPLIANCE" || $2 == "OBJECT-IDENTITY" || $2 == "OBJECT-TYPE" || $2 == "OBJECT-GROUP" || $2 == "NOTIFICATION-TYPE" || $2 == "NOTIFICATION-GROUP" { holddesc=$1 } $1 == "::=" && holddesc != "none" && NF == 5 { oidadd(holddesc, $3, $4) holddesc="none" } # # foo ::= { baz 17 } $2$3 == "::={" { oidadd($1,$4,$5) holddesc="none" } # # End of the road - output the data. # END { print "struct obj" dump("iso") print "*mibroot = &_iso_obj;" } function inn(file) { if (file == "" || file == "-") return "" return " in " file } # # add a new object to the tree # # new OBJECT IDENTIFIER ::= { parent value } # function oidadd(new, parent, value) { # Ignore 0.0 if (parent == "0" && value == 0) return if (debug) print "/* oidadd" inn(FILENAME) ":", new, "in", parent, "as", value, "line", $0, "*/" # use safe C identifiers gsub(/[-&\/]/,"",new) gsub(/[-&\/]/,"",parent) # check if parent missing if (oid[parent] == "") { printf "/* parse problem%s: no parent for %s.%s(%d) */\n", \ inn(FILENAME), parent, new, value return } # check if parent.value already exists if (oid[new] > 0 && oid[new] != value) { printf "/* parse problem%s: dup %s.%s(%d) != old (%d) */\n", \ inn(FILENAME), parent, new, value, oid[new] return } # check for new name for parent.value if (child[parent] != "") { for (sib = child[parent]; sib != ""; sib = sibling[sib]) if (oid[sib] == value) { if (new != sib) printf "/* parse problem%s: new name" \ " \"%s\"" \ " for %s.%s(%d) ignored */\n", \ inn(FILENAME), new, parent, \ sib, value return } } oid[new]=value if (child[parent] == "") { child[parent] = new } else { sibling[new] = child[parent] child[parent] = new } } # # old(?) routine to recurse down the tree (in postfix order for convenience) # function dump(item, c, s) { # newitem=sofar"."item"("oid[item]")" # printf "/* %s c=%s s=%s */\n", newitem, child[item], sibling[item] c="NULL" if (child[item] != "") { dump(child[item]) c = "&_"child[item]"_obj" } s="NULL" if (sibling[item] != "") { dump(sibling[item]) s = "&_"sibling[item]"_obj" } printf "_%s_obj = {\n\t\"%s\", %d, 0,\n\t%s, %s\n},\n", \ item, item, oid[item], c, s } ' $@ exit 0 tcpdump-3.7.2/mib.h0100644000076500000240000006451407002440607013271 0ustar fennerstaff/* * This file was generated by tcpdump/makemib on Wed Sep 26 12:12:31 EDT 1990 * You probably don't want to edit this by hand! * * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer }; */ /* parse problem: new name "mib" for mgmt.mib(1) ignored */ /* parse problem: no parent for 0.nullSpecific(0) */ struct obj _proteon_obj = { "proteon", 1, 0, NULL, NULL }, _ibm_obj = { "ibm", 2, 0, NULL, &_proteon_obj }, _cmu_obj = { "cmu", 3, 0, NULL, &_ibm_obj }, _unix_obj = { "unix", 4, 0, NULL, &_cmu_obj }, _acc_obj = { "acc", 5, 0, NULL, &_unix_obj }, _twg_obj = { "twg", 6, 0, NULL, &_acc_obj }, _cayman_obj = { "cayman", 7, 0, NULL, &_twg_obj }, _nysernet_obj = { "nysernet", 8, 0, NULL, &_cayman_obj }, _cisco_obj = { "cisco", 9, 0, NULL, &_nysernet_obj }, _nsc_obj = { "nsc", 10, 0, NULL, &_cisco_obj }, _hp_obj = { "hp", 11, 0, NULL, &_nsc_obj }, _epilogue_obj = { "epilogue", 12, 0, NULL, &_hp_obj }, _utennessee_obj = { "utennessee", 13, 0, NULL, &_epilogue_obj }, _bbn_obj = { "bbn", 14, 0, NULL, &_utennessee_obj }, _xylogics_obj = { "xylogics", 15, 0, NULL, &_bbn_obj }, _unisys_obj = { "unisys", 16, 0, NULL, &_xylogics_obj }, _canstar_obj = { "canstar", 17, 0, NULL, &_unisys_obj }, _wellfleet_obj = { "wellfleet", 18, 0, NULL, &_canstar_obj }, _trw_obj = { "trw", 19, 0, NULL, &_wellfleet_obj }, _mit_obj = { "mit", 20, 0, NULL, &_trw_obj }, _eon_obj = { "eon", 21, 0, NULL, &_mit_obj }, _spartacus_obj = { "spartacus", 22, 0, NULL, &_eon_obj }, _excelan_obj = { "excelan", 23, 0, NULL, &_spartacus_obj }, _spider_obj = { "spider", 24, 0, NULL, &_excelan_obj }, _nsfnet_obj = { "nsfnet", 25, 0, NULL, &_spider_obj }, _sytek_obj = { "sytek", 26, 0, NULL, &_nsfnet_obj }, _intergraph_obj = { "intergraph", 27, 0, NULL, &_sytek_obj }, _interlan_obj = { "interlan", 28, 0, NULL, &_intergraph_obj }, _vitalink_obj = { "vitalink", 29, 0, NULL, &_interlan_obj }, _ulana_obj = { "ulana", 30, 0, NULL, &_vitalink_obj }, _nswc_obj = { "nswc", 31, 0, NULL, &_ulana_obj }, _santacruzoperation_obj = { "santacruzoperation", 32, 0, NULL, &_nswc_obj }, _xyplex_obj = { "xyplex", 33, 0, NULL, &_santacruzoperation_obj }, _cray_obj = { "cray", 34, 0, NULL, &_xyplex_obj }, _bellnorthernresearch_obj = { "bellnorthernresearch", 35, 0, NULL, &_cray_obj }, _dec_obj = { "dec", 36, 0, NULL, &_bellnorthernresearch_obj }, _touch_obj = { "touch", 37, 0, NULL, &_dec_obj }, _networkresearchcorp_obj = { "networkresearchcorp", 38, 0, NULL, &_touch_obj }, _baylor_obj = { "baylor", 39, 0, NULL, &_networkresearchcorp_obj }, _nmfeccllnl_obj = { "nmfeccllnl", 40, 0, NULL, &_baylor_obj }, _sri_obj = { "sri", 41, 0, NULL, &_nmfeccllnl_obj }, _sun_obj = { "sun", 42, 0, NULL, &_sri_obj }, _3com_obj = { "3com", 43, 0, NULL, &_sun_obj }, _cmc_obj = { "cmc", 44, 0, NULL, &_3com_obj }, _synoptics_obj = { "synoptics", 45, 0, NULL, &_cmc_obj }, _cheyenne_obj = { "cheyenne", 46, 0, NULL, &_synoptics_obj }, _prime_obj = { "prime", 47, 0, NULL, &_cheyenne_obj }, _mcnc_obj = { "mcnc", 48, 0, NULL, &_prime_obj }, _chipcom_obj = { "chipcom", 49, 0, NULL, &_mcnc_obj }, _opticaldatasystems_obj = { "opticaldatasystems", 50, 0, NULL, &_chipcom_obj }, _gated_obj = { "gated", 51, 0, NULL, &_opticaldatasystems_obj }, _cabletron_obj = { "cabletron", 52, 0, NULL, &_gated_obj }, _apollo_obj = { "apollo", 53, 0, NULL, &_cabletron_obj }, _desktalksystems_obj = { "desktalksystems", 54, 0, NULL, &_apollo_obj }, _ssds_obj = { "ssds", 55, 0, NULL, &_desktalksystems_obj }, _castlerock_obj = { "castlerock", 56, 0, NULL, &_ssds_obj }, _mips_obj = { "mips", 57, 0, NULL, &_castlerock_obj }, _tgv_obj = { "tgv", 58, 0, NULL, &_mips_obj }, _silicongraphics_obj = { "silicongraphics", 59, 0, NULL, &_tgv_obj }, _ubc_obj = { "ubc", 60, 0, NULL, &_silicongraphics_obj }, _merit_obj = { "merit", 61, 0, NULL, &_ubc_obj }, _fibercom_obj = { "fibercom", 62, 0, NULL, &_merit_obj }, _apple_obj = { "apple", 63, 0, NULL, &_fibercom_obj }, _gandalf_obj = { "gandalf", 64, 0, NULL, &_apple_obj }, _dartmouth_obj = { "dartmouth", 65, 0, NULL, &_gandalf_obj }, _davidsystems_obj = { "davidsystems", 66, 0, NULL, &_dartmouth_obj }, _reuter_obj = { "reuter", 67, 0, NULL, &_davidsystems_obj }, _cornell_obj = { "cornell", 68, 0, NULL, &_reuter_obj }, _tmac_obj = { "tmac", 69, 0, NULL, &_cornell_obj }, _locus_obj = { "locus", 70, 0, NULL, &_tmac_obj }, _nasa_obj = { "nasa", 71, 0, NULL, &_locus_obj }, _retix_obj = { "retix", 72, 0, NULL, &_nasa_obj }, _boeing_obj = { "boeing", 73, 0, NULL, &_retix_obj }, _att_obj = { "att", 74, 0, NULL, &_boeing_obj }, _ungermannbass_obj = { "ungermannbass", 75, 0, NULL, &_att_obj }, _digitalanalysis_obj = { "digitalanalysis", 76, 0, NULL, &_ungermannbass_obj }, _hplanman_obj = { "hplanman", 77, 0, NULL, &_digitalanalysis_obj }, _netlabs_obj = { "netlabs", 78, 0, NULL, &_hplanman_obj }, _icl_obj = { "icl", 79, 0, NULL, &_netlabs_obj }, _auspex_obj = { "auspex", 80, 0, NULL, &_icl_obj }, _lannet_obj = { "lannet", 81, 0, NULL, &_auspex_obj }, _ncd_obj = { "ncd", 82, 0, NULL, &_lannet_obj }, _raycom_obj = { "raycom", 83, 0, NULL, &_ncd_obj }, _pirellifocom_obj = { "pirellifocom", 84, 0, NULL, &_raycom_obj }, _datability_obj = { "datability", 85, 0, NULL, &_pirellifocom_obj }, _networkappltech_obj = { "networkappltech", 86, 0, NULL, &_datability_obj }, _link_obj = { "link", 87, 0, NULL, &_networkappltech_obj }, _nyu_obj = { "nyu", 88, 0, NULL, &_link_obj }, _rnd_obj = { "rnd", 89, 0, NULL, &_nyu_obj }, _intercon_obj = { "intercon", 90, 0, NULL, &_rnd_obj }, _learningtree_obj = { "learningtree", 91, 0, NULL, &_intercon_obj }, _webstercomputer_obj = { "webstercomputer", 92, 0, NULL, &_learningtree_obj }, _frontier_obj = { "frontier", 93, 0, NULL, &_webstercomputer_obj }, _nokia_obj = { "nokia", 94, 0, NULL, &_frontier_obj }, _allenbradley_obj = { "allenbradley", 95, 0, NULL, &_nokia_obj }, _cern_obj = { "cern", 96, 0, NULL, &_allenbradley_obj }, _sigma_obj = { "sigma", 97, 0, NULL, &_cern_obj }, _emergingtech_obj = { "emergingtech", 98, 0, NULL, &_sigma_obj }, _snmpresearch_obj = { "snmpresearch", 99, 0, NULL, &_emergingtech_obj }, _ohiostate_obj = { "ohiostate", 100, 0, NULL, &_snmpresearch_obj }, _ultra_obj = { "ultra", 101, 0, NULL, &_ohiostate_obj }, _ccur_obj = { "ccur", 136, 0, NULL, &_ultra_obj }, _enterprises_obj = { "enterprises", 1, 0, &_ccur_obj, NULL }, _snmpInPkts_obj = { "snmpInPkts", 1, 0, NULL, NULL }, _snmpOutPkts_obj = { "snmpOutPkts", 2, 0, NULL, &_snmpInPkts_obj }, _snmpInBadVersions_obj = { "snmpInBadVersions", 3, 0, NULL, &_snmpOutPkts_obj }, _snmpInBadCommunityNames_obj = { "snmpInBadCommunityNames", 4, 0, NULL, &_snmpInBadVersions_obj }, _snmpInBadCommunityUses_obj = { "snmpInBadCommunityUses", 5, 0, NULL, &_snmpInBadCommunityNames_obj }, _snmpInASNParseErrs_obj = { "snmpInASNParseErrs", 6, 0, NULL, &_snmpInBadCommunityUses_obj }, _snmpInBadTypes_obj = { "snmpInBadTypes", 7, 0, NULL, &_snmpInASNParseErrs_obj }, _snmpInTooBigs_obj = { "snmpInTooBigs", 8, 0, NULL, &_snmpInBadTypes_obj }, _snmpInNoSuchNames_obj = { "snmpInNoSuchNames", 9, 0, NULL, &_snmpInTooBigs_obj }, _snmpInBadValues_obj = { "snmpInBadValues", 10, 0, NULL, &_snmpInNoSuchNames_obj }, _snmpInReadOnlys_obj = { "snmpInReadOnlys", 11, 0, NULL, &_snmpInBadValues_obj }, _snmpInGenErrs_obj = { "snmpInGenErrs", 12, 0, NULL, &_snmpInReadOnlys_obj }, _snmpInTotalReqVars_obj = { "snmpInTotalReqVars", 13, 0, NULL, &_snmpInGenErrs_obj }, _snmpInTotalSetVars_obj = { "snmpInTotalSetVars", 14, 0, NULL, &_snmpInTotalReqVars_obj }, _snmpInGetRequests_obj = { "snmpInGetRequests", 15, 0, NULL, &_snmpInTotalSetVars_obj }, _snmpInGetNexts_obj = { "snmpInGetNexts", 16, 0, NULL, &_snmpInGetRequests_obj }, _snmpInSetRequests_obj = { "snmpInSetRequests", 17, 0, NULL, &_snmpInGetNexts_obj }, _snmpInGetResponses_obj = { "snmpInGetResponses", 18, 0, NULL, &_snmpInSetRequests_obj }, _snmpInTraps_obj = { "snmpInTraps", 19, 0, NULL, &_snmpInGetResponses_obj }, _snmpOutTooBigs_obj = { "snmpOutTooBigs", 20, 0, NULL, &_snmpInTraps_obj }, _snmpOutNoSuchNames_obj = { "snmpOutNoSuchNames", 21, 0, NULL, &_snmpOutTooBigs_obj }, _snmpOutBadValues_obj = { "snmpOutBadValues", 22, 0, NULL, &_snmpOutNoSuchNames_obj }, _snmpOutReadOnlys_obj = { "snmpOutReadOnlys", 23, 0, NULL, &_snmpOutBadValues_obj }, _snmpOutGenErrs_obj = { "snmpOutGenErrs", 24, 0, NULL, &_snmpOutReadOnlys_obj }, _snmpOutGetRequests_obj = { "snmpOutGetRequests", 25, 0, NULL, &_snmpOutGenErrs_obj }, _snmpOutGetNexts_obj = { "snmpOutGetNexts", 26, 0, NULL, &_snmpOutGetRequests_obj }, _snmpOutSetRequests_obj = { "snmpOutSetRequests", 27, 0, NULL, &_snmpOutGetNexts_obj }, _snmpOutGetResponses_obj = { "snmpOutGetResponses", 28, 0, NULL, &_snmpOutSetRequests_obj }, _snmpOutTraps_obj = { "snmpOutTraps", 29, 0, NULL, &_snmpOutGetResponses_obj }, _snmpEnableAuthTraps_obj = { "snmpEnableAuthTraps", 30, 0, NULL, &_snmpOutTraps_obj }, _egpNeighState_obj = { "egpNeighState", 1, 0, NULL, NULL }, _egpNeighAddr_obj = { "egpNeighAddr", 2, 0, NULL, &_egpNeighState_obj }, _egpNeighAs_obj = { "egpNeighAs", 3, 0, NULL, &_egpNeighAddr_obj }, _egpNeighInMsgs_obj = { "egpNeighInMsgs", 4, 0, NULL, &_egpNeighAs_obj }, _egpNeighInErrs_obj = { "egpNeighInErrs", 5, 0, NULL, &_egpNeighInMsgs_obj }, _egpNeighOutMsgs_obj = { "egpNeighOutMsgs", 6, 0, NULL, &_egpNeighInErrs_obj }, _egpNeighOutErrs_obj = { "egpNeighOutErrs", 7, 0, NULL, &_egpNeighOutMsgs_obj }, _egpNeighInErrMsgs_obj = { "egpNeighInErrMsgs", 8, 0, NULL, &_egpNeighOutErrs_obj }, _egpNeighOutErrMsgs_obj = { "egpNeighOutErrMsgs", 9, 0, NULL, &_egpNeighInErrMsgs_obj }, _egpNeighStateUps_obj = { "egpNeighStateUps", 10, 0, NULL, &_egpNeighOutErrMsgs_obj }, _egpNeighStateDowns_obj = { "egpNeighStateDowns", 11, 0, NULL, &_egpNeighStateUps_obj }, _egpNeighIntervalHello_obj = { "egpNeighIntervalHello", 12, 0, NULL, &_egpNeighStateDowns_obj }, _egpNeighIntervalPoll_obj = { "egpNeighIntervalPoll", 13, 0, NULL, &_egpNeighIntervalHello_obj }, _egpNeighMode_obj = { "egpNeighMode", 14, 0, NULL, &_egpNeighIntervalPoll_obj }, _egpNeighEventTrigger_obj = { "egpNeighEventTrigger", 15, 0, NULL, &_egpNeighMode_obj }, _egpNeighEntry_obj = { "egpNeighEntry", 1, 0, &_egpNeighEventTrigger_obj, NULL }, _egpInMsgs_obj = { "egpInMsgs", 1, 0, NULL, NULL }, _egpInErrors_obj = { "egpInErrors", 2, 0, NULL, &_egpInMsgs_obj }, _egpOutMsgs_obj = { "egpOutMsgs", 3, 0, NULL, &_egpInErrors_obj }, _egpOutErrors_obj = { "egpOutErrors", 4, 0, NULL, &_egpOutMsgs_obj }, _egpNeighTable_obj = { "egpNeighTable", 5, 0, &_egpNeighEntry_obj, &_egpOutErrors_obj }, _egpAs_obj = { "egpAs", 6, 0, NULL, &_egpNeighTable_obj }, _udpLocalAddress_obj = { "udpLocalAddress", 1, 0, NULL, NULL }, _udpLocalPort_obj = { "udpLocalPort", 2, 0, NULL, &_udpLocalAddress_obj }, _udpEntry_obj = { "udpEntry", 1, 0, &_udpLocalPort_obj, NULL }, _udpInDatagrams_obj = { "udpInDatagrams", 1, 0, NULL, NULL }, _udpNoPorts_obj = { "udpNoPorts", 2, 0, NULL, &_udpInDatagrams_obj }, _udpInErrors_obj = { "udpInErrors", 3, 0, NULL, &_udpNoPorts_obj }, _udpOutDatagrams_obj = { "udpOutDatagrams", 4, 0, NULL, &_udpInErrors_obj }, _udpTable_obj = { "udpTable", 5, 0, &_udpEntry_obj, &_udpOutDatagrams_obj }, _tcpConnState_obj = { "tcpConnState", 1, 0, NULL, NULL }, _tcpConnLocalAddress_obj = { "tcpConnLocalAddress", 2, 0, NULL, &_tcpConnState_obj }, _tcpConnLocalPort_obj = { "tcpConnLocalPort", 3, 0, NULL, &_tcpConnLocalAddress_obj }, _tcpConnRemAddress_obj = { "tcpConnRemAddress", 4, 0, NULL, &_tcpConnLocalPort_obj }, _tcpConnRemPort_obj = { "tcpConnRemPort", 5, 0, NULL, &_tcpConnRemAddress_obj }, _tcpConnEntry_obj = { "tcpConnEntry", 1, 0, &_tcpConnRemPort_obj, NULL }, _tcpRtoAlgorithm_obj = { "tcpRtoAlgorithm", 1, 0, NULL, NULL }, _tcpRtoMin_obj = { "tcpRtoMin", 2, 0, NULL, &_tcpRtoAlgorithm_obj }, _tcpRtoMax_obj = { "tcpRtoMax", 3, 0, NULL, &_tcpRtoMin_obj }, _tcpMaxConn_obj = { "tcpMaxConn", 4, 0, NULL, &_tcpRtoMax_obj }, _tcpActiveOpens_obj = { "tcpActiveOpens", 5, 0, NULL, &_tcpMaxConn_obj }, _tcpPassiveOpens_obj = { "tcpPassiveOpens", 6, 0, NULL, &_tcpActiveOpens_obj }, _tcpAttemptFails_obj = { "tcpAttemptFails", 7, 0, NULL, &_tcpPassiveOpens_obj }, _tcpEstabResets_obj = { "tcpEstabResets", 8, 0, NULL, &_tcpAttemptFails_obj }, _tcpCurrEstab_obj = { "tcpCurrEstab", 9, 0, NULL, &_tcpEstabResets_obj }, _tcpInSegs_obj = { "tcpInSegs", 10, 0, NULL, &_tcpCurrEstab_obj }, _tcpOutSegs_obj = { "tcpOutSegs", 11, 0, NULL, &_tcpInSegs_obj }, _tcpRetransSegs_obj = { "tcpRetransSegs", 12, 0, NULL, &_tcpOutSegs_obj }, _tcpConnTable_obj = { "tcpConnTable", 13, 0, &_tcpConnEntry_obj, &_tcpRetransSegs_obj }, _tcpInErrs_obj = { "tcpInErrs", 14, 0, NULL, &_tcpConnTable_obj }, _tcpOutRsts_obj = { "tcpOutRsts", 15, 0, NULL, &_tcpInErrs_obj }, _icmpInMsgs_obj = { "icmpInMsgs", 1, 0, NULL, NULL }, _icmpInErrors_obj = { "icmpInErrors", 2, 0, NULL, &_icmpInMsgs_obj }, _icmpInDestUnreachs_obj = { "icmpInDestUnreachs", 3, 0, NULL, &_icmpInErrors_obj }, _icmpInTimeExcds_obj = { "icmpInTimeExcds", 4, 0, NULL, &_icmpInDestUnreachs_obj }, _icmpInParmProbs_obj = { "icmpInParmProbs", 5, 0, NULL, &_icmpInTimeExcds_obj }, _icmpInSrcQuenchs_obj = { "icmpInSrcQuenchs", 6, 0, NULL, &_icmpInParmProbs_obj }, _icmpInRedirects_obj = { "icmpInRedirects", 7, 0, NULL, &_icmpInSrcQuenchs_obj }, _icmpInEchos_obj = { "icmpInEchos", 8, 0, NULL, &_icmpInRedirects_obj }, _icmpInEchoReps_obj = { "icmpInEchoReps", 9, 0, NULL, &_icmpInEchos_obj }, _icmpInTimestamps_obj = { "icmpInTimestamps", 10, 0, NULL, &_icmpInEchoReps_obj }, _icmpInTimestampReps_obj = { "icmpInTimestampReps", 11, 0, NULL, &_icmpInTimestamps_obj }, _icmpInAddrMasks_obj = { "icmpInAddrMasks", 12, 0, NULL, &_icmpInTimestampReps_obj }, _icmpInAddrMaskReps_obj = { "icmpInAddrMaskReps", 13, 0, NULL, &_icmpInAddrMasks_obj }, _icmpOutMsgs_obj = { "icmpOutMsgs", 14, 0, NULL, &_icmpInAddrMaskReps_obj }, _icmpOutErrors_obj = { "icmpOutErrors", 15, 0, NULL, &_icmpOutMsgs_obj }, _icmpOutDestUnreachs_obj = { "icmpOutDestUnreachs", 16, 0, NULL, &_icmpOutErrors_obj }, _icmpOutTimeExcds_obj = { "icmpOutTimeExcds", 17, 0, NULL, &_icmpOutDestUnreachs_obj }, _icmpOutParmProbs_obj = { "icmpOutParmProbs", 18, 0, NULL, &_icmpOutTimeExcds_obj }, _icmpOutSrcQuenchs_obj = { "icmpOutSrcQuenchs", 19, 0, NULL, &_icmpOutParmProbs_obj }, _icmpOutRedirects_obj = { "icmpOutRedirects", 20, 0, NULL, &_icmpOutSrcQuenchs_obj }, _icmpOutEchos_obj = { "icmpOutEchos", 21, 0, NULL, &_icmpOutRedirects_obj }, _icmpOutEchoReps_obj = { "icmpOutEchoReps", 22, 0, NULL, &_icmpOutEchos_obj }, _icmpOutTimestamps_obj = { "icmpOutTimestamps", 23, 0, NULL, &_icmpOutEchoReps_obj }, _icmpOutTimestampReps_obj = { "icmpOutTimestampReps", 24, 0, NULL, &_icmpOutTimestamps_obj }, _icmpOutAddrMasks_obj = { "icmpOutAddrMasks", 25, 0, NULL, &_icmpOutTimestampReps_obj }, _icmpOutAddrMaskReps_obj = { "icmpOutAddrMaskReps", 26, 0, NULL, &_icmpOutAddrMasks_obj }, _ipNetToMediaIfIndex_obj = { "ipNetToMediaIfIndex", 1, 0, NULL, NULL }, _ipNetToMediaPhysAddress_obj = { "ipNetToMediaPhysAddress", 2, 0, NULL, &_ipNetToMediaIfIndex_obj }, _ipNetToMediaNetAddress_obj = { "ipNetToMediaNetAddress", 3, 0, NULL, &_ipNetToMediaPhysAddress_obj }, _ipNetToMediaType_obj = { "ipNetToMediaType", 4, 0, NULL, &_ipNetToMediaNetAddress_obj }, _ipNetToMediaEntry_obj = { "ipNetToMediaEntry", 1, 0, &_ipNetToMediaType_obj, NULL }, _ipRouteDest_obj = { "ipRouteDest", 1, 0, NULL, NULL }, _ipRouteIfIndex_obj = { "ipRouteIfIndex", 2, 0, NULL, &_ipRouteDest_obj }, _ipRouteMetric1_obj = { "ipRouteMetric1", 3, 0, NULL, &_ipRouteIfIndex_obj }, _ipRouteMetric2_obj = { "ipRouteMetric2", 4, 0, NULL, &_ipRouteMetric1_obj }, _ipRouteMetric3_obj = { "ipRouteMetric3", 5, 0, NULL, &_ipRouteMetric2_obj }, _ipRouteMetric4_obj = { "ipRouteMetric4", 6, 0, NULL, &_ipRouteMetric3_obj }, _ipRouteNextHop_obj = { "ipRouteNextHop", 7, 0, NULL, &_ipRouteMetric4_obj }, _ipRouteType_obj = { "ipRouteType", 8, 0, NULL, &_ipRouteNextHop_obj }, _ipRouteProto_obj = { "ipRouteProto", 9, 0, NULL, &_ipRouteType_obj }, _ipRouteAge_obj = { "ipRouteAge", 10, 0, NULL, &_ipRouteProto_obj }, _ipRouteMask_obj = { "ipRouteMask", 11, 0, NULL, &_ipRouteAge_obj }, _ipRouteEntry_obj = { "ipRouteEntry", 1, 0, &_ipRouteMask_obj, NULL }, _ipAdEntAddr_obj = { "ipAdEntAddr", 1, 0, NULL, NULL }, _ipAdEntIfIndex_obj = { "ipAdEntIfIndex", 2, 0, NULL, &_ipAdEntAddr_obj }, _ipAdEntNetMask_obj = { "ipAdEntNetMask", 3, 0, NULL, &_ipAdEntIfIndex_obj }, _ipAdEntBcastAddr_obj = { "ipAdEntBcastAddr", 4, 0, NULL, &_ipAdEntNetMask_obj }, _ipAdEntReasmMaxSize_obj = { "ipAdEntReasmMaxSize", 5, 0, NULL, &_ipAdEntBcastAddr_obj }, _ipAddrEntry_obj = { "ipAddrEntry", 1, 0, &_ipAdEntReasmMaxSize_obj, NULL }, _ipForwarding_obj = { "ipForwarding", 1, 0, NULL, NULL }, _ipDefaultTTL_obj = { "ipDefaultTTL", 2, 0, NULL, &_ipForwarding_obj }, _ipInReceives_obj = { "ipInReceives", 3, 0, NULL, &_ipDefaultTTL_obj }, _ipInHdrErrors_obj = { "ipInHdrErrors", 4, 0, NULL, &_ipInReceives_obj }, _ipInAddrErrors_obj = { "ipInAddrErrors", 5, 0, NULL, &_ipInHdrErrors_obj }, _ipForwDatagrams_obj = { "ipForwDatagrams", 6, 0, NULL, &_ipInAddrErrors_obj }, _ipInUnknownProtos_obj = { "ipInUnknownProtos", 7, 0, NULL, &_ipForwDatagrams_obj }, _ipInDiscards_obj = { "ipInDiscards", 8, 0, NULL, &_ipInUnknownProtos_obj }, _ipInDelivers_obj = { "ipInDelivers", 9, 0, NULL, &_ipInDiscards_obj }, _ipOutRequests_obj = { "ipOutRequests", 10, 0, NULL, &_ipInDelivers_obj }, _ipOutDiscards_obj = { "ipOutDiscards", 11, 0, NULL, &_ipOutRequests_obj }, _ipOutNoRoutes_obj = { "ipOutNoRoutes", 12, 0, NULL, &_ipOutDiscards_obj }, _ipReasmTimeout_obj = { "ipReasmTimeout", 13, 0, NULL, &_ipOutNoRoutes_obj }, _ipReasmReqds_obj = { "ipReasmReqds", 14, 0, NULL, &_ipReasmTimeout_obj }, _ipReasmOKs_obj = { "ipReasmOKs", 15, 0, NULL, &_ipReasmReqds_obj }, _ipReasmFails_obj = { "ipReasmFails", 16, 0, NULL, &_ipReasmOKs_obj }, _ipFragOKs_obj = { "ipFragOKs", 17, 0, NULL, &_ipReasmFails_obj }, _ipFragFails_obj = { "ipFragFails", 18, 0, NULL, &_ipFragOKs_obj }, _ipFragCreates_obj = { "ipFragCreates", 19, 0, NULL, &_ipFragFails_obj }, _ipAddrTable_obj = { "ipAddrTable", 20, 0, &_ipAddrEntry_obj, &_ipFragCreates_obj }, _ipRoutingTable_obj = { "ipRoutingTable", 21, 0, &_ipRouteEntry_obj, &_ipAddrTable_obj }, _ipNetToMediaTable_obj = { "ipNetToMediaTable", 22, 0, &_ipNetToMediaEntry_obj, &_ipRoutingTable_obj }, _atIfIndex_obj = { "atIfIndex", 1, 0, NULL, NULL }, _atPhysAddress_obj = { "atPhysAddress", 2, 0, NULL, &_atIfIndex_obj }, _atNetAddress_obj = { "atNetAddress", 3, 0, NULL, &_atPhysAddress_obj }, _atEntry_obj = { "atEntry", 1, 0, &_atNetAddress_obj, NULL }, _atTable_obj = { "atTable", 1, 0, &_atEntry_obj, NULL }, _ifIndex_obj = { "ifIndex", 1, 0, NULL, NULL }, _ifDescr_obj = { "ifDescr", 2, 0, NULL, &_ifIndex_obj }, _ifType_obj = { "ifType", 3, 0, NULL, &_ifDescr_obj }, _ifMtu_obj = { "ifMtu", 4, 0, NULL, &_ifType_obj }, _ifSpeed_obj = { "ifSpeed", 5, 0, NULL, &_ifMtu_obj }, _ifPhysAddress_obj = { "ifPhysAddress", 6, 0, NULL, &_ifSpeed_obj }, _ifAdminStatus_obj = { "ifAdminStatus", 7, 0, NULL, &_ifPhysAddress_obj }, _ifOperStatus_obj = { "ifOperStatus", 8, 0, NULL, &_ifAdminStatus_obj }, _ifLastChange_obj = { "ifLastChange", 9, 0, NULL, &_ifOperStatus_obj }, _ifInOctets_obj = { "ifInOctets", 10, 0, NULL, &_ifLastChange_obj }, _ifInUcastPkts_obj = { "ifInUcastPkts", 11, 0, NULL, &_ifInOctets_obj }, _ifInNUcastPkts_obj = { "ifInNUcastPkts", 12, 0, NULL, &_ifInUcastPkts_obj }, _ifInDiscards_obj = { "ifInDiscards", 13, 0, NULL, &_ifInNUcastPkts_obj }, _ifInErrors_obj = { "ifInErrors", 14, 0, NULL, &_ifInDiscards_obj }, _ifInUnknownProtos_obj = { "ifInUnknownProtos", 15, 0, NULL, &_ifInErrors_obj }, _ifOutOctets_obj = { "ifOutOctets", 16, 0, NULL, &_ifInUnknownProtos_obj }, _ifOutUcastPkts_obj = { "ifOutUcastPkts", 17, 0, NULL, &_ifOutOctets_obj }, _ifOutNUcastPkts_obj = { "ifOutNUcastPkts", 18, 0, NULL, &_ifOutUcastPkts_obj }, _ifOutDiscards_obj = { "ifOutDiscards", 19, 0, NULL, &_ifOutNUcastPkts_obj }, _ifOutErrors_obj = { "ifOutErrors", 20, 0, NULL, &_ifOutDiscards_obj }, _ifOutQLen_obj = { "ifOutQLen", 21, 0, NULL, &_ifOutErrors_obj }, _ifSpecific_obj = { "ifSpecific", 22, 0, NULL, &_ifOutQLen_obj }, _ifEntry_obj = { "ifEntry", 1, 0, &_ifSpecific_obj, NULL }, _ifNumber_obj = { "ifNumber", 1, 0, NULL, NULL }, _ifTable_obj = { "ifTable", 2, 0, &_ifEntry_obj, &_ifNumber_obj }, _sysDescr_obj = { "sysDescr", 1, 0, NULL, NULL }, _sysObjectID_obj = { "sysObjectID", 2, 0, NULL, &_sysDescr_obj }, _sysUpTime_obj = { "sysUpTime", 3, 0, NULL, &_sysObjectID_obj }, _sysContact_obj = { "sysContact", 4, 0, NULL, &_sysUpTime_obj }, _sysName_obj = { "sysName", 5, 0, NULL, &_sysContact_obj }, _sysLocation_obj = { "sysLocation", 6, 0, NULL, &_sysName_obj }, _sysServices_obj = { "sysServices", 7, 0, NULL, &_sysLocation_obj }, _system_obj = { "system", 1, 0, &_sysServices_obj, NULL }, _interfaces_obj = { "interfaces", 2, 0, &_ifTable_obj, &_system_obj }, _at_obj = { "at", 3, 0, &_atTable_obj, &_interfaces_obj }, _ip_obj = { "ip", 4, 0, &_ipNetToMediaTable_obj, &_at_obj }, _icmp_obj = { "icmp", 5, 0, &_icmpOutAddrMaskReps_obj, &_ip_obj }, _tcp_obj = { "tcp", 6, 0, &_tcpOutRsts_obj, &_icmp_obj }, _udp_obj = { "udp", 7, 0, &_udpTable_obj, &_tcp_obj }, _egp_obj = { "egp", 8, 0, &_egpAs_obj, &_udp_obj }, _transmission_obj = { "transmission", 10, 0, NULL, &_egp_obj }, _snmp_obj = { "snmp", 11, 0, &_snmpEnableAuthTraps_obj, &_transmission_obj }, _usmMIBCompliances_obj = { "usmMIBCompliances", 1, 0, NULL, NULL }, _usmMIBGroups_obj = { "usmMIBGroups", 2, 0, NULL, &_usmMIBCompliances_obj }, _usmUserEngineID_obj = { "usmUserEngineID", 1, 0, NULL, NULL }, _usmUserName_obj = { "usmUserName", 2, 0, NULL, &_usmUserEngineID_obj }, _usmUserSecurityName_obj = { "usmUserSecurityName", 3, 0, NULL, &_usmUserName_obj }, _usmUserCloneFrom_obj = { "usmUserCloneFrom", 4, 0, NULL, &_usmUserSecurityName_obj }, _usmUserAuthProtocol_obj = { "usmUserAuthProtocol", 5, 0, NULL, &_usmUserCloneFrom_obj }, _usmUserAuthKeyChange_obj = { "usmUserAuthKeyChange", 6, 0, NULL, &_usmUserAuthProtocol_obj }, _usmUserOwnAuthKeyChange_obj = { "usmUserOwnAuthKeyChange", 7, 0, NULL, &_usmUserAuthKeyChange_obj }, _usmUserPrivProtocol_obj = { "usmUserPrivProtocol", 8, 0, NULL, &_usmUserOwnAuthKeyChange_obj }, _usmUserPrivKeyChange_obj = { "usmUserPrivKeyChange", 9, 0, NULL, &_usmUserPrivProtocol_obj }, _usmUserOwnPrivKeyChange_obj = { "usmUserOwnPrivKeyChange", 10, 0, NULL, &_usmUserPrivKeyChange_obj }, _usmUserPublic_obj = { "usmUserPublic", 11, 0, NULL, &_usmUserOwnPrivKeyChange_obj }, _usmUserStorageType_obj = { "usmUserStorageType", 12, 0, NULL, &_usmUserPublic_obj }, _usmUserStatus_obj = { "usmUserStatus", 13, 0, NULL, &_usmUserStorageType_obj }, _usmUserEntry_obj = { "usmUserEntry", 1, 0, &_usmUserStatus_obj, NULL }, _usmUserSpinLock_obj = { "usmUserSpinLock", 1, 0, NULL, NULL }, _usmUserTable_obj = { "usmUserTable", 2, 0, &_usmUserEntry_obj, &_usmUserSpinLock_obj }, _usmStatsUnsupportedSecLevels_obj = { "usmStatsUnsupportedSecLevels", 1, 0, NULL, NULL }, _usmStatsNotInTimeWindows_obj = { "usmStatsNotInTimeWindows", 2, 0, NULL, &_usmStatsUnsupportedSecLevels_obj }, _usmStatsUnknownUserNames_obj = { "usmStatsUnknownUserNames", 3, 0, NULL, &_usmStatsNotInTimeWindows_obj }, _usmStatsUnknownEngineIDs_obj = { "usmStatsUnknownEngineIDs", 4, 0, NULL, &_usmStatsUnknownUserNames_obj }, _usmStatsWrongDigests_obj = { "usmStatsWrongDigests", 5, 0, NULL, &_usmStatsUnknownEngineIDs_obj }, _usmStatsDecryptionErrors_obj = { "usmStatsDecryptionErrors", 6, 0, NULL, &_usmStatsWrongDigests_obj }, _usmStats_obj = { "usmStats", 1, 0, &_usmStatsDecryptionErrors_obj, NULL }, _usmUser_obj = { "usmUser", 2, 0, &_usmUserTable_obj, &_usmStats_obj }, _usmMIBObjects_obj = { "usmMIBObjects", 1, 0, &_usmUser_obj, NULL }, _usmMIBConformance_obj = { "usmMIBConformance", 2, 0, &_usmMIBGroups_obj, &_usmMIBObjects_obj }, _snmpMPDMIBCompliances_obj = { "snmpMPDMIBCompliances", 1, 0, NULL, NULL }, _snmpMPDMIBGroups_obj = { "snmpMPDMIBGroups", 2, 0, NULL, &_snmpMPDMIBCompliances_obj }, _snmpUnknownSecurityModels_obj = { "snmpUnknownSecurityModels", 1, 0, NULL, NULL }, _snmpInvalidMsgs_obj = { "snmpInvalidMsgs", 2, 0, NULL, &_snmpUnknownSecurityModels_obj }, _snmpUnknownPDUHandlers_obj = { "snmpUnknownPDUHandlers", 3, 0, NULL, &_snmpInvalidMsgs_obj }, _snmpMPDStats_obj = { "snmpMPDStats", 1, 0, &_snmpUnknownPDUHandlers_obj, NULL }, _snmpMPDAdmin_obj = { "snmpMPDAdmin", 1, 0, NULL, NULL }, _snmpMPDMIBObjects_obj = { "snmpMPDMIBObjects", 2, 0, &_snmpMPDStats_obj, &_snmpMPDAdmin_obj }, _snmpMPDMIBConformance_obj = { "snmpMPDMIBConformance", 3, 0, &_snmpMPDMIBGroups_obj, &_snmpMPDMIBObjects_obj }, _snmpEngineID_obj = { "snmpEngineID", 1, 0, NULL, NULL }, _snmpEngineBoots_obj = { "snmpEngineBoots", 2, 0, NULL, &_snmpEngineID_obj }, _snmpEngineTime_obj = { "snmpEngineTime", 3, 0, NULL, &_snmpEngineBoots_obj }, _snmpEngineMaxMessageSize_obj = { "snmpEngineMaxMessageSize", 4, 0, NULL, &_snmpEngineTime_obj }, _snmpEngine_obj = { "snmpEngine", 1, 0, &_snmpEngineMaxMessageSize_obj, NULL }, _snmpFrameworkAdmin_obj = { "snmpFrameworkAdmin", 1, 0, NULL, NULL }, _snmpFrameworkMIBObjects_obj = { "snmpFrameworkMIBObjects", 2, 0, &_snmpEngine_obj, &_snmpFrameworkAdmin_obj }, _snmpFrameworkMIBConformance_obj = { "snmpFrameworkMIBConformance", 3, 0, NULL, &_snmpFrameworkMIBObjects_obj }, _snmpFrameworkMIB_obj = { "snmpFrameworkMIB", 10, 0, &_snmpFrameworkMIBConformance_obj, NULL }, _snmpMPDMIB_obj = { "snmpMPDMIB", 11, 0, &_snmpMPDMIBConformance_obj, &_snmpFrameworkMIB_obj }, _snmpUsmMIB_obj = { "snmpUsmMIB", 15, 0, &_usmMIBConformance_obj, &_snmpMPDMIB_obj }, _snmpModules_obj = { "snmpModules", 3, 0, &_snmpUsmMIB_obj, NULL }, _mib_obj = { "mib", 1, 0, &_snmp_obj, NULL }, _directory_obj = { "directory", 1, 0, NULL, NULL }, _mgmt_obj = { "mgmt", 2, 0, &_mib_obj, &_directory_obj }, _experimental_obj = { "experimental", 3, 0, NULL, &_mgmt_obj }, _private_obj = { "private", 4, 0, &_enterprises_obj, &_experimental_obj }, _security_obj = { "security", 5, 0, NULL, &_private_obj }, _snmpV2_obj = { "snmpV2", 6, 0, &_snmpModules_obj, &_security_obj }, _internet_obj = { "internet", 1, 0, &_snmpV2_obj, NULL }, _dod_obj = { "dod", 6, 0, &_internet_obj, NULL }, _org_obj = { "org", 3, 0, &_dod_obj, NULL }, _iso_obj = { "iso", 1, 0, &_org_obj, NULL }, *mibroot = &_iso_obj; tcpdump-3.7.2/missing/0040755000076500000240000000000007423403561014020 5ustar fennerstafftcpdump-3.7.2/missing/addrinfo.h0100644000076500000240000001120707175157124015762 0ustar fennerstaff/* * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* $Id: addrinfo.h,v 1.3 2000/10/24 00:56:52 fenner Exp $ */ #ifndef HAVE_ADDRINFO /* * Error return codes from getaddrinfo() */ #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ #define EAI_AGAIN 2 /* temporary failure in name resolution */ #define EAI_BADFLAGS 3 /* invalid value for ai_flags */ #define EAI_FAIL 4 /* non-recoverable failure in name resolution */ #define EAI_FAMILY 5 /* ai_family not supported */ #define EAI_MEMORY 6 /* memory allocation failure */ #define EAI_NODATA 7 /* no address associated with hostname */ #define EAI_NONAME 8 /* hostname nor servname provided, or not known */ #define EAI_SERVICE 9 /* servname not supported for ai_socktype */ #define EAI_SOCKTYPE 10 /* ai_socktype not supported */ #define EAI_SYSTEM 11 /* system error returned in errno */ #define EAI_BADHINTS 12 #define EAI_PROTOCOL 13 #define EAI_MAX 14 /* internal error */ #define NETDB_INTERNAL -1 /* see errno */ /* * Flag values for getaddrinfo() */ #define AI_PASSIVE 0x00000001 /* get address to use bind() */ #define AI_CANONNAME 0x00000002 /* fill ai_canonname */ #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ /* valid flags for addrinfo */ #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ /* special recommended flags for getipnodebyname */ #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) struct addrinfo { int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ int ai_family; /* PF_xxx */ int ai_socktype; /* SOCK_xxx */ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ size_t ai_addrlen; /* length of ai_addr */ char *ai_canonname; /* canonical name for hostname */ struct sockaddr *ai_addr; /* binary address */ struct addrinfo *ai_next; /* next structure in linked list */ }; extern void freeaddrinfo (struct addrinfo *); extern void freehostent (struct hostent *); extern char *gai_strerror (int); extern int getaddrinfo (const char *, const char *, const struct addrinfo *, struct addrinfo **); extern int getnameinfo (const struct sockaddr *, size_t, char *, size_t, char *, size_t, int); extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *); extern struct hostent *getipnodebyname (const char *, int, int, int *); extern int inet_pton (int, const char *, void *); extern const char *inet_ntop (int, const void *, char *, size_t); #endif /* HAVE_ADDRINFO */ /* * Constants for getnameinfo() */ #ifndef NI_MAXHOST #define NI_MAXHOST 1025 #endif #ifndef NI_MAXSERV #define NI_MAXSERV 32 #endif /* * Flag values for getnameinfo() */ #ifndef NI_NOFQDN #define NI_NOFQDN 0x00000001 #endif #ifndef NI_NUMERICHOST #define NI_NUMERICHOST 0x00000002 #endif #ifndef NI_NAMEREQD #define NI_NAMEREQD 0x00000004 #endif #ifndef NI_NUMERICSERV #define NI_NUMERICSERV 0x00000008 #endif #ifndef NI_DGRAM #define NI_DGRAM 0x00000010 #endif tcpdump-3.7.2/missing/addrsize.h0100644000076500000240000000322207006476773016006 0ustar fennerstaff/* * 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 tcpdump-3.7.2/missing/bittypes.h0100644000076500000240000000451107006476773016046 0ustar fennerstaff/* * 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 */ tcpdump-3.7.2/missing/CVS/0040755000076500000240000000000007627054635014465 5ustar fennerstafftcpdump-3.7.2/missing/CVS/Entries0100644000076500000240000000150507627054635016017 0ustar fennerstaff/addrinfo.h/1.3/Tue Oct 24 00:56:52 2000//Ttcpdump_3_7 /addrsize.h/1.1/Sat Oct 30 05:11:23 1999//Ttcpdump_3_7 /bittypes.h/1.1/Sat Oct 30 05:11:23 1999//Ttcpdump_3_7 /getaddrinfo.c/1.10/Tue Oct 24 00:56:53 2000//Ttcpdump_3_7 /getnameinfo.c/1.8/Tue Oct 24 00:56:53 2000//Ttcpdump_3_7 /inet_aton.c/1.2/Sun Jan 9 21:35:45 2000//Ttcpdump_3_7 /inet_ntop.c/1.3/Sun Jan 9 21:35:45 2000//Ttcpdump_3_7 /inet_pton.c/1.2/Sun Jan 9 21:35:46 2000//Ttcpdump_3_7 /resolv6.h/1.1/Sat Oct 30 05:11:24 1999//Ttcpdump_3_7 /resolv_ext.h/1.1/Sat Oct 30 05:11:24 1999//Ttcpdump_3_7 /snprintf.c/1.5/Fri Jan 12 10:14:40 2001//Ttcpdump_3_7 /sockstorage.h/1.1/Sat Oct 30 05:11:24 1999//Ttcpdump_3_7 /strdup.c/1.1/Sat Jan 20 07:26:08 2001//Ttcpdump_3_7 /strlcat.c/1.1/Wed Jan 19 05:34:19 2000//Ttcpdump_3_7 /strlcpy.c/1.1/Wed Jan 19 05:34:19 2000//Ttcpdump_3_7 D tcpdump-3.7.2/missing/CVS/Repository0100644000076500000240000000004007423403560016543 0ustar fennerstaff/tcpdump/master/tcpdump/missing tcpdump-3.7.2/missing/CVS/Root0100644000076500000240000000006107423403560015312 0ustar fennerstaff:pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master tcpdump-3.7.2/missing/CVS/Tag0100644000076500000240000000001507627054635015114 0ustar fennerstaffTtcpdump_3_7 tcpdump-3.7.2/missing/getaddrinfo.c0100644000076500000240000006141607175157125016465 0ustar fennerstaff/* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator. * * Issues to be discussed: * - Thread safe-ness must be checked. * - Return values. There are nonstandard return values defined and used * in the source code. This is because RFC2553 is silent about which error * code must be returned for which situation. * Note: * - We use getipnodebyname() just for thread-safeness. There's no intent * to let it do PF_UNSPEC (actually we never pass PF_UNSPEC to * getipnodebyname(). * - The code filters out AFs that are not supported by the kernel, * when globbing NULL hostname (to loopback, or wildcard). Is it the right * thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG * in ai_flags? */ #ifdef HAVE_CONFIG_H #include #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/missing/getaddrinfo.c,v 1.10 2000/10/24 00:56:53 fenner Exp $"; #endif #include #include #if 0 #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef HAVE_U_INT32_T #include "bittypes.h" #endif #ifndef HAVE_SOCKADDR_STORAGE #include "sockstorage.h" #endif #ifdef NEED_ADDRINFO_H #include "addrinfo.h" #endif #if defined(__KAME__) && defined(INET6) # define FAITH #endif #define SUCCESS 0 #define ANY 0 #define YES 1 #define NO 0 #ifdef FAITH static int translate = NO; static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT; #endif static const char in_addrany[] = { 0, 0, 0, 0 }; static const char in6_addrany[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const char in_loopback[] = { 127, 0, 0, 1 }; static const char in6_loopback[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; struct sockinet { u_char si_len; u_char si_family; u_short si_port; u_int32_t si_scope_id; }; static const struct afd { int a_af; int a_addrlen; int a_socklen; int a_off; const char *a_addrany; const char *a_loopback; int a_scoped; } afdl [] = { #ifdef INET6 {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), offsetof(struct sockaddr_in6, sin6_addr), in6_addrany, in6_loopback, 1}, #endif {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), offsetof(struct sockaddr_in, sin_addr), in_addrany, in_loopback, 0}, {0, 0, 0, 0, NULL, NULL, 0}, }; struct explore { int e_af; int e_socktype; int e_protocol; const char *e_protostr; int e_wild; #define WILD_AF(ex) ((ex)->e_wild & 0x01) #define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) #define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04) }; static const struct explore explore[] = { #if 0 { PF_LOCAL, 0, ANY, ANY, NULL, 0x01 }, #endif #ifdef INET6 { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 }, #endif { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, { PF_INET, SOCK_RAW, ANY, NULL, 0x05 }, { -1, 0, 0, NULL, 0 }, }; #ifdef INET6 #define PTON_MAX 16 #else #define PTON_MAX 4 #endif static int str_isnumber (const char *); static int explore_fqdn (const struct addrinfo *, const char *, const char *, struct addrinfo **); static int explore_null (const struct addrinfo *, const char *, const char *, struct addrinfo **); static int explore_numeric (const struct addrinfo *, const char *, const char *, struct addrinfo **); static int explore_numeric_scope (const struct addrinfo *, const char *, const char *, struct addrinfo **); static int get_name (const char *, const struct afd *, struct addrinfo **, char *, const struct addrinfo *, const char *); static int get_canonname (const struct addrinfo *, struct addrinfo *, const char *); static struct addrinfo *get_ai (const struct addrinfo *, const struct afd *, const char *); static int get_portmatch (const struct addrinfo *, const char *); static int get_port (struct addrinfo *, const char *, int); static const struct afd *find_afd (int); static char *ai_errlist[] = { "Success", "Address family for hostname not supported", /* EAI_ADDRFAMILY */ "Temporary failure in name resolution", /* EAI_AGAIN */ "Invalid value for ai_flags", /* EAI_BADFLAGS */ "Non-recoverable failure in name resolution", /* EAI_FAIL */ "ai_family not supported", /* EAI_FAMILY */ "Memory allocation failure", /* EAI_MEMORY */ "No address associated with hostname", /* EAI_NODATA */ "hostname nor servname provided, or not known", /* EAI_NONAME */ "servname not supported for ai_socktype", /* EAI_SERVICE */ "ai_socktype not supported", /* EAI_SOCKTYPE */ "System error returned in errno", /* EAI_SYSTEM */ "Invalid value for hints", /* EAI_BADHINTS */ "Resolved protocol is unknown", /* EAI_PROTOCOL */ "Unknown error", /* EAI_MAX */ }; /* XXX macros that make external reference is BAD. */ #define GET_AI(ai, afd, addr) \ do { \ /* external reference: pai, error, and label free */ \ (ai) = get_ai(pai, (afd), (addr)); \ if ((ai) == NULL) { \ error = EAI_MEMORY; \ goto free; \ } \ } while (0) #define GET_PORT(ai, serv) \ do { \ /* external reference: error and label free */ \ error = get_port((ai), (serv), 0); \ if (error != 0) \ goto free; \ } while (0) #define GET_CANONNAME(ai, str) \ do { \ /* external reference: pai, error and label free */ \ error = get_canonname(pai, (ai), (str)); \ if (error != 0) \ goto free; \ } while (0) #define ERR(err) \ do { \ /* external reference: error, and label bad */ \ error = (err); \ goto bad; \ } while (0) #define MATCH_FAMILY(x, y, w) \ ((x) == (y) || ((w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC))) #define MATCH(x, y, w) \ ((x) == (y) || ((w) && ((x) == ANY || (y) == ANY))) char * gai_strerror(ecode) int ecode; { if (ecode < 0 || ecode > EAI_MAX) ecode = EAI_MAX; return ai_errlist[ecode]; } void freeaddrinfo(ai) struct addrinfo *ai; { struct addrinfo *next; do { next = ai->ai_next; if (ai->ai_canonname) free(ai->ai_canonname); /* no need to free(ai->ai_addr) */ free(ai); } while ((ai = next) != NULL); } static int str_isnumber(p) const char *p; { char *q = (char *)p; while (*q) { if (! isdigit(*q)) return NO; q++; } return YES; } int getaddrinfo(hostname, servname, hints, res) const char *hostname, *servname; const struct addrinfo *hints; struct addrinfo **res; { struct addrinfo sentinel; struct addrinfo *cur; int error = 0; struct addrinfo ai; struct addrinfo ai0; struct addrinfo *pai; const struct afd *afd; const struct explore *ex; #ifdef FAITH static int firsttime = 1; if (firsttime) { /* translator hack */ char *q = getenv("GAI"); if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1) translate = YES; firsttime = 0; } #endif sentinel.ai_next = NULL; cur = &sentinel; pai = &ai; pai->ai_flags = 0; pai->ai_family = PF_UNSPEC; pai->ai_socktype = ANY; pai->ai_protocol = ANY; pai->ai_addrlen = 0; pai->ai_canonname = NULL; pai->ai_addr = NULL; pai->ai_next = NULL; if (hostname == NULL && servname == NULL) return EAI_NONAME; if (hints) { /* error check for hints */ if (hints->ai_addrlen || hints->ai_canonname || hints->ai_addr || hints->ai_next) ERR(EAI_BADHINTS); /* xxx */ if (hints->ai_flags & ~AI_MASK) ERR(EAI_BADFLAGS); switch (hints->ai_family) { case PF_UNSPEC: case PF_INET: #ifdef INET6 case PF_INET6: #endif break; default: ERR(EAI_FAMILY); } memcpy(pai, hints, sizeof(*pai)); /* * if both socktype/protocol are specified, check if they * are meaningful combination. */ if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) { for (ex = explore; ex->e_af >= 0; ex++) { if (pai->ai_family != ex->e_af) continue; if (ex->e_socktype == ANY) continue; if (ex->e_protocol == ANY) continue; if (pai->ai_socktype == ex->e_socktype && pai->ai_protocol != ex->e_protocol) { ERR(EAI_BADHINTS); } } } } /* * check for special cases. (1) numeric servname is disallowed if * socktype/protocol are left unspecified. (2) servname is disallowed * for raw and other inet{,6} sockets. */ if (MATCH_FAMILY(pai->ai_family, PF_INET, 1) #ifdef PF_INET6 || MATCH_FAMILY(pai->ai_family, PF_INET6, 1) #endif ) { ai0 = *pai; if (pai->ai_family == PF_UNSPEC) { #ifdef PF_INET6 pai->ai_family = PF_INET6; #else pai->ai_family = PF_INET; #endif } error = get_portmatch(pai, servname); if (error) ERR(error); *pai = ai0; } ai0 = *pai; /* NULL hostname, or numeric hostname */ for (ex = explore; ex->e_af >= 0; ex++) { *pai = ai0; if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex))) continue; if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex))) continue; if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex))) continue; if (pai->ai_family == PF_UNSPEC) pai->ai_family = ex->e_af; if (pai->ai_socktype == ANY && ex->e_socktype != ANY) pai->ai_socktype = ex->e_socktype; if (pai->ai_protocol == ANY && ex->e_protocol != ANY) pai->ai_protocol = ex->e_protocol; if (hostname == NULL) error = explore_null(pai, hostname, servname, &cur->ai_next); else error = explore_numeric_scope(pai, hostname, servname, &cur->ai_next); if (error) goto free; while (cur && cur->ai_next) cur = cur->ai_next; } /* * XXX * If numreic representation of AF1 can be interpreted as FQDN * representation of AF2, we need to think again about the code below. */ if (sentinel.ai_next) goto good; if (pai->ai_flags & AI_NUMERICHOST) ERR(EAI_NONAME); if (hostname == NULL) ERR(EAI_NONAME); /* * hostname as alphabetical name. * we would like to prefer AF_INET6 than AF_INET, so we'll make a * outer loop by AFs. */ for (afd = afdl; afd->a_af; afd++) { *pai = ai0; if (!MATCH_FAMILY(pai->ai_family, afd->a_af, 1)) continue; for (ex = explore; ex->e_af >= 0; ex++) { *pai = ai0; if (pai->ai_family == PF_UNSPEC) pai->ai_family = afd->a_af; if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex))) continue; if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex))) { continue; } if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex))) { continue; } if (pai->ai_family == PF_UNSPEC) pai->ai_family = ex->e_af; if (pai->ai_socktype == ANY && ex->e_socktype != ANY) pai->ai_socktype = ex->e_socktype; if (pai->ai_protocol == ANY && ex->e_protocol != ANY) pai->ai_protocol = ex->e_protocol; error = explore_fqdn(pai, hostname, servname, &cur->ai_next); while (cur && cur->ai_next) cur = cur->ai_next; } } /* XXX */ if (sentinel.ai_next) error = 0; if (error) goto free; if (error == 0) { if (sentinel.ai_next) { good: *res = sentinel.ai_next; return SUCCESS; } else error = EAI_FAIL; } free: bad: if (sentinel.ai_next) freeaddrinfo(sentinel.ai_next); *res = NULL; return error; } /* * FQDN hostname, DNS lookup */ static int explore_fqdn(pai, hostname, servname, res) const struct addrinfo *pai; const char *hostname; const char *servname; struct addrinfo **res; { struct hostent *hp; int h_error; int af; char **aplist = NULL, *apbuf = NULL; char *ap; struct addrinfo sentinel, *cur; int i; #ifndef USE_GETIPNODEBY int naddrs; #endif const struct afd *afd; int error; *res = NULL; sentinel.ai_next = NULL; cur = &sentinel; /* * Do not filter unsupported AFs here. We need to honor content of * databases (/etc/hosts, DNS and others). Otherwise we cannot * replace gethostbyname() by getaddrinfo(). */ /* * if the servname does not match socktype/protocol, ignore it. */ if (get_portmatch(pai, servname) != 0) return 0; afd = find_afd(pai->ai_family); /* * post-RFC2553: should look at (pai->ai_flags & AI_ADDRCONFIG) * rather than hardcoding it. we may need to add AI_ADDRCONFIG * handling code by ourselves in case we don't have getipnodebyname(). */ #ifdef USE_GETIPNODEBY hp = getipnodebyname(hostname, pai->ai_family, AI_ADDRCONFIG, &h_error); #else #ifdef HAVE_GETHOSTBYNAME2 hp = gethostbyname2(hostname, pai->ai_family); #else if (pai->ai_family != AF_INET) return 0; hp = gethostbyname(hostname); #ifdef HAVE_H_ERRNO h_error = h_errno; #else h_error = EINVAL; #endif #endif /*HAVE_GETHOSTBYNAME2*/ #endif /*USE_GETIPNODEBY*/ if (hp == NULL) { switch (h_error) { case HOST_NOT_FOUND: case NO_DATA: error = EAI_NODATA; break; case TRY_AGAIN: error = EAI_AGAIN; break; case NO_RECOVERY: case NETDB_INTERNAL: default: error = EAI_FAIL; break; } } else if ((hp->h_name == NULL) || (hp->h_name[0] == 0) || (hp->h_addr_list[0] == NULL)) { #ifdef USE_GETIPNODEBY freehostent(hp); #endif hp = NULL; error = EAI_FAIL; } if (hp == NULL) goto free; #ifdef USE_GETIPNODEBY aplist = hp->h_addr_list; #else /* * hp will be overwritten if we use gethostbyname2(). * always deep copy for simplification. */ for (naddrs = 0; hp->h_addr_list[naddrs] != NULL; naddrs++) ; naddrs++; aplist = (char **)malloc(sizeof(aplist[0]) * naddrs); apbuf = (char *)malloc(hp->h_length * naddrs); if (aplist == NULL || apbuf == NULL) { error = EAI_MEMORY; goto free; } memset(aplist, 0, sizeof(aplist[0]) * naddrs); for (i = 0; i < naddrs; i++) { if (hp->h_addr_list[i] == NULL) { aplist[i] = NULL; continue; } memcpy(&apbuf[i * hp->h_length], hp->h_addr_list[i], hp->h_length); aplist[i] = &apbuf[i * hp->h_length]; } #endif for (i = 0; aplist[i] != NULL; i++) { af = hp->h_addrtype; ap = aplist[i]; #ifdef AF_INET6 if (af == AF_INET6 && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) { af = AF_INET; ap = ap + sizeof(struct in6_addr) - sizeof(struct in_addr); } #endif if (af != pai->ai_family) continue; if ((pai->ai_flags & AI_CANONNAME) == 0) { GET_AI(cur->ai_next, afd, ap); GET_PORT(cur->ai_next, servname); } else { /* * if AI_CANONNAME and if reverse lookup * fail, return ai anyway to pacify * calling application. * * XXX getaddrinfo() is a name->address * translation function, and it looks * strange that we do addr->name * translation here. */ get_name(ap, afd, &cur->ai_next, ap, pai, servname); } while (cur && cur->ai_next) cur = cur->ai_next; } *res = sentinel.ai_next; return 0; free: #ifdef USE_GETIPNODEBY if (hp) freehostent(hp); #endif if (aplist) free(aplist); if (apbuf) free(apbuf); if (sentinel.ai_next) freeaddrinfo(sentinel.ai_next); return error; } /* * hostname == NULL. * passive socket -> anyaddr (0.0.0.0 or ::) * non-passive socket -> localhost (127.0.0.1 or ::1) */ static int explore_null(pai, hostname, servname, res) const struct addrinfo *pai; const char *hostname; const char *servname; struct addrinfo **res; { int s; const struct afd *afd; struct addrinfo *cur; struct addrinfo sentinel; int error; *res = NULL; sentinel.ai_next = NULL; cur = &sentinel; /* * filter out AFs that are not supported by the kernel * XXX errno? */ s = socket(pai->ai_family, SOCK_DGRAM, 0); if (s < 0) { if (errno != EMFILE) return 0; } else close(s); /* * if the servname does not match socktype/protocol, ignore it. */ if (get_portmatch(pai, servname) != 0) return 0; afd = find_afd(pai->ai_family); if (pai->ai_flags & AI_PASSIVE) { GET_AI(cur->ai_next, afd, afd->a_addrany); /* xxx meaningless? * GET_CANONNAME(cur->ai_next, "anyaddr"); */ GET_PORT(cur->ai_next, servname); } else { GET_AI(cur->ai_next, afd, afd->a_loopback); /* xxx meaningless? * GET_CANONNAME(cur->ai_next, "localhost"); */ GET_PORT(cur->ai_next, servname); } cur = cur->ai_next; *res = sentinel.ai_next; return 0; free: if (sentinel.ai_next) freeaddrinfo(sentinel.ai_next); return error; } /* * numeric hostname */ static int explore_numeric(pai, hostname, servname, res) const struct addrinfo *pai; const char *hostname; const char *servname; struct addrinfo **res; { const struct afd *afd; struct addrinfo *cur; struct addrinfo sentinel; int error; char pton[PTON_MAX]; int flags; *res = NULL; sentinel.ai_next = NULL; cur = &sentinel; /* * if the servname does not match socktype/protocol, ignore it. */ if (get_portmatch(pai, servname) != 0) return 0; afd = find_afd(pai->ai_family); flags = pai->ai_flags; if (inet_pton(afd->a_af, hostname, pton) == 1) { u_int32_t v4a; #ifdef INET6 u_char pfx; #endif switch (afd->a_af) { case AF_INET: v4a = (u_int32_t)ntohl(((struct in_addr *)pton)->s_addr); if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) flags &= ~AI_CANONNAME; v4a >>= IN_CLASSA_NSHIFT; if (v4a == 0 || v4a == IN_LOOPBACKNET) flags &= ~AI_CANONNAME; break; #ifdef INET6 case AF_INET6: pfx = ((struct in6_addr *)pton)->s6_addr[0]; if (pfx == 0 || pfx == 0xfe || pfx == 0xff) flags &= ~AI_CANONNAME; break; #endif } if (pai->ai_family == afd->a_af || pai->ai_family == PF_UNSPEC /*?*/) { if ((flags & AI_CANONNAME) == 0) { GET_AI(cur->ai_next, afd, pton); GET_PORT(cur->ai_next, servname); } else { /* * if AI_CANONNAME and if reverse lookup * fail, return ai anyway to pacify * calling application. * * XXX getaddrinfo() is a name->address * translation function, and it looks * strange that we do addr->name * translation here. */ get_name(pton, afd, &cur->ai_next, pton, pai, servname); } while (cur && cur->ai_next) cur = cur->ai_next; } else ERR(EAI_FAMILY); /*xxx*/ } *res = sentinel.ai_next; return 0; free: bad: if (sentinel.ai_next) freeaddrinfo(sentinel.ai_next); return error; } /* * numeric hostname with scope */ static int explore_numeric_scope(pai, hostname, servname, res) const struct addrinfo *pai; const char *hostname; const char *servname; struct addrinfo **res; { #ifndef SCOPE_DELIMITER return explore_numeric(pai, hostname, servname, res); #else const struct afd *afd; struct addrinfo *cur; int error; char *cp, *hostname2 = NULL; int scope; struct sockaddr_in6 *sin6; /* * if the servname does not match socktype/protocol, ignore it. */ if (get_portmatch(pai, servname) != 0) return 0; afd = find_afd(pai->ai_family); if (!afd->a_scoped) return explore_numeric(pai, hostname, servname, res); cp = strchr(hostname, SCOPE_DELIMITER); if (cp == NULL) return explore_numeric(pai, hostname, servname, res); /* * Handle special case of */ hostname2 = strdup(hostname); if (hostname2 == NULL) return EAI_MEMORY; /* terminate at the delimiter */ hostname2[cp - hostname] = '\0'; cp++; switch (pai->ai_family) { #ifdef INET6 case AF_INET6: scope = if_nametoindex(cp); if (scope == 0) { free(hostname2); return (EAI_NONAME); } break; #endif } error = explore_numeric(pai, hostname2, servname, res); if (error == 0) { for (cur = *res; cur; cur = cur->ai_next) { if (cur->ai_family != AF_INET6) continue; sin6 = (struct sockaddr_in6 *)cur->ai_addr; if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr)) sin6->sin6_scope_id = scope; } } free(hostname2); return error; #endif } static int get_name(addr, afd, res, numaddr, pai, servname) const char *addr; const struct afd *afd; struct addrinfo **res; char *numaddr; const struct addrinfo *pai; const char *servname; { struct hostent *hp = NULL; struct addrinfo *cur = NULL; int error = 0; char *ap = NULL, *cn = NULL; #ifdef USE_GETIPNODEBY int h_error; hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); #else hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af); #endif if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { #ifdef USE_GETIPNODEBY GET_AI(cur, afd, hp->h_addr_list[0]); GET_PORT(cur, servname); GET_CANONNAME(cur, hp->h_name); #else /* hp will be damaged if we use gethostbyaddr() */ if ((ap = (char *)malloc(hp->h_length)) == NULL) { error = EAI_MEMORY; goto free; } memcpy(ap, hp->h_addr_list[0], hp->h_length); if ((cn = strdup(hp->h_name)) == NULL) { error = EAI_MEMORY; goto free; } GET_AI(cur, afd, ap); GET_PORT(cur, servname); GET_CANONNAME(cur, cn); free(ap); ap = NULL; free(cn); cn = NULL; #endif } else { GET_AI(cur, afd, numaddr); GET_PORT(cur, servname); } #ifdef USE_GETIPNODEBY if (hp) freehostent(hp); #endif *res = cur; return SUCCESS; free: if (cur) freeaddrinfo(cur); if (ap) free(ap); if (cn) free(cn); #ifdef USE_GETIPNODEBY if (hp) freehostent(hp); #endif *res = NULL; return error; } static int get_canonname(pai, ai, str) const struct addrinfo *pai; struct addrinfo *ai; const char *str; { if ((pai->ai_flags & AI_CANONNAME) != 0) { ai->ai_canonname = (char *)malloc(strlen(str) + 1); if (ai->ai_canonname == NULL) return EAI_MEMORY; strcpy(ai->ai_canonname, str); } return 0; } static struct addrinfo * get_ai(pai, afd, addr) const struct addrinfo *pai; const struct afd *afd; const char *addr; { char *p; struct addrinfo *ai; ai = (struct addrinfo *)malloc(sizeof(struct addrinfo) + (afd->a_socklen)); if (ai == NULL) return NULL; memcpy(ai, pai, sizeof(struct addrinfo)); ai->ai_addr = (struct sockaddr *)(ai + 1); memset(ai->ai_addr, 0, afd->a_socklen); #ifdef HAVE_SOCKADDR_SA_LEN ai->ai_addr->sa_len = afd->a_socklen; #endif ai->ai_addrlen = afd->a_socklen; ai->ai_addr->sa_family = ai->ai_family = afd->a_af; p = (char *)(ai->ai_addr); memcpy(p + afd->a_off, addr, afd->a_addrlen); return ai; } static int get_portmatch(ai, servname) const struct addrinfo *ai; const char *servname; { /* get_port does not touch first argument. when matchonly == 1. */ return get_port((struct addrinfo *)ai, servname, 1); } static int get_port(ai, servname, matchonly) struct addrinfo *ai; const char *servname; int matchonly; { const char *proto; struct servent *sp; int port; int allownumeric; if (servname == NULL) return 0; switch (ai->ai_family) { case AF_INET: #ifdef AF_INET6 case AF_INET6: #endif break; default: return 0; } switch (ai->ai_socktype) { case SOCK_RAW: return EAI_SERVICE; case SOCK_DGRAM: case SOCK_STREAM: allownumeric = 1; break; case ANY: allownumeric = 0; break; default: return EAI_SOCKTYPE; } if (str_isnumber(servname)) { if (!allownumeric) return EAI_SERVICE; port = htons(atoi(servname)); if (port < 0 || port > 65535) return EAI_SERVICE; } else { switch (ai->ai_socktype) { case SOCK_DGRAM: proto = "udp"; break; case SOCK_STREAM: proto = "tcp"; break; default: proto = NULL; break; } if ((sp = getservbyname(servname, proto)) == NULL) return EAI_SERVICE; port = sp->s_port; } if (!matchonly) { switch (ai->ai_family) { case AF_INET: ((struct sockaddr_in *)ai->ai_addr)->sin_port = port; break; #ifdef INET6 case AF_INET6: ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = port; break; #endif } } return 0; } static const struct afd * find_afd(af) int af; { const struct afd *afd; if (af == PF_UNSPEC) return NULL; for (afd = afdl; afd->a_af; afd++) { if (afd->a_af == af) return afd; } return NULL; } tcpdump-3.7.2/missing/getnameinfo.c0100644000076500000240000001633707175157125016475 0ustar fennerstaff/* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Issues to be discussed: * - Thread safe-ness must be checked * - Return values. There seems to be no standard for return value (RFC2553) * but INRIA implementation returns EAI_xxx defined for getaddrinfo(). * - RFC2553 says that we should raise error on short buffer. X/Open says * we need to truncate the result. We obey RFC2553 (and X/Open should be * modified). */ #ifdef HAVE_CONFIG_H #include #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.8 2000/10/24 00:56:53 fenner Exp $"; #endif #include #include #include #include #include #include #include #include #include #include #include #ifdef NEED_ADDRINFO_H #include "addrinfo.h" #endif #define SUCCESS 0 #define ANY 0 #define YES 1 #define NO 0 static struct afd { int a_af; int a_addrlen; int a_socklen; int a_off; } afdl [] = { #ifdef INET6 {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), offsetof(struct sockaddr_in6, sin6_addr)}, #endif {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), offsetof(struct sockaddr_in, sin_addr)}, {0, 0, 0}, }; struct sockinet { u_char si_len; u_char si_family; u_short si_port; }; #define ENI_NOSOCKET 0 #define ENI_NOSERVNAME 1 #define ENI_NOHOSTNAME 2 #define ENI_MEMORY 3 #define ENI_SYSTEM 4 #define ENI_FAMILY 5 #define ENI_SALEN 6 int getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) const struct sockaddr *sa; size_t salen; char *host; size_t hostlen; char *serv; size_t servlen; int flags; { struct afd *afd; struct servent *sp; struct hostent *hp; u_short port; int family, i; char *addr, *p; u_int32_t v4a; int h_error; char numserv[512]; char numaddr[512]; if (sa == NULL) return ENI_NOSOCKET; #ifdef HAVE_SA_LEN /*XXX*/ if (sa->sa_len != salen) return ENI_SALEN; #endif family = sa->sa_family; for (i = 0; afdl[i].a_af; i++) if (afdl[i].a_af == family) { afd = &afdl[i]; goto found; } return ENI_FAMILY; found: if (salen != afd->a_socklen) return ENI_SALEN; port = ((struct sockinet *)sa)->si_port; /* network byte order */ addr = (char *)sa + afd->a_off; if (serv == NULL || servlen == 0) { /* * do nothing in this case. * in case you are wondering if "&&" is more correct than * "||" here: RFC2553 says that serv == NULL OR servlen == 0 * means that the caller does not want the result. */ } else { if (flags & NI_NUMERICSERV) sp = NULL; else { sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp"); } if (sp) { if (strlen(sp->s_name) + 1 > servlen) return ENI_MEMORY; strcpy(serv, sp->s_name); } else { snprintf(numserv, sizeof(numserv), "%d", ntohs(port)); if (strlen(numserv) + 1 > servlen) return ENI_MEMORY; strcpy(serv, numserv); } } switch (sa->sa_family) { case AF_INET: v4a = (u_int32_t) ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr); if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) flags |= NI_NUMERICHOST; v4a >>= IN_CLASSA_NSHIFT; if (v4a == 0) flags |= NI_NUMERICHOST; break; #ifdef INET6 case AF_INET6: { struct sockaddr_in6 *sin6; sin6 = (struct sockaddr_in6 *)sa; switch (sin6->sin6_addr.s6_addr[0]) { case 0x00: if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) ; else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) ; else flags |= NI_NUMERICHOST; break; default: if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { flags |= NI_NUMERICHOST; } else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) flags |= NI_NUMERICHOST; break; } } break; #endif } if (host == NULL || hostlen == 0) { /* * do nothing in this case. * in case you are wondering if "&&" is more correct than * "||" here: RFC2553 says that host == NULL OR hostlen == 0 * means that the caller does not want the result. */ } else if (flags & NI_NUMERICHOST) { /* NUMERICHOST and NAMEREQD conflicts with each other */ if (flags & NI_NAMEREQD) return ENI_NOHOSTNAME; if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) == NULL) return ENI_SYSTEM; if (strlen(numaddr) + 1 > hostlen) return ENI_MEMORY; strcpy(host, numaddr); #if defined(INET6) && defined(NI_WITHSCOPEID) if (afd->a_af == AF_INET6 && (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) || IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) && ((struct sockaddr_in6 *)sa)->sin6_scope_id) { #ifndef ALWAYS_WITHSCOPE if (flags & NI_WITHSCOPEID) #endif /* !ALWAYS_WITHSCOPE */ { char *ep = strchr(host, '\0'); unsigned int ifindex = ((struct sockaddr_in6 *)sa)->sin6_scope_id; *ep = SCOPE_DELIMITER; if ((if_indextoname(ifindex, ep + 1)) == NULL) /* XXX what should we do? */ strncpy(ep + 1, "???", 3); } } #endif /* INET6 */ } else { #ifdef USE_GETIPNODEBY hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); #else hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af); #ifdef HAVE_H_ERRNO h_error = h_errno; #else h_error = EINVAL; #endif #endif if (hp) { if (flags & NI_NOFQDN) { p = strchr(hp->h_name, '.'); if (p) *p = '\0'; } if (strlen(hp->h_name) + 1 > hostlen) { #ifdef USE_GETIPNODEBY freehostent(hp); #endif return ENI_MEMORY; } strcpy(host, hp->h_name); #ifdef USE_GETIPNODEBY freehostent(hp); #endif } else { if (flags & NI_NAMEREQD) return ENI_NOHOSTNAME; if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) == NULL) return ENI_NOHOSTNAME; if (strlen(numaddr) + 1 > hostlen) return ENI_MEMORY; strcpy(host, numaddr); } } return SUCCESS; } tcpdump-3.7.2/missing/inet_aton.c0100644000076500000240000000472207036177461016155 0ustar fennerstaff/* * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* $Id: inet_aton.c,v 1.2 2000/01/09 21:35:45 fenner Exp $ */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.2 2000/01/09 21:35:45 fenner Exp $"; #endif #include #include #include #include /* Minimal implementation of inet_aton. * Cannot distinguish between failure and a local broadcast address. */ #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff #endif int inet_aton(const char *cp, struct in_addr *addr) { addr->s_addr = inet_addr(cp); return (addr->s_addr == INADDR_NONE) ? 0 : 1; } tcpdump-3.7.2/missing/inet_ntop.c0100644000076500000240000000620507036177461016172 0ustar fennerstaff/* * Copyright (c) 1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* $Id: inet_ntop.c,v 1.3 2000/01/09 21:35:45 fenner Exp $ */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.3 2000/01/09 21:35:45 fenner Exp $"; #endif #include #include #include #include #include /* * */ #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN 16 #endif static const char * inet_ntop_v4 (const void *src, char *dst, size_t size) { const char digits[] = "0123456789"; int i; struct in_addr *addr = (struct in_addr *)src; u_long a = ntohl(addr->s_addr); const char *orig_dst = dst; if (size < INET_ADDRSTRLEN) { errno = ENOSPC; return NULL; } for (i = 0; i < 4; ++i) { int n = (a >> (24 - i * 8)) & 0xFF; int non_zerop = 0; if (non_zerop || n / 100 > 0) { *dst++ = digits[n / 100]; n %= 100; non_zerop = 1; } if (non_zerop || n / 10 > 0) { *dst++ = digits[n / 10]; n %= 10; non_zerop = 1; } *dst++ = digits[n]; if (i != 3) *dst++ = '.'; } *dst++ = '\0'; return orig_dst; } const char * inet_ntop(int af, const void *src, char *dst, size_t size) { switch (af) { case AF_INET : return inet_ntop_v4 (src, dst, size); default : errno = EAFNOSUPPORT; return NULL; } } tcpdump-3.7.2/missing/inet_pton.c0100644000076500000240000000445407036177462016177 0ustar fennerstaff/* * Copyright (c) 1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Kungliga Tekniska * Högskolan and its contributors. * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* $Id: inet_pton.c,v 1.2 2000/01/09 21:35:46 fenner Exp $ */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.2 2000/01/09 21:35:46 fenner Exp $"; #endif #include #include #include #include int inet_pton(int af, const char *src, void *dst) { if (af != AF_INET) { errno = EAFNOSUPPORT; return -1; } return inet_aton (src, dst); } tcpdump-3.7.2/missing/resolv6.h0100644000076500000240000000336007006476774015605 0ustar fennerstaff/* * 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 tcpdump-3.7.2/missing/resolv_ext.h0100644000076500000240000000370107006476774016376 0ustar fennerstaff/* * 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; tcpdump-3.7.2/missing/snprintf.c0100644000076500000240000003146407227554420016037 0ustar fennerstaff/* * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* $Id: snprintf.c,v 1.5 2001/01/12 10:14:40 guy Exp $ */ #ifdef HAVE_CONFIG_H #include #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.5 2001/01/12 10:14:40 guy Exp $"; #endif #include #include #include #include #include #include #include enum format_flags { minus_flag = 1, plus_flag = 2, space_flag = 4, alternate_flag = 8, zero_flag = 16 }; /* * Common state */ struct state { unsigned char *str; unsigned char *s; unsigned char *theend; size_t sz; size_t max_sz; int (*append_char)(struct state *, unsigned char); int (*reserve)(struct state *, size_t); /* XXX - methods */ }; #ifndef HAVE_VSNPRINTF static int sn_reserve (struct state *state, size_t n) { return state->s + n > state->theend; } static int sn_append_char (struct state *state, unsigned char c) { if (sn_reserve (state, 1)) { return 1; } else { *state->s++ = c; return 0; } } #endif #if 0 static int as_reserve (struct state *state, size_t n) { if (state->s + n > state->theend) { int off = state->s - state->str; unsigned char *tmp; if (state->max_sz && state->sz >= state->max_sz) return 1; state->sz = max(state->sz * 2, state->sz + n); if (state->max_sz) state->sz = min(state->sz, state->max_sz); tmp = realloc (state->str, state->sz); if (tmp == NULL) return 1; state->str = tmp; state->s = state->str + off; state->theend = state->str + state->sz - 1; } return 0; } static int as_append_char (struct state *state, unsigned char c) { if(as_reserve (state, 1)) return 1; else { *state->s++ = c; return 0; } } #endif static int append_number(struct state *state, unsigned long num, unsigned base, char *rep, int width, int prec, int flags, int minusp) { int len = 0; int i; /* given precision, ignore zero flag */ if(prec != -1) flags &= ~zero_flag; else prec = 1; /* zero value with zero precision -> "" */ if(prec == 0 && num == 0) return 0; do{ if((*state->append_char)(state, rep[num % base])) return 1; len++; num /= base; }while(num); prec -= len; /* pad with prec zeros */ while(prec-- > 0){ if((*state->append_char)(state, '0')) return 1; len++; } /* add length of alternate prefix (added later) to len */ if(flags & alternate_flag && (base == 16 || base == 8)) len += base / 8; /* pad with zeros */ if(flags & zero_flag){ width -= len; if(minusp || (flags & space_flag) || (flags & plus_flag)) width--; while(width-- > 0){ if((*state->append_char)(state, '0')) return 1; len++; } } /* add alternate prefix */ if(flags & alternate_flag && (base == 16 || base == 8)){ if(base == 16) if((*state->append_char)(state, rep[10] + 23)) /* XXX */ return 1; if((*state->append_char)(state, '0')) return 1; } /* add sign */ if(minusp){ if((*state->append_char)(state, '-')) return 1; len++; } else if(flags & plus_flag) { if((*state->append_char)(state, '+')) return 1; len++; } else if(flags & space_flag) { if((*state->append_char)(state, ' ')) return 1; len++; } if(flags & minus_flag) /* swap before padding with spaces */ for(i = 0; i < len / 2; i++){ char c = state->s[-i-1]; state->s[-i-1] = state->s[-len+i]; state->s[-len+i] = c; } width -= len; while(width-- > 0){ if((*state->append_char)(state, ' ')) return 1; len++; } if(!(flags & minus_flag)) /* swap after padding with spaces */ for(i = 0; i < len / 2; i++){ char c = state->s[-i-1]; state->s[-i-1] = state->s[-len+i]; state->s[-len+i] = c; } return 0; } static int append_string (struct state *state, unsigned char *arg, int width, int prec, int flags) { if(prec != -1) width -= prec; else width -= strlen((char *)arg); if(!(flags & minus_flag)) while(width-- > 0) if((*state->append_char) (state, ' ')) return 1; if (prec != -1) { while (*arg && prec--) if ((*state->append_char) (state, *arg++)) return 1; } else { while (*arg) if ((*state->append_char) (state, *arg++)) return 1; } if(flags & minus_flag) while(width-- > 0) if((*state->append_char) (state, ' ')) return 1; return 0; } static int append_char(struct state *state, unsigned char arg, int width, int flags) { while(!(flags & minus_flag) && --width > 0) if((*state->append_char) (state, ' ')) return 1; if((*state->append_char) (state, arg)) return 1; while((flags & minus_flag) && --width > 0) if((*state->append_char) (state, ' ')) return 1; return 0; } /* * This can't be made into a function... */ #define PARSE_INT_FORMAT(res, arg, unsig) \ if (long_flag) \ res = (unsig long)va_arg(arg, unsig long); \ else if (short_flag) \ res = (unsig short)va_arg(arg, unsig int); \ else \ res = (unsig int)va_arg(arg, unsig int) /* * zyxprintf - return 0 or -1 */ static int xyzprintf (struct state *state, const char *char_format, va_list ap) { const unsigned char *format = (const unsigned char *)char_format; unsigned char c; while((c = *format++)) { if (c == '%') { int flags = 0; int width = 0; int prec = -1; int long_flag = 0; int short_flag = 0; /* flags */ while((c = *format++)){ if(c == '-') flags |= minus_flag; else if(c == '+') flags |= plus_flag; else if(c == ' ') flags |= space_flag; else if(c == '#') flags |= alternate_flag; else if(c == '0') flags |= zero_flag; else break; } if((flags & space_flag) && (flags & plus_flag)) flags ^= space_flag; if((flags & minus_flag) && (flags & zero_flag)) flags ^= zero_flag; /* width */ if (isdigit(c)) do { width = width * 10 + c - '0'; c = *format++; } while(isdigit(c)); else if(c == '*') { width = va_arg(ap, int); c = *format++; } /* precision */ if (c == '.') { prec = 0; c = *format++; if (isdigit(c)) do { prec = prec * 10 + c - '0'; c = *format++; } while(isdigit(c)); else if (c == '*') { prec = va_arg(ap, int); c = *format++; } } /* size */ if (c == 'h') { short_flag = 1; c = *format++; } else if (c == 'l') { long_flag = 1; c = *format++; } switch (c) { case 'c' : if(append_char(state, va_arg(ap, int), width, flags)) return -1; break; case 's' : if (append_string(state, va_arg(ap, unsigned char*), width, prec, flags)) return -1; break; case 'd' : case 'i' : { long arg; unsigned long num; int minusp = 0; PARSE_INT_FORMAT(arg, ap, signed); if (arg < 0) { minusp = 1; num = -arg; } else num = arg; if (append_number (state, num, 10, "0123456789", width, prec, flags, minusp)) return -1; break; } case 'u' : { unsigned long arg; PARSE_INT_FORMAT(arg, ap, unsigned); if (append_number (state, arg, 10, "0123456789", width, prec, flags, 0)) return -1; break; } case 'o' : { unsigned long arg; PARSE_INT_FORMAT(arg, ap, unsigned); if (append_number (state, arg, 010, "01234567", width, prec, flags, 0)) return -1; break; } case 'x' : { unsigned long arg; PARSE_INT_FORMAT(arg, ap, unsigned); if (append_number (state, arg, 0x10, "0123456789abcdef", width, prec, flags, 0)) return -1; break; } case 'X' :{ unsigned long arg; PARSE_INT_FORMAT(arg, ap, unsigned); if (append_number (state, arg, 0x10, "0123456789ABCDEF", width, prec, flags, 0)) return -1; break; } case 'p' : { unsigned long arg = (unsigned long)va_arg(ap, void*); if (append_number (state, arg, 0x10, "0123456789ABCDEF", width, prec, flags, 0)) return -1; break; } case 'n' : { int *arg = va_arg(ap, int*); *arg = state->s - state->str; break; } case '\0' : --format; /* FALLTHROUGH */ case '%' : if ((*state->append_char)(state, c)) return -1; break; default : if ( (*state->append_char)(state, '%') || (*state->append_char)(state, c)) return -1; break; } } else if ((*state->append_char) (state, c)) return -1; } return 0; } #ifndef HAVE_SNPRINTF int snprintf (char *str, size_t sz, const char *format, ...) { va_list args; int ret; va_start(args, format); ret = vsnprintf (str, sz, format, args); #ifdef PARANOIA { int ret2; char *tmp; tmp = malloc (sz); if (tmp == NULL) abort (); ret2 = vsprintf (tmp, format, args); if (ret != ret2 || strcmp(str, tmp)) abort (); free (tmp); } #endif va_end(args); return ret; } #endif #if 0 #ifndef HAVE_ASPRINTF int asprintf (char **ret, const char *format, ...) { va_list args; int val; va_start(args, format); val = vasprintf (ret, format, args); #ifdef PARANOIA { int ret2; char *tmp; tmp = malloc (val + 1); if (tmp == NULL) abort (); ret2 = vsprintf (tmp, format, args); if (val != ret2 || strcmp(*ret, tmp)) abort (); free (tmp); } #endif va_end(args); return val; } #endif #ifndef HAVE_ASNPRINTF int asnprintf (char **ret, size_t max_sz, const char *format, ...) { va_list args; int val; va_start(args, format); val = vasnprintf (ret, max_sz, format, args); #ifdef PARANOIA { int ret2; char *tmp; tmp = malloc (val + 1); if (tmp == NULL) abort (); ret2 = vsprintf (tmp, format, args); if (val != ret2 || strcmp(*ret, tmp)) abort (); free (tmp); } #endif va_end(args); return val; } #endif #ifndef HAVE_VASPRINTF int vasprintf (char **ret, const char *format, va_list args) { return vasnprintf (ret, 0, format, args); } #endif #ifndef HAVE_VASNPRINTF int vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) { int st; size_t len; struct state state; state.max_sz = max_sz; state.sz = 1; state.str = malloc(state.sz); if (state.str == NULL) { *ret = NULL; return -1; } state.s = state.str; state.theend = state.s + state.sz - 1; state.append_char = as_append_char; state.reserve = as_reserve; st = xyzprintf (&state, format, args); if (st) { free (state.str); *ret = NULL; return -1; } else { char *tmp; *state.s = '\0'; len = state.s - state.str; tmp = realloc (state.str, len+1); if (tmp == NULL) { free (state.str); *ret = NULL; return -1; } *ret = tmp; return len; } } #endif #endif #ifndef HAVE_VSNPRINTF int vsnprintf (char *str, size_t sz, const char *format, va_list args) { struct state state; int ret; unsigned char *ustr = (unsigned char *)str; state.max_sz = 0; state.sz = sz; state.str = ustr; state.s = ustr; state.theend = ustr + sz - 1; state.append_char = sn_append_char; state.reserve = sn_reserve; ret = xyzprintf (&state, format, args); *state.s = '\0'; if (ret) return sz; else return state.s - state.str; } #endif tcpdump-3.7.2/missing/sockstorage.h0100644000076500000240000000334007006476774016527 0ustar fennerstaff/* * Copyright (C) 1999 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ struct sockaddr_storage { #ifdef HAVE_SOCKADDR_SA_LEN u_int8_t __ss_len; u_int8_t __ss_family; u_int8_t fill[126]; #else u_int8_t __ss_family; u_int8_t fill[127]; #endif /* HAVE_SOCKADDR_SA_LEN */ }; tcpdump-3.7.2/missing/strdup.c0100644000076500000240000000441007232236620015477 0ustar fennerstaff/* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/missing/strdup.c,v 1.1 2001/01/20 07:26:08 guy Exp $ (LBL)"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include "interface.h" char * strdup(str) const char *str; { size_t len; char *copy; len = strlen(str) + 1; if ((copy = malloc(len)) == NULL) return (NULL); memcpy(copy, str, len); return (copy); } tcpdump-3.7.2/missing/strlcat.c0100644000076500000240000000511407041246333015634 0ustar fennerstaff/* $NetBSD: strlcat.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */ /* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */ /* * Copyright (c) 1998 Todd C. Miller * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcat.c,v 1.1 2000/01/19 05:34:19 itojun Exp $ (LBL)"; #endif #include #include #include #include "interface.h" /* * Appends src to string dst of size siz (unlike strncat, siz is the * full size of dst, not space left). At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t strlcat(dst, src, siz) char *dst; const char *src; size_t siz; { register char *d = dst; register const char *s = src; register size_t n = siz; size_t dlen; /* Find the end of dst and adjust bytes left but don't go past end */ while (*d != '\0' && n-- != 0) d++; dlen = d - dst; n = siz - dlen; if (n == 0) return(dlen + strlen(s)); while (*s != '\0') { if (n != 1) { *d++ = *s; n--; } s++; } *d = '\0'; return(dlen + (s - src)); /* count does not include NUL */ } tcpdump-3.7.2/missing/strlcpy.c0100644000076500000240000000501207041246333015655 0ustar fennerstaff/* $NetBSD: strlcpy.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */ /* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */ /* * Copyright (c) 1998 Todd C. Miller * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcpy.c,v 1.1 2000/01/19 05:34:19 itojun Exp $ (LBL)"; #endif #include #include #include #include "interface.h" /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t strlcpy(dst, src, siz) char *dst; const char *src; size_t siz; { register char *d = dst; register const char *s = src; register size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) { do { if ((*d++ = *s++) == 0) break; } while (--n != 0); } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return(s - src - 1); /* count does not include NUL */ } tcpdump-3.7.2/mkdep0100755000076500000240000000445606777230376013420 0ustar fennerstaff#!/bin/sh - # # Copyright (c) 1994, 1996 # The Regents of the University of California. All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that this notice is preserved and that due credit is given # to the University of California at Berkeley. The name of the University # may not be used to endorse or promote products derived from this # software without specific prior written permission. This software # is provided ``as is'' without express or implied warranty. # # @(#)mkdep.sh 5.11 (Berkeley) 5/5/88 # PATH=/bin:/usr/bin:/usr/ucb:/usr/local:/usr/local/bin export PATH MAKE=Makefile # default makefile name is "Makefile" CC=cc # default C compiler is "cc" while : do case "$1" in # -c allows you to specify the C compiler -c) CC=$2 shift; shift ;; # -f allows you to select a makefile name -f) MAKE=$2 shift; shift ;; # the -p flag produces "program: program.c" style dependencies # so .o's don't get produced -p) SED='s;\.o;;' shift ;; *) break ;; esac done if [ $# = 0 ] ; then echo 'usage: mkdep [-p] [-c cc] [-f makefile] [flags] file ...' exit 1 fi if [ ! -w $MAKE ]; then echo "mkdep: no writeable file \"$MAKE\"" exit 1 fi TMP=/tmp/mkdep$$ trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 cp $MAKE ${MAKE}.bak sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP cat << _EOF_ >> $TMP # DO NOT DELETE THIS LINE -- mkdep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. _EOF_ # If your compiler doesn't have -M, add it. If you can't, the next two # lines will try and replace the "cc -M". The real problem is that this # hack can't deal with anything that requires a search path, and doesn't # even try for anything using bracket (<>) syntax. # # egrep '^#include[ ]*".*"' /dev/null $* | # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' | # XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait" $CC -M $* | sed " s; \./; ;g $SED" | awk '{ if ($1 != prev) { if (rec != "") print rec; rec = $0; prev = $1; } else { if (length(rec $2) > 78) { print rec; rec = $0; } else rec = rec " " $2 } } END { print rec }' >> $TMP cat << _EOF_ >> $TMP # IF YOU PUT ANYTHING HERE IT WILL GO AWAY _EOF_ # copy to preserve permissions cp $TMP $MAKE rm -f ${MAKE}.bak $TMP exit 0 tcpdump-3.7.2/nameser.h0100644000076500000240000002457507316270700014162 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.9 2001/06/27 05:40:16 guy Exp $ (LBL) */ /* * Copyright (c) 1983, 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)nameser.h 8.2 (Berkeley) 2/16/94 * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * - * --Copyright-- */ #ifndef _NAMESER_H_ #define _NAMESER_H_ #include /* * Define constants based on rfc883 */ #define PACKETSZ 512 /* maximum packet size */ #define MAXDNAME 256 /* maximum domain name */ #define MAXCDNAME 255 /* maximum compressed domain name */ #define MAXLABEL 63 /* maximum length of domain label */ /* Number of bytes of fixed size data in query structure */ #define QFIXEDSZ 4 /* number of bytes of fixed size data in resource record */ #define RRFIXEDSZ 10 /* * Internet nameserver port number */ #define NAMESERVER_PORT 53 /* * Currently defined opcodes */ #define QUERY 0x0 /* standard query */ #define IQUERY 0x1 /* inverse query */ #define STATUS 0x2 /* nameserver status query */ #if 0 #define xxx 0x3 /* 0x3 reserved */ #endif /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */ #define UPDATEA 0x9 /* add resource record */ #define UPDATED 0xa /* delete a specific resource record */ #define UPDATEDA 0xb /* delete all named resource record */ #define UPDATEM 0xc /* modify a specific resource record */ #define UPDATEMA 0xd /* modify all named resource record */ #define ZONEINIT 0xe /* initial zone transfer */ #define ZONEREF 0xf /* incremental zone referesh */ /* * Undefine various #defines from various System V-flavored OSes (Solaris, * SINIX, HP-UX) so the compiler doesn't whine that we redefine them. */ #ifdef T_NULL #undef T_NULL #endif #ifdef T_OPT #undef T_OPT #endif #ifdef T_UNSPEC #undef T_UNSPEC #endif #ifdef NOERROR #undef NOERROR #endif /* * Currently defined response codes */ #define NOERROR 0 /* no error */ #define FORMERR 1 /* format error */ #define SERVFAIL 2 /* server failure */ #define NXDOMAIN 3 /* non existent domain */ #define NOTIMP 4 /* not implemented */ #define REFUSED 5 /* query refused */ /* non standard */ #define NOCHANGE 0xf /* update failed to change db */ /* * Type values for resources and queries */ #define T_A 1 /* host address */ #define T_NS 2 /* authoritative server */ #define T_MD 3 /* mail destination */ #define T_MF 4 /* mail forwarder */ #define T_CNAME 5 /* connonical name */ #define T_SOA 6 /* start of authority zone */ #define T_MB 7 /* mailbox domain name */ #define T_MG 8 /* mail group member */ #define T_MR 9 /* mail rename name */ #define T_NULL 10 /* null resource record */ #define T_WKS 11 /* well known service */ #define T_PTR 12 /* domain name pointer */ #define T_HINFO 13 /* host information */ #define T_MINFO 14 /* mailbox information */ #define T_MX 15 /* mail routing information */ #define T_TXT 16 /* text strings */ #define T_RP 17 /* responsible person */ #define T_AFSDB 18 /* AFS cell database */ #define T_X25 19 /* X_25 calling address */ #define T_ISDN 20 /* ISDN calling address */ #define T_RT 21 /* router */ #define T_NSAP 22 /* NSAP address */ #define T_NSAP_PTR 23 /* reverse lookup for NSAP */ #define T_SIG 24 /* security signature */ #define T_KEY 25 /* security key */ #define T_PX 26 /* X.400 mail mapping */ #define T_GPOS 27 /* geographical position (withdrawn) */ #define T_AAAA 28 /* IP6 Address */ #define T_LOC 29 /* Location Information */ #define T_NXT 30 /* Next Valid Name in Zone */ #define T_EID 31 /* Endpoint identifier */ #define T_NIMLOC 32 /* Nimrod locator */ #define T_SRV 33 /* Server selection */ #define T_ATMA 34 /* ATM Address */ #define T_NAPTR 35 /* Naming Authority PoinTeR */ #define T_A6 38 /* IP6 address */ #define T_DNAME 39 /* non-terminal redirection */ #define T_OPT 41 /* EDNS0 option (meta-RR) */ /* non standard */ #define T_UINFO 100 /* user (finger) information */ #define T_UID 101 /* user ID */ #define T_GID 102 /* group ID */ #define T_UNSPEC 103 /* Unspecified format (binary data) */ #define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */ /* Query type values which do not appear in resource records */ #define T_TKEY 249 /* Transaction Key [RFC2930] */ #define T_TSIG 250 /* Transaction Signature [RFC2845] */ #define T_IXFR 251 /* incremental transfer [RFC1995] */ #define T_AXFR 252 /* transfer zone of authority */ #define T_MAILB 253 /* transfer mailbox records */ #define T_MAILA 254 /* transfer mail agent records */ #define T_ANY 255 /* wildcard match */ /* * Values for class field */ #define C_IN 1 /* the arpa internet */ #define C_CHAOS 3 /* for chaos net (MIT) */ #define C_HS 4 /* for Hesiod name server (MIT) (XXX) */ /* Query class values which do not appear in resource records */ #define C_ANY 255 /* wildcard match */ /* * Status return codes for T_UNSPEC conversion routines */ #define CONV_SUCCESS 0 #define CONV_OVERFLOW -1 #define CONV_BADFMT -2 #define CONV_BADCKSUM -3 #define CONV_BADBUFLEN -4 /* * Structure for query header. */ typedef struct { u_int16_t id; /* query identification number */ u_int8_t flags1; /* first byte of flags */ u_int8_t flags2; /* second byte of flags */ u_int16_t qdcount; /* number of question entries */ u_int16_t ancount; /* number of answer entries */ u_int16_t nscount; /* number of authority entries */ u_int16_t arcount; /* number of resource entries */ } HEADER; /* * Macros for subfields of flag fields. */ #define DNS_QR(np) ((np)->flags1 & 0x80) /* response flag */ #define DNS_OPCODE(np) ((((np)->flags1) >> 3) & 0xF) /* purpose of message */ #define DNS_AA(np) ((np)->flags1 & 0x04) /* authoritative answer */ #define DNS_TC(np) ((np)->flags1 & 0x02) /* truncated message */ #define DNS_RD(np) ((np)->flags1 & 0x01) /* recursion desired */ #define DNS_RA(np) ((np)->flags2 & 0x80) /* recursion available */ #define DNS_AD(np) ((np)->flags2 & 0x20) /* authentic data from named */ #define DNS_CD(np) ((np)->flags2 & 0x10) /* checking disabled by resolver */ #define DNS_RCODE(np) ((np)->flags2 & 0xF) /* response code */ /* * Defines for handling compressed domain names, EDNS0 labels, etc. */ #define INDIR_MASK 0xc0 /* 11.... */ #define EDNS0_MASK 0x40 /* 01.... */ # define EDNS0_ELT_BITLABEL 0x01 /* * Structure for passing resource records around. */ struct rrec { int16_t r_zone; /* zone number */ int16_t r_class; /* class number */ int16_t r_type; /* type number */ u_int32_t r_ttl; /* time to live */ int r_size; /* size of data area */ char *r_data; /* pointer to data */ }; /* * Inline versions of get/put short/long. Pointer is advanced. * We also assume that a "u_int16_t" holds 2 "chars" * and that a "u_int32_t" holds 4 "chars". * * These macros demonstrate the property of C whereby it can be * portable or it can be elegant but never both. */ #define GETSHORT(s, cp) { \ register u_char *t_cp = (u_char *)(cp); \ (s) = ((u_int16_t)t_cp[0] << 8) | (u_int16_t)t_cp[1]; \ (cp) += 2; \ } #define GETLONG(l, cp) { \ register u_char *t_cp = (u_char *)(cp); \ (l) = (((u_int32_t)t_cp[0]) << 24) \ | (((u_int32_t)t_cp[1]) << 16) \ | (((u_int32_t)t_cp[2]) << 8) \ | (((u_int32_t)t_cp[3])); \ (cp) += 4; \ } #define PUTSHORT(s, cp) { \ register u_int16_t t_s = (u_int16_t)(s); \ register u_char *t_cp = (u_char *)(cp); \ *t_cp++ = t_s >> 8; \ *t_cp = t_s; \ (cp) += 2; \ } /* * Warning: PUTLONG --no-longer-- destroys its first argument. if you * were depending on this "feature", you will lose. */ #define PUTLONG(l, cp) { \ register u_int32_t t_l = (u_int32_t)(l); \ register u_char *t_cp = (u_char *)(cp); \ *t_cp++ = t_l >> 24; \ *t_cp++ = t_l >> 16; \ *t_cp++ = t_l >> 8; \ *t_cp = t_l; \ (cp) += 4; \ } #endif /* !_NAMESER_H_ */ tcpdump-3.7.2/netbios.h0100644000076500000240000000044306777230376014176 0ustar fennerstaff/* * NETBIOS protocol formats * * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.1.1.1 1999/10/07 23:47:10 mcr Exp $ */ struct p8022Hdr { u_char dsap; u_char ssap; u_char flags; }; #define p8022Size 3 /* min 802.2 header size */ #define UI 0x03 /* 802.2 flags */ tcpdump-3.7.2/nfs.h0100644000076500000240000003330107140510060013270 0ustar fennerstaff/* $NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Rick Macklem at The University of Guelph. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95 */ /* * nfs definitions as per the Version 2 and 3 specs */ /* * Constants as defined in the Sun NFS Version 2 and 3 specs. * "NFS: Network File System Protocol Specification" RFC1094 * and in the "NFS: Network File System Version 3 Protocol * Specification" */ #define NFS_PORT 2049 #define NFS_PROG 100003 #define NFS_VER2 2 #define NFS_VER3 3 #define NFS_V2MAXDATA 8192 #define NFS_MAXDGRAMDATA 16384 #define NFS_MAXDATA 32768 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_MAXPKTHDR 404 #define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA) #define NFS_MINPACKET 20 #define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */ /* Stat numbers for rpc returns (version 2 and 3) */ #define NFS_OK 0 #define NFSERR_PERM 1 #define NFSERR_NOENT 2 #define NFSERR_IO 5 #define NFSERR_NXIO 6 #define NFSERR_ACCES 13 #define NFSERR_EXIST 17 #define NFSERR_XDEV 18 /* Version 3 only */ #define NFSERR_NODEV 19 #define NFSERR_NOTDIR 20 #define NFSERR_ISDIR 21 #define NFSERR_INVAL 22 /* Version 3 only */ #define NFSERR_FBIG 27 #define NFSERR_NOSPC 28 #define NFSERR_ROFS 30 #define NFSERR_MLINK 31 /* Version 3 only */ #define NFSERR_NAMETOL 63 #define NFSERR_NOTEMPTY 66 #define NFSERR_DQUOT 69 #define NFSERR_STALE 70 #define NFSERR_REMOTE 71 /* Version 3 only */ #define NFSERR_WFLUSH 99 /* Version 2 only */ #define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */ #define NFSERR_NOT_SYNC 10002 #define NFSERR_BAD_COOKIE 10003 #define NFSERR_NOTSUPP 10004 #define NFSERR_TOOSMALL 10005 #define NFSERR_SERVERFAULT 10006 #define NFSERR_BADTYPE 10007 #define NFSERR_JUKEBOX 10008 #define NFSERR_TRYLATER NFSERR_JUKEBOX #define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */ #define NFSERR_RETVOID 0x20000000 /* Return void, not error */ #define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */ #define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */ /* Sizes in bytes of various nfs rpc components */ #define NFSX_UNSIGNED 4 /* specific to NFS Version 2 */ #define NFSX_V2FH 32 #define NFSX_V2FATTR 68 #define NFSX_V2SATTR 32 #define NFSX_V2COOKIE 4 #define NFSX_V2STATFS 20 /* specific to NFS Version 3 */ #if 0 #define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */ #endif #define NFSX_V3FHMAX 64 /* max. allowed by protocol */ #define NFSX_V3FATTR 84 #define NFSX_V3SATTR 60 /* max. all fields filled in */ #define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr)) #define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED) #define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED) #define NFSX_V3COOKIEVERF 8 #define NFSX_V3WRITEVERF 8 #define NFSX_V3CREATEVERF 8 #define NFSX_V3STATFS 52 #define NFSX_V3FSINFO 48 #define NFSX_V3PATHCONF 24 /* variants for both versions */ #define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \ NFSX_V2FH) #define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH) #define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR) #define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0) #define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0) #define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \ NFSX_V2FATTR) #define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0) #define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR) #define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR) #define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0) #define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0) #define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \ (2 * NFSX_UNSIGNED)) #define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS) /* nfs rpc procedure numbers (before version mapping) */ #define NFSPROC_NULL 0 #define NFSPROC_GETATTR 1 #define NFSPROC_SETATTR 2 #define NFSPROC_LOOKUP 3 #define NFSPROC_ACCESS 4 #define NFSPROC_READLINK 5 #define NFSPROC_READ 6 #define NFSPROC_WRITE 7 #define NFSPROC_CREATE 8 #define NFSPROC_MKDIR 9 #define NFSPROC_SYMLINK 10 #define NFSPROC_MKNOD 11 #define NFSPROC_REMOVE 12 #define NFSPROC_RMDIR 13 #define NFSPROC_RENAME 14 #define NFSPROC_LINK 15 #define NFSPROC_READDIR 16 #define NFSPROC_READDIRPLUS 17 #define NFSPROC_FSSTAT 18 #define NFSPROC_FSINFO 19 #define NFSPROC_PATHCONF 20 #define NFSPROC_COMMIT 21 /* And leasing (nqnfs) procedure numbers (must be last) */ #define NQNFSPROC_GETLEASE 22 #define NQNFSPROC_VACATED 23 #define NQNFSPROC_EVICTED 24 #define NFSPROC_NOOP 25 #define NFS_NPROCS 26 /* Actual Version 2 procedure numbers */ #define NFSV2PROC_NULL 0 #define NFSV2PROC_GETATTR 1 #define NFSV2PROC_SETATTR 2 #define NFSV2PROC_NOOP 3 #define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */ #define NFSV2PROC_LOOKUP 4 #define NFSV2PROC_READLINK 5 #define NFSV2PROC_READ 6 #define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */ #define NFSV2PROC_WRITE 8 #define NFSV2PROC_CREATE 9 #define NFSV2PROC_REMOVE 10 #define NFSV2PROC_RENAME 11 #define NFSV2PROC_LINK 12 #define NFSV2PROC_SYMLINK 13 #define NFSV2PROC_MKDIR 14 #define NFSV2PROC_RMDIR 15 #define NFSV2PROC_READDIR 16 #define NFSV2PROC_STATFS 17 /* * Constants used by the Version 3 protocol for various RPCs */ #define NFSV3SATTRTIME_DONTCHANGE 0 #define NFSV3SATTRTIME_TOSERVER 1 #define NFSV3SATTRTIME_TOCLIENT 2 #define NFSV3ATTRTIME_NMODES 3 #define NFSV3ACCESS_READ 0x01 #define NFSV3ACCESS_LOOKUP 0x02 #define NFSV3ACCESS_MODIFY 0x04 #define NFSV3ACCESS_EXTEND 0x08 #define NFSV3ACCESS_DELETE 0x10 #define NFSV3ACCESS_EXECUTE 0x20 #define NFSV3WRITE_UNSTABLE 0 #define NFSV3WRITE_DATASYNC 1 #define NFSV3WRITE_FILESYNC 2 #define NFSV3WRITE_NMODES 3 #define NFSV3CREATE_UNCHECKED 0 #define NFSV3CREATE_GUARDED 1 #define NFSV3CREATE_EXCLUSIVE 2 #define NFSV3CREATE_NMODES 3 #define NFSV3FSINFO_LINK 0x01 #define NFSV3FSINFO_SYMLINK 0x02 #define NFSV3FSINFO_HOMOGENEOUS 0x08 #define NFSV3FSINFO_CANSETTIME 0x10 /* Conversion macros */ #define vtonfsv2_mode(t,m) \ txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \ MAKEIMODE((t), (m))) #define vtonfsv3_mode(m) txdr_unsigned((m) & 07777) #define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&07777) #define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))]) #define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))]) #define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] #define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] /* File types */ typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5, NFSOCK=6, NFFIFO=7 } nfs_type; /* Structs for common parts of the rpc's */ /* * File Handle (32 bytes for version 2), variable up to 64 for version 3. * File Handles of up to NFS_SMALLFH in size are stored directly in the * nfs node, whereas larger ones are malloc'd. (This never happens when * NFS_SMALLFH is set to 64.) * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4. */ #ifndef NFS_SMALLFH #define NFS_SMALLFH 64 #endif union nfsfh { /* fhandle_t fh_generic; */ u_char fh_bytes[NFS_SMALLFH]; }; typedef union nfsfh nfsfh_t; struct nfsv2_time { u_int32_t nfsv2_sec; u_int32_t nfsv2_usec; }; typedef struct nfsv2_time nfstime2; struct nfsv3_time { u_int32_t nfsv3_sec; u_int32_t nfsv3_nsec; }; typedef struct nfsv3_time nfstime3; /* * Quads are defined as arrays of 2 longs to ensure dense packing for the * protocol and to facilitate xdr conversion. */ struct nfs_uquad { u_int32_t nfsuquad[2]; }; typedef struct nfs_uquad nfsuint64; #if 0 /* XXX - this doesn't seemed to be used and it doesn't work * with non-gcc, so comment it out for now. */ /* * Used to convert between two u_longs and a u_quad_t. */ union nfs_quadconvert { u_int32_t lval[2]; u_int64_t qval; }; typedef union nfs_quadconvert nfsquad_t; #endif /* * NFS Version 3 special file number. */ struct nfsv3_spec { u_int32_t specdata1; u_int32_t specdata2; }; typedef struct nfsv3_spec nfsv3spec; /* * File attributes and setable attributes. These structures cover both * NFS version 2 and the version 3 protocol. Note that the union is only * used so that one pointer can refer to both variants. These structures * go out on the wire and must be densely packed, so no quad data types * are used. (all fields are longs or u_longs or structures of same) * NB: You can't do sizeof(struct nfs_fattr), you must use the * NFSX_FATTR(v3) macro. */ struct nfs_fattr { u_int32_t fa_type; u_int32_t fa_mode; u_int32_t fa_nlink; u_int32_t fa_uid; u_int32_t fa_gid; union { struct { u_int32_t nfsv2fa_size; u_int32_t nfsv2fa_blocksize; u_int32_t nfsv2fa_rdev; u_int32_t nfsv2fa_blocks; u_int32_t nfsv2fa_fsid; u_int32_t nfsv2fa_fileid; nfstime2 nfsv2fa_atime; nfstime2 nfsv2fa_mtime; nfstime2 nfsv2fa_ctime; } fa_nfsv2; struct { nfsuint64 nfsv3fa_size; nfsuint64 nfsv3fa_used; nfsv3spec nfsv3fa_rdev; nfsuint64 nfsv3fa_fsid; nfsuint64 nfsv3fa_fileid; nfstime3 nfsv3fa_atime; nfstime3 nfsv3fa_mtime; nfstime3 nfsv3fa_ctime; } fa_nfsv3; } fa_un; }; /* and some ugly defines for accessing union components */ #define fa2_size fa_un.fa_nfsv2.nfsv2fa_size #define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize #define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev #define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks #define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid #define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid #define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime #define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime #define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime #define fa3_size fa_un.fa_nfsv3.nfsv3fa_size #define fa3_used fa_un.fa_nfsv3.nfsv3fa_used #define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev #define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid #define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid #define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime #define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime #define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime struct nfsv2_sattr { u_int32_t sa_mode; u_int32_t sa_uid; u_int32_t sa_gid; u_int32_t sa_size; nfstime2 sa_atime; nfstime2 sa_mtime; }; /* * NFS Version 3 sattr structure for the new node creation case. */ struct nfsv3_sattr { u_int32_t sa_modeset; u_int32_t sa_mode; u_int32_t sa_uidset; u_int32_t sa_uid; u_int32_t sa_gidset; u_int32_t sa_gid; u_int32_t sa_sizeset; u_int32_t sa_size; u_int32_t sa_atimetype; nfstime3 sa_atime; u_int32_t sa_mtimetype; nfstime3 sa_mtime; }; struct nfs_statfs { union { struct { u_int32_t nfsv2sf_tsize; u_int32_t nfsv2sf_bsize; u_int32_t nfsv2sf_blocks; u_int32_t nfsv2sf_bfree; u_int32_t nfsv2sf_bavail; } sf_nfsv2; struct { nfsuint64 nfsv3sf_tbytes; nfsuint64 nfsv3sf_fbytes; nfsuint64 nfsv3sf_abytes; nfsuint64 nfsv3sf_tfiles; nfsuint64 nfsv3sf_ffiles; nfsuint64 nfsv3sf_afiles; u_int32_t nfsv3sf_invarsec; } sf_nfsv3; } sf_un; }; #define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize #define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize #define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks #define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree #define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail #define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes #define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes #define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes #define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles #define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles #define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles #define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec struct nfsv3_fsinfo { u_int32_t fs_rtmax; u_int32_t fs_rtpref; u_int32_t fs_rtmult; u_int32_t fs_wtmax; u_int32_t fs_wtpref; u_int32_t fs_wtmult; u_int32_t fs_dtpref; nfsuint64 fs_maxfilesize; nfstime3 fs_timedelta; u_int32_t fs_properties; }; struct nfsv3_pathconf { u_int32_t pc_linkmax; u_int32_t pc_namemax; u_int32_t pc_notrunc; u_int32_t pc_chownrestricted; u_int32_t pc_caseinsensitive; u_int32_t pc_casepreserving; }; tcpdump-3.7.2/nfsfh.h0100644000076500000240000000523007351470740013624 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.12 2001/09/17 21:57:52 fenner Exp $ (LBL) */ /* * Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation, * Western Research Laboratory. All rights reserved. * Copyright (c) 2001 Compaq Computer Corporation. All rights reserved. * * Permission to use, copy, and modify this software and its * documentation is hereby granted only under the following terms and * conditions. Both the above copyright notice and this permission * notice must appear in all copies of the software, derivative works * or modified versions, and any portions thereof, and both notices * must appear in supporting documentation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THE SOFTWARE IS PROVIDED "AS IS" AND COMPAQ COMPUTER CORPORATION * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO * EVENT SHALL COMPAQ COMPUTER CORPORATION BE LIABLE FOR ANY * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* * nfsfh.h - NFS file handle definitions (for portable use) * * Jeffrey C. Mogul * Digital Equipment Corporation * Western Research Laboratory */ /* * Internal representation of dev_t, because different NFS servers * that we might be spying upon use different external representations. */ typedef struct { u_int32_t Minor; /* upper case to avoid clashing with macro names */ u_int32_t Major; } my_devt; #define dev_eq(a,b) ((a.Minor == b.Minor) && (a.Major == b.Major)) /* * Many file servers now use a large file system ID. This is * our internal representation of that. */ typedef struct { my_devt Fsid_dev; /* XXX avoid name conflict with AIX */ char Opaque_Handle[2 * 32 + 1]; u_int32_t fsid_code; } my_fsid; #define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\ dev_eq(a.Fsid_dev, b.Fsid_dev)) extern void Parse_fh(caddr_t *, int, my_fsid *, ino_t *, const char **, const char **, int); tcpdump-3.7.2/ntp.h0100644000076500000240000000744307166245201013325 0ustar fennerstaff/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.4 2000/10/03 02:54:57 itojun Exp $ */ /* * Based on ntp.h from the U of MD implementation * This file is based on Version 2 of the NTP spec (RFC1119). */ /* * Definitions for the masses */ #define JAN_1970 2208988800 /* 1970 - 1900 in seconds */ /* * Structure definitions for NTP fixed point values * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Integer Part | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Fraction Part | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Integer Part | Fraction Part | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct l_fixedpt { u_int32_t int_part; u_int32_t fraction; }; struct s_fixedpt { u_int16_t int_part; u_int16_t fraction; }; /* ================= Table 3.3. Packet Variables ================= */ /* * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |LI | VN | Mode| Stratum | Poll | Precision | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Synchronizing Distance | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Synchronizing Dispersion | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Reference Clock Identifier | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * | Reference Timestamp (64 bits) | * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * | Originate Timestamp (64 bits) | * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * | Receive Timestamp (64 bits) | * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * | Transmit Timestamp (64 bits) | * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct ntpdata { u_char status; /* status of local clock and leap info */ u_char stratum; /* Stratum level */ u_char ppoll; /* poll value */ int precision:8; struct s_fixedpt distance; struct s_fixedpt dispersion; u_int32_t refid; struct l_fixedpt reftime; struct l_fixedpt org; struct l_fixedpt rec; struct l_fixedpt xmt; }; /* * Leap Second Codes (high order two bits) */ #define NO_WARNING 0x00 /* no warning */ #define PLUS_SEC 0x40 /* add a second (61 seconds) */ #define MINUS_SEC 0x80 /* minus a second (59 seconds) */ #define ALARM 0xc0 /* alarm condition (clock unsynchronized) */ /* * Clock Status Bits that Encode Version */ #define NTPVERSION_1 0x08 #define VERSIONMASK 0x38 #define LEAPMASK 0xc0 #define MODEMASK 0x07 /* * Code values */ #define MODE_UNSPEC 0 /* unspecified */ #define MODE_SYM_ACT 1 /* symmetric active */ #define MODE_SYM_PAS 2 /* symmetric passive */ #define MODE_CLIENT 3 /* client */ #define MODE_SERVER 4 /* server */ #define MODE_BROADCAST 5 /* broadcast */ #define MODE_RES1 6 /* reserved */ #define MODE_RES2 7 /* reserved */ /* * Stratum Definitions */ #define UNSPECIFIED 0 #define PRIM_REF 1 /* radio clock */ #define INFO_QUERY 62 /* **** THIS implementation dependent **** */ #define INFO_REPLY 63 /* **** THIS implementation dependent **** */ tcpdump-3.7.2/oakley.h0100644000076500000240000001275307006476756014026 0ustar fennerstaff/* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* YIPS @(#)$Id: oakley.h,v 1.1 1999/10/30 05:11:10 itojun Exp $ */ /* refer to RFC 2409 */ #if !defined(_ISAKMP_OAKLEY_H_) #define _ISAKMP_OAKLEY_H_ /* Attribute Classes */ #define OAKLEY_ATTR_ENC_ALG 1 /* B */ #define OAKLEY_ATTR_ENC_ALG_DES 1 #define OAKLEY_ATTR_ENC_ALG_IDEA 2 #define OAKLEY_ATTR_ENC_ALG_BL 3 #define OAKLEY_ATTR_ENC_ALG_RC5 4 #define OAKLEY_ATTR_ENC_ALG_3DES 5 #define OAKLEY_ATTR_ENC_ALG_CAST 6 #define OAKLEY_ATTR_HASH_ALG 2 /* B */ #define OAKLEY_ATTR_HASH_ALG_MD5 1 #define OAKLEY_ATTR_HASH_ALG_SHA 2 #define OAKLEY_ATTR_HASH_ALG_TIGER 3 #define OAKLEY_ATTR_AUTH_METHOD 3 /* B */ #define OAKLEY_ATTR_AUTH_METHOD_PSKEY 1 #define OAKLEY_ATTR_AUTH_METHOD_DSS 2 #define OAKLEY_ATTR_AUTH_METHOD_RSA 3 #define OAKLEY_ATTR_AUTH_METHOD_RSAENC 4 #define OAKLEY_ATTR_AUTH_METHOD_RSAREV 5 #define OAKLEY_ATTR_GRP_DESC 4 /* B */ #define OAKLEY_ATTR_GRP_DESC_MODP768 1 #define OAKLEY_ATTR_GRP_DESC_MODP1024 2 #define OAKLEY_ATTR_GRP_DESC_EC2N155 3 #define OAKLEY_ATTR_GRP_DESC_EC2N185 4 #define OAKLEY_ATTR_GRP_TYPE 5 /* B */ #define OAKLEY_ATTR_GRP_TYPE_MODP 1 #define OAKLEY_ATTR_GRP_TYPE_ECP 2 #define OAKLEY_ATTR_GRP_TYPE_EC2N 3 #define OAKLEY_ATTR_GRP_PI 6 /* V */ #define OAKLEY_ATTR_GRP_GEN_ONE 7 /* V */ #define OAKLEY_ATTR_GRP_GEN_TWO 8 /* V */ #define OAKLEY_ATTR_GRP_CURVE_A 9 /* V */ #define OAKLEY_ATTR_GRP_CURVE_B 10 /* V */ #define OAKLEY_ATTR_SA_LTYPE 11 /* B */ #define OAKLEY_ATTR_SA_LTYPE_DEFAULT 1 #define OAKLEY_ATTR_SA_LTYPE_SEC 1 #define OAKLEY_ATTR_SA_LTYPE_KB 2 #define OAKLEY_ATTR_SA_LDUR 12 /* V */ #define OAKLEY_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */ #define OAKLEY_ATTR_PRF 13 /* B */ #define OAKLEY_ATTR_KEY_LEN 14 /* B */ #define OAKLEY_ATTR_FIELD_SIZE 15 /* B */ #define OAKLEY_ATTR_GRP_ORDER 16 /* V */ #define OAKLEY_ID_IPV4_ADDR 0 #define OAKLEY_ID_IPV4_ADDR_SUBNET 1 #define OAKLEY_ID_IPV6_ADDR 2 #define OAKLEY_ID_IPV6_ADDR_SUBNET 3 /* Additional Exchange Type */ #define ISAKMP_ETYPE_QUICK 32 #define ISAKMP_ETYPE_NEWGRP 33 /* The use for checking proposal payload. This is not exchange type. */ #define OAKLEY_MAIN_MODE 0 #define OAKLEY_QUICK_MODE 1 #define OAKLEY_PRIME_MODP768 "\ FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \ 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \ EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \ E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF" #define OAKLEY_PRIME_MODP1024 "\ FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \ 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \ EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \ E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED \ EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 \ FFFFFFFF FFFFFFFF" #define DEFAULTSECRETSIZE ( 128 / 8 ) /* 128 bits */ #define DEFAULTNONCESIZE ( 128 / 8 ) /* 128 bits */ #define MAXPADLWORD 20 #if 0 /* isakmp sa structure */ struct oakley_sa { u_int8_t proto_id; /* OAKLEY */ vchar_t *spi; /* spi */ u_int8_t dhgrp; /* DH; group */ u_int8_t auth_t; /* method of authentication */ u_int8_t prf_t; /* type of prf */ u_int8_t hash_t; /* type of hash */ u_int8_t enc_t; /* type of cipher */ u_int8_t life_t; /* type of duration of lifetime */ u_int32_t ldur; /* life duration */ }; #endif #endif /* !defined(_ISAKMP_OAKLEY_H_) */ tcpdump-3.7.2/ospf.h0100644000076500000240000001447307217243506013477 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ #define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */ #define OSPF_TYPE_HELLO 1 /* Hello */ #define OSPF_TYPE_DB 2 /* Database Description */ #define OSPF_TYPE_LSR 3 /* Link State Request */ #define OSPF_TYPE_LSU 4 /* Link State Update */ #define OSPF_TYPE_LSA 5 /* Link State Ack */ #define OSPF_TYPE_MAX 6 /* Options *_options */ #define OSPF_OPTION_T 0x01 /* T bit: TOS support */ #define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */ #define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */ /* ospf_authtype */ #define OSPF_AUTH_NONE 0 /* No auth-data */ #define OSPF_AUTH_SIMPLE 1 /* Simple password */ #define OSPF_AUTH_MD5 2 /* MD5 authentication */ #define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */ /* db_flags */ #define OSPF_DB_INIT 0x04 /* */ #define OSPF_DB_MORE 0x02 #define OSPF_DB_MASTER 0x01 /* ls_type */ #define LS_TYPE_ROUTER 1 /* router link */ #define LS_TYPE_NETWORK 2 /* network link */ #define LS_TYPE_SUM_IP 3 /* summary link */ #define LS_TYPE_SUM_ABR 4 /* summary area link */ #define LS_TYPE_ASE 5 /* ASE */ #define LS_TYPE_GROUP 6 /* Group membership (multicast */ /* extensions 23 July 1991) */ #define LS_TYPE_MAX 7 /************************************************* * * is the above a bug in the documentation? * *************************************************/ /* rla_link.link_type */ #define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ #define RLA_TYPE_TRANSIT 2 /* connection to transit network */ #define RLA_TYPE_STUB 3 /* connection to stub network */ #define RLA_TYPE_VIRTUAL 4 /* virtual link */ /* rla_flags */ #define RLA_FLAG_B 0x01 #define RLA_FLAG_E 0x02 #define RLA_FLAG_W1 0x04 #define RLA_FLAG_W2 0x08 /* sla_tosmetric breakdown */ #define SLA_MASK_TOS 0x7f000000 #define SLA_MASK_METRIC 0x00ffffff #define SLA_SHIFT_TOS 24 /* asla_tosmetric breakdown */ #define ASLA_FLAG_EXTERNAL 0x80000000 #define ASLA_MASK_TOS 0x7f000000 #define ASLA_SHIFT_TOS 24 #define ASLA_MASK_METRIC 0x00ffffff /* multicast vertex type */ #define MCLA_VERTEX_ROUTER 1 #define MCLA_VERTEX_NETWORK 2 /* link state advertisement header */ struct lsa_hdr { u_int16_t ls_age; u_int8_t ls_options; u_int8_t ls_type; struct in_addr ls_stateid; struct in_addr ls_router; u_int32_t ls_seq; u_int16_t ls_chksum; u_int16_t ls_length; } ; /* link state advertisement */ struct lsa { struct lsa_hdr ls_hdr; /* Link state types */ union { /* Router links advertisements */ struct { u_int8_t rla_flags; u_int8_t rla_zero[1]; u_int16_t rla_count; struct rlalink { struct in_addr link_id; struct in_addr link_data; u_int8_t link_type; u_int8_t link_toscount; u_int16_t link_tos0metric; } rla_link[1]; /* may repeat */ } un_rla; /* Network links advertisements */ struct { struct in_addr nla_mask; struct in_addr nla_router[1]; /* may repeat */ } un_nla; /* Summary links advertisements */ struct { struct in_addr sla_mask; u_int32_t sla_tosmetric[1]; /* may repeat */ } un_sla; /* AS external links advertisements */ struct { struct in_addr asla_mask; struct aslametric { u_int32_t asla_tosmetric; struct in_addr asla_forward; struct in_addr asla_tag; } asla_metric[1]; /* may repeat */ } un_asla; /* Multicast group membership */ struct mcla { u_int32_t mcla_vtype; struct in_addr mcla_vid; } un_mcla[1]; } lsa_un; } ; /* * TOS metric struct (will be 0 or more in router links update) */ struct tos_metric { u_int8_t tos_type; u_int8_t tos_zero; u_int16_t tos_metric; } ; #define OSPF_AUTH_SIZE 8 /* * the main header */ struct ospfhdr { u_int8_t ospf_version; u_int8_t ospf_type; u_int16_t ospf_len; struct in_addr ospf_routerid; struct in_addr ospf_areaid; u_int16_t ospf_chksum; u_int16_t ospf_authtype; u_int8_t ospf_authdata[OSPF_AUTH_SIZE]; union { /* Hello packet */ struct { struct in_addr hello_mask; u_int16_t hello_helloint; u_int8_t hello_options; u_int8_t hello_priority; u_int32_t hello_deadint; struct in_addr hello_dr; struct in_addr hello_bdr; struct in_addr hello_neighbor[1]; /* may repeat */ } un_hello; /* Database Description packet */ struct { u_int8_t db_zero[2]; u_int8_t db_options; u_int8_t db_flags; u_int32_t db_seq; struct lsa_hdr db_lshdr[1]; /* may repeat */ } un_db; /* Link State Request */ struct lsr { u_int32_t ls_type; struct in_addr ls_stateid; struct in_addr ls_router; } un_lsr[1]; /* may repeat */ /* Link State Update */ struct { u_int32_t lsu_count; struct lsa lsu_lsa[1]; /* may repeat */ } un_lsu; /* Link State Acknowledgement */ struct { struct lsa_hdr lsa_lshdr[1]; /* may repeat */ } un_lsa ; } ospf_un ; } ; #define ospf_hello ospf_un.un_hello #define ospf_db ospf_un.un_db #define ospf_lsr ospf_un.un_lsr #define ospf_lsu ospf_un.un_lsu #define ospf_lsa ospf_un.un_lsa tcpdump-3.7.2/ospf6.h0100644000076500000240000001644707217243506013570 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.3 2000/12/17 23:07:50 guy Exp $ (LBL) */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ #define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */ #define OSPF_TYPE_HELLO 1 /* Hello */ #define OSPF_TYPE_DB 2 /* Database Description */ #define OSPF_TYPE_LSR 3 /* Link State Request */ #define OSPF_TYPE_LSU 4 /* Link State Update */ #define OSPF_TYPE_LSA 5 /* Link State Ack */ #define OSPF_TYPE_MAX 6 /* Options *_options */ #define OSPF6_OPTION_V6 0x01 /* V6 bit: A bit for peeping tom */ #define OSPF6_OPTION_E 0x02 /* E bit: External routes advertised */ #define OSPF6_OPTION_MC 0x04 /* MC bit: Multicast capable */ #define OSPF6_OPTION_N 0x08 /* N bit: For type-7 LSA */ #define OSPF6_OPTION_R 0x10 /* R bit: Router bit */ #define OSPF6_OPTION_DC 0x20 /* DC bit: Demand circuits */ /* db_flags */ #define OSPF6_DB_INIT 0x04 /* */ #define OSPF6_DB_MORE 0x02 #define OSPF6_DB_MASTER 0x01 /* ls_type */ #define LS_TYPE_ROUTER 1 /* router link */ #define LS_TYPE_NETWORK 2 /* network link */ #define LS_TYPE_INTER_AP 3 /* Inter-Area-Prefix */ #define LS_TYPE_INTER_AR 4 /* Inter-Area-Router */ #define LS_TYPE_ASE 5 /* ASE */ #define LS_TYPE_GROUP 6 /* Group membership */ #define LS_TYPE_TYPE7 7 /* Type 7 LSA */ #define LS_TYPE_LINK 8 /* Link LSA */ #define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */ #define LS_TYPE_MAX 10 #define LS_TYPE_MASK 0x1fff #define LS_SCOPE_LINKLOCAL 0x0000 #define LS_SCOPE_AREA 0x2000 #define LS_SCOPE_AS 0x4000 #define LS_SCOPE_MASK 0x6000 /************************************************* * * is the above a bug in the documentation? * *************************************************/ /* rla_link.link_type */ #define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ #define RLA_TYPE_TRANSIT 2 /* connection to transit network */ #define RLA_TYPE_VIRTUAL 4 /* virtual link */ /* rla_flags */ #define RLA_FLAG_B 0x01 #define RLA_FLAG_E 0x02 #define RLA_FLAG_V 0x04 #define RLA_FLAG_W 0x08 /* sla_tosmetric breakdown */ #define SLA_MASK_TOS 0x7f000000 #define SLA_MASK_METRIC 0x00ffffff #define SLA_SHIFT_TOS 24 /* asla_metric */ #define ASLA_FLAG_EXTERNAL 0x04000000 #define ASLA_FLAG_FWDADDR 0x02000000 #define ASLA_FLAG_ROUTETAG 0x01000000 #define ASLA_MASK_METRIC 0x00ffffff /* multicast vertex type */ #define MCLA_VERTEX_ROUTER 1 #define MCLA_VERTEX_NETWORK 2 typedef u_int32_t rtrid_t; /* link state advertisement header */ struct lsa_hdr { u_int16_t ls_age; u_int16_t ls_type; rtrid_t ls_stateid; rtrid_t ls_router; u_int32_t ls_seq; u_int16_t ls_chksum; u_int16_t ls_length; } ; struct lsa_prefix { u_int8_t lsa_p_len; u_int8_t lsa_p_opt; u_int16_t lsa_p_mbz; u_int8_t lsa_p_prefix[4]; }; /* link state advertisement */ struct lsa { struct lsa_hdr ls_hdr; /* Link state types */ union { /* Router links advertisements */ struct { union { u_int8_t flg; u_int32_t opt; } rla_flgandopt; #define rla_flags rla_flgandopt.flg #define rla_options rla_flgandopt.opt struct rlalink { u_int8_t link_type; u_int8_t link_zero[1]; u_int16_t link_metric; u_int32_t link_ifid; u_int32_t link_nifid; rtrid_t link_nrtid; } rla_link[1]; /* may repeat */ } un_rla; /* Network links advertisements */ struct { u_int32_t nla_options; rtrid_t nla_router[1]; /* may repeat */ } un_nla; /* Inter Area Prefix LSA */ struct { u_int32_t inter_ap_metric; struct lsa_prefix inter_ap_prefix[1]; } un_inter_ap; /* AS external links advertisements */ struct { u_int32_t asla_metric; struct lsa_prefix asla_prefix[1]; /* some optional fields follow */ } un_asla; #if 0 /* Summary links advertisements */ struct { struct in_addr sla_mask; u_int32_t sla_tosmetric[1]; /* may repeat */ } un_sla; /* Multicast group membership */ struct mcla { u_int32_t mcla_vtype; struct in_addr mcla_vid; } un_mcla[1]; #endif /* Type 7 LSA */ /* Link LSA */ struct llsa { union { u_int8_t pri; u_int32_t opt; } llsa_priandopt; #define llsa_priority llsa_priandopt.pri #define llsa_options llsa_priandopt.opt struct in6_addr llsa_lladdr; u_int32_t llsa_nprefix; struct lsa_prefix llsa_prefix[1]; } un_llsa; /* Intra-Area-Prefix */ struct { u_int16_t intra_ap_nprefix; u_int16_t intra_ap_lstype; rtrid_t intra_ap_lsid; rtrid_t intra_ap_rtid; struct lsa_prefix intra_ap_prefix[1]; } un_intra_ap; } lsa_un; } ; /* * TOS metric struct (will be 0 or more in router links update) */ struct tos_metric { u_int8_t tos_type; u_int8_t tos_zero; u_int16_t tos_metric; } ; #define OSPF_AUTH_SIZE 8 /* * the main header */ struct ospf6hdr { u_int8_t ospf6_version; u_int8_t ospf6_type; u_int16_t ospf6_len; rtrid_t ospf6_routerid; rtrid_t ospf6_areaid; u_int16_t ospf6_chksum; u_int8_t ospf6_instanceid; u_int8_t ospf6_rsvd; union { /* Hello packet */ struct { u_int32_t hello_ifid; union { u_int8_t pri; u_int32_t opt; } hello_priandopt; #define hello_priority hello_priandopt.pri #define hello_options hello_priandopt.opt u_int16_t hello_helloint; u_int16_t hello_deadint; rtrid_t hello_dr; rtrid_t hello_bdr; rtrid_t hello_neighbor[1]; /* may repeat */ } un_hello; /* Database Description packet */ struct { u_int32_t db_options; u_int16_t db_mtu; u_int8_t db_mbz; u_int8_t db_flags; u_int32_t db_seq; struct lsa_hdr db_lshdr[1]; /* may repeat */ } un_db; /* Link State Request */ struct lsr { u_int16_t ls_mbz; u_int16_t ls_type; rtrid_t ls_stateid; rtrid_t ls_router; } un_lsr[1]; /* may repeat */ /* Link State Update */ struct { u_int32_t lsu_count; struct lsa lsu_lsa[1]; /* may repeat */ } un_lsu; /* Link State Acknowledgement */ struct { struct lsa_hdr lsa_lshdr[1]; /* may repeat */ } un_lsa ; } ospf6_un ; } ; #define ospf6_hello ospf6_un.un_hello #define ospf6_db ospf6_un.un_db #define ospf6_lsr ospf6_un.un_lsr #define ospf6_lsu ospf6_un.un_lsu #define ospf6_lsa ospf6_un.un_lsa tcpdump-3.7.2/packetdat.awk0100644000076500000240000000262406777230377015032 0ustar fennerstaffBEGIN { # we need to know (usual) packet size to convert byte numbers # to packet numbers if (packetsize <= 0) packetsize = 512 } $5 !~ /[SR]/ { # print out per-packet data in the form: # # # <1st send time> # # <1st ack time> # # <# sends> # <# acks> n = split ($1,t,":") tim = t[1]*3600 + t[2]*60 + t[3] if ($6 != "ack") { i = index($6,":") strtSeq = substr($6,1,i-1) id = 1.5 + (strtSeq - 1) / packetsize id -= id % 1 if (maxId < id) maxId = id if (firstSend[id] == 0) { firstSend[id] = tim seqNo[id] = strtSeq } lastSend[id] = tim timesSent[id]++ totalPackets++ } else { id = 1 + ($7 - 2) / packetsize id -= id % 1 timesAcked[id]++ if (firstAck[id] == 0) firstAck[id] = tim lastAck[id] = tim totalAcks++ } } END { print "# " maxId " chunks. " totalPackets " packets sent. " \ totalAcks " acks." # for packets that were implicitly acked, make the ack time # be the ack time of next explicitly acked packet. for (i = maxId-1; i > 0; --i) while (i > 0 && firstAck[i] == 0) { lastAck[i] = firstAck[i] = firstAck[i+1] --i } tzero = firstSend[1] for (i = 1; i <= maxId; i++) printf "%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%d\t%d\n",\ i, seqNo[i], \ firstSend[i] - tzero, lastSend[i] - tzero,\ firstAck[i] - tzero, lastAck[i] - tzero,\ timesSent[i], timesAcked[i] } tcpdump-3.7.2/parsenfsfh.c0100644000076500000240000002777507351470741014675 0ustar fennerstaff/* * Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation, * Western Research Laboratory. All rights reserved. * Copyright (c) 2001 Compaq Computer Corporation. All rights reserved. * * Permission to use, copy, and modify this software and its * documentation is hereby granted only under the following terms and * conditions. Both the above copyright notice and this permission * notice must appear in all copies of the software, derivative works * or modified versions, and any portions thereof, and both notices * must appear in supporting documentation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THE SOFTWARE IS PROVIDED "AS IS" AND COMPAQ COMPUTER CORPORATION * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO * EVENT SHALL COMPAQ COMPUTER CORPORATION BE LIABLE FOR ANY * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* * parsenfsfh.c - portable parser for NFS file handles * uses all sorts of heuristics * * Jeffrey C. Mogul * Digital Equipment Corporation * Western Research Laboratory */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.23 2001/09/17 21:57:53 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "interface.h" #include "nfsfh.h" /* * This routine attempts to parse a file handle (in network byte order), * using heuristics to guess what kind of format it is in. See the * file "fhandle_layouts" for a detailed description of the various * patterns we know about. * * The file handle is parsed into our internal representation of a * file-system id, and an internal representation of an inode-number. */ #define FHT_UNKNOWN 0 #define FHT_AUSPEX 1 #define FHT_DECOSF 2 #define FHT_IRIX4 3 #define FHT_IRIX5 4 #define FHT_SUNOS3 5 #define FHT_SUNOS4 6 #define FHT_ULTRIX 7 #define FHT_VMSUCX 8 #define FHT_SUNOS5 9 #define FHT_AIX32 10 #define FHT_HPUX9 11 #ifdef ultrix /* Nasty hack to keep the Ultrix C compiler from emitting bogus warnings */ #define XFF(x) ((u_int32_t)(x)) #else #define XFF(x) (x) #endif #define make_uint32(msb,b,c,lsb)\ (XFF(lsb) + (XFF(c)<<8) + (XFF(b)<<16) + (XFF(msb)<<24)) #define make_uint24(msb,b, lsb)\ (XFF(lsb) + (XFF(b)<<8) + (XFF(msb)<<16)) #define make_uint16(msb,lsb)\ (XFF(lsb) + (XFF(msb)<<8)) #ifdef __alpha /* or other 64-bit systems */ #define make_uint48(msb,b,c,d,e,lsb)\ ((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24) + ((b)<<32) + ((msb)<<40)) #else /* on 32-bit systems ignore high-order bits */ #define make_uint48(msb,b,c,d,e,lsb)\ ((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24)) #endif static int is_UCX(unsigned char *); void Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself) register caddr_t *fh; int len; my_fsid *fsidp; ino_t *inop; const char **osnamep; /* if non-NULL, return OS name here */ const char **fsnamep; /* if non-NULL, return server fs name here (for VMS) */ int ourself; /* true if file handle was generated on this host */ { register unsigned char *fhp = (unsigned char *)fh; u_int32_t temp; int fhtype = FHT_UNKNOWN; int i; if (ourself) { /* File handle generated on this host, no need for guessing */ #if defined(IRIX40) fhtype = FHT_IRIX4; #endif #if defined(IRIX50) fhtype = FHT_IRIX5; #endif #if defined(IRIX51) fhtype = FHT_IRIX5; #endif #if defined(SUNOS4) fhtype = FHT_SUNOS4; #endif #if defined(SUNOS5) fhtype = FHT_SUNOS5; #endif #if defined(ultrix) fhtype = FHT_ULTRIX; #endif #if defined(__osf__) fhtype = FHT_DECOSF; #endif } /* * This is basically a big decision tree */ else if ((fhp[0] == 0) && (fhp[1] == 0)) { /* bytes[0,1] == (0,0); rules out Ultrix, IRIX5, SUNOS5 */ /* probably rules out HP-UX, AIX unless they allow major=0 */ if ((fhp[2] == 0) && (fhp[3] == 0)) { /* bytes[2,3] == (0,0); must be Auspex */ /* XXX or could be Ultrix+MASSBUS "hp" disk? */ fhtype = FHT_AUSPEX; } else { /* * bytes[2,3] != (0,0); rules out Auspex, could be * DECOSF, SUNOS4, or IRIX4 */ if ((fhp[4] != 0) && (fhp[5] == 0) && (fhp[8] == 12) && (fhp[9] == 0)) { /* seems to be DECOSF, with minor == 0 */ fhtype = FHT_DECOSF; } else { /* could be SUNOS4 or IRIX4 */ /* XXX the test of fhp[5] == 8 could be wrong */ if ((fhp[4] == 0) && (fhp[5] == 8) && (fhp[6] == 0) && (fhp[7] == 0)) { /* looks like a length, not a file system typecode */ fhtype = FHT_IRIX4; } else { /* by elimination */ fhtype = FHT_SUNOS4; } } } } else { /* * bytes[0,1] != (0,0); rules out Auspex, IRIX4, SUNOS4 * could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5 * could be AIX, HP-UX */ if ((fhp[2] == 0) && (fhp[3] == 0)) { /* * bytes[2,3] == (0,0); rules out OSF, probably not UCX * (unless the exported device name is just one letter!), * could be Ultrix, IRIX5, AIX, or SUNOS5 * might be HP-UX (depends on their values for minor devs) */ /*XXX we probably only need to test of these two bytes */ if ((fhp[21] == 0) && (fhp[23] == 0)) { fhtype = FHT_ULTRIX; } else { /* Could be SUNOS5/IRIX5, maybe AIX */ /* XXX no obvious difference between SUNOS5 and IRIX5 */ if (fhp[9] == 10) fhtype = FHT_SUNOS5; /* XXX what about AIX? */ } } else { /* * bytes[2,3] != (0,0); rules out Ultrix, could be * DECOSF, SUNOS5, IRIX5, AIX, HP-UX, or UCX */ if ((fhp[8] == 12) && (fhp[9] == 0)) { fhtype = FHT_DECOSF; } else if ((fhp[8] == 0) && (fhp[9] == 10)) { /* could be SUNOS5/IRIX5, AIX, HP-UX */ if ((fhp[7] == 0) && (fhp[6] == 0) && (fhp[5] == 0) && (fhp[4] == 0)) { /* XXX is this always true of HP-UX? */ fhtype = FHT_HPUX9; } else if (fhp[7] == 2) { /* This would be MNT_NFS on AIX, which is impossible */ fhtype = FHT_SUNOS5; /* or maybe IRIX5 */ } else { /* * XXX Could be SUNOS5/IRIX5 or AIX. I don't * XXX see any way to disambiguate these, so * XXX I'm going with the more likely guess. * XXX Sorry, Big Blue. */ fhtype = FHT_SUNOS5; /* or maybe IRIX5 */ } } else { if (is_UCX(fhp)) { fhtype = FHT_VMSUCX; } else { fhtype = FHT_UNKNOWN; } } } } /* XXX still needs to handle SUNOS3 */ switch (fhtype) { case FHT_AUSPEX: fsidp->Fsid_dev.Minor = fhp[7]; fsidp->Fsid_dev.Major = fhp[6]; fsidp->fsid_code = 0; temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); *inop = temp; if (osnamep) *osnamep = "Auspex"; break; case FHT_DECOSF: fsidp->fsid_code = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]); /* XXX could ignore 3 high-order bytes */ temp = make_uint32(fhp[3], fhp[2], fhp[1], fhp[0]); fsidp->Fsid_dev.Minor = temp & 0xFFFFF; fsidp->Fsid_dev.Major = (temp>>20) & 0xFFF; temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]); *inop = temp; if (osnamep) *osnamep = "OSF"; break; case FHT_IRIX4: fsidp->Fsid_dev.Minor = fhp[3]; fsidp->Fsid_dev.Major = fhp[2]; fsidp->fsid_code = 0; temp = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]); *inop = temp; if (osnamep) *osnamep = "IRIX4"; break; case FHT_IRIX5: fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]); fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]); fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); *inop = temp; if (osnamep) *osnamep = "IRIX5"; break; case FHT_SUNOS3: if (osnamep) *osnamep = "SUNOS3"; break; case FHT_SUNOS4: fsidp->Fsid_dev.Minor = fhp[3]; fsidp->Fsid_dev.Major = fhp[2]; fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); *inop = temp; if (osnamep) *osnamep = "SUNOS4"; break; case FHT_SUNOS5: temp = make_uint16(fhp[0], fhp[1]); fsidp->Fsid_dev.Major = (temp>>2) & 0x3FFF; temp = make_uint24(fhp[1], fhp[2], fhp[3]); fsidp->Fsid_dev.Minor = temp & 0x3FFFF; fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); *inop = temp; if (osnamep) *osnamep = "SUNOS5"; break; case FHT_ULTRIX: fsidp->fsid_code = 0; fsidp->Fsid_dev.Minor = fhp[0]; fsidp->Fsid_dev.Major = fhp[1]; temp = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]); *inop = temp; if (osnamep) *osnamep = "Ultrix"; break; case FHT_VMSUCX: /* No numeric file system ID, so hash on the device-name */ if (sizeof(*fsidp) >= 14) { if (sizeof(*fsidp) > 14) memset((char *)fsidp, 0, sizeof(*fsidp)); /* just use the whole thing */ memcpy((char *)fsidp, (char *)fh, 14); } else { u_int32_t tempa[4]; /* at least 16 bytes, maybe more */ memset((char *)tempa, 0, sizeof(tempa)); memcpy((char *)tempa, (char *)fh, 14); /* ensure alignment */ fsidp->Fsid_dev.Minor = tempa[0] + (tempa[1]<<1); fsidp->Fsid_dev.Major = tempa[2] + (tempa[3]<<1); fsidp->fsid_code = 0; } /* VMS file ID is: (RVN, FidHi, FidLo) */ *inop = make_uint32(fhp[26], fhp[27], fhp[23], fhp[22]); /* Caller must save (and null-terminate?) this value */ if (fsnamep) *fsnamep = (char *)&(fhp[1]); if (osnamep) *osnamep = "VMS"; break; case FHT_AIX32: fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]); fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]); fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); *inop = temp; if (osnamep) *osnamep = "AIX32"; break; case FHT_HPUX9: fsidp->Fsid_dev.Major = fhp[0]; temp = make_uint24(fhp[1], fhp[2], fhp[3]); fsidp->Fsid_dev.Minor = temp; fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); *inop = temp; if (osnamep) *osnamep = "HPUX9"; break; case FHT_UNKNOWN: #ifdef DEBUG /* XXX debugging */ for (i = 0; i < 32; i++) (void)fprintf(stderr, "%x.", fhp[i]); (void)fprintf(stderr, "\n"); #endif /* Save the actual handle, so it can be display with -u */ for (i = 0; i < 32; i++) (void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X", fhp[i]); /* XXX for now, give "bogus" values to aid debugging */ fsidp->fsid_code = 0; fsidp->Fsid_dev.Minor = 257; fsidp->Fsid_dev.Major = 257; *inop = 1; /* display will show this string instead of (257,257) */ if (fsnamep) *fsnamep = "Unknown"; if (osnamep) *osnamep = "Unknown"; break; } } /* * Is this a VMS UCX file handle? * Check for: * (1) leading code byte [XXX not yet] * (2) followed by string of printing chars & spaces * (3) followed by string of nulls */ static int is_UCX(fhp) unsigned char *fhp; { register int i; int seen_null = 0; for (i = 1; i < 14; i++) { if (isprint(fhp[i])) { if (seen_null) return(0); else continue; } else if (fhp[i] == 0) { seen_null = 1; continue; } else return(0); } return(1); } tcpdump-3.7.2/PLATFORMS0100644000076500000240000000025107422774220013636 0ustar fennerstaff== Tested platforms == NetBSD 1.5/i386 (mcr - 2002/1/1) Debian Linux (woody/i386) (mcr - 2002/1/1) --- RedHat Linux 6.1/i386 (assar) FreeBSD 2.2.8/i386 (itojun) tcpdump-3.7.2/ppp.h0100644000076500000240000000540307237135723013323 0ustar fennerstaff/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.12 2001/02/04 02:17:55 fenner Exp $ (LBL) */ /* * Point to Point Protocol (PPP) RFC1331 * * Copyright 1989 by Carnegie Mellon. * * Permission to use, copy, modify, and distribute this program for any * purpose and without fee is hereby granted, provided that this copyright * and permission notice appear on all copies and supporting documentation, * the name of Carnegie Mellon not be used in advertising or publicity * pertaining to distribution of the program without specific prior * permission, and notice be given in supporting documentation that copying * and distribution is by permission of Carnegie Mellon and Stanford * University. Carnegie Mellon makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ #define PPP_HDRLEN 4 /* length of PPP header */ #define PPP_ADDRESS 0xff /* The address byte value */ #define PPP_CONTROL 0x03 /* The control byte value */ /* Protocol numbers */ #define PPP_IP 0x0021 /* Raw IP */ #define PPP_OSI 0x0023 /* OSI Network Layer */ #define PPP_NS 0x0025 /* Xerox NS IDP */ #define PPP_DECNET 0x0027 /* DECnet Phase IV */ #define PPP_APPLE 0x0029 /* Appletalk */ #define PPP_IPX 0x002b /* Novell IPX */ #define PPP_VJC 0x002d /* Van Jacobson Compressed TCP/IP */ #define PPP_VJNC 0x002f /* Van Jacobson Uncompressed TCP/IP */ #define PPP_BRPDU 0x0031 /* Bridging PDU */ #define PPP_STII 0x0033 /* Stream Protocol (ST-II) */ #define PPP_VINES 0x0035 /* Banyan Vines */ #define PPP_IPV6 0x0057 /* IPv6 */ #define PPP_COMP 0x00fd /* Compressed Datagram */ #define PPP_HELLO 0x0201 /* 802.1d Hello Packets */ #define PPP_LUXCOM 0x0231 /* Luxcom */ #define PPP_SNS 0x0233 /* Sigma Network Systems */ #define PPP_IPCP 0x8021 /* IP Control Protocol */ #define PPP_OSICP 0x8023 /* OSI Network Layer Control Protocol */ #define PPP_NSCP 0x8025 /* Xerox NS IDP Control Protocol */ #define PPP_DECNETCP 0x8027 /* DECnet Control Protocol */ #define PPP_APPLECP 0x8029 /* Appletalk Control Protocol */ #define PPP_IPXCP 0x802b /* Novell IPX Control Protocol */ #define PPP_STIICP 0x8033 /* Strean Protocol Control Protocol */ #define PPP_VINESCP 0x8035 /* Banyan Vines Control Protocol */ #define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ #define PPP_CCP 0x80fd /* Compress Control Protocol */ #define PPP_LCP 0xc021 /* Link Control Protocol */ #define PPP_PAP 0xc023 /* Password Authentication Protocol */ #define PPP_LQM 0xc025 /* Link Quality Monitoring */ #define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */ #define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */ #define PPP_BAP 0xc02d /* BAP */ #define PPP_MP 0xc03d /* Multi-Link */ extern struct tok ppptype2str[]; tcpdump-3.7.2/print-802_11.c0100644000076500000240000005243507627054624014475 0ustar fennerstaff/* * Copyright (c) 2001 * Fortress Technologies, Inc. All rights reserved. * Charlie Lenahan (clenahan@fortresstech.com) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.6.4.1 2002/05/13 08:34:50 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "extract.h" #include "ieee802_11.h" #define PRINT_RATES(p) \ do { \ int z; \ char *sep = " ["; \ for (z = 0; z < p.rates.length ; z++) { \ printf("%s%2.1f", sep, (.5 * (p.rates.rate[z] & 0x7f))); \ sep = " "; \ } \ if (p.rates.length != 0) \ printf(" Mbit]"); \ } while (0) static const char *auth_alg_text[]={"Open System","Shared Key","EAP"}; static const char *subtype_text[]={ "Assoc Request", "Assoc Response", "ReAssoc Request", "ReAssoc Response", "Probe Request", "Probe Response", "RESERVED", "RESERVED", "Beacon", "ATIM", "Disassociation", "Authentication", "DeAuthentication", "RESERVED", "RESERVED" }; static const char *status_text[] = { "Succesful", /* 0 */ "Unspecified failure", /* 1 */ "Reserved", /* 2 */ "Reserved", /* 3 */ "Reserved", /* 4 */ "Reserved", /* 5 */ "Reserved", /* 6 */ "Reserved", /* 7 */ "Reserved", /* 8 */ "Reserved", /* 9 */ "Cannot Support all requested capabilities in the Capability Information field", /* 10 */ "Reassociation denied due to inability to confirm that association exists", /* 11 */ "Association denied due to reason outside the scope of the standard", /* 12 */ "Responding station does not support the specified authentication algorithm ", /* 13 */ "Received an Authentication frame with authentication transaction " \ "sequence number out of expected sequence", /* 14 */ "Authentication rejected because of challenge failure", /* 15 */ "Authentication rejected due to timeout waiting for next frame in sequence", /* 16 */ "Association denied because AP is unable to handle additional associated stations", /* 17 */ "Association denied due to requesting station not supporting all of the " \ "data rates in BSSBasicRateSet parameter", /* 18 */ NULL }; static const char *reason_text[] = { "Reserved", /* 0 */ "Unspecified reason", /* 1 */ "Previous authentication no longer valid", /* 2 */ "Deauthenticated because sending station is leaving (or has left) IBSS or ESS", /* 3 */ "Disassociated due to inactivity", /* 4 */ "Disassociated because AP is unable to handle all currently associated stations", /* 5 */ "Class 2 frame receivedfrom nonauthenticated station", /* 6 */ "Class 3 frame received from nonassociated station", /* 7 */ "Disassociated because sending station is leaving (or has left) BSS", /* 8 */ "Station requesting (re)association is not authenticated with responding station", /* 9 */ NULL }; static int wep_print(const u_char *p,u_int length) { u_int32_t iv; if (!TTEST2(*p, 4)) return 0; iv = EXTRACT_LE_32BITS(p); printf("Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv), IV_KEYID(iv)); return 1; } static int parse_elements(struct mgmt_body_t *pbody,const u_char *p,int offset) { for (;;) { if (!TTEST2(*(p + offset), 1)) return 1; switch (*(p + offset)) { case E_SSID: if (!TTEST2(*(p+offset), 2)) return 0; memcpy(&(pbody->ssid),p+offset,2); offset += 2; if (pbody->ssid.length > 0) { if (!TTEST2(*(p+offset), pbody->ssid.length)) return 0; memcpy(&(pbody->ssid.ssid),p+offset,pbody->ssid.length); offset += pbody->ssid.length; pbody->ssid.ssid[pbody->ssid.length]='\0'; } break; case E_CHALLENGE: if (!TTEST2(*(p+offset), 2)) return 0; memcpy(&(pbody->challenge),p+offset,2); offset += 2; if (pbody->challenge.length > 0) { if (!TTEST2(*(p+offset), pbody->challenge.length)) return 0; memcpy(&(pbody->challenge.text),p+offset,pbody->challenge.length); offset += pbody->challenge.length; pbody->challenge.text[pbody->challenge.length]='\0'; } break; case E_RATES: if (!TTEST2(*(p+offset), 2)) return 0; memcpy(&(pbody->rates),p+offset,2); offset += 2; if (pbody->rates.length > 0) { if (!TTEST2(*(p+offset), pbody->rates.length)) return 0; memcpy(&(pbody->rates.rate),p+offset,pbody->rates.length); offset += pbody->rates.length; } break; case E_DS: if (!TTEST2(*(p+offset), 3)) return 0; memcpy(&(pbody->ds),p+offset,3); offset +=3; break; case E_CF: if (!TTEST2(*(p+offset), 8)) return 0; memcpy(&(pbody->cf),p+offset,8); offset +=8; break; case E_TIM: if (!TTEST2(*(p+offset), 2)) return 0; memcpy(&(pbody->tim),p+offset,2); offset +=2; if (!TTEST2(*(p+offset), 3)) return 0; memcpy(&(pbody->tim.count),p+offset,3); offset +=3; if ((pbody->tim.length -3) > 0) { if (!TTEST2(*(p+offset), pbody->tim.length -3)) return 0; memcpy((pbody->tim.bitmap),p+(pbody->tim.length -3),(pbody->tim.length -3)); offset += pbody->tim.length -3; } break; default: #if 0 printf("(1) unhandled element_id (%d) ", *(p+offset) ); #endif offset+= *(p+offset+1) + 2; break; } } return 1; } /********************************************************************************* * Print Handle functions for the management frame types *********************************************************************************/ static int handle_beacon(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, 12)) return 0; memcpy(&pbody.timestamp, p, 8); offset += 8; pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); offset += 2; pbody.capability_info = EXTRACT_LE_16BITS(p+offset); offset += 2; if (!parse_elements(&pbody,p,offset)) return 0; printf("%s (", subtype_text[FC_SUBTYPE(fc)]); fn_print(pbody.ssid.ssid, NULL); printf(")"); PRINT_RATES(pbody); printf(" %s CH: %u %s", CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS", pbody.ds.channel, CAPABILITY_PRIVACY(pbody.capability_info) ? ", PRIVACY" : "" ); return 1; } static int handle_assoc_request(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, 4)) return 0; pbody.capability_info = EXTRACT_LE_16BITS(p); offset += 2; pbody.listen_interval = EXTRACT_LE_16BITS(p+offset); offset += 2; if (!parse_elements(&pbody,p,offset)) return 0; printf("%s (", subtype_text[FC_SUBTYPE(fc)]); fn_print(pbody.ssid.ssid, NULL); printf(")"); PRINT_RATES(pbody); return 1; } static int handle_assoc_response(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, 6)) return 0; pbody.capability_info = EXTRACT_LE_16BITS(p); offset += 2; pbody.status_code = EXTRACT_LE_16BITS(p+offset); offset += 2; pbody.aid = EXTRACT_LE_16BITS(p+offset); offset += 2; if (!parse_elements(&pbody,p,offset)) return 0; printf("%s AID(%x) :%s: %s", subtype_text[FC_SUBTYPE(fc)], ((u_int16_t)(pbody.aid << 2 )) >> 2 , CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "", (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a")); return 1; } static int handle_reassoc_request(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, 10)) return 0; pbody.capability_info = EXTRACT_LE_16BITS(p); offset += 2; pbody.listen_interval = EXTRACT_LE_16BITS(p+offset); offset += 2; memcpy(&pbody.ap,p+offset,6); offset += 6; if (!parse_elements(&pbody,p,offset)) return 0; printf("%s (", subtype_text[FC_SUBTYPE(fc)]); fn_print(pbody.ssid.ssid, NULL); printf(") AP : %s", etheraddr_string( pbody.ap )); return 1; } static int handle_reassoc_response(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { /* Same as a Association Reponse */ return handle_assoc_response(fc,pmh,p); } static int handle_probe_request(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); if (!parse_elements(&pbody, p, offset)) return 0; printf("%s (", subtype_text[FC_SUBTYPE(fc)]); fn_print(pbody.ssid.ssid, NULL); printf(")"); PRINT_RATES(pbody); return 1; } static int handle_probe_response(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, 12)) return 0; memcpy(&pbody.timestamp,p,8); offset += 8; pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); offset += 2; pbody.capability_info = EXTRACT_LE_16BITS(p+offset); offset += 2; if (!parse_elements(&pbody, p, offset)) return 0; printf("%s (", subtype_text[FC_SUBTYPE(fc)]); fn_print(pbody.ssid.ssid, NULL); printf(") "); PRINT_RATES(pbody); printf(" CH: %u%s", pbody.ds.channel, CAPABILITY_PRIVACY(pbody.capability_info) ? ", PRIVACY" : "" ); return 1; } static int handle_atim(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { /* the frame body for ATIM is null. */ printf("ATIM"); return 1; } static int handle_disassoc(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, 2)) return 0; pbody.reason_code = EXTRACT_LE_16BITS(p); offset += 2; printf("%s: %s", subtype_text[FC_SUBTYPE(fc)], pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" ); return 1; } static int handle_auth(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, 6)) return 0; pbody.auth_alg = EXTRACT_LE_16BITS(p); offset += 2; pbody.auth_trans_seq_num = EXTRACT_LE_16BITS(p + offset); offset += 2; pbody.status_code = EXTRACT_LE_16BITS(p + offset); offset += 2; if (!parse_elements(&pbody,p,offset)) return 0; if ((pbody.auth_alg == 1) && ((pbody.auth_trans_seq_num == 2) || (pbody.auth_trans_seq_num == 3))) { printf("%s (%s)-%x [Challenge Text] %s", subtype_text[FC_SUBTYPE(fc)], pbody.auth_alg < 4 ? auth_alg_text[pbody.auth_alg] : "Reserved" , pbody.auth_trans_seq_num, ((pbody.auth_trans_seq_num % 2) ? (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a") : "" )); } else { printf("%s (%s)-%x: %s", subtype_text[FC_SUBTYPE(fc)], pbody.auth_alg < 4 ? auth_alg_text[pbody.auth_alg] : "Reserved" , pbody.auth_trans_seq_num, ((pbody.auth_trans_seq_num % 2) ? (pbody.status_code < 19 ? status_text[pbody.status_code] : "n/a") : "")); } return 1; } static int handle_deauth(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p) { struct mgmt_body_t pbody; int offset = 0; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, 2)) return 0; pbody.reason_code = EXTRACT_LE_16BITS(p); offset += 2; if (eflag) { printf("%s: %s", subtype_text[FC_SUBTYPE(fc)], pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" ); } else { printf("%s (%s): %s", subtype_text[FC_SUBTYPE(fc)], etheraddr_string(pmh->sa), pbody.reason_code < 10 ? reason_text[pbody.reason_code] : "Reserved" ); } return 1; } /********************************************************************************* * Print Body funcs *********************************************************************************/ static int mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p, u_int length) { switch (FC_SUBTYPE(fc)) { case ST_ASSOC_REQUEST: return (handle_assoc_request(fc, pmh, p)); case ST_ASSOC_RESPONSE: return (handle_assoc_response(fc, pmh, p)); case ST_REASSOC_REQUEST: return (handle_reassoc_request(fc, pmh, p)); case ST_REASSOC_RESPONSE: return (handle_reassoc_response(fc, pmh, p)); case ST_PROBE_REQUEST: return (handle_probe_request(fc, pmh, p)); case ST_PROBE_RESPONSE: return (handle_probe_response(fc, pmh, p)); case ST_BEACON: return (handle_beacon(fc, pmh, p)); case ST_ATIM: return (handle_atim(fc, pmh, p)); case ST_DISASSOC: return (handle_disassoc(fc, pmh, p)); case ST_AUTH: if (!TTEST2(*p, 3)) return 0; if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) { printf("Authentication (Shared-Key)-3 "); return (wep_print(p, length)); } else return (handle_auth(fc, pmh, p)); case ST_DEAUTH: return (handle_deauth(fc, pmh, p)); break; default: printf("Unhandled Managment subtype(%x)", FC_SUBTYPE(fc)); return 1; } } /********************************************************************************* * Handles printing all the control frame types *********************************************************************************/ static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length) { switch (FC_SUBTYPE(fc)) { case CTRL_PS_POLL: if (!TTEST2(*p, CTRL_PS_POLL_LEN)) return 0; printf("Power Save-Poll AID(%x)", EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))); break; case CTRL_RTS: if (!TTEST2(*p, CTRL_RTS_LEN)) return 0; if (eflag) printf("Request-To-Send"); else printf("Request-To-Send TA:%s ", etheraddr_string(((const struct ctrl_rts_t *)p)->ta)); break; case CTRL_CTS: if (!TTEST2(*p, CTRL_CTS_LEN)) return 0; if (eflag) printf("Clear-To-Send"); else printf("Clear-To-Send RA:%s ", etheraddr_string(((const struct ctrl_cts_t *)p)->ra)); break; case CTRL_ACK: if (!TTEST2(*p, CTRL_ACK_LEN)) return 0; if (eflag) printf("Acknowledgment"); else printf("Acknowledgment RA:%s ", etheraddr_string(((const struct ctrl_ack_t *)p)->ra)); break; case CTRL_CF_END: if (!TTEST2(*p, CTRL_END_LEN)) return 0; if (eflag) printf("CF-End"); else printf("CF-End RA:%s ", etheraddr_string(((const struct ctrl_end_t *)p)->ra)); break; case CTRL_END_ACK: if (!TTEST2(*p, CTRL_END_ACK_LEN)) return 0; if (eflag) printf("CF-End+CF-Ack"); else printf("CF-End+CF-Ack RA:%s ", etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra)); break; default: printf("(B) Unknown Ctrl Subtype"); } return 1; } /* * Print Header funcs */ /* * Data Frame - Address field contents * * To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4 * 0 | 0 | DA | SA | BSSID | n/a * 0 | 1 | DA | BSSID | SA | n/a * 1 | 0 | BSSID | SA | DA | n/a * 1 | 1 | RA | TA | DA | SA */ static void data_header_print(u_int16_t fc,const u_char *p, u_int length) { #define ADDR1 (p + 4) #define ADDR2 (p + 10) #define ADDR3 (p + 16) #define ADDR4 (p + 24) if (!FC_TO_DS(fc)) { if (!FC_FROM_DS(fc)) printf("DA:%s SA:%s BSSID:%s ", etheraddr_string(ADDR1), etheraddr_string(ADDR2), etheraddr_string(ADDR3)); else printf("DA:%s BSSID:%s SA:%s ", etheraddr_string(ADDR1), etheraddr_string(ADDR2), etheraddr_string(ADDR3)); } else { if (!FC_FROM_DS(fc)) printf("BSSID:%s SA:%s DA:%s ", etheraddr_string(ADDR1), etheraddr_string(ADDR2), etheraddr_string(ADDR3)); else printf("RA:%s TA:%s DA:%s SA:%s ", etheraddr_string(ADDR1), etheraddr_string(ADDR2), etheraddr_string(ADDR3), etheraddr_string(ADDR4)); } #undef ADDR1 #undef ADDR2 #undef ADDR3 #undef ADDR4 } static void mgmt_header_print(const u_char *p, u_int length) { const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p; printf("BSSID:%s DA:%s SA:%s ", etheraddr_string((hp)->bssid), etheraddr_string((hp)->da), etheraddr_string((hp)->sa)); } static void ctrl_header_print(u_int16_t fc,const u_char *p, u_int length) { switch (FC_SUBTYPE(fc)) { case CTRL_PS_POLL: printf("BSSID:%s TA:%s ", etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid), etheraddr_string(((const struct ctrl_ps_poll_t *)p)->ta)); break; case CTRL_RTS: printf("RA:%s TA:%s ", etheraddr_string(((const struct ctrl_rts_t *)p)->ra), etheraddr_string(((const struct ctrl_rts_t *)p)->ta)); break; case CTRL_CTS: printf("RA:%s ", etheraddr_string(((const struct ctrl_cts_t *)p)->ra)); break; case CTRL_ACK: printf("RA:%s ", etheraddr_string(((const struct ctrl_ack_t *)p)->ra)); break; case CTRL_CF_END: printf("RA:%s BSSID:%s ", etheraddr_string(((const struct ctrl_end_t *)p)->ra), etheraddr_string(((const struct ctrl_end_t *)p)->bssid)); break; case CTRL_END_ACK: printf("RA:%s BSSID:%s ", etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra), etheraddr_string(((const struct ctrl_end_ack_t *)p)->bssid)); break; default: printf("(H) Unknown Ctrl Subtype"); } } static int GetHeaderLength(u_int16_t fc) { int iLength=0; switch (FC_TYPE(fc)) { case T_MGMT: iLength = MGMT_HEADER_LEN; break; case T_CTRL: switch (FC_SUBTYPE(fc)) { case CTRL_PS_POLL: iLength = CTRL_PS_POLL_LEN; break; case CTRL_RTS: iLength = CTRL_RTS_LEN; break; case CTRL_CTS: iLength = CTRL_CTS_LEN; break; case CTRL_ACK: iLength = CTRL_ACK_LEN; break; case CTRL_CF_END: iLength = CTRL_END_LEN; break; case CTRL_END_ACK: iLength = CTRL_END_ACK_LEN; break; default: iLength = 0; break; } break; case T_DATA: if (FC_TO_DS(fc) && FC_FROM_DS(fc)) iLength = 30; else iLength = 24; break; default: printf("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); break; } return iLength; } /* * Print the 802.11 MAC header */ static inline void ieee_802_11_print(u_int16_t fc, const u_char *p, u_int length) { switch (FC_TYPE(fc)) { case T_MGMT: mgmt_header_print(p, length); break; case T_CTRL: ctrl_header_print(fc, p, length); break; case T_DATA: data_header_print(fc, p, length); break; default: printf("(header) unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); break; } } /* * This is the top level routine of the printer. 'p' is the points * to the ether header of the packet, 'h->tv' is the timestamp, * 'h->length' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ void ieee802_11_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; u_int16_t fc; u_int HEADER_LENGTH; u_short extracted_ethertype; ++infodelay; ts_print(&h->ts); if (caplen < IEEE802_11_FC_LEN) { printf("[|802.11]"); goto out; } fc=EXTRACT_LE_16BITS(p); if (eflag) ieee_802_11_print(fc, p, length); /* * Some printers want to get back at the ethernet addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; HEADER_LENGTH=GetHeaderLength(fc); length -= HEADER_LENGTH; caplen -= HEADER_LENGTH; p += HEADER_LENGTH; switch (FC_TYPE(fc)) { case T_MGMT: if (!mgmt_body_print(fc, (const struct mgmt_header_t *)packetp, p, length)) { printf("[|802.11]"); goto out; } break; case T_CTRL: if (!ctrl_body_print(fc, p - HEADER_LENGTH, length + HEADER_LENGTH)) { printf("[|802.11]"); goto out; } break; case T_DATA: /* There may be a problem w/ AP not having this bit set */ if (FC_WEP(fc)) { if (!wep_print(p,length)) { printf("[|802.11]"); goto out; } } else { if (llc_print(p, length, caplen, packetp + 10, packetp + 4, &extracted_ethertype) == 0) { /* * Some kinds of LLC packet we cannot * handle intelligently */ if (!eflag) ieee_802_11_print(fc, p - HEADER_LENGTH, length + HEADER_LENGTH); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } if (!xflag && !qflag) default_print(p, caplen); } } break; default: printf("(body) unhandled IEEE802.11 frame type (%d)", FC_TYPE(fc)); break; } if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } tcpdump-3.7.2/print-ah.c0100644000076500000240000000443107351470742014241 0ustar fennerstaff/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.15 2001/09/17 21:57:54 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "ah.h" #include "interface.h" #include "addrtoname.h" int ah_print(register const u_char *bp, register const u_char *bp2) { register const struct ah *ah; register const u_char *ep; int sumlen; u_int32_t spi; ah = (const struct ah *)bp; ep = snapend; /* 'ep' points to the end of available data. */ TCHECK(*ah); sumlen = ah->ah_len << 2; spi = (u_int32_t)ntohl(ah->ah_spi); printf("AH(spi=0x%08x", spi); if (vflag) printf(",sumlen=%d", sumlen); printf(",seq=0x%x", (u_int32_t)ntohl(*(const u_int32_t *)(ah + 1))); if (bp + sizeof(struct ah) + sumlen > ep) fputs("[truncated]", stdout); fputs("): ", stdout); return sizeof(struct ah) + sumlen; trunc: fputs("[|AH]", stdout); return 65535; } tcpdump-3.7.2/print-arcnet.c0100644000076500000240000001313107627054624015125 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.6.4.1 2002/06/01 23:51:11 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "arcnet.h" int arcnet_encap_print(u_char arctype, const u_char *p, u_int length, u_int caplen); struct tok arctypemap[] = { { ARCTYPE_IP_OLD, "oldip" }, { ARCTYPE_ARP_OLD, "oldarp" }, { ARCTYPE_IP, "ip" }, { ARCTYPE_ARP, "arp" }, { ARCTYPE_REVARP, "rarp" }, { ARCTYPE_ATALK, "atalk" }, { ARCTYPE_BANIAN, "banyan" }, { ARCTYPE_IPX, "ipx" }, { ARCTYPE_INET6, "ipv6" }, { ARCTYPE_DIAGNOSE, "diag" }, { 0, 0 } }; static inline void arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid) { const struct arc_header *ap; const char *arctypename; ap = (const struct arc_header *)bp; if (qflag) { (void)printf("%02x %02x %d: ", ap->arc_shost, ap->arc_dhost, length); return; } arctypename = tok2str(arctypemap, "%02x", ap->arc_type); if (!phds) { (void)printf("%02x %02x %s %d: ", ap->arc_shost, ap->arc_dhost, arctypename, length); return; } if (flag == 0) { (void)printf("%02x %02x %s seqid %04x %d: ", ap->arc_shost, ap->arc_dhost, arctypename, seqid, length); return; } if (flag & 1) (void)printf("%02x %02x %s seqid %04x " "(first of %d fragments) %d: ", ap->arc_shost, ap->arc_dhost, arctypename, seqid, (flag + 3) / 2, length); else (void)printf("%02x %02x %s seqid %04x " "(fragment %d) %d: ", ap->arc_shost, ap->arc_dhost, arctypename, seqid, flag/2 + 1, length); } /* * This is the top level routine of the printer. 'p' is the points * to the ether header of the packet, 'tvp' is the timestamp, * 'length' is the length of the packet off the wire, and 'caplen' * is the number of bytes actually captured. */ void arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; const struct arc_header *ap; int phds, flag = 0, archdrlen = 0; u_int seqid = 0; u_char arc_type; ++infodelay; ts_print(&h->ts); if (caplen < ARC_HDRLEN) { printf("[|arcnet]"); goto out; } ap = (const struct arc_header *)p; arc_type = ap->arc_type; switch (arc_type) { default: phds = 1; break; case ARCTYPE_IP_OLD: case ARCTYPE_ARP_OLD: case ARCTYPE_DIAGNOSE: phds = 0; archdrlen = ARC_HDRLEN; break; } if (phds) { if (caplen < ARC_HDRNEWLEN) { arcnet_print(p, length, 0, 0, 0); printf("[|phds]"); goto out; } if (ap->arc_flag == 0xff) { if (caplen < ARC_HDRNEWLEN_EXC) { arcnet_print(p, length, 0, 0, 0); printf("[|phds extended]"); goto out; } flag = ap->arc_flag2; seqid = ap->arc_seqid2; archdrlen = ARC_HDRNEWLEN_EXC; } else { flag = ap->arc_flag; seqid = ap->arc_seqid; archdrlen = ARC_HDRNEWLEN; } } if (eflag) arcnet_print(p, length, phds, flag, seqid); /* * Some printers want to get back at the ethernet addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; length -= archdrlen; caplen -= archdrlen; p += archdrlen; if (phds && flag && (flag & 1) == 0) goto out2; if (!arcnet_encap_print(arc_type, p, length, caplen)) { default_print(p, caplen); goto out; } out2: if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } /* * Prints the packet encapsulated in an ARCnet data field, * given the ARCnet system code. * * Returns non-zero if it can do so, zero if the system code is unknown. */ int arcnet_encap_print(u_char arctype, const u_char *p, u_int length, u_int caplen) { switch (arctype) { case ARCTYPE_IP_OLD: case ARCTYPE_IP: ip_print(p, length); return (1); #ifdef INET6 case ARCTYPE_INET6: ip6_print(p, length); return (1); #endif /*INET6*/ case ARCTYPE_ARP_OLD: case ARCTYPE_ARP: case ARCTYPE_REVARP: arp_print(p, length, caplen); return (1); case ARCTYPE_ATALK: /* XXX was this ever used? */ if (vflag) fputs("et1 ", stdout); atalk_print(p, length); return (1); default: return (0); } } tcpdump-3.7.2/print-arp.c0100644000076500000240000001266207627054624014443 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.51.4.2 2002/07/10 07:09:53 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ether.h" #include "ethertype.h" #include "extract.h" /* must come after interface.h */ /* * Address Resolution Protocol. * * See RFC 826 for protocol description. ARP packets are variable * in size; the arphdr structure defines the fixed-length portion. * Protocol type values are the same as those for 10 Mb/s Ethernet. * It is followed by the variable-sized fields ar_sha, arp_spa, * arp_tha and arp_tpa in that order, according to the lengths * specified. Field names used correspond to RFC 826. */ struct arp_pkthdr { u_short ar_hrd; /* format of hardware address */ #define ARPHRD_ETHER 1 /* ethernet hardware format */ #define ARPHRD_IEEE802 6 /* token-ring hardware format */ #define ARPHRD_ARCNET 7 /* arcnet hardware format */ #define ARPHRD_FRELAY 15 /* frame relay hardware format */ #define ARPHRD_STRIP 23 /* Ricochet Starmode Radio hardware format */ #define ARPHRD_IEEE1394 24 /* IEEE 1394 (FireWire) hardware format */ u_short ar_pro; /* format of protocol address */ u_char ar_hln; /* length of hardware address */ u_char ar_pln; /* length of protocol address */ u_short ar_op; /* one of: */ #define ARPOP_REQUEST 1 /* request to resolve address */ #define ARPOP_REPLY 2 /* response to previous request */ #define ARPOP_REVREQUEST 3 /* request protocol address given hardware */ #define ARPOP_REVREPLY 4 /* response giving protocol address */ #define ARPOP_INVREQUEST 8 /* request to identify peer */ #define ARPOP_INVREPLY 9 /* response identifying peer */ /* * The remaining fields are variable in size, * according to the sizes above. */ #ifdef COMMENT_ONLY u_char ar_sha[]; /* sender hardware address */ u_char ar_spa[]; /* sender protocol address */ u_char ar_tha[]; /* target hardware address */ u_char ar_tpa[]; /* target protocol address */ #endif #define ar_sha(ap) (((const u_char *)((ap)+1))+0) #define ar_spa(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln) #define ar_tha(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln+(ap)->ar_pln) #define ar_tpa(ap) (((const u_char *)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln) }; #define ARP_HDRLEN 8 #define HRD(ap) ((ap)->ar_hrd) #define HLN(ap) ((ap)->ar_hln) #define PLN(ap) ((ap)->ar_pln) #define OP(ap) ((ap)->ar_op) #define PRO(ap) ((ap)->ar_pro) #define SHA(ap) (ar_sha(ap)) #define SPA(ap) (ar_spa(ap)) #define THA(ap) (ar_tha(ap)) #define TPA(ap) (ar_tpa(ap)) static u_char ezero[6]; void arp_print(const u_char *bp, u_int length, u_int caplen) { const struct arp_pkthdr *ap; u_short pro, hrd, op; ap = (const struct arp_pkthdr *)bp; TCHECK(*ap); if ((const u_char *)(ar_tpa(ap) + PLN(ap)) > snapend) { (void)printf("truncated-arp"); default_print((const u_char *)ap, length); return; } pro = EXTRACT_16BITS(&PRO(ap)); hrd = EXTRACT_16BITS(&HRD(ap)); op = EXTRACT_16BITS(&OP(ap)); if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) { (void)printf("arp-#%d for proto #%d (%d) hardware #%d (%d)", op, pro, PLN(ap), hrd, HLN(ap)); return; } if (pro == ETHERTYPE_TRAIL) (void)printf("trailer-"); switch (op) { case ARPOP_REQUEST: (void)printf("arp who-has %s", ipaddr_string(TPA(ap))); if (memcmp((const char *)ezero, (const char *)THA(ap), HLN(ap)) != 0) (void)printf(" (%s)", linkaddr_string(THA(ap), HLN(ap))); (void)printf(" tell %s", ipaddr_string(SPA(ap))); break; case ARPOP_REPLY: (void)printf("arp reply %s", ipaddr_string(SPA(ap))); (void)printf(" is-at %s", linkaddr_string(SHA(ap), HLN(ap))); break; case ARPOP_REVREQUEST: (void)printf("rarp who-is %s tell %s", linkaddr_string(THA(ap), HLN(ap)), linkaddr_string(SHA(ap), HLN(ap))); break; case ARPOP_REVREPLY: (void)printf("rarp reply %s at %s", linkaddr_string(THA(ap), HLN(ap)), ipaddr_string(TPA(ap))); break; default: (void)printf("arp-#%d", op); default_print((const u_char *)ap, caplen); return; } if (hrd != ARPHRD_ETHER) printf(" hardware #%d", hrd); return; trunc: (void)printf("[|arp]"); } tcpdump-3.7.2/print-ascii.c0100644000076500000240000001151307044614662014740 0ustar fennerstaff/* $NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Alan Barrett and Simon J. Gerraty. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.6 2000/01/29 16:47:46 itojun Exp $"; #endif #include #include #include #include "interface.h" #define HEXDUMP_BYTES_PER_LINE 16 #define HEXDUMP_SHORTS_PER_LINE (HEXDUMP_BYTES_PER_LINE / 2) #define HEXDUMP_HEXSTUFF_PER_SHORT 5 /* 4 hex digits and a space */ #define HEXDUMP_HEXSTUFF_PER_LINE \ (HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE) void ascii_print_with_offset(register const u_char *cp, register u_int length, register u_int oset) { register u_int i; register int s1, s2; register int nshorts; char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp; char asciistuff[HEXDUMP_BYTES_PER_LINE+1], *asp; nshorts = length / sizeof(u_short); i = 0; hsp = hexstuff; asp = asciistuff; while (--nshorts >= 0) { s1 = *cp++; s2 = *cp++; (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), " %02x%02x", s1, s2); hsp += HEXDUMP_HEXSTUFF_PER_SHORT; *(asp++) = (isgraph(s1) ? s1 : '.'); *(asp++) = (isgraph(s2) ? s2 : '.'); if (++i >= HEXDUMP_SHORTS_PER_LINE) { *hsp = *asp = '\0'; (void)printf("\n0x%04x\t%-*s\t%s", oset, HEXDUMP_HEXSTUFF_PER_LINE, hexstuff, asciistuff); i = 0; hsp = hexstuff; asp = asciistuff; oset += HEXDUMP_BYTES_PER_LINE; } } if (length & 1) { s1 = *cp++; (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), " %02x", s1); hsp += 3; *(asp++) = (isgraph(s1) ? s1 : '.'); ++i; } if (i > 0) { *hsp = *asp = '\0'; (void)printf("\n0x%04x\t%-*s\t%s", oset, HEXDUMP_HEXSTUFF_PER_LINE, hexstuff, asciistuff); } } void ascii_print(register const u_char *cp, register u_int length) { ascii_print_with_offset(cp, length, 0); } /* * telnet_print() wants this. It is essentially default_print_unaligned() */ void hex_print_with_offset(register const u_char *cp, register u_int length, register u_int oset) { register u_int i, s; register int nshorts; nshorts = (u_int) length / sizeof(u_short); i = 0; while (--nshorts >= 0) { if ((i++ % 8) == 0) { (void)printf("\n0x%04x\t", oset); oset += HEXDUMP_BYTES_PER_LINE; } s = *cp++; (void)printf(" %02x%02x", s, *cp++); } if (length & 1) { if ((i % 8) == 0) (void)printf("\n0x%04x\t", oset); (void)printf(" %02x", *cp); } } /* * just for completeness */ void hex_print(register const u_char *cp, register u_int length) { hex_print_with_offset(cp, length, 0); } #ifdef MAIN int main(int argc, char *argv[]) { hex_print("Hello, World!\n", 14); printf("\n"); ascii_print("Hello, World!\n", 14); printf("\n"); #define TMSG "Now is the winter of our discontent...\n" ascii_print_with_offset(TMSG, sizeof(TMSG) - 1, 0x100); printf("\n"); exit(0); } #endif /* MAIN */ tcpdump-3.7.2/print-atalk.c0100644000076500000240000003674607627054624014766 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Format and print AppleTalk packets. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.70.2.1 2002/02/05 10:04:18 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include /* for MAXHOSTNAMELEN on some platforms */ #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "extract.h" /* must come after interface.h */ #include "appletalk.h" static struct tok type2str[] = { { ddpRTMP, "rtmp" }, { ddpRTMPrequest, "rtmpReq" }, { ddpECHO, "echo" }, { ddpIP, "IP" }, { ddpARP, "ARP" }, { ddpKLAP, "KLAP" }, { 0, NULL } }; struct aarp { u_int16_t htype, ptype; u_int8_t halen, palen; u_int16_t op; u_int8_t hsaddr[6]; u_int8_t psaddr[4]; u_int8_t hdaddr[6]; u_int8_t pdaddr[4]; }; static char tstr[] = "[|atalk]"; static void atp_print(const struct atATP *, u_int); static void atp_bitmap_print(u_char); static void nbp_print(const struct atNBP *, u_int, u_short, u_char, u_char); static const char *print_cstring(const char *, const u_char *); static const struct atNBPtuple *nbp_tuple_print(const struct atNBPtuple *, const u_char *, u_short, u_char, u_char); static const struct atNBPtuple *nbp_name_print(const struct atNBPtuple *, const u_char *); static const char *ataddr_string(u_short, u_char); static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char); static const char *ddpskt_string(int); /* * Print LLAP packets received on a physical LocalTalk interface. */ void ltalk_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { snapend = p + h->caplen; ++infodelay; ts_print(&h->ts); llap_print(p, h->caplen); if(xflag) default_print(p, h->caplen); putchar('\n'); --infodelay; if (infoprint) info(0); } /* * Print AppleTalk LLAP packets. */ void llap_print(register const u_char *bp, u_int length) { register const struct LAP *lp; register const struct atDDP *dp; register const struct atShortDDP *sdp; u_short snet; /* * 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()". */ lp = (const struct LAP *)bp; bp += sizeof(*lp); length -= sizeof(*lp); switch (lp->type) { case lapShortDDP: if (length < ddpSSize) { (void)printf(" [|sddp %d]", length); return; } sdp = (const struct atShortDDP *)bp; printf("%s.%s", ataddr_string(0, lp->src), ddpskt_string(sdp->srcSkt)); printf(" > %s.%s:", ataddr_string(0, lp->dst), ddpskt_string(sdp->dstSkt)); bp += ddpSSize; length -= ddpSSize; ddp_print(bp, length, sdp->type, 0, lp->src, sdp->srcSkt); break; case lapDDP: if (length < ddpSize) { (void)printf(" [|ddp %d]", length); return; } dp = (const struct atDDP *)bp; snet = EXTRACT_16BITS(&dp->srcNet); printf("%s.%s", ataddr_string(snet, dp->srcNode), ddpskt_string(dp->srcSkt)); printf(" > %s.%s:", ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode), ddpskt_string(dp->dstSkt)); bp += ddpSize; length -= ddpSize; ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt); break; #ifdef notdef case lapKLAP: klap_print(bp, length); break; #endif default: printf("%d > %d at-lap#%d %d", lp->src, lp->dst, lp->type, length); break; } } /* * Print EtherTalk/TokenTalk packets (or FDDITalk, or whatever it's called * when it runs over FDDI; yes, I've seen FDDI captures with AppleTalk * packets in them). */ void atalk_print(register const u_char *bp, u_int length) { register const struct atDDP *dp; u_short snet; if (length < ddpSize) { (void)printf(" [|ddp %d]", length); return; } dp = (const struct atDDP *)bp; snet = EXTRACT_16BITS(&dp->srcNet); printf("%s.%s", ataddr_string(snet, dp->srcNode), ddpskt_string(dp->srcSkt)); printf(" > %s.%s:", ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode), ddpskt_string(dp->dstSkt)); bp += ddpSize; length -= ddpSize; #ifdef LBL_ALIGN if ((long)bp & 3) { static u_char *abuf = NULL; if (abuf == NULL) { abuf = (u_char *)malloc(snaplen); if (abuf == NULL) error("atalk_print: malloc"); } memcpy((char *)abuf, (char *)bp, min(length, snaplen)); snapend += abuf - (u_char *)bp; packetp = abuf; bp = abuf; } #endif ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt); } /* XXX should probably pass in the snap header and do checks like arp_print() */ void aarp_print(register const u_char *bp, u_int length) { register const struct aarp *ap; #define AT(member) ataddr_string((ap->member[1]<<8)|ap->member[2],ap->member[3]) printf("aarp "); ap = (const struct aarp *)bp; if (ntohs(ap->htype) == 1 && ntohs(ap->ptype) == ETHERTYPE_ATALK && ap->halen == 6 && ap->palen == 4 ) switch (ntohs(ap->op)) { case 1: /* request */ (void)printf("who-has %s tell %s", AT(pdaddr), AT(psaddr)); return; case 2: /* response */ (void)printf("reply %s is-at %s", AT(pdaddr), etheraddr_string(ap->hdaddr)); return; case 3: /* probe (oy!) */ (void)printf("probe %s tell %s", AT(pdaddr), AT(psaddr)); return; } (void)printf("len %u op %u htype %u ptype %#x halen %u palen %u", length, ntohs(ap->op), ntohs(ap->htype), ntohs(ap->ptype), ap->halen, ap->palen); } /* * Print AppleTalk Datagram Delivery Protocol packets. */ static void ddp_print(register const u_char *bp, register u_int length, register int t, register u_short snet, register u_char snode, u_char skt) { switch (t) { case ddpNBP: nbp_print((const struct atNBP *)bp, length, snet, snode, skt); break; case ddpATP: atp_print((const struct atATP *)bp, length); break; default: (void)printf(" at-%s %d", tok2str(type2str, NULL, t), length); break; } } static void atp_print(register const struct atATP *ap, u_int length) { char c; u_int32_t data; if ((const u_char *)(ap + 1) > snapend) { /* Just bail if we don't have the whole chunk. */ fputs(tstr, stdout); return; } length -= sizeof(*ap); switch (ap->control & 0xc0) { case atpReqCode: (void)printf(" atp-req%s %d", ap->control & atpXO? " " : "*", EXTRACT_16BITS(&ap->transID)); atp_bitmap_print(ap->bitmap); if (length != 0) (void)printf(" [len=%d]", length); switch (ap->control & (atpEOM|atpSTS)) { case atpEOM: (void)printf(" [EOM]"); break; case atpSTS: (void)printf(" [STS]"); break; case atpEOM|atpSTS: (void)printf(" [EOM,STS]"); break; } break; case atpRspCode: (void)printf(" atp-resp%s%d:%d (%d)", ap->control & atpEOM? "*" : " ", EXTRACT_16BITS(&ap->transID), ap->bitmap, length); switch (ap->control & (atpXO|atpSTS)) { case atpXO: (void)printf(" [XO]"); break; case atpSTS: (void)printf(" [STS]"); break; case atpXO|atpSTS: (void)printf(" [XO,STS]"); break; } break; case atpRelCode: (void)printf(" atp-rel %d", EXTRACT_16BITS(&ap->transID)); atp_bitmap_print(ap->bitmap); /* length should be zero */ if (length) (void)printf(" [len=%d]", length); /* there shouldn't be any control flags */ if (ap->control & (atpXO|atpEOM|atpSTS)) { c = '['; if (ap->control & atpXO) { (void)printf("%cXO", c); c = ','; } if (ap->control & atpEOM) { (void)printf("%cEOM", c); c = ','; } if (ap->control & atpSTS) { (void)printf("%cSTS", c); c = ','; } (void)printf("]"); } break; default: (void)printf(" atp-0x%x %d (%d)", ap->control, EXTRACT_16BITS(&ap->transID), length); break; } data = EXTRACT_32BITS(&ap->userData); if (data != 0) (void)printf(" 0x%x", data); } static void atp_bitmap_print(register u_char bm) { register char c; register int i; /* * The '& 0xff' below is needed for compilers that want to sign * extend a u_char, which is the case with the Ultrix compiler. * (gcc is smart enough to eliminate it, at least on the Sparc). */ if ((bm + 1) & (bm & 0xff)) { c = '<'; for (i = 0; bm; ++i) { if (bm & 1) { (void)printf("%c%d", c, i); c = ','; } bm >>= 1; } (void)printf(">"); } else { for (i = 0; bm; ++i) bm >>= 1; if (i > 1) (void)printf("<0-%d>", i - 1); else (void)printf("<0>"); } } static void nbp_print(register const struct atNBP *np, u_int length, register u_short snet, register u_char snode, register u_char skt) { register const struct atNBPtuple *tp = (const struct atNBPtuple *)((u_char *)np + nbpHeaderSize); int i; const u_char *ep; if (length < nbpHeaderSize) { (void)printf(" truncated-nbp %d", length); return; } length -= nbpHeaderSize; if (length < 8) { /* must be room for at least one tuple */ (void)printf(" truncated-nbp %d", length + nbpHeaderSize); return; } /* ep points to end of available data */ ep = snapend; if ((const u_char *)tp > ep) { fputs(tstr, stdout); return; } switch (i = np->control & 0xf0) { case nbpBrRq: case nbpLkUp: (void)printf(i == nbpLkUp? " nbp-lkup %d:":" nbp-brRq %d:", np->id); if ((const u_char *)(tp + 1) > ep) { fputs(tstr, stdout); return; } (void)nbp_name_print(tp, ep); /* * look for anomalies: the spec says there can only * be one tuple, the address must match the source * address and the enumerator should be zero. */ if ((np->control & 0xf) != 1) (void)printf(" [ntup=%d]", np->control & 0xf); if (tp->enumerator) (void)printf(" [enum=%d]", tp->enumerator); if (EXTRACT_16BITS(&tp->net) != snet || tp->node != snode || tp->skt != skt) (void)printf(" [addr=%s.%d]", ataddr_string(EXTRACT_16BITS(&tp->net), tp->node), tp->skt); break; case nbpLkUpReply: (void)printf(" nbp-reply %d:", np->id); /* print each of the tuples in the reply */ for (i = np->control & 0xf; --i >= 0 && tp; ) tp = nbp_tuple_print(tp, ep, snet, snode, skt); break; default: (void)printf(" nbp-0x%x %d (%d)", np->control, np->id, length); break; } } /* print a counted string */ static const char * print_cstring(register const char *cp, register const u_char *ep) { register u_int length; if (cp >= (const char *)ep) { fputs(tstr, stdout); return (0); } length = *cp++; /* Spec says string can be at most 32 bytes long */ if (length > 32) { (void)printf("[len=%u]", length); return (0); } while ((int)--length >= 0) { if (cp >= (const char *)ep) { fputs(tstr, stdout); return (0); } putchar(*cp++); } return (cp); } static const struct atNBPtuple * nbp_tuple_print(register const struct atNBPtuple *tp, register const u_char *ep, register u_short snet, register u_char snode, register u_char skt) { register const struct atNBPtuple *tpn; if ((const u_char *)(tp + 1) > ep) { fputs(tstr, stdout); return 0; } tpn = nbp_name_print(tp, ep); /* if the enumerator isn't 1, print it */ if (tp->enumerator != 1) (void)printf("(%d)", tp->enumerator); /* if the socket doesn't match the src socket, print it */ if (tp->skt != skt) (void)printf(" %d", tp->skt); /* if the address doesn't match the src address, it's an anomaly */ if (EXTRACT_16BITS(&tp->net) != snet || tp->node != snode) (void)printf(" [addr=%s]", ataddr_string(EXTRACT_16BITS(&tp->net), tp->node)); return (tpn); } static const struct atNBPtuple * nbp_name_print(const struct atNBPtuple *tp, register const u_char *ep) { register const char *cp = (const char *)tp + nbpTupleSize; putchar(' '); /* Object */ putchar('"'); if ((cp = print_cstring(cp, ep)) != NULL) { /* Type */ putchar(':'); if ((cp = print_cstring(cp, ep)) != NULL) { /* Zone */ putchar('@'); if ((cp = print_cstring(cp, ep)) != NULL) putchar('"'); } } return ((const struct atNBPtuple *)cp); } #define HASHNAMESIZE 4096 struct hnamemem { int addr; char *name; struct hnamemem *nxt; }; static struct hnamemem hnametable[HASHNAMESIZE]; static const char * ataddr_string(u_short atnet, u_char athost) { register struct hnamemem *tp, *tp2; register int i = (atnet << 8) | athost; char nambuf[MAXHOSTNAMELEN + 20]; static int first = 1; FILE *fp; /* * if this is the first call, see if there's an AppleTalk * number to name map file. */ if (first && (first = 0, !nflag) && (fp = fopen("/etc/atalk.names", "r"))) { char line[256]; int i1, i2, i3; 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) /* got a hostname. */ i3 |= ((i1 << 8) | i2) << 8; else if (sscanf(line, "%d.%d %256s", &i1, &i2, nambuf) == 3) /* got a net name */ i3 = (((i1 << 8) | i2) << 8) | 255; else continue; for (tp = &hnametable[i3 & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) ; tp->addr = i3; tp->nxt = newhnamemem(); tp->name = strdup(nambuf); } fclose(fp); } for (tp = &hnametable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); /* didn't have the node name -- see if we've got the net name */ i |= 255; for (tp2 = &hnametable[i & (HASHNAMESIZE-1)]; tp2->nxt; tp2 = tp2->nxt) if (tp2->addr == i) { tp->addr = (atnet << 8) | athost; tp->nxt = newhnamemem(); (void)snprintf(nambuf, sizeof(nambuf), "%s.%d", tp2->name, athost); tp->name = strdup(nambuf); return (tp->name); } tp->addr = (atnet << 8) | athost; tp->nxt = newhnamemem(); if (athost != 255) (void)snprintf(nambuf, sizeof(nambuf), "%d.%d.%d", atnet >> 8, atnet & 0xff, athost); else (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8, atnet & 0xff); tp->name = strdup(nambuf); return (tp->name); } static struct tok skt2str[] = { { rtmpSkt, "rtmp" }, /* routing table maintenance */ { nbpSkt, "nis" }, /* name info socket */ { echoSkt, "echo" }, /* AppleTalk echo protocol */ { zipSkt, "zip" }, /* zone info protocol */ { 0, NULL } }; static const char * ddpskt_string(register int skt) { static char buf[8]; if (nflag) { (void)snprintf(buf, sizeof(buf), "%d", skt); return (buf); } return (tok2str(skt2str, "%d", skt)); } tcpdump-3.7.2/print-atm.c0100644000076500000240000000772707321133726014440 0ustar fennerstaff/* * Copyright (c) 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.21 2001/07/05 18:54:14 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" /* * This is the top level routine of the printer. 'p' is the points * to the LLC/SNAP header of the packet, 'tvp' is the timestamp, * 'length' is the length of the packet off the wire, and 'caplen' * is the number of bytes actually captured. */ void atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; u_short ethertype; ++infodelay; ts_print(&h->ts); if (caplen < 8) { printf("[|atm]"); goto out; } if (p[0] != 0xaa || p[1] != 0xaa || p[2] != 0x03) { /*XXX assume 802.6 MAC header from fore driver */ if (eflag) printf("%04x%04x %04x%04x ", p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3], p[4] << 24 | p[5] << 16 | p[6] << 8 | p[7], p[8] << 24 | p[9] << 16 | p[10] << 8 | p[11], p[12] << 24 | p[13] << 16 | p[14] << 8 | p[15]); p += 20; length -= 20; caplen -= 20; } ethertype = p[6] << 8 | p[7]; if (eflag) printf("%02x %02x %02x %02x-%02x-%02x %04x: ", p[0], p[1], p[2], /* dsap/ssap/ctrl */ p[3], p[4], p[5], /* manufacturer's code */ ethertype); /* * Some printers want to get back at the ethernet addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; length -= 8; caplen -= 8; p += 8; switch (ethertype) { case ETHERTYPE_IP: ip_print(p, length); break; #ifdef INET6 case ETHERTYPE_IPV6: ip6_print(p, length); break; #endif /*INET6*/ /*XXX this probably isn't right */ case ETHERTYPE_ARP: case ETHERTYPE_REVARP: arp_print(p, length, caplen); break; #ifdef notyet case ETHERTYPE_DN: decnet_print(p, length, caplen); break; case ETHERTYPE_ATALK: if (vflag) fputs("et1 ", stdout); atalk_print(p, length); break; case ETHERTYPE_AARP: aarp_print(p, length); break; case ETHERTYPE_LAT: case ETHERTYPE_MOPRC: case ETHERTYPE_MOPDL: /* default_print for now */ #endif default: /* ether_type not known, print raw packet */ if (!eflag) printf("%02x %02x %02x %02x-%02x-%02x %04x: ", packetp[0], packetp[1], packetp[2], /* dsap/ssap/ctrl */ packetp[3], packetp[4], packetp[5], /* manufacturer's code */ ethertype); if (!xflag && !qflag) default_print(p, caplen); } if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } tcpdump-3.7.2/print-beep.c0100644000076500000240000000325507627054625014573 0ustar fennerstaff/* * Copyright (C) 2000, Richard Sharpe * * This software may be distributed either under the terms of the * BSD-style licence that accompanies tcpdump or under the GNU GPL * version 2 or later. * * print-beep.c * */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.1.2.1 2002/07/11 07:47:01 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #ifdef HAVE_MEMORY_H #include #endif #include #include #include #include #include "interface.h" #include "extract.h" /* Check for a string but not go beyond length * Return TRUE on match, FALSE otherwise * * Looks at the first few chars up to tl1 ... */ static int l_strnstart(const char *, u_int, const char *, u_int); static int l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2) { if (tl1 > l2) return 0; return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0); } void beep_print(const u_char *bp, u_int length) { if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */ printf(" BEEP MSG"); else if (l_strnstart("RPY ", 4, (const char *)bp, length)) printf(" BEEP RPY"); else if (l_strnstart("ERR ", 4, (const char *)bp, length)) printf(" BEEP ERR"); else if (l_strnstart("ANS ", 4, (const char *)bp, length)) printf(" BEEP ANS"); else if (l_strnstart("NUL ", 4, (const char *)bp, length)) printf(" BEEP NUL"); else if (l_strnstart("SEQ ", 4, (const char *)bp, length)) printf(" BEEP SEQ"); else if (l_strnstart("END", 4, (const char *)bp, length)) printf(" BEEP END"); else printf(" BEEP (payload or undecoded)"); } tcpdump-3.7.2/print-bgp.c0100644000076500000240000004361507627054625014434 0ustar fennerstaff/* * Copyright (C) 1999 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.27.2.1 2003/02/26 05:51:56 fenner Exp $"; #endif #include #include #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" struct bgp { u_int8_t bgp_marker[16]; u_int16_t bgp_len; u_int8_t bgp_type; }; #define BGP_SIZE 19 /* unaligned */ #define BGP_OPEN 1 #define BGP_UPDATE 2 #define BGP_NOTIFICATION 3 #define BGP_KEEPALIVE 4 struct bgp_open { u_int8_t bgpo_marker[16]; u_int16_t bgpo_len; u_int8_t bgpo_type; u_int8_t bgpo_version; u_int16_t bgpo_myas; u_int16_t bgpo_holdtime; u_int32_t bgpo_id; u_int8_t bgpo_optlen; /* options should follow */ }; #define BGP_OPEN_SIZE 29 /* unaligned */ struct bgp_opt { u_int8_t bgpopt_type; u_int8_t bgpopt_len; /* variable length */ }; #define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */ struct bgp_notification { u_int8_t bgpn_marker[16]; u_int16_t bgpn_len; u_int8_t bgpn_type; u_int8_t bgpn_major; u_int8_t bgpn_minor; /* data should follow */ }; #define BGP_NOTIFICATION_SIZE 21 /* unaligned */ struct bgp_attr { u_int8_t bgpa_flags; u_int8_t bgpa_type; union { u_int8_t len; u_int16_t elen; } bgpa_len; #define bgp_attr_len(p) \ (((p)->bgpa_flags & 0x10) ? \ ntohs((p)->bgpa_len.elen) : (p)->bgpa_len.len) #define bgp_attr_off(p) \ (((p)->bgpa_flags & 0x10) ? 4 : 3) }; #define BGPTYPE_ORIGIN 1 #define BGPTYPE_AS_PATH 2 #define BGPTYPE_NEXT_HOP 3 #define BGPTYPE_MULTI_EXIT_DISC 4 #define BGPTYPE_LOCAL_PREF 5 #define BGPTYPE_ATOMIC_AGGREGATE 6 #define BGPTYPE_AGGREGATOR 7 #define BGPTYPE_COMMUNITIES 8 /* RFC1997 */ #define BGPTYPE_ORIGINATOR_ID 9 /* RFC1998 */ #define BGPTYPE_CLUSTER_LIST 10 /* RFC1998 */ #define BGPTYPE_DPA 11 /* work in progress */ #define BGPTYPE_ADVERTISERS 12 /* RFC1863 */ #define BGPTYPE_RCID_PATH 13 /* RFC1863 */ #define BGPTYPE_MP_REACH_NLRI 14 /* RFC2283 */ #define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2283 */ static const char *bgptype[] = { NULL, "OPEN", "UPDATE", "NOTIFICATION", "KEEPALIVE", }; #define bgp_type(x) num_or_str(bgptype, sizeof(bgptype)/sizeof(bgptype[0]), (x)) static const char *bgpopt_type[] = { NULL, "Authentication Information", "Capabilities Advertisement", }; #define bgp_opttype(x) \ num_or_str(bgpopt_type, sizeof(bgpopt_type)/sizeof(bgpopt_type[0]), (x)) static const char *bgpnotify_major[] = { NULL, "Message Header Error", "OPEN Message Error", "UPDATE Message Error", "Hold Timer Expired", "Finite State Machine Error", "Cease", }; #define bgp_notify_major(x) \ num_or_str(bgpnotify_major, \ sizeof(bgpnotify_major)/sizeof(bgpnotify_major[0]), (x)) static const char *bgpnotify_minor_1[] = { NULL, "Connection Not Synchronized", "Bad Message Length", "Bad Message Type", }; static const char *bgpnotify_minor_2[] = { NULL, "Unsupported Version Number", "Bad Peer AS", "Bad BGP Identifier", "Unsupported Optional Parameter", "Authentication Failure", "Unacceptable Hold Time", }; static const char *bgpnotify_minor_3[] = { NULL, "Malformed Attribute List", "Unrecognized Well-known Attribute", "Missing Well-known Attribute", "Attribute Flags Error", "Attribute Length Error", "Invalid ORIGIN Attribute", "AS Routing Loop", "Invalid NEXT_HOP Attribute", "Optional Attribute Error", "Invalid Network Field", "Malformed AS_PATH", }; static const char **bgpnotify_minor[] = { NULL, bgpnotify_minor_1, bgpnotify_minor_2, bgpnotify_minor_3, }; static const int bgpnotify_minor_siz[] = { 0, sizeof(bgpnotify_minor_1)/sizeof(bgpnotify_minor_1[0]), sizeof(bgpnotify_minor_2)/sizeof(bgpnotify_minor_2[0]), sizeof(bgpnotify_minor_3)/sizeof(bgpnotify_minor_3[0]), }; static const char *bgpattr_origin[] = { "IGP", "EGP", "INCOMPLETE", }; #define bgp_attr_origin(x) \ num_or_str(bgpattr_origin, \ sizeof(bgpattr_origin)/sizeof(bgpattr_origin[0]), (x)) static const char *bgpattr_type[] = { NULL, "ORIGIN", "AS_PATH", "NEXT_HOP", "MULTI_EXIT_DISC", "LOCAL_PREF", "ATOMIC_AGGREGATE", "AGGREGATOR", "COMMUNITIES", "ORIGINATOR_ID", "CLUSTER_LIST", "DPA", "ADVERTISERS", "RCID_PATH", "MP_REACH_NLRI", "MP_UNREACH_NLRI", }; #define bgp_attr_type(x) \ num_or_str(bgpattr_type, \ sizeof(bgpattr_type)/sizeof(bgpattr_type[0]), (x)) /* Subsequent address family identifier, RFC2283 section 7 */ static const char *bgpattr_nlri_safi[] = { "Reserved", "Unicast", "Multicast", "Unicast+Multicast", }; #define bgp_attr_nlri_safi(x) \ num_or_str(bgpattr_nlri_safi, \ sizeof(bgpattr_nlri_safi)/sizeof(bgpattr_nlri_safi[0]), (x)) /* well-known community */ #define BGP_COMMUNITY_NO_EXPORT 0xffffff01 #define BGP_COMMUNITY_NO_ADVERT 0xffffff02 #define BGP_COMMUNITY_NO_EXPORT_SUBCONFED 0xffffff03 /* RFC1700 address family numbers */ #define AFNUM_INET 1 #define AFNUM_INET6 2 #define AFNUM_NSAP 3 #define AFNUM_HDLC 4 #define AFNUM_BBN1822 5 #define AFNUM_802 6 #define AFNUM_E163 7 #define AFNUM_E164 8 #define AFNUM_F69 9 #define AFNUM_X121 10 #define AFNUM_IPX 11 #define AFNUM_ATALK 12 #define AFNUM_DECNET 13 #define AFNUM_BANYAN 14 #define AFNUM_E164NSAP 15 static const char *afnumber[] = { "Reserved", "IPv4", "IPv6", "NSAP", "HDLC", "BBN 1822", "802", "E.163", "E.164", "F.69", "X.121", "IPX", "Appletalk", "Decnet IV", "Banyan Vines", "E.164 with NSAP subaddress", }; #define af_name(x) \ (((x) == 65535) ? afnumber[0] : \ num_or_str(afnumber, \ sizeof(afnumber)/sizeof(afnumber[0]), (x))) static const char * num_or_str(const char **table, size_t siz, int value) { static char buf[20]; if (value < 0 || siz <= value || table[value] == NULL) { snprintf(buf, sizeof(buf), "#%d", value); return buf; } else return table[value]; } static const char * bgp_notify_minor(int major, int minor) { static const char **table; int siz; static char buf[20]; const char *p; if (0 <= major && major < sizeof(bgpnotify_minor)/sizeof(bgpnotify_minor[0]) && bgpnotify_minor[major]) { table = bgpnotify_minor[major]; siz = bgpnotify_minor_siz[major]; if (0 <= minor && minor < siz && table[minor]) p = table[minor]; else p = NULL; } else p = NULL; if (p == NULL) { snprintf(buf, sizeof(buf), "#%d", minor); return buf; } else return p; } static int decode_prefix4(const u_char *pd, char *buf, u_int buflen) { struct in_addr addr; u_int plen; plen = pd[0]; if (plen < 0 || 32 < plen) return -1; memset(&addr, 0, sizeof(addr)); memcpy(&addr, &pd[1], (plen + 7) / 8); if (plen % 8) { ((u_char *)&addr)[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen); return 1 + (plen + 7) / 8; } #ifdef INET6 static int decode_prefix6(const u_char *pd, char *buf, u_int buflen) { struct in6_addr addr; u_int plen; plen = pd[0]; if (plen < 0 || 128 < plen) return -1; memset(&addr, 0, sizeof(addr)); memcpy(&addr, &pd[1], (plen + 7) / 8); if (plen % 8) { addr.s6_addr[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen); return 1 + (plen + 7) / 8; } #endif static void bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len) { int i; u_int16_t af; u_int8_t safi, snpa; int advance; int tlen; const u_char *p; char buf[MAXHOSTNAMELEN + 100]; p = dat; switch (attr->bgpa_type) { case BGPTYPE_ORIGIN: if (len != 1) printf(" invalid len"); else printf(" %s", bgp_attr_origin(p[0])); break; case BGPTYPE_AS_PATH: if (len % 2) { printf(" invalid len"); break; } while (p < dat + len) { /* * under RFC1965, p[0] means: * 1: AS_SET 2: AS_SEQUENCE * 3: AS_CONFED_SET 4: AS_CONFED_SEQUENCE */ printf(" "); if (p[0] == 3 || p[0] == 4) printf("confed"); printf("%s", (p[0] & 1) ? "{" : ""); for (i = 0; i < p[1] * 2; i += 2) { printf("%s%u", i == 0 ? "" : " ", EXTRACT_16BITS(&p[2 + i])); } printf("%s", (p[0] & 1) ? "}" : ""); p += 2 + p[1] * 2; } break; case BGPTYPE_NEXT_HOP: if (len != 4) printf(" invalid len"); else printf(" %s", getname(p)); break; case BGPTYPE_MULTI_EXIT_DISC: case BGPTYPE_LOCAL_PREF: if (len != 4) printf(" invalid len"); else printf(" %u", EXTRACT_32BITS(p)); break; case BGPTYPE_ATOMIC_AGGREGATE: if (len != 0) printf(" invalid len"); break; case BGPTYPE_AGGREGATOR: if (len != 6) { printf(" invalid len"); break; } printf(" AS #%u, origin %s", EXTRACT_16BITS(p), getname(p + 2)); break; case BGPTYPE_COMMUNITIES: if (len % 4) { printf(" invalid len"); break; } for (i = 0; i < len; i += 4) { u_int32_t comm; comm = EXTRACT_32BITS(&p[i]); switch (comm) { case BGP_COMMUNITY_NO_EXPORT: printf(" NO_EXPORT"); break; case BGP_COMMUNITY_NO_ADVERT: printf(" NO_ADVERTISE"); break; case BGP_COMMUNITY_NO_EXPORT_SUBCONFED: printf(" NO_EXPORT_SUBCONFED"); break; default: printf(" (AS #%d value 0x%04x)", (comm >> 16) & 0xffff, comm & 0xffff); break; } } break; case BGPTYPE_MP_REACH_NLRI: af = EXTRACT_16BITS(p); safi = p[2]; if (safi >= 128) printf(" %s vendor specific,", af_name(af)); else { printf(" %s %s,", af_name(af), bgp_attr_nlri_safi(safi)); } p += 3; if (af == AFNUM_INET) ; #ifdef INET6 else if (af == AFNUM_INET6) ; #endif else break; tlen = p[0]; if (tlen) { printf(" nexthop"); i = 0; while (i < tlen) { switch (af) { case AFNUM_INET: printf(" %s", getname(p + 1 + i)); i += sizeof(struct in_addr); break; #ifdef INET6 case AFNUM_INET6: printf(" %s", getname6(p + 1 + i)); i += sizeof(struct in6_addr); break; #endif default: printf(" (unknown af)"); i = tlen; /*exit loop*/ break; } } printf(","); } p += 1 + tlen; snpa = p[0]; p++; if (snpa) { printf(" %u snpa", snpa); for (/*nothing*/; snpa > 0; snpa--) { printf("(%d bytes)", p[0]); p += p[0] + 1; } printf(","); } printf(" NLRI"); while (len - (p - dat) > 0) { switch (af) { case AFNUM_INET: advance = decode_prefix4(p, buf, sizeof(buf)); if (advance < 0) { p = dat + len; break; } printf(" %s", buf); break; #ifdef INET6 case AFNUM_INET6: advance = decode_prefix6(p, buf, sizeof(buf)); if (advance < 0) { p = dat + len; break; } printf(" %s", buf); break; #endif default: printf(" (unknown af)"); advance = 0; p = dat + len; break; } p += advance; } break; case BGPTYPE_MP_UNREACH_NLRI: af = EXTRACT_16BITS(p); safi = p[2]; if (safi >= 128) printf(" %s vendor specific,", af_name(af)); else { printf(" %s %s,", af_name(af), bgp_attr_nlri_safi(safi)); } p += 3; printf(" Withdraw"); while (len - (p - dat) > 0) { switch (af) { case AFNUM_INET: advance = decode_prefix4(p, buf, sizeof(buf)); if (advance < 0) { p = dat + len; break; } printf(" %s", buf); break; #ifdef INET6 case AFNUM_INET6: advance = decode_prefix6(p, buf, sizeof(buf)); if (advance < 0) { p = dat + len; break; } printf(" %s", buf); break; #endif default: printf(" (unknown af)"); advance = 0; p = dat + len; break; } p += advance; } break; default: break; } } static void bgp_open_print(const u_char *dat, int length) { struct bgp_open bgpo; struct bgp_opt bgpopt; int hlen; const u_char *opt; int i; TCHECK2(dat[0], BGP_OPEN_SIZE); memcpy(&bgpo, dat, BGP_OPEN_SIZE); hlen = ntohs(bgpo.bgpo_len); printf(": Version %d,", bgpo.bgpo_version); printf(" AS #%u,", ntohs(bgpo.bgpo_myas)); printf(" Holdtime %u,", ntohs(bgpo.bgpo_holdtime)); printf(" ID %s,", getname((u_char *)&bgpo.bgpo_id)); printf(" Option length %u", bgpo.bgpo_optlen); /* ugly! */ opt = &((const struct bgp_open *)dat)->bgpo_optlen; opt++; i = 0; while (i < bgpo.bgpo_optlen) { TCHECK2(opt[i], BGP_OPT_SIZE); memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE); if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) { printf(" [|opt %d %d]", bgpopt.bgpopt_len, bgpopt.bgpopt_type); break; } printf(" (option %s, len=%d)", bgp_opttype(bgpopt.bgpopt_type), bgpopt.bgpopt_len); i += BGP_OPT_SIZE + bgpopt.bgpopt_len; } return; trunc: printf("[|BGP]"); } static void bgp_update_print(const u_char *dat, int length) { struct bgp bgp; struct bgp_attr bgpa; int hlen; const u_char *p; int len; int i; int newline; TCHECK2(dat[0], BGP_SIZE); memcpy(&bgp, dat, BGP_SIZE); hlen = ntohs(bgp.bgp_len); p = dat + BGP_SIZE; /*XXX*/ printf(":"); /* Unfeasible routes */ len = EXTRACT_16BITS(p); if (len) { /* * Without keeping state from the original NLRI message, * it's not possible to tell if this a v4 or v6 route, * so only try to decode it if we're not v6 enabled. */ #ifdef INET6 printf(" (Withdrawn routes: %d bytes)", len); #else char buf[MAXHOSTNAMELEN + 100]; int wpfx; TCHECK2(p[2], len); i = 2; printf(" (Withdrawn routes:"); while(i < 2 + len) { wpfx = decode_prefix4(&p[i], buf, sizeof(buf)); if (wpfx < 0) break; i += wpfx; printf(" %s", buf); } printf(")\n"); #endif } p += 2 + len; TCHECK2(p[0], 2); len = EXTRACT_16BITS(p); if (len) { /* do something more useful!*/ i = 2; printf(" (Path attributes:"); /* ) */ newline = 0; while (i < 2 + len) { int alen, aoff; TCHECK2(p[i], sizeof(bgpa)); memcpy(&bgpa, &p[i], sizeof(bgpa)); alen = bgp_attr_len(&bgpa); aoff = bgp_attr_off(&bgpa); if (vflag && newline) printf("\n\t\t"); else printf(" "); printf("("); /* ) */ printf("%s", bgp_attr_type(bgpa.bgpa_type)); if (bgpa.bgpa_flags) { printf("[%s%s%s%s", bgpa.bgpa_flags & 0x80 ? "O" : "", bgpa.bgpa_flags & 0x40 ? "T" : "", bgpa.bgpa_flags & 0x20 ? "P" : "", bgpa.bgpa_flags & 0x10 ? "E" : ""); if (bgpa.bgpa_flags & 0xf) printf("+%x", bgpa.bgpa_flags & 0xf); printf("]"); } bgp_attr_print(&bgpa, &p[i + aoff], alen); newline = 1; /* ( */ printf(")"); i += aoff + alen; } /* ( */ printf(")"); } p += 2 + len; if (len && dat + length > p) printf("\n\t\t"); if (dat + length > p) { printf("(NLRI:"); /* ) */ while (dat + length > p) { char buf[MAXHOSTNAMELEN + 100]; i = decode_prefix4(p, buf, sizeof(buf)); if (i < 0) break; printf(" %s", buf); p += i; } /* ( */ printf(")"); } return; trunc: printf("[|BGP]"); } static void bgp_notification_print(const u_char *dat, int length) { struct bgp_notification bgpn; int hlen; TCHECK2(dat[0], BGP_NOTIFICATION_SIZE); memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE); hlen = ntohs(bgpn.bgpn_len); printf(": error %s,", bgp_notify_major(bgpn.bgpn_major)); printf(" subcode %s", bgp_notify_minor(bgpn.bgpn_major, bgpn.bgpn_minor)); return; trunc: printf("[|BGP]"); } static void bgp_header_print(const u_char *dat, int length) { struct bgp bgp; TCHECK2(dat[0], BGP_SIZE); memcpy(&bgp, dat, BGP_SIZE); printf("(%s", bgp_type(bgp.bgp_type)); /* ) */ switch (bgp.bgp_type) { case BGP_OPEN: bgp_open_print(dat, length); break; case BGP_UPDATE: bgp_update_print(dat, length); break; case BGP_NOTIFICATION: bgp_notification_print(dat, length); break; } /* ( */ printf(")"); return; trunc: printf("[|BGP]"); } void bgp_print(const u_char *dat, int length) { const u_char *p; const u_char *ep; const u_char *start; const u_char marker[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; struct bgp bgp; u_int16_t hlen; int newline; ep = dat + length; if (snapend < dat + length) ep = snapend; printf(": BGP"); p = dat; newline = 0; start = p; while (p < snapend) { if (!TTEST2(p[0], 1)) break; if (p[0] != 0xff) { p++; continue; } if (!TTEST2(p[0], sizeof(marker))) break; if (memcmp(p, marker, sizeof(marker)) != 0) { p++; continue; } /* found BGP header */ TCHECK2(p[0], BGP_SIZE); /*XXX*/ memcpy(&bgp, p, BGP_SIZE); if (start != p) printf(" [|BGP]"); hlen = ntohs(bgp.bgp_len); if (vflag && newline) printf("\n\t"); else printf(" "); if (TTEST2(p[0], hlen)) { bgp_header_print(p, hlen); newline = 1; p += hlen; start = p; } else { printf("[|BGP %s]", bgp_type(bgp.bgp_type)); break; } } return; trunc: printf(" [|BGP]"); } tcpdump-3.7.2/print-bootp.c0100644000076500000240000003706707627054625015013 0ustar fennerstaff/* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Format and print bootp packets. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.60.4.2 2002/06/01 23:51:11 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" #include "ether.h" #include "bootp.h" static void rfc1048_print(const u_char *); static void cmu_print(const u_char *); static char tstr[] = " [|bootp]"; /* * Print bootp requests */ void bootp_print(register const u_char *cp, u_int length, u_short sport, u_short dport) { register const struct bootp *bp; static const u_char vm_cmu[4] = VM_CMU; static const u_char vm_rfc1048[4] = VM_RFC1048; bp = (const struct bootp *)cp; TCHECK(bp->bp_op); switch (bp->bp_op) { case BOOTREQUEST: /* Usually, a request goes from a client to a server */ if (sport != IPPORT_BOOTPC || dport != IPPORT_BOOTPS) printf(" (request)"); break; case BOOTREPLY: /* Usually, a reply goes from a server to a client */ if (sport != IPPORT_BOOTPS || dport != IPPORT_BOOTPC) printf(" (reply)"); break; default: printf(" bootp-#%d", bp->bp_op); } TCHECK(bp->bp_secs); /* The usual hardware address type is 1 (10Mb Ethernet) */ if (bp->bp_htype != 1) printf(" htype-#%d", bp->bp_htype); /* The usual length for 10Mb Ethernet address is 6 bytes */ if (bp->bp_htype != 1 || bp->bp_hlen != 6) printf(" hlen:%d", bp->bp_hlen); /* Only print interesting fields */ if (bp->bp_hops) printf(" hops:%d", bp->bp_hops); if (bp->bp_xid) printf(" xid:0x%x", (u_int32_t)ntohl(bp->bp_xid)); if (bp->bp_secs) printf(" secs:%d", ntohs(bp->bp_secs)); if (bp->bp_flags) printf(" flags:0x%x", ntohs(bp->bp_flags)); /* Client's ip address */ TCHECK(bp->bp_ciaddr); if (bp->bp_ciaddr.s_addr) printf(" C:%s", ipaddr_string(&bp->bp_ciaddr)); /* 'your' ip address (bootp client) */ TCHECK(bp->bp_yiaddr); if (bp->bp_yiaddr.s_addr) printf(" Y:%s", ipaddr_string(&bp->bp_yiaddr)); /* Server's ip address */ TCHECK(bp->bp_siaddr); if (bp->bp_siaddr.s_addr) printf(" S:%s", ipaddr_string(&bp->bp_siaddr)); /* Gateway's ip address */ TCHECK(bp->bp_giaddr); if (bp->bp_giaddr.s_addr) printf(" G:%s", ipaddr_string(&bp->bp_giaddr)); /* Client's Ethernet address */ if (bp->bp_htype == 1 && bp->bp_hlen == 6) { register const struct ether_header *eh; register const char *e; TCHECK2(bp->bp_chaddr[0], 6); eh = (const struct ether_header *)packetp; if (bp->bp_op == BOOTREQUEST) e = (const char *)ESRC(eh); else if (bp->bp_op == BOOTREPLY) e = (const char *)EDST(eh); else e = 0; if (e == 0 || memcmp((const char *)bp->bp_chaddr, e, 6) != 0) printf(" ether %s", etheraddr_string(bp->bp_chaddr)); } TCHECK2(bp->bp_sname[0], 1); /* check first char only */ if (*bp->bp_sname) { printf(" sname \""); if (fn_print(bp->bp_sname, snapend)) { putchar('"'); fputs(tstr + 1, stdout); return; } putchar('"'); } TCHECK2(bp->bp_sname[0], 1); /* check first char only */ if (*bp->bp_file) { printf(" file \""); if (fn_print(bp->bp_file, snapend)) { putchar('"'); fputs(tstr + 1, stdout); return; } putchar('"'); } /* Decode the vendor buffer */ TCHECK(bp->bp_vend[0]); if (memcmp((const char *)bp->bp_vend, vm_rfc1048, sizeof(u_int32_t)) == 0) rfc1048_print(bp->bp_vend); else if (memcmp((const char *)bp->bp_vend, vm_cmu, sizeof(u_int32_t)) == 0) cmu_print(bp->bp_vend); else { u_int32_t ul; ul = EXTRACT_32BITS(&bp->bp_vend); if (ul != 0) printf("vend-#0x%x", ul); } return; trunc: fputs(tstr, stdout); } /* * The first character specifies the format to print: * i - ip address (32 bits) * p - ip address pairs (32 bits + 32 bits) * l - long (32 bits) * L - unsigned long (32 bits) * s - short (16 bits) * b - period-seperated decimal bytes (variable length) * x - colon-seperated hex bytes (variable length) * a - ascii string (variable length) * B - on/off (8 bits) * $ - special (explicit code to handle) */ static struct tok tag2str[] = { /* RFC1048 tags */ { TAG_PAD, " PAD" }, { TAG_SUBNET_MASK, "iSM" }, /* subnet mask (RFC950) */ { TAG_TIME_OFFSET, "LTZ" }, /* seconds from UTC */ { TAG_GATEWAY, "iDG" }, /* default gateway */ { TAG_TIME_SERVER, "iTS" }, /* time servers (RFC868) */ { TAG_NAME_SERVER, "iIEN" }, /* IEN name servers (IEN116) */ { TAG_DOMAIN_SERVER, "iNS" }, /* domain name (RFC1035) */ { TAG_LOG_SERVER, "iLOG" }, /* MIT log servers */ { TAG_COOKIE_SERVER, "iCS" }, /* cookie servers (RFC865) */ { TAG_LPR_SERVER, "iLPR" }, /* lpr server (RFC1179) */ { TAG_IMPRESS_SERVER, "iIM" }, /* impress servers (Imagen) */ { TAG_RLP_SERVER, "iRL" }, /* resource location (RFC887) */ { TAG_HOSTNAME, "aHN" }, /* ascii hostname */ { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */ { TAG_END, " END" }, /* RFC1497 tags */ { TAG_DUMPPATH, "aDP" }, { TAG_DOMAINNAME, "aDN" }, { TAG_SWAP_SERVER, "iSS" }, { TAG_ROOTPATH, "aRP" }, { TAG_EXTPATH, "aEP" }, /* RFC2132 tags */ { TAG_IP_FORWARD, "BIPF" }, { TAG_NL_SRCRT, "BSRT" }, { TAG_PFILTERS, "pPF" }, { TAG_REASS_SIZE, "sRSZ" }, { TAG_DEF_TTL, "bTTL" }, { TAG_MTU_TIMEOUT, "lMA" }, { TAG_MTU_TABLE, "sMT" }, { TAG_INT_MTU, "sMTU" }, { TAG_LOCAL_SUBNETS, "BLSN" }, { TAG_BROAD_ADDR, "iBR" }, { TAG_DO_MASK_DISC, "BMD" }, { TAG_SUPPLY_MASK, "BMS" }, { TAG_DO_RDISC, "BRD" }, { TAG_RTR_SOL_ADDR, "iRSA" }, { TAG_STATIC_ROUTE, "pSR" }, { TAG_USE_TRAILERS, "BUT" }, { TAG_ARP_TIMEOUT, "lAT" }, { TAG_ETH_ENCAP, "BIE" }, { TAG_TCP_TTL, "bTT" }, { TAG_TCP_KEEPALIVE, "lKI" }, { TAG_KEEPALIVE_GO, "BKG" }, { TAG_NIS_DOMAIN, "aYD" }, { TAG_NIS_SERVERS, "iYS" }, { TAG_NTP_SERVERS, "iNTP" }, { TAG_VENDOR_OPTS, "bVO" }, { TAG_NETBIOS_NS, "iWNS" }, { TAG_NETBIOS_DDS, "iWDD" }, { TAG_NETBIOS_NODE, "$WNT" }, { TAG_NETBIOS_SCOPE, "aWSC" }, { TAG_XWIN_FS, "iXFS" }, { TAG_XWIN_DM, "iXDM" }, { TAG_NIS_P_DOMAIN, "sN+D" }, { TAG_NIS_P_SERVERS, "iN+S" }, { TAG_MOBILE_HOME, "iMH" }, { TAG_SMPT_SERVER, "iSMTP" }, { TAG_POP3_SERVER, "iPOP3" }, { TAG_NNTP_SERVER, "iNNTP" }, { TAG_WWW_SERVER, "iWWW" }, { TAG_FINGER_SERVER, "iFG" }, { TAG_IRC_SERVER, "iIRC" }, { TAG_STREETTALK_SRVR, "iSTS" }, { TAG_STREETTALK_STDA, "iSTDA" }, { TAG_REQUESTED_IP, "iRQ" }, { TAG_IP_LEASE, "lLT" }, { TAG_OPT_OVERLOAD, "$OO" }, { TAG_TFTP_SERVER, "aTFTP" }, { TAG_BOOTFILENAME, "aBF" }, { TAG_DHCP_MESSAGE, " DHCP" }, { TAG_SERVER_ID, "iSID" }, { TAG_PARM_REQUEST, "bPR" }, { TAG_MESSAGE, "aMSG" }, { TAG_MAX_MSG_SIZE, "sMSZ" }, { TAG_RENEWAL_TIME, "lRN" }, { TAG_REBIND_TIME, "lRB" }, { TAG_VENDOR_CLASS, "aVC" }, { TAG_CLIENT_ID, "$CID" }, /* RFC 2485 */ { TAG_OPEN_GROUP_UAP, "aUAP" }, /* RFC 2563 */ { TAG_DISABLE_AUTOCONF, "BNOAUTO" }, /* RFC 2610 */ { TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */ { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */ /* RFC 2937 */ { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */ /* RFC 3011 */ { TAG_IP4_SUBNET_SELECT, "iSUBNET" }, /* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */ { TAG_USER_CLASS, "aCLASS" }, { TAG_SLP_NAMING_AUTH, "aSLP-NA" }, { TAG_CLIENT_FQDN, "$FQDN" }, { TAG_AGENT_CIRCUIT, "bACKT" }, { TAG_AGENT_REMOTE, "bARMT" }, { TAG_AGENT_MASK, "bAMSK" }, { TAG_TZ_STRING, "aTZSTR" }, { TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */ { TAG_AUTH, "bAUTH" }, /* XXX 'b' */ { TAG_VINES_SERVERS, "iVINES" }, { TAG_SERVER_RANK, "sRANK" }, { TAG_CLIENT_ARCH, "sARCH" }, { TAG_CLIENT_NDI, "bNDI" }, /* XXX 'b' */ { TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */ { TAG_LDAP_URL, "aLDAP" }, { TAG_6OVER4, "i6o4" }, { TAG_PRINTER_NAME, "aPRTR" }, { TAG_MDHCP_SERVER, "bMDHCP" }, /* XXX 'b' */ { TAG_IPX_COMPAT, "bIPX" }, /* XXX 'b' */ { TAG_NETINFO_PARENT, "iNI" }, { TAG_NETINFO_PARENT_TAG, "aNITAG" }, { TAG_URL, "aURL" }, { TAG_FAILOVER, "bFAIL" }, /* XXX 'b' */ { 0, NULL } }; /* 2-byte extended tags */ static struct tok xtag2str[] = { { 0, NULL } }; /* DHCP "options overload" types */ static struct tok oo2str[] = { { 1, "file" }, { 2, "sname" }, { 3, "file+sname" }, { 0, NULL } }; /* NETBIOS over TCP/IP node type options */ static struct tok nbo2str[] = { { 0x1, "b-node" }, { 0x2, "p-node" }, { 0x4, "m-node" }, { 0x8, "h-node" }, { 0, NULL } }; /* ARP Hardware types, for Client-ID option */ static struct tok arp2str[] = { { 0x1, "ether" }, { 0x6, "ieee802" }, { 0x7, "arcnet" }, { 0xf, "frelay" }, { 0x17, "strip" }, { 0x18, "ieee1394" }, { 0, NULL } }; static void rfc1048_print(register const u_char *bp) { register u_int16_t tag; register u_int len, size; register const char *cp; register char c; int first; u_int32_t ul; u_int16_t us; u_int8_t uc; printf(" vend-rfc1048"); /* Step over magic cookie */ bp += sizeof(int32_t); /* Loop while we there is a tag left in the buffer */ while (bp + 1 < snapend) { tag = *bp++; if (tag == TAG_PAD) continue; if (tag == TAG_END) return; if (tag == TAG_EXTENDED_OPTION) { TCHECK2(*(bp + 1), 2); tag = EXTRACT_16BITS(bp + 1); /* XXX we don't know yet if the IANA will * preclude overlap of 1-byte and 2-byte spaces. * If not, we need to offset tag after this step. */ cp = tok2str(xtag2str, "?xT%u", tag); } else cp = tok2str(tag2str, "?T%u", tag); c = *cp++; printf(" %s:", cp); /* Get the length; check for truncation */ if (bp + 1 >= snapend) { fputs(tstr, stdout); return; } len = *bp++; if (bp + len >= snapend) { fputs(tstr, stdout); return; } if (tag == TAG_DHCP_MESSAGE && len == 1) { uc = *bp++; switch (uc) { case DHCPDISCOVER: printf("DISCOVER"); break; case DHCPOFFER: printf("OFFER"); break; case DHCPREQUEST: printf("REQUEST"); break; case DHCPDECLINE: printf("DECLINE"); break; case DHCPACK: printf("ACK"); break; case DHCPNAK: printf("NACK"); break; case DHCPRELEASE: printf("RELEASE"); break; case DHCPINFORM: printf("INFORM"); break; default: printf("%u", uc); break; } continue; } if (tag == TAG_PARM_REQUEST) { first = 1; while (len-- > 0) { uc = *bp++; cp = tok2str(tag2str, "?T%u", uc); if (!first) putchar('+'); printf("%s", cp + 1); first = 0; } continue; } if (tag == TAG_EXTENDED_REQUEST) { first = 1; while (len > 1) { len -= 2; us = EXTRACT_16BITS(bp); bp += 2; cp = tok2str(xtag2str, "?xT%u", us); if (!first) putchar('+'); printf("%s", cp + 1); first = 0; } continue; } /* Print data */ size = len; if (c == '?') { /* Base default formats for unknown tags on data size */ if (size & 1) c = 'b'; else if (size & 2) c = 's'; else c = 'l'; } first = 1; switch (c) { case 'a': /* ascii strings */ putchar('"'); (void)fn_printn(bp, size, NULL); putchar('"'); bp += size; size = 0; break; case 'i': case 'l': case 'L': /* ip addresses/32-bit words */ while (size >= sizeof(ul)) { if (!first) putchar(','); ul = EXTRACT_32BITS(bp); if (c == 'i') { ul = htonl(ul); printf("%s", ipaddr_string(&ul)); } else if (c == 'L') printf("%d", ul); else printf("%u", ul); bp += sizeof(ul); size -= sizeof(ul); first = 0; } break; case 'p': /* IP address pairs */ while (size >= 2*sizeof(ul)) { if (!first) putchar(','); memcpy((char *)&ul, (const char *)bp, sizeof(ul)); printf("(%s:", ipaddr_string(&ul)); bp += sizeof(ul); memcpy((char *)&ul, (const char *)bp, sizeof(ul)); printf("%s)", ipaddr_string(&ul)); bp += sizeof(ul); size -= 2*sizeof(ul); first = 0; } break; case 's': /* shorts */ while (size >= sizeof(us)) { if (!first) putchar(','); us = EXTRACT_16BITS(bp); printf("%u", us); bp += sizeof(us); size -= sizeof(us); first = 0; } break; case 'B': /* boolean */ while (size > 0) { if (!first) putchar(','); switch (*bp) { case 0: putchar('N'); break; case 1: putchar('Y'); break; default: printf("%u?", *bp); break; } ++bp; --size; first = 0; } break; case 'b': case 'x': default: /* Bytes */ while (size > 0) { if (!first) putchar(c == 'x' ? ':' : '.'); if (c == 'x') printf("%02x", *bp); else printf("%u", *bp); ++bp; --size; first = 0; } break; case '$': /* Guys we can't handle with one of the usual cases */ switch (tag) { case TAG_NETBIOS_NODE: tag = *bp++; --size; fputs(tok2str(nbo2str, NULL, tag), stdout); break; case TAG_OPT_OVERLOAD: tag = *bp++; --size; fputs(tok2str(oo2str, NULL, tag), stdout); break; case TAG_CLIENT_FQDN: if (*bp++) printf("[svrreg]"); if (*bp) printf("%u/%u/", *bp, *(bp+1)); bp += 2; putchar('"'); (void)fn_printn(bp, size - 3, NULL); putchar('"'); bp += size - 3; size = 0; break; case TAG_CLIENT_ID: { int type = *bp++; size--; if (type == 0) { putchar('"'); (void)fn_printn(bp, size, NULL); putchar('"'); break; } else { printf("[%s]", tok2str(arp2str, "type-%d", type)); } while (size > 0) { if (!first) putchar(':'); printf("%02x", *bp); ++bp; --size; first = 0; } break; } default: printf("[unknown special tag %u, size %u]", tag, size); bp += size; size = 0; break; } break; } /* Data left over? */ if (size) printf("[len %u]", len); } return; trunc: printf("|[rfc1048]"); } static void cmu_print(register const u_char *bp) { register const struct cmu_vend *cmu; #define PRINTCMUADDR(m, s) { TCHECK(cmu->m); \ if (cmu->m.s_addr != 0) \ printf(" %s:%s", s, ipaddr_string(&cmu->m.s_addr)); } printf(" vend-cmu"); cmu = (const struct cmu_vend *)bp; /* Only print if there are unknown bits */ TCHECK(cmu->v_flags); if ((cmu->v_flags & ~(VF_SMASK)) != 0) printf(" F:0x%x", cmu->v_flags); PRINTCMUADDR(v_dgate, "DG"); PRINTCMUADDR(v_smask, cmu->v_flags & VF_SMASK ? "SM" : "SM*"); PRINTCMUADDR(v_dns1, "NS1"); PRINTCMUADDR(v_dns2, "NS2"); PRINTCMUADDR(v_ins1, "IEN1"); PRINTCMUADDR(v_ins2, "IEN2"); PRINTCMUADDR(v_ts1, "TS1"); PRINTCMUADDR(v_ts2, "TS2"); return; trunc: fputs(tstr, stdout); #undef PRINTCMUADDR } tcpdump-3.7.2/print-cdp.c0100644000076500000240000001374107351470744014425 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Code by Gert Doering, SpaceNet GmbH, gert@space.net * * Reference documentation: * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.11 2001/09/17 21:57:56 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ static int cdp_print_addr(const u_char *, int); static int cdp_print_prefixes(const u_char *, int); void cdp_print(const u_char *p, u_int length, u_int caplen, const u_char *esrc, const u_char *edst) { u_int i; int type, len; /* Cisco Discovery Protocol */ if (caplen < 4) { (void)printf("[|cdp]"); return; } i = 0; /* CDP data starts at offset 0 */ printf("CDP v%u, ttl=%us", p[i], p[i + 1]); i += 4; /* skip version, TTL and chksum */ while (i < length) { if (i + 4 > caplen) goto trunc; type = (p[i] << 8) + p[i + 1]; len = (p[i + 2] << 8) + p[i + 3]; if (vflag > 1) printf("\n\t"); if (vflag) printf(" %02x/%02x", type, len); if (i + len > caplen) goto trunc; switch (type) { case 0x00: printf(" Goodbye"); break; case 0x01: printf(" DevID '%.*s'", len - 4, p + i + 4); break; case 0x02: printf(" Addr"); if (cdp_print_addr(p + i + 4, len - 4) < 0) goto trunc; break; case 0x03: printf(" PortID '%.*s'", len - 4, p + i + 4); break; case 0x04: printf(" CAP 0x%02x", (unsigned) p[i + 7]); break; case 0x05: if (vflag > 1) printf(" Version:\n%.*s", len - 4, p + i + 4); else printf(" Version: (suppressed)"); break; case 0x06: printf(" Platform: '%.*s'", len - 4, p + i + 4); break; case 0x07: if (cdp_print_prefixes(p + i + 4, len - 4) < 0) goto trunc; break; case 0x09: /* guess - not documented */ printf(" VTP Management Domain: '%.*s'", len - 4, p + i + 4); break; case 0x0a: /* guess - not documented */ printf(" Native VLAN ID: %d", (p[i + 4] << 8) + p[i + 4 + 1] - 1); break; case 0x0b: /* guess - not documented */ printf(" Duplex: %s", p[i + 4] ? "full": "half"); break; default: printf(" unknown field type %02x, len %d", type, len); break; } /* avoid infinite loop */ if (len == 0) break; i += len; } return; trunc: printf("[|cdp]"); } /* * Protocol type values. * * PT_NLPID means that the protocol type field contains an OSI NLPID. * * PT_IEEE_802_2 means that the protocol type field contains an IEEE 802.2 * LLC header that specifies that the payload is for that protocol. */ #define PT_NLPID 1 /* OSI NLPID */ #define PT_IEEE_802_2 2 /* IEEE 802.2 LLC header */ static int cdp_print_addr(const u_char * p, int l) { int pt, pl, al, num; const u_char *endp = p + l; #ifdef INET6 static u_char prot_ipv6[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd }; #endif num = EXTRACT_32BITS(p); p += 4; printf(" (%d): ", num); while (p < endp && num >= 0) { if (p + 2 > endp) goto trunc; pt = p[0]; /* type of "protocol" field */ pl = p[1]; /* length of "protocol" field */ p += 2; if (p + pl + 2 > endp) goto trunc; al = EXTRACT_16BITS(&p[pl]); /* address length */ if (pt == PT_NLPID && pl == 1 && *p == 0xcc && al == 4) { /* * IPv4: protocol type = NLPID, protocol length = 1 * (1-byte NLPID), protocol = 0xcc (NLPID for IPv4), * address length = 4 */ p += 3; if (p + 4 > endp) goto trunc; printf("IPv4 %u.%u.%u.%u", p[0], p[1], p[2], p[3]); p += 4; } #ifdef INET6 else if (pt == PT_IEEE_802_2 && pl == 8 && memcmp(p, prot_ipv6, 8) == 0 && al == 16) { /* * IPv6: protocol type = IEEE 802.2 header, * protocol length = 8 (size of LLC+SNAP header), * protocol = LLC+SNAP header with the IPv6 * Ethertype, address length = 16 */ p += 10; if (p + al > endp) goto trunc; printf("IPv6 %s", ip6addr_string(p)); p += al; } #endif else { /* * Generic case: just print raw data */ if (p + pl > endp) goto trunc; printf("pt=0x%02x, pl=%d, pb=", *(p - 2), pl); while (pl-- > 0) printf(" %02x", *p++); if (p + 2 > endp) goto trunc; al = (*p << 8) + *(p + 1); printf(", al=%d, a=", al); p += 2; if (p + al > endp) goto trunc; while (al-- > 0) printf(" %02x", *p++); } num--; if (num) printf(" "); } return 0; trunc: return -1; } static int cdp_print_prefixes(const u_char * p, int l) { if (l % 5) goto trunc; printf(" IPv4 Prefixes (%d):", l / 5); while (l > 0) { printf(" %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]); l -= 5; p += 5; } return 0; trunc: return -1; } tcpdump-3.7.2/print-chdlc.c0100644000076500000240000001071407351470745014732 0ustar fennerstaff/* maybe it should be merged into print-ppp.c */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.13 2001/09/17 21:57:57 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "extract.h" #include "ppp.h" #include "chdlc.h" static void chdlc_slarp_print(const u_char *, u_int); /* Standard CHDLC printer */ void chdlc_if_print(u_char *user, const struct pcap_pkthdr *h, register const u_char *p) { register u_int length = h->len; register u_int caplen = h->caplen; ++infodelay; ts_print(&h->ts); /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; chdlc_print(p, length, caplen); putchar('\n'); --infodelay; if (infoprint) info(0); } void chdlc_print(register const u_char *p, u_int length, u_int caplen) { const struct ip *ip; u_int proto; if (caplen < CHDLC_HDRLEN) { printf("[|chdlc]"); return; } proto = EXTRACT_16BITS(&p[2]); if (eflag) { switch (p[0]) { case CHDLC_UNICAST: printf("unicast "); break; case CHDLC_BCAST: printf("bcast "); break; default: printf("0x%02x ", p[0]); break; } printf("%d %04x: ", length, proto); } length -= CHDLC_HDRLEN; ip = (const struct ip *)(p + CHDLC_HDRLEN); switch (proto) { case ETHERTYPE_IP: ip_print((const u_char *)ip, length); break; #ifdef INET6 case ETHERTYPE_IPV6: ip6_print((const u_char *)ip, length); break; #endif case CHDLC_TYPE_SLARP: chdlc_slarp_print((const u_char *)ip, length); break; #if 0 case CHDLC_TYPE_CDP: chdlc_cdp_print((const u_char *)ip, length); break; #endif } if (xflag) default_print((const u_char *)ip, caplen - CHDLC_HDRLEN); } struct cisco_slarp { u_int32_t code; #define SLARP_REQUEST 0 #define SLARP_REPLY 1 #define SLARP_KEEPALIVE 2 union { struct { struct in_addr addr; struct in_addr mask; u_int16_t unused[3]; } addr; struct { u_int32_t myseq; u_int32_t yourseq; u_int16_t rel; u_int16_t t1; u_int16_t t2; } keep; } un; }; #define SLARP_LEN 18 static void chdlc_slarp_print(const u_char *cp, u_int length) { const struct cisco_slarp *slarp; if (length < SLARP_LEN) { printf("[|slarp]"); return; } slarp = (const struct cisco_slarp *)cp; switch (ntohl(slarp->code)) { case SLARP_REQUEST: printf("slarp-request"); break; case SLARP_REPLY: printf("slarp-reply %s/%s", ipaddr_string(&slarp->un.addr.addr), ipaddr_string(&slarp->un.addr.mask)); break; case SLARP_KEEPALIVE: printf("slarp-keepalive my=0x%x your=0x%x ", (u_int32_t)ntohl(slarp->un.keep.myseq), (u_int32_t)ntohl(slarp->un.keep.yourseq)); printf("reliability=0x%04x t1=%d.%d", ntohs(slarp->un.keep.rel), ntohs(slarp->un.keep.t1), ntohs(slarp->un.keep.t2)); break; default: printf("slarp-0x%x unknown", (u_int32_t)ntohl(slarp->code)); break; } if (SLARP_LEN < length && vflag) printf("(trailing junk: %d bytes)", length - SLARP_LEN); } tcpdump-3.7.2/print-cip.c0100644000076500000240000000605307353454646014435 0ustar fennerstaff/* * Marko Kiiskila carnil@cs.tut.fi * * Tampere University of Technology - Telecommunications Laboratory * * Permission to use, copy, modify and distribute this * software and its documentation is hereby granted, * provided that both the copyright notice and this * permission notice appear in all copies of the software, * derivative works or modified versions, and any portions * thereof, that both notices appear in supporting * documentation, and that the use of this software is * acknowledged in any publications resulting from using * the software. * * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS * SOFTWARE. * */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.16 2001/09/23 21:52:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "ether.h" #define RFC1483LLC_LEN 8 static unsigned char rfcllc[] = { 0xaa, /* DSAP: non-ISO */ 0xaa, /* SSAP: non-ISO */ 0x03, /* Ctrl: Unnumbered Information Command PDU */ 0x00, /* OUI: EtherType */ 0x00, 0x00 }; static inline void cip_print(register const u_char *bp, int length) { /* * There is no MAC-layer header, so just print the length. */ printf("%d: ", length); } /* * This is the top level routine of the printer. 'p' is the points * to the raw header of the packet, 'tvp' is the timestamp, * 'length' is the length of the packet off the wire, and 'caplen' * is the number of bytes actually captured. */ void cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; u_short extracted_ethertype; ++infodelay; ts_print(&h->ts); if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) { printf("[|cip]"); goto out; } if (eflag) cip_print(p, length); /* * Some printers want to get back at the ethernet addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) { /* * LLC header is present. Try to print it & higher layers. */ if (llc_print(p, length, caplen, NULL, NULL, &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) cip_print(p, length); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } if (!xflag && !qflag) default_print(p, caplen); } } else { /* * LLC header is absent; treat it as just IP. */ ip_print(p, length); } if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } tcpdump-3.7.2/print-cnfp.c0100644000076500000240000001347507351470746014613 0ustar fennerstaff/* $OpenBSD: print-cnfp.c,v 1.2 1998/06/25 20:26:59 mickey Exp $ */ /* * Copyright (c) 1998 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Michael Shalayeff. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Cisco NetFlow protocol */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.8 2001/09/17 21:57:58 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include "interface.h" #include "tcp.h" struct nfhdr { u_int32_t ver_cnt; /* version [15], and # of records */ u_int32_t msys_uptime; u_int32_t utc_sec; u_int32_t utc_nsec; u_int32_t sequence; /* v5 flow sequence number */ u_int32_t reserved; /* v5 only */ }; struct nfrec { struct in_addr src_ina; struct in_addr dst_ina; struct in_addr nhop_ina; u_int32_t ifaces; /* src,dst ifaces */ u_int32_t packets; u_int32_t octets; u_int32_t start_time; /* sys_uptime value */ u_int32_t last_time; /* sys_uptime value */ u_int32_t ports; /* src,dst ports */ u_int32_t proto_tos; /* proto, tos, pad, flags(v5) */ u_int32_t asses; /* v1: flags; v5: src,dst AS */ u_int32_t masks; /* src,dst addr prefix; v6: encaps */ struct in_addr peer_nexthop; /* v6: IP address of the nexthop within the peer (FIB)*/ }; void cnfp_print(const u_char *cp, u_int len, const u_char *bp) { register const struct nfhdr *nh; register const struct nfrec *nr; register const struct ip *ip; struct protoent *pent; int nrecs, ver; time_t t; ip = (const struct ip *)bp; nh = (const struct nfhdr *)cp; if ((const u_char *)(nh + 1) > snapend) return; nrecs = ntohl(nh->ver_cnt) & 0xffff; ver = (ntohl(nh->ver_cnt) & 0xffff0000) >> 16; t = ntohl(nh->utc_sec); /* (p = ctime(&t))[24] = '\0'; */ printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver, (unsigned)ntohl(nh->msys_uptime)/1000, (unsigned)ntohl(nh->msys_uptime)%1000, (unsigned)ntohl(nh->utc_sec), (unsigned)ntohl(nh->utc_nsec)); if (ver == 5 || ver == 6) { printf("#%u, ", (unsigned)htonl(nh->sequence)); nr = (const struct nfrec *)&nh[1]; snaplen -= 24; } else { nr = (const struct nfrec *)&nh->sequence; snaplen -= 16; } printf("%2u recs", nrecs); for (; nrecs-- && (const u_char *)(nr + 1) <= snapend; nr++) { char buf[20]; char asbuf[20]; printf("\n started %u.%03u, last %u.%03u", (unsigned)ntohl(nr->start_time)/1000, (unsigned)ntohl(nr->start_time)%1000, (unsigned)ntohl(nr->last_time)/1000, (unsigned)ntohl(nr->last_time)%1000); asbuf[0] = buf[0] = '\0'; if (ver == 5 || ver == 6) { snprintf(buf, sizeof(buf), "/%u", (unsigned)(ntohl(nr->masks) >> 24) & 0xff); snprintf(asbuf, sizeof(asbuf), ":%u", (unsigned)(ntohl(nr->asses) >> 16) & 0xffff); } printf("\n %s%s%s:%u ", inet_ntoa(nr->src_ina), buf, asbuf, (unsigned)ntohl(nr->ports) >> 16); if (ver == 5 || ver ==6) { snprintf(buf, sizeof(buf), "/%d", (unsigned)(ntohl(nr->masks) >> 16) & 0xff); snprintf(asbuf, sizeof(asbuf), ":%u", (unsigned)ntohl(nr->asses) & 0xffff); } printf("> %s%s%s:%u ", inet_ntoa(nr->dst_ina), buf, asbuf, (unsigned)ntohl(nr->ports) & 0xffff); printf(">> %s\n ", inet_ntoa(nr->nhop_ina)); pent = getprotobynumber((ntohl(nr->proto_tos) >> 8) & 0xff); if (!pent || nflag) printf("%u ", (unsigned)(ntohl(nr->proto_tos) >> 8) & 0xff); else printf("%s ", pent->p_name); /* tcp flags for tcp only */ if (pent && pent->p_proto == IPPROTO_TCP) { int flags; if (ver == 1) flags = (ntohl(nr->asses) >> 24) & 0xff; else flags = (ntohl(nr->proto_tos) >> 16) & 0xff; if (flags & TH_FIN) putchar('F'); if (flags & TH_SYN) putchar('S'); if (flags & TH_RST) putchar('R'); if (flags & TH_PUSH) putchar('P'); if (flags & TH_ACK) putchar('A'); if (flags & TH_URG) putchar('U'); if (flags) putchar(' '); } buf[0]='\0'; if (ver == 6) { snprintf(buf, sizeof(buf), "(%u<>%u encaps)", (unsigned)(ntohl(nr->masks) >> 8) & 0xff, (unsigned)(ntohl(nr->masks)) & 0xff); } printf("tos %u, %u (%u octets) %s", (unsigned)ntohl(nr->proto_tos) & 0xff, (unsigned)ntohl(nr->packets), (unsigned)ntohl(nr->octets), buf); } } tcpdump-3.7.2/print-decnet.c0100644000076500000240000005206107351470747015122 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.33 2001/09/17 21:57:59 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include struct mbuf; struct rtentry; #ifdef HAVE_LIBDNET #include #endif #include #include #include #include #include #include "decnet.h" #include "extract.h" #include "interface.h" #include "addrtoname.h" /* Forwards */ static void print_decnet_ctlmsg(const union routehdr *, u_int); static void print_t_info(int); static void print_l1_routes(const char *, u_int); static void print_l2_routes(const char *, u_int); static void print_i_info(int); static void print_elist(const char *, u_int); static void print_nsp(const u_char *, u_int); static void print_reason(int); #ifdef PRINT_NSPDATA static void pdata(u_char *, int); #endif #ifdef HAVE_LIBDNET extern char *dnet_htoa(struct dn_naddr *); #endif void decnet_print(register const u_char *ap, register u_int length, register u_int caplen) { static union routehdr rhcopy; register union routehdr *rhp = &rhcopy; register int mflags; int dst, src, hops; u_int rhlen, nsplen, pktlen; const u_char *nspp; if (length < sizeof(struct shorthdr)) { (void)printf("[|decnet]"); return; } pktlen = EXTRACT_LE_16BITS(ap); rhlen = min(length, caplen); rhlen = min(rhlen, sizeof(*rhp)); memcpy((char *)rhp, (char *)&(ap[sizeof(short)]), rhlen); mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); if (mflags & RMF_PAD) { /* pad bytes of some sort in front of message */ u_int padlen = mflags & RMF_PADMASK; if (vflag) (void) printf("[pad:%d] ", padlen); ap += padlen; length -= padlen; caplen -= padlen; rhlen = min(length, caplen); rhlen = min(rhlen, sizeof(*rhp)); memcpy((char *)rhp, (char *)&(ap[sizeof(short)]), rhlen); mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); } if (mflags & RMF_FVER) { (void) printf("future-version-decnet"); default_print(ap, length); return; } /* is it a control message? */ if (mflags & RMF_CTLMSG) { print_decnet_ctlmsg(rhp, min(length, caplen)); return; } switch (mflags & RMF_MASK) { case RMF_LONG: dst = EXTRACT_LE_16BITS(rhp->rh_long.lg_dst.dne_remote.dne_nodeaddr); src = EXTRACT_LE_16BITS(rhp->rh_long.lg_src.dne_remote.dne_nodeaddr); hops = EXTRACT_LE_8BITS(rhp->rh_long.lg_visits); nspp = &(ap[sizeof(short) + sizeof(struct longhdr)]); nsplen = min((length - sizeof(struct longhdr)), (caplen - sizeof(struct longhdr))); break; case RMF_SHORT: dst = EXTRACT_LE_16BITS(rhp->rh_short.sh_dst); src = EXTRACT_LE_16BITS(rhp->rh_short.sh_src); hops = (EXTRACT_LE_8BITS(rhp->rh_short.sh_visits) & VIS_MASK)+1; nspp = &(ap[sizeof(short) + sizeof(struct shorthdr)]); nsplen = min((length - sizeof(struct shorthdr)), (caplen - sizeof(struct shorthdr))); break; default: (void) printf("unknown message flags under mask"); default_print((u_char *)ap, length); return; } (void)printf("%s > %s %d ", dnaddr_string(src), dnaddr_string(dst), pktlen); if (vflag) { if (mflags & RMF_RQR) (void)printf("RQR "); if (mflags & RMF_RTS) (void)printf("RTS "); if (mflags & RMF_IE) (void)printf("IE "); (void)printf("%d hops ", hops); } print_nsp(nspp, nsplen); } static void print_decnet_ctlmsg(register const union routehdr *rhp, u_int length) { int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); register union controlmsg *cmp = (union controlmsg *)rhp; int src, dst, info, blksize, eco, ueco, hello, other, vers; etheraddr srcea, rtea; int priority; char *rhpx = (char *)rhp; switch (mflags & RMF_CTLMASK) { case RMF_INIT: (void)printf("init "); src = EXTRACT_LE_16BITS(cmp->cm_init.in_src); info = EXTRACT_LE_8BITS(cmp->cm_init.in_info); blksize = EXTRACT_LE_16BITS(cmp->cm_init.in_blksize); vers = EXTRACT_LE_8BITS(cmp->cm_init.in_vers); eco = EXTRACT_LE_8BITS(cmp->cm_init.in_eco); ueco = EXTRACT_LE_8BITS(cmp->cm_init.in_ueco); hello = EXTRACT_LE_16BITS(cmp->cm_init.in_hello); print_t_info(info); (void)printf( "src %sblksize %d vers %d eco %d ueco %d hello %d", dnaddr_string(src), blksize, vers, eco, ueco, hello); break; case RMF_VER: (void)printf("verification "); src = EXTRACT_LE_16BITS(cmp->cm_ver.ve_src); other = EXTRACT_LE_8BITS(cmp->cm_ver.ve_fcnval); (void)printf("src %s fcnval %o", dnaddr_string(src), other); break; case RMF_TEST: (void)printf("test "); src = EXTRACT_LE_16BITS(cmp->cm_test.te_src); other = EXTRACT_LE_8BITS(cmp->cm_test.te_data); (void)printf("src %s data %o", dnaddr_string(src), other); break; case RMF_L1ROUT: (void)printf("lev-1-routing "); src = EXTRACT_LE_16BITS(cmp->cm_l1rou.r1_src); (void)printf("src %s ", dnaddr_string(src)); print_l1_routes(&(rhpx[sizeof(struct l1rout)]), length - sizeof(struct l1rout)); break; case RMF_L2ROUT: (void)printf("lev-2-routing "); src = EXTRACT_LE_16BITS(cmp->cm_l2rout.r2_src); (void)printf("src %s ", dnaddr_string(src)); print_l2_routes(&(rhpx[sizeof(struct l2rout)]), length - sizeof(struct l2rout)); break; case RMF_RHELLO: (void)printf("router-hello "); vers = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_vers); eco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_eco); ueco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_ueco); memcpy((char *)&srcea, (char *)&(cmp->cm_rhello.rh_src), sizeof(srcea)); src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr); info = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_info); blksize = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_blksize); priority = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_priority); hello = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_hello); print_i_info(info); (void)printf( "vers %d eco %d ueco %d src %s blksize %d pri %d hello %d", vers, eco, ueco, dnaddr_string(src), blksize, priority, hello); print_elist(&(rhpx[sizeof(struct rhellomsg)]), length - sizeof(struct rhellomsg)); break; case RMF_EHELLO: (void)printf("endnode-hello "); vers = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_vers); eco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_eco); ueco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_ueco); memcpy((char *)&srcea, (char *)&(cmp->cm_ehello.eh_src), sizeof(srcea)); src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr); info = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_info); blksize = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_blksize); /*seed*/ memcpy((char *)&rtea, (char *)&(cmp->cm_ehello.eh_router), sizeof(rtea)); dst = EXTRACT_LE_16BITS(rtea.dne_remote.dne_nodeaddr); hello = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_hello); other = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_data); print_i_info(info); (void)printf( "vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o", vers, eco, ueco, dnaddr_string(src), blksize, dnaddr_string(dst), hello, other); break; default: (void)printf("unknown control message"); default_print((u_char *)rhp, length); break; } } static void print_t_info(int info) { int ntype = info & 3; switch (ntype) { case 0: (void)printf("reserved-ntype? "); break; case TI_L2ROUT: (void)printf("l2rout "); break; case TI_L1ROUT: (void)printf("l1rout "); break; case TI_ENDNODE: (void)printf("endnode "); break; } if (info & TI_VERIF) (void)printf("verif "); if (info & TI_BLOCK) (void)printf("blo "); } static void print_l1_routes(const char *rp, u_int len) { int count; int id; int info; /* The last short is a checksum */ while (len > (3 * sizeof(short))) { count = EXTRACT_LE_16BITS(rp); if (count > 1024) return; /* seems to be bogus from here on */ rp += sizeof(short); len -= sizeof(short); id = EXTRACT_LE_16BITS(rp); rp += sizeof(short); len -= sizeof(short); info = EXTRACT_LE_16BITS(rp); rp += sizeof(short); len -= sizeof(short); (void)printf("{ids %d-%d cost %d hops %d} ", id, id + count, RI_COST(info), RI_HOPS(info)); } } static void print_l2_routes(const char *rp, u_int len) { int count; int area; int info; /* The last short is a checksum */ while (len > (3 * sizeof(short))) { count = EXTRACT_LE_16BITS(rp); if (count > 1024) return; /* seems to be bogus from here on */ rp += sizeof(short); len -= sizeof(short); area = EXTRACT_LE_16BITS(rp); rp += sizeof(short); len -= sizeof(short); info = EXTRACT_LE_16BITS(rp); rp += sizeof(short); len -= sizeof(short); (void)printf("{areas %d-%d cost %d hops %d} ", area, area + count, RI_COST(info), RI_HOPS(info)); } } static void print_i_info(int info) { int ntype = info & II_TYPEMASK; switch (ntype) { case 0: (void)printf("reserved-ntype? "); break; case II_L2ROUT: (void)printf("l2rout "); break; case II_L1ROUT: (void)printf("l1rout "); break; case II_ENDNODE: (void)printf("endnode "); break; } if (info & II_VERIF) (void)printf("verif "); if (info & II_NOMCAST) (void)printf("nomcast "); if (info & II_BLOCK) (void)printf("blo "); } static void print_elist(const char *elp, u_int len) { /* Not enough examples available for me to debug this */ } static void print_nsp(const u_char *nspp, u_int nsplen) { const struct nsphdr *nsphp = (struct nsphdr *)nspp; int dst, src, flags; flags = EXTRACT_LE_8BITS(nsphp->nh_flags); dst = EXTRACT_LE_16BITS(nsphp->nh_dst); src = EXTRACT_LE_16BITS(nsphp->nh_src); switch (flags & NSP_TYPEMASK) { case MFT_DATA: switch (flags & NSP_SUBMASK) { case MFS_BOM: case MFS_MOM: case MFS_EOM: case MFS_BOM+MFS_EOM: printf("data %d>%d ", src, dst); { struct seghdr *shp = (struct seghdr *)nspp; int ack; #ifdef PRINT_NSPDATA u_char *dp; #endif u_int data_off = sizeof(struct minseghdr); ack = EXTRACT_LE_16BITS(shp->sh_seq[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) (void)printf("nak %d ", ack & SGQ_MASK); else (void)printf("ack %d ", ack & SGQ_MASK); ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); data_off += sizeof(short); if (ack & SGQ_OACK) { /* ackoth field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) (void)printf("onak %d ", ack & SGQ_MASK); else (void)printf("oack %d ", ack & SGQ_MASK); ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); data_off += sizeof(short); } } (void)printf("seg %d ", ack & SGQ_MASK); #ifdef PRINT_NSPDATA dp = &(nspp[data_off]); pdata(dp, 10); #endif } break; case MFS_ILS+MFS_INT: printf("intr "); { struct seghdr *shp = (struct seghdr *)nspp; int ack; #ifdef PRINT_NSPDATA u_char *dp; #endif u_int data_off = sizeof(struct minseghdr); ack = EXTRACT_LE_16BITS(shp->sh_seq[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) (void)printf("nak %d ", ack & SGQ_MASK); else (void)printf("ack %d ", ack & SGQ_MASK); ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); data_off += sizeof(short); if (ack & SGQ_OACK) { /* ackdat field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) (void)printf("nakdat %d ", ack & SGQ_MASK); else (void)printf("ackdat %d ", ack & SGQ_MASK); ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); data_off += sizeof(short); } } (void)printf("seg %d ", ack & SGQ_MASK); #ifdef PRINT_NSPDATA dp = &(nspp[data_off]); pdata(dp, 10); #endif } break; case MFS_ILS: (void)printf("link-service %d>%d ", src, dst); { struct seghdr *shp = (struct seghdr *)nspp; struct lsmsg *lsmp = (struct lsmsg *)&(nspp[sizeof(struct seghdr)]); int ack; int lsflags, fcval; ack = EXTRACT_LE_16BITS(shp->sh_seq[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) (void)printf("nak %d ", ack & SGQ_MASK); else (void)printf("ack %d ", ack & SGQ_MASK); ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); if (ack & SGQ_OACK) { /* ackdat field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) (void)printf("nakdat %d ", ack & SGQ_MASK); else (void)printf("ackdat %d ", ack & SGQ_MASK); ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); } } (void)printf("seg %d ", ack & SGQ_MASK); lsflags = EXTRACT_LE_8BITS(lsmp->ls_lsflags); fcval = EXTRACT_LE_8BITS(lsmp->ls_fcval); switch (lsflags & LSI_MASK) { case LSI_DATA: (void)printf("dat seg count %d ", fcval); switch (lsflags & LSM_MASK) { case LSM_NOCHANGE: break; case LSM_DONOTSEND: (void)printf("donotsend-data "); break; case LSM_SEND: (void)printf("send-data "); break; default: (void)printf("reserved-fcmod? %x", lsflags); break; } break; case LSI_INTR: (void)printf("intr req count %d ", fcval); break; default: (void)printf("reserved-fcval-int? %x", lsflags); break; } } break; default: (void)printf("reserved-subtype? %x %d > %d", flags, src, dst); break; } break; case MFT_ACK: switch (flags & NSP_SUBMASK) { case MFS_DACK: (void)printf("data-ack %d>%d ", src, dst); { struct ackmsg *amp = (struct ackmsg *)nspp; int ack; ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) (void)printf("nak %d ", ack & SGQ_MASK); else (void)printf("ack %d ", ack & SGQ_MASK); ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]); if (ack & SGQ_OACK) { /* ackoth field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) (void)printf("onak %d ", ack & SGQ_MASK); else (void)printf("oack %d ", ack & SGQ_MASK); } } } break; case MFS_IACK: (void)printf("ils-ack %d>%d ", src, dst); { struct ackmsg *amp = (struct ackmsg *)nspp; int ack; ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) (void)printf("nak %d ", ack & SGQ_MASK); else (void)printf("ack %d ", ack & SGQ_MASK); ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]); if (ack & SGQ_OACK) { /* ackdat field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) (void)printf("nakdat %d ", ack & SGQ_MASK); else (void)printf("ackdat %d ", ack & SGQ_MASK); } } } break; case MFS_CACK: (void)printf("conn-ack %d", dst); break; default: (void)printf("reserved-acktype? %x %d > %d", flags, src, dst); break; } break; case MFT_CTL: switch (flags & NSP_SUBMASK) { case MFS_CI: case MFS_RCI: if ((flags & NSP_SUBMASK) == MFS_CI) (void)printf("conn-initiate "); else (void)printf("retrans-conn-initiate "); (void)printf("%d>%d ", src, dst); { struct cimsg *cimp = (struct cimsg *)nspp; int services, info, segsize; #ifdef PRINT_NSPDATA u_char *dp; #endif services = EXTRACT_LE_8BITS(cimp->ci_services); info = EXTRACT_LE_8BITS(cimp->ci_info); segsize = EXTRACT_LE_16BITS(cimp->ci_segsize); switch (services & COS_MASK) { case COS_NONE: break; case COS_SEGMENT: (void)printf("seg "); break; case COS_MESSAGE: (void)printf("msg "); break; case COS_CRYPTSER: (void)printf("crypt "); break; } switch (info & COI_MASK) { case COI_32: (void)printf("ver 3.2 "); break; case COI_31: (void)printf("ver 3.1 "); break; case COI_40: (void)printf("ver 4.0 "); break; case COI_41: (void)printf("ver 4.1 "); break; } (void)printf("segsize %d ", segsize); #ifdef PRINT_NSPDATA dp = &(nspp[sizeof(struct cimsg)]); pdata(dp, nsplen - sizeof(struct cimsg)); #endif } break; case MFS_CC: (void)printf("conn-confirm %d>%d ", src, dst); { struct ccmsg *ccmp = (struct ccmsg *)nspp; int services, info; u_int segsize, optlen; #ifdef PRINT_NSPDATA u_char *dp; #endif services = EXTRACT_LE_8BITS(ccmp->cc_services); info = EXTRACT_LE_8BITS(ccmp->cc_info); segsize = EXTRACT_LE_16BITS(ccmp->cc_segsize); optlen = EXTRACT_LE_8BITS(ccmp->cc_optlen); switch (services & COS_MASK) { case COS_NONE: break; case COS_SEGMENT: (void)printf("seg "); break; case COS_MESSAGE: (void)printf("msg "); break; case COS_CRYPTSER: (void)printf("crypt "); break; } switch (info & COI_MASK) { case COI_32: (void)printf("ver 3.2 "); break; case COI_31: (void)printf("ver 3.1 "); break; case COI_40: (void)printf("ver 4.0 "); break; case COI_41: (void)printf("ver 4.1 "); break; } (void)printf("segsize %d ", segsize); if (optlen) { (void)printf("optlen %d ", optlen); #ifdef PRINT_NSPDATA optlen = min(optlen, nsplen - sizeof(struct ccmsg)); dp = &(nspp[sizeof(struct ccmsg)]); pdata(dp, optlen); #endif } } break; case MFS_DI: (void)printf("disconn-initiate %d>%d ", src, dst); { struct dimsg *dimp = (struct dimsg *)nspp; int reason; u_int optlen; #ifdef PRINT_NSPDATA u_char *dp; #endif reason = EXTRACT_LE_16BITS(dimp->di_reason); optlen = EXTRACT_LE_8BITS(dimp->di_optlen); print_reason(reason); if (optlen) { (void)printf("optlen %d ", optlen); #ifdef PRINT_NSPDATA optlen = min(optlen, nsplen - sizeof(struct dimsg)); dp = &(nspp[sizeof(struct dimsg)]); pdata(dp, optlen); #endif } } break; case MFS_DC: (void)printf("disconn-confirm %d>%d ", src, dst); { struct dcmsg *dcmp = (struct dcmsg *)nspp; int reason; reason = EXTRACT_LE_16BITS(dcmp->dc_reason); print_reason(reason); } break; default: (void)printf("reserved-ctltype? %x %d > %d", flags, src, dst); break; } break; default: (void)printf("reserved-type? %x %d > %d", flags, src, dst); break; } } static struct tok reason2str[] = { { UC_OBJREJECT, "object rejected connect" }, { UC_RESOURCES, "insufficient resources" }, { UC_NOSUCHNODE, "unrecognized node name" }, { DI_SHUT, "node is shutting down" }, { UC_NOSUCHOBJ, "unrecognized object" }, { UC_INVOBJFORMAT, "invalid object name format" }, { UC_OBJTOOBUSY, "object too busy" }, { DI_PROTOCOL, "protocol error discovered" }, { DI_TPA, "third party abort" }, { UC_USERABORT, "user abort" }, { UC_INVNODEFORMAT, "invalid node name format" }, { UC_LOCALSHUT, "local node shutting down" }, { DI_LOCALRESRC, "insufficient local resources" }, { DI_REMUSERRESRC, "insufficient remote user resources" }, { UC_ACCESSREJECT, "invalid access control information" }, { DI_BADACCNT, "bad ACCOUNT information" }, { UC_NORESPONSE, "no response from object" }, { UC_UNREACHABLE, "node unreachable" }, { DC_NOLINK, "no link terminate" }, { DC_COMPLETE, "disconnect complete" }, { DI_BADIMAGE, "bad image data in connect" }, { DI_SERVMISMATCH, "cryptographic service mismatch" }, { 0, NULL } }; static void print_reason(register int reason) { printf("%s ", tok2str(reason2str, "reason-%d", reason)); } const char * dnnum_string(u_short dnaddr) { char *str; size_t siz; int area = (u_short)(dnaddr & AREAMASK) >> AREASHIFT; int node = dnaddr & NODEMASK; str = (char *)malloc(siz = sizeof("00.0000")); if (str == NULL) error("dnnum_string: malloc"); snprintf(str, siz, "%d.%d", area, node); return(str); } const char * dnname_string(u_short dnaddr) { #ifdef HAVE_LIBDNET struct dn_naddr dna; dna.a_len = sizeof(short); memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short)); return (strdup(dnet_htoa(&dna))); #else return(dnnum_string(dnaddr)); /* punt */ #endif } #ifdef PRINT_NSPDATA static void pdata(u_char *dp, u_int maxlen) { char c; u_int x = maxlen; while (x-- > 0) { c = *dp++; safeputchar(c); } } #endif tcpdump-3.7.2/print-dhcp6.c0100644000076500000240000001254107627054625014662 0ustar fennerstaff/* * Copyright (C) 1998 and 1999 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * draft-ietf-dhc-dhcpv6-22.txt */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.14.4.2 2002/06/01 23:51:12 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" /* Error Values */ #define DH6ERR_FAILURE 16 #define DH6ERR_AUTHFAIL 17 #define DH6ERR_POORLYFORMED 18 #define DH6ERR_UNAVAIL 19 #define DH6ERR_OPTUNAVAIL 20 /* Message type */ #define DH6_REPLY 7 #define DH6_INFORM_REQ 11 /* DHCP6 base packet format */ struct dhcp6 { union { u_int8_t m; u_int32_t x; } dh6_msgtypexid; struct in6_addr dh6_servaddr; /* options follow */ } __attribute__ ((__packed__)); #define dh6_msgtype dh6_msgtypexid.m #define dh6_xid dh6_msgtypexid.x #define DH6_XIDMASK 0x00ffffff /* option */ #define DH6OPT_DUID 1 /* TBD */ #define DH6OPT_DNS 11 /* TBD */ struct dhcp6opt { u_int16_t dh6opt_type; u_int16_t dh6opt_len; /* type-dependent data follows */ } __attribute__ ((__packed__)); static void dhcp6opt_print(u_char *cp, u_char *ep) { struct dhcp6opt *dh6o; u_char *tp; int i; size_t optlen; if (cp == ep) return; while (cp < ep) { if (ep - cp < sizeof(*dh6o)) goto trunc; dh6o = (struct dhcp6opt *)cp; optlen = ntohs(dh6o->dh6opt_len); if (ep - cp < sizeof(*dh6o) + optlen) goto trunc; switch (ntohs(dh6o->dh6opt_type)) { case DH6OPT_DUID: printf(" (duid"); /*)*/ if (optlen < 2) { /*(*/ printf(" ??)"); break; } tp = (u_char *)(dh6o + 1); switch (ntohs(*(u_int16_t *)tp)) { case 1: if (optlen >= 2 + 6) { printf(" hwaddr/time time %u type %u ", ntohl(*(u_int32_t *)&tp[2]), ntohs(*(u_int16_t *)&tp[6])); for (i = 8; i < optlen; i++) printf("%02x", tp[i]); /*(*/ printf(")"); } else { /*(*/ printf(" ??)"); } break; case 2: if (optlen >= 2 + 8) { printf(" vid "); for (i = 2; i < 2 + 8; i++) printf("%02x", tp[i]); /*(*/ printf(")"); } else { /*(*/ printf(" ??)"); } break; case 3: if (optlen >= 2 + 2) { printf(" hwaddr type %u ", ntohs(*(u_int16_t *)&tp[2])); for (i = 4; i < optlen; i++) printf("%02x", tp[i]); /*(*/ printf(")"); } else { /*(*/ printf(" ??)"); } } break; case DH6OPT_DNS: printf(" (dnsserver"); /*)*/ if (optlen % 16) { /*(*/ printf(" ??)"); break; } tp = (u_char *)(dh6o + 1); for (i = 0; i < optlen; i += 16) printf(" %s", ip6addr_string(&tp[i])); /*(*/ printf(")"); default: printf(" (opt-%u)", ntohs(dh6o->dh6opt_type)); break; } cp += sizeof(*dh6o) + optlen; } return; trunc: printf("[|dhcp6ext]"); } /* * Print dhcp6 packets */ void dhcp6_print(register const u_char *cp, u_int length, u_int16_t sport, u_int16_t dport) { struct dhcp6 *dh6; u_char *ep; u_char *extp; const char *name; printf("dhcp6"); ep = (u_char *)snapend; dh6 = (struct dhcp6 *)cp; TCHECK(dh6->dh6_servaddr); switch (dh6->dh6_msgtype) { case DH6_REPLY: name = "reply"; break; case DH6_INFORM_REQ: name= "inf-req"; break; default: name = NULL; break; } if (!vflag) { if (name) printf(" %s", name); else printf(" msgtype-%u", dh6->dh6_msgtype); return; } /* XXX relay agent messages have to be handled differently */ if (name) printf(" %s (", name); /*)*/ else printf(" msgtype-%u (", dh6->dh6_msgtype); /*)*/ printf("xid=%x", ntohl(dh6->dh6_xid) & DH6_XIDMASK); printf(" server=%s", ip6addr_string(&dh6->dh6_servaddr)); extp = (u_char *)(dh6 + 1); dhcp6opt_print(extp, ep); /*(*/ printf(")"); return; trunc: printf("[|dhcp6]"); } tcpdump-3.7.2/print-domain.c0100644000076500000240000003504007363765700015124 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.78 2001/10/19 09:00:48 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "nameser.h" #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ static const char *ns_ops[] = { "", " inv_q", " stat", " op3", " notify", " update", " op6", " op7", " op8", " updataA", " updateD", " updateDA", " updateM", " updateMA", " zoneInit", " zoneRef", }; static const char *ns_resp[] = { "", " FormErr", " ServFail", " NXDomain", " NotImp", " Refused", " YXDomain", " YXRRSet", " NXRRSet", " NotAuth", " NotZone", " Resp11", " Resp12", " Resp13", " Resp14", " NoChange", }; /* skip over a domain name */ static const u_char * ns_nskip(register const u_char *cp, register const u_char *bp) { register u_char i; if (!TTEST2(*cp, 1)) return (NULL); if (((i = *cp++) & INDIR_MASK) == INDIR_MASK) return (cp + 1); while (i) { if ((i & INDIR_MASK) == EDNS0_MASK) { int bitlen, bytelen; if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL) return(NULL); /* unknown ELT */ if (!TTEST2(*cp, 1)) return (NULL); if ((bitlen = *cp++) == 0) bitlen = 256; bytelen = (bitlen + 7) / 8; cp += bytelen; } else cp += i; if (!TTEST2(*cp, 1)) return (NULL); i = *cp++; } return (cp); } /* print a */ static const u_char * blabel_print(const u_char *cp) { int bitlen, slen, b; int truncated = 0; const u_char *bitp, *lim; char tc; if (!TTEST2(*cp, 1)) return(NULL); if ((bitlen = *cp) == 0) bitlen = 256; slen = (bitlen + 3) / 4; if ((lim = cp + 1 + slen) > snapend) { truncated = 1; lim = snapend; } /* print the bit string as a hex string */ printf("\\[x"); for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) printf("%02x", *bitp); if (bitp == lim) printf("..."); else if (b > 4) { tc = *bitp++; printf("%02x", tc & (0xff << (8 - b))); } else if (b > 0) { tc = *bitp++; printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b))); } printf("/%d]", bitlen); return(truncated ? NULL : lim); } static int labellen(const u_char *cp) { register u_int i; if (!TTEST2(*cp, 1)) return(-1); i = *cp; if ((i & INDIR_MASK) == EDNS0_MASK) { int bitlen, elt; if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) return(-1); if (!TTEST2(*(cp + 1), 1)) return(-1); if ((bitlen = *(cp + 1)) == 0) bitlen = 256; return(((bitlen + 7) / 8) + 1); } else return(i); } static const u_char * ns_nprint(register const u_char *cp, register const u_char *bp) { register u_int i, l; register const u_char *rp = NULL; register int compress = 0; int chars_processed; int elt; int data_size = snapend - bp; if ((l = labellen(cp)) < 0) return(NULL); if (!TTEST2(*cp, 1)) return(NULL); chars_processed = 1; if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) { compress = 0; rp = cp + l; } if (i != 0) while (i && cp < snapend) { if ((i & INDIR_MASK) == INDIR_MASK) { if (!compress) { rp = cp + 1; compress = 1; } if (!TTEST2(*cp, 1)) return(NULL); cp = bp + (((i << 8) | *cp) & 0x3fff); if ((l = labellen(cp)) < 0) return(NULL); if (!TTEST2(*cp, 1)) return(NULL); i = *cp++; chars_processed++; /* * If we've looked at every character in * the message, this pointer will make * us look at some character again, * which means we're looping. */ if (chars_processed >= data_size) { printf(""); return (NULL); } continue; } if ((i & INDIR_MASK) == EDNS0_MASK) { elt = (i & ~INDIR_MASK); switch(elt) { case EDNS0_ELT_BITLABEL: if (blabel_print(cp) == NULL) return (NULL); break; default: /* unknown ELT */ printf("", elt); return(NULL); } } else { if (fn_printn(cp, l, snapend)) return(NULL); } cp += l; chars_processed += l; putchar('.'); if ((l = labellen(cp)) < 0) return(NULL); if (!TTEST2(*cp, 1)) return(NULL); i = *cp++; chars_processed++; if (!compress) rp += l + 1; } else putchar('.'); return (rp); } /* print a */ static const u_char * ns_cprint(register const u_char *cp, register const u_char *bp) { register u_int i; if (!TTEST2(*cp, 1)) return (NULL); i = *cp++; if (fn_printn(cp, i, snapend)) return (NULL); return (cp + i); } struct tok ns_type2str[] = { { T_A, "A" }, { T_NS, "NS" }, { T_MD, "MD" }, { T_MF, "MF" }, { T_CNAME, "CNAME" }, { T_SOA, "SOA" }, { T_MB, "MB" }, { T_MG, "MG" }, { T_MR, "MR" }, { T_NULL, "NULL" }, { T_WKS, "WKS" }, { T_PTR, "PTR" }, { T_HINFO, "HINFO" }, { T_MINFO, "MINFO" }, { T_MX, "MX" }, { T_TXT, "TXT" }, { T_RP, "RP" }, { T_AFSDB, "AFSDB" }, { T_X25, "X25" }, { T_ISDN, "ISDN" }, { T_RT, "RT" }, { T_NSAP, "NSAP" }, { T_NSAP_PTR, "NSAP_PTR" }, { T_SIG, "SIG" }, { T_KEY, "KEY" }, { T_PX, "PX" }, { T_GPOS, "GPOS" }, { T_AAAA, "AAAA" }, { T_LOC, "LOC" }, { T_NXT, "NXT" }, { T_EID, "EID" }, { T_NIMLOC, "NIMLOC" }, { T_SRV, "SRV" }, { T_ATMA, "ATMA" }, { T_NAPTR, "NAPTR" }, { T_A6, "A6" }, { T_DNAME, "DNAME" }, { T_OPT, "OPT" }, { T_UINFO, "UINFO" }, { T_UID, "UID" }, { T_GID, "GID" }, { T_UNSPEC, "UNSPEC" }, { T_UNSPECA, "UNSPECA" }, { T_TKEY, "TKEY" }, { T_TSIG, "TSIG" }, { T_IXFR, "IXFR" }, { T_AXFR, "AXFR" }, { T_MAILB, "MAILB" }, { T_MAILA, "MAILA" }, { T_ANY, "ANY" }, { 0, NULL } }; struct tok ns_class2str[] = { { C_IN, "IN" }, /* Not used */ { C_CHAOS, "CHAOS" }, { C_HS, "HS" }, { C_ANY, "ANY" }, { 0, NULL } }; /* print a query */ static const u_char * ns_qprint(register const u_char *cp, register const u_char *bp) { register const u_char *np = cp; register u_int i; cp = ns_nskip(cp, bp); if (cp == NULL || !TTEST2(*cp, 4)) return(NULL); /* print the qtype and qclass (if it's not IN) */ i = *cp++ << 8; i |= *cp++; printf(" %s", tok2str(ns_type2str, "Type%d", i)); i = *cp++ << 8; i |= *cp++; if (i != C_IN) printf(" %s", tok2str(ns_class2str, "(Class %d)", i)); fputs("? ", stdout); cp = ns_nprint(np, bp); return(cp ? cp + 4 : NULL); } /* print a reply */ static const u_char * ns_rprint(register const u_char *cp, register const u_char *bp) { register u_int class; register u_short typ, len; register const u_char *rp; if (vflag) { putchar(' '); if ((cp = ns_nprint(cp, bp)) == NULL) return NULL; } else cp = ns_nskip(cp, bp); if (cp == NULL || !TTEST2(*cp, 10)) return (snapend); /* print the type/qtype and class (if it's not IN) */ typ = *cp++ << 8; typ |= *cp++; class = *cp++ << 8; class |= *cp++; if (class != C_IN && typ != T_OPT) printf(" %s", tok2str(ns_class2str, "(Class %d)", class)); /* ignore ttl */ cp += 4; len = *cp++ << 8; len |= *cp++; rp = cp + len; printf(" %s", tok2str(ns_type2str, "Type%d", typ)); if (rp > snapend) return(NULL); switch (typ) { case T_A: if (!TTEST2(*cp, sizeof(struct in_addr))) return(NULL); printf(" %s", ipaddr_string(cp)); break; case T_NS: case T_CNAME: case T_PTR: #ifdef T_DNAME case T_DNAME: #endif putchar(' '); if (ns_nprint(cp, bp) == NULL) return(NULL); break; case T_SOA: if (!vflag) break; putchar(' '); if ((cp = ns_nprint(cp, bp)) == NULL) return(NULL); putchar(' '); if ((cp = ns_nprint(cp, bp)) == NULL) return(NULL); if (!TTEST2(*cp, 5 * 4)) return(NULL); printf(" %u", EXTRACT_32BITS(cp)); cp += 4; printf(" %u", EXTRACT_32BITS(cp)); cp += 4; printf(" %u", EXTRACT_32BITS(cp)); cp += 4; printf(" %u", EXTRACT_32BITS(cp)); cp += 4; printf(" %u", EXTRACT_32BITS(cp)); cp += 4; break; case T_MX: putchar(' '); if (!TTEST2(*cp, 2)) return(NULL); if (ns_nprint(cp + 2, bp) == NULL) return(NULL); printf(" %d", EXTRACT_16BITS(cp)); break; case T_TXT: putchar(' '); (void)ns_cprint(cp, bp); break; #ifdef INET6 case T_AAAA: if (!TTEST2(*cp, sizeof(struct in6_addr))) return(NULL); printf(" %s", ip6addr_string(cp)); break; case T_A6: { struct in6_addr a; int pbit, pbyte; if (!TTEST2(*cp, 1)) return(NULL); pbit = *cp; pbyte = (pbit & ~7) / 8; if (pbit > 128) { printf(" %u(bad plen)", pbit); break; } else if (pbit < 128) { if (!TTEST2(*(cp + 1), sizeof(a) - pbyte)) return(NULL); memset(&a, 0, sizeof(a)); memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte); printf(" %u %s", pbit, ip6addr_string(&a)); } if (pbit > 0) { putchar(' '); if (ns_nprint(cp + 1 + sizeof(a) - pbyte, bp) == NULL) return(NULL); } break; } #endif /*INET6*/ case T_OPT: printf(" UDPsize=%u", class); break; case T_UNSPECA: /* One long string */ if (!TTEST2(*cp, len)) return(NULL); if (fn_printn(cp, len, snapend)) return(NULL); break; case T_TSIG: { if (cp + len > snapend) return(NULL); if (!vflag) break; putchar(' '); if ((cp = ns_nprint(cp, bp)) == NULL) return(NULL); cp += 6; if (!TTEST2(*cp, 2)) return(NULL); printf(" fudge=%u", EXTRACT_16BITS(cp)); cp += 2; if (!TTEST2(*cp, 2)) return(NULL); printf(" maclen=%u", EXTRACT_16BITS(cp)); cp += 2 + EXTRACT_16BITS(cp); if (!TTEST2(*cp, 2)) return(NULL); printf(" origid=%u", EXTRACT_16BITS(cp)); cp += 2; if (!TTEST2(*cp, 2)) return(NULL); printf(" error=%u", EXTRACT_16BITS(cp)); cp += 2; if (!TTEST2(*cp, 2)) return(NULL); printf(" otherlen=%u", EXTRACT_16BITS(cp)); cp += 2; } } return (rp); /* XXX This isn't always right */ } void ns_print(register const u_char *bp, u_int length) { register const HEADER *np; register int qdcount, ancount, nscount, arcount; register const u_char *cp; np = (const HEADER *)bp; TCHECK(*np); /* get the byte-order right */ qdcount = ntohs(np->qdcount); ancount = ntohs(np->ancount); nscount = ntohs(np->nscount); arcount = ntohs(np->arcount); if (DNS_QR(np)) { /* this is a response */ printf(" %d%s%s%s%s%s%s", ntohs(np->id), ns_ops[DNS_OPCODE(np)], ns_resp[DNS_RCODE(np)], DNS_AA(np)? "*" : "", DNS_RA(np)? "" : "-", DNS_TC(np)? "|" : "", DNS_CD(np)? "%" : ""); if (qdcount != 1) printf(" [%dq]", qdcount); /* Print QUESTION section on -vv */ cp = (const u_char *)(np + 1); while (qdcount--) { if (qdcount < ntohs(np->qdcount) - 1) putchar(','); if (vflag > 1) { fputs(" q:", stdout); if ((cp = ns_qprint(cp, bp)) == NULL) goto trunc; } else { if ((cp = ns_nskip(cp, bp)) == NULL) goto trunc; cp += 4; /* skip QTYPE and QCLASS */ } } printf(" %d/%d/%d", ancount, nscount, arcount); if (ancount--) { if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; while (cp < snapend && ancount--) { putchar(','); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; } } if (ancount > 0) goto trunc; /* Print NS and AR sections on -vv */ if (vflag > 1) { if (cp < snapend && nscount--) { fputs(" ns:", stdout); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; while (cp < snapend && nscount--) { putchar(','); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; } } if (nscount > 0) goto trunc; if (cp < snapend && arcount--) { fputs(" ar:", stdout); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; while (cp < snapend && arcount--) { putchar(','); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; } } if (arcount > 0) goto trunc; } } else { /* this is a request */ printf(" %d%s%s%s", ntohs(np->id), ns_ops[DNS_OPCODE(np)], DNS_RD(np) ? "+" : "", DNS_AD(np) ? "$" : ""); /* any weirdness? */ if (*(((u_short *)np)+1) & htons(0x6cf)) printf(" [b2&3=0x%x]", ntohs(*(((u_short *)np)+1))); if (DNS_OPCODE(np) == IQUERY) { if (qdcount) printf(" [%dq]", qdcount); if (ancount != 1) printf(" [%da]", ancount); } else { if (ancount) printf(" [%da]", ancount); if (qdcount != 1) printf(" [%dq]", qdcount); } if (nscount) printf(" [%dn]", nscount); if (arcount) printf(" [%dau]", arcount); cp = (const u_char *)(np + 1); if (qdcount--) { cp = ns_qprint(cp, (const u_char *)np); if (!cp) goto trunc; while (cp < snapend && qdcount--) { cp = ns_qprint((const u_char *)cp, (const u_char *)np); if (!cp) goto trunc; } } if (qdcount > 0) goto trunc; /* Print remaining sections on -vv */ if (vflag > 1) { if (ancount--) { if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; while (cp < snapend && ancount--) { putchar(','); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; } } if (ancount > 0) goto trunc; if (cp < snapend && nscount--) { fputs(" ns:", stdout); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; while (nscount-- && cp < snapend) { putchar(','); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; } } if (nscount > 0) goto trunc; if (cp < snapend && arcount--) { fputs(" ar:", stdout); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; while (cp < snapend && arcount--) { putchar(','); if ((cp = ns_rprint(cp, bp)) == NULL) goto trunc; } } if (arcount > 0) goto trunc; } } printf(" (%d)", length); return; trunc: printf("[|domain]"); return; } tcpdump-3.7.2/print-dvmrp.c0100644000076500000240000002016107276423554015004 0ustar fennerstaff/* * Copyright (c) 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.21 2001/05/10 05:30:20 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include "interface.h" #include "extract.h" #include "addrtoname.h" /* * DVMRP message types and flag values shamelessly stolen from * mrouted/dvmrp.h. */ #define DVMRP_PROBE 1 /* for finding neighbors */ #define DVMRP_REPORT 2 /* for reporting some or all routes */ #define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */ /* of this router's neighbors */ #define DVMRP_NEIGHBORS 4 /* response to such a request */ #define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */ #define DVMRP_NEIGHBORS2 6 #define DVMRP_PRUNE 7 /* prune message */ #define DVMRP_GRAFT 8 /* graft message */ #define DVMRP_GRAFT_ACK 9 /* graft acknowledgement */ /* * 'flags' byte values in DVMRP_NEIGHBORS2 reply. */ #define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */ #define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */ #define DVMRP_NF_DOWN 0x10 /* kernel state of interface */ #define DVMRP_NF_DISABLED 0x20 /* administratively disabled */ #define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */ static void print_probe(const u_char *, const u_char *, u_int); static void print_report(const u_char *, const u_char *, u_int); static void print_neighbors(const u_char *, const u_char *, u_int); static void print_neighbors2(const u_char *, const u_char *, u_int); static void print_prune(const u_char *, const u_char *, u_int); static void print_graft(const u_char *, const u_char *, u_int); static void print_graft_ack(const u_char *, const u_char *, u_int); static u_int32_t target_level; void dvmrp_print(register const u_char *bp, register u_int len) { register const u_char *ep; register u_char type; ep = (const u_char *)snapend; if (bp >= ep) return; type = bp[1]; /* Skip IGMP header */ bp += 8; len -= 8; switch (type) { case DVMRP_PROBE: printf(" Probe"); if (vflag) print_probe(bp, ep, len); break; case DVMRP_REPORT: printf(" Report"); if (vflag > 1) print_report(bp, ep, len); break; case DVMRP_ASK_NEIGHBORS: printf(" Ask-neighbors(old)"); break; case DVMRP_NEIGHBORS: printf(" Neighbors(old)"); print_neighbors(bp, ep, len); break; case DVMRP_ASK_NEIGHBORS2: printf(" Ask-neighbors2"); break; case DVMRP_NEIGHBORS2: printf(" Neighbors2"); /* * extract version and capabilities from IGMP group * address field */ bp -= 4; target_level = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3]; bp += 4; print_neighbors2(bp, ep, len); break; case DVMRP_PRUNE: printf(" Prune"); print_prune(bp, ep, len); break; case DVMRP_GRAFT: printf(" Graft"); print_graft(bp, ep, len); break; case DVMRP_GRAFT_ACK: printf(" Graft-ACK"); print_graft_ack(bp, ep, len); break; default: printf(" [type %d]", type); break; } } static void print_report(register const u_char *bp, register const u_char *ep, register u_int len) { register u_int32_t mask, origin; register int metric, i, width, done; while (len > 0) { if (len < 3) { printf(" [|]"); return; } mask = (u_int32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2]; width = 1; if (bp[0]) width = 2; if (bp[1]) width = 3; if (bp[2]) width = 4; printf("\n\tMask %s", intoa(htonl(mask))); bp += 3; len -= 3; do { if (bp + width + 1 > ep) { printf(" [|]"); return; } if (len < width + 1) { printf("\n\t [Truncated Report]"); return; } origin = 0; for (i = 0; i < width; ++i) origin = origin << 8 | *bp++; for ( ; i < 4; ++i) origin <<= 8; metric = *bp++; done = metric & 0x80; metric &= 0x7f; printf("\n\t %s metric %d", intoa(htonl(origin)), metric); len -= width + 1; } while (!done); } } static void print_probe(register const u_char *bp, register const u_char *ep, register u_int len) { register u_int32_t genid; TCHECK2(bp[0], 4); if ((len < 4) || ((bp + 4) > ep)) { /* { (ctags) */ printf(" [|}"); return; } genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3]; bp += 4; len -= 4; if (vflag > 1) printf("\n\t"); else printf(" "); printf("genid %u", genid); if (vflag < 2) return; while ((len > 0) && (bp < ep)) { TCHECK2(bp[0], 4); printf("\n\tneighbor %s", ipaddr_string(bp)); bp += 4; len -= 4; } return; trunc: (void)printf("[|dvmrp]"); } static void print_neighbors(register const u_char *bp, register const u_char *ep, register u_int len) { const u_char *laddr; register u_char metric; register u_char thresh; register int ncount; while (len > 0 && bp < ep) { TCHECK2(bp[0], 7); laddr = bp; bp += 4; metric = *bp++; thresh = *bp++; ncount = *bp++; len -= 7; while (--ncount >= 0) { TCHECK2(bp[0], 4); printf(" [%s ->", ipaddr_string(laddr)); printf(" %s, (%d/%d)]", ipaddr_string(bp), metric, thresh); bp += 4; len -= 4; } } return; trunc: (void)printf("[|dvmrp]"); } static void print_neighbors2(register const u_char *bp, register const u_char *ep, register u_int len) { const u_char *laddr; register u_char metric, thresh, flags; register int ncount; printf(" (v %d.%d):", (int)target_level & 0xff, (int)(target_level >> 8) & 0xff); while (len > 0 && bp < ep) { TCHECK2(bp[0], 8); laddr = bp; bp += 4; metric = *bp++; thresh = *bp++; flags = *bp++; ncount = *bp++; len -= 8; while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) { printf(" [%s -> ", ipaddr_string(laddr)); printf("%s (%d/%d", ipaddr_string(bp), metric, thresh); if (flags & DVMRP_NF_TUNNEL) printf("/tunnel"); if (flags & DVMRP_NF_SRCRT) printf("/srcrt"); if (flags & DVMRP_NF_QUERIER) printf("/querier"); if (flags & DVMRP_NF_DISABLED) printf("/disabled"); if (flags & DVMRP_NF_DOWN) printf("/down"); printf(")]"); bp += 4; len -= 4; } if (ncount != -1) { printf(" [|]"); return; } } return; trunc: (void)printf("[|dvmrp]"); } static void print_prune(register const u_char *bp, register const u_char *ep, register u_int len) { TCHECK2(bp[0], 12); printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4)); bp += 8; (void)printf(" timer "); relts_print(EXTRACT_32BITS(bp)); return; trunc: (void)printf("[|dvmrp]"); } static void print_graft(register const u_char *bp, register const u_char *ep, register u_int len) { TCHECK2(bp[0], 8); printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4)); return; trunc: (void)printf("[|dvmrp]"); } static void print_graft_ack(register const u_char *bp, register const u_char *ep, register u_int len) { TCHECK2(bp[0], 8); printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4)); return; trunc: (void)printf("[|dvmrp]"); } tcpdump-3.7.2/print-egp.c0100644000076500000240000001732007627054625014431 0ustar fennerstaff/* * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Lawrence Berkeley Laboratory, * Berkeley, CA. The name of the University may not be used to * endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Initial contribution from Jeff Honig (jch@MITCHELL.CIT.CORNELL.EDU). */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.28.4.1 2002/06/01 23:51:12 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ip.h" struct egp_packet { u_char egp_version; #define EGP_VERSION 2 u_char egp_type; #define EGPT_ACQUIRE 3 #define EGPT_REACH 5 #define EGPT_POLL 2 #define EGPT_UPDATE 1 #define EGPT_ERROR 8 u_char egp_code; #define EGPC_REQUEST 0 #define EGPC_CONFIRM 1 #define EGPC_REFUSE 2 #define EGPC_CEASE 3 #define EGPC_CEASEACK 4 #define EGPC_HELLO 0 #define EGPC_HEARDU 1 u_char egp_status; #define EGPS_UNSPEC 0 #define EGPS_ACTIVE 1 #define EGPS_PASSIVE 2 #define EGPS_NORES 3 #define EGPS_ADMIN 4 #define EGPS_GODOWN 5 #define EGPS_PARAM 6 #define EGPS_PROTO 7 #define EGPS_INDET 0 #define EGPS_UP 1 #define EGPS_DOWN 2 #define EGPS_UNSOL 0x80 u_short egp_checksum; u_short egp_as; u_short egp_sequence; union { u_short egpu_hello; u_char egpu_gws[2]; u_short egpu_reason; #define EGPR_UNSPEC 0 #define EGPR_BADHEAD 1 #define EGPR_BADDATA 2 #define EGPR_NOREACH 3 #define EGPR_XSPOLL 4 #define EGPR_NORESP 5 #define EGPR_UVERSION 6 } egp_handg; #define egp_hello egp_handg.egpu_hello #define egp_intgw egp_handg.egpu_gws[0] #define egp_extgw egp_handg.egpu_gws[1] #define egp_reason egp_handg.egpu_reason union { u_short egpu_poll; u_int32_t egpu_sourcenet; } egp_pands; #define egp_poll egp_pands.egpu_poll #define egp_sourcenet egp_pands.egpu_sourcenet }; const char *egp_acquire_codes[] = { "request", "confirm", "refuse", "cease", "cease_ack" }; const char *egp_acquire_status[] = { "unspecified", "active_mode", "passive_mode", "insufficient_resources", "administratively_prohibited", "going_down", "parameter_violation", "protocol_violation" }; const char *egp_reach_codes[] = { "hello", "i-h-u" }; const char *egp_status_updown[] = { "indeterminate", "up", "down" }; const char *egp_reasons[] = { "unspecified", "bad_EGP_header_format", "bad_EGP_data_field_format", "reachability_info_unavailable", "excessive_polling_rate", "no_response", "unsupported_version" }; static void egpnrprint(register const struct egp_packet *egp, register u_int length) { register const u_char *cp; u_int32_t addr; register u_int32_t net; register u_int netlen; int gateways, distances, networks; int t_gateways; char *comma; addr = egp->egp_sourcenet; if (IN_CLASSA(addr)) { net = addr & IN_CLASSA_NET; netlen = 1; } else if (IN_CLASSB(addr)) { net = addr & IN_CLASSB_NET; netlen = 2; } else if (IN_CLASSC(addr)) { net = addr & IN_CLASSC_NET; netlen = 3; } else { net = 0; netlen = 0; } cp = (u_char *)(egp + 1); t_gateways = egp->egp_intgw + egp->egp_extgw; for (gateways = 0; gateways < t_gateways; ++gateways) { /* Pickup host part of gateway address */ addr = 0; TCHECK2(cp[0], 4 - netlen); switch (netlen) { case 1: addr = *cp++; /* fall through */ case 2: addr = (addr << 8) | *cp++; /* fall through */ case 3: addr = (addr << 8) | *cp++; } addr |= net; TCHECK2(cp[0], 1); distances = *cp++; printf(" %s %s ", gateways < (int)egp->egp_intgw ? "int" : "ext", ipaddr_string(&addr)); comma = ""; putchar('('); while (--distances >= 0) { TCHECK2(cp[0], 2); printf("%sd%d:", comma, (int)*cp++); comma = ", "; networks = *cp++; while (--networks >= 0) { /* Pickup network number */ TCHECK2(cp[0], 1); addr = (u_int32_t)*cp++ << 24; if (IN_CLASSB(addr)) { TCHECK2(cp[0], 1); addr |= (u_int32_t)*cp++ << 16; } else if (!IN_CLASSA(addr)) { TCHECK2(cp[0], 2); addr |= (u_int32_t)*cp++ << 16; addr |= (u_int32_t)*cp++ << 8; } printf(" %s", ipaddr_string(&addr)); } } putchar(')'); } return; trunc: fputs("[|]", stdout); } void egp_print(register const u_char *bp, register u_int length, register const u_char *bp2) { register const struct egp_packet *egp; register const struct ip *ip; register int status; register int code; register int type; egp = (struct egp_packet *)bp; ip = (struct ip *)bp2; (void)printf("egp: "); if (egp->egp_version != EGP_VERSION) { printf("[version %d]", egp->egp_version); return; } printf("as:%d seq:%d", ntohs(egp->egp_as), ntohs(egp->egp_sequence)); type = egp->egp_type; code = egp->egp_code; status = egp->egp_status; switch (type) { case EGPT_ACQUIRE: printf(" acquire"); switch (code) { case EGPC_REQUEST: case EGPC_CONFIRM: printf(" %s", egp_acquire_codes[code]); switch (status) { case EGPS_UNSPEC: case EGPS_ACTIVE: case EGPS_PASSIVE: printf(" %s", egp_acquire_status[status]); break; default: printf(" [status %d]", status); break; } printf(" hello:%d poll:%d", ntohs(egp->egp_hello), ntohs(egp->egp_poll)); break; case EGPC_REFUSE: case EGPC_CEASE: case EGPC_CEASEACK: printf(" %s", egp_acquire_codes[code]); switch (status ) { case EGPS_UNSPEC: case EGPS_NORES: case EGPS_ADMIN: case EGPS_GODOWN: case EGPS_PARAM: case EGPS_PROTO: printf(" %s", egp_acquire_status[status]); break; default: printf("[status %d]", status); break; } break; default: printf("[code %d]", code); break; } break; case EGPT_REACH: switch (code) { case EGPC_HELLO: case EGPC_HEARDU: printf(" %s", egp_reach_codes[code]); if (status <= EGPS_DOWN) printf(" state:%s", egp_status_updown[status]); else printf(" [status %d]", status); break; default: printf("[reach code %d]", code); break; } break; case EGPT_POLL: printf(" poll"); if (egp->egp_status <= EGPS_DOWN) printf(" state:%s", egp_status_updown[status]); else printf(" [status %d]", status); printf(" net:%s", ipaddr_string(&egp->egp_sourcenet)); break; case EGPT_UPDATE: printf(" update"); if (status & EGPS_UNSOL) { status &= ~EGPS_UNSOL; printf(" unsolicited"); } if (status <= EGPS_DOWN) printf(" state:%s", egp_status_updown[status]); else printf(" [status %d]", status); printf(" %s int %d ext %d", ipaddr_string(&egp->egp_sourcenet), egp->egp_intgw, egp->egp_extgw); if (vflag) egpnrprint(egp, length); break; case EGPT_ERROR: printf(" error"); if (status <= EGPS_DOWN) printf(" state:%s", egp_status_updown[status]); else printf(" [status %d]", status); if (ntohs(egp->egp_reason) <= EGPR_UVERSION) printf(" %s", egp_reasons[ntohs(egp->egp_reason)]); else printf(" [reason %d]", ntohs(egp->egp_reason)); break; default: printf("[type %d]", type); break; } } tcpdump-3.7.2/print-esp.c0100644000076500000240000002152307627054626014446 0ustar fennerstaff/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.20.4.2 2002/02/22 09:26:27 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #ifdef HAVE_LIBCRYPTO #include #include #ifdef HAVE_RC5_H #include #endif #ifdef HAVE_CAST_H #include #endif #endif #include #include "ip.h" #include "esp.h" #ifdef INET6 #include "ip6.h" #endif #define AVOID_CHURN 1 #include "interface.h" #include "addrtoname.h" static struct esp_algorithm *espsecret_xform=NULL; /* cache of decoded alg. */ static char *espsecret_key=NULL; enum cipher { NONE, DESCBC, BLOWFISH, RC5, CAST128, DES3CBC}; struct esp_algorithm { char *name; enum cipher algo; int ivlen; int authlen; int replaysize; }; struct esp_algorithm esp_xforms[]={ {"none", NONE, 0, 0, 0}, {"des-cbc", DESCBC, 8, 0, 0}, {"des-cbc-hmac96", DESCBC, 8, 12, 4}, {"blowfish-cbc", BLOWFISH,8, 0, 0}, {"blowfish-cbc-hmac96", BLOWFISH,8, 12, 4}, {"rc5-cbc", RC5, 8, 0, 0}, {"rc5-cbc-hmac96", RC5, 8, 12, 4}, {"cast128-cbc", CAST128, 8, 0, 0}, {"cast128-cbc-hmac96", CAST128, 8, 12, 4}, {"3des-cbc-hmac96", DES3CBC, 8, 12, 4}, }; static int hexdigit(char hex) { if(hex >= '0' && hex <= '9') { return (hex - '0'); } else if(hex >= 'A' && hex <= 'F') { return (hex - 'A' + 10); } else if(hex >= 'a' && hex <= 'f') { return (hex - 'a' + 10); } else { printf("invalid hex digit %c in espsecret\n", hex); return 0; } } static int hex2byte(char *hexstring) { int byte; byte = (hexdigit(hexstring[0]) << 4) + hexdigit(hexstring[1]); return byte; } static void esp_print_decodesecret(void) { char *colon; int len, i; struct esp_algorithm *xf; if(espsecret == NULL) { /* set to NONE transform */ espsecret_xform = esp_xforms; return; } if(espsecret_key != NULL) { return; } colon = strchr(espsecret, ':'); if(colon == NULL) { printf("failed to decode espsecret: %s\n", espsecret); /* set to NONE transform */ espsecret_xform = esp_xforms; } len = colon - espsecret; xf = esp_xforms; while(xf->name && strncasecmp(espsecret, xf->name, len)!=0) { xf++; } if(xf->name == NULL) { printf("failed to find cipher algo %s\n", espsecret); espsecret_xform = esp_xforms; return; } espsecret_xform = xf; colon++; if(colon[0]=='0' && colon[1]=='x') { /* decode some hex! */ colon+=2; len = strlen(colon) / 2; espsecret_key = (char *)malloc(len); if(espsecret_key == NULL) { fprintf(stderr, "%s: ran out of memory (%d) to allocate secret key\n", program_name, len); exit(2); } i = 0; while(colon[0] != '\0' && colon[1]!='\0') { espsecret_key[i]=hex2byte(colon); colon+=2; i++; } } else { espsecret_key = colon; } } int esp_print(register const u_char *bp, register const u_char *bp2, int *nhdr, int *padlen) { register const struct esp *esp; register const u_char *ep; u_int32_t spi; struct ip *ip = NULL; #ifdef INET6 struct ip6_hdr *ip6 = NULL; #endif int advance; int len; char *secret; int ivlen = 0; u_char *ivoff; u_char *p; esp = (struct esp *)bp; spi = (u_int32_t)ntohl(esp->esp_spi); secret = NULL; #if 0 /* keep secret out of a register */ p = (u_char *)&secret; #endif /* 'ep' points to the end of available data. */ ep = snapend; if ((u_char *)(esp + 1) >= ep - sizeof(struct esp)) { fputs("[|ESP]", stdout); goto fail; } printf("ESP(spi=0x%08x", spi); printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(esp + 1))); printf(")"); /* if we don't have decryption key, we can't decrypt this packet. */ if (!espsecret) goto fail; if(!espsecret_xform) { esp_print_decodesecret(); } if(espsecret_xform->algo == NONE) { goto fail; } ip = (struct ip *)bp2; switch (IP_V(ip)) { #ifdef INET6 case 6: ip6 = (struct ip6_hdr *)bp2; ip = NULL; /* we do not attempt to decrypt jumbograms */ if (!ntohs(ip6->ip6_plen)) goto fail; /* if we can't get nexthdr, we do not need to decrypt it */ len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen); break; #endif /*INET6*/ case 4: /* nexthdr & padding are in the last fragment */ if (ntohs(ip->ip_off) & IP_MF) goto fail; #ifdef INET6 ip6 = NULL; #endif len = ntohs(ip->ip_len); break; default: goto fail; } /* if we can't get nexthdr, we do not need to decrypt it */ if (ep - bp2 < len) goto fail; ivoff = (u_char *)(esp + 1) + espsecret_xform->replaysize; ivlen = espsecret_xform->ivlen; secret = espsecret_key; switch (espsecret_xform->algo) { case DESCBC: #ifdef HAVE_LIBCRYPTO { u_char iv[8]; des_key_schedule schedule; switch (ivlen) { case 4: memcpy(iv, ivoff, 4); memcpy(&iv[4], ivoff, 4); p = &iv[4]; *p++ ^= 0xff; *p++ ^= 0xff; *p++ ^= 0xff; *p++ ^= 0xff; break; case 8: memcpy(iv, ivoff, 8); break; default: goto fail; } des_check_key = 0; des_set_key((void *)secret, schedule); p = ivoff + ivlen; des_cbc_encrypt((void *)p, (void *)p, (long)(ep - p), schedule, (void *)iv, DES_DECRYPT); advance = ivoff - (u_char *)esp + ivlen; break; } #else goto fail; #endif /*HAVE_LIBCRYPTO*/ case BLOWFISH: #ifdef HAVE_LIBCRYPTO { BF_KEY schedule; BF_set_key(&schedule, strlen(secret), secret); p = ivoff + ivlen; BF_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff, BF_DECRYPT); advance = ivoff - (u_char *)esp + ivlen; break; } #else goto fail; #endif /*HAVE_LIBCRYPTO*/ case RC5: #if defined(HAVE_LIBCRYPTO) && defined(HAVE_RC5_H) { RC5_32_KEY schedule; RC5_32_set_key(&schedule, strlen(secret), secret, RC5_16_ROUNDS); p = ivoff + ivlen; RC5_32_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff, RC5_DECRYPT); advance = ivoff - (u_char *)esp + ivlen; break; } #else goto fail; #endif /*HAVE_LIBCRYPTO*/ case CAST128: #if defined(HAVE_LIBCRYPTO) && defined(HAVE_CAST_H) && !defined(HAVE_BUGGY_CAST128) { CAST_KEY schedule; CAST_set_key(&schedule, strlen(secret), secret); p = ivoff + ivlen; CAST_cbc_encrypt(p, p, (long)(ep - p), &schedule, ivoff, CAST_DECRYPT); advance = ivoff - (u_char *)esp + ivlen; break; } #else goto fail; #endif /*HAVE_LIBCRYPTO*/ case DES3CBC: #if defined(HAVE_LIBCRYPTO) { des_key_schedule s1, s2, s3; des_check_key = 1; des_set_odd_parity((void *)secret); des_set_odd_parity((void *)(secret + 8)); des_set_odd_parity((void *)(secret + 16)); if(des_set_key((void *)secret, s1) != 0) { printf("failed to schedule key 1\n"); } if(des_set_key((void *)(secret + 8), s2)!=0) { printf("failed to schedule key 2\n"); } if(des_set_key((void *)(secret + 16), s3)!=0) { printf("failed to schedule key 3\n"); } p = ivoff + ivlen; des_ede3_cbc_encrypt((void *)p, (void *)p, (long)(ep - p), s1, s2, s3, (void *)ivoff, DES_DECRYPT); advance = ivoff - (u_char *)esp + ivlen; break; } #else goto fail; #endif /*HAVE_LIBCRYPTO*/ case NONE: default: advance = sizeof(struct esp) + espsecret_xform->replaysize; break; } ep = ep - espsecret_xform->authlen; /* sanity check for pad length */ if (ep - bp < *(ep - 2)) goto fail; if (padlen) *padlen = *(ep - 2) + 2; if (nhdr) *nhdr = *(ep - 1); printf(": "); return advance; fail: if (nhdr) *nhdr = -1; return 65536; } tcpdump-3.7.2/print-ether.c0100644000076500000240000001442107627054626014765 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.65.4.1 2002/06/01 23:51:12 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "ether.h" const u_char *packetp; const u_char *snapend; static inline void ether_print(register const u_char *bp, u_int length) { register const struct ether_header *ep; ep = (const struct ether_header *)bp; if (qflag) (void)printf("%s %s %d: ", etheraddr_string(ESRC(ep)), etheraddr_string(EDST(ep)), length); else (void)printf("%s %s %s %d: ", etheraddr_string(ESRC(ep)), etheraddr_string(EDST(ep)), etherproto_string(ep->ether_type), length); } /* * This is the top level routine of the printer. 'p' is the points * to the ether header of the packet, 'h->tv' is the timestamp, * 'h->length' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ void ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; struct ether_header *ep; u_short ether_type; u_short extracted_ethertype; ++infodelay; ts_print(&h->ts); if (caplen < ETHER_HDRLEN) { printf("[|ether]"); goto out; } if (eflag) ether_print(p, length); /* * Some printers want to get back at the ethernet addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; length -= ETHER_HDRLEN; caplen -= ETHER_HDRLEN; ep = (struct ether_header *)p; p += ETHER_HDRLEN; ether_type = ntohs(ep->ether_type); /* * Is it (gag) an 802.3 encapsulation? */ extracted_ethertype = 0; if (ether_type <= ETHERMTU) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(ep), EDST(ep), &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) ether_print((u_char *)ep, length + ETHER_HDRLEN); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } if (!xflag && !qflag) default_print(p, caplen); } } else if (ether_encap_print(ether_type, p, length, caplen, &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) ether_print((u_char *)ep, length + ETHER_HDRLEN); if (!xflag && !qflag) default_print(p, caplen); } if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } /* * Prints the packet encapsulated in an Ethernet data segment * (or an equivalent encapsulation), given the Ethernet type code. * * Returns non-zero if it can do so, zero if the ethertype is unknown. * * The Ethernet type code is passed through a pointer; if it was * ETHERTYPE_8021Q, it gets updated to be the Ethernet type of * the 802.1Q payload, for the benefit of lower layers that might * want to know what it is. */ int ether_encap_print(u_short ethertype, const u_char *p, u_int length, u_int caplen, u_short *extracted_ethertype) { recurse: *extracted_ethertype = ethertype; switch (ethertype) { case ETHERTYPE_IP: ip_print(p, length); return (1); #ifdef INET6 case ETHERTYPE_IPV6: ip6_print(p, length); return (1); #endif /*INET6*/ case ETHERTYPE_ARP: case ETHERTYPE_REVARP: arp_print(p, length, caplen); return (1); case ETHERTYPE_DN: decnet_print(p, length, caplen); return (1); case ETHERTYPE_ATALK: if (vflag) fputs("et1 ", stdout); atalk_print(p, length); return (1); case ETHERTYPE_AARP: aarp_print(p, length); return (1); case ETHERTYPE_IPX: ipx_print(p, length); return (1); case ETHERTYPE_8021Q: printf("802.1Q vlan#%d P%d%s ", ntohs(*(u_int16_t *)p) & 0xfff, ntohs(*(u_int16_t *)p) >> 13, (ntohs(*(u_int16_t *)p) & 0x1000) ? " CFI" : ""); ethertype = ntohs(*(u_int16_t *)(p + 2)); p += 4; length -= 4; caplen -= 4; if (ethertype > ETHERMTU) goto recurse; *extracted_ethertype = 0; if (llc_print(p, length, caplen, p - 18, p - 12, extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) ether_print(p - 18, length + 4); if (*extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(*extracted_ethertype))); } if (!xflag && !qflag) default_print(p - 18, caplen + 4); } return (1); case ETHERTYPE_PPPOED: case ETHERTYPE_PPPOES: pppoe_print(p, length); return (1); case ETHERTYPE_PPP: printf("ppp"); if (length) { printf(": "); ppp_print(p, length); } return (1); case ETHERTYPE_MPLS: case ETHERTYPE_MPLS_MULTI: mpls_print(p, length); return (1); case ETHERTYPE_LAT: case ETHERTYPE_SCA: case ETHERTYPE_MOPRC: case ETHERTYPE_MOPDL: /* default_print for now */ default: return (0); } } tcpdump-3.7.2/print-fddi.c0100644000076500000240000002324507627054626014570 0ustar fennerstaff/* * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.53.2.1 2002/06/01 23:51:13 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "ether.h" #include "fddi.h" /* * Some FDDI interfaces use bit-swapped addresses. */ #if defined(ultrix) || defined(__alpha) || defined(__bsdi) || defined(__NetBSD__) || defined(__linux__) int fddi_bitswap = 0; #else int fddi_bitswap = 1; #endif /* * FDDI support for tcpdump, by Jeffrey Mogul [DECWRL], June 1992 * * Based in part on code by Van Jacobson, which bears this note: * * NOTE: This is a very preliminary hack for FDDI support. * There are all sorts of wired in constants & nothing (yet) * to print SMT packets as anything other than hex dumps. * Most of the necessary changes are waiting on my redoing * the "header" that a kernel fddi driver supplies to bpf: I * want it to look like one byte of 'direction' (0 or 1 * depending on whether the packet was inbound or outbound), * two bytes of system/driver dependent data (anything an * implementor thinks would be useful to filter on and/or * save per-packet, then the real 21-byte FDDI header. * Steve McCanne & I have also talked about adding the * 'direction' byte to all bpf headers (e.g., in the two * bytes of padding on an ethernet header). It's not clear * we could do this in a backwards compatible way & we hate * the idea of an incompatible bpf change. Discussions are * proceeding. * * Also, to really support FDDI (and better support 802.2 * over ethernet) we really need to re-think the rather simple * minded assumptions about fixed length & fixed format link * level headers made in gencode.c. One day... * * - vj */ static u_char fddi_bit_swap[] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, }; /* * Print FDDI frame-control bits */ static inline void print_fddi_fc(u_char fc) { switch (fc) { case FDDIFC_VOID: /* Void frame */ printf("void "); break; case FDDIFC_NRT: /* Nonrestricted token */ printf("nrt "); break; case FDDIFC_RT: /* Restricted token */ printf("rt "); break; case FDDIFC_SMT_INFO: /* SMT Info */ printf("info "); break; case FDDIFC_SMT_NSA: /* SMT Next station adrs */ printf("nsa "); break; case FDDIFC_MAC_BEACON: /* MAC Beacon frame */ printf("beacon "); break; case FDDIFC_MAC_CLAIM: /* MAC Claim frame */ printf("claim "); break; default: switch (fc & FDDIFC_CLFF) { case FDDIFC_MAC: printf("mac%1x ", fc & FDDIFC_ZZZZ); break; case FDDIFC_SMT: printf("smt%1x ", fc & FDDIFC_ZZZZ); break; case FDDIFC_LLC_ASYNC: printf("async%1x ", fc & FDDIFC_ZZZZ); break; case FDDIFC_LLC_SYNC: printf("sync%1x ", fc & FDDIFC_ZZZZ); break; case FDDIFC_IMP_ASYNC: printf("imp_async%1x ", fc & FDDIFC_ZZZZ); break; case FDDIFC_IMP_SYNC: printf("imp_sync%1x ", fc & FDDIFC_ZZZZ); break; default: printf("%02x ", fc); break; } } } /* Extract src, dst addresses */ static inline void extract_fddi_addrs(const struct fddi_header *fddip, char *fsrc, char *fdst) { register int i; if (fddi_bitswap) { /* * bit-swap the fddi addresses (isn't the IEEE standards * process wonderful!) then convert them to names. */ for (i = 0; i < 6; ++i) fdst[i] = fddi_bit_swap[fddip->fddi_dhost[i]]; for (i = 0; i < 6; ++i) fsrc[i] = fddi_bit_swap[fddip->fddi_shost[i]]; } else { memcpy(fdst, (const char *)fddip->fddi_dhost, 6); memcpy(fsrc, (const char *)fddip->fddi_shost, 6); } } /* * Print the FDDI MAC header */ static inline void fddi_print(register const struct fddi_header *fddip, register u_int length, register const u_char *fsrc, register const u_char *fdst) { const char *srcname, *dstname; srcname = etheraddr_string(fsrc); dstname = etheraddr_string(fdst); if (vflag) (void) printf("%02x %s %s %d: ", fddip->fddi_fc, srcname, dstname, length); else if (qflag) printf("%s %s %d: ", srcname, dstname, length); else { (void) print_fddi_fc(fddip->fddi_fc); (void) printf("%s %s %d: ", srcname, dstname, length); } } static inline void fddi_smt_print(const u_char *p, u_int length) { printf(""); } /* * This is the top level routine of the printer. 'sp' is the points * to the FDDI header of the packet, 'tvp' is the timestamp, * 'length' is the length of the packet off the wire, and 'caplen' * is the number of bytes actually captured. */ void fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h, register const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; const struct fddi_header *fddip = (const struct fddi_header *)p; struct ether_header ehdr; u_short extracted_ethertype; ++infodelay; ts_print(&h->ts); if (caplen < FDDI_HDRLEN) { printf("[|fddi]"); goto out; } /* * Get the FDDI addresses into a canonical form */ extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr)); /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ snapend = p + caplen; /* * Actually, the only printers that use packetp are print-arp.c * and print-bootp.c, and they assume that packetp points to an * Ethernet header. The right thing to do is to fix them to know * which link type is in use when they excavate. XXX */ packetp = (u_char *)&ehdr; if (eflag) fddi_print(fddip, length, ESRC(&ehdr), EDST(&ehdr)); /* Skip over FDDI MAC header */ length -= FDDI_HDRLEN; p += FDDI_HDRLEN; caplen -= FDDI_HDRLEN; /* Frame Control field determines interpretation of packet */ extracted_ethertype = 0; if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr), &extracted_ethertype) == 0) { /* * Some kinds of LLC packet we cannot * handle intelligently */ if (!eflag) fddi_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr), EDST(&ehdr)); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } if (!xflag && !qflag) default_print(p, caplen); } } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) fddi_smt_print(p, caplen); else { /* Some kinds of FDDI packet we cannot handle intelligently */ if (!eflag) fddi_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr), EDST(&ehdr)); if (!xflag && !qflag) default_print(p, caplen); } if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } tcpdump-3.7.2/print-frag6.c0100644000076500000240000000517107351470752014661 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.13 2001/09/17 21:58:02 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef INET6 #include #include #include #include #include #include #include "ip6.h" #include "interface.h" #include "addrtoname.h" int frag6_print(register const u_char *bp, register const u_char *bp2) { register const struct ip6_frag *dp; register const struct ip6_hdr *ip6; register const u_char *ep; dp = (const struct ip6_frag *)bp; ip6 = (const struct ip6_hdr *)bp2; /* 'ep' points to the end of available data. */ ep = snapend; TCHECK(dp->ip6f_offlg); if (vflag) { printf("frag (0x%08x:%d|%ld)", (u_int32_t)ntohl(dp->ip6f_ident), ntohs(dp->ip6f_offlg & IP6F_OFF_MASK), sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) - (long)(bp - bp2) - sizeof(struct ip6_frag)); } else { printf("frag (%d|%ld)", ntohs(dp->ip6f_offlg & IP6F_OFF_MASK), sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) - (long)(bp - bp2) - sizeof(struct ip6_frag)); } #if 1 /* it is meaningless to decode non-first fragment */ if (ntohs(dp->ip6f_offlg & IP6F_OFF_MASK) != 0) return 65535; else #endif { fputs(" ", stdout); return sizeof(struct ip6_frag); } trunc: fputs("[|frag]", stdout); return 65535; #undef TCHECK } #endif /* INET6 */ tcpdump-3.7.2/print-gre.c0100644000076500000240000001047707627054626014442 0ustar fennerstaff/* * Copyright (c) 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Lawrence Berkeley Laboratory, * Berkeley, CA. The name of the University may not be used to * endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Initial contribution from John Hawkinson * * This module implements support for decoding GRE (Generic Routing * Encapsulation) tunnels; they're documented in RFC1701 and RFC1702. * This code only supports the IP encapsulation thereof. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.13.4.1 2002/06/01 23:51:13 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ struct gre { u_int16_t flags; u_int16_t proto; }; /* RFC 2784 - GRE */ #define GRE_CP 0x8000 /* Checksum Present */ #define GRE_VER_MASK 0x0007 /* Version */ /* RFC 2890 - Key and Sequence extensions to GRE */ #define GRE_KP 0x2000 /* Key Present */ #define GRE_SP 0x1000 /* Sequence Present */ /* Legacy from RFC 1700 */ #define GRE_RP 0x4000 /* Routing Present */ #define GRE_sP 0x0800 /* strict source route present */ #define GRE_RECUR_MASK 0x0700 /* Recursion Control */ #define GRE_RECUR_SHIFT 8 #define GRE_COP (GRE_RP|GRE_CP) /* Checksum & Offset Present */ /* "Enhanced GRE" from RFC2637 - PPTP */ #define GRE_AP 0x0080 /* Ack present */ #define GRE_MBZ_MASK 0x0078 /* not defined */ /* * Deencapsulate and print a GRE-tunneled IP datagram */ void gre_print(const u_char *bp, u_int length) { const u_char *cp = bp + 4; const struct gre *gre; u_int16_t flags, proto; u_short ver=0; u_short extracted_ethertype; gre = (const struct gre *)bp; TCHECK(gre->proto); flags = EXTRACT_16BITS(&gre->flags); proto = EXTRACT_16BITS(&gre->proto); (void)printf("gre "); if (flags) { /* Decode the flags */ putchar('['); if (flags & GRE_CP) putchar('C'); if (flags & GRE_RP) putchar('R'); if (flags & GRE_KP) putchar('K'); if (flags & GRE_SP) putchar('S'); if (flags & GRE_sP) putchar('s'); if (flags & GRE_AP) putchar('A'); if (flags & GRE_RECUR_MASK) printf("R%x", (flags & GRE_RECUR_MASK) >> GRE_RECUR_SHIFT); ver = flags & GRE_VER_MASK; printf("v%u", ver); if (flags & GRE_MBZ_MASK) printf("!%x", flags & GRE_MBZ_MASK); fputs("] ", stdout); } if (flags & GRE_COP) { int checksum, offset; TCHECK2(*cp, 4); checksum = EXTRACT_16BITS(cp); offset = EXTRACT_16BITS(cp + 2); if (flags & GRE_CP) { /* Checksum present */ /* todo: check checksum */ if (vflag > 1) printf("C:%04x ", checksum); } if (flags & GRE_RP) { /* Offset present */ if (vflag > 1) printf("O:%04x ", offset); } cp += 4; /* skip checksum and offset */ } if (flags & GRE_KP) { TCHECK2(*cp, 4); if (ver == 1) { /* PPTP */ if (vflag > 1) printf("PL:%u ", EXTRACT_16BITS(cp)); printf("ID:%04x ", EXTRACT_16BITS(cp+2)); } else printf("K:%08x ", EXTRACT_32BITS(cp)); cp += 4; /* skip key */ } if (flags & GRE_SP) { TCHECK2(*cp, 4); printf("S:%u ", EXTRACT_32BITS(cp)); cp += 4; /* skip seq */ } if (flags & GRE_AP && ver >= 1) { TCHECK2(*cp, 4); printf("A:%u ", EXTRACT_32BITS(cp)); cp += 4; /* skip ack */ } /* We don't support routing fields (variable length) now. Punt. */ if (flags & GRE_RP) return; TCHECK(cp[0]); length -= cp - bp; if (ether_encap_print(proto, cp, length, length, &extracted_ethertype) == 0) printf("gre-proto-0x%04X", proto); return; trunc: fputs("[|gre]", stdout); } tcpdump-3.7.2/print-hsrp.c0100644000076500000240000001063307360350165014622 0ustar fennerstaff/* * Copyright (C) 2001 Julian Cowley * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* Cisco Hot Standby Router Protocol (HSRP). */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.2 2001/10/08 16:12:37 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "interface.h" #include "addrtoname.h" /* HSRP op code types. */ static const char *op_code_str[] = { "hello", "coup", "resign" }; /* HSRP states and associated names. */ static struct tok states[] = { { 0, "initial" }, { 1, "learn" }, { 2, "listen" }, { 4, "speak" }, { 8, "standby" }, { 16, "active" }, { 0, NULL } }; /* * RFC 2281: * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Op Code | State | Hellotime | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Holdtime | Priority | Group | Reserved | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Authentication Data | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Authentication Data | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Virtual IP Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ #define HSRP_AUTH_SIZE 8 /* HSRP protocol header. */ struct hsrp { u_char hsrp_version; u_char hsrp_op_code; u_char hsrp_state; u_char hsrp_hellotime; u_char hsrp_holdtime; u_char hsrp_priority; u_char hsrp_group; u_char hsrp_reserved; u_char hsrp_authdata[HSRP_AUTH_SIZE]; struct in_addr hsrp_virtaddr; }; void hsrp_print(register const u_char *bp, register u_int len) { struct hsrp *hp = (struct hsrp *) bp; TCHECK(hp->hsrp_version); printf("HSRPv%d", hp->hsrp_version); if (hp->hsrp_version != 0) return; TCHECK(hp->hsrp_op_code); printf("-"); printf("%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code)); printf("%d: ", len); TCHECK(hp->hsrp_state); printf("state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state)); TCHECK(hp->hsrp_group); printf("group=%d ", hp->hsrp_group); TCHECK(hp->hsrp_reserved); if (hp->hsrp_reserved != 0) { printf("[reserved=%d!] ", hp->hsrp_reserved); } TCHECK2(hp->hsrp_virtaddr, sizeof(hp->hsrp_virtaddr)); printf("addr=%s", ipaddr_string(&hp->hsrp_virtaddr)); if (vflag) { printf(" hellotime="); relts_print(hp->hsrp_hellotime); printf(" holdtime="); relts_print(hp->hsrp_holdtime); printf(" priority=%d", hp->hsrp_priority); printf(" auth=\""); fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata), NULL); printf("\""); } return; trunc: printf("[|hsrp]"); } tcpdump-3.7.2/print-icmp.c0100644000076500000240000003465007627054627014615 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.62.4.1 2002/06/01 23:51:13 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include /* for MAXHOSTNAMELEN on some platforms */ #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ #include "ip.h" #include "udp.h" /* * Interface Control Message Protocol Definitions. * Per RFC 792, September 1981. */ /* * Structure of an icmp header. */ struct icmp { u_int8_t icmp_type; /* type of message, see below */ u_int8_t icmp_code; /* type sub code */ u_int16_t icmp_cksum; /* ones complement cksum of struct */ union { u_int8_t ih_pptr; /* ICMP_PARAMPROB */ struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ struct ih_idseq { u_int16_t icd_id; u_int16_t icd_seq; } ih_idseq; u_int32_t ih_void; /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ struct ih_pmtu { u_int16_t ipm_void; u_int16_t ipm_nextmtu; } ih_pmtu; } icmp_hun; #define icmp_pptr icmp_hun.ih_pptr #define icmp_gwaddr icmp_hun.ih_gwaddr #define icmp_id icmp_hun.ih_idseq.icd_id #define icmp_seq icmp_hun.ih_idseq.icd_seq #define icmp_void icmp_hun.ih_void #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu union { struct id_ts { u_int32_t its_otime; u_int32_t its_rtime; u_int32_t its_ttime; } id_ts; struct id_ip { struct ip idi_ip; /* options and then 64 bits of data */ } id_ip; u_int32_t id_mask; u_int8_t id_data[1]; } icmp_dun; #define icmp_otime icmp_dun.id_ts.its_otime #define icmp_rtime icmp_dun.id_ts.its_rtime #define icmp_ttime icmp_dun.id_ts.its_ttime #define icmp_ip icmp_dun.id_ip.idi_ip #define icmp_mask icmp_dun.id_mask #define icmp_data icmp_dun.id_data }; /* * Lower bounds on packet lengths for various types. * For the error advice packets must first insure that the * packet is large enought to contain the returned ip header. * Only then can we do the check to see if 64 bits of packet * data have been returned, since we need to check the returned * ip header length. */ #define ICMP_MINLEN 8 /* abs minimum */ #define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */ #define ICMP_MASKLEN 12 /* address mask */ #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ #define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8) /* N.B.: must separately check that ip_hl >= 5 */ /* * Definition of type and code field values. */ #define ICMP_ECHOREPLY 0 /* echo reply */ #define ICMP_UNREACH 3 /* dest unreachable, codes: */ #define ICMP_UNREACH_NET 0 /* bad net */ #define ICMP_UNREACH_HOST 1 /* bad host */ #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ #define ICMP_UNREACH_PORT 3 /* bad port */ #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ #define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ #define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ #define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ #define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ #define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ #define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ #define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ #define ICMP_REDIRECT 5 /* shorter route, codes: */ #define ICMP_REDIRECT_NET 0 /* for network */ #define ICMP_REDIRECT_HOST 1 /* for host */ #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ #define ICMP_ECHO 8 /* echo service */ #define ICMP_ROUTERADVERT 9 /* router advertisement */ #define ICMP_ROUTERSOLICIT 10 /* router solicitation */ #define ICMP_TIMXCEED 11 /* time exceeded, code: */ #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ #define ICMP_PARAMPROB 12 /* ip header bad */ #define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ #define ICMP_TSTAMP 13 /* timestamp request */ #define ICMP_TSTAMPREPLY 14 /* timestamp reply */ #define ICMP_IREQ 15 /* information request */ #define ICMP_IREQREPLY 16 /* information reply */ #define ICMP_MASKREQ 17 /* address mask request */ #define ICMP_MASKREPLY 18 /* address mask reply */ #define ICMP_MAXTYPE 18 #define ICMP_INFOTYPE(type) \ ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) /* rfc1700 */ #ifndef ICMP_UNREACH_NET_UNKNOWN #define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */ #endif #ifndef ICMP_UNREACH_HOST_UNKNOWN #define ICMP_UNREACH_HOST_UNKNOWN 7 /* destination host unknown */ #endif #ifndef ICMP_UNREACH_ISOLATED #define ICMP_UNREACH_ISOLATED 8 /* source host isolated */ #endif #ifndef ICMP_UNREACH_NET_PROHIB #define ICMP_UNREACH_NET_PROHIB 9 /* admin prohibited net */ #endif #ifndef ICMP_UNREACH_HOST_PROHIB #define ICMP_UNREACH_HOST_PROHIB 10 /* admin prohibited host */ #endif #ifndef ICMP_UNREACH_TOSNET #define ICMP_UNREACH_TOSNET 11 /* tos prohibited net */ #endif #ifndef ICMP_UNREACH_TOSHOST #define ICMP_UNREACH_TOSHOST 12 /* tos prohibited host */ #endif /* rfc1716 */ #ifndef ICMP_UNREACH_FILTER_PROHIB #define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohibited filter */ #endif #ifndef ICMP_UNREACH_HOST_PRECEDENCE #define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host precedence violation */ #endif #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */ #endif /* Most of the icmp types */ static struct tok icmp2str[] = { { ICMP_ECHOREPLY, "echo reply" }, { ICMP_SOURCEQUENCH, "source quench" }, { ICMP_ECHO, "echo request" }, { ICMP_ROUTERSOLICIT, "router solicitation" }, { ICMP_TSTAMP, "time stamp request" }, { ICMP_TSTAMPREPLY, "time stamp reply" }, { ICMP_IREQ, "information request" }, { ICMP_IREQREPLY, "information reply" }, { ICMP_MASKREQ, "address mask request" }, { 0, NULL } }; /* Formats for most of the ICMP_UNREACH codes */ static struct tok unreach2str[] = { { ICMP_UNREACH_NET, "net %s unreachable" }, { ICMP_UNREACH_HOST, "host %s unreachable" }, { ICMP_UNREACH_SRCFAIL, "%s unreachable - source route failed" }, { ICMP_UNREACH_NET_UNKNOWN, "net %s unreachable - unknown" }, { ICMP_UNREACH_HOST_UNKNOWN, "host %s unreachable - unknown" }, { ICMP_UNREACH_ISOLATED, "%s unreachable - source host isolated" }, { ICMP_UNREACH_NET_PROHIB, "net %s unreachable - admin prohibited" }, { ICMP_UNREACH_HOST_PROHIB, "host %s unreachable - admin prohibited" }, { ICMP_UNREACH_TOSNET, "net %s unreachable - tos prohibited" }, { ICMP_UNREACH_TOSHOST, "host %s unreachable - tos prohibited" }, { ICMP_UNREACH_FILTER_PROHIB, "host %s unreachable - admin prohibited filter" }, { ICMP_UNREACH_HOST_PRECEDENCE, "host %s unreachable - host precedence violation" }, { ICMP_UNREACH_PRECEDENCE_CUTOFF, "host %s unreachable - precedence cutoff" }, { 0, NULL } }; /* Formats for the ICMP_REDIRECT codes */ static struct tok type2str[] = { { ICMP_REDIRECT_NET, "redirect %s to net %s" }, { ICMP_REDIRECT_HOST, "redirect %s to host %s" }, { ICMP_REDIRECT_TOSNET, "redirect-tos %s to net %s" }, { ICMP_REDIRECT_TOSHOST, "redirect-tos %s to host %s" }, { 0, NULL } }; /* rfc1191 */ struct mtu_discovery { u_int16_t unused; u_int16_t nexthopmtu; }; /* rfc1256 */ struct ih_rdiscovery { u_int8_t ird_addrnum; u_int8_t ird_addrsiz; u_int16_t ird_lifetime; }; struct id_rdiscovery { u_int32_t ird_addr; u_int32_t ird_pref; }; void icmp_print(const u_char *bp, u_int plen, const u_char *bp2) { char *cp; const struct icmp *dp; const struct ip *ip; const char *str, *fmt; const struct ip *oip; const struct udphdr *ouh; u_int hlen, dport, mtu; char buf[MAXHOSTNAMELEN + 100]; dp = (struct icmp *)bp; ip = (struct ip *)bp2; str = buf; TCHECK(dp->icmp_code); switch (dp->icmp_type) { case ICMP_UNREACH: TCHECK(dp->icmp_ip.ip_dst); switch (dp->icmp_code) { case ICMP_UNREACH_PROTOCOL: TCHECK(dp->icmp_ip.ip_p); (void)snprintf(buf, sizeof(buf), "%s protocol %d unreachable", ipaddr_string(&dp->icmp_ip.ip_dst), dp->icmp_ip.ip_p); break; case ICMP_UNREACH_PORT: TCHECK(dp->icmp_ip.ip_p); oip = &dp->icmp_ip; hlen = IP_HL(oip) * 4; ouh = (struct udphdr *)(((u_char *)oip) + hlen); dport = ntohs(ouh->uh_dport); switch (oip->ip_p) { case IPPROTO_TCP: (void)snprintf(buf, sizeof(buf), "%s tcp port %s unreachable", ipaddr_string(&oip->ip_dst), tcpport_string(dport)); break; case IPPROTO_UDP: (void)snprintf(buf, sizeof(buf), "%s udp port %s unreachable", ipaddr_string(&oip->ip_dst), udpport_string(dport)); break; default: (void)snprintf(buf, sizeof(buf), "%s protocol %d port %d unreachable", ipaddr_string(&oip->ip_dst), oip->ip_p, dport); break; } break; case ICMP_UNREACH_NEEDFRAG: { register const struct mtu_discovery *mp; mp = (struct mtu_discovery *)&dp->icmp_void; mtu = EXTRACT_16BITS(&mp->nexthopmtu); if (mtu) { (void)snprintf(buf, sizeof(buf), "%s unreachable - need to frag (mtu %d)", ipaddr_string(&dp->icmp_ip.ip_dst), mtu); } else { (void)snprintf(buf, sizeof(buf), "%s unreachable - need to frag", ipaddr_string(&dp->icmp_ip.ip_dst)); } } break; default: fmt = tok2str(unreach2str, "#%d %%s unreachable", dp->icmp_code); (void)snprintf(buf, sizeof(buf), fmt, ipaddr_string(&dp->icmp_ip.ip_dst)); break; } break; case ICMP_REDIRECT: TCHECK(dp->icmp_ip.ip_dst); fmt = tok2str(type2str, "redirect-#%d %%s to net %%s", dp->icmp_code); (void)snprintf(buf, sizeof(buf), fmt, ipaddr_string(&dp->icmp_ip.ip_dst), ipaddr_string(&dp->icmp_gwaddr)); break; case ICMP_ROUTERADVERT: { register const struct ih_rdiscovery *ihp; register const struct id_rdiscovery *idp; u_int lifetime, num, size; (void)snprintf(buf, sizeof(buf), "router advertisement"); cp = buf + strlen(buf); ihp = (struct ih_rdiscovery *)&dp->icmp_void; TCHECK(*ihp); (void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf)); cp = buf + strlen(buf); lifetime = EXTRACT_16BITS(&ihp->ird_lifetime); if (lifetime < 60) { (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u", lifetime); } else if (lifetime < 60 * 60) { (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u", lifetime / 60, lifetime % 60); } else { (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u:%02u", lifetime / 3600, (lifetime % 3600) / 60, lifetime % 60); } cp = buf + strlen(buf); num = ihp->ird_addrnum; (void)snprintf(cp, sizeof(buf) - (cp - buf), " %d:", num); cp = buf + strlen(buf); size = ihp->ird_addrsiz; if (size != 2) { (void)snprintf(cp, sizeof(buf) - (cp - buf), " [size %d]", size); break; } idp = (struct id_rdiscovery *)&dp->icmp_data; while (num-- > 0) { TCHECK(*idp); (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}", ipaddr_string(&idp->ird_addr), EXTRACT_32BITS(&idp->ird_pref)); cp = buf + strlen(buf); ++idp; } } break; case ICMP_TIMXCEED: TCHECK(dp->icmp_ip.ip_dst); switch (dp->icmp_code) { case ICMP_TIMXCEED_INTRANS: str = "time exceeded in-transit"; break; case ICMP_TIMXCEED_REASS: str = "ip reassembly time exceeded"; break; default: (void)snprintf(buf, sizeof(buf), "time exceeded-#%d", dp->icmp_code); break; } break; case ICMP_PARAMPROB: if (dp->icmp_code) (void)snprintf(buf, sizeof(buf), "parameter problem - code %d", dp->icmp_code); else { TCHECK(dp->icmp_pptr); (void)snprintf(buf, sizeof(buf), "parameter problem - octet %d", dp->icmp_pptr); } break; case ICMP_MASKREPLY: TCHECK(dp->icmp_mask); (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x", (unsigned)ntohl(dp->icmp_mask)); break; case ICMP_TSTAMP: TCHECK(dp->icmp_seq); (void)snprintf(buf, sizeof(buf), "time stamp query id %u seq %u", (unsigned)ntohs(dp->icmp_id), (unsigned)ntohs(dp->icmp_seq)); break; case ICMP_TSTAMPREPLY: TCHECK(dp->icmp_ttime); (void)snprintf(buf, sizeof(buf), "time stamp reply id %u seq %u : org 0x%lx recv 0x%lx xmit 0x%lx", (unsigned)ntohs(dp->icmp_id), (unsigned)ntohs(dp->icmp_seq), (unsigned long)ntohl(dp->icmp_otime), (unsigned long)ntohl(dp->icmp_rtime), (unsigned long)ntohl(dp->icmp_ttime)); break; default: str = tok2str(icmp2str, "type-#%d", dp->icmp_type); break; } (void)printf("icmp: %s", str); if (vflag) { if (TTEST2(*bp, plen)) { if (in_cksum((u_short*)dp, plen, 0)) printf(" (wrong icmp csum)"); } } if (vflag > 1 && !ICMP_INFOTYPE(dp->icmp_type)) { bp += 8; (void)printf(" for "); ip = (struct ip *)bp; snaplen = snapend - bp; ip_print(bp, ntohs(ip->ip_len)); } return; trunc: fputs("[|icmp]", stdout); } tcpdump-3.7.2/print-icmp6.c0100644000076500000240000005771207627054627014707 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.56.4.1 2002/05/31 10:08:31 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef INET6 #include #include #include #include #include #include #include #include #include #include #include "ip6.h" #include "icmp6.h" #include "interface.h" #include "addrtoname.h" #include "udp.h" #include "ah.h" static const char *get_rtpref(u_int); static const char *get_lifetime(u_int32_t); static void print_lladdr(const u_char *, size_t); void icmp6_opt_print(const u_char *, int); void mld6_print(const u_char *); static struct udphdr *get_upperlayer(u_char *, int *); static void dnsname_print(const u_char *, const u_char *); void icmp6_nodeinfo_print(int, const u_char *, const u_char *); void icmp6_rrenum_print(int, const u_char *, const u_char *); #ifndef abs #define abs(a) ((0 < (a)) ? (a) : -(a)) #endif static const char * get_rtpref(u_int v) { static const char *rtpref_str[] = { "medium", /* 00 */ "high", /* 01 */ "rsv", /* 10 */ "low" /* 11 */ }; return rtpref_str[((v & ND_RA_FLAG_RTPREF_MASK) >> 3) & 0xff]; } static const char * get_lifetime(u_int32_t v) { static char buf[20]; if (v == (u_int32_t)~0UL) return "infinity"; else { snprintf(buf, sizeof(buf), "%u", v); return buf; } } static void print_lladdr(const u_int8_t *p, size_t l) { const u_int8_t *ep, *q; q = p; ep = p + l; while (l > 0 && q < ep) { if (q > p) printf(":"); printf("%02x", *q++); l--; } } void icmp6_print(const u_char *bp, const u_char *bp2) { const struct icmp6_hdr *dp; const struct ip6_hdr *ip; const char *str; const struct ip6_hdr *oip; const struct udphdr *ouh; int dport; const u_char *ep; char buf[256]; int icmp6len, prot; dp = (struct icmp6_hdr *)bp; ip = (struct ip6_hdr *)bp2; oip = (struct ip6_hdr *)(dp + 1); str = buf; /* 'ep' points to the end of available data. */ ep = snapend; if (ip->ip6_plen) icmp6len = (ntohs(ip->ip6_plen) + sizeof(struct ip6_hdr) - (bp - bp2)); else /* XXX: jumbo payload case... */ icmp6len = snapend - bp; TCHECK(dp->icmp6_code); switch (dp->icmp6_type) { case ICMP6_DST_UNREACH: TCHECK(oip->ip6_dst); switch (dp->icmp6_code) { case ICMP6_DST_UNREACH_NOROUTE: printf("icmp6: %s unreachable route", ip6addr_string(&oip->ip6_dst)); break; case ICMP6_DST_UNREACH_ADMIN: printf("icmp6: %s unreachable prohibited", ip6addr_string(&oip->ip6_dst)); break; case ICMP6_DST_UNREACH_BEYONDSCOPE: printf("icmp6: %s beyond scope of source address %s", ip6addr_string(&oip->ip6_dst), ip6addr_string(&oip->ip6_src)); break; case ICMP6_DST_UNREACH_ADDR: printf("icmp6: %s unreachable address", ip6addr_string(&oip->ip6_dst)); break; case ICMP6_DST_UNREACH_NOPORT: if ((ouh = get_upperlayer((u_char *)oip, &prot)) == NULL) goto trunc; dport = ntohs(ouh->uh_dport); switch (prot) { case IPPROTO_TCP: printf("icmp6: %s tcp port %s unreachable", ip6addr_string(&oip->ip6_dst), tcpport_string(dport)); break; case IPPROTO_UDP: printf("icmp6: %s udp port %s unreachable", ip6addr_string(&oip->ip6_dst), udpport_string(dport)); break; default: printf("icmp6: %s protocol %d port %d unreachable", ip6addr_string(&oip->ip6_dst), oip->ip6_nxt, dport); break; } break; default: printf("icmp6: %s unreachable code-#%d", ip6addr_string(&oip->ip6_dst), dp->icmp6_code); break; } break; case ICMP6_PACKET_TOO_BIG: TCHECK(dp->icmp6_mtu); printf("icmp6: too big %u", (u_int32_t)ntohl(dp->icmp6_mtu)); break; case ICMP6_TIME_EXCEEDED: TCHECK(oip->ip6_dst); switch (dp->icmp6_code) { case ICMP6_TIME_EXCEED_TRANSIT: printf("icmp6: time exceeded in-transit for %s", ip6addr_string(&oip->ip6_dst)); break; case ICMP6_TIME_EXCEED_REASSEMBLY: printf("icmp6: ip6 reassembly time exceeded"); break; default: printf("icmp6: time exceeded code-#%d", dp->icmp6_code); break; } break; case ICMP6_PARAM_PROB: TCHECK(oip->ip6_dst); switch (dp->icmp6_code) { case ICMP6_PARAMPROB_HEADER: printf("icmp6: parameter problem errorneous - octet %u", (u_int32_t)ntohl(dp->icmp6_pptr)); break; case ICMP6_PARAMPROB_NEXTHEADER: printf("icmp6: parameter problem next header - octet %u", (u_int32_t)ntohl(dp->icmp6_pptr)); break; case ICMP6_PARAMPROB_OPTION: printf("icmp6: parameter problem option - octet %u", (u_int32_t)ntohl(dp->icmp6_pptr)); break; default: printf("icmp6: parameter problem code-#%d", dp->icmp6_code); break; } break; case ICMP6_ECHO_REQUEST: printf("icmp6: echo request"); break; case ICMP6_ECHO_REPLY: printf("icmp6: echo reply"); break; case ICMP6_MEMBERSHIP_QUERY: printf("icmp6: multicast listener query "); mld6_print((const u_char *)dp); break; case ICMP6_MEMBERSHIP_REPORT: printf("icmp6: multicast listener report "); mld6_print((const u_char *)dp); break; case ICMP6_MEMBERSHIP_REDUCTION: printf("icmp6: multicast listener done "); mld6_print((const u_char *)dp); break; case ND_ROUTER_SOLICIT: printf("icmp6: router solicitation "); if (vflag) { #define RTSOLLEN 8 icmp6_opt_print((const u_char *)dp + RTSOLLEN, icmp6len - RTSOLLEN); } break; case ND_ROUTER_ADVERT: printf("icmp6: router advertisement"); if (vflag) { struct nd_router_advert *p; p = (struct nd_router_advert *)dp; TCHECK(p->nd_ra_retransmit); printf("(chlim=%d, ", (int)p->nd_ra_curhoplimit); if (p->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED) printf("M"); if (p->nd_ra_flags_reserved & ND_RA_FLAG_OTHER) printf("O"); if (p->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT) printf("H"); if ((p->nd_ra_flags_reserved & ~ND_RA_FLAG_RTPREF_MASK) != 0) printf(" "); printf("pref=%s, ", get_rtpref(p->nd_ra_flags_reserved)); printf("router_ltime=%d, ", ntohs(p->nd_ra_router_lifetime)); printf("reachable_time=%u, ", (u_int32_t)ntohl(p->nd_ra_reachable)); printf("retrans_time=%u)", (u_int32_t)ntohl(p->nd_ra_retransmit)); #define RTADVLEN 16 icmp6_opt_print((const u_char *)dp + RTADVLEN, icmp6len - RTADVLEN); } break; case ND_NEIGHBOR_SOLICIT: { struct nd_neighbor_solicit *p; p = (struct nd_neighbor_solicit *)dp; TCHECK(p->nd_ns_target); printf("icmp6: neighbor sol: who has %s", ip6addr_string(&p->nd_ns_target)); if (vflag) { #define NDSOLLEN 24 icmp6_opt_print((const u_char *)dp + NDSOLLEN, icmp6len - NDSOLLEN); } } break; case ND_NEIGHBOR_ADVERT: { struct nd_neighbor_advert *p; p = (struct nd_neighbor_advert *)dp; TCHECK(p->nd_na_target); printf("icmp6: neighbor adv: tgt is %s", ip6addr_string(&p->nd_na_target)); if (vflag) { #define ND_NA_FLAG_ALL \ (ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE) /* we don't need ntohl() here. see advanced-api-04. */ if (p->nd_na_flags_reserved & ND_NA_FLAG_ALL) { #undef ND_NA_FLAG_ALL u_int32_t flags; flags = p->nd_na_flags_reserved; printf("("); if (flags & ND_NA_FLAG_ROUTER) printf("R"); if (flags & ND_NA_FLAG_SOLICITED) printf("S"); if (flags & ND_NA_FLAG_OVERRIDE) printf("O"); printf(")"); } #define NDADVLEN 24 icmp6_opt_print((const u_char *)dp + NDADVLEN, icmp6len - NDADVLEN); #undef NDADVLEN } } break; case ND_REDIRECT: #define RDR(i) ((struct nd_redirect *)(i)) TCHECK(RDR(dp)->nd_rd_dst); printf("icmp6: redirect %s", getname6((const u_char *)&RDR(dp)->nd_rd_dst)); printf(" to %s", getname6((const u_char*)&RDR(dp)->nd_rd_target)); #define REDIRECTLEN 40 if (vflag) { icmp6_opt_print((const u_char *)dp + REDIRECTLEN, icmp6len - REDIRECTLEN); } break; #undef REDIRECTLEN #undef RDR case ICMP6_ROUTER_RENUMBERING: icmp6_rrenum_print(icmp6len, bp, ep); break; case ICMP6_NI_QUERY: case ICMP6_NI_REPLY: icmp6_nodeinfo_print(icmp6len, bp, ep); break; default: printf("icmp6: type-#%d", dp->icmp6_type); break; } return; trunc: fputs("[|icmp6]", stdout); } static struct udphdr * get_upperlayer(u_char *bp, int *prot) { const u_char *ep; struct ip6_hdr *ip6 = (struct ip6_hdr *)bp; struct udphdr *uh; struct ip6_hbh *hbh; struct ip6_frag *fragh; struct ah *ah; int nh, hlen; /* 'ep' points to the end of available data. */ ep = snapend; if (TTEST(ip6->ip6_nxt) == 0) return NULL; nh = ip6->ip6_nxt; hlen = sizeof(struct ip6_hdr); while (bp < snapend) { bp += hlen; switch(nh) { case IPPROTO_UDP: case IPPROTO_TCP: uh = (struct udphdr *)bp; if (TTEST(uh->uh_dport)) { *prot = nh; return(uh); } else return(NULL); /* NOTREACHED */ case IPPROTO_HOPOPTS: case IPPROTO_DSTOPTS: case IPPROTO_ROUTING: hbh = (struct ip6_hbh *)bp; if (TTEST(hbh->ip6h_len) == 0) return(NULL); nh = hbh->ip6h_nxt; hlen = (hbh->ip6h_len + 1) << 3; break; case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */ fragh = (struct ip6_frag *)bp; if (TTEST(fragh->ip6f_offlg) == 0) return(NULL); /* fragments with non-zero offset are meaningless */ if ((fragh->ip6f_offlg & IP6F_OFF_MASK) != 0) return(NULL); nh = fragh->ip6f_nxt; hlen = sizeof(struct ip6_frag); break; case IPPROTO_AH: ah = (struct ah *)bp; if (TTEST(ah->ah_len) == 0) return(NULL); nh = ah->ah_nxt; hlen = (ah->ah_len + 2) << 2; break; default: /* unknown or undecodable header */ *prot = nh; /* meaningless, but set here anyway */ return(NULL); } } return(NULL); /* should be notreached, though */ } void icmp6_opt_print(const u_char *bp, int resid) { const struct nd_opt_hdr *op; const struct nd_opt_hdr *opl; /* why there's no struct? */ const struct nd_opt_prefix_info *opp; const struct icmp6_opts_redirect *opr; const struct nd_opt_mtu *opm; const struct nd_opt_advinterval *opa; const struct nd_opt_route_info *opri; const u_char *cp, *ep; struct in6_addr in6, *in6p; size_t l; #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return cp = bp; /* 'ep' points to the end of available data. */ ep = snapend; while (cp < ep) { op = (struct nd_opt_hdr *)cp; ECHECK(op->nd_opt_len); if (resid <= 0) return; if (op->nd_opt_len == 0) goto trunc; if (cp + (op->nd_opt_len << 3) > ep) goto trunc; switch (op->nd_opt_type) { case ND_OPT_SOURCE_LINKADDR: opl = (struct nd_opt_hdr *)op; printf("(src lladdr: "); l = (op->nd_opt_len << 3) - 2; print_lladdr(cp + 2, l); /*(*/ printf(")"); break; case ND_OPT_TARGET_LINKADDR: opl = (struct nd_opt_hdr *)op; printf("(tgt lladdr: "); l = (op->nd_opt_len << 3) - 2; print_lladdr(cp + 2, l); /*(*/ printf(")"); break; case ND_OPT_PREFIX_INFORMATION: opp = (struct nd_opt_prefix_info *)op; TCHECK(opp->nd_opt_pi_prefix); printf("(prefix info: "); /*)*/ if (op->nd_opt_len != 4) { printf("badlen"); /*(*/ printf(")"); break; } if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK) printf("L"); if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO) printf("A"); if (opp->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ROUTER) printf("R"); if (opp->nd_opt_pi_flags_reserved) printf(" "); printf("valid_ltime=%s,", get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_valid_time))); printf("preferred_ltime=%s,", get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_preferred_time))); printf("prefix=%s/%d", ip6addr_string(&opp->nd_opt_pi_prefix), opp->nd_opt_pi_prefix_len); if (opp->nd_opt_pi_len != 4) printf("!"); /*(*/ printf(")"); break; case ND_OPT_REDIRECTED_HEADER: opr = (struct icmp6_opts_redirect *)op; printf("(redirect)"); /* xxx */ break; case ND_OPT_MTU: opm = (struct nd_opt_mtu *)op; TCHECK(opm->nd_opt_mtu_mtu); printf("(mtu:"); /*)*/ if (op->nd_opt_len != 1) { printf("badlen"); /*(*/ printf(")"); break; } printf(" mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu)); if (opm->nd_opt_mtu_len != 1) printf("!"); printf(")"); break; case ND_OPT_ADVINTERVAL: opa = (struct nd_opt_advinterval *)op; TCHECK(opa->nd_opt_adv_interval); printf("(advint:"); /*)*/ printf(" advint=%u", (u_int32_t)ntohl(opa->nd_opt_adv_interval)); /*(*/ printf(")"); break; case ND_OPT_ROUTE_INFO: opri = (struct nd_opt_route_info *)op; TCHECK(opri->nd_opt_rti_lifetime); memset(&in6, 0, sizeof(in6)); in6p = (struct in6_addr *)(opri + 1); switch (op->nd_opt_len) { case 1: break; case 2: TCHECK2(*in6p, 8); memcpy(&in6, opri + 1, 8); break; case 3: TCHECK(*in6p); memcpy(&in6, opri + 1, sizeof(in6)); break; default: goto trunc; } printf("(rtinfo:"); /*)*/ printf(" %s/%u", ip6addr_string(&in6), opri->nd_opt_rti_prefixlen); printf(", pref=%s", get_rtpref(opri->nd_opt_rti_flags)); printf(", lifetime=%s", get_lifetime((u_int32_t)ntohl(opri->nd_opt_rti_lifetime))); /*(*/ printf(")"); break; default: printf("(unknown opt_type=%d, opt_len=%d)", op->nd_opt_type, op->nd_opt_len); break; } cp += op->nd_opt_len << 3; resid -= op->nd_opt_len << 3; } return; trunc: fputs("[ndp opt]", stdout); return; #undef ECHECK } void mld6_print(const u_char *bp) { struct mld6_hdr *mp = (struct mld6_hdr *)bp; const u_char *ep; /* 'ep' points to the end of available data. */ ep = snapend; if ((u_char *)mp + sizeof(*mp) > ep) return; printf("max resp delay: %d ", ntohs(mp->mld6_maxdelay)); printf("addr: %s", ip6addr_string(&mp->mld6_addr)); } static void dnsname_print(const u_char *cp, const u_char *ep) { int i; /* DNS name decoding - no decompression */ printf(", \""); while (cp < ep) { i = *cp++; if (i) { if (i > ep - cp) { printf("???"); break; } while (i-- && cp < ep) { safeputchar(*cp); cp++; } if (cp + 1 < ep && *cp) printf("."); } else { if (cp == ep) { /* FQDN */ printf("."); } else if (cp + 1 == ep && *cp == '\0') { /* truncated */ } else { /* invalid */ printf("???"); } break; } } printf("\""); } void icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep) { struct icmp6_nodeinfo *ni6; struct icmp6_hdr *dp; const u_char *cp; int siz, i; int needcomma; dp = (struct icmp6_hdr *)bp; ni6 = (struct icmp6_nodeinfo *)bp; siz = ep - bp; switch (ni6->ni_type) { case ICMP6_NI_QUERY: if (siz == sizeof(*dp) + 4) { /* KAME who-are-you */ printf("icmp6: who-are-you request"); break; } printf("icmp6: node information query"); TCHECK2(*dp, sizeof(*ni6)); ni6 = (struct icmp6_nodeinfo *)dp; printf(" ("); /*)*/ switch (ntohs(ni6->ni_qtype)) { case NI_QTYPE_NOOP: printf("noop"); break; case NI_QTYPE_SUPTYPES: printf("supported qtypes"); i = ntohs(ni6->ni_flags); if (i) printf(" [%s]", (i & 0x01) ? "C" : ""); break; break; case NI_QTYPE_FQDN: printf("DNS name"); break; case NI_QTYPE_NODEADDR: printf("node addresses"); i = ni6->ni_flags; if (!i) break; /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */ printf(" [%s%s%s%s%s%s]", (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "", (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "", (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "", (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "", (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "", (i & NI_NODEADDR_FLAG_ALL) ? "A" : ""); break; default: printf("unknown"); break; } if (ni6->ni_qtype == NI_QTYPE_NOOP || ni6->ni_qtype == NI_QTYPE_SUPTYPES) { if (siz != sizeof(*ni6)) if (vflag) printf(", invalid len"); /*(*/ printf(")"); break; } /* XXX backward compat, icmp-name-lookup-03 */ if (siz == sizeof(*ni6)) { printf(", 03 draft"); /*(*/ printf(")"); break; } switch (ni6->ni_code) { case ICMP6_NI_SUBJ_IPV6: if (!TTEST2(*dp, sizeof(*ni6) + sizeof(struct in6_addr))) break; if (siz != sizeof(*ni6) + sizeof(struct in6_addr)) { if (vflag) printf(", invalid subject len"); break; } printf(", subject=%s", getname6((const u_char *)(ni6 + 1))); break; case ICMP6_NI_SUBJ_FQDN: printf(", subject=DNS name"); cp = (const u_char *)(ni6 + 1); if (cp[0] == ep - cp - 1) { /* icmp-name-lookup-03, pascal string */ if (vflag) printf(", 03 draft"); cp++; printf(", \""); while (cp < ep) { safeputchar(*cp); cp++; } printf("\""); } else dnsname_print(cp, ep); break; case ICMP6_NI_SUBJ_IPV4: if (!TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr))) break; if (siz != sizeof(*ni6) + sizeof(struct in_addr)) { if (vflag) printf(", invalid subject len"); break; } printf(", subject=%s", getname((const u_char *)(ni6 + 1))); break; default: printf(", unknown subject"); break; } /*(*/ printf(")"); break; case ICMP6_NI_REPLY: if (icmp6len > siz) { printf("[|icmp6: node information reply]"); break; } needcomma = 0; ni6 = (struct icmp6_nodeinfo *)dp; printf("icmp6: node information reply"); printf(" ("); /*)*/ switch (ni6->ni_code) { case ICMP6_NI_SUCCESS: if (vflag) { printf("success"); needcomma++; } break; case ICMP6_NI_REFUSED: printf("refused"); needcomma++; if (siz != sizeof(*ni6)) if (vflag) printf(", invalid length"); break; case ICMP6_NI_UNKNOWN: printf("unknown"); needcomma++; if (siz != sizeof(*ni6)) if (vflag) printf(", invalid length"); break; } if (ni6->ni_code != ICMP6_NI_SUCCESS) { /*(*/ printf(")"); break; } switch (ntohs(ni6->ni_qtype)) { case NI_QTYPE_NOOP: if (needcomma) printf(", "); printf("noop"); if (siz != sizeof(*ni6)) if (vflag) printf(", invalid length"); break; case NI_QTYPE_SUPTYPES: if (needcomma) printf(", "); printf("supported qtypes"); i = ntohs(ni6->ni_flags); if (i) printf(" [%s]", (i & 0x01) ? "C" : ""); break; case NI_QTYPE_FQDN: if (needcomma) printf(", "); printf("DNS name"); cp = (const u_char *)(ni6 + 1) + 4; if (cp[0] == ep - cp - 1) { /* icmp-name-lookup-03, pascal string */ if (vflag) printf(", 03 draft"); cp++; printf(", \""); while (cp < ep) { safeputchar(*cp); cp++; } printf("\""); } else dnsname_print(cp, ep); if ((ntohs(ni6->ni_flags) & 0x01) != 0) printf(" [TTL=%u]", *(u_int32_t *)(ni6 + 1)); break; case NI_QTYPE_NODEADDR: if (needcomma) printf(", "); printf("node addresses"); i = sizeof(*ni6); while (i < siz) { if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz) break; printf(" %s", getname6(bp + i)); i += sizeof(struct in6_addr); printf("(%d)", (int32_t)ntohl(*(int32_t *)(bp + i))); i += sizeof(int32_t); } i = ni6->ni_flags; if (!i) break; printf(" [%s%s%s%s%s%s%s]", (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "", (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "", (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "", (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "", (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "", (i & NI_NODEADDR_FLAG_ALL) ? "A" : "", (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : ""); break; default: if (needcomma) printf(", "); printf("unknown"); break; } /*(*/ printf(")"); break; } return; trunc: fputs("[|icmp6]", stdout); } void icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep) { struct icmp6_router_renum *rr6; struct icmp6_hdr *dp; size_t siz; const char *cp; struct rr_pco_match *match; struct rr_pco_use *use; char hbuf[NI_MAXHOST]; int n; dp = (struct icmp6_hdr *)bp; rr6 = (struct icmp6_router_renum *)bp; siz = ep - bp; cp = (const char *)(rr6 + 1); TCHECK(rr6->rr_reserved); switch (rr6->rr_code) { case ICMP6_ROUTER_RENUMBERING_COMMAND: printf("router renum: command"); break; case ICMP6_ROUTER_RENUMBERING_RESULT: printf("router renum: result"); break; case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET: printf("router renum: sequence number reset"); break; default: printf("router renum: code-#%d", rr6->rr_code); break; } printf(", seq=%u", (u_int32_t)ntohl(rr6->rr_seqnum)); if (vflag) { #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "") printf("["); /*]*/ if (rr6->rr_flags) { printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"), F(ICMP6_RR_FLAGS_REQRESULT, "R"), F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"), F(ICMP6_RR_FLAGS_SPECSITE, "S"), F(ICMP6_RR_FLAGS_PREVDONE, "P")); } printf("seg=%u,", rr6->rr_segnum); printf("maxdelay=%u", rr6->rr_maxdelay); if (rr6->rr_reserved) printf("rsvd=0x%x", (u_int16_t)ntohs(rr6->rr_reserved)); /*[*/ printf("]"); #undef F } if (rr6->rr_code == ICMP6_ROUTER_RENUMBERING_COMMAND) { match = (struct rr_pco_match *)cp; cp = (const char *)(match + 1); TCHECK(match->rpm_prefix); if (vflag > 1) printf("\n\t"); else printf(" "); printf("match("); /*)*/ switch (match->rpm_code) { case RPM_PCO_ADD: printf("add"); break; case RPM_PCO_CHANGE: printf("change"); break; case RPM_PCO_SETGLOBAL: printf("setglobal"); break; default: printf("#%u", match->rpm_code); break; } if (vflag) { printf(",ord=%u", match->rpm_ordinal); printf(",min=%u", match->rpm_minlen); printf(",max=%u", match->rpm_maxlen); } if (inet_ntop(AF_INET6, &match->rpm_prefix, hbuf, sizeof(hbuf))) printf(",%s/%u", hbuf, match->rpm_matchlen); else printf(",?/%u", match->rpm_matchlen); /*(*/ printf(")"); n = match->rpm_len - 3; if (n % 4) goto trunc; n /= 4; while (n-- > 0) { use = (struct rr_pco_use *)cp; cp = (const char *)(use + 1); TCHECK(use->rpu_prefix); if (vflag > 1) printf("\n\t"); else printf(" "); printf("use("); /*)*/ if (use->rpu_flags) { #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "") printf("%s%s,", F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"), F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P")); #undef F } if (vflag) { printf("mask=0x%x,", use->rpu_ramask); printf("raflags=0x%x,", use->rpu_raflags); if (~use->rpu_vltime == 0) printf("vltime=infty,"); else printf("vltime=%u,", (u_int32_t)ntohl(use->rpu_vltime)); if (~use->rpu_pltime == 0) printf("pltime=infty,"); else printf("pltime=%u,", (u_int32_t)ntohl(use->rpu_pltime)); } if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf, sizeof(hbuf))) printf("%s/%u/%u", hbuf, use->rpu_uselen, use->rpu_keeplen); else printf("?/%u/%u", use->rpu_uselen, use->rpu_keeplen); /*(*/ printf(")"); } } return; trunc: fputs("[|icmp6]", stdout); } #endif /* INET6 */ tcpdump-3.7.2/print-igmp.c0100644000076500000240000002170207627054627014613 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.5.4.1 2002/06/02 18:25:05 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ #ifndef IN_CLASSD #define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000) #endif /* (following from ipmulti/mrouted/prune.h) */ /* * The packet format for a traceroute request. */ struct tr_query { u_int tr_src; /* traceroute source */ u_int tr_dst; /* traceroute destination */ u_int tr_raddr; /* traceroute response address */ u_int tr_rttlqid; /* response ttl and qid */ }; #define TR_GETTTL(x) (int)(((x) >> 24) & 0xff) #define TR_GETQID(x) ((x) & 0x00ffffff) /* * Traceroute response format. A traceroute response has a tr_query at the * beginning, followed by one tr_resp for each hop taken. */ struct tr_resp { u_int tr_qarr; /* query arrival time */ u_int tr_inaddr; /* incoming interface address */ u_int tr_outaddr; /* outgoing interface address */ u_int tr_rmtaddr; /* parent address in source tree */ u_int tr_vifin; /* input packet count on interface */ u_int tr_vifout; /* output packet count on interface */ u_int tr_pktcnt; /* total incoming packets for src-grp */ u_char tr_rproto; /* routing proto deployed on router */ u_char tr_fttl; /* ttl required to forward on outvif */ u_char tr_smask; /* subnet mask for src addr */ u_char tr_rflags; /* forwarding error codes */ }; /* defs within mtrace */ #define TR_QUERY 1 #define TR_RESP 2 /* fields for tr_rflags (forwarding error codes) */ #define TR_NO_ERR 0 #define TR_WRONG_IF 1 #define TR_PRUNED 2 #define TR_OPRUNED 3 #define TR_SCOPED 4 #define TR_NO_RTE 5 #define TR_NO_FWD 7 #define TR_NO_SPACE 0x81 #define TR_OLD_ROUTER 0x82 /* fields for tr_rproto (routing protocol) */ #define TR_PROTO_DVMRP 1 #define TR_PROTO_MOSPF 2 #define TR_PROTO_PIM 3 #define TR_PROTO_CBT 4 /* igmpv3 report types */ static struct tok igmpv3report2str[] = { { 1, "is_in" }, { 2, "is_ex" }, { 3, "to_in" }, { 4, "to_ex" }, { 5, "allow" }, { 6, "block" }, { 0, NULL } }; static void print_mtrace(register const u_char *bp, register u_int len) { register const struct tr_query *tr = (const struct tr_query *)(bp + 8); printf("mtrace %lu: %s to %s reply-to %s", (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)), ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst), ipaddr_string(&tr->tr_raddr)); if (IN_CLASSD(ntohl(tr->tr_raddr))) printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid))); } static void print_mresp(register const u_char *bp, register u_int len) { register const struct tr_query *tr = (const struct tr_query *)(bp + 8); printf("mresp %lu: %s to %s reply-to %s", (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)), ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst), ipaddr_string(&tr->tr_raddr)); if (IN_CLASSD(ntohl(tr->tr_raddr))) printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid))); } static void print_igmpv3_report(register const u_char *bp, register u_int len) { u_int group, nsrcs, ngroups; register u_int i, j; /* Minimum len is 16, and should be a multiple of 4 */ if (len < 16 || len & 0x03) { (void)printf(" [invalid len %d]", len); return; } TCHECK2(bp[6], 2); ngroups = EXTRACT_16BITS(&bp[6]); (void)printf(", %d group record(s)", ngroups); if (vflag > 0) { /* Print the group records */ group = 8; for (i=0; i> 4) + 3); } if (mrc != 100) { (void)printf(" [max resp time "); relts_print(mrt); (void)printf("]"); } TCHECK2(bp[4], 4); if (EXTRACT_32BITS(&bp[4]) == 0) return; (void)printf(" [gaddr %s", ipaddr_string(&bp[4])); TCHECK2(bp[10], 2); nsrcs = EXTRACT_16BITS(&bp[10]); if (nsrcs > 0) { if (len < 12 + (nsrcs << 2)) (void)printf(" [invalid number of sources]"); else if (vflag > 1) { (void)printf(" {"); for (i=0; i= 12) print_igmpv3_query(bp, len); else { if (bp[1]) { (void)printf(" v2"); if (bp[1] != 100) (void)printf(" [max resp time %d]", bp[1]); } else (void)printf(" v1"); if (EXTRACT_32BITS(&bp[4])) (void)printf(" [gaddr %s]", ipaddr_string(&bp[4])); if (len != 8) (void)printf(" [len %d]", len); } break; case 0x12: (void)printf("igmp v1 report %s", ipaddr_string(&bp[4])); if (len != 8) (void)printf(" [len %d]", len); break; case 0x16: (void)printf("igmp v2 report %s", ipaddr_string(&bp[4])); break; case 0x22: (void)printf("igmp v3 report"); print_igmpv3_report(bp, len); break; case 0x17: (void)printf("igmp leave %s", ipaddr_string(&bp[4])); break; case 0x13: (void)printf("igmp dvmrp"); if (len < 8) (void)printf(" [len %d]", len); else dvmrp_print(bp, len); break; case 0x14: (void)printf("igmp pimv1"); pimv1_print(bp, len); break; case 0x1e: print_mresp(bp, len); break; case 0x1f: print_mtrace(bp, len); break; default: (void)printf("igmp-%d", bp[0]); break; } if (vflag && TTEST2(bp[0], len)) { /* Check the IGMP checksum */ if (in_cksum((const u_short*)bp, len, 0)) printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2])); } return; trunc: fputs("[|igmp]", stdout); } tcpdump-3.7.2/print-igrp.c0100644000076500000240000000760507312504574014616 0ustar fennerstaff/* * Copyright (c) 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Initial contribution from Francis Dupont (francis.dupont@inria.fr) */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.16 2001/06/15 22:17:32 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include /* concession to AIX */ #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "igrp.h" #include "ip.h" #include "extract.h" /* must come after interface.h */ static void igrp_entry_print(register struct igrprte *igr, register int is_interior, register int is_exterior) { register u_int delay, bandwidth; u_int metric, mtu; if (is_interior) printf(" *.%d.%d.%d", igr->igr_net[0], igr->igr_net[1], igr->igr_net[2]); else if (is_exterior) printf(" X%d.%d.%d.0", igr->igr_net[0], igr->igr_net[1], igr->igr_net[2]); else printf(" %d.%d.%d.0", igr->igr_net[0], igr->igr_net[1], igr->igr_net[2]); delay = EXTRACT_24BITS(igr->igr_dly); bandwidth = EXTRACT_24BITS(igr->igr_bw); metric = bandwidth + delay; if (metric > 0xffffff) metric = 0xffffff; mtu = EXTRACT_16BITS(igr->igr_mtu); printf(" d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops", 10 * delay, bandwidth == 0 ? 0 : 10000000 / bandwidth, igr->igr_rel, igr->igr_ld, metric, mtu, igr->igr_hct); } static struct tok op2str[] = { { IGRP_UPDATE, "update" }, { IGRP_REQUEST, "request" }, { 0, NULL } }; void igrp_print(register const u_char *bp, u_int length, register const u_char *bp2) { register struct igrphdr *hdr; register struct ip *ip; register u_char *cp; u_int nint, nsys, next; hdr = (struct igrphdr *)bp; ip = (struct ip *)bp2; cp = (u_char *)(hdr + 1); (void)printf("igrp:"); /* Header */ TCHECK(*hdr); nint = EXTRACT_16BITS(&hdr->ig_ni); nsys = EXTRACT_16BITS(&hdr->ig_ns); next = EXTRACT_16BITS(&hdr->ig_nx); (void)printf(" %s V%d edit=%d AS=%d (%d/%d/%d)", tok2str(op2str, "op-#%d", IGRP_OP(hdr->ig_vop)), IGRP_V(hdr->ig_vop), hdr->ig_ed, EXTRACT_16BITS(&hdr->ig_as), nint, nsys, next); length -= sizeof(*hdr); while (length >= IGRP_RTE_SIZE) { if (nint > 0) { TCHECK2(*cp, IGRP_RTE_SIZE); igrp_entry_print((struct igrprte *)cp, 1, 0); --nint; } else if (nsys > 0) { TCHECK2(*cp, IGRP_RTE_SIZE); igrp_entry_print((struct igrprte *)cp, 0, 0); --nsys; } else if (next > 0) { TCHECK2(*cp, IGRP_RTE_SIZE); igrp_entry_print((struct igrprte *)cp, 0, 1); --next; } else { (void)printf(" [extra bytes %d]", length); break; } cp += IGRP_RTE_SIZE; length -= IGRP_RTE_SIZE; } if (nint == 0 && nsys == 0 && next == 0) return; trunc: fputs(" [|igrp]", stdout); } tcpdump-3.7.2/print-ip.c0100644000076500000240000003026507627054627014273 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.100.4.1 2002/01/25 05:39:54 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include "addrtoname.h" #include "interface.h" #include "extract.h" /* must come after interface.h */ #include "ip.h" /* Compatibility */ #ifndef IPPROTO_ND #define IPPROTO_ND 77 #endif /* * print the recorded route in an IP RR, LSRR or SSRR option. */ static void ip_printroute(const char *type, register const u_char *cp, u_int length) { register u_int ptr = cp[2] - 1; register u_int len; printf(" %s{", type); if ((length + 1) & 3) printf(" [bad length %d]", length); if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1) printf(" [bad ptr %d]", cp[2]); type = ""; for (len = 3; len < length; len += 4) { if (ptr == len) type = "#"; printf("%s%s", type, ipaddr_string(&cp[len])); type = " "; } printf("%s}", ptr == len? "#" : ""); } static void ip_printts(register const u_char *cp, u_int length) { register u_int ptr = cp[2] - 1; register u_int len = 0; int hoplen; char *type; printf(" TS{"); hoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4; if ((length - 4) & (hoplen-1)) printf("[bad length %d]", length); if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1) printf("[bad ptr %d]", cp[2]); switch (cp[3]&0xF) { case IPOPT_TS_TSONLY: printf("TSONLY"); break; case IPOPT_TS_TSANDADDR: printf("TS+ADDR"); break; /* * prespecified should really be 3, but some ones might send 2 * instead, and the IPOPT_TS_PRESPEC constant can apparently * have both values, so we have to hard-code it here. */ case 2: printf("PRESPEC2.0"); break; case 3: /* IPOPT_TS_PRESPEC */ printf("PRESPEC"); break; default: printf("[bad ts type %d]", cp[3]&0xF); goto done; } type = " "; for (len = 4; len < length; len += hoplen) { if (ptr == len) type = " ^ "; printf("%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]), hoplen!=8 ? "" : ipaddr_string(&cp[len])); type = " "; } done: printf("%s", ptr == len ? " ^ " : ""); if (cp[3]>>4) printf(" [%d hops not recorded]} ", cp[3]>>4); else printf("}"); } /* * print IP options. */ static void ip_optprint(register const u_char *cp, u_int length) { register u_int len; for (; length > 0; cp += len, length -= len) { int tt = *cp; if (tt == IPOPT_NOP || tt == IPOPT_EOL) len = 1; else { if (&cp[1] >= snapend) { printf("[|ip]"); return; } len = cp[1]; } if (len <= 0) { printf("[|ip op len %d]", len); return; } if (&cp[1] >= snapend || cp + len > snapend) { printf("[|ip]"); return; } switch (tt) { case IPOPT_EOL: printf(" EOL"); if (length > 1) printf("-%d", length - 1); return; case IPOPT_NOP: printf(" NOP"); break; case IPOPT_TS: ip_printts(cp, len); break; #ifndef IPOPT_SECURITY #define IPOPT_SECURITY 130 #endif /* IPOPT_SECURITY */ case IPOPT_SECURITY: printf(" SECURITY{%d}", len); break; case IPOPT_RR: ip_printroute("RR", cp, len); break; case IPOPT_SSRR: ip_printroute("SSRR", cp, len); break; case IPOPT_LSRR: ip_printroute("LSRR", cp, len); break; #ifndef IPOPT_RA #define IPOPT_RA 148 /* router alert */ #endif case IPOPT_RA: printf(" RA"); if (len != 4) printf("{%d}", len); else if (cp[2] || cp[3]) printf("%d.%d", cp[2], cp[3]); break; default: printf(" IPOPT-%d{%d}", cp[0], len); break; } } } /* * 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); } /* * print an IP datagram. */ void ip_print(register const u_char *bp, register u_int length) { register const struct ip *ip; register u_int hlen, len, len0, off; register const u_char *cp; u_char nh; int advance; struct protoent *proto; ip = (const struct ip *)bp; #ifdef LBL_ALIGN /* * If the IP header is not aligned, copy into abuf. */ if ((long)ip & 3) { static u_char *abuf = NULL; static int didwarn = 0; if (abuf == NULL) { abuf = (u_char *)malloc(snaplen); if (abuf == NULL) error("ip_print: malloc"); } memcpy((char *)abuf, (char *)ip, min(length, snaplen)); snapend += abuf - (u_char *)ip; packetp = abuf; ip = (struct ip *)abuf; /* We really want libpcap to give us aligned packets */ if (!didwarn) { warning("compensating for unaligned libpcap packets"); ++didwarn; } } #endif if ((u_char *)(ip + 1) > snapend) { printf("[|ip]"); return; } if (length < sizeof (struct ip)) { (void)printf("truncated-ip %d", length); return; } hlen = IP_HL(ip) * 4; if (hlen < sizeof (struct ip)) { (void)printf("bad-hlen %d", hlen); return; } len = ntohs(ip->ip_len); if (length < len) (void)printf("truncated-ip - %d bytes missing! ", len - length); len -= hlen; len0 = len; /* * If this is fragment zero, hand it to the next higher * level protocol. */ off = ntohs(ip->ip_off); if ((off & 0x1fff) == 0) { cp = (const u_char *)ip + hlen; nh = ip->ip_p; #ifndef IPPROTO_SCTP #define IPPROTO_SCTP 132 #endif if (nh != IPPROTO_TCP && nh != IPPROTO_UDP && nh != IPPROTO_SCTP) { (void)printf("%s > %s: ", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); } again: switch (nh) { #ifndef IPPROTO_AH #define IPPROTO_AH 51 #endif case IPPROTO_AH: nh = *cp; advance = ah_print(cp, (const u_char *)ip); cp += advance; len -= advance; goto again; #ifndef IPPROTO_ESP #define IPPROTO_ESP 50 #endif case IPPROTO_ESP: { int enh, padlen; advance = esp_print(cp, (const u_char *)ip, &enh, &padlen); cp += advance; len -= advance + padlen; if (enh < 0) break; nh = enh & 0xff; goto again; } #ifndef IPPROTO_IPCOMP #define IPPROTO_IPCOMP 108 #endif case IPPROTO_IPCOMP: { int enh; advance = ipcomp_print(cp, (const u_char *)ip, &enh); cp += advance; len -= advance; if (enh < 0) break; nh = enh & 0xff; goto again; } case IPPROTO_SCTP: sctp_print(cp, (const u_char *)ip, len); break; case IPPROTO_TCP: tcp_print(cp, len, (const u_char *)ip, (off &~ 0x6000)); break; case IPPROTO_UDP: udp_print(cp, len, (const u_char *)ip, (off &~ 0x6000)); break; case IPPROTO_ICMP: icmp_print(cp, len, (const u_char *)ip); break; #ifndef IPPROTO_IGRP #define IPPROTO_IGRP 9 #endif case IPPROTO_IGRP: igrp_print(cp, len, (const u_char *)ip); break; case IPPROTO_ND: (void)printf(" nd %d", len); break; case IPPROTO_EGP: egp_print(cp, len, (const u_char *)ip); break; #ifndef IPPROTO_OSPF #define IPPROTO_OSPF 89 #endif case IPPROTO_OSPF: ospf_print(cp, len, (const u_char *)ip); break; #ifndef IPPROTO_IGMP #define IPPROTO_IGMP 2 #endif case IPPROTO_IGMP: igmp_print(cp, len); break; case 4: /* DVMRP multicast tunnel (ip-in-ip encapsulation) */ ip_print(cp, len); if (! vflag) { printf(" (ipip-proto-4)"); return; } break; #ifdef INET6 #ifndef IP6PROTO_ENCAP #define IP6PROTO_ENCAP 41 #endif case IP6PROTO_ENCAP: /* ip6-in-ip encapsulation */ ip6_print(cp, len); break; #endif /*INET6*/ #ifndef IPPROTO_GRE #define IPPROTO_GRE 47 #endif case IPPROTO_GRE: /* do it */ gre_print(cp, len); break; #ifndef IPPROTO_MOBILE #define IPPROTO_MOBILE 55 #endif case IPPROTO_MOBILE: mobile_print(cp, len); break; #ifndef IPPROTO_PIM #define IPPROTO_PIM 103 #endif case IPPROTO_PIM: pim_print(cp, len); break; #ifndef IPPROTO_VRRP #define IPPROTO_VRRP 112 #endif case IPPROTO_VRRP: vrrp_print(cp, len, ip->ip_ttl); break; default: if ((proto = getprotobynumber(nh)) != NULL) (void)printf(" %s", proto->p_name); else (void)printf(" ip-proto-%d", nh); printf(" %d", len); break; } } /* Ultra quiet now means that all this stuff should be suppressed */ /* res 3-Nov-98 */ if (qflag > 1) return; /* * for fragmented datagrams, print id:size@offset. On all * but the last stick a "+". For unfragmented datagrams, note * the don't fragment flag. */ len = len0; /* get the original length */ if (off & 0x3fff) { /* * if this isn't the first frag, we're missing the * next level protocol header. print the ip addr * and the protocol. */ if (off & 0x1fff) { (void)printf("%s > %s:", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); if ((proto = getprotobynumber(ip->ip_p)) != NULL) (void)printf(" %s", proto->p_name); else (void)printf(" ip-proto-%d", ip->ip_p); } #ifndef IP_MF #define IP_MF 0x2000 #endif /* IP_MF */ #ifndef IP_DF #define IP_DF 0x4000 #endif /* IP_DF */ (void)printf(" (frag %d:%u@%d%s)", ntohs(ip->ip_id), len, (off & 0x1fff) * 8, (off & IP_MF)? "+" : ""); } else if (off & IP_DF) (void)printf(" (DF)"); if (ip->ip_tos) { (void)printf(" [tos 0x%x", (int)ip->ip_tos); /* ECN bits */ if (ip->ip_tos & 0x03) { switch (ip->ip_tos & 0x03) { case 1: (void)printf(",ECT(1)"); break; case 2: (void)printf(",ECT(0)"); break; case 3: (void)printf(",CE"); } } (void)printf("] "); } if (ip->ip_ttl <= 1) (void)printf(" [ttl %d]", (int)ip->ip_ttl); if (vflag) { int sum; char *sep = ""; printf(" ("); if (ip->ip_ttl > 1) { (void)printf("%sttl %d", sep, (int)ip->ip_ttl); sep = ", "; } if ((off & 0x3fff) == 0) { (void)printf("%sid %d", sep, (int)ntohs(ip->ip_id)); sep = ", "; } (void)printf("%slen %d", sep, (int)ntohs(ip->ip_len)); sep = ", "; if ((u_char *)ip + hlen <= snapend) { sum = in_cksum((const u_short *)ip, hlen, 0); if (sum != 0) { (void)printf("%sbad cksum %x!", sep, ntohs(ip->ip_sum)); sep = ", "; } } if ((hlen -= sizeof(struct ip)) > 0) { (void)printf("%soptlen=%d", sep, hlen); ip_optprint((u_char *)(ip + 1), hlen); } printf(")"); } } void ipN_print(register const u_char *bp, register u_int length) { struct ip *ip, hdr; ip = (struct ip *)bp; if (length < 4) { (void)printf("truncated-ip %d", length); return; } memcpy (&hdr, (char *)ip, 4); switch (IP_V(&hdr)) { case 4: ip_print (bp, length); return; #ifdef INET6 case 6: ip6_print (bp, length); return; #endif default: (void)printf("unknown ip %d", IP_V(&hdr)); return; } } tcpdump-3.7.2/print-ip6.c0100644000076500000240000001251607375073500014347 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.21 2001/11/16 02:17:36 itojun Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef INET6 #include #include #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ip6.h" /* * print an IP6 datagram. */ void ip6_print(register const u_char *bp, register u_int length) { register const struct ip6_hdr *ip6; register int advance; register u_int len; register const u_char *cp; int nh; int fragmented = 0; u_int flow; ip6 = (const struct ip6_hdr *)bp; #ifdef LBL_ALIGN /* * The IP6 header is not 16-byte aligned, so copy into abuf. */ if ((u_long)ip6 & 15) { static u_char *abuf; if (abuf == NULL) { abuf = malloc(snaplen); if (abuf == NULL) error("ip6_print: malloc"); } memcpy(abuf, ip6, min(length, snaplen)); snapend += abuf - (u_char *)ip6; packetp = abuf; ip6 = (struct ip6_hdr *)abuf; bp = abuf; } #endif TCHECK(*ip6); if (length < sizeof (struct ip6_hdr)) { (void)printf("truncated-ip6 %d", length); return; } advance = sizeof(struct ip6_hdr); len = ntohs(ip6->ip6_plen); if (length < len + advance) (void)printf("truncated-ip6 - %d bytes missing!", len + advance - length); cp = (const u_char *)ip6; nh = ip6->ip6_nxt; while (cp < snapend) { cp += advance; if (cp == (const u_char *)(ip6 + 1) && nh != IPPROTO_TCP && nh != IPPROTO_UDP) { (void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src), ip6addr_string(&ip6->ip6_dst)); } switch (nh) { case IPPROTO_HOPOPTS: advance = hbhopt_print(cp); nh = *cp; break; case IPPROTO_DSTOPTS: advance = dstopt_print(cp); nh = *cp; break; case IPPROTO_FRAGMENT: advance = frag6_print(cp, (const u_char *)ip6); if (snapend <= cp + advance) goto end; nh = *cp; fragmented = 1; break; case IPPROTO_ROUTING: advance = rt6_print(cp, (const u_char *)ip6); nh = *cp; break; case IPPROTO_TCP: tcp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp), (const u_char *)ip6, fragmented); goto end; case IPPROTO_UDP: udp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp), (const u_char *)ip6, fragmented); goto end; case IPPROTO_ICMPV6: icmp6_print(cp, (const u_char *)ip6); goto end; case IPPROTO_AH: advance = ah_print(cp, (const u_char *)ip6); nh = *cp; break; case IPPROTO_ESP: { int enh, padlen; advance = esp_print(cp, (const u_char *)ip6, &enh, &padlen); if (enh < 0) goto end; nh = enh & 0xff; len -= padlen; break; } #ifndef IPPROTO_IPCOMP #define IPPROTO_IPCOMP 108 #endif case IPPROTO_IPCOMP: { int enh; advance = ipcomp_print(cp, (const u_char *)ip6, &enh); if (enh < 0) goto end; nh = enh & 0xff; break; } #ifndef IPPROTO_PIM #define IPPROTO_PIM 103 #endif case IPPROTO_PIM: pim_print(cp, len); goto end; #ifndef IPPROTO_OSPF #define IPPROTO_OSPF 89 #endif case IPPROTO_OSPF: ospf6_print(cp, len); goto end; case IPPROTO_IPV6: ip6_print(cp, len); goto end; #ifndef IPPROTO_IPV4 #define IPPROTO_IPV4 4 #endif case IPPROTO_IPV4: ip_print(cp, len); goto end; case IPPROTO_NONE: (void)printf("no next header"); goto end; default: (void)printf("ip-proto-%d %d", ip6->ip6_nxt, len); goto end; } } end: flow = ntohl(ip6->ip6_flow); #if 0 /* rfc1883 */ if (flow & 0x0f000000) (void)printf(" [pri 0x%x]", (flow & 0x0f000000) >> 24); if (flow & 0x00ffffff) (void)printf(" [flowlabel 0x%x]", flow & 0x00ffffff); #else /* RFC 2460 */ if (flow & 0x0ff00000) (void)printf(" [class 0x%x]", (flow & 0x0ff00000) >> 20); if (flow & 0x000fffff) (void)printf(" [flowlabel 0x%x]", flow & 0x000fffff); #endif if (ip6->ip6_hlim <= 1) (void)printf(" [hlim %d]", (int)ip6->ip6_hlim); if (vflag) { printf(" ("); (void)printf("len %d", len); if (ip6->ip6_hlim > 1) (void)printf(", hlim %d", (int)ip6->ip6_hlim); printf(")"); } return; trunc: (void)printf("[|ip6]"); } #endif /* INET6 */ tcpdump-3.7.2/print-ip6opts.c0100644000076500000240000002044007276127676015266 0ustar fennerstaff/* * Copyright (C) 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.9 2001/05/09 02:47:26 itojun Exp $"; #endif #ifdef INET6 #include #include #include #include #include #include #include "ip6.h" #include "interface.h" #include "addrtoname.h" /* items outside of rfc2292bis */ #ifndef IP6OPT_MINLEN #define IP6OPT_MINLEN 2 #endif #ifndef IP6OPT_RTALERT_LEN #define IP6OPT_RTALERT_LEN 4 #endif #ifndef IP6OPT_JUMBO_LEN #define IP6OPT_JUMBO_LEN 6 #endif #define IP6OPT_HOMEADDR_MINLEN 18 #define IP6OPT_BU_MINLEN 10 #define IP6OPT_BA_MINLEN 13 #define IP6OPT_BR_MINLEN 2 #define IP6SOPT_ALTCOA 0x4 #define IP6SOPT_ALTCOA_MINLEN 18 #define IP6SOPT_UI 0x2 #define IP6SOPT_UI_MINLEN 4 static void ip6_sopt_print(const u_char *, int); static void ip6_sopt_print(const u_char *bp, int len) { int i; int optlen; for (i = 0; i < len; i += optlen) { if (bp[i] == IP6OPT_PAD1) optlen = 1; else { if (i + 1 < len) optlen = bp[i + 1] + 2; else goto trunc; } if (i + optlen > len) goto trunc; switch (bp[i]) { case IP6OPT_PAD1: printf(", pad1"); break; case IP6OPT_PADN: if (len - i < IP6OPT_MINLEN) { printf(", padn: trunc"); goto trunc; } printf(", padn"); break; case IP6SOPT_ALTCOA: if (len - i < IP6SOPT_ALTCOA_MINLEN) { printf(", altcoa: trunc"); goto trunc; } printf(", alt-CoA: %s", ip6addr_string(&bp[i+2])); break; case IP6SOPT_UI: if (len - i < IP6SOPT_UI_MINLEN) { printf(", ui: trunc"); goto trunc; } printf("(ui: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2])); break; default: if (len - i < IP6OPT_MINLEN) { printf(", sopt_type %d: trunc)", bp[i]); goto trunc; } printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]); break; } } return; trunc: printf("[trunc] "); } void ip6_opt_print(const u_char *bp, int len) { int i; int optlen; for (i = 0; i < len; i += optlen) { if (bp[i] == IP6OPT_PAD1) optlen = 1; else { if (i + 1 < len) optlen = bp[i + 1] + 2; else goto trunc; } if (i + optlen > len) goto trunc; switch (bp[i]) { case IP6OPT_PAD1: printf("(pad1)"); break; case IP6OPT_PADN: if (len - i < IP6OPT_MINLEN) { printf("(padn: trunc)"); goto trunc; } printf("(padn)"); break; case IP6OPT_ROUTER_ALERT: if (len - i < IP6OPT_RTALERT_LEN) { printf("(rtalert: trunc)"); goto trunc; } if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) { printf("(rtalert: invalid len %d)", bp[i + 1]); goto trunc; } printf("(rtalert: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2])); break; case IP6OPT_JUMBO: if (len - i < IP6OPT_JUMBO_LEN) { printf("(jumbo: trunc)"); goto trunc; } if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) { printf("(jumbo: invalid len %d)", bp[i + 1]); goto trunc; } printf("(jumbo: %u) ", (u_int32_t)ntohl(*(u_int32_t *)&bp[i + 2])); break; case IP6OPT_HOME_ADDRESS: if (len - i < IP6OPT_HOMEADDR_MINLEN) { printf("(homeaddr: trunc)"); goto trunc; } if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) { printf("(homeaddr: invalid len %d)", bp[i + 1]); goto trunc; } printf("(homeaddr: %s", ip6addr_string(&bp[i + 2])); if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) { ip6_sopt_print(&bp[i + IP6OPT_HOMEADDR_MINLEN], (optlen - IP6OPT_HOMEADDR_MINLEN)); } printf(")"); break; case IP6OPT_BINDING_UPDATE: if (len - i < IP6OPT_BU_MINLEN) { printf("(bu: trunc)"); goto trunc; } if (bp[i + 1] < IP6OPT_BU_MINLEN - 2) { printf("(bu: invalid len %d)", bp[i + 1]); goto trunc; } printf("(bu: "); if (bp[i + 2] & 0x80) printf("A"); if (bp[i + 2] & 0x40) printf("H"); if (bp[i + 2] & 0x20) printf("R"); if (bp[i + 2] & 0x10) printf("D"); if (bp[i + 2] & 0x0f) printf("res"); printf(", prefixlen: %u", bp[i + 3]); printf(", sequence: %u", (u_int16_t)ntohs(*(u_int16_t *)&bp[i + 4])); printf(", lifetime: %u", (u_int32_t)ntohs(*(u_int32_t *)&bp[i + 8])); if (bp[i + 1] > IP6OPT_BU_MINLEN - 2) { ip6_sopt_print(&bp[i + IP6OPT_BU_MINLEN], (optlen - IP6OPT_BU_MINLEN)); } printf(")"); break; case IP6OPT_BINDING_ACK: if (len - i < IP6OPT_BA_MINLEN) { printf("(ba: trunc)"); goto trunc; } if (bp[i + 1] < IP6OPT_BA_MINLEN - 2) { printf("(ba: invalid len %d)", bp[i + 1]); goto trunc; } printf("(ba: "); printf("status: %u", bp[i + 2]); printf(", sequence: %u", (u_int16_t)ntohs(*(u_int16_t *)&bp[i + 3])); printf(", lifetime: %u", (u_int32_t)ntohs(*(u_int32_t *)&bp[i + 7])); printf(", refresh: %u", (u_int32_t)ntohs(*(u_int32_t *)&bp[i + 11])); if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) { ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN], (optlen - IP6OPT_BA_MINLEN)); } printf(")"); break; case IP6OPT_BINDING_REQ: if (len - i < IP6OPT_BR_MINLEN) { printf("(br: trunc)"); goto trunc; } printf("(br"); if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) { ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN], (optlen - IP6OPT_BR_MINLEN)); } printf(")"); break; default: if (len - i < IP6OPT_MINLEN) { printf("(type %d: trunc)", bp[i]); goto trunc; } printf("(opt_type 0x%02x: len=%d) ", bp[i], bp[i + 1]); break; } } #if 0 end: #endif return; trunc: printf("[trunc] "); } int hbhopt_print(register const u_char *bp) { const struct ip6_hbh *dp = (struct ip6_hbh *)bp; register const u_char *ep; int hbhlen = 0; /* 'ep' points to the end of available data. */ ep = snapend; TCHECK(dp->ip6h_len); hbhlen = (int)((dp->ip6h_len + 1) << 3); TCHECK2(*dp, hbhlen); printf("HBH "); if (vflag) ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp)); return(hbhlen); trunc: fputs("[|HBH]", stdout); return(hbhlen); } int dstopt_print(register const u_char *bp) { const struct ip6_dest *dp = (struct ip6_dest *)bp; register const u_char *ep; int dstoptlen = 0; /* 'ep' points to the end of available data. */ ep = snapend; TCHECK(dp->ip6d_len); dstoptlen = (int)((dp->ip6d_len + 1) << 3); TCHECK2(*dp, dstoptlen); printf("DSTOPT "); if (vflag) { ip6_opt_print((const u_char *)dp + sizeof(*dp), dstoptlen - sizeof(*dp)); } return(dstoptlen); trunc: fputs("[|DSTOPT]", stdout); return(dstoptlen); } #endif /* INET6 */ tcpdump-3.7.2/print-ipcomp.c0100644000076500000240000000526207215373321015135 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.13 2000/12/12 09:58:41 itojun Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include struct ipcomp { u_int8_t comp_nxt; /* Next Header */ u_int8_t comp_flags; /* Length of data, in 32bit */ u_int16_t comp_cpi; /* Compression parameter index */ }; #if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) #include #endif #include "interface.h" #include "addrtoname.h" int ipcomp_print(register const u_char *bp, register const u_char *bp2, int *nhdr) { register const struct ipcomp *ipcomp; register const u_char *ep; u_int16_t cpi; #if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) int advance; #endif ipcomp = (struct ipcomp *)bp; cpi = (u_int16_t)ntohs(ipcomp->comp_cpi); /* 'ep' points to the end of available data. */ ep = snapend; if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) { fputs("[|IPCOMP]", stdout); goto fail; } printf("IPComp(cpi=0x%04x)", cpi); #if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) if (1) goto fail; /* * We may want to decompress the packet here. Packet buffer * management is a headache (if we decompress, packet will become * larger). */ if (nhdr) *nhdr = ipcomp->comp_nxt; advance = sizeof(struct ipcomp); printf(": "); return advance; #endif fail: if (nhdr) *nhdr = -1; return 65536; } tcpdump-3.7.2/print-ipx.c0100644000076500000240000001250607360414700014443 0ustar fennerstaff/* * Copyright (c) 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Format and print Novell IPX packets. * Contributed by Brad Parker (brad@fcr.com). */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.32 2001/10/08 21:25:20 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ipx.h" #include "extract.h" static const char *ipxaddr_string(u_int32_t, const u_char *); void ipx_decode(const struct ipxHdr *, const u_char *, u_int); void ipx_sap_print(const u_short *, u_int); void ipx_rip_print(const u_short *, u_int); /* * Print IPX datagram packets. */ void ipx_print(const u_char *p, u_int length) { const struct ipxHdr *ipx = (const struct ipxHdr *)p; TCHECK(ipx->srcSkt); (void)printf("%s.%x > ", ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode), EXTRACT_16BITS(&ipx->srcSkt)); (void)printf("%s.%x:", ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode), EXTRACT_16BITS(&ipx->dstSkt)); /* take length from ipx header */ TCHECK(ipx->length); length = EXTRACT_16BITS(&ipx->length); ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize); return; trunc: printf("[|ipx %d]", length); } static const char * ipxaddr_string(u_int32_t net, const u_char *node) { static char line[256]; snprintf(line, sizeof(line), "%x.%02x:%02x:%02x:%02x:%02x:%02x", net, node[0], node[1], node[2], node[3], node[4], node[5]); return line; } void ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length) { register u_short dstSkt; dstSkt = EXTRACT_16BITS(&ipx->dstSkt); switch (dstSkt) { case IPX_SKT_NCP: (void)printf(" ipx-ncp %d", length); break; case IPX_SKT_SAP: ipx_sap_print((u_short *)datap, length); break; case IPX_SKT_RIP: ipx_rip_print((u_short *)datap, length); break; case IPX_SKT_NETBIOS: (void)printf(" ipx-netbios %d", length); #ifdef TCPDUMP_DO_SMB ipx_netbios_print(datap, length); #endif break; case IPX_SKT_DIAGNOSTICS: (void)printf(" ipx-diags %d", length); break; case IPX_SKT_NWLINK_DGM: (void)printf(" ipx-nwlink-dgm %d", length); #ifdef TCPDUMP_DO_SMB ipx_netbios_print(datap, length); #endif break; case IPX_SKT_EIGRP: (void)printf(" ipx-eigrp %d", length); break; default: (void)printf(" ipx-#%x %d", dstSkt, length); break; } } void ipx_sap_print(const u_short *ipx, u_int length) { int command, i; TCHECK(ipx[0]); command = EXTRACT_16BITS(ipx); ipx++; length -= 2; switch (command) { case 1: case 3: if (command == 1) (void)printf("ipx-sap-req"); else (void)printf("ipx-sap-nearest-req"); TCHECK(ipx[0]); (void)printf(" %x", EXTRACT_16BITS(&ipx[0])); break; case 2: case 4: if (command == 2) (void)printf("ipx-sap-resp"); else (void)printf("ipx-sap-nearest-resp"); for (i = 0; i < 8 && length > 0; i++) { TCHECK2(ipx[25], 10); (void)printf(" %x '", EXTRACT_16BITS(&ipx[0])); fn_print((u_char *)&ipx[1], (u_char *)&ipx[1] + 48); printf("' addr %s", ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27])); ipx += 32; length -= 64; } break; default: (void)printf("ipx-sap-?%x", command); break; } return; trunc: printf("[|ipx %d]", length); } void ipx_rip_print(const u_short *ipx, u_int length) { int command, i; TCHECK(ipx[0]); command = EXTRACT_16BITS(ipx); ipx++; length -= 2; switch (command) { case 1: (void)printf("ipx-rip-req"); if (length > 0) { TCHECK(ipx[3]); (void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]), EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])); } break; case 2: (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]), EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])); ipx += 4; length -= 8; } break; default: (void)printf("ipx-rip-?%x", command); break; } return; trunc: printf("[|ipx %d]", length); } tcpdump-3.7.2/print-isakmp.c0100644000076500000240000007164207627054627015153 0ustar fennerstaff/* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.29.2.2 2003/02/26 05:58:39 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include "isakmp.h" #include "ipsec_doi.h" #include "oakley.h" #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ #include "ip.h" #ifdef INET6 #include "ip6.h" #endif #ifndef HAVE_SOCKADDR_STORAGE #define sockaddr_storage sockaddr #endif static u_char *isakmp_sa_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_p_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_t_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_ke_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_id_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_cert_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_cr_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_sig_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_hash_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_nonce_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_n_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_d_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_vid_print(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_sub0_print(u_char, struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static u_char *isakmp_sub_print(u_char, struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t); static char *numstr(int); static void safememcpy(void *, void *, size_t); #define MAXINITIATORS 20 int ninitiator = 0; struct { cookie_t initiator; struct sockaddr_storage iaddr; struct sockaddr_storage raddr; } cookiecache[MAXINITIATORS]; /* protocol id */ static char *protoidstr[] = { NULL, "isakmp", "ipsec-ah", "ipsec-esp", "ipcomp", }; /* isakmp->np */ static char *npstr[] = { "none", "sa", "p", "t", "ke", "id", "cert", "cr", "hash", "sig", "nonce", "n", "d", "vid" }; /* isakmp->np */ static u_char *(*npfunc[])(struct isakmp_gen *, u_char *, u_int32_t, u_int32_t, u_int32_t) = { NULL, isakmp_sa_print, isakmp_p_print, isakmp_t_print, isakmp_ke_print, isakmp_id_print, isakmp_cert_print, isakmp_cr_print, isakmp_hash_print, isakmp_sig_print, isakmp_nonce_print, isakmp_n_print, isakmp_d_print, isakmp_vid_print, }; /* isakmp->etype */ static char *etypestr[] = { "none", "base", "ident", "auth", "agg", "inf", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "oakley-quick", "oakley-newgroup", }; #define STR_OR_ID(x, tab) \ (((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x)) #define PROTOIDSTR(x) STR_OR_ID(x, protoidstr) #define NPSTR(x) STR_OR_ID(x, npstr) #define ETYPESTR(x) STR_OR_ID(x, etypestr) #define NPFUNC(x) \ (((x) < sizeof(npfunc)/sizeof(npfunc[0]) && npfunc[(x)]) \ ? npfunc[(x)] : NULL) static int iszero(u_char *p, size_t l) { while (l--) { if (*p++) return 0; } return 1; } /* find cookie from initiator cache */ static int cookie_find(cookie_t *in) { int i; for (i = 0; i < MAXINITIATORS; i++) { if (memcmp(in, &cookiecache[i].initiator, sizeof(*in)) == 0) return i; } return -1; } /* record initiator */ static void cookie_record(cookie_t *in, const u_char *bp2) { int i; struct ip *ip; struct sockaddr_in *sin; #ifdef INET6 struct ip6_hdr *ip6; struct sockaddr_in6 *sin6; #endif i = cookie_find(in); if (0 <= i) { ninitiator = (i + 1) % MAXINITIATORS; return; } ip = (struct ip *)bp2; switch (IP_V(ip)) { case 4: memset(&cookiecache[ninitiator].iaddr, 0, sizeof(cookiecache[ninitiator].iaddr)); memset(&cookiecache[ninitiator].raddr, 0, sizeof(cookiecache[ninitiator].raddr)); sin = (struct sockaddr_in *)&cookiecache[ninitiator].iaddr; #ifdef HAVE_SOCKADDR_SA_LEN sin->sin_len = sizeof(struct sockaddr_in); #endif sin->sin_family = AF_INET; memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src)); sin = (struct sockaddr_in *)&cookiecache[ninitiator].raddr; #ifdef HAVE_SOCKADDR_SA_LEN sin->sin_len = sizeof(struct sockaddr_in); #endif sin->sin_family = AF_INET; memcpy(&sin->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst)); break; #ifdef INET6 case 6: memset(&cookiecache[ninitiator].iaddr, 0, sizeof(cookiecache[ninitiator].iaddr)); memset(&cookiecache[ninitiator].raddr, 0, sizeof(cookiecache[ninitiator].raddr)); ip6 = (struct ip6_hdr *)bp2; sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].iaddr; #ifdef HAVE_SOCKADDR_SA_LEN sin6->sin6_len = sizeof(struct sockaddr_in6); #endif sin6->sin6_family = AF_INET6; memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src)); sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].raddr; #ifdef HAVE_SOCKADDR_SA_LEN sin6->sin6_len = sizeof(struct sockaddr_in6); #endif sin6->sin6_family = AF_INET6; memcpy(&sin6->sin6_addr, &ip6->ip6_dst, sizeof(ip6->ip6_dst)); break; #endif default: return; } memcpy(&cookiecache[ninitiator].initiator, in, sizeof(*in)); ninitiator = (ninitiator + 1) % MAXINITIATORS; } #define cookie_isinitiator(x, y) cookie_sidecheck((x), (y), 1) #define cookie_isresponder(x, y) cookie_sidecheck((x), (y), 0) static int cookie_sidecheck(int i, const u_char *bp2, int initiator) { struct sockaddr_storage ss; struct sockaddr *sa; struct ip *ip; struct sockaddr_in *sin; #ifdef INET6 struct ip6_hdr *ip6; struct sockaddr_in6 *sin6; #endif int salen; memset(&ss, 0, sizeof(ss)); ip = (struct ip *)bp2; switch (IP_V(ip)) { case 4: sin = (struct sockaddr_in *)&ss; #ifdef HAVE_SOCKADDR_SA_LEN sin->sin_len = sizeof(struct sockaddr_in); #endif sin->sin_family = AF_INET; memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src)); break; #ifdef INET6 case 6: ip6 = (struct ip6_hdr *)bp2; sin6 = (struct sockaddr_in6 *)&ss; #ifdef HAVE_SOCKADDR_SA_LEN sin6->sin6_len = sizeof(struct sockaddr_in6); #endif sin6->sin6_family = AF_INET6; memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src)); break; #endif default: return 0; } sa = (struct sockaddr *)&ss; if (initiator) { if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].iaddr)->sa_family) return 0; #ifdef HAVE_SOCKADDR_SA_LEN salen = sa->sa_len; #else #ifdef INET6 if (sa->sa_family == AF_INET6) salen = sizeof(struct sockaddr_in6); else salen = sizeof(struct sockaddr); #else salen = sizeof(struct sockaddr); #endif #endif if (memcmp(&ss, &cookiecache[i].iaddr, salen) == 0) return 1; } else { if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].raddr)->sa_family) return 0; #ifdef HAVE_SOCKADDR_SA_LEN salen = sa->sa_len; #else #ifdef INET6 if (sa->sa_family == AF_INET6) salen = sizeof(struct sockaddr_in6); else salen = sizeof(struct sockaddr); #else salen = sizeof(struct sockaddr); #endif #endif if (memcmp(&ss, &cookiecache[i].raddr, salen) == 0) return 1; } return 0; } static void rawprint(caddr_t loc, size_t len) { static u_char *p; int i; p = (u_char *)loc; for (i = 0; i < len; i++) printf("%02x", p[i] & 0xff); } struct attrmap { char *type; int nvalue; char *value[30]; /*XXX*/ }; static u_char * isakmp_attrmap_print(u_char *p, u_char *ep, struct attrmap *map, size_t nmap) { u_int16_t *q; int totlen; u_int32_t t, v; q = (u_int16_t *)p; if (p[0] & 0x80) totlen = 4; else totlen = 4 + ntohs(q[1]); if (ep < p + totlen) { printf("[|attr]"); return ep + 1; } printf("("); t = ntohs(q[0]) & 0x7fff; if (map && t < nmap && map[t].type) printf("type=%s ", map[t].type); else printf("type=#%d ", t); if (p[0] & 0x80) { printf("value="); v = ntohs(q[1]); if (map && t < nmap && v < map[t].nvalue && map[t].value[v]) printf("%s", map[t].value[v]); else rawprint((caddr_t)&q[1], 2); } else { printf("len=%d value=", ntohs(q[1])); rawprint((caddr_t)&p[4], ntohs(q[1])); } printf(")"); return p + totlen; } static u_char * isakmp_attr_print(u_char *p, u_char *ep) { u_int16_t *q; int totlen; u_int32_t t; q = (u_int16_t *)p; if (p[0] & 0x80) totlen = 4; else totlen = 4 + ntohs(q[1]); if (ep < p + totlen) { printf("[|attr]"); return ep + 1; } printf("("); t = ntohs(q[0]) & 0x7fff; printf("type=#%d ", t); if (p[0] & 0x80) { printf("value="); t = q[1]; rawprint((caddr_t)&q[1], 2); } else { printf("len=%d value=", ntohs(q[1])); rawprint((caddr_t)&p[2], ntohs(q[1])); } printf(")"); return p + totlen; } static u_char * isakmp_sa_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi0, u_int32_t proto0) { struct isakmp_pl_sa *p, sa; u_int32_t *q; u_int32_t doi, sit, ident; u_char *cp, *np; int t; printf("%s:", NPSTR(ISAKMP_NPTYPE_SA)); p = (struct isakmp_pl_sa *)ext; safememcpy(&sa, ext, sizeof(sa)); doi = ntohl(sa.doi); sit = ntohl(sa.sit); if (doi != 1) { printf(" doi=%d", doi); printf(" situation=%u", (u_int32_t)ntohl(sa.sit)); return (u_char *)(p + 1); } printf(" doi=ipsec"); q = (u_int32_t *)&sa.sit; printf(" situation="); t = 0; if (sit & 0x01) { printf("identity"); t++; } if (sit & 0x02) { printf("%ssecrecy", t ? "+" : ""); t++; } if (sit & 0x04) printf("%sintegrity", t ? "+" : ""); np = (u_char *)ext + sizeof(sa); if (sit != 0x01) { safememcpy(&ident, ext + 1, sizeof(ident)); printf(" ident=%u", (u_int32_t)ntohl(ident)); np += sizeof(ident); } ext = (struct isakmp_gen *)np; cp = isakmp_sub_print(ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0); return cp; } static u_char * isakmp_p_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi0, u_int32_t proto0) { struct isakmp_pl_p *p, prop; u_char *cp; printf("%s:", NPSTR(ISAKMP_NPTYPE_P)); p = (struct isakmp_pl_p *)ext; safememcpy(&prop, ext, sizeof(prop)); printf(" #%d protoid=%s transform=%d", prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t); if (prop.spi_size) { printf(" spi="); rawprint((caddr_t)(p + 1), prop.spi_size); } ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size); cp = isakmp_sub_print(ISAKMP_NPTYPE_T, ext, ep, phase, doi0, prop.prot_id); return cp; } static char *isakmp_p_map[] = { NULL, "ike", }; static char *ah_p_map[] = { NULL, "(reserved)", "md5", "sha", "1des", "sha2-256", "sha2-384", "sha2-512", }; static char *esp_p_map[] = { NULL, "1des-iv64", "1des", "3des", "rc5", "idea", "cast", "blowfish", "3idea", "1des-iv32", "rc4", "null", "aes" }; static char *ipcomp_p_map[] = { NULL, "oui", "deflate", "lzs", }; struct attrmap ipsec_t_map[] = { { NULL, 0, }, { "lifetype", 3, { NULL, "sec", "kb", }, }, { "life", 0, }, { "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155", "EC2N 2^185", }, }, { "enc mode", 3, { NULL, "tunnel", "transport", }, }, { "auth", 5, { NULL, "hmac-md5", "hmac-sha1", "1des-mac", "keyed", }, }, { "keylen", 0, }, { "rounds", 0, }, { "dictsize", 0, }, { "privalg", 0, }, }; struct attrmap oakley_t_map[] = { { NULL, 0 }, { "enc", 8, { NULL, "1des", "idea", "blowfish", "rc5", "3des", "cast", "aes", }, }, { "hash", 7, { NULL, "md5", "sha1", "tiger", "sha2-256", "sha2-384", "sha2-512", }, }, { "auth", 6, { NULL, "preshared", "dss", "rsa sig", "rsa enc", "rsa enc revised", }, }, { "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155", "EC2N 2^185", }, }, { "group type", 4, { NULL, "MODP", "ECP", "EC2N", }, }, { "group prime", 0, }, { "group gen1", 0, }, { "group gen2", 0, }, { "group curve A", 0, }, { "group curve B", 0, }, { "lifetype", 3, { NULL, "sec", "kb", }, }, { "lifeduration", 0, }, { "prf", 0, }, { "keylen", 0, }, { "field", 0, }, { "order", 0, }, }; static u_char * isakmp_t_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi, u_int32_t proto) { struct isakmp_pl_t *p, t; u_char *cp; char *idstr; struct attrmap *map; size_t nmap; u_char *ep2; printf("%s:", NPSTR(ISAKMP_NPTYPE_T)); p = (struct isakmp_pl_t *)ext; safememcpy(&t, ext, sizeof(t)); switch (proto) { case 1: idstr = STR_OR_ID(t.t_id, isakmp_p_map); map = oakley_t_map; nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]); break; case 2: idstr = STR_OR_ID(t.t_id, ah_p_map); map = ipsec_t_map; nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]); break; case 3: idstr = STR_OR_ID(t.t_id, esp_p_map); map = ipsec_t_map; nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]); break; case 4: idstr = STR_OR_ID(t.t_id, ipcomp_p_map); map = ipsec_t_map; nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]); break; default: idstr = NULL; map = NULL; nmap = 0; break; } if (idstr) printf(" #%d id=%s ", t.t_no, idstr); else printf(" #%d id=%d ", t.t_no, t.t_id); cp = (u_char *)(p + 1); ep2 = (u_char *)p + ntohs(t.h.len); while (cp < ep && cp < ep2) { if (map && nmap) { cp = isakmp_attrmap_print(cp, (ep < ep2) ? ep : ep2, map, nmap); } else cp = isakmp_attr_print(cp, (ep < ep2) ? ep : ep2); } if (ep < ep2) printf("..."); return cp; } static u_char * isakmp_ke_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi, u_int32_t proto) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_KE)); safememcpy(&e, ext, sizeof(e)); printf(" key len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); } return (u_char *)ext + ntohs(e.len); } static u_char * isakmp_id_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi, u_int32_t proto) { #define USE_IPSECDOI_IN_PHASE1 1 struct isakmp_pl_id *p, id; static char *idtypestr[] = { "IPv4", "IPv4net", "IPv6", "IPv6net", }; static char *ipsecidtypestr[] = { NULL, "IPv4", "FQDN", "user FQDN", "IPv4net", "IPv6", "IPv6net", "IPv4range", "IPv6range", "ASN1 DN", "ASN1 GN", "keyid", }; int len; u_char *data; printf("%s:", NPSTR(ISAKMP_NPTYPE_ID)); p = (struct isakmp_pl_id *)ext; safememcpy(&id, ext, sizeof(id)); if (sizeof(*p) < id.h.len) data = (u_char *)(p + 1); else data = NULL; len = ntohs(id.h.len) - sizeof(*p); #if 0 /*debug*/ printf(" [phase=%d doi=%d proto=%d]", phase, doi, proto); #endif switch (phase) { #ifndef USE_IPSECDOI_IN_PHASE1 case 1: #endif default: printf(" idtype=%s", STR_OR_ID(id.d.id_type, idtypestr)); printf(" doi_data=%u", (u_int32_t)(ntohl(id.d.doi_data) & 0xffffff)); break; #ifdef USE_IPSECDOI_IN_PHASE1 case 1: #endif case 2: { struct ipsecdoi_id *p, id; struct protoent *pe; p = (struct ipsecdoi_id *)ext; safememcpy(&id, ext, sizeof(id)); printf(" idtype=%s", STR_OR_ID(id.type, ipsecidtypestr)); if (id.proto_id) { setprotoent(1); pe = getprotobynumber(id.proto_id); if (pe) printf(" protoid=%s", pe->p_name); endprotoent(); } else { /* it DOES NOT mean IPPROTO_IP! */ printf(" protoid=%s", "0"); } printf(" port=%d", ntohs(id.port)); if (!len) break; switch (id.type) { case IPSECDOI_ID_IPV4_ADDR: printf(" len=%d %s", len, ipaddr_string(data)); len = 0; break; case IPSECDOI_ID_FQDN: case IPSECDOI_ID_USER_FQDN: { int i; printf(" len=%d ", len); for (i = 0; i < len; i++) safeputchar(data[i]); len = 0; break; } case IPSECDOI_ID_IPV4_ADDR_SUBNET: { u_char *mask; mask = data + sizeof(struct in_addr); printf(" len=%d %s/%u.%u.%u.%u", len, ipaddr_string(data), mask[0], mask[1], mask[2], mask[3]); len = 0; break; } #ifdef INET6 case IPSECDOI_ID_IPV6_ADDR: printf(" len=%d %s", len, ip6addr_string(data)); len = 0; break; case IPSECDOI_ID_IPV6_ADDR_SUBNET: { u_int32_t *mask; mask = (u_int32_t *)(data + sizeof(struct in6_addr)); /*XXX*/ printf(" len=%d %s/0x%08x%08x%08x%08x", len, ip6addr_string(data), mask[0], mask[1], mask[2], mask[3]); len = 0; break; } #endif /*INET6*/ case IPSECDOI_ID_IPV4_ADDR_RANGE: printf(" len=%d %s-%s", len, ipaddr_string(data), ipaddr_string(data + sizeof(struct in_addr))); len = 0; break; #ifdef INET6 case IPSECDOI_ID_IPV6_ADDR_RANGE: printf(" len=%d %s-%s", len, ip6addr_string(data), ip6addr_string(data + sizeof(struct in6_addr))); len = 0; break; #endif /*INET6*/ case IPSECDOI_ID_DER_ASN1_DN: case IPSECDOI_ID_DER_ASN1_GN: case IPSECDOI_ID_KEY_ID: break; } break; } } if (data && len) { printf(" len=%d", len); if (2 < vflag) { printf(" "); rawprint((caddr_t)data, len); } } return (u_char *)ext + ntohs(id.h.len); } static u_char * isakmp_cert_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi0, u_int32_t proto0) { struct isakmp_pl_cert *p, cert; static char *certstr[] = { "none", "pkcs7", "pgp", "dns", "x509sign", "x509ke", "kerberos", "crl", "arl", "spki", "x509attr", }; printf("%s:", NPSTR(ISAKMP_NPTYPE_CERT)); p = (struct isakmp_pl_cert *)ext; safememcpy(&cert, ext, sizeof(cert)); printf(" len=%d", ntohs(cert.h.len) - 4); printf(" type=%s", STR_OR_ID((cert.encode), certstr)); if (2 < vflag && 4 < ntohs(cert.h.len)) { printf(" "); rawprint((caddr_t)(ext + 1), ntohs(cert.h.len) - 4); } return (u_char *)ext + ntohs(cert.h.len); } static u_char * isakmp_cr_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi0, u_int32_t proto0) { struct isakmp_pl_cert *p, cert; static char *certstr[] = { "none", "pkcs7", "pgp", "dns", "x509sign", "x509ke", "kerberos", "crl", "arl", "spki", "x509attr", }; printf("%s:", NPSTR(ISAKMP_NPTYPE_CR)); p = (struct isakmp_pl_cert *)ext; safememcpy(&cert, ext, sizeof(cert)); printf(" len=%d", ntohs(cert.h.len) - 4); printf(" type=%s", STR_OR_ID((cert.encode), certstr)); if (2 < vflag && 4 < ntohs(cert.h.len)) { printf(" "); rawprint((caddr_t)(ext + 1), ntohs(cert.h.len) - 4); } return (u_char *)ext + ntohs(cert.h.len); } static u_char * isakmp_hash_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi, u_int32_t proto) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_HASH)); safememcpy(&e, ext, sizeof(e)); printf(" len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); } return (u_char *)ext + ntohs(e.len); } static u_char * isakmp_sig_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi, u_int32_t proto) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_SIG)); safememcpy(&e, ext, sizeof(e)); printf(" len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); } return (u_char *)ext + ntohs(e.len); } static u_char * isakmp_nonce_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi, u_int32_t proto) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_NONCE)); safememcpy(&e, ext, sizeof(e)); printf(" n len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); } return (u_char *)ext + ntohs(e.len); } static u_char * isakmp_n_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi0, u_int32_t proto0) { struct isakmp_pl_n *p, n; u_char *cp; u_char *ep2; u_int32_t doi; u_int32_t proto; static char *notifystr[] = { NULL, "INVALID-PAYLOAD-TYPE", "DOI-NOT-SUPPORTED", "SITUATION-NOT-SUPPORTED", "INVALID-COOKIE", "INVALID-MAJOR-VERSION", "INVALID-MINOR-VERSION", "INVALID-EXCHANGE-TYPE", "INVALID-FLAGS", "INVALID-MESSAGE-ID", "INVALID-PROTOCOL-ID", "INVALID-SPI", "INVALID-TRANSFORM-ID", "ATTRIBUTES-NOT-SUPPORTED", "NO-PROPOSAL-CHOSEN", "BAD-PROPOSAL-SYNTAX", "PAYLOAD-MALFORMED", "INVALID-KEY-INFORMATION", "INVALID-ID-INFORMATION", "INVALID-CERT-ENCODING", "INVALID-CERTIFICATE", "CERT-TYPE-UNSUPPORTED", "INVALID-CERT-AUTHORITY", "INVALID-HASH-INFORMATION", "AUTHENTICATION-FAILED", "INVALID-SIGNATURE", "ADDRESS-NOTIFICATION", "NOTIFY-SA-LIFETIME", "CERTIFICATE-UNAVAILABLE", "UNSUPPORTED-EXCHANGE-TYPE", "UNEQUAL-PAYLOAD-LENGTHS", }; static char *ipsecnotifystr[] = { "RESPONDER-LIFETIME", "REPLAY-STATUS", "INITIAL-CONTACT", }; /* NOTE: these macro must be called with x in proper range */ #define NOTIFYSTR(x) \ (((x) == 16384) ? "CONNECTED" : STR_OR_ID((x), notifystr)) #define IPSECNOTIFYSTR(x) \ (((x) == 8192) ? "RESERVED" : STR_OR_ID(((x) - 24576), ipsecnotifystr)) printf("%s:", NPSTR(ISAKMP_NPTYPE_N)); p = (struct isakmp_pl_n *)ext; safememcpy(&n, ext, sizeof(n)); doi = ntohl(n.doi); proto = n.prot_id; if (doi != 1) { printf(" doi=%d", doi); printf(" proto=%d", proto); printf(" type=%s", NOTIFYSTR(ntohs(n.type))); if (n.spi_size) { printf(" spi="); rawprint((caddr_t)(p + 1), n.spi_size); } return (u_char *)(p + 1) + n.spi_size; } printf(" doi=ipsec"); printf(" proto=%s", PROTOIDSTR(proto)); if (ntohs(n.type) < 8192) printf(" type=%s", NOTIFYSTR(ntohs(n.type))); else if (ntohs(n.type) < 16384) printf(" type=%s", IPSECNOTIFYSTR(ntohs(n.type))); else if (ntohs(n.type) < 24576) printf(" type=%s", NOTIFYSTR(ntohs(n.type))); else if (ntohs(n.type) < 40960) printf(" type=%s", IPSECNOTIFYSTR(ntohs(n.type))); else printf(" type=%s", NOTIFYSTR(ntohs(n.type))); if (n.spi_size) { printf(" spi="); rawprint((caddr_t)(p + 1), n.spi_size); } cp = (u_char *)(p + 1) + n.spi_size; ep2 = (u_char *)p + ntohs(n.h.len); if (cp < ep) { printf(" orig=("); switch (ntohs(n.type)) { case IPSECDOI_NTYPE_RESPONDER_LIFETIME: { struct attrmap *map = oakley_t_map; size_t nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]); while (cp < ep && cp < ep2) { cp = isakmp_attrmap_print(cp, (ep < ep2) ? ep : ep2, map, nmap); } break; } case IPSECDOI_NTYPE_REPLAY_STATUS: printf("replay detection %sabled", (*(u_int32_t *)cp) ? "en" : "dis"); break; case ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN: isakmp_sub_print(ISAKMP_NPTYPE_SA, (struct isakmp_gen *)cp, ep, phase, doi, proto); break; default: /* NULL is dummy */ isakmp_print(cp, ntohs(n.h.len) - sizeof(*p) - n.spi_size, NULL); } printf(")"); } return (u_char *)ext + ntohs(n.h.len); } static u_char * isakmp_d_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi0, u_int32_t proto0) { struct isakmp_pl_d *p, d; u_int8_t *q; u_int32_t doi; u_int32_t proto; int i; printf("%s:", NPSTR(ISAKMP_NPTYPE_D)); p = (struct isakmp_pl_d *)ext; safememcpy(&d, ext, sizeof(d)); doi = ntohl(d.doi); proto = d.prot_id; if (doi != 1) { printf(" doi=%u", doi); printf(" proto=%u", proto); } else { printf(" doi=ipsec"); printf(" proto=%s", PROTOIDSTR(proto)); } printf(" spilen=%u", d.spi_size); printf(" nspi=%u", ntohs(d.num_spi)); printf(" spi="); q = (u_int8_t *)(p + 1); for (i = 0; i < ntohs(d.num_spi); i++) { if (i != 0) printf(","); rawprint((caddr_t)q, d.spi_size); q += d.spi_size; } return q; } static u_char * isakmp_vid_print(struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi, u_int32_t proto) { struct isakmp_gen e; printf("%s:", NPSTR(ISAKMP_NPTYPE_VID)); safememcpy(&e, ext, sizeof(e)); printf(" len=%d", ntohs(e.len) - 4); if (2 < vflag && 4 < ntohs(e.len)) { printf(" "); rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4); } return (u_char *)ext + ntohs(e.len); } static u_char * isakmp_sub0_print(u_char np, struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi, u_int32_t proto) { u_char *cp; struct isakmp_gen e; u_int item_len; cp = (u_char *)ext; safememcpy(&e, ext, sizeof(e)); if (NPFUNC(np)) cp = (*NPFUNC(np))(ext, ep, phase, doi, proto); else { printf("%s", NPSTR(np)); item_len = ntohs(e.len); if (item_len == 0) { /* * We don't want to loop forever processing this * bogus (zero-length) item; return NULL so that * we stop dissecting. */ cp = NULL; } else cp += item_len; } return cp; } static u_char * isakmp_sub_print(u_char np, struct isakmp_gen *ext, u_char *ep, u_int32_t phase, u_int32_t doi, u_int32_t proto) { u_char *cp; static int depth = 0; int i; struct isakmp_gen e; cp = (u_char *)ext; while (np) { safememcpy(&e, ext, sizeof(e)); if (ep < (u_char *)ext + ntohs(e.len)) { printf(" [|%s]", NPSTR(np)); cp = ep + 1; break; } depth++; printf("\n"); for (i = 0; i < depth; i++) printf(" "); printf("("); cp = isakmp_sub0_print(np, ext, ep, phase, doi, proto); printf(")"); depth--; if (cp == NULL) { /* Zero-length subitem */ return NULL; } np = e.np; ext = (struct isakmp_gen *)cp; } return cp; } static char * numstr(int x) { static char buf[20]; snprintf(buf, sizeof(buf), "#%d", x); return buf; } /* * some compiler tries to optimize memcpy(), using the alignment constraint * on the argument pointer type. by using this function, we try to avoid the * optimization. */ static void safememcpy(void *p, void *q, size_t l) { memcpy(p, q, l); } void isakmp_print(const u_char *bp, u_int length, const u_char *bp2) { struct isakmp *p, base; u_char *ep; u_char np; int i; int phase; int major, minor; p = (struct isakmp *)bp; ep = (u_char *)snapend; if ((struct isakmp *)ep < p + 1) { printf("[|isakmp]"); return; } safememcpy(&base, p, sizeof(base)); printf("isakmp"); if (vflag) { major = (base.vers & ISAKMP_VERS_MAJOR) >> ISAKMP_VERS_MAJOR_SHIFT; minor = (base.vers & ISAKMP_VERS_MINOR) >> ISAKMP_VERS_MINOR_SHIFT; printf(" %d.%d", major, minor); } if (vflag) { printf(" msgid "); rawprint((caddr_t)&base.msgid, sizeof(base.msgid)); } if (1 < vflag) { printf(" cookie "); rawprint((caddr_t)&base.i_ck, sizeof(base.i_ck)); printf("->"); rawprint((caddr_t)&base.r_ck, sizeof(base.r_ck)); } printf(":"); phase = (*(u_int32_t *)base.msgid == 0) ? 1 : 2; if (phase == 1) printf(" phase %d", phase); else printf(" phase %d/others", phase); i = cookie_find(&base.i_ck); if (i < 0) { if (iszero((u_char *)&base.r_ck, sizeof(base.r_ck))) { /* the first packet */ printf(" I"); if (bp2) cookie_record(&base.i_ck, bp2); } else printf(" ?"); } else { if (bp2 && cookie_isinitiator(i, bp2)) printf(" I"); else if (bp2 && cookie_isresponder(i, bp2)) printf(" R"); else printf(" ?"); } printf(" %s", ETYPESTR(base.etype)); if (base.flags) { printf("[%s%s]", base.flags & ISAKMP_FLAG_E ? "E" : "", base.flags & ISAKMP_FLAG_C ? "C" : ""); } printf(":"); { struct isakmp_gen *ext; int nparen; #define CHECKLEN(p, np) \ if (ep < (u_char *)(p)) { \ printf(" [|%s]", NPSTR(np)); \ goto done; \ } /* regardless of phase... */ if (base.flags & ISAKMP_FLAG_E) { /* * encrypted, nothing we can do right now. * we hope to decrypt the packet in the future... */ printf(" [encrypted %s]", NPSTR(base.np)); goto done; } nparen = 0; CHECKLEN(p + 1, base.np) np = base.np; ext = (struct isakmp_gen *)(p + 1); isakmp_sub_print(np, ext, ep, phase, 0, 0); } done: if (vflag) { if (ntohl(base.len) != length) { printf(" (len mismatch: isakmp %u/ip %d)", (u_int32_t)ntohl(base.len), length); } } } tcpdump-3.7.2/print-isoclns.c0100644000076500000240000012416707627054630015334 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Original code by Matt Thomas, Digital Equipment Corporation * * Extensively modified by Hannes Gredler (hannes@juniper.net) for more * complete IS-IS support. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.36.2.2 2002/06/29 04:28:44 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "ether.h" #include "extract.h" #define NLPID_CLNS 129 /* 0x81 */ #define NLPID_ESIS 130 /* 0x82 */ #define NLPID_ISIS 131 /* 0x83 */ #define NLPID_IP6 0x8e #define NLPID_IP 0xcc #define NLPID_NULLNS 0 /* * IS-IS is defined in ISO 10589. Look there for protocol definitions. */ #define SYSTEM_ID_LEN ETHER_ADDR_LEN #define ISIS_VERSION 1 #define PDU_TYPE_MASK 0x1F #define PRIORITY_MASK 0x7F #define L1_LAN_IIH 15 #define L2_LAN_IIH 16 #define PTP_IIH 17 #define L1_LSP 18 #define L2_LSP 20 #define L1_CSNP 24 #define L2_CSNP 25 #define L1_PSNP 26 #define L2_PSNP 27 /* * A TLV is a tuple of a type, length and a value and is normally used for * encoding information in all sorts of places. This is an enumeration of * the well known types. */ #define TLV_AREA_ADDR 1 #define TLV_IS_REACH 2 #define TLV_ES_REACH 3 #define TLV_SUMMARY 5 #define TLV_ISNEIGH 6 #define TLV_PADDING 8 #define TLV_LSP 9 #define TLV_AUTH 10 #define TLV_CHECKSUM 12 #define TLV_EXT_IS_REACH 22 #define TLV_IP_REACH 128 #define TLV_PROTOCOLS 129 #define TLV_IP_REACH_EXT 130 #define TLV_IDRP_INFO 131 #define TLV_IPADDR 132 #define TLV_IPAUTH 133 #define TLV_TE_ROUTER_ID 134 #define TLV_EXT_IP_REACH 135 #define TLV_HOSTNAME 137 #define TLV_RESTART_SIGNALING 211 #define TLV_MT_IS_REACH 222 #define TLV_MT_SUPPORTED 229 #define TLV_IP6ADDR 232 #define TLV_MT_REACH 235 #define TLV_IP6_REACH 236 #define TLV_PTP_ADJ 240 #define SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 #define SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 #define SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 #define SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 #define SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 #define SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 #define SUBTLV_EXT_IS_REACH_TE_METRIC 18 #define SUBTLV_AUTH_SIMPLE 1 #define SUBTLV_AUTH_MD5 54 #define ISIS_MASK_LEVEL_BITS(x) ((x)&0x1) #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4) #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3) #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80) #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78) #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40) #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20) #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10) #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8) #define ISIS_MASK_TLV_EXT_IP_UPDOWN(x) ((x)&0x80) #define ISIS_MASK_TLV_EXT_IP_SUBTLV(x) ((x)&0x40) #define ISIS_MASK_TLV_IP6_UPDOWN(x) ((x)&0x80) #define ISIS_MASK_TLV_IP6_IE(x) ((x)&0x40) #define ISIS_MASK_TLV_IP6_SUBTLV(x) ((x)&0x20) #define ISIS_MASK_RESTART_RR(x) ((x)&0x1) #define ISIS_MASK_RESTART_RA(x) ((x)&0x2) #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80) #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40) #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80) #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f) #define ISIS_LSP_TYPE_UNUSED0 0 #define ISIS_LSP_TYPE_LEVEL_1 1 #define ISIS_LSP_TYPE_UNUSED2 2 #define ISIS_LSP_TYPE_LEVEL_2 3 static struct tok isis_lsp_istype_values[] = { { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"}, { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"}, { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"}, { ISIS_LSP_TYPE_LEVEL_2, "L1L2 IS"}, { 0, NULL } }; static struct tok isis_nlpid_values[] = { { NLPID_CLNS, "CLNS"}, { NLPID_IP, "IPv4"}, { NLPID_IP6, "IPv6"}, { 0, "unknown" } }; /* * Katz's point to point adjacency TLV uses codes to tell us the state of * the remote adjacency. Enumerate them. */ #define ISIS_PTP_ADJ_UP 0 #define ISIS_PTP_ADJ_INIT 1 #define ISIS_PTP_ADJ_DOWN 2 static int osi_cksum(const u_char *, u_int, u_char *); static void esis_print(const u_char *, u_int); static int isis_print(const u_char *, u_int); static struct tok isis_ptp_adjancey_values[] = { { ISIS_PTP_ADJ_UP, "Up" }, { ISIS_PTP_ADJ_INIT, "Initializing" }, { ISIS_PTP_ADJ_DOWN, "Down" } }; struct isis_tlv_ptp_adj { u_char adjacency_state; u_char ext_local_circuit_id[4]; u_char neighbor_sysid[SYSTEM_ID_LEN]; u_char neighbor_ext_local_circuit_id[4]; }; struct isis_tlv_ip_reach { u_char metric_default; u_char metric_delay; u_char metric_expense; u_char metric_error; u_char prefix[4]; u_char mask[4]; }; struct isis_tlv_is_reach { u_char metric_default; u_char metric_delay; u_char metric_expense; u_char metric_error; u_char neighbor_nodeid[SYSTEM_ID_LEN+1]; }; struct isis_common_header { u_char nlpid; u_char fixed_len; u_char version; /* Protocol version? */ u_char id_length; u_char pdu_type; /* 3 MSbs are reserved */ u_char pkt_version; /* Packet format version? */ u_char reserved; u_char max_area; }; struct isis_iih_lan_header { u_char circuit_type; u_char source_id[SYSTEM_ID_LEN]; u_char holding_time[2]; u_char pdu_len[2]; u_char priority; u_char lan_id[SYSTEM_ID_LEN+1]; }; struct isis_iih_ptp_header { u_char circuit_type; u_char source_id[SYSTEM_ID_LEN]; u_char holding_time[2]; u_char pdu_len[2]; u_char circuit_id; }; struct isis_lsp_header { u_char pdu_len[2]; u_char remaining_lifetime[2]; u_char lsp_id[SYSTEM_ID_LEN+2]; u_char sequence_number[4]; u_char checksum[2]; u_char typeblock; }; struct isis_csnp_header { u_char pdu_len[2]; u_char source_id[SYSTEM_ID_LEN+1]; u_char start_lsp_id[SYSTEM_ID_LEN+2]; u_char end_lsp_id[SYSTEM_ID_LEN+2]; }; struct isis_psnp_header { u_char pdu_len[2]; u_char source_id[SYSTEM_ID_LEN+1]; }; struct isis_tlv_lsp { u_char remaining_lifetime[2]; u_char lsp_id[SYSTEM_ID_LEN+2]; u_char sequence_number[4]; u_char checksum[2]; }; #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header)) #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header)) #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header)) #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header)) #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header)) #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header)) void isoclns_print(const u_char *p, u_int length, u_int caplen, const u_char *esrc, const u_char *edst) { u_char pdu_type; const struct isis_common_header *header; header = (const struct isis_common_header *)p; pdu_type = header->pdu_type & PDU_TYPE_MASK; if (caplen < 1) { printf("[|iso-clns] "); if (!eflag && esrc != NULL && edst != NULL) printf("%s > %s", etheraddr_string(esrc), etheraddr_string(edst)); return; } switch (*p) { case NLPID_CLNS: (void)printf("CLNS(%d)", length); if (!eflag && esrc != NULL && edst != NULL) (void)printf(", %s > %s", etheraddr_string(esrc), etheraddr_string(edst)); break; case NLPID_ESIS: (void)printf("ESIS"); if (!eflag && esrc != NULL && edst != NULL) (void)printf(", %s > %s", etheraddr_string(esrc), etheraddr_string(edst)); esis_print(p, length); return; case NLPID_ISIS: (void)printf("ISIS(%d)", length); if (!eflag && esrc != NULL && edst != NULL) (void)printf(", %s > %s", etheraddr_string(esrc), etheraddr_string(edst)); if (!isis_print(p, length)) default_print_unaligned(p, caplen); break; case NLPID_NULLNS: (void)printf("ISO NULLNS(%d)", length); if (!eflag && esrc != NULL && edst != NULL) (void)printf(", %s > %s", etheraddr_string(esrc), etheraddr_string(edst)); break; default: (void)printf("CLNS %02x(%d)", p[0], length); if (!eflag && esrc != NULL && edst != NULL) (void)printf(", %s > %s", etheraddr_string(esrc), etheraddr_string(edst)); if (caplen > 1) default_print_unaligned(p, caplen); break; } } #define ESIS_REDIRECT 6 #define ESIS_ESH 2 #define ESIS_ISH 4 struct esis_hdr { u_char version; u_char reserved; u_char type; u_char tmo[2]; u_char cksum[2]; }; static void esis_print(const u_char *p, u_int length) { const u_char *ep; u_int li; const struct esis_hdr *eh; u_char off[2]; if (length <= 2) { if (qflag) printf(" bad pkt!"); else printf(" no header at all!"); return; } li = p[1]; eh = (const struct esis_hdr *) &p[2]; ep = p + li; if (li > length) { if (qflag) printf(" bad pkt!"); else printf(" LI(%d) > PDU size (%d)!", li, length); return; } if (li < sizeof(struct esis_hdr) + 2) { if (qflag) printf(" bad pkt!"); else { printf(" too short for esis header %d:", li); while (--length != 0) printf("%02X", *p++); } return; } switch (eh->type & 0x1f) { case ESIS_REDIRECT: printf(" redirect"); break; case ESIS_ESH: printf(" esh"); break; case ESIS_ISH: printf(" ish"); break; default: printf(" type %d", eh->type & 0x1f); break; } off[0] = eh->cksum[0]; off[1] = eh->cksum[1]; if (vflag && osi_cksum(p, li, off)) { printf(" bad cksum (got %02x%02x)", eh->cksum[1], eh->cksum[0]); default_print(p, length); return; } if (eh->version != 1) { printf(" unsupported version %d", eh->version); return; } p += sizeof(*eh) + 2; li -= sizeof(*eh) + 2; /* protoid * li */ switch (eh->type & 0x1f) { case ESIS_REDIRECT: { const u_char *dst, *snpa, *is; dst = p; p += *p + 1; if (p > snapend) return; printf("\n\t\t\t %s", isonsap_string(dst)); snpa = p; p += *p + 1; is = p; p += *p + 1; if (p > snapend) return; if (p > ep) { printf(" [bad li]"); return; } if (is[0] == 0) printf(" > %s", etheraddr_string(&snpa[1])); else printf(" > %s", isonsap_string(is)); li = ep - p; break; } #if 0 case ESIS_ESH: printf(" esh"); break; #endif case ESIS_ISH: { const u_char *is; is = p; p += *p + 1; if (p > ep) { printf(" [bad li]"); return; } if (p > snapend) return; if (!qflag) printf("\n\t\t\t %s", isonsap_string(is)); li = ep - p; break; } default: (void)printf(" len=%d", length); if (length && p < snapend) { length = snapend - p; default_print(p, length); } return; } if (vflag) while (p < ep && li) { u_int op, opli; const u_char *q; if (snapend - p < 2) return; if (li < 2) { printf(" bad opts/li"); return; } op = *p++; opli = *p++; li -= 2; if (opli > li) { printf(" opt (%d) too long", op); return; } li -= opli; q = p; p += opli; if (snapend < p) return; if (op == 198 && opli == 2) { printf(" tmo=%d", q[0] * 256 + q[1]); continue; } printf (" %d:<", op); while (opli-- > 0) printf("%02x", *q++); printf (">"); } } /* * print_nsap * Print out an NSAP. */ static int print_nsap(register const u_char *cp, register int length) { int i; for (i = 0; i < length; i++) { if (!TTEST2(*cp, 1)) return (0); printf("%02x", *cp++); if (((i & 1) == 0) && (i + 1 < length)) { printf("."); } } return (1); } static int isis_print_sysid(const u_char *cp) { int i; for (i = 1; i <= 6; i++) { if (!TTEST2(*cp, 1)) return (0); printf("%02x", *cp++); if ((i==2)^(i==4)) { printf("."); } } return (1); } static int isis_print_nodeid(const u_char *cp) { int i; for (i = 1; i <= 7; i++) { if (!TTEST2(*cp, 1)) return (0); printf("%02x", *cp++); if ((i & 1) == 0) { printf("."); } } return (1); } static void isis_print_lspid(const u_char *cp) { int i; for (i = 1; i <= 7; i++) { printf("%02x", *cp++); if ((i & 1) == 0) printf("."); } printf("-%02x", *cp); } static int isis_print_tlv_ip_reach (const u_char *cp, int length) { u_int bitmasks[33] = { 0x00000000, 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff }; u_int mask; int prefix_len; const struct isis_tlv_ip_reach *tlv_ip_reach; tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp; while (length > 0) { if (length < sizeof(*tlv_ip_reach)) { printf("short IP reachability (%d vs %lu)", length, (unsigned long)sizeof(*tlv_ip_reach)); return (0); } if (!TTEST(*tlv_ip_reach)) return (0); mask = EXTRACT_32BITS(tlv_ip_reach->mask); prefix_len = 0; while (prefix_len <= 33) { if (bitmasks[prefix_len++] == mask) { prefix_len--; break; } } /* * 34 indicates no match -> must be a discontiguous netmask * lets dump the mask, otherwise print the prefix_len */ if (prefix_len == 34) printf("\n\t\t\tIPv4 prefix: %u.%u.%u.%u mask %u.%u.%u.%u", (tlv_ip_reach->prefix)[0], (tlv_ip_reach->prefix)[1], (tlv_ip_reach->prefix)[2], (tlv_ip_reach->prefix)[3], (tlv_ip_reach->mask)[0], (tlv_ip_reach->mask)[1], (tlv_ip_reach->mask)[2], (tlv_ip_reach->mask)[3]); else printf("\n\t\t\tIPv4 prefix: %u.%u.%u.%u/%u", (tlv_ip_reach->prefix)[0], (tlv_ip_reach->prefix)[1], (tlv_ip_reach->prefix)[2], (tlv_ip_reach->prefix)[3], prefix_len); printf("\n\t\t\t Default Metric: %02d, %s, Distribution: %s", ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->metric_default), ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->metric_default) ? "External" : "Internal", ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->metric_default) ? "down" : "up"); if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->metric_delay)) printf("\n\t\t\t Delay Metric: %02d, %s", ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->metric_delay), ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->metric_delay) ? "External" : "Internal"); if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->metric_expense)) printf("\n\t\t\t Expense Metric: %02d, %s", ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->metric_expense), ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->metric_expense) ? "External" : "Internal"); if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->metric_error)) printf("\n\t\t\t Error Metric: %02d, %s", ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->metric_error), ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->metric_error) ? "External" : "Internal"); length -= sizeof(struct isis_tlv_ip_reach); tlv_ip_reach++; } return (1); } /* * isis_print * Decode IS-IS packets. Return 0 on error. */ static int isis_print (const u_char *p, u_int length) { const struct isis_common_header *header; const struct isis_iih_lan_header *header_iih_lan; const struct isis_iih_ptp_header *header_iih_ptp; const struct isis_lsp_header *header_lsp; const struct isis_csnp_header *header_csnp; const struct isis_psnp_header *header_psnp; const struct isis_tlv_lsp *tlv_lsp; const struct isis_tlv_ptp_adj *tlv_ptp_adj; const struct isis_tlv_is_reach *tlv_is_reach; u_char pdu_type, max_area, type, len, tmp, alen, subl, subt, tslen, ttslen; const u_char *optr, *pptr, *tptr; u_char subtlv_len; u_short packet_len,pdu_len; u_int i,j,bit_length,byte_length,metric; u_char prefix[4]; /* copy buffer for ipv4 prefixes */ #ifdef INET6 u_char prefix6[16]; /* copy buffer for ipv6 prefixes */ #endif u_char off[2]; float bw; /* copy buffer for several subTLVs of the extended IS reachability TLV */ packet_len=length; optr = p; /* initialize the _o_riginal pointer - need it for parsing the checksum TLV */ header = (const struct isis_common_header *)p; TCHECK(*header); pptr = p+(ISIS_COMMON_HEADER_SIZE); header_iih_lan = (const struct isis_iih_lan_header *)pptr; header_iih_ptp = (const struct isis_iih_ptp_header *)pptr; header_lsp = (const struct isis_lsp_header *)pptr; header_csnp = (const struct isis_csnp_header *)pptr; header_psnp = (const struct isis_psnp_header *)pptr; /* * Sanity checking of the header. */ if (header->nlpid != NLPID_ISIS) { printf(", coding error!"); return (0); } if (header->version != ISIS_VERSION) { printf(", version %d packet not supported", header->version); return (0); } if ((header->id_length != SYSTEM_ID_LEN) && (header->id_length != 0)) { printf(", system ID length of %d is not supported", header->id_length); return (0); } if (header->pkt_version != ISIS_VERSION) { printf(", version %d packet not supported", header->pkt_version); return (0); } max_area = header->max_area; switch(max_area) { case 0: max_area = 3; /* silly shit */ break; case 255: printf(", bad packet -- 255 areas"); return (0); default: break; } printf(", hlen: %u, v: %u, sys-id-len: 6 (0), max-area: %u (%u)", header->fixed_len, header->pkt_version, max_area, header->max_area); pdu_type=header->pdu_type; switch (pdu_type) { case L1_LAN_IIH: case L2_LAN_IIH: if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) { printf(", bogus fixed header length %u should be %lu", header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE); return (0); } pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len); if (packet_len>pdu_len) { packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ length=pdu_len; } printf(", L%s Lan IIH (%u)", ISIS_MASK_LEVEL_BITS(pdu_type) ? "1" : "2", pdu_len); TCHECK(*header_iih_lan); printf("\n\t\t source-id: "); isis_print_sysid(header_iih_lan->source_id); printf(", holding time: %us",EXTRACT_16BITS(header_iih_lan->holding_time)); switch(header_iih_lan->circuit_type) { case 1: printf(", Level 1 only"); break; case 2: printf(", Level 2 only"); break; case 3: printf(", Level 1, Level 2"); break; default: printf(", unknown 0x%02x", header_iih_lan->circuit_type); break; } printf("\n\t\t lan-id: "); isis_print_nodeid(header_iih_lan->lan_id); printf(", Priority: %u",(header_iih_lan->priority) & PRIORITY_MASK); packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); break; case PTP_IIH: if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) { printf(", bogus fixed header length %u should be %lu", header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE); return (0); } pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len); if (packet_len>pdu_len) { packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ length=pdu_len; } printf(", PTP IIH (%u)",pdu_len); TCHECK(*header_iih_ptp); printf("\n\t\t source-id: "); isis_print_sysid(header_iih_ptp->source_id); printf(", holding time: %us",EXTRACT_16BITS(header_iih_ptp->holding_time)); printf(", circuit-id: 0x%02x", header_iih_ptp->circuit_id); switch(header_iih_ptp->circuit_type) { case 1: printf(", Level 1 only"); break; case 2: printf(", Level 2 only"); break; case 3: printf(", Level 1, Level 2"); break; default: printf(", unknown 0x%02x", header_iih_ptp->circuit_type); break; } packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); break; case L1_LSP: case L2_LSP: if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) { printf(", bogus fixed header length %u should be %lu", header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE); return (0); } pdu_len=EXTRACT_16BITS(header_lsp->pdu_len); if (packet_len>pdu_len) { packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ length=pdu_len; } if (pdu_type == L1_LSP) printf(", L1 LSP (%u)",pdu_len); else if (pdu_type == L2_LSP) printf(", L2 LSP (%u)",pdu_len); TCHECK(*header_lsp); printf("\n\t\t lsp-id: "); isis_print_lspid(header_lsp->lsp_id); printf(", sequence number: 0x%08x",EXTRACT_32BITS(header_lsp->sequence_number)); printf(", lifetime: %5us",EXTRACT_16BITS(header_lsp->remaining_lifetime)); printf("\n\t\t checksum: 0x%04x",EXTRACT_16BITS(header_lsp->checksum)); printf(", %s", ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""); if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) { printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""); printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""); printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""); printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : ""); printf("ATT bit set, "); } printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : ""); printf("%s", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))); packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); break; case L1_CSNP: case L2_CSNP: if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) { printf(", bogus fixed header length %u should be %lu", header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE); return (0); } pdu_len=EXTRACT_16BITS(header_csnp->pdu_len); if (packet_len>pdu_len) { packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ length=pdu_len; } printf(", L%s CSNP (%u)", ISIS_MASK_LEVEL_BITS(pdu_type) ? "2" : "1", pdu_len); TCHECK(*header_csnp); printf("\n\t\t source-id: "); isis_print_nodeid(header_csnp->source_id); printf("\n\t\t start lsp-id: "); isis_print_lspid(header_csnp->start_lsp_id); printf("\n\t\t end lsp-id: "); isis_print_lspid(header_csnp->end_lsp_id); packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); break; case L1_PSNP: case L2_PSNP: if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) { printf("- bogus fixed header length %u should be %lu", header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE); return (0); } pdu_len=EXTRACT_16BITS(header_psnp->pdu_len); if (packet_len>pdu_len) { packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ length=pdu_len; } printf(", L%s PSNP (%u)", ISIS_MASK_LEVEL_BITS(pdu_type) ? "2" : "1", pdu_len); TCHECK(*header_psnp); printf("\n\t\t source-id: "); isis_print_nodeid(header_psnp->source_id); packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); break; default: printf(", PDU type (0x%02x) not supported", pdu_type); return (1); } /* * Now print the TLV's. */ while (packet_len >= 2) { if (pptr == snapend) { return (1); } if (!TTEST2(*pptr, 2)) { printf("\n\t\t\t packet exceeded snapshot (%ld) bytes", (long)(pptr-snapend)); return (1); } type = *pptr++; len = *pptr++; packet_len -= 2; if (len > packet_len) { break; } printf("\n\t\t "); switch (type) { case TLV_AREA_ADDR: printf("Area address(es) (%u)",len); tmp = len; tptr = pptr; if (!TTEST2(*tptr, 1)) goto trunctlv; alen = *tptr++; while (tmp && alen < tmp) { printf("\n\t\t\tArea address (%u): ",alen); if (!print_nsap(tptr, alen)) return (1); tptr += alen; tmp -= alen + 1; if (tmp==0) /* if this is the last area address do not attemt a boundary check */ break; if (!TTEST2(*tptr, 1)) goto trunctlv; alen = *tptr++; } break; case TLV_ISNEIGH: printf("IS Neighbor(s) (%u)",len); tmp = len; tptr = pptr; while (tmp >= ETHER_ADDR_LEN) { printf("\n\t\t\tIS Neighbor: "); if (!isis_print_sysid(tptr)) return (1); tmp -= ETHER_ADDR_LEN; tptr += ETHER_ADDR_LEN; } break; case TLV_PADDING: printf("Padding (%u)", len); break; case TLV_MT_IS_REACH: printf("Multi Topology IS Reachability (%u)",len); tptr=pptr; tmp=len; while (tmp>0) { printf("\n\t\t\t"); if (!TTEST2(*tptr, 2)) goto trunctlv; switch(EXTRACT_16BITS(tptr)&0x0fff) { case 0: printf("IPv4 unicast"); break; case 1: printf("In-Band Management"); break; case 2: printf("IPv6 unicast"); break; case 3: printf("Multicast"); break; case 4095: printf("Development, Experimental or Proprietary"); break; default: printf("Reserved for IETF Consensus"); break; } printf(" Topology (0x%03x)",EXTRACT_16BITS(tptr)&0x0fff); tptr+=2; printf("\n\t\t\t IS Neighbor: "); if (!isis_print_nodeid(tptr)) return (1); tptr+=(SYSTEM_ID_LEN+1); if (!TTEST2(*tptr, 3)) goto trunctlv; printf(", Metric: %d",EXTRACT_24BITS(tptr)); tptr+=3; if (!TTEST2(*tptr, 1)) goto trunctlv; tslen=*(tptr++); printf(", %ssub-TLVs present",tslen ? "" : "no "); tptr+=tslen; tmp-=(13+tslen); } break; case TLV_EXT_IS_REACH: printf("Extended IS Reachability (%u)",len); tptr=pptr; tmp=len; while (tmp>0) { printf("\n\t\t\tIS Neighbor: "); if (!isis_print_nodeid(tptr)) return (1); tptr+=(SYSTEM_ID_LEN+1); if (!TTEST2(*tptr, 3)) goto trunctlv; printf(", Metric: %d",EXTRACT_24BITS(tptr)); tptr+=3; if (!TTEST2(*tptr, 1)) goto trunctlv; tslen=*(tptr++); printf(", %ssub-TLVs present",tslen ? "" : "no "); if (tslen) { printf(" (%u)",tslen); ttslen=tslen; while (ttslen>0) { if (!TTEST2(*tptr,2)) goto trunctlv; printf("\n\t\t\t "); subt=*(tptr++); subl=*(tptr++); switch(subt) { case SUBTLV_EXT_IS_REACH_ADMIN_GROUP: printf("Administrative groups: 0x%08x", EXTRACT_32BITS(tptr)); break; case SUBTLV_EXT_IS_REACH_MAX_LINK_BW : if (!TTEST2(*tptr,4)) goto trunctlv; j = EXTRACT_32BITS(tptr); memcpy (&bw, &j, 4); printf("Maximum link bandwidth : %.3f Mbps", bw*8/1000000 ); break; case SUBTLV_EXT_IS_REACH_RESERVABLE_BW : if (!TTEST2(*tptr,4)) goto trunctlv; j = EXTRACT_32BITS(tptr); memcpy (&bw, &j, 4); printf("Reservable link bandwidth: %.3f Mbps", bw*8/1000000 ); break; case SUBTLV_EXT_IS_REACH_UNRESERVED_BW : printf("Unreserved bandwidth:"); for (i = 0; i < 8; i++) { if (!TTEST2(*tptr,4)) goto trunctlv; j = EXTRACT_32BITS(tptr); memcpy (&bw, &j, 4); printf("\n\t\t\t priority level %d: %.3f Mbps", i, bw*8/1000000 ); tptr+=4; } tptr-=32; break; case SUBTLV_EXT_IS_REACH_TE_METRIC: if (!TTEST2(*tptr,3)) goto trunctlv; printf("Traffic Engineering Metric: %d", EXTRACT_24BITS(tptr)); break; case SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR: if (!TTEST2(*tptr,4)) goto trunctlv; printf("IPv4 interface address: %s", ipaddr_string(tptr)); break; case SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR: if (!TTEST2(*tptr,4)) goto trunctlv; printf("IPv4 neighbor address: %s", ipaddr_string(tptr)); break; case 250: case 251: case 252: case 253: case 254: printf("Reserved for cisco specific extensions, type %d, length %d", subt, subl); break; case 255: printf("Reserved for future expansion, type %d, length %d", subt, subl); break; default: printf("unknown subTLV, type %d, length %d", subt, subl); } tptr+=subl; ttslen-=(subl+2); } } tptr+=tslen; tmp-=(11+tslen); } break; case TLV_IS_REACH: printf("IS Reachability (%u)",len); tptr=pptr; if (!TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */ goto trunctlv; switch (*tptr) { case 0: printf("\n\t\t\tIsNotVirtual"); break; case 1: printf("\n\t\t\tIsVirtual"); break; default: printf("\n\t\t\tbogus virtual flag 0x%02x",(*tptr)); break; } tptr++; tlv_is_reach = (const struct isis_tlv_is_reach *)tptr; tmp = len; while (tmp >= sizeof(struct isis_tlv_is_reach)) { if (!TTEST(*tlv_is_reach)) goto trunctlv; printf("\n\t\t\tIS Neighbor: "); isis_print_nodeid(tlv_is_reach->neighbor_nodeid); printf(", Default Metric: %d, %s", ISIS_LSP_TLV_METRIC_VALUE(tlv_is_reach->metric_default), ISIS_LSP_TLV_METRIC_IE(tlv_is_reach->metric_default) ? "External" : "Internal"); if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_is_reach->metric_delay)) printf("\n\t\t\t Delay Metric: %d, %s", ISIS_LSP_TLV_METRIC_VALUE(tlv_is_reach->metric_delay), ISIS_LSP_TLV_METRIC_IE(tlv_is_reach->metric_delay) ? "External" : "Internal"); if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_is_reach->metric_expense)) printf("\n\t\t\t Expense Metric: %d, %s", ISIS_LSP_TLV_METRIC_VALUE(tlv_is_reach->metric_expense), ISIS_LSP_TLV_METRIC_IE(tlv_is_reach->metric_expense) ? "External" : "Internal"); if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_is_reach->metric_error)) printf("\n\t\t\t Error Metric: %d, %s", ISIS_LSP_TLV_METRIC_VALUE(tlv_is_reach->metric_error), ISIS_LSP_TLV_METRIC_IE(tlv_is_reach->metric_error) ? "External" : "Internal"); tmp -= sizeof(struct isis_tlv_is_reach); tlv_is_reach++; } break; case TLV_IP_REACH: printf("IP Internal reachability (%u)",len); if (!isis_print_tlv_ip_reach(pptr, len)) return (1); break; case TLV_IP_REACH_EXT: printf("IP External reachability (%u)",len); if (!isis_print_tlv_ip_reach(pptr, len)) return (1); break; case TLV_EXT_IP_REACH: printf("Extended IP reachability (%u)",len); i=len; tptr=pptr; while (i>0) { memset (prefix, 0, 4); if (!TTEST2(*tptr, 4)) return (1); metric = EXTRACT_32BITS(tptr); tptr+=4; if (!TTEST2(*tptr, 1)) return (1); j=*(tptr); bit_length = (*(tptr)++&0x3f); byte_length = (bit_length + 7) / 8; if (!TTEST2(*tptr, byte_length)) return (1); memcpy(prefix,tptr,byte_length); printf("\n\t\t\tIPv4 prefix: %u.%u.%u.%u/%d", prefix[0], prefix[1], prefix[2], prefix[3], bit_length); printf("\n\t\t\t Metric: %u, Distribution: %s", metric, ISIS_MASK_TLV_EXT_IP_UPDOWN(j) ? "down" : "up"); printf(", %ssub-TLVs present", ISIS_MASK_TLV_EXT_IP_SUBTLV(j) ? "" : "no "); if (ISIS_MASK_TLV_EXT_IP_SUBTLV(j)) { if (!TTEST2(*tptr, 1)) return (1); subtlv_len = *tptr; printf(" (%u)",subtlv_len); /* no subTLV decoder supported - just print out subTLV length */ i -= subtlv_len; tptr += subtlv_len + 1; } i-=(5+byte_length); tptr+=byte_length; } break; #ifdef INET6 case TLV_IP6_REACH: printf("IP6 reachability (%u)",len); i=len; tptr=pptr; while (i>0) { if (!TTEST2(*tptr, 4)) return (1); metric = EXTRACT_32BITS(tptr); tptr+=4; if (!TTEST2(*tptr, 2)) return (1); j=*(tptr++); bit_length = (*(tptr)++); byte_length = (bit_length + 7) / 8; if (!TTEST2(*tptr, byte_length)) return (1); memset(prefix6, 0, 16); memcpy(prefix6,tptr,byte_length); printf("\n\t\t\tIPv6 prefix: %s/%u", ip6addr_string(prefix6), bit_length); printf("\n\t\t\t Metric: %u, %s, Distribution: %s, %ssub-TLVs present", metric, ISIS_MASK_TLV_IP6_IE(j) ? "External" : "Internal", ISIS_MASK_TLV_IP6_UPDOWN(j) ? "down" : "up", ISIS_MASK_TLV_IP6_SUBTLV(j) ? "" : "no "); if (ISIS_MASK_TLV_IP6_SUBTLV(j)) { if (!TTEST2(*tptr, 1)) return (1); printf(" (%u)",*tptr); /* no subTLV decoder supported - just print out subTLV length */ i-=*tptr; tptr+=*tptr++; } i-=(6+byte_length); tptr+=byte_length; } break; #endif #ifdef INET6 case TLV_IP6ADDR: printf("IPv6 Interface address(es) (%u)",len); i=len; tptr=pptr; while (i>0) { if (!TTEST2(*tptr, 16)) goto trunctlv; printf("\n\t\t\tIPv6 interface address: %s", ip6addr_string(tptr)); tptr += 16; i -= 16; } break; #endif case TLV_AUTH: if (!TTEST2(*pptr, 1)) goto trunctlv; printf("Authentication (%u)",len); if (*pptr==SUBTLV_AUTH_SIMPLE) { printf("\n\t\t\tsimple text password: "); for(i=1;i=1) { if (!TTEST2(*pptr, 1)) goto trunctlv; printf("\n\t\t\tAdjacency State: %s", tok2str(isis_ptp_adjancey_values, "#0x%x", *pptr)); i--; } if(i>=4) { if (!TTEST2(tlv_ptp_adj->ext_local_circuit_id, 4)) goto trunctlv; printf("\n\t\t\tExtended Local circuit ID: 0x%08x", EXTRACT_32BITS(tlv_ptp_adj->ext_local_circuit_id)); i-=4; } if(i>=6) { if (!TTEST2(tlv_ptp_adj->neighbor_sysid, 6)) goto trunctlv; printf("\n\t\t\tNeighbor SystemID: "); isis_print_sysid(tlv_ptp_adj->neighbor_sysid); i-=6; } if(i>=4) { if (!TTEST2(tlv_ptp_adj->neighbor_ext_local_circuit_id, 4)) goto trunctlv; printf("\n\t\t\tNeighbor Extended Local circuit ID: 0x%08x", EXTRACT_32BITS(tlv_ptp_adj->neighbor_ext_local_circuit_id)); } break; case TLV_PROTOCOLS: printf("Protocols supported (%u)", len); printf("\n\t\t\tNLPID(s): "); for (i = 0; i < len; i++) { if (!TTEST2(*(pptr+i), 1)) goto trunctlv; printf("%s (0x%02x)",tok2str(isis_nlpid_values, "Unknown", *(pptr+i)),*(pptr+i)); if (i0) { if (!TTEST2(*tptr, 4)) goto trunctlv; printf("\n\t\t\tIPv4 interface address: %s", ipaddr_string(tptr)); tptr += 4; i -= 4; } break; case TLV_HOSTNAME: printf("Hostname (%u)", len); printf("\n\t\t\tHostname: "); for(i = 0; i < len; i++) { if (!TTEST2(*(pptr+i), 1)) goto trunctlv; printf("%c",*(pptr+i)); } break; case TLV_LSP: tlv_lsp = (const struct isis_tlv_lsp *)pptr; printf("LSP entries (%u)", len); i=0; while(ilsp_id)) return (1); if (!TTEST((tlv_lsp->lsp_id)[SYSTEM_ID_LEN+1])) goto trunctlv; printf("-%02x",(tlv_lsp->lsp_id)[SYSTEM_ID_LEN+1]); if (!TTEST2(tlv_lsp->sequence_number, 4)) goto trunctlv; printf("\n\t\t\t sequence number: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number)); if (!TTEST2(tlv_lsp->remaining_lifetime, 2)) goto trunctlv; printf("\n\t\t\t Remaining lifetime: %5ds",EXTRACT_16BITS(tlv_lsp->remaining_lifetime)); if (!TTEST2(tlv_lsp->checksum, 2)) goto trunctlv; printf("\n\t\t\t checksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum)); i+=sizeof(struct isis_tlv_lsp); tlv_lsp++; } break; case TLV_CHECKSUM: if (!TTEST2(*pptr, 2)) goto trunctlv; printf("Checksum (%u)", len); printf("\n\t\t\tchecksum: 0x%04x", EXTRACT_16BITS(pptr)); if (osi_cksum(optr, length, off)) printf(" (incorrect)"); else printf(" (correct)"); break; case TLV_MT_SUPPORTED: printf("Multi Topology (%u)",len); i=len; tptr=pptr; while (i>1) { /* length can only be a multiple of 2, otherwise there is something broken -> so decode down until length is 1 */ if (i!=1) { if (!TTEST2(*tptr, 2)) goto trunctlv; printf("\n\t\t\t"); switch(EXTRACT_16BITS(tptr)&0x0fff) { case 0: printf("IPv4 unicast"); break; case 1: printf("In-Band Management"); break; case 2: printf("IPv6 unicast"); break; case 3: printf("Multicast"); break; case 4095: printf("Development, Experimental or Proprietary"); break; default: printf("Reserved for IETF Consensus"); break; } printf(" Topology (0x%03x)%s%s", EXTRACT_16BITS(tptr)&0xfff, (EXTRACT_16BITS(tptr)&0x8000) ? "" : ", no sub-TLVs present", (EXTRACT_16BITS(tptr)&0x4000) ? ", ATT bit set" : "" ); } else { printf("\n\t\t\tmalformed MT-ID"); break; } i-=2; tptr+=2; } break; case TLV_RESTART_SIGNALING: tptr=pptr; printf("Restart Signaling (%u)",len); if (!TTEST2(*tptr, 3)) goto trunctlv; printf("\n\t\t\tRestart Request bit %s, Restart Acknowledgement bit %s\n\t\t\tRemaining holding time: %us", ISIS_MASK_RESTART_RR(*tptr) ? "set" : "clear", ISIS_MASK_RESTART_RA(*tptr) ? "set" : "clear", EXTRACT_16BITS(tptr+1)); tptr += 3; break; default: printf("unknown TLV, type %d, length %d\n\t\t\t", type, len); tptr=pptr; for(i=0;i= 0) { c0 += *p++; c0 %= 255; c1 += c0; c1 %= 255; } return (c0 | c1); } tcpdump-3.7.2/print-krb.c0100644000076500000240000001530707165020602014420 0ustar fennerstaff/* * Copyright (c) 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Initial contribution from John Hawkinson (jhawk@mit.edu). */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.15 2000/09/29 04:58:42 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" const u_char *c_print(register const u_char *, register const u_char *); const u_char *krb4_print_hdr(const u_char *); void krb4_print(const u_char *); void krb_print(const u_char *, u_int); #define AUTH_MSG_KDC_REQUEST 1<<1 #define AUTH_MSG_KDC_REPLY 2<<1 #define AUTH_MSG_APPL_REQUEST 3<<1 #define AUTH_MSG_APPL_REQUEST_MUTUAL 4<<1 #define AUTH_MSG_ERR_REPLY 5<<1 #define AUTH_MSG_PRIVATE 6<<1 #define AUTH_MSG_SAFE 7<<1 #define AUTH_MSG_APPL_ERR 8<<1 #define AUTH_MSG_DIE 63<<1 #define KERB_ERR_OK 0 #define KERB_ERR_NAME_EXP 1 #define KERB_ERR_SERVICE_EXP 2 #define KERB_ERR_AUTH_EXP 3 #define KERB_ERR_PKT_VER 4 #define KERB_ERR_NAME_MAST_KEY_VER 5 #define KERB_ERR_SERV_MAST_KEY_VER 6 #define KERB_ERR_BYTE_ORDER 7 #define KERB_ERR_PRINCIPAL_UNKNOWN 8 #define KERB_ERR_PRINCIPAL_NOT_UNIQUE 9 #define KERB_ERR_NULL_KEY 10 struct krb { u_char pvno; /* Protocol Version */ u_char type; /* Type+B */ }; static char tstr[] = " [|kerberos]"; static struct tok type2str[] = { { AUTH_MSG_KDC_REQUEST, "KDC_REQUEST" }, { AUTH_MSG_KDC_REPLY, "KDC_REPLY" }, { AUTH_MSG_APPL_REQUEST, "APPL_REQUEST" }, { AUTH_MSG_APPL_REQUEST_MUTUAL, "APPL_REQUEST_MUTUAL" }, { AUTH_MSG_ERR_REPLY, "ERR_REPLY" }, { AUTH_MSG_PRIVATE, "PRIVATE" }, { AUTH_MSG_SAFE, "SAFE" }, { AUTH_MSG_APPL_ERR, "APPL_ERR" }, { AUTH_MSG_DIE, "DIE" }, { 0, NULL } }; static struct tok kerr2str[] = { { KERB_ERR_OK, "OK" }, { KERB_ERR_NAME_EXP, "NAME_EXP" }, { KERB_ERR_SERVICE_EXP, "SERVICE_EXP" }, { KERB_ERR_AUTH_EXP, "AUTH_EXP" }, { KERB_ERR_PKT_VER, "PKT_VER" }, { KERB_ERR_NAME_MAST_KEY_VER, "NAME_MAST_KEY_VER" }, { KERB_ERR_SERV_MAST_KEY_VER, "SERV_MAST_KEY_VER" }, { KERB_ERR_BYTE_ORDER, "BYTE_ORDER" }, { KERB_ERR_PRINCIPAL_UNKNOWN, "PRINCIPAL_UNKNOWN" }, { KERB_ERR_PRINCIPAL_NOT_UNIQUE,"PRINCIPAL_NOT_UNIQUE" }, { KERB_ERR_NULL_KEY, "NULL_KEY"}, { 0, NULL} }; /* little endian (unaligned) to host byte order */ /* XXX need to look at this... */ #define vtohlp(x) ((( ((char *)(x))[0] ) ) | \ (( ((char *)(x))[1] ) << 8) | \ (( ((char *)(x))[2] ) << 16) | \ (( ((char *)(x))[3] ) << 24)) #define vtohsp(x) ((( ((char *)(x))[0] ) ) | \ (( ((char *)(x))[1] ) << 8)) /* network (big endian) (unaligned) to host byte order */ #define ntohlp(x) ((( ((char *)(x))[3] ) ) | \ (( ((char *)(x))[2] ) << 8) | \ (( ((char *)(x))[1] ) << 16) | \ (( ((char *)(x))[0] ) << 24)) #define ntohsp(x) ((( ((char *)(x))[1] ) ) | \ (( ((char *)(x))[0] ) << 8)) const u_char * c_print(register const u_char *s, register const u_char *ep) { register u_char c; register int flag; flag = 1; while (s < ep) { c = *s++; if (c == '\0') { flag = 0; break; } if (!isascii(c)) { c = toascii(c); putchar('M'); putchar('-'); } if (!isprint(c)) { c ^= 0x40; /* DEL to ?, others to alpha */ putchar('^'); } putchar(c); } if (flag) return NULL; return (s); } const u_char * krb4_print_hdr(const u_char *cp) { cp += 2; #define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc PRINT; putchar('.'); PRINT; putchar('@'); PRINT; return (cp); trunc: fputs(tstr, stdout); return (NULL); #undef PRINT } void krb4_print(const u_char *cp) { register const struct krb *kp; u_char type; u_short len; #define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc /* True if struct krb is little endian */ #define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0) #define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? vtohsp(cp) : ntohsp(cp)) kp = (struct krb *)cp; if ((&kp->type) >= snapend) { fputs(tstr, stdout); return; } type = kp->type & (0xFF << 1); printf(" %s %s: ", IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type)); switch (type) { case AUTH_MSG_KDC_REQUEST: if ((cp = krb4_print_hdr(cp)) == NULL) return; cp += 4; /* ctime */ TCHECK(*cp); printf(" %dmin ", *cp++ * 5); PRINT; putchar('.'); PRINT; break; case AUTH_MSG_APPL_REQUEST: cp += 2; TCHECK(*cp); printf("v%d ", *cp++); PRINT; TCHECK(*cp); printf(" (%d)", *cp++); TCHECK(*cp); printf(" (%d)", *cp); break; case AUTH_MSG_KDC_REPLY: if ((cp = krb4_print_hdr(cp)) == NULL) return; cp += 10; /* timestamp + n + exp + kvno */ TCHECK2(*cp, sizeof(short)); len = KTOHSP(kp, cp); printf(" (%d)", len); break; case AUTH_MSG_ERR_REPLY: if ((cp = krb4_print_hdr(cp)) == NULL) return; cp += 4; /* timestamp */ TCHECK2(*cp, sizeof(short)); printf(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp))); cp += 4; PRINT; break; default: fputs("(unknown)", stdout); break; } return; trunc: fputs(tstr, stdout); } void krb_print(const u_char *dat, u_int length) { register const struct krb *kp; kp = (struct krb *)dat; if (dat >= snapend) { fputs(tstr, stdout); return; } switch (kp->pvno) { case 1: case 2: case 3: printf(" v%d", kp->pvno); break; case 4: printf(" v%d", kp->pvno); krb4_print((const u_char *)kp); break; case 106: case 107: fputs(" v5", stdout); /* Decode ASN.1 here "someday" */ break; } return; } tcpdump-3.7.2/print-l2tp.c0100644000076500000240000004675307627054630014547 0ustar fennerstaff/* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net) */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.10.2.1 2002/05/25 09:47:07 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "l2tp.h" #include "interface.h" #include "extract.h" static char tstr[] = " [|l2tp]"; #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */ #define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */ #define L2TP_MSGTYPE_SCCCN 3 /* Start-Control-Connection-Connected */ #define L2TP_MSGTYPE_STOPCCN 4 /* Stop-Control-Connection-Notification */ #define L2TP_MSGTYPE_HELLO 6 /* Hello */ #define L2TP_MSGTYPE_OCRQ 7 /* Outgoing-Call-Request */ #define L2TP_MSGTYPE_OCRP 8 /* Outgoing-Call-Reply */ #define L2TP_MSGTYPE_OCCN 9 /* Outgoing-Call-Connected */ #define L2TP_MSGTYPE_ICRQ 10 /* Incoming-Call-Request */ #define L2TP_MSGTYPE_ICRP 11 /* Incoming-Call-Reply */ #define L2TP_MSGTYPE_ICCN 12 /* Incoming-Call-Connected */ #define L2TP_MSGTYPE_CDN 14 /* Call-Disconnect-Notify */ #define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */ #define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */ static struct tok l2tp_msgtype2str[] = { { L2TP_MSGTYPE_SCCRQ, "SCCRQ" }, { L2TP_MSGTYPE_SCCRP, "SCCRP" }, { L2TP_MSGTYPE_SCCCN, "SCCCN" }, { L2TP_MSGTYPE_STOPCCN, "StopCCN" }, { L2TP_MSGTYPE_HELLO, "HELLO" }, { L2TP_MSGTYPE_OCRQ, "OCRQ" }, { L2TP_MSGTYPE_OCRP, "OCRP" }, { L2TP_MSGTYPE_OCCN, "OCCN" }, { L2TP_MSGTYPE_ICRQ, "ICRQ" }, { L2TP_MSGTYPE_ICRP, "ICRP" }, { L2TP_MSGTYPE_ICCN, "ICCN" }, { L2TP_MSGTYPE_CDN, "CDN" }, { L2TP_MSGTYPE_WEN, "WEN" }, { L2TP_MSGTYPE_SLI, "SLI" }, { 0, NULL } }; #define L2TP_AVP_MSGTYPE 0 /* Message Type */ #define L2TP_AVP_RESULT_CODE 1 /* Result Code */ #define L2TP_AVP_PROTO_VER 2 /* Protocol Version */ #define L2TP_AVP_FRAMING_CAP 3 /* Framing Capabilities */ #define L2TP_AVP_BEARER_CAP 4 /* Bearer Capabilities */ #define L2TP_AVP_TIE_BREAKER 5 /* Tie Breaker */ #define L2TP_AVP_FIRM_VER 6 /* Firmware Revision */ #define L2TP_AVP_HOST_NAME 7 /* Host Name */ #define L2TP_AVP_VENDOR_NAME 8 /* Vendor Name */ #define L2TP_AVP_ASSND_TUN_ID 9 /* Assigned Tunnel ID */ #define L2TP_AVP_RECV_WIN_SIZE 10 /* Receive Window Size */ #define L2TP_AVP_CHALLENGE 11 /* Challenge */ #define L2TP_AVP_Q931_CC 12 /* Q.931 Cause Code */ #define L2TP_AVP_CHALLENGE_RESP 13 /* Challenge Response */ #define L2TP_AVP_ASSND_SESS_ID 14 /* Assigned Session ID */ #define L2TP_AVP_CALL_SER_NUM 15 /* Call Serial Number */ #define L2TP_AVP_MINIMUM_BPS 16 /* Minimum BPS */ #define L2TP_AVP_MAXIMUM_BPS 17 /* Maximum BPS */ #define L2TP_AVP_BEARER_TYPE 18 /* Bearer Type */ #define L2TP_AVP_FRAMING_TYPE 19 /* Framing Type */ #define L2TP_AVP_PACKET_PROC_DELAY 20 /* Packet Processing Delay (OBSOLETE) */ #define L2TP_AVP_CALLED_NUMBER 21 /* Called Number */ #define L2TP_AVP_CALLING_NUMBER 22 /* Calling Number */ #define L2TP_AVP_SUB_ADDRESS 23 /* Sub-Address */ #define L2TP_AVP_TX_CONN_SPEED 24 /* (Tx) Connect Speed */ #define L2TP_AVP_PHY_CHANNEL_ID 25 /* Physical Channel ID */ #define L2TP_AVP_INI_RECV_LCP 26 /* Initial Received LCP CONFREQ */ #define L2TP_AVP_LAST_SENT_LCP 27 /* Last Sent LCP CONFREQ */ #define L2TP_AVP_LAST_RECV_LCP 28 /* Last Received LCP CONFREQ */ #define L2TP_AVP_PROXY_AUTH_TYPE 29 /* Proxy Authen Type */ #define L2TP_AVP_PROXY_AUTH_NAME 30 /* Proxy Authen Name */ #define L2TP_AVP_PROXY_AUTH_CHAL 31 /* Proxy Authen Challenge */ #define L2TP_AVP_PROXY_AUTH_ID 32 /* Proxy Authen ID */ #define L2TP_AVP_PROXY_AUTH_RESP 33 /* Proxy Authen Response */ #define L2TP_AVP_CALL_ERRORS 34 /* Call Errors */ #define L2TP_AVP_ACCM 35 /* ACCM */ #define L2TP_AVP_RANDOM_VECTOR 36 /* Random Vector */ #define L2TP_AVP_PRIVATE_GRP_ID 37 /* Private Group ID */ #define L2TP_AVP_RX_CONN_SPEED 38 /* (Rx) Connect Speed */ #define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */ #define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */ static struct tok l2tp_avp2str[] = { { L2TP_AVP_MSGTYPE, "MSGTYPE" }, { L2TP_AVP_RESULT_CODE, "RESULT_CODE" }, { L2TP_AVP_PROTO_VER, "PROTO_VER" }, { L2TP_AVP_FRAMING_CAP, "FRAMING_CAP" }, { L2TP_AVP_BEARER_CAP, "BEARER_CAP" }, { L2TP_AVP_TIE_BREAKER, "TIE_BREAKER" }, { L2TP_AVP_FIRM_VER, "FIRM_VER" }, { L2TP_AVP_HOST_NAME, "HOST_NAME" }, { L2TP_AVP_VENDOR_NAME, "VENDOR_NAME" }, { L2TP_AVP_ASSND_TUN_ID, "ASSND_TUN_ID" }, { L2TP_AVP_RECV_WIN_SIZE, "RECV_WIN_SIZE" }, { L2TP_AVP_CHALLENGE, "CHALLENGE" }, { L2TP_AVP_Q931_CC, "Q931_CC", }, { L2TP_AVP_CHALLENGE_RESP, "CHALLENGE_RESP" }, { L2TP_AVP_ASSND_SESS_ID, "ASSND_SESS_ID" }, { L2TP_AVP_CALL_SER_NUM, "CALL_SER_NUM" }, { L2TP_AVP_MINIMUM_BPS, "MINIMUM_BPS" }, { L2TP_AVP_MAXIMUM_BPS, "MAXIMUM_BPS" }, { L2TP_AVP_BEARER_TYPE, "BEARER_TYPE" }, { L2TP_AVP_FRAMING_TYPE, "FRAMING_TYPE" }, { L2TP_AVP_PACKET_PROC_DELAY, "PACKET_PROC_DELAY" }, { L2TP_AVP_CALLED_NUMBER, "CALLED_NUMBER" }, { L2TP_AVP_CALLING_NUMBER, "CALLING_NUMBER" }, { L2TP_AVP_SUB_ADDRESS, "SUB_ADDRESS" }, { L2TP_AVP_TX_CONN_SPEED, "TX_CONN_SPEED" }, { L2TP_AVP_PHY_CHANNEL_ID, "PHY_CHANNEL_ID" }, { L2TP_AVP_INI_RECV_LCP, "INI_RECV_LCP" }, { L2TP_AVP_LAST_SENT_LCP, "LAST_SENT_LCP" }, { L2TP_AVP_LAST_RECV_LCP, "LAST_RECV_LCP" }, { L2TP_AVP_PROXY_AUTH_TYPE, "PROXY_AUTH_TYPE" }, { L2TP_AVP_PROXY_AUTH_NAME, "PROXY_AUTH_NAME" }, { L2TP_AVP_PROXY_AUTH_CHAL, "PROXY_AUTH_CHAL" }, { L2TP_AVP_PROXY_AUTH_ID, "PROXY_AUTH_ID" }, { L2TP_AVP_PROXY_AUTH_RESP, "PROXY_AUTH_RESP" }, { L2TP_AVP_CALL_ERRORS, "CALL_ERRORS" }, { L2TP_AVP_ACCM, "ACCM" }, { L2TP_AVP_RANDOM_VECTOR, "RANDOM_VECTOR" }, { L2TP_AVP_PRIVATE_GRP_ID, "PRIVATE_GRP_ID" }, { L2TP_AVP_RX_CONN_SPEED, "RX_CONN_SPEED" }, { L2TP_AVP_SEQ_REQUIRED, "SEQ_REQUIRED" }, { L2TP_AVP_PPP_DISCON_CC, "PPP_DISCON_CC" }, { 0, NULL } }; static struct tok l2tp_authentype2str[] = { { L2TP_AUTHEN_TYPE_RESERVED, "Reserved" }, { L2TP_AUTHEN_TYPE_TEXTUAL, "Textual" }, { L2TP_AUTHEN_TYPE_CHAP, "CHAP" }, { L2TP_AUTHEN_TYPE_PAP, "PAP" }, { L2TP_AUTHEN_TYPE_NO_AUTH, "No Auth" }, { L2TP_AUTHEN_TYPE_MSCHAPv1, "MS-CHAPv1" }, { 0, NULL } }; #define L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL 0 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2 static struct tok l2tp_cc_direction2str[] = { { L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL, "global error" }, { L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER, "at peer" }, { L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL,"at local" }, { 0, NULL } }; #if 0 static char *l2tp_result_code_StopCCN[] = { "Reserved", "General request to clear control connection", "General error--Error Code indicates the problem", "Control channel already exists", "Requester is not authorized to establish a control channel", "The protocol version of the requester is not supported", "Requester is being shut down", "Finite State Machine error" #define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8 }; #endif #if 0 static char *l2tp_result_code_CDN[] = { "Reserved", "Call disconnected due to loss of carrier", "Call disconnected for the reason indicated in error code", "Call disconnected for administrative reasons", "Call failed due to lack of appropriate facilities being " \ "available (temporary condition)", "Call failed due to lack of appropriate facilities being " \ "available (permanent condition)", "Invalid destination", "Call failed due to no carrier detected", "Call failed due to detection of a busy signal", "Call failed due to lack of a dial tone", "Call was not established within time allotted by LAC", "Call was connected but no appropriate framing was detected" #define L2TP_MAX_RESULT_CODE_CDN_INDEX 12 }; #endif #if 0 static char *l2tp_error_code_general[] = { "No general error", "No control connection exists yet for this LAC-LNS pair", "Length is wrong", "One of the field values was out of range or " \ "reserved field was non-zero" "Insufficient resources to handle this operation now", "The Session ID is invalid in this context", "A generic vendor-specific error occurred in the LAC", "Try another" #define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8 }; #endif /******************************/ /* generic print out routines */ /******************************/ static void print_string(const u_char *dat, u_int length) { int i; for (i=0; i 2) { /* Error Code (opt) */ printf("/%u", EXTRACT_16BITS(ptr)); ptr++; } if (length > 4) { /* Error Message (opt) */ printf(" "); print_string((u_char *)ptr, length - 4); } } static void l2tp_proto_ver_print(const u_int16_t *dat) { printf("%u.%u", (EXTRACT_16BITS(dat) >> 8), (EXTRACT_16BITS(dat) & 0xff)); } static void l2tp_framing_cap_print(const u_char *dat) { u_int32_t *ptr = (u_int32_t *)dat; if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) { printf("A"); } if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_SYNC_MASK) { printf("S"); } } static void l2tp_bearer_cap_print(const u_char *dat) { u_int32_t *ptr = (u_int32_t *)dat; if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_ANALOG_MASK) { printf("A"); } if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_DIGITAL_MASK) { printf("D"); } } static void l2tp_q931_cc_print(const u_char *dat, u_int length) { print_16bits_val((u_int16_t *)dat); printf(", %02x", dat[2]); if (length > 3) { printf(" "); print_string(dat+3, length-3); } } static void l2tp_bearer_type_print(const u_char *dat) { u_int32_t *ptr = (u_int32_t *)dat; if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) { printf("A"); } if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_DIGITAL_MASK) { printf("D"); } } static void l2tp_framing_type_print(const u_char *dat) { u_int32_t *ptr = (u_int32_t *)dat; if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) { printf("A"); } if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) { printf("S"); } } static void l2tp_packet_proc_delay_print(void) { printf("obsolete"); } static void l2tp_proxy_auth_type_print(const u_char *dat) { u_int16_t *ptr = (u_int16_t *)dat; printf("%s", tok2str(l2tp_authentype2str, "AuthType-#%u", EXTRACT_16BITS(ptr))); } static void l2tp_proxy_auth_id_print(const u_char *dat) { u_int16_t *ptr = (u_int16_t *)dat; printf("%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK); } static void l2tp_call_errors_print(const u_char *dat) { u_int16_t *ptr = (u_int16_t *)dat; u_int16_t val_h, val_l; ptr++; /* skip "Reserved" */ val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("CRCErr=%u ", (val_h<<16) + val_l); val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("FrameErr=%u ", (val_h<<16) + val_l); val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("HardOver=%u ", (val_h<<16) + val_l); val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("BufOver=%u ", (val_h<<16) + val_l); val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("Timeout=%u ", (val_h<<16) + val_l); val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("AlignErr=%u ", (val_h<<16) + val_l); } static void l2tp_accm_print(const u_char *dat) { u_int16_t *ptr = (u_int16_t *)dat; u_int16_t val_h, val_l; ptr++; /* skip "Reserved" */ val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("send=%08x ", (val_h<<16) + val_l); val_h = EXTRACT_16BITS(ptr); ptr++; val_l = EXTRACT_16BITS(ptr); ptr++; printf("recv=%08x ", (val_h<<16) + val_l); } static void l2tp_ppp_discon_cc_print(const u_char *dat, u_int length) { u_int16_t *ptr = (u_int16_t *)dat; printf("%04x, ", EXTRACT_16BITS(ptr)); ptr++; /* Disconnect Code */ printf("%04x ", EXTRACT_16BITS(ptr)); ptr++; /* Control Protocol Number */ printf("%s", tok2str(l2tp_cc_direction2str, "Direction-#%u", *((u_char *)ptr++))); if (length > 5) { printf(" "); print_string((const u_char *)ptr, length-5); } } static void l2tp_avp_print(const u_char *dat, int length) { u_int len; const u_int16_t *ptr = (u_int16_t *)dat; u_int16_t attr_type; int hidden = FALSE; if (length <= 0) { return; } printf(" "); TCHECK(*ptr); /* Flags & Length */ len = EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_LEN_MASK; /* If it is not long enough to decode the entire AVP, we'll abandon. */ TCHECK2(*ptr, len); /* After this point, no need to worry about truncation */ if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) { printf("*"); } if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) { hidden = TRUE; printf("?"); } ptr++; if (EXTRACT_16BITS(ptr)) { /* Vendor Specific Attribute */ printf("VENDOR%04x:", EXTRACT_16BITS(ptr)); ptr++; printf("ATTR%04x", EXTRACT_16BITS(ptr)); ptr++; printf("("); print_octets((u_char *)ptr, len-6); printf(")"); } else { /* IETF-defined Attributes */ ptr++; attr_type = EXTRACT_16BITS(ptr); ptr++; printf("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type)); printf("("); if (hidden) { printf("???"); } else { switch (attr_type) { case L2TP_AVP_MSGTYPE: l2tp_msgtype_print((u_char *)ptr); break; case L2TP_AVP_RESULT_CODE: l2tp_result_code_print((u_char *)ptr, len-6); break; case L2TP_AVP_PROTO_VER: l2tp_proto_ver_print(ptr); break; case L2TP_AVP_FRAMING_CAP: l2tp_framing_cap_print((u_char *)ptr); break; case L2TP_AVP_BEARER_CAP: l2tp_bearer_cap_print((u_char *)ptr); break; case L2TP_AVP_TIE_BREAKER: print_octets((u_char *)ptr, 8); break; case L2TP_AVP_FIRM_VER: case L2TP_AVP_ASSND_TUN_ID: case L2TP_AVP_RECV_WIN_SIZE: case L2TP_AVP_ASSND_SESS_ID: print_16bits_val(ptr); break; case L2TP_AVP_HOST_NAME: case L2TP_AVP_VENDOR_NAME: case L2TP_AVP_CALLING_NUMBER: case L2TP_AVP_CALLED_NUMBER: case L2TP_AVP_SUB_ADDRESS: case L2TP_AVP_PROXY_AUTH_NAME: case L2TP_AVP_PRIVATE_GRP_ID: print_string((u_char *)ptr, len-6); break; case L2TP_AVP_CHALLENGE: case L2TP_AVP_INI_RECV_LCP: case L2TP_AVP_LAST_SENT_LCP: case L2TP_AVP_LAST_RECV_LCP: case L2TP_AVP_PROXY_AUTH_CHAL: case L2TP_AVP_PROXY_AUTH_RESP: case L2TP_AVP_RANDOM_VECTOR: print_octets((u_char *)ptr, len-6); break; case L2TP_AVP_Q931_CC: l2tp_q931_cc_print((u_char *)ptr, len-6); break; case L2TP_AVP_CHALLENGE_RESP: print_octets((u_char *)ptr, 16); break; case L2TP_AVP_CALL_SER_NUM: case L2TP_AVP_MINIMUM_BPS: case L2TP_AVP_MAXIMUM_BPS: case L2TP_AVP_TX_CONN_SPEED: case L2TP_AVP_PHY_CHANNEL_ID: case L2TP_AVP_RX_CONN_SPEED: print_32bits_val((u_int32_t *)ptr); break; case L2TP_AVP_BEARER_TYPE: l2tp_bearer_type_print((u_char *)ptr); break; case L2TP_AVP_FRAMING_TYPE: l2tp_framing_type_print((u_char *)ptr); break; case L2TP_AVP_PACKET_PROC_DELAY: l2tp_packet_proc_delay_print(); break; case L2TP_AVP_PROXY_AUTH_TYPE: l2tp_proxy_auth_type_print((u_char *)ptr); break; case L2TP_AVP_PROXY_AUTH_ID: l2tp_proxy_auth_id_print((u_char *)ptr); break; case L2TP_AVP_CALL_ERRORS: l2tp_call_errors_print((u_char *)ptr); break; case L2TP_AVP_ACCM: l2tp_accm_print((u_char *)ptr); break; case L2TP_AVP_SEQ_REQUIRED: break; /* No Attribute Value */ case L2TP_AVP_PPP_DISCON_CC: l2tp_ppp_discon_cc_print((u_char *)ptr, len-6); break; default: break; } } printf(")"); } l2tp_avp_print(dat+len, length-len); return; trunc: printf("|..."); } void l2tp_print(const u_char *dat, u_int length) { const u_int16_t *ptr = (u_int16_t *)dat; u_int cnt = 0; /* total octets consumed */ u_int16_t pad; int flag_t, flag_l, flag_s, flag_o, flag_p; u_int16_t l2tp_len; flag_t = flag_l = flag_s = flag_o = flag_p = FALSE; TCHECK(*ptr); /* Flags & Version */ if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) { printf(" l2tp:"); } else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) { printf(" l2f:"); return; /* nothing to do */ } else { printf(" Unknown Version, neither L2F(1) nor L2TP(2)"); return; /* nothing we can do */ } printf("["); if (EXTRACT_16BITS(ptr) & L2TP_FLAG_TYPE) { flag_t = TRUE; printf("T"); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_LENGTH) { flag_l = TRUE; printf("L"); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_SEQUENCE) { flag_s = TRUE; printf("S"); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_OFFSET) { flag_o = TRUE; printf("O"); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY) { flag_p = TRUE; printf("P"); } printf("]"); ptr++; cnt += 2; if (flag_l) { TCHECK(*ptr); /* Length */ l2tp_len = EXTRACT_16BITS(ptr); ptr++; cnt += 2; } else { l2tp_len = 0; } TCHECK(*ptr); /* Tunnel ID */ printf("(%u/", EXTRACT_16BITS(ptr)); ptr++; cnt += 2; TCHECK(*ptr); /* Session ID */ printf("%u)", EXTRACT_16BITS(ptr)); ptr++; cnt += 2; if (flag_s) { TCHECK(*ptr); /* Ns */ printf("Ns=%u,", EXTRACT_16BITS(ptr)); ptr++; cnt += 2; TCHECK(*ptr); /* Nr */ printf("Nr=%u", EXTRACT_16BITS(ptr)); ptr++; cnt += 2; } if (flag_o) { TCHECK(*ptr); /* Offset Size */ pad = EXTRACT_16BITS(ptr); ptr++; ptr += pad / sizeof(*ptr); cnt += (2 + pad); } if (flag_t) { if (length - cnt == 0) { printf(" ZLB"); } else { l2tp_avp_print((u_char *)ptr, length - cnt); } } else { printf(" {"); ppp_print((u_char *)ptr, length - cnt); printf("}"); } return; trunc: printf("%s", tstr); } tcpdump-3.7.2/print-lane.c0100644000076500000240000000723007321133727014564 0ustar fennerstaff/* * Marko Kiiskila carnil@cs.tut.fi * * Tampere University of Technology - Telecommunications Laboratory * * Permission to use, copy, modify and distribute this * software and its documentation is hereby granted, * provided that both the copyright notice and this * permission notice appear in all copies of the software, * derivative works or modified versions, and any portions * thereof, that both notices appear in supporting * documentation, and that the use of this software is * acknowledged in any publications resulting from using * the software. * * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS * SOFTWARE. * */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.12 2001/07/05 18:54:15 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ether.h" #include "lane.h" static inline void lane_print(register const u_char *bp, int length) { register const struct lecdatahdr_8023 *ep; ep = (const struct lecdatahdr_8023 *)bp; if (qflag) (void)printf("lecid:%d %s %s %d: ", ntohs(ep->le_header), etheraddr_string(ep->h_source), etheraddr_string(ep->h_dest), length); else (void)printf("lecid:%d %s %s %s %d: ", ntohs(ep->le_header), etheraddr_string(ep->h_source), etheraddr_string(ep->h_dest), etherproto_string(ep->h_type), length); } /* * This is the top level routine of the printer. 'p' is the points * to the ether header of the packet, 'h->tv' is the timestamp, * 'h->length' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ void lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { int caplen = h->caplen; int length = h->len; struct lecdatahdr_8023 *ep; u_short ether_type; u_short extracted_ethertype; ++infodelay; ts_print(&h->ts); if (caplen < sizeof(struct lecdatahdr_8023)) { printf("[|lane]"); goto out; } if (eflag) lane_print(p, length); /* * Some printers want to get back at the ethernet addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; length -= sizeof(struct lecdatahdr_8023); caplen -= sizeof(struct lecdatahdr_8023); ep = (struct lecdatahdr_8023 *)p; p += sizeof(struct lecdatahdr_8023); ether_type = ntohs(ep->h_type); /* * Is it (gag) an 802.3 encapsulation? */ extracted_ethertype = 0; if (ether_type < ETHERMTU) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ep->h_source, ep->h_dest, &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) lane_print((u_char *)ep, length + sizeof(*ep)); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } if (!xflag && !qflag) default_print(p, caplen); } } else if (ether_encap_print(ether_type, p, length, caplen, &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) lane_print((u_char *)ep, length + sizeof(*ep)); if (!xflag && !qflag) default_print(p, caplen); } if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } tcpdump-3.7.2/print-lcp.c0100644000076500000240000001310207167251660014423 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-lcp.c,v 1.9 2000/10/06 04:23:12 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ #include "ppp.h" /* Codes */ enum { LCP_CONFREQ = 1, LCP_CONFACK = 2, LCP_CONFNAK = 3, LCP_CONFREJ = 4, LCP_TERMREQ = 5, LCP_TERMACK = 6, LCP_CODEREJ = 7, LCP_PROTREJ = 8, LCP_ECHOREQ = 9, LCP_ECHOREP = 10, LCP_DISCARD = 11 }; static struct tok lcpcode2str[] = { { LCP_CONFREQ, "ConfReq" }, { LCP_CONFACK, "ConfAck" }, { LCP_CONFNAK, "ConfNak" }, { LCP_CONFREJ, "ConfRej" }, { LCP_TERMREQ, "TermReq" }, { LCP_TERMACK, "TermAck" }, { LCP_CODEREJ, "CodeRej" }, { LCP_PROTREJ, "ProtRej" }, { LCP_ECHOREQ, "EchoReq" }, { LCP_ECHOREP, "EchoRep" }, { LCP_DISCARD, "Discard" }, { 0, NULL } }; enum { LCP_RESERVED = 0, LCP_MRU = 1, LCP_ASYNCMAP = 2, LCP_AUTHPROTO = 3, LCP_QUALPROTO = 4, LCP_MAGICNUM = 5, LCP_PCOMP = 7, LCP_ACFCOMP = 8, LCP_CALLBACK = 13 }; static struct tok lcpoption2str[] = { { LCP_RESERVED, "reserved"}, { LCP_MRU, "mru"}, { LCP_ASYNCMAP, "asyncmap"}, { LCP_AUTHPROTO, "auth"}, { LCP_QUALPROTO, "qual"}, { LCP_MAGICNUM, "magic"}, { LCP_PCOMP, "pcomp"}, { LCP_ACFCOMP, "acfcomp"}, { LCP_CALLBACK, "callback"}, { 0, NULL } }; static struct tok lcpauth2str[] = { {0xc023, "PAP"}, {0xc223, "CHAP"}, { 0, NULL } }; static struct tok lcpqual2str[] = { {0xc025, "LQR"}, { 0, NULL } }; static struct tok lcpchap2str[] = { {0x05, "MD5"}, {0x80, "MS"}, { 0, NULL } }; void lcp_print(register const u_char *bp, u_int length) { u_short lcp_code, lcp_id, lcp_length; const u_char *lcp_data; lcp_data = bp+4; if (snapend < lcp_data) { printf(" [LCP|]"); return; } lcp_code = bp[0]; lcp_id = bp[1]; lcp_length = EXTRACT_16BITS(bp+2); printf("LCP %s id=0x%x", tok2str(lcpcode2str, "LCP-#%d", lcp_code), lcp_id); switch (lcp_code) { case LCP_CONFREQ: case LCP_CONFACK: case LCP_CONFNAK: case LCP_CONFREJ: /* Print Options */ { u_char lcpopt_type, lcpopt_length; const u_char *p=lcp_data; while (p+2 < lcp_data+lcp_length && p+2 < snapend) { lcpopt_type = p[0]; lcpopt_length = p[1]; p+=2; printf(" <%s ",tok2str(lcpoption2str, "option-#%d", lcpopt_type)); if (lcpopt_length) switch (lcpopt_type) { case LCP_MRU: if (snapend < p+2) return; printf("%d",ntohs(*(u_short*)p)); if (lcpopt_length != 4) printf(" len=%d!",lcpopt_length); break; case LCP_AUTHPROTO: if (snapend < p+2) return; printf("%s",tok2str(lcpauth2str, "AUTH-%#x", ntohs(*(u_short*)p))); if (lcpopt_length < 4) printf(" len=%d!",lcpopt_length); if (lcpopt_length >= 5 && p < snapend) printf(" %s",tok2str(lcpchap2str, "%#x", p[0])); break; case LCP_QUALPROTO: if (snapend < p+2) return; printf("%s",tok2str(lcpqual2str, "QUAL-%#x", ntohs(*(u_short*)p))); if (lcpopt_length < 4) printf(" len=%d!",lcpopt_length); /* Print data field of auth? */ break; case LCP_ASYNCMAP: case LCP_MAGICNUM: if (snapend < p+4) return; printf("%#x", (unsigned)ntohl(*(u_long*)p)); if (lcpopt_length != 6) printf(" len=%d!",lcpopt_length); break; case LCP_PCOMP: case LCP_ACFCOMP: case LCP_RESERVED: if (lcpopt_length != 2) printf(" len=%d!",lcpopt_length); break; default: if (lcpopt_length != 2) printf(" len=%d",lcpopt_length); break; } printf(">"); p+=lcpopt_length-2; } } break; case LCP_ECHOREQ: case LCP_ECHOREP: case LCP_DISCARD: if (snapend < lcp_data+4) return; printf(" magic=%#x", (unsigned)ntohl(*(u_long *) lcp_data)); lcp_data +=4; break; case LCP_PROTREJ: if (snapend < lcp_data+2) return; printf(" prot=%s", tok2str(ppptype2str, "PROT-%#x", ntohs(*(u_short *) lcp_data))); /* TODO print rejected packet too ? */ break; case LCP_CODEREJ: if (snapend < lcp_data+4) return; printf(" "); lcp_print(lcp_data, (lcp_length+lcp_data > snapend ? snapend-lcp_data : lcp_length)); break; case LCP_TERMREQ: case LCP_TERMACK: break; default: break; } return; } tcpdump-3.7.2/print-llc.c0100644000076500000240000002032007360414702014410 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Code by Matt Thomas, Digital Equipment Corporation * with an awful lot of hacking by Jeffrey Mogul, DECWRL */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.43 2001/10/08 21:25:22 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ #include "llc.h" #include "ethertype.h" static struct tok cmd2str[] = { { LLC_UI, "ui" }, { LLC_TEST, "test" }, { LLC_XID, "xid" }, { LLC_UA, "ua" }, { LLC_DISC, "disc" }, { LLC_DM, "dm" }, { LLC_SABME, "sabme" }, { LLC_FRMR, "frmr" }, { 0, NULL } }; /* * Returns non-zero IFF it succeeds in printing the header */ int llc_print(const u_char *p, u_int length, u_int caplen, const u_char *esrc, const u_char *edst, u_short *extracted_ethertype) { struct llc llc; register u_short et; u_int16_t control; register int ret; if (caplen < 3) { (void)printf("[|llc]"); default_print((u_char *)p, caplen); return(0); } /* Watch out for possible alignment problems */ memcpy((char *)&llc, (char *)p, min(caplen, sizeof(llc))); if (llc.ssap == LLCSAP_GLOBAL && llc.dsap == LLCSAP_GLOBAL) { /* * This is an Ethernet_802.3 IPX frame; it has an * 802.3 header (i.e., an Ethernet header where the * type/length field is <= ETHERMTU, i.e. it's a length * field, not a type field), but has no 802.2 header - * the IPX packet starts right after the Ethernet header, * with a signature of two bytes of 0xFF (which is * LLCSAP_GLOBAL). * * (It might also have been an Ethernet_802.3 IPX at * one time, but got bridged onto another network, * such as an 802.11 network; this has appeared in at * least one capture file.) */ ipx_print(p, length); return (1); } if (llc.ssap == LLCSAP_8021D && llc.dsap == LLCSAP_8021D) { stp_print(p, length); return (1); } if (llc.ssap == LLCSAP_IPX && llc.dsap == LLCSAP_IPX && llc.llcui == LLC_UI) { /* * This is an Ethernet_802.2 IPX frame, with an 802.3 * header and an 802.2 LLC header with the source and * destination SAPs being the IPX SAP. * * Skip DSAP, LSAP, and control field. */ p += 3; length -= 3; caplen -= 3; ipx_print(p, length); return (1); } #ifdef TCPDUMP_DO_SMB if (llc.ssap == LLCSAP_NETBEUI && llc.dsap == LLCSAP_NETBEUI && (!(llc.llcu & LLC_S_FMT) || llc.llcu == LLC_U_FMT)) { /* * we don't actually have a full netbeui parser yet, but the * smb parser can handle many smb-in-netbeui packets, which * is very useful, so we call that * * We don't call it for S frames, however, just I frames * (which are frames that don't have the low-order bit, * LLC_S_FMT, set in the first byte of the control field) * and UI frames (whose control field is just 3, LLC_U_FMT). */ /* * Skip the DSAP and LSAP. */ p += 2; length -= 2; caplen -= 2; /* * OK, what type of LLC frame is this? The length * of the control field depends on that - I frames * have a two-byte control field, and U frames have * a one-byte control field. */ if (llc.llcu == LLC_U_FMT) { control = llc.llcu; p += 1; length -= 1; caplen -= 1; } else { /* * The control field in I and S frames is * little-endian. */ control = EXTRACT_LE_16BITS(&llc.llcu); p += 2; length -= 2; caplen -= 2; } netbeui_print(control, p, length); return (1); } #endif if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS && llc.llcui == LLC_UI) { isoclns_print(p + 3, length - 3, caplen - 3, esrc, edst); return (1); } if (llc.ssap == LLCSAP_SNAP && llc.dsap == LLCSAP_SNAP && llc.llcui == LLC_UI) { u_int32_t orgcode; if (caplen < sizeof(llc)) { (void)printf("[|llc-snap]"); default_print((u_char *)p, caplen); return (0); } if (vflag) (void)printf("snap %s ", protoid_string(llc.llcpi)); caplen -= sizeof(llc); length -= sizeof(llc); p += sizeof(llc); orgcode = EXTRACT_24BITS(&llc.llc_orgcode[0]); et = EXTRACT_16BITS(&llc.llc_ethertype[0]); switch (orgcode) { case OUI_ENCAP_ETHER: case OUI_CISCO_90: /* * This is an encapsulated Ethernet packet, * or a packet bridged by some piece of * Cisco hardware; the protocol ID is * an Ethernet protocol type. */ ret = ether_encap_print(et, p, length, caplen, extracted_ethertype); if (ret) return (ret); break; case OUI_APPLETALK: if (et == ETHERTYPE_ATALK) { /* * No, I have no idea why Apple used one * of their own OUIs, rather than * 0x000000, and an Ethernet packet * type, for Appletalk data packets, * but used 0x000000 and an Ethernet * packet type for AARP packets. */ ret = ether_encap_print(et, p, length, caplen, extracted_ethertype); if (ret) return (ret); } break; case OUI_CISCO: if (et == ETHERTYPE_CISCO_CDP) { cdp_print(p, length, caplen, esrc, edst); return 1; } break; } } if ((llc.ssap & ~LLC_GSAP) == llc.dsap) { if (eflag || esrc == NULL || edst == NULL) (void)printf("%s ", llcsap_string(llc.dsap)); else (void)printf("%s > %s %s ", etheraddr_string(esrc), etheraddr_string(edst), llcsap_string(llc.dsap)); } else { if (eflag || esrc == NULL || edst == NULL) (void)printf("%s > %s ", llcsap_string(llc.ssap & ~LLC_GSAP), llcsap_string(llc.dsap)); else (void)printf("%s %s > %s %s ", etheraddr_string(esrc), llcsap_string(llc.ssap & ~LLC_GSAP), etheraddr_string(edst), llcsap_string(llc.dsap)); } if ((llc.llcu & LLC_U_FMT) == LLC_U_FMT) { u_int16_t cmd; const char *m; char f; cmd = LLC_U_CMD(llc.llcu); m = tok2str(cmd2str, "%02x", cmd); switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) { case 0: f = 'C'; break; case LLC_GSAP: f = 'R'; break; case LLC_U_POLL: f = 'P'; break; case LLC_GSAP|LLC_U_POLL: f = 'F'; break; default: f = '?'; break; } printf("%s/%c", m, f); p += 3; length -= 3; caplen -= 3; if ((llc.llcu & ~LLC_U_POLL) == LLC_XID) { if (*p == LLC_XID_FI) { printf(": %02x %02x", p[1], p[2]); p += 3; length -= 3; caplen -= 3; } } } else { char f; /* * The control field in I and S frames is little-endian. */ control = EXTRACT_LE_16BITS(&llc.llcu); switch ((llc.ssap & LLC_GSAP) | (control & LLC_IS_POLL)) { case 0: f = 'C'; break; case LLC_GSAP: f = 'R'; break; case LLC_IS_POLL: f = 'P'; break; case LLC_GSAP|LLC_IS_POLL: f = 'F'; break; default: f = '?'; break; } if ((control & LLC_S_FMT) == LLC_S_FMT) { static char *llc_s[] = { "rr", "rej", "rnr", "03" }; (void)printf("%s (r=%d,%c)", llc_s[LLC_S_CMD(control)], LLC_IS_NR(control), f); } else { (void)printf("I (s=%d,r=%d,%c)", LLC_I_NS(control), LLC_IS_NR(control), f); } p += 4; length -= 4; caplen -= 4; } (void)printf(" len=%d", length); return(1); } tcpdump-3.7.2/print-lwres.c0100644000076500000240000003247507316024531015006 0ustar fennerstaff/* * Copyright (C) 2001 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.5 2001/06/26 06:19:05 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "nameser.h" #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ /* BIND9 lib/lwres/include/lwres */ typedef u_int32_t lwres_uint32_t; typedef u_int16_t lwres_uint16_t; typedef u_int8_t lwres_uint8_t; struct lwres_lwpacket { lwres_uint32_t length; lwres_uint16_t version; lwres_uint16_t pktflags; lwres_uint32_t serial; lwres_uint32_t opcode; lwres_uint32_t result; lwres_uint32_t recvlength; lwres_uint16_t authtype; lwres_uint16_t authlength; }; #define LWRES_LWPACKETFLAG_RESPONSE 0x0001U /* if set, pkt is a response */ #define LWRES_LWPACKETVERSION_0 0 #define LWRES_FLAG_TRUSTNOTREQUIRED 0x00000001U #define LWRES_FLAG_SECUREDATA 0x00000002U /* * no-op */ #define LWRES_OPCODE_NOOP 0x00000000U typedef struct { /* public */ lwres_uint16_t datalength; /* data follows */ } lwres_nooprequest_t; typedef struct { /* public */ lwres_uint16_t datalength; /* data follows */ } lwres_noopresponse_t; /* * get addresses by name */ #define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U typedef struct lwres_addr lwres_addr_t; struct lwres_addr { lwres_uint32_t family; lwres_uint16_t length; /* address folows */ }; typedef struct { /* public */ lwres_uint32_t flags; lwres_uint32_t addrtypes; lwres_uint16_t namelen; /* name follows */ } lwres_gabnrequest_t; typedef struct { /* public */ lwres_uint32_t flags; lwres_uint16_t naliases; lwres_uint16_t naddrs; lwres_uint16_t realnamelen; /* aliases follows */ /* addrs follows */ /* realname follows */ } lwres_gabnresponse_t; /* * get name by address */ #define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U typedef struct { /* public */ lwres_uint32_t flags; lwres_addr_t addr; /* addr body follows */ } lwres_gnbarequest_t; typedef struct { /* public */ lwres_uint32_t flags; lwres_uint16_t naliases; lwres_uint16_t realnamelen; /* aliases follows */ /* realname follows */ } lwres_gnbaresponse_t; /* * get rdata by name */ #define LWRES_OPCODE_GETRDATABYNAME 0x00010003U typedef struct { /* public */ lwres_uint32_t flags; lwres_uint16_t rdclass; lwres_uint16_t rdtype; lwres_uint16_t namelen; /* name follows */ } lwres_grbnrequest_t; typedef struct { /* public */ lwres_uint32_t flags; lwres_uint16_t rdclass; lwres_uint16_t rdtype; lwres_uint32_t ttl; lwres_uint16_t nrdatas; lwres_uint16_t nsigs; /* realname here (len + name) */ /* rdata here (len + name) */ /* signatures here (len + name) */ } lwres_grbnresponse_t; #define LWRDATA_VALIDATED 0x00000001 #define LWRES_ADDRTYPE_V4 0x00000001U /* ipv4 */ #define LWRES_ADDRTYPE_V6 0x00000002U /* ipv6 */ #define LWRES_MAX_ALIASES 16 /* max # of aliases */ #define LWRES_MAX_ADDRS 64 /* max # of addrs */ struct tok opcode[] = { { LWRES_OPCODE_NOOP, "noop", }, { LWRES_OPCODE_GETADDRSBYNAME, "getaddrsbyname", }, { LWRES_OPCODE_GETNAMEBYADDR, "getnamebyaddr", }, { LWRES_OPCODE_GETRDATABYNAME, "getrdatabyname", }, { 0, NULL, }, }; /* print-domain.c */ extern struct tok ns_type2str[]; extern struct tok ns_class2str[]; static int lwres_printname(size_t, const char *); static int lwres_printnamelen(const char *); static int lwres_printbinlen(const char *); static int lwres_printaddr(lwres_addr_t *); static int lwres_printname(size_t l, const char *p0) { const char *p; int i; p = p0; /* + 1 for terminating \0 */ if (p + l + 1 > (const char *)snapend) goto trunc; printf(" "); for (i = 0; i < l; i++) safeputchar(*p++); p++; /* skip terminating \0 */ return p - p0; trunc: return -1; } static int lwres_printnamelen(const char *p) { u_int16_t l; int advance; if (p + 2 > (const char *)snapend) goto trunc; l = EXTRACT_16BITS(p); advance = lwres_printname(l, p + 2); if (advance < 0) goto trunc; return 2 + advance; trunc: return -1; } static int lwres_printbinlen(const char *p0) { const char *p; u_int16_t l; int i; p = p0; if (p + 2 > (const char *)snapend) goto trunc; l = EXTRACT_16BITS(p); if (p + 2 + l > (const char *)snapend) goto trunc; p += 2; for (i = 0; i < l; i++) printf("%02x", *p++); return p - p0; trunc: return -1; } static int lwres_printaddr(lwres_addr_t *ap) { u_int16_t l; const char *p; int i; TCHECK(ap->length); l = ntohs(ap->length); /* XXX ap points to packed struct */ p = (const char *)&ap->length + sizeof(ap->length); if (p + l > (const char *)snapend) goto trunc; switch (ntohl(ap->family)) { case 1: /* IPv4 */ printf(" %s", ipaddr_string(p)); p += sizeof(struct in_addr); break; #ifdef INET6 case 2: /* IPv6 */ printf(" %s", ip6addr_string(p)); p += sizeof(struct in6_addr); break; #endif default: printf(" %lu/", (unsigned long)ntohl(ap->family)); for (i = 0; i < l; i++) printf("%02x", *p++); } return p - (const char *)ap; trunc: return -1; } void lwres_print(register const u_char *bp, u_int length) { const struct lwres_lwpacket *np; u_int32_t v; const char *s; int response; int advance; int unsupported = 0; np = (const struct lwres_lwpacket *)bp; TCHECK(np->authlength); printf(" lwres"); v = ntohs(np->version); if (vflag || v != LWRES_LWPACKETVERSION_0) printf(" v%u", v); if (v != LWRES_LWPACKETVERSION_0) { s = (const char *)np + ntohl(np->length); goto tail; } response = ntohs(np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE; /* opcode and pktflags */ v = (u_int32_t)ntohl(np->opcode); s = tok2str(opcode, "#0x%x", v); printf(" %s%s", s, response ? "" : "?"); /* pktflags */ v = ntohs(np->pktflags); if (v & ~LWRES_LWPACKETFLAG_RESPONSE) printf("[0x%x]", v); if (vflag > 1) { printf(" ("); /*)*/ printf("serial:0x%lx", (unsigned long)ntohl(np->serial)); printf(" result:0x%lx", (unsigned long)ntohl(np->result)); printf(" recvlen:%lu", (unsigned long)ntohl(np->recvlength)); /* BIND910: not used */ if (vflag > 2) { printf(" authtype:0x%x", ntohs(np->authtype)); printf(" authlen:%u", ntohs(np->authlength)); } /*(*/ printf(")"); } /* per-opcode content */ if (!response) { /* * queries */ lwres_gabnrequest_t *gabn; lwres_gnbarequest_t *gnba; lwres_grbnrequest_t *grbn; u_int32_t l; gabn = NULL; gnba = NULL; grbn = NULL; switch (ntohl(np->opcode)) { case LWRES_OPCODE_NOOP: break; case LWRES_OPCODE_GETADDRSBYNAME: gabn = (lwres_gabnrequest_t *)(np + 1); TCHECK(gabn->namelen); /* XXX gabn points to packed struct */ s = (const char *)&gabn->namelen + sizeof(gabn->namelen); l = ntohs(gabn->namelen); /* BIND910: not used */ if (vflag > 2) { printf(" flags:0x%lx", (unsigned long)ntohl(gabn->flags)); } v = (u_int32_t)ntohl(gabn->addrtypes); switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) { case LWRES_ADDRTYPE_V4: printf(" IPv4"); break; case LWRES_ADDRTYPE_V6: printf(" IPv6"); break; case LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6: printf(" IPv4/6"); break; } if (v & ~(LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) printf("[0x%x]", v); advance = lwres_printname(l, s); if (advance < 0) goto trunc; s += advance; break; case LWRES_OPCODE_GETNAMEBYADDR: gnba = (lwres_gnbarequest_t *)(np + 1); TCHECK(gnba->addr); /* BIND910: not used */ if (vflag > 2) { printf(" flags:0x%lx", (unsigned long)ntohl(gnba->flags)); } s = (const char *)&gnba->addr; advance = lwres_printaddr(&gnba->addr); if (advance < 0) goto trunc; s += advance; break; case LWRES_OPCODE_GETRDATABYNAME: /* XXX no trace, not tested */ grbn = (lwres_grbnrequest_t *)(np + 1); TCHECK(grbn->namelen); /* BIND910: not used */ if (vflag > 2) { printf(" flags:0x%lx", (unsigned long)ntohl(grbn->flags)); } printf(" %s", tok2str(ns_type2str, "Type%d", ntohs(grbn->rdtype))); if (ntohs(grbn->rdclass) != C_IN); printf(" %s", tok2str(ns_class2str, "Class%d", ntohs(grbn->rdclass))); /* XXX grbn points to packed struct */ s = (const char *)&grbn->namelen + sizeof(grbn->namelen); l = ntohs(gabn->namelen); advance = lwres_printname(l, s); if (advance < 0) goto trunc; s += advance; break; default: unsupported++; break; } } else { /* * responses */ lwres_gabnresponse_t *gabn; lwres_gnbaresponse_t *gnba; lwres_grbnresponse_t *grbn; u_int32_t l, na; int i; gabn = NULL; gnba = NULL; grbn = NULL; switch (ntohl(np->opcode)) { case LWRES_OPCODE_NOOP: break; case LWRES_OPCODE_GETADDRSBYNAME: gabn = (lwres_gabnresponse_t *)(np + 1); TCHECK(gabn->realnamelen); /* XXX gabn points to packed struct */ s = (const char *)&gabn->realnamelen + sizeof(gabn->realnamelen); l = ntohs(gabn->realnamelen); /* BIND910: not used */ if (vflag > 2) { printf(" flags:0x%lx", (unsigned long)ntohl(gabn->flags)); } printf(" %u/%u", ntohs(gabn->naliases), ntohs(gabn->naddrs)); advance = lwres_printname(l, s); if (advance < 0) goto trunc; s += advance; /* aliases */ na = ntohs(gabn->naliases); for (i = 0; i < na; i++) { advance = lwres_printnamelen(s); if (advance < 0) goto trunc; s += advance; } /* addrs */ na = ntohs(gabn->naddrs); for (i = 0; i < na; i++) { advance = lwres_printaddr((lwres_addr_t *)s); if (advance < 0) goto trunc; s += advance; } break; case LWRES_OPCODE_GETNAMEBYADDR: gnba = (lwres_gnbaresponse_t *)(np + 1); TCHECK(gnba->realnamelen); /* XXX gnba points to packed struct */ s = (const char *)&gnba->realnamelen + sizeof(gnba->realnamelen); l = ntohs(gnba->realnamelen); /* BIND910: not used */ if (vflag > 2) { printf(" flags:0x%lx", (unsigned long)ntohl(gnba->flags)); } printf(" %u", ntohs(gnba->naliases)); advance = lwres_printname(l, s); if (advance < 0) goto trunc; s += advance; /* aliases */ na = ntohs(gnba->naliases); for (i = 0; i < na; i++) { advance = lwres_printnamelen(s); if (advance < 0) goto trunc; s += advance; } break; case LWRES_OPCODE_GETRDATABYNAME: /* XXX no trace, not tested */ grbn = (lwres_grbnresponse_t *)(np + 1); TCHECK(grbn->nsigs); /* BIND910: not used */ if (vflag > 2) { printf(" flags:0x%lx", (unsigned long)ntohl(grbn->flags)); } printf(" %s", tok2str(ns_type2str, "Type%d", ntohs(grbn->rdtype))); if (ntohs(grbn->rdclass) != C_IN); printf(" %s", tok2str(ns_class2str, "Class%d", ntohs(grbn->rdclass))); printf(" TTL "); relts_print(ntohl(grbn->ttl)); printf(" %u/%u", ntohs(grbn->nrdatas), ntohs(grbn->nsigs)); /* XXX grbn points to packed struct */ s = (const char *)&grbn->nsigs+ sizeof(grbn->nsigs); advance = lwres_printnamelen(s); if (advance < 0) goto trunc; s += advance; /* rdatas */ na = ntohs(grbn->nrdatas); for (i = 0; i < na; i++) { /* XXX should decode resource data */ advance = lwres_printbinlen(s); if (advance < 0) goto trunc; s += advance; } /* sigs */ na = ntohs(grbn->nsigs); for (i = 0; i < na; i++) { /* XXX how should we print it? */ advance = lwres_printbinlen(s); if (advance < 0) goto trunc; s += advance; } break; default: unsupported++; break; } } tail: /* length mismatch */ if (ntohl(np->length) != length) { printf(" [len: %lu != %u]", (unsigned long)ntohl(np->length), length); } if (!unsupported && s < (const char *)np + ntohl(np->length)) printf("[extra]"); return; trunc: printf("[|lwres]"); return; } tcpdump-3.7.2/print-mobile.c0100644000076500000240000000663407627054630015127 0ustar fennerstaff/* $NetBSD: print-mobile.c,v 1.2 1998/09/30 08:57:01 hwr Exp $ */ /* * (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Heiko W.Rupp * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.7.4.1 2002/06/01 23:51:14 guy Exp $"; #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ #define MOBILE_SIZE (8) struct mobile_ip { u_int16_t proto; u_int16_t hcheck; u_int32_t odst; u_int32_t osrc; }; #define OSRC_PRES 0x0080 /* old source is present */ /* * Deencapsulate and print a mobile-tunneled IP datagram */ void mobile_print(const u_char *bp, u_int length) { const u_char *cp = bp +8 ; const struct mobile_ip *mob; u_short proto,crc; u_char osp =0; /* old source address present */ mob = (const struct mobile_ip *)bp; if (length < MOBILE_SIZE) { fputs("[|mobile]", stdout); return; } fputs("mobile: ", stdout); proto = EXTRACT_16BITS(&mob->proto); crc = EXTRACT_16BITS(&mob->hcheck); if (proto & OSRC_PRES) { osp=1; cp +=4 ; } if (osp) { fputs("[S] ",stdout); if (vflag) (void)printf("%s ",ipaddr_string(&mob->osrc)); } else { fputs("[] ",stdout); } if (vflag) { (void)printf("> %s ",ipaddr_string(&mob->odst)); (void)printf("(oproto=%d)",proto>>8); } if (in_cksum((u_short *)mob, osp ? 12 : 8, 0)!=0) { (void)printf(" (bad checksum %d)",crc); } return; } tcpdump-3.7.2/print-mpls.c0100644000076500000240000000715707627054630014634 0ustar fennerstaff/* * Copyright (C) 2001 WIDE Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.2.4.1 2002/05/07 18:36:28 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include "addrtoname.h" #include "interface.h" #include "extract.h" /* must come after interface.h */ #define LABEL_MASK 0xfffff000 #define LABEL_SHIFT 12 #define EXP_MASK 0x00000e00 #define EXP_SHIFT 9 #define STACK_MASK 0x00000100 #define STACK_SHIFT 8 #define TTL_MASK 0x000000ff #define TTL_SHIFT 0 #define MPLS_LABEL(x) (((x) & LABEL_MASK) >> LABEL_SHIFT) #define MPLS_EXP(x) (((x) & EXP_MASK) >> EXP_SHIFT) #define MPLS_STACK(x) (((x) & STACK_MASK) >> STACK_SHIFT) #define MPLS_TTL(x) (((x) & TTL_MASK) >> TTL_SHIFT) static const char *mpls_labelname[] = { /*0*/ "IPv4 explicit NULL", "router alert", "IPv6 explicit NULL", "implicit NULL", "rsvd", /*5*/ "rsvd", "rsvd", "rsvd", "rsvd", "rsvd", /*10*/ "rsvd", "rsvd", "rsvd", "rsvd", "rsvd", /*15*/ "rsvd", }; /* * RFC3032: MPLS label stack encoding */ void mpls_print(const u_char *bp, u_int length) { const u_char *p; u_int32_t v; p = bp; printf("MPLS"); do { TCHECK2(*p, sizeof(v)); v = EXTRACT_32BITS(p); printf(" ("); /*)*/ printf("label 0x%x", MPLS_LABEL(v)); if (vflag && MPLS_LABEL(v) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0])) printf("(%s)", mpls_labelname[MPLS_LABEL(v)]); if (MPLS_EXP(v)) printf(" exp 0x%x", MPLS_EXP(v)); if (MPLS_STACK(v)) printf("[S]"); printf(" TTL %u", MPLS_TTL(v)); /*(*/ printf(")"); p += sizeof(v); } while (!MPLS_STACK(v)); switch (MPLS_LABEL(v)) { case 0: /* IPv4 explicit NULL label */ ip_print(p, length - (p - bp)); break; #ifdef INET6 case 2: /* IPv6 explicit NULL label */ ip6_print(p, length - (p - bp)); break; #endif default: /* * Since there's no indication of protocol in MPLS label * encoding, we can print nothing further. */ return; } trunc: printf("[|MPLS]"); } tcpdump-3.7.2/print-msdp.c0100644000076500000240000000517207405066420014611 0ustar fennerstaff/* * Copyright (c) 2001 William C. Fenner. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code * distributions retain the above copyright notice and this paragraph * in its entirety, and (2) distributions including binary code include * the above copyright notice and this paragraph in its entirety in * the documentation or other materials provided with the distribution. * The name of William C. Fenner may not be used to endorse or * promote products derived from this software without specific prior * written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.2 2001/12/10 08:06:40 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" #define MSDP_TYPE_MAX 7 void msdp_print(const unsigned char *sp, u_int length) { unsigned int type, len; TCHECK2(*sp, 3); /* See if we think we're at the beginning of a compound packet */ type = *sp; len = EXTRACT_16BITS(sp + 1); if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX) goto trunc; /* not really truncated, but still not decodable */ (void)printf(" msdp:"); while (length > 0) { TCHECK2(*sp, 3); type = *sp; len = EXTRACT_16BITS(sp + 1); if (len > 1400 || vflag) printf(" [len %d]", len); if (len < 3) goto trunc; sp += 3; length -= 3; switch (type) { case 1: /* IPv4 Source-Active */ case 3: /* IPv4 Source-Active Response */ if (type == 1) (void)printf(" SA"); else (void)printf(" SA-Response"); TCHECK(*sp); (void)printf(" %d entries", *sp); if (*sp * 12 + 8 < len) { (void)printf(" [w/data]"); if (vflag > 1) { (void)printf(" "); ip_print(sp + *sp * 12 + 8 - 3, len - (*sp * 12 + 8)); } } break; case 2: (void)printf(" SA-Request"); TCHECK2(*sp, 5); (void)printf(" for %s", ipaddr_string(sp + 1)); break; case 4: (void)printf(" Keepalive"); if (len != 3) (void)printf("[len=%d] ", len); break; case 5: (void)printf(" Notification"); break; default: (void)printf(" [type=%d len=%d]", type, len); break; } sp += (len - 3); length -= (len - 3); } return; trunc: (void)printf(" [|msdp]"); } tcpdump-3.7.2/print-netbios.c0100644000076500000240000000505307165020603015303 0ustar fennerstaff/* * Copyright (c) 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Format and print NETBIOS packets. * Contributed by Brad Parker (brad@fcr.com). */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.17 2000/09/29 04:58:43 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "netbios.h" #include "extract.h" /* * Print NETBIOS packets. */ void netbios_print(struct p8022Hdr *nb, u_int length) { if (length < p8022Size) { (void)printf(" truncated-netbios %d", length); return; } if (nb->flags == UI) { (void)printf("802.1 UI "); } else { (void)printf("802.1 CONN "); } if ((u_char *)(nb + 1) > snapend) { printf(" [|netbios]"); return; } /* netbios_decode(nb, (u_char *)nb + p8022Size, length - p8022Size); */ } #ifdef never (void)printf("%s.%d > ", ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode), EXTRACT_16BITS(ipx->srcSkt)); (void)printf("%s.%d:", ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode), EXTRACT_16BITS(ipx->dstSkt)); if ((u_char *)(ipx + 1) > snapend) { printf(" [|ipx]"); return; } /* take length from ipx header */ length = EXTRACT_16BITS(&ipx->length); ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize); #endif tcpdump-3.7.2/print-nfs.c0100644000076500000240000011512007627054631014436 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.89.4.2 2002/06/01 23:51:14 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "nfs.h" #include "nfsfh.h" #include "ip.h" #ifdef INET6 #include "ip6.h" #endif static void nfs_printfh(const u_int32_t *, const u_int); static void xid_map_enter(const struct rpc_msg *, const u_char *); static int32_t xid_map_find(const struct rpc_msg *, const u_char *, u_int32_t *, u_int32_t *); static void interp_reply(const struct rpc_msg *, u_int32_t, u_int32_t, int); static const u_int32_t *parse_post_op_attr(const u_int32_t *, int); static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose); static int print_int64(const u_int32_t *dp, int how); static void print_nfsaddr(const u_char *, const char *, const char *); /* * Mapping of old NFS Version 2 RPC numbers to generic numbers. */ u_int32_t nfsv3_procid[NFS_NPROCS] = { NFSPROC_NULL, NFSPROC_GETATTR, NFSPROC_SETATTR, NFSPROC_NOOP, NFSPROC_LOOKUP, NFSPROC_READLINK, NFSPROC_READ, NFSPROC_NOOP, NFSPROC_WRITE, NFSPROC_CREATE, NFSPROC_REMOVE, NFSPROC_RENAME, NFSPROC_LINK, NFSPROC_SYMLINK, NFSPROC_MKDIR, NFSPROC_RMDIR, NFSPROC_READDIR, NFSPROC_FSSTAT, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP }; /* * NFS V2 and V3 status values. * * Some of these come from the RFCs for NFS V2 and V3, with the message * strings taken from the FreeBSD C library "errlst.c". * * Others are errors that are not in the RFC but that I suspect some * NFS servers could return; the values are FreeBSD errno values, as * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS * was primarily BSD-derived. */ static struct tok status2str[] = { { 1, "Operation not permitted" }, /* EPERM */ { 2, "No such file or directory" }, /* ENOENT */ { 5, "Input/output error" }, /* EIO */ { 6, "Device not configured" }, /* ENXIO */ { 11, "Resource deadlock avoided" }, /* EDEADLK */ { 12, "Cannot allocate memory" }, /* ENOMEM */ { 13, "Permission denied" }, /* EACCES */ { 17, "File exists" }, /* EEXIST */ { 18, "Cross-device link" }, /* EXDEV */ { 19, "Operation not supported by device" }, /* ENODEV */ { 20, "Not a directory" }, /* ENOTDIR */ { 21, "Is a directory" }, /* EISDIR */ { 22, "Invalid argument" }, /* EINVAL */ { 26, "Text file busy" }, /* ETXTBSY */ { 27, "File too large" }, /* EFBIG */ { 28, "No space left on device" }, /* ENOSPC */ { 30, "Read-only file system" }, /* EROFS */ { 31, "Too many links" }, /* EMLINK */ { 45, "Operation not supported" }, /* EOPNOTSUPP */ { 62, "Too many levels of symbolic links" }, /* ELOOP */ { 63, "File name too long" }, /* ENAMETOOLONG */ { 66, "Directory not empty" }, /* ENOTEMPTY */ { 69, "Disc quota exceeded" }, /* EDQUOT */ { 70, "Stale NFS file handle" }, /* ESTALE */ { 71, "Too many levels of remote in path" }, /* EREMOTE */ { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */ { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */ { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */ { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */ { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */ { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */ { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */ { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */ { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */ { 0, NULL } }; static struct tok nfsv3_writemodes[] = { { 0, "unstable" }, { 1, "datasync" }, { 2, "filesync" }, { 0, NULL } }; static struct tok type2str[] = { { NFNON, "NON" }, { NFREG, "REG" }, { NFDIR, "DIR" }, { NFBLK, "BLK" }, { NFCHR, "CHR" }, { NFLNK, "LNK" }, { NFFIFO, "FIFO" }, { 0, NULL } }; /* * Print out a 64-bit integer. This appears to be different on each system, * try to make the best of it. The integer stored as 2 consecutive XDR * encoded 32-bit integers, to which a pointer is passed. * * Assume that a system that has INT64_FORMAT defined, has a 64-bit * integer datatype and can print it. */ #define UNSIGNED 0 #define SIGNED 1 #define HEX 2 static int print_int64(const u_int32_t *dp, int how) { #ifdef INT64_FORMAT u_int64_t res; res = ((u_int64_t)ntohl(dp[0]) << 32) | (u_int64_t)ntohl(dp[1]); switch (how) { case SIGNED: printf(INT64_FORMAT, res); break; case UNSIGNED: printf(U_INT64_FORMAT, res); break; case HEX: printf(HEX_INT64_FORMAT, res); break; default: return (0); } #else switch (how) { case SIGNED: case UNSIGNED: case HEX: printf("0x%x%08x", (u_int32_t)ntohl(dp[0]), (u_int32_t)ntohl(dp[1])); break; default: return (0); } #endif return 1; } static void print_nfsaddr(const u_char *bp, const char *s, const char *d) { struct ip *ip; #ifdef INET6 struct ip6_hdr *ip6; char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN]; #else #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN 16 #endif char srcaddr[INET_ADDRSTRLEN], dstaddr[INET_ADDRSTRLEN]; #endif srcaddr[0] = dstaddr[0] = '\0'; switch (IP_V((struct ip *)bp)) { case 4: ip = (struct ip *)bp; strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr)); strlcpy(dstaddr, ipaddr_string(&ip->ip_dst), sizeof(dstaddr)); break; #ifdef INET6 case 6: ip6 = (struct ip6_hdr *)bp; strlcpy(srcaddr, ip6addr_string(&ip6->ip6_src), sizeof(srcaddr)); strlcpy(dstaddr, ip6addr_string(&ip6->ip6_dst), sizeof(dstaddr)); break; #endif default: strlcpy(srcaddr, "?", sizeof(srcaddr)); strlcpy(dstaddr, "?", sizeof(dstaddr)); break; } (void)printf("%s.%s > %s.%s: ", srcaddr, s, dstaddr, d); } static const u_int32_t * parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3) { TCHECK(dp[0]); if ((sa3->sa_modeset = ntohl(*dp++))) { TCHECK(dp[0]); sa3->sa_mode = ntohl(*dp++); } TCHECK(dp[0]); if ((sa3->sa_uidset = ntohl(*dp++))) { TCHECK(dp[0]); sa3->sa_uid = ntohl(*dp++); } TCHECK(dp[0]); if ((sa3->sa_gidset = ntohl(*dp++))) { TCHECK(dp[0]); sa3->sa_gid = ntohl(*dp++); } TCHECK(dp[0]); if ((sa3->sa_sizeset = ntohl(*dp++))) { TCHECK(dp[0]); sa3->sa_size = ntohl(*dp++); } TCHECK(dp[0]); if ((sa3->sa_atimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) { TCHECK(dp[1]); sa3->sa_atime.nfsv3_sec = ntohl(*dp++); sa3->sa_atime.nfsv3_nsec = ntohl(*dp++); } TCHECK(dp[0]); if ((sa3->sa_mtimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) { TCHECK(dp[1]); sa3->sa_mtime.nfsv3_sec = ntohl(*dp++); sa3->sa_mtime.nfsv3_nsec = ntohl(*dp++); } return dp; trunc: return NULL; } static int nfserr; /* true if we error rather than trunc */ static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose) { if (sa3->sa_modeset) printf(" mode %o", sa3->sa_mode); if (sa3->sa_uidset) printf(" uid %u", sa3->sa_uid); if (sa3->sa_gidset) printf(" gid %u", sa3->sa_gid); if (verbose > 1) { if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT) printf(" atime %u.%06u", sa3->sa_atime.nfsv3_sec, sa3->sa_atime.nfsv3_nsec); if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT) printf(" mtime %u.%06u", sa3->sa_mtime.nfsv3_sec, sa3->sa_mtime.nfsv3_nsec); } } void nfsreply_print(register const u_char *bp, u_int length, register const u_char *bp2) { register const struct rpc_msg *rp; u_int32_t proc, vers; char srcid[20], dstid[20]; /*fits 32bit*/ nfserr = 0; /* assume no error */ rp = (const struct rpc_msg *)bp; if (!nflag) { strlcpy(srcid, "nfs", sizeof(srcid)); snprintf(dstid, sizeof(dstid), "%u", (u_int32_t)ntohl(rp->rm_xid)); } else { snprintf(srcid, sizeof(srcid), "%u", NFS_PORT); snprintf(dstid, sizeof(dstid), "%u", (u_int32_t)ntohl(rp->rm_xid)); } print_nfsaddr(bp2, srcid, dstid); (void)printf("reply %s %d", ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED? "ok":"ERR", length); if (xid_map_find(rp, bp2, &proc, &vers) >= 0) interp_reply(rp, proc, vers, length); } /* * Return a pointer to the first file handle in the packet. * If the packet was truncated, return 0. */ static const u_int32_t * parsereq(register const struct rpc_msg *rp, register u_int length) { register const u_int32_t *dp; register u_int len; /* * find the start of the req data (if we captured it) */ dp = (u_int32_t *)&rp->rm_call.cb_cred; TCHECK(dp[1]); len = ntohl(dp[1]); if (len < length) { dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp); TCHECK(dp[1]); len = ntohl(dp[1]); if (len < length) { dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp); TCHECK2(dp[0], 0); return (dp); } } trunc: return (NULL); } /* * Print out an NFS file handle and return a pointer to following word. * If packet was truncated, return 0. */ static const u_int32_t * parsefh(register const u_int32_t *dp, int v3) { int len; if (v3) { TCHECK(dp[0]); len = (int)ntohl(*dp) / 4; dp++; } else len = NFSX_V2FH / 4; if (TTEST2(*dp, len * sizeof(*dp))) { nfs_printfh(dp, len); return (dp + len); } trunc: return (NULL); } /* * Print out a file name and return pointer to 32-bit word past it. * If packet was truncated, return 0. */ static const u_int32_t * parsefn(register const u_int32_t *dp) { register u_int32_t len; register const u_char *cp; /* Bail if we don't have the string length */ TCHECK(*dp); /* Fetch string length; convert to host order */ len = *dp++; NTOHL(len); TCHECK2(*dp, ((len + 3) & ~3)); cp = (u_char *)dp; /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */ dp += ((len + 3) & ~3) / sizeof(*dp); /* XXX seems like we should be checking the length */ putchar('"'); (void) fn_printn(cp, len, NULL); putchar('"'); return (dp); trunc: return NULL; } /* * Print out file handle and file name. * Return pointer to 32-bit word past file name. * If packet was truncated (or there was some other error), return 0. */ static const u_int32_t * parsefhn(register const u_int32_t *dp, int v3) { dp = parsefh(dp, v3); if (dp == NULL) return (NULL); putchar(' '); return (parsefn(dp)); } void nfsreq_print(register const u_char *bp, u_int length, register const u_char *bp2) { register const struct rpc_msg *rp; register const u_int32_t *dp; nfs_type type; int v3; u_int32_t proc; struct nfsv3_sattr sa3; char srcid[20], dstid[20]; /*fits 32bit*/ nfserr = 0; /* assume no error */ rp = (const struct rpc_msg *)bp; if (!nflag) { snprintf(srcid, sizeof(srcid), "%u", (u_int32_t)ntohl(rp->rm_xid)); strlcpy(dstid, "nfs", sizeof(dstid)); } else { snprintf(srcid, sizeof(srcid), "%u", (u_int32_t)ntohl(rp->rm_xid)); snprintf(dstid, sizeof(dstid), "%u", NFS_PORT); } print_nfsaddr(bp2, srcid, dstid); (void)printf("%d", length); xid_map_enter(rp, bp2); /* record proc number for later on */ v3 = (ntohl(rp->rm_call.cb_vers) == NFS_VER3); proc = ntohl(rp->rm_call.cb_proc); if (!v3 && proc < NFS_NPROCS) proc = nfsv3_procid[proc]; switch (proc) { case NFSPROC_NOOP: printf(" nop"); return; case NFSPROC_NULL: printf(" null"); return; case NFSPROC_GETATTR: printf(" getattr"); if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) return; break; case NFSPROC_SETATTR: printf(" setattr"); if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) return; break; case NFSPROC_LOOKUP: printf(" lookup"); if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL) return; break; case NFSPROC_ACCESS: printf(" access"); if ((dp = parsereq(rp, length)) != NULL && (dp = parsefh(dp, v3)) != NULL) { TCHECK(dp[0]); printf(" %04x", (u_int32_t)ntohl(dp[0])); return; } break; case NFSPROC_READLINK: printf(" readlink"); if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) return; break; case NFSPROC_READ: printf(" read"); if ((dp = parsereq(rp, length)) != NULL && (dp = parsefh(dp, v3)) != NULL) { if (v3) { TCHECK(dp[2]); printf(" %u bytes @ ", (u_int32_t) ntohl(dp[2])); print_int64(dp, UNSIGNED); } else { TCHECK(dp[1]); printf(" %u bytes @ %u", (u_int32_t)ntohl(dp[1]), (u_int32_t)ntohl(dp[0])); } return; } break; case NFSPROC_WRITE: printf(" write"); if ((dp = parsereq(rp, length)) != NULL && (dp = parsefh(dp, v3)) != NULL) { if (v3) { TCHECK(dp[4]); printf(" %u bytes @ ", (u_int32_t) ntohl(dp[4])); print_int64(dp, UNSIGNED); if (vflag) { dp += 3; TCHECK(dp[0]); printf(" <%s>", tok2str(nfsv3_writemodes, NULL, ntohl(*dp))); } } else { TCHECK(dp[3]); printf(" %u (%u) bytes @ %u (%u)", (u_int32_t)ntohl(dp[3]), (u_int32_t)ntohl(dp[2]), (u_int32_t)ntohl(dp[1]), (u_int32_t)ntohl(dp[0])); } return; } break; case NFSPROC_CREATE: printf(" create"); if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL) return; break; case NFSPROC_MKDIR: printf(" mkdir"); if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0) return; break; case NFSPROC_SYMLINK: printf(" symlink"); if ((dp = parsereq(rp, length)) != 0 && (dp = parsefhn(dp, v3)) != 0) { fputs(" ->", stdout); if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0) break; if (parsefn(dp) == 0) break; if (v3 && vflag) print_sattr3(&sa3, vflag); return; } break; case NFSPROC_MKNOD: printf(" mknod"); if ((dp = parsereq(rp, length)) != 0 && (dp = parsefhn(dp, v3)) != 0) { TCHECK(*dp); type = (nfs_type)ntohl(*dp++); if ((dp = parse_sattr3(dp, &sa3)) == 0) break; printf(" %s", tok2str(type2str, "unk-ft %d", type)); if (vflag && (type == NFCHR || type == NFBLK)) { TCHECK(dp[1]); printf(" %u/%u", (u_int32_t)ntohl(dp[0]), (u_int32_t)ntohl(dp[1])); dp += 2; } if (vflag) print_sattr3(&sa3, vflag); return; } break; case NFSPROC_REMOVE: printf(" remove"); if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL) return; break; case NFSPROC_RMDIR: printf(" rmdir"); if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL) return; break; case NFSPROC_RENAME: printf(" rename"); if ((dp = parsereq(rp, length)) != NULL && (dp = parsefhn(dp, v3)) != NULL) { fputs(" ->", stdout); if (parsefhn(dp, v3) != NULL) return; } break; case NFSPROC_LINK: printf(" link"); if ((dp = parsereq(rp, length)) != NULL && (dp = parsefh(dp, v3)) != NULL) { fputs(" ->", stdout); if (parsefhn(dp, v3) != NULL) return; } break; case NFSPROC_READDIR: printf(" readdir"); if ((dp = parsereq(rp, length)) != NULL && (dp = parsefh(dp, v3)) != NULL) { if (v3) { TCHECK(dp[4]); /* * We shouldn't really try to interpret the * offset cookie here. */ printf(" %u bytes @ ", (u_int32_t) ntohl(dp[4])); print_int64(dp, SIGNED); if (vflag) printf(" verf %08x%08x", dp[2], dp[3]); } else { TCHECK(dp[1]); /* * Print the offset as signed, since -1 is * common, but offsets > 2^31 aren't. */ printf(" %u bytes @ %d", (u_int32_t)ntohl(dp[1]), (u_int32_t)ntohl(dp[0])); } return; } break; case NFSPROC_READDIRPLUS: printf(" readdirplus"); if ((dp = parsereq(rp, length)) != NULL && (dp = parsefh(dp, v3)) != NULL) { TCHECK(dp[4]); /* * We don't try to interpret the offset * cookie here. */ printf(" %u bytes @ ", (u_int32_t) ntohl(dp[4])); print_int64(dp, SIGNED); if (vflag) printf(" max %u verf %08x%08x", (u_int32_t) ntohl(dp[5]), dp[2], dp[3]); return; } break; case NFSPROC_FSSTAT: printf(" fsstat"); if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) return; break; case NFSPROC_FSINFO: printf(" fsinfo"); if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) return; break; case NFSPROC_PATHCONF: printf(" pathconf"); if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL) return; break; case NFSPROC_COMMIT: printf(" commit"); if ((dp = parsereq(rp, length)) != NULL && (dp = parsefh(dp, v3)) != NULL) { printf(" %u bytes @ ", (u_int32_t) ntohl(dp[2])); print_int64(dp, UNSIGNED); return; } break; default: printf(" proc-%u", (u_int32_t)ntohl(rp->rm_call.cb_proc)); return; } trunc: if (!nfserr) fputs(" [|nfs]", stdout); } /* * Print out an NFS file handle. * We assume packet was not truncated before the end of the * file handle pointed to by dp. * * Note: new version (using portable file-handle parser) doesn't produce * generation number. It probably could be made to do that, with some * additional hacking on the parser code. */ static void nfs_printfh(register const u_int32_t *dp, const u_int len) { my_fsid fsid; ino_t ino; char *sfsname = NULL; Parse_fh((caddr_t*)dp, len, &fsid, &ino, NULL, &sfsname, 0); if (sfsname) { /* file system ID is ASCII, not numeric, for this server OS */ static char temp[NFSX_V3FHMAX+1]; /* Make sure string is null-terminated */ strncpy(temp, sfsname, NFSX_V3FHMAX); temp[sizeof(temp) - 1] = '\0'; /* Remove trailing spaces */ sfsname = strchr(temp, ' '); if (sfsname) *sfsname = 0; (void)printf(" fh %s/", temp); } else { (void)printf(" fh %d,%d/", fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor); } if(fsid.Fsid_dev.Minor == 257 && uflag) /* Print the undecoded handle */ (void)printf("%s", fsid.Opaque_Handle); else (void)printf("%ld", (long) ino); } /* * Maintain a small cache of recent client.XID.server/proc pairs, to allow * us to match up replies with requests and thus to know how to parse * the reply. */ struct xid_map_entry { u_int32_t xid; /* transaction ID (net order) */ int ipver; /* IP version (4 or 6) */ #ifdef INET6 struct in6_addr client; /* client IP address (net order) */ struct in6_addr server; /* server IP address (net order) */ #else struct in_addr client; /* client IP address (net order) */ struct in_addr server; /* server IP address (net order) */ #endif u_int32_t proc; /* call proc number (host order) */ u_int32_t vers; /* program version (host order) */ }; /* * Map entries are kept in an array that we manage as a ring; * new entries are always added at the tail of the ring. Initially, * all the entries are zero and hence don't match anything. */ #define XIDMAPSIZE 64 struct xid_map_entry xid_map[XIDMAPSIZE]; int xid_map_next = 0; int xid_map_hint = 0; static void xid_map_enter(const struct rpc_msg *rp, const u_char *bp) { struct ip *ip = NULL; #ifdef INET6 struct ip6_hdr *ip6 = NULL; #endif struct xid_map_entry *xmep; switch (IP_V((struct ip *)bp)) { case 4: ip = (struct ip *)bp; break; #ifdef INET6 case 6: ip6 = (struct ip6_hdr *)bp; break; #endif default: return; } xmep = &xid_map[xid_map_next]; if (++xid_map_next >= XIDMAPSIZE) xid_map_next = 0; xmep->xid = rp->rm_xid; if (ip) { xmep->ipver = 4; memcpy(&xmep->client, &ip->ip_src, sizeof(ip->ip_src)); memcpy(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst)); } #ifdef INET6 else if (ip6) { xmep->ipver = 6; memcpy(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src)); memcpy(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst)); } #endif xmep->proc = ntohl(rp->rm_call.cb_proc); xmep->vers = ntohl(rp->rm_call.cb_vers); } /* * Returns 0 and puts NFSPROC_xxx in proc return and * version in vers return, or returns -1 on failure */ static int xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc, u_int32_t *vers) { int i; struct xid_map_entry *xmep; u_int32_t xid = rp->rm_xid; struct ip *ip = (struct ip *)bp; #ifdef INET6 struct ip6_hdr *ip6 = (struct ip6_hdr *)bp; #endif int cmp; /* Start searching from where we last left off */ i = xid_map_hint; do { xmep = &xid_map[i]; cmp = 1; if (xmep->ipver != IP_V(ip) || xmep->xid != xid) goto nextitem; switch (xmep->ipver) { case 4: if (memcmp(&ip->ip_src, &xmep->server, sizeof(ip->ip_src)) != 0 || memcmp(&ip->ip_dst, &xmep->client, sizeof(ip->ip_dst)) != 0) { cmp = 0; } break; #ifdef INET6 case 6: if (memcmp(&ip6->ip6_src, &xmep->server, sizeof(ip6->ip6_src)) != 0 || memcmp(&ip6->ip6_dst, &xmep->client, sizeof(ip6->ip6_dst)) != 0) { cmp = 0; } break; #endif default: cmp = 0; break; } if (cmp) { /* match */ xid_map_hint = i; *proc = xmep->proc; *vers = xmep->vers; return 0; } nextitem: if (++i >= XIDMAPSIZE) i = 0; } while (i != xid_map_hint); /* search failed */ return (-1); } /* * Routines for parsing reply packets */ /* * Return a pointer to the beginning of the actual results. * If the packet was truncated, return 0. */ static const u_int32_t * parserep(register const struct rpc_msg *rp, register u_int length) { register const u_int32_t *dp; u_int len; enum accept_stat astat; /* * Portability note: * Here we find the address of the ar_verf credentials. * Originally, this calculation was * dp = (u_int32_t *)&rp->rm_reply.rp_acpt.ar_verf * On the wire, the rp_acpt field starts immediately after * the (32 bit) rp_stat field. However, rp_acpt (which is a * "struct accepted_reply") contains a "struct opaque_auth", * whose internal representation contains a pointer, so on a * 64-bit machine the compiler inserts 32 bits of padding * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use * the internal representation to parse the on-the-wire * representation. Instead, we skip past the rp_stat field, * which is an "enum" and so occupies one 32-bit word. */ dp = ((const u_int32_t *)&rp->rm_reply) + 1; TCHECK(dp[1]); len = ntohl(dp[1]); if (len >= length) return (NULL); /* * skip past the ar_verf credentials. */ dp += (len + (2*sizeof(u_int32_t) + 3)) / sizeof(u_int32_t); TCHECK2(dp[0], 0); /* * now we can check the ar_stat field */ astat = ntohl(*(enum accept_stat *)dp); switch (astat) { case SUCCESS: break; case PROG_UNAVAIL: printf(" PROG_UNAVAIL"); nfserr = 1; /* suppress trunc string */ return (NULL); case PROG_MISMATCH: printf(" PROG_MISMATCH"); nfserr = 1; /* suppress trunc string */ return (NULL); case PROC_UNAVAIL: printf(" PROC_UNAVAIL"); nfserr = 1; /* suppress trunc string */ return (NULL); case GARBAGE_ARGS: printf(" GARBAGE_ARGS"); nfserr = 1; /* suppress trunc string */ return (NULL); case SYSTEM_ERR: printf(" SYSTEM_ERR"); nfserr = 1; /* suppress trunc string */ return (NULL); default: printf(" ar_stat %d", astat); nfserr = 1; /* suppress trunc string */ return (NULL); } /* successful return */ TCHECK2(*dp, sizeof(astat)); return ((u_int32_t *) (sizeof(astat) + ((char *)dp))); trunc: return (0); } static const u_int32_t * parsestatus(const u_int32_t *dp, int *er) { int errnum; TCHECK(dp[0]); errnum = ntohl(dp[0]); if (er) *er = errnum; if (errnum != 0) { if (!qflag) printf(" ERROR: %s", tok2str(status2str, "unk %d", errnum)); nfserr = 1; } return (dp + 1); trunc: return NULL; } static const u_int32_t * parsefattr(const u_int32_t *dp, int verbose, int v3) { const struct nfs_fattr *fap; fap = (const struct nfs_fattr *)dp; TCHECK(fap->fa_gid); if (verbose) { printf(" %s %o ids %d/%d", tok2str(type2str, "unk-ft %d ", (u_int32_t)ntohl(fap->fa_type)), (u_int32_t)ntohl(fap->fa_mode), (u_int32_t)ntohl(fap->fa_uid), (u_int32_t) ntohl(fap->fa_gid)); if (v3) { TCHECK(fap->fa3_size); printf(" sz "); print_int64((u_int32_t *)&fap->fa3_size, UNSIGNED); putchar(' '); } else { TCHECK(fap->fa2_size); printf(" sz %d ", (u_int32_t) ntohl(fap->fa2_size)); } } /* print lots more stuff */ if (verbose > 1) { if (v3) { TCHECK(fap->fa3_ctime); printf("nlink %d rdev %d/%d ", (u_int32_t)ntohl(fap->fa_nlink), (u_int32_t) ntohl(fap->fa3_rdev.specdata1), (u_int32_t) ntohl(fap->fa3_rdev.specdata2)); printf("fsid "); print_int64((u_int32_t *)&fap->fa2_fsid, HEX); printf(" nodeid "); print_int64((u_int32_t *)&fap->fa2_fileid, HEX); printf(" a/m/ctime %u.%06u ", (u_int32_t) ntohl(fap->fa3_atime.nfsv3_sec), (u_int32_t) ntohl(fap->fa3_atime.nfsv3_nsec)); printf("%u.%06u ", (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_sec), (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_nsec)); printf("%u.%06u ", (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_sec), (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_nsec)); } else { TCHECK(fap->fa2_ctime); printf("nlink %d rdev %x fsid %x nodeid %x a/m/ctime ", (u_int32_t) ntohl(fap->fa_nlink), (u_int32_t) ntohl(fap->fa2_rdev), (u_int32_t) ntohl(fap->fa2_fsid), (u_int32_t) ntohl(fap->fa2_fileid)); printf("%u.%06u ", (u_int32_t) ntohl(fap->fa2_atime.nfsv2_sec), (u_int32_t) ntohl(fap->fa2_atime.nfsv2_usec)); printf("%u.%06u ", (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_sec), (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_usec)); printf("%u.%06u ", (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_sec), (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_usec)); } } return ((const u_int32_t *)((unsigned char *)dp + (v3 ? NFSX_V3FATTR : NFSX_V2FATTR))); trunc: return (NULL); } static int parseattrstat(const u_int32_t *dp, int verbose, int v3) { int er; dp = parsestatus(dp, &er); if (dp == NULL) return (0); if (er) return (1); return (parsefattr(dp, verbose, v3) != NULL); } static int parsediropres(const u_int32_t *dp) { int er; if (!(dp = parsestatus(dp, &er))) return (0); if (er) return (1); dp = parsefh(dp, 0); if (dp == NULL) return (0); return (parsefattr(dp, vflag, 0) != NULL); } static int parselinkres(const u_int32_t *dp, int v3) { int er; dp = parsestatus(dp, &er); if (dp == NULL) return(0); if (er) return(1); if (v3 && !(dp = parse_post_op_attr(dp, vflag))) return (0); putchar(' '); return (parsefn(dp) != NULL); } static int parsestatfs(const u_int32_t *dp, int v3) { const struct nfs_statfs *sfsp; int er; dp = parsestatus(dp, &er); if (dp == NULL) return (0); if (!v3 && er) return (1); if (qflag) return(1); if (v3) { if (vflag) printf(" POST:"); if (!(dp = parse_post_op_attr(dp, vflag))) return (0); } TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS)); sfsp = (const struct nfs_statfs *)dp; if (v3) { printf(" tbytes "); print_int64((u_int32_t *)&sfsp->sf_tbytes, UNSIGNED); printf(" fbytes "); print_int64((u_int32_t *)&sfsp->sf_fbytes, UNSIGNED); printf(" abytes "); print_int64((u_int32_t *)&sfsp->sf_abytes, UNSIGNED); if (vflag) { printf(" tfiles "); print_int64((u_int32_t *)&sfsp->sf_tfiles, UNSIGNED); printf(" ffiles "); print_int64((u_int32_t *)&sfsp->sf_ffiles, UNSIGNED); printf(" afiles "); print_int64((u_int32_t *)&sfsp->sf_afiles, UNSIGNED); printf(" invar %u", (u_int32_t) ntohl(sfsp->sf_invarsec)); } } else { printf(" tsize %d bsize %d blocks %d bfree %d bavail %d", (u_int32_t)ntohl(sfsp->sf_tsize), (u_int32_t)ntohl(sfsp->sf_bsize), (u_int32_t)ntohl(sfsp->sf_blocks), (u_int32_t)ntohl(sfsp->sf_bfree), (u_int32_t)ntohl(sfsp->sf_bavail)); } return (1); trunc: return (0); } static int parserddires(const u_int32_t *dp) { int er; dp = parsestatus(dp, &er); if (dp == NULL) return (0); if (er) return (1); if (qflag) return (1); TCHECK(dp[2]); printf(" offset %x size %d ", (u_int32_t)ntohl(dp[0]), (u_int32_t)ntohl(dp[1])); if (dp[2] != 0) printf(" eof"); return (1); trunc: return (0); } static const u_int32_t * parse_wcc_attr(const u_int32_t *dp) { printf(" sz "); print_int64(dp, UNSIGNED); printf(" mtime %u.%06u ctime %u.%06u", (u_int32_t)ntohl(dp[2]), (u_int32_t)ntohl(dp[3]), (u_int32_t)ntohl(dp[4]), (u_int32_t)ntohl(dp[5])); return (dp + 6); } /* * Pre operation attributes. Print only if vflag > 1. */ static const u_int32_t * parse_pre_op_attr(const u_int32_t *dp, int verbose) { TCHECK(dp[0]); if (!ntohl(dp[0])) return (dp + 1); dp++; TCHECK2(*dp, 24); if (verbose > 1) { return parse_wcc_attr(dp); } else { /* If not verbose enough, just skip over wcc_attr */ return (dp + 6); } trunc: return (NULL); } /* * Post operation attributes are printed if vflag >= 1 */ static const u_int32_t * parse_post_op_attr(const u_int32_t *dp, int verbose) { TCHECK(dp[0]); if (!ntohl(dp[0])) return (dp + 1); dp++; if (verbose) { return parsefattr(dp, verbose, 1); } else return (dp + (NFSX_V3FATTR / sizeof (u_int32_t))); trunc: return (NULL); } static const u_int32_t * parse_wcc_data(const u_int32_t *dp, int verbose) { if (verbose > 1) printf(" PRE:"); if (!(dp = parse_pre_op_attr(dp, verbose))) return (0); if (verbose) printf(" POST:"); return parse_post_op_attr(dp, verbose); } static const u_int32_t * parsecreateopres(const u_int32_t *dp, int verbose) { int er; if (!(dp = parsestatus(dp, &er))) return (0); if (er) dp = parse_wcc_data(dp, verbose); else { TCHECK(dp[0]); if (!ntohl(dp[0])) return (dp + 1); dp++; if (!(dp = parsefh(dp, 1))) return (0); if (verbose) { if (!(dp = parse_post_op_attr(dp, verbose))) return (0); if (vflag > 1) { printf("dir attr:"); dp = parse_wcc_data(dp, verbose); } } } return (dp); trunc: return (NULL); } static int parsewccres(const u_int32_t *dp, int verbose) { int er; if (!(dp = parsestatus(dp, &er))) return (0); return parse_wcc_data(dp, verbose) != 0; } static const u_int32_t * parsev3rddirres(const u_int32_t *dp, int verbose) { int er; if (!(dp = parsestatus(dp, &er))) return (0); if (vflag) printf(" POST:"); if (!(dp = parse_post_op_attr(dp, verbose))) return (0); if (er) return dp; if (vflag) { TCHECK(dp[1]); printf(" verf %08x%08x", dp[0], dp[1]); dp += 2; } return dp; trunc: return (NULL); } static int parsefsinfo(const u_int32_t *dp) { struct nfsv3_fsinfo *sfp; int er; if (!(dp = parsestatus(dp, &er))) return (0); if (vflag) printf(" POST:"); if (!(dp = parse_post_op_attr(dp, vflag))) return (0); if (er) return (1); sfp = (struct nfsv3_fsinfo *)dp; TCHECK(*sfp); printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u", (u_int32_t) ntohl(sfp->fs_rtmax), (u_int32_t) ntohl(sfp->fs_rtpref), (u_int32_t) ntohl(sfp->fs_wtmax), (u_int32_t) ntohl(sfp->fs_wtpref), (u_int32_t) ntohl(sfp->fs_dtpref)); if (vflag) { printf(" rtmult %u wtmult %u maxfsz ", (u_int32_t) ntohl(sfp->fs_rtmult), (u_int32_t) ntohl(sfp->fs_wtmult)); print_int64((u_int32_t *)&sfp->fs_maxfilesize, UNSIGNED); printf(" delta %u.%06u ", (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_sec), (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_nsec)); } return (1); trunc: return (0); } static int parsepathconf(const u_int32_t *dp) { int er; struct nfsv3_pathconf *spp; if (!(dp = parsestatus(dp, &er))) return (0); if (vflag) printf(" POST:"); if (!(dp = parse_post_op_attr(dp, vflag))) return (0); if (er) return (1); spp = (struct nfsv3_pathconf *)dp; TCHECK(*spp); printf(" linkmax %u namemax %u %s %s %s %s", (u_int32_t) ntohl(spp->pc_linkmax), (u_int32_t) ntohl(spp->pc_namemax), ntohl(spp->pc_notrunc) ? "notrunc" : "", ntohl(spp->pc_chownrestricted) ? "chownres" : "", ntohl(spp->pc_caseinsensitive) ? "igncase" : "", ntohl(spp->pc_casepreserving) ? "keepcase" : ""); return (1); trunc: return (0); } static void interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int length) { register const u_int32_t *dp; register int v3; int er; v3 = (vers == NFS_VER3); if (!v3 && proc < NFS_NPROCS) proc = nfsv3_procid[proc]; switch (proc) { case NFSPROC_NOOP: printf(" nop"); return; case NFSPROC_NULL: printf(" null"); return; case NFSPROC_GETATTR: printf(" getattr"); dp = parserep(rp, length); if (dp != NULL && parseattrstat(dp, !qflag, v3) != 0) return; break; case NFSPROC_SETATTR: printf(" setattr"); if (!(dp = parserep(rp, length))) return; if (v3) { if (parsewccres(dp, vflag)) return; } else { if (parseattrstat(dp, !qflag, 0) != 0) return; } break; case NFSPROC_LOOKUP: printf(" lookup"); if (!(dp = parserep(rp, length))) break; if (v3) { if (!(dp = parsestatus(dp, &er))) break; if (er) { if (vflag > 1) { printf(" post dattr:"); dp = parse_post_op_attr(dp, vflag); } } else { if (!(dp = parsefh(dp, v3))) break; if ((dp = parse_post_op_attr(dp, vflag)) && vflag > 1) { printf(" post dattr:"); dp = parse_post_op_attr(dp, vflag); } } if (dp) return; } else { if (parsediropres(dp) != 0) return; } break; case NFSPROC_ACCESS: printf(" access"); if (!(dp = parserep(rp, length))) break; if (!(dp = parsestatus(dp, &er))) break; if (vflag) printf(" attr:"); if (!(dp = parse_post_op_attr(dp, vflag))) break; if (!er) printf(" c %04x", (u_int32_t)ntohl(dp[0])); return; case NFSPROC_READLINK: printf(" readlink"); dp = parserep(rp, length); if (dp != NULL && parselinkres(dp, v3) != 0) return; break; case NFSPROC_READ: printf(" read"); if (!(dp = parserep(rp, length))) break; if (v3) { if (!(dp = parsestatus(dp, &er))) break; if (!(dp = parse_post_op_attr(dp, vflag))) break; if (er) return; if (vflag) { TCHECK(dp[1]); printf("%u bytes", (u_int32_t) ntohl(dp[0])); if (ntohl(dp[1])) printf(" EOF"); } return; } else { if (parseattrstat(dp, vflag, 0) != 0) return; } break; case NFSPROC_WRITE: printf(" write"); if (!(dp = parserep(rp, length))) break; if (v3) { if (!(dp = parsestatus(dp, &er))) break; if (!(dp = parse_wcc_data(dp, vflag))) break; if (er) return; if (vflag) { TCHECK(dp[0]); printf("%u bytes", (u_int32_t) ntohl(dp[0])); if (vflag > 1) { TCHECK(dp[1]); printf(" <%s>", tok2str(nfsv3_writemodes, NULL, ntohl(dp[1]))); } return; } } else { if (parseattrstat(dp, vflag, v3) != 0) return; } break; case NFSPROC_CREATE: printf(" create"); if (!(dp = parserep(rp, length))) break; if (v3) { if (parsecreateopres(dp, vflag) != 0) return; } else { if (parsediropres(dp) != 0) return; } break; case NFSPROC_MKDIR: printf(" mkdir"); if (!(dp = parserep(rp, length))) break; if (v3) { if (parsecreateopres(dp, vflag) != 0) return; } else { if (parsediropres(dp) != 0) return; } break; case NFSPROC_SYMLINK: printf(" symlink"); if (!(dp = parserep(rp, length))) break; if (v3) { if (parsecreateopres(dp, vflag) != 0) return; } else { if (parsestatus(dp, &er) != 0) return; } break; case NFSPROC_MKNOD: printf(" mknod"); if (!(dp = parserep(rp, length))) break; if (parsecreateopres(dp, vflag) != 0) return; break; case NFSPROC_REMOVE: printf(" remove"); if (!(dp = parserep(rp, length))) break; if (v3) { if (parsewccres(dp, vflag)) return; } else { if (parsestatus(dp, &er) != 0) return; } break; case NFSPROC_RMDIR: printf(" rmdir"); if (!(dp = parserep(rp, length))) break; if (v3) { if (parsewccres(dp, vflag)) return; } else { if (parsestatus(dp, &er) != 0) return; } break; case NFSPROC_RENAME: printf(" rename"); if (!(dp = parserep(rp, length))) break; if (v3) { if (!(dp = parsestatus(dp, &er))) break; if (vflag) { printf(" from:"); if (!(dp = parse_wcc_data(dp, vflag))) break; printf(" to:"); if (!(dp = parse_wcc_data(dp, vflag))) break; } return; } else { if (parsestatus(dp, &er) != 0) return; } break; case NFSPROC_LINK: printf(" link"); if (!(dp = parserep(rp, length))) break; if (v3) { if (!(dp = parsestatus(dp, &er))) break; if (vflag) { printf(" file POST:"); if (!(dp = parse_post_op_attr(dp, vflag))) break; printf(" dir:"); if (!(dp = parse_wcc_data(dp, vflag))) break; return; } } else { if (parsestatus(dp, &er) != 0) return; } break; case NFSPROC_READDIR: printf(" readdir"); if (!(dp = parserep(rp, length))) break; if (v3) { if (parsev3rddirres(dp, vflag)) return; } else { if (parserddires(dp) != 0) return; } break; case NFSPROC_READDIRPLUS: printf(" readdirplus"); if (!(dp = parserep(rp, length))) break; if (parsev3rddirres(dp, vflag)) return; break; case NFSPROC_FSSTAT: printf(" fsstat"); dp = parserep(rp, length); if (dp != NULL && parsestatfs(dp, v3) != 0) return; break; case NFSPROC_FSINFO: printf(" fsinfo"); dp = parserep(rp, length); if (dp != NULL && parsefsinfo(dp) != 0) return; break; case NFSPROC_PATHCONF: printf(" pathconf"); dp = parserep(rp, length); if (dp != NULL && parsepathconf(dp) != 0) return; break; case NFSPROC_COMMIT: printf(" commit"); dp = parserep(rp, length); if (dp != NULL && parsewccres(dp, vflag) != 0) return; break; default: printf(" proc-%u", proc); return; } trunc: if (!nfserr) fputs(" [|nfs]", stdout); } tcpdump-3.7.2/print-ntp.c0100644000076500000240000001447107627054631014460 0ustar fennerstaff/* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Format and print ntp packets. * By Jeffrey Mogul/DECWRL * loosely based on print-bootp.c */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.32.4.1 2002/07/10 07:13:37 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #ifdef MODEMASK #undef MODEMASK /* Solaris sucks */ #endif #include "ntp.h" static void p_sfix(const struct s_fixedpt *); static void p_ntp_time(const struct l_fixedpt *); static void p_ntp_delta(const struct l_fixedpt *, const struct l_fixedpt *); /* * Print ntp requests */ void ntp_print(register const u_char *cp, u_int length) { register const struct ntpdata *bp; int mode, version, leapind; bp = (struct ntpdata *)cp; /* Note funny sized packets */ if (length != sizeof(struct ntpdata)) (void)printf(" [len=%d]", length); TCHECK(bp->status); version = (int)(bp->status & VERSIONMASK) >> 3; printf(" v%d", version); leapind = bp->status & LEAPMASK; switch (leapind) { case NO_WARNING: break; case PLUS_SEC: fputs(" +1s", stdout); break; case MINUS_SEC: fputs(" -1s", stdout); break; } mode = bp->status & MODEMASK; switch (mode) { case MODE_UNSPEC: /* unspecified */ fputs(" unspec", stdout); break; case MODE_SYM_ACT: /* symmetric active */ fputs(" sym_act", stdout); break; case MODE_SYM_PAS: /* symmetric passive */ fputs(" sym_pas", stdout); break; case MODE_CLIENT: /* client */ fputs(" client", stdout); break; case MODE_SERVER: /* server */ fputs(" server", stdout); break; case MODE_BROADCAST: /* broadcast */ fputs(" bcast", stdout); break; case MODE_RES1: /* reserved */ fputs(" res1", stdout); break; case MODE_RES2: /* reserved */ fputs(" res2", stdout); break; } TCHECK(bp->stratum); printf(" strat %d", bp->stratum); TCHECK(bp->ppoll); printf(" poll %d", bp->ppoll); /* Can't TCHECK bp->precision bitfield so bp->distance + 0 instead */ TCHECK2(bp->distance, 0); printf(" prec %d", bp->precision); if (!vflag) return; TCHECK(bp->distance); fputs(" dist ", stdout); p_sfix(&bp->distance); TCHECK(bp->dispersion); fputs(" disp ", stdout); p_sfix(&bp->dispersion); TCHECK(bp->refid); fputs(" ref ", stdout); /* Interpretation depends on stratum */ switch (bp->stratum) { case UNSPECIFIED: printf("(unspec)"); break; case PRIM_REF: fn_printn((u_char *)&(bp->refid), 4, NULL); break; case INFO_QUERY: printf("%s INFO_QUERY", ipaddr_string(&(bp->refid))); /* this doesn't have more content */ return; case INFO_REPLY: printf("%s INFO_REPLY", ipaddr_string(&(bp->refid))); /* this is too complex to be worth printing */ return; default: printf("%s", ipaddr_string(&(bp->refid))); break; } TCHECK(bp->reftime); putchar('@'); p_ntp_time(&(bp->reftime)); TCHECK(bp->org); fputs(" orig ", stdout); p_ntp_time(&(bp->org)); TCHECK(bp->rec); fputs(" rec ", stdout); p_ntp_delta(&(bp->org), &(bp->rec)); TCHECK(bp->xmt); fputs(" xmt ", stdout); p_ntp_delta(&(bp->org), &(bp->xmt)); return; trunc: fputs(" [|ntp]", stdout); } static void p_sfix(register const struct s_fixedpt *sfp) { register int i; register int f; register float ff; i = ntohs(sfp->int_part); f = ntohs(sfp->fraction); ff = f / 65536.0; /* shift radix point by 16 bits */ f = ff * 1000000.0; /* Treat fraction as parts per million */ printf("%d.%06d", i, f); } #define FMAXINT (4294967296.0) /* floating point rep. of MAXINT */ static void p_ntp_time(register const struct l_fixedpt *lfp) { register int32_t i; register u_int32_t uf; register u_int32_t f; register float ff; i = ntohl(lfp->int_part); uf = ntohl(lfp->fraction); ff = uf; if (ff < 0.0) /* some compilers are buggy */ ff += FMAXINT; ff = ff / FMAXINT; /* shift radix point by 32 bits */ f = ff * 1000000000.0; /* treat fraction as parts per billion */ printf("%u.%09d", i, f); } /* Prints time difference between *lfp and *olfp */ static void p_ntp_delta(register const struct l_fixedpt *olfp, register const struct l_fixedpt *lfp) { register int32_t i; register u_int32_t uf; register u_int32_t ouf; register u_int32_t f; register float ff; int signbit; i = ntohl(lfp->int_part) - ntohl(olfp->int_part); uf = ntohl(lfp->fraction); ouf = ntohl(olfp->fraction); if (i > 0) { /* new is definitely greater than old */ signbit = 0; f = uf - ouf; if (ouf > uf) /* must borrow from high-order bits */ i -= 1; } else if (i < 0) { /* new is definitely less than old */ signbit = 1; f = ouf - uf; if (uf > ouf) /* must carry into the high-order bits */ i += 1; i = -i; } else { /* int_part is zero */ if (uf > ouf) { signbit = 0; f = uf - ouf; } else { signbit = 1; f = ouf - uf; } } ff = f; if (ff < 0.0) /* some compilers are buggy */ ff += FMAXINT; ff = ff / FMAXINT; /* shift radix point by 32 bits */ f = ff * 1000000000.0; /* treat fraction as parts per billion */ if (signbit) putchar('-'); else putchar('+'); printf("%d.%09d", i, f); } tcpdump-3.7.2/print-null.c0100644000076500000240000000773407627054631014635 0ustar fennerstaff/* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.41.4.1 2002/06/01 23:51:15 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ip.h" #ifdef INET6 #include "ip6.h" #endif #ifndef AF_NS #define AF_NS 6 /* XEROX NS protocols */ #endif /* * The DLT_NULL packet header is 4 bytes long. It contains a host-byte-order * 32-bit integer that specifies the family, e.g. AF_INET. * * Note here that "host" refers to the host on which the packets were * captured; that isn't necessarily *this* host. * * The OpenBSD DLT_LOOP packet header is the same, except that the integer * is in network byte order. */ #define NULL_HDRLEN 4 static void null_print(u_int family, u_int length) { if (nflag) printf("AF %u ", family); else { switch (family) { case AF_INET: printf("ip "); break; #ifdef INET6 case AF_INET6: printf("ip6 "); break; #endif case AF_NS: printf("ns "); break; default: printf("AF %u ", family); break; } } printf("%d: ", length); } /* * Byte-swap a 32-bit number. * ("htonl()" or "ntohl()" won't work - we want to byte-swap even on * big-endian platforms.) */ #define SWAPLONG(y) \ ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff)) void null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int length = h->len; u_int caplen = h->caplen; const struct ip *ip; u_int family; ++infodelay; ts_print(&h->ts); memcpy((char *)&family, (char *)p, sizeof(family)); /* * This isn't necessarily in our host byte order; if this is * a DLT_LOOP capture, it's in network byte order, and if * this is a DLT_NULL capture from a machine with the opposite * byte-order, it's in the opposite byte order from ours. * * If the upper 16 bits aren't all zero, assume it's byte-swapped. */ if ((family & 0xFFFF0000) != 0) family = SWAPLONG(family); /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; length -= NULL_HDRLEN; ip = (struct ip *)(p + NULL_HDRLEN); if (eflag) null_print(family, length); switch (IP_V(ip)) { case 4: ip_print((const u_char *)ip, length); break; #ifdef INET6 case 6: ip6_print((const u_char *)ip, length); break; #endif /* INET6 */ default: printf("ip v%d", IP_V(ip)); break; } if (xflag) default_print((const u_char *)ip, caplen - NULL_HDRLEN); putchar('\n'); --infodelay; if (infoprint) info(0); } tcpdump-3.7.2/print-ospf.c0100644000076500000240000003357707316531753014636 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.31 2001/06/28 04:34:51 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ospf.h" #include "ip.h" struct bits { u_int32_t bit; const char *str; }; static const struct bits ospf_option_bits[] = { { OSPF_OPTION_T, "T" }, { OSPF_OPTION_E, "E" }, { OSPF_OPTION_MC, "MC" }, { 0, NULL } }; static const struct bits ospf_rla_flag_bits[] = { { RLA_FLAG_B, "B" }, { RLA_FLAG_E, "E" }, { RLA_FLAG_W1, "W1" }, { RLA_FLAG_W2, "W2" }, { 0, NULL } }; static struct tok type2str[] = { { OSPF_TYPE_UMD, "umd" }, { OSPF_TYPE_HELLO, "hello" }, { OSPF_TYPE_DB, "dd" }, { OSPF_TYPE_LSR, "ls_req" }, { OSPF_TYPE_LSU, "ls_upd" }, { OSPF_TYPE_LSA, "ls_ack" }, { 0, NULL } }; static char tstr[] = " [|ospf]"; /* Forwards */ static inline void ospf_print_seqage(u_int32_t, time_t); static inline void ospf_print_bits(const struct bits *, u_char); static void ospf_print_ls_type(u_int, const struct in_addr *, const struct in_addr *, const char *); static int ospf_print_lshdr(const struct lsa_hdr *); static int ospf_print_lsa(const struct lsa *); static int ospf_decode_v2(const struct ospfhdr *, const u_char *); static inline void ospf_print_seqage(register u_int32_t seq, register time_t us) { register time_t sec = us % 60; register time_t mins = (us / 60) % 60; register time_t hour = us / 3600; printf(" S %X age ", seq); if (hour) printf("%u:%02u:%02u", (u_int32_t) hour, (u_int32_t) mins, (u_int32_t) sec); else if (mins) printf("%u:%02u", (u_int32_t) mins, (u_int32_t) sec); else printf("%u", (u_int32_t) sec); } static inline void ospf_print_bits(register const struct bits *bp, register u_char options) { register char sep = ' '; do { if (options & bp->bit) { printf("%c%s", sep, bp->str); sep = '/'; } } while ((++bp)->bit); } static void ospf_print_ls_type(register u_int ls_type, register const struct in_addr *ls_stateid, register const struct in_addr *ls_router, register const char *fmt) { switch (ls_type) { case LS_TYPE_ROUTER: printf(" rtr %s ", ipaddr_string(ls_router)); break; case LS_TYPE_NETWORK: printf(" net dr %s if %s", ipaddr_string(ls_router), ipaddr_string(ls_stateid)); break; case LS_TYPE_SUM_IP: printf(" sum %s abr %s", ipaddr_string(ls_stateid), ipaddr_string(ls_router)); break; case LS_TYPE_SUM_ABR: printf(" abr %s rtr %s", ipaddr_string(ls_router), ipaddr_string(ls_stateid)); break; case LS_TYPE_ASE: printf(" ase %s asbr %s", ipaddr_string(ls_stateid), ipaddr_string(ls_router)); break; case LS_TYPE_GROUP: printf(" group %s rtr %s", ipaddr_string(ls_stateid), ipaddr_string(ls_router)); break; default: putchar(' '); printf(fmt, ls_type); break; } } static int ospf_print_lshdr(register const struct lsa_hdr *lshp) { TCHECK(lshp->ls_type); printf(" {"); /* } (ctags) */ TCHECK(lshp->ls_options); ospf_print_bits(ospf_option_bits, lshp->ls_options); TCHECK(lshp->ls_seq); ospf_print_seqage(ntohl(lshp->ls_seq), ntohs(lshp->ls_age)); ospf_print_ls_type(lshp->ls_type, &lshp->ls_stateid, &lshp->ls_router, "ls_type %d"); return (0); trunc: return (1); } /* * Print a single link state advertisement. If truncated return 1, else 0. */ static int ospf_print_lsa(register const struct lsa *lsap) { register const u_char *ls_end; register const struct rlalink *rlp; register const struct tos_metric *tosp; register const struct in_addr *ap; register const struct aslametric *almp; register const struct mcla *mcp; register const u_int32_t *lp; register int j, k; if (ospf_print_lshdr(&lsap->ls_hdr)) return (1); TCHECK(lsap->ls_hdr.ls_length); ls_end = (u_char *)lsap + ntohs(lsap->ls_hdr.ls_length); switch (lsap->ls_hdr.ls_type) { case LS_TYPE_ROUTER: TCHECK(lsap->lsa_un.un_rla.rla_flags); ospf_print_bits(ospf_rla_flag_bits, lsap->lsa_un.un_rla.rla_flags); TCHECK(lsap->lsa_un.un_rla.rla_count); j = ntohs(lsap->lsa_un.un_rla.rla_count); TCHECK(lsap->lsa_un.un_rla.rla_link); rlp = lsap->lsa_un.un_rla.rla_link; while (j--) { TCHECK(*rlp); printf(" {"); /* } (ctags) */ switch (rlp->link_type) { case RLA_TYPE_VIRTUAL: printf(" virt"); /* Fall through */ case RLA_TYPE_ROUTER: printf(" nbrid %s if %s", ipaddr_string(&rlp->link_id), ipaddr_string(&rlp->link_data)); break; case RLA_TYPE_TRANSIT: printf(" dr %s if %s", ipaddr_string(&rlp->link_id), ipaddr_string(&rlp->link_data)); break; case RLA_TYPE_STUB: printf(" net %s mask %s", ipaddr_string(&rlp->link_id), ipaddr_string(&rlp->link_data)); break; default: /* { (ctags) */ printf(" ??RouterLinksType %d?? }", rlp->link_type); return (0); } printf(" tos 0 metric %d", ntohs(rlp->link_tos0metric)); tosp = (struct tos_metric *) ((sizeof rlp->link_tos0metric) + (u_char *) rlp); for (k = 0; k < (int) rlp->link_toscount; ++k, ++tosp) { TCHECK(*tosp); printf(" tos %d metric %d", tosp->tos_type, ntohs(tosp->tos_metric)); } /* { (ctags) */ printf(" }"); rlp = (struct rlalink *)((u_char *)(rlp + 1) + ((rlp->link_toscount) * sizeof(*tosp))); } break; case LS_TYPE_NETWORK: TCHECK(lsap->lsa_un.un_nla.nla_mask); printf(" mask %s rtrs", ipaddr_string(&lsap->lsa_un.un_nla.nla_mask)); ap = lsap->lsa_un.un_nla.nla_router; while ((u_char *)ap < ls_end) { TCHECK(*ap); printf(" %s", ipaddr_string(ap)); ++ap; } break; case LS_TYPE_SUM_IP: TCHECK(lsap->lsa_un.un_nla.nla_mask); printf(" mask %s", ipaddr_string(&lsap->lsa_un.un_sla.sla_mask)); /* Fall through */ case LS_TYPE_SUM_ABR: TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); lp = lsap->lsa_un.un_sla.sla_tosmetric; while ((u_char *)lp < ls_end) { register u_int32_t ul; TCHECK(*lp); ul = ntohl(*lp); printf(" tos %d metric %d", (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS, ul & SLA_MASK_METRIC); ++lp; } break; case LS_TYPE_ASE: TCHECK(lsap->lsa_un.un_nla.nla_mask); printf(" mask %s", ipaddr_string(&lsap->lsa_un.un_asla.asla_mask)); TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); almp = lsap->lsa_un.un_asla.asla_metric; while ((u_char *)almp < ls_end) { register u_int32_t ul; TCHECK(almp->asla_tosmetric); ul = ntohl(almp->asla_tosmetric); printf(" type %d tos %d metric %d", (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1, (ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS, (ul & ASLA_MASK_METRIC)); TCHECK(almp->asla_forward); if (almp->asla_forward.s_addr) { printf(" forward %s", ipaddr_string(&almp->asla_forward)); } TCHECK(almp->asla_tag); if (almp->asla_tag.s_addr) { printf(" tag %s", ipaddr_string(&almp->asla_tag)); } ++almp; } break; case LS_TYPE_GROUP: /* Multicast extensions as of 23 July 1991 */ mcp = lsap->lsa_un.un_mcla; while ((u_char *)mcp < ls_end) { TCHECK(mcp->mcla_vid); switch (ntohl(mcp->mcla_vtype)) { case MCLA_VERTEX_ROUTER: printf(" rtr rtrid %s", ipaddr_string(&mcp->mcla_vid)); break; case MCLA_VERTEX_NETWORK: printf(" net dr %s", ipaddr_string(&mcp->mcla_vid)); break; default: printf(" ??VertexType %u??", (u_int32_t)ntohl(mcp->mcla_vtype)); break; } ++mcp; } } /* { (ctags) */ fputs(" }", stdout); return (0); trunc: fputs(" }", stdout); return (1); } static int ospf_decode_v2(register const struct ospfhdr *op, register const u_char *dataend) { register const struct in_addr *ap; register const struct lsr *lsrp; register const struct lsa_hdr *lshp; register const struct lsa *lsap; register char sep; register int i; switch (op->ospf_type) { case OSPF_TYPE_UMD: /* * Rob Coltun's special monitoring packets; * do nothing */ break; case OSPF_TYPE_HELLO: if (vflag) { TCHECK(op->ospf_hello.hello_deadint); ospf_print_bits(ospf_option_bits, op->ospf_hello.hello_options); printf(" mask %s int %d pri %d dead %u", ipaddr_string(&op->ospf_hello.hello_mask), ntohs(op->ospf_hello.hello_helloint), op->ospf_hello.hello_priority, (u_int32_t)ntohl(op->ospf_hello.hello_deadint)); } TCHECK(op->ospf_hello.hello_dr); if (op->ospf_hello.hello_dr.s_addr != 0) printf(" dr %s", ipaddr_string(&op->ospf_hello.hello_dr)); TCHECK(op->ospf_hello.hello_bdr); if (op->ospf_hello.hello_bdr.s_addr != 0) printf(" bdr %s", ipaddr_string(&op->ospf_hello.hello_bdr)); if (vflag) { ap = op->ospf_hello.hello_neighbor; if ((u_char *)ap < dataend) printf(" nbrs"); while ((u_char *)ap < dataend) { TCHECK(*ap); printf(" %s", ipaddr_string(ap)); ++ap; } } break; /* HELLO */ case OSPF_TYPE_DB: TCHECK(op->ospf_db.db_options); ospf_print_bits(ospf_option_bits, op->ospf_db.db_options); sep = ' '; TCHECK(op->ospf_db.db_flags); if (op->ospf_db.db_flags & OSPF_DB_INIT) { printf("%cI", sep); sep = '/'; } if (op->ospf_db.db_flags & OSPF_DB_MORE) { printf("%cM", sep); sep = '/'; } if (op->ospf_db.db_flags & OSPF_DB_MASTER) { printf("%cMS", sep); sep = '/'; } TCHECK(op->ospf_db.db_seq); printf(" S %X", (u_int32_t)ntohl(op->ospf_db.db_seq)); if (vflag) { /* Print all the LS adv's */ lshp = op->ospf_db.db_lshdr; while (!ospf_print_lshdr(lshp)) { /* { (ctags) */ printf(" }"); ++lshp; } } break; case OSPF_TYPE_LSR: if (vflag) { lsrp = op->ospf_lsr; while ((u_char *)lsrp < dataend) { TCHECK(*lsrp); printf(" {"); /* } (ctags) */ ospf_print_ls_type(ntohl(lsrp->ls_type), &lsrp->ls_stateid, &lsrp->ls_router, "LinkStateType %d"); /* { (ctags) */ printf(" }"); ++lsrp; } } break; case OSPF_TYPE_LSU: if (vflag) { lsap = op->ospf_lsu.lsu_lsa; TCHECK(op->ospf_lsu.lsu_count); i = ntohl(op->ospf_lsu.lsu_count); while (i--) { if (ospf_print_lsa(lsap)) goto trunc; lsap = (struct lsa *)((u_char *)lsap + ntohs(lsap->ls_hdr.ls_length)); } } break; case OSPF_TYPE_LSA: if (vflag) { lshp = op->ospf_lsa.lsa_lshdr; while (!ospf_print_lshdr(lshp)) { /* { (ctags) */ printf(" }"); ++lshp; } } break; default: printf("v2 type %d", op->ospf_type); break; } return (0); trunc: return (1); } void ospf_print(register const u_char *bp, register u_int length, register const u_char *bp2) { register const struct ospfhdr *op; register const struct ip *ip; register const u_char *dataend; register const char *cp; op = (struct ospfhdr *)bp; ip = (struct ip *)bp2; /* XXX Before we do anything else, strip off the MD5 trailer */ TCHECK(op->ospf_authtype); if (ntohs(op->ospf_authtype) == OSPF_AUTH_MD5) { length -= OSPF_AUTH_MD5_LEN; snapend -= OSPF_AUTH_MD5_LEN; } /* If the type is valid translate it, or just print the type */ /* value. If it's not valid, say so and return */ TCHECK(op->ospf_type); cp = tok2str(type2str, "type%d", op->ospf_type); printf("OSPFv%d-%s %d:", op->ospf_version, cp, length); if (*cp == 't') return; TCHECK(op->ospf_len); if (length != ntohs(op->ospf_len)) { printf(" [len %d]", ntohs(op->ospf_len)); return; } dataend = bp + length; /* Print the routerid if it is not the same as the source */ TCHECK(op->ospf_routerid); if (ip->ip_src.s_addr != op->ospf_routerid.s_addr) printf(" rtrid %s", ipaddr_string(&op->ospf_routerid)); TCHECK(op->ospf_areaid); if (op->ospf_areaid.s_addr != 0) printf(" area %s", ipaddr_string(&op->ospf_areaid)); else printf(" backbone"); if (vflag) { /* Print authentication data (should we really do this?) */ TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata)); switch (ntohs(op->ospf_authtype)) { case OSPF_AUTH_NONE: break; case OSPF_AUTH_SIMPLE: printf(" auth \""); (void)fn_printn(op->ospf_authdata, sizeof(op->ospf_authdata), NULL); printf("\""); break; case OSPF_AUTH_MD5: printf(" auth MD5"); break; default: printf(" ??authtype-%d??", ntohs(op->ospf_authtype)); return; } } /* Do rest according to version. */ switch (op->ospf_version) { case 2: /* ospf version 2 */ if (ospf_decode_v2(op, dataend)) goto trunc; break; default: printf(" ospf [version %d]", op->ospf_version); break; } /* end switch on version */ return; trunc: fputs(tstr, stdout); } tcpdump-3.7.2/print-ospf6.c0100644000076500000240000004065007276114163014707 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.7 2001/05/09 01:08:03 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ospf6.h" struct bits { u_int32_t bit; const char *str; }; static const struct bits ospf6_option_bits[] = { { OSPF6_OPTION_V6, "V6" }, { OSPF6_OPTION_E, "E" }, { OSPF6_OPTION_MC, "MC" }, { OSPF6_OPTION_N, "N" }, { OSPF6_OPTION_R, "R" }, { OSPF6_OPTION_DC, "DC" }, { 0, NULL } }; static const struct bits ospf6_rla_flag_bits[] = { { RLA_FLAG_B, "B" }, { RLA_FLAG_E, "E" }, { RLA_FLAG_V, "V" }, { RLA_FLAG_W, "W" }, { 0, NULL } }; static const struct bits ospf6_asla_flag_bits[] = { { ASLA_FLAG_EXTERNAL, "E" }, { ASLA_FLAG_FWDADDR, "F" }, { ASLA_FLAG_ROUTETAG, "T" }, { 0, NULL } }; static struct tok type2str[] = { { OSPF_TYPE_UMD, "umd" }, { OSPF_TYPE_HELLO, "hello" }, { OSPF_TYPE_DB, "dd" }, { OSPF_TYPE_LSR, "ls_req" }, { OSPF_TYPE_LSU, "ls_upd" }, { OSPF_TYPE_LSA, "ls_ack" }, { 0, NULL } }; static char tstr[] = " [|ospf]"; /* Forwards */ static inline void ospf6_print_seqage(u_int32_t, time_t); static inline void ospf6_print_bits(const struct bits *, u_char); static void ospf6_print_ls_type(u_int, const rtrid_t *, const rtrid_t *, const char *); static int ospf6_print_lshdr(const struct lsa_hdr *); static int ospf6_print_lsa(const struct lsa *); static int ospf6_decode_v3(const struct ospf6hdr *, const u_char *); static inline void ospf6_print_seqage(register u_int32_t seq, register time_t us) { register time_t sec = us % 60; register time_t mins = (us / 60) % 60; register time_t hour = us / 3600; printf(" S %X age ", seq); if (hour) printf("%u:%02u:%02u", (u_int32_t) hour, (u_int32_t) mins, (u_int32_t) sec); else if (mins) printf("%u:%02u", (u_int32_t) mins, (u_int32_t) sec); else printf("%u", (u_int32_t) sec); } static inline void ospf6_print_bits(register const struct bits *bp, register u_char options) { register char sep = ' '; do { if (options & bp->bit) { printf("%c%s", sep, bp->str); sep = '/'; } } while ((++bp)->bit); } static void ospf6_print_ls_type(register u_int ls_type, register const rtrid_t *ls_stateid, register const rtrid_t *ls_router, register const char *fmt) { char *scope; switch (ls_type & LS_SCOPE_MASK) { case LS_SCOPE_LINKLOCAL: scope = "linklocal-"; break; case LS_SCOPE_AREA: scope = "area-"; break; case LS_SCOPE_AS: scope = "AS-"; break; default: scope = ""; break; } switch (ls_type & LS_TYPE_MASK) { case LS_TYPE_ROUTER: printf(" %srtr %s", scope, ipaddr_string(ls_router)); break; case LS_TYPE_NETWORK: printf(" %snet dr %s if %s", scope, ipaddr_string(ls_router), ipaddr_string(ls_stateid)); break; case LS_TYPE_INTER_AP: printf(" %sinter-area-prefix %s abr %s", scope, ipaddr_string(ls_stateid), ipaddr_string(ls_router)); break; case LS_TYPE_INTER_AR: printf(" %sinter-area-router %s rtr %s", scope, ipaddr_string(ls_router), ipaddr_string(ls_stateid)); break; case LS_TYPE_ASE: printf(" %sase %s asbr %s", scope, ipaddr_string(ls_stateid), ipaddr_string(ls_router)); break; case LS_TYPE_GROUP: printf(" %sgroup %s rtr %s", scope, ipaddr_string(ls_stateid), ipaddr_string(ls_router)); break; case LS_TYPE_TYPE7: printf(" %stype7 %s rtr %s", scope, ipaddr_string(ls_stateid), ipaddr_string(ls_router)); break; case LS_TYPE_LINK: printf(" %slink %s rtr %s", scope, ipaddr_string(ls_stateid), ipaddr_string(ls_router)); break; case LS_TYPE_INTRA_AP: printf(" %sintra-area-prefix %s rtr %s", scope, ipaddr_string(ls_stateid), ipaddr_string(ls_router)); break; default: printf(" %s", scope); printf(fmt, ls_type); break; } } static int ospf6_print_lshdr(register const struct lsa_hdr *lshp) { TCHECK(lshp->ls_type); printf(" {"); /* } (ctags) */ TCHECK(lshp->ls_seq); ospf6_print_seqage(ntohl(lshp->ls_seq), ntohs(lshp->ls_age)); ospf6_print_ls_type(ntohs(lshp->ls_type), &lshp->ls_stateid, &lshp->ls_router, "ls_type %d"); return (0); trunc: return (1); } static int ospf6_print_lsaprefix(register const struct lsa_prefix *lsapp) { int k; struct in6_addr prefix; TCHECK(*lsapp); k = (lsapp->lsa_p_len + 31) / 32; if (k * 4 > sizeof(struct in6_addr)) { printf("??prefixlen %d??", lsapp->lsa_p_len); goto trunc; } memset(&prefix, 0, sizeof(prefix)); memcpy(&prefix, lsapp->lsa_p_prefix, k * 4); printf(" %s/%d", ip6addr_string(&prefix), lsapp->lsa_p_len); if (lsapp->lsa_p_opt) printf("(opt=%x)", lsapp->lsa_p_opt); if (lsapp->lsa_p_mbz) printf("(mbz=%x)", ntohs(lsapp->lsa_p_mbz)); /* XXX */ return sizeof(*lsapp) - 4 + k * 4; trunc: return -1; } /* * Print a single link state advertisement. If truncated return 1, else 0. */ static int ospf6_print_lsa(register const struct lsa *lsap) { register const u_char *ls_end, *ls_opt; register const struct rlalink *rlp; #if 0 register const struct tos_metric *tosp; #endif register const rtrid_t *ap; #if 0 register const struct aslametric *almp; register const struct mcla *mcp; #endif register const struct llsa *llsap; register const struct lsa_prefix *lsapp; #if 0 register const u_int32_t *lp; #endif register int j, k; u_int32_t flags32; if (ospf6_print_lshdr(&lsap->ls_hdr)) return (1); TCHECK(lsap->ls_hdr.ls_length); ls_end = (u_char *)lsap + ntohs(lsap->ls_hdr.ls_length); switch (ntohs(lsap->ls_hdr.ls_type)) { case LS_TYPE_ROUTER | LS_SCOPE_AREA: TCHECK(lsap->lsa_un.un_rla.rla_flags); ospf6_print_bits(ospf6_rla_flag_bits, lsap->lsa_un.un_rla.rla_flags); TCHECK(lsap->lsa_un.un_rla.rla_options); ospf6_print_bits(ospf6_option_bits, ntohl(lsap->lsa_un.un_rla.rla_options)); TCHECK(lsap->lsa_un.un_rla.rla_link); rlp = lsap->lsa_un.un_rla.rla_link; while (rlp + sizeof(*rlp) <= (struct rlalink *)ls_end) { TCHECK(*rlp); printf(" {"); /* } (ctags) */ switch (rlp->link_type) { case RLA_TYPE_VIRTUAL: printf(" virt"); /* Fall through */ case RLA_TYPE_ROUTER: printf(" nbrid %s nbrif %s if %s", ipaddr_string(&rlp->link_nrtid), ipaddr_string(&rlp->link_nifid), ipaddr_string(&rlp->link_ifid)); break; case RLA_TYPE_TRANSIT: printf(" dr %s drif %s if %s", ipaddr_string(&rlp->link_nrtid), ipaddr_string(&rlp->link_nifid), ipaddr_string(&rlp->link_ifid)); break; default: /* { (ctags) */ printf(" ??RouterLinksType 0x%02x?? }", rlp->link_type); return (0); } printf(" metric %d", ntohs(rlp->link_metric)); /* { (ctags) */ printf(" }"); rlp++; } break; case LS_TYPE_NETWORK | LS_SCOPE_AREA: TCHECK(lsap->lsa_un.un_nla.nla_options); ospf6_print_bits(ospf6_option_bits, ntohl(lsap->lsa_un.un_nla.nla_options)); printf(" rtrs"); ap = lsap->lsa_un.un_nla.nla_router; while ((u_char *)ap < ls_end) { TCHECK(*ap); printf(" %s", ipaddr_string(ap)); ++ap; } break; case LS_TYPE_INTER_AP | LS_SCOPE_AREA: TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric); printf(" metric %u", (u_int32_t)ntohl(lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC); lsapp = lsap->lsa_un.un_inter_ap.inter_ap_prefix; while (lsapp + sizeof(lsapp) <= (struct lsa_prefix *)ls_end) { k = ospf6_print_lsaprefix(lsapp); if (k) goto trunc; lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k); } break; case LS_SCOPE_AS | LS_TYPE_ASE: TCHECK(lsap->lsa_un.un_asla.asla_metric); flags32 = ntohl(lsap->lsa_un.un_asla.asla_metric); ospf6_print_bits(ospf6_asla_flag_bits, flags32); printf(" metric %u", (u_int32_t)ntohl(lsap->lsa_un.un_asla.asla_metric) & ASLA_MASK_METRIC); lsapp = lsap->lsa_un.un_asla.asla_prefix; k = ospf6_print_lsaprefix(lsapp); if (k < 0) goto trunc; if ((ls_opt = (u_char *)(((u_char *)lsapp) + k)) < ls_end) { struct in6_addr *fwdaddr6; if ((flags32 & ASLA_FLAG_FWDADDR) != 0) { fwdaddr6 = (struct in6_addr *)ls_opt; TCHECK(*fwdaddr6); printf(" forward %s", ip6addr_string(fwdaddr6)); ls_opt += sizeof(struct in6_addr); } if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) { TCHECK(*(u_int32_t *)ls_opt); printf(" tag %s", ipaddr_string((u_int32_t *)ls_opt)); ls_opt += sizeof(u_int32_t); } if (lsapp->lsa_p_mbz) { TCHECK(*(u_int32_t *)ls_opt); printf(" RefLSID: %s", ipaddr_string((u_int32_t *)ls_opt)); ls_opt += sizeof(u_int32_t); } } break; #if 0 case LS_TYPE_SUM_ABR: TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); lp = lsap->lsa_un.un_sla.sla_tosmetric; while ((u_char *)lp < ls_end) { register u_int32_t ul; TCHECK(*lp); ul = ntohl(*lp); printf(" tos %d metric %d", (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS, ul & SLA_MASK_METRIC); ++lp; } break; case LS_TYPE_GROUP: /* Multicast extensions as of 23 July 1991 */ mcp = lsap->lsa_un.un_mcla; while ((u_char *)mcp < ls_end) { TCHECK(mcp->mcla_vid); switch (ntohl(mcp->mcla_vtype)) { case MCLA_VERTEX_ROUTER: printf(" rtr rtrid %s", ipaddr_string(&mcp->mcla_vid)); break; case MCLA_VERTEX_NETWORK: printf(" net dr %s", ipaddr_string(&mcp->mcla_vid)); break; default: printf(" ??VertexType %u??", (u_int32_t)ntohl(mcp->mcla_vtype)); break; } ++mcp; } #endif case LS_TYPE_LINK: /* Link LSA */ llsap = &lsap->lsa_un.un_llsa; TCHECK(llsap->llsa_options); ospf6_print_bits(ospf6_option_bits, ntohl(llsap->llsa_options)); TCHECK(llsap->llsa_nprefix); printf(" pri %d lladdr %s npref %d", llsap->llsa_priority, ip6addr_string(&llsap->llsa_lladdr), (u_int32_t)ntohl(llsap->llsa_nprefix)); lsapp = llsap->llsa_prefix; for (j = 0; j < ntohl(llsap->llsa_nprefix); j++) { k = ospf6_print_lsaprefix(lsapp); if (k) goto trunc; lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k); } break; case LS_TYPE_INTRA_AP | LS_SCOPE_AREA: /* Intra-Area-Prefix LSA */ TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid); ospf6_print_ls_type( ntohs(lsap->lsa_un.un_intra_ap.intra_ap_lstype), &lsap->lsa_un.un_intra_ap.intra_ap_lsid, &lsap->lsa_un.un_intra_ap.intra_ap_rtid, "LinkStateType %d"); TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix); printf(" npref %d", ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix)); lsapp = lsap->lsa_un.un_intra_ap.intra_ap_prefix; for (j = 0; j < ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix); j++) { k = ospf6_print_lsaprefix(lsapp); if (k) goto trunc; lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k); } break; default: printf(" ??LinkStateType 0x%04x??", ntohs(lsap->ls_hdr.ls_type)); } /* { (ctags) */ fputs(" }", stdout); return (0); trunc: fputs(" }", stdout); return (1); } static int ospf6_decode_v3(register const struct ospf6hdr *op, register const u_char *dataend) { register const rtrid_t *ap; register const struct lsr *lsrp; register const struct lsa_hdr *lshp; register const struct lsa *lsap; register char sep; register int i; switch (op->ospf6_type) { case OSPF_TYPE_UMD: /* * Rob Coltun's special monitoring packets; * do nothing */ break; case OSPF_TYPE_HELLO: if (vflag) { TCHECK(op->ospf6_hello.hello_deadint); ospf6_print_bits(ospf6_option_bits, ntohl(op->ospf6_hello.hello_options)); printf(" ifid %s pri %d int %d dead %u", ipaddr_string(&op->ospf6_hello.hello_ifid), op->ospf6_hello.hello_priority, ntohs(op->ospf6_hello.hello_helloint), ntohs(op->ospf6_hello.hello_deadint)); } TCHECK(op->ospf6_hello.hello_dr); if (op->ospf6_hello.hello_dr != 0) printf(" dr %s", ipaddr_string(&op->ospf6_hello.hello_dr)); TCHECK(op->ospf6_hello.hello_bdr); if (op->ospf6_hello.hello_bdr != 0) printf(" bdr %s", ipaddr_string(&op->ospf6_hello.hello_bdr)); if (vflag) { printf(" nbrs"); ap = op->ospf6_hello.hello_neighbor; while ((u_char *)ap < dataend) { TCHECK(*ap); printf(" %s", ipaddr_string(ap)); ++ap; } } break; /* HELLO */ case OSPF_TYPE_DB: TCHECK(op->ospf6_db.db_options); ospf6_print_bits(ospf6_option_bits, ntohl(op->ospf6_db.db_options)); sep = ' '; TCHECK(op->ospf6_db.db_flags); if (op->ospf6_db.db_flags & OSPF6_DB_INIT) { printf("%cI", sep); sep = '/'; } if (op->ospf6_db.db_flags & OSPF6_DB_MORE) { printf("%cM", sep); sep = '/'; } if (op->ospf6_db.db_flags & OSPF6_DB_MASTER) { printf("%cMS", sep); sep = '/'; } TCHECK(op->ospf6_db.db_seq); printf(" mtu %u S %X", ntohs(op->ospf6_db.db_mtu), (u_int32_t)ntohl(op->ospf6_db.db_seq)); if (vflag) { /* Print all the LS adv's */ lshp = op->ospf6_db.db_lshdr; while (!ospf6_print_lshdr(lshp)) { /* { (ctags) */ printf(" }"); ++lshp; } } break; case OSPF_TYPE_LSR: if (vflag) { lsrp = op->ospf6_lsr; while ((u_char *)lsrp < dataend) { TCHECK(*lsrp); printf(" {"); /* } (ctags) */ ospf6_print_ls_type(ntohs(lsrp->ls_type), &lsrp->ls_stateid, &lsrp->ls_router, "LinkStateType %d"); /* { (ctags) */ printf(" }"); ++lsrp; } } break; case OSPF_TYPE_LSU: if (vflag) { lsap = op->ospf6_lsu.lsu_lsa; TCHECK(op->ospf6_lsu.lsu_count); i = ntohl(op->ospf6_lsu.lsu_count); while (i--) { if (ospf6_print_lsa(lsap)) goto trunc; lsap = (struct lsa *)((u_char *)lsap + ntohs(lsap->ls_hdr.ls_length)); } } break; case OSPF_TYPE_LSA: if (vflag) { lshp = op->ospf6_lsa.lsa_lshdr; while (!ospf6_print_lshdr(lshp)) { /* { (ctags) */ printf(" }"); ++lshp; } } break; default: printf("v3 type %d", op->ospf6_type); break; } return (0); trunc: return (1); } void ospf6_print(register const u_char *bp, register u_int length) { register const struct ospf6hdr *op; register const u_char *dataend; register const char *cp; op = (struct ospf6hdr *)bp; /* If the type is valid translate it, or just print the type */ /* value. If it's not valid, say so and return */ TCHECK(op->ospf6_type); cp = tok2str(type2str, "type%d", op->ospf6_type); printf("OSPFv%d-%s %d:", op->ospf6_version, cp, length); if (*cp == 't') return; TCHECK(op->ospf6_len); if (length != ntohs(op->ospf6_len)) { printf(" [len %d]", ntohs(op->ospf6_len)); return; } dataend = bp + length; /* Print the routerid if it is not the same as the source */ TCHECK(op->ospf6_routerid); printf(" rtrid %s", ipaddr_string(&op->ospf6_routerid)); TCHECK(op->ospf6_areaid); if (op->ospf6_areaid != 0) printf(" area %s", ipaddr_string(&op->ospf6_areaid)); else printf(" backbone"); TCHECK(op->ospf6_instanceid); if (op->ospf6_instanceid) printf(" instance %u", op->ospf6_instanceid); /* Do rest according to version. */ switch (op->ospf6_version) { case 3: /* ospf version 3 */ if (ospf6_decode_v3(op, dataend)) goto trunc; break; default: printf(" ospf [version %d]", op->ospf6_version); break; } /* end switch on version */ return; trunc: fputs(tstr, stdout); } tcpdump-3.7.2/print-pim.c0100644000076500000240000005326407627054631014447 0ustar fennerstaff/* * Copyright (c) 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.29.4.1 2002/05/07 18:30:19 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include /* * XXX: We consider a case where IPv6 is not ready yet for portability, * but PIM dependent defintions should be independent of IPv6... */ struct pim { u_int8_t pim_typever; /* upper 4bit: PIM version number; 2 for PIMv2 */ /* lower 4bit: the PIM message type, currently they are: * Hello, Register, Register-Stop, Join/Prune, * Bootstrap, Assert, Graft (PIM-DM only), * Graft-Ack (PIM-DM only), C-RP-Adv */ #define PIM_VER(x) (((x) & 0xf0) >> 4) #define PIM_TYPE(x) ((x) & 0x0f) u_char pim_rsv; /* Reserved */ u_short pim_cksum; /* IP style check sum */ }; #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" #include "ip.h" static void pimv2_print(register const u_char *bp, register u_int len); static void pimv1_join_prune_print(register const u_char *bp, register u_int len) { int maddrlen, addrlen, ngroups, njoin, nprune; int njp; /* If it's a single group and a single source, use 1-line output. */ if (TTEST2(bp[0], 30) && bp[11] == 1 && ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) { int hold; (void)printf(" RPF %s ", ipaddr_string(bp)); hold = EXTRACT_16BITS(&bp[6]); if (hold != 180) { (void)printf("Hold "); relts_print(hold); } (void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune", ipaddr_string(&bp[26]), bp[25] & 0x3f, ipaddr_string(&bp[12])); if (EXTRACT_32BITS(&bp[16]) != 0xffffffff) (void)printf("/%s", ipaddr_string(&bp[16])); (void)printf(") %s%s %s", (bp[24] & 0x01) ? "Sparse" : "Dense", (bp[25] & 0x80) ? " WC" : "", (bp[25] & 0x40) ? "RP" : "SPT"); return; } TCHECK2(bp[0], 4); if (vflag > 1) (void)printf("\n"); (void)printf(" Upstream Nbr: %s", ipaddr_string(bp)); TCHECK2(bp[6], 2); if (vflag > 1) (void)printf("\n"); (void)printf(" Hold time: "); relts_print(EXTRACT_16BITS(&bp[6])); if (vflag < 2) return; bp += 8; len -= 8; TCHECK2(bp[0], 4); maddrlen = bp[1]; addrlen = bp[2]; ngroups = bp[3]; bp += 4; len -= 4; while (ngroups--) { TCHECK2(bp[0], 4); (void)printf("\n\tGroup: %s", ipaddr_string(bp)); if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) (void)printf("/%s", ipaddr_string(&bp[4])); TCHECK2(bp[8], 4); njoin = EXTRACT_16BITS(&bp[8]); nprune = EXTRACT_16BITS(&bp[10]); (void)printf(" joined: %d pruned: %d", njoin, nprune); bp += 12; len -= 12; for (njp = 0; njp < (njoin + nprune); njp++) { char *type; if (njp < njoin) type = "Join "; else type = "Prune"; TCHECK2(bp[0], 6); (void)printf("\n\t%s %s%s%s%s/%d", type, (bp[0] & 0x01) ? "Sparse " : "Dense ", (bp[1] & 0x80) ? "WC " : "", (bp[1] & 0x40) ? "RP " : "SPT ", ipaddr_string(&bp[2]), bp[1] & 0x3f); bp += 6; len -= 6; } } return; trunc: (void)printf("[|pim]"); return; } void pimv1_print(register const u_char *bp, register u_int len) { register const u_char *ep; register u_char type; ep = (const u_char *)snapend; if (bp >= ep) return; type = bp[1]; switch (type) { case 0: (void)printf(" Query"); if (TTEST(bp[8])) { switch (bp[8] >> 4) { case 0: (void)printf(" Dense-mode"); break; case 1: (void)printf(" Sparse-mode"); break; case 2: (void)printf(" Sparse-Dense-mode"); break; default: (void)printf(" mode-%d", bp[8] >> 4); break; } } if (vflag) { TCHECK2(bp[10],2); (void)printf(" (Hold-time "); relts_print(EXTRACT_16BITS(&bp[10])); (void)printf(")"); } break; case 1: (void)printf(" Register"); TCHECK2(bp[8], 20); /* ip header */ (void)printf(" for %s > %s", ipaddr_string(&bp[20]), ipaddr_string(&bp[24])); break; case 2: (void)printf(" Register-Stop"); TCHECK2(bp[12], 4); (void)printf(" for %s > %s", ipaddr_string(&bp[8]), ipaddr_string(&bp[12])); break; case 3: (void)printf(" Join/Prune"); if (vflag) pimv1_join_prune_print(&bp[8], len - 8); break; case 4: (void)printf(" RP-reachable"); if (vflag) { TCHECK2(bp[22], 2); (void)printf(" group %s", ipaddr_string(&bp[8])); if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) (void)printf("/%s", ipaddr_string(&bp[12])); (void)printf(" RP %s hold ", ipaddr_string(&bp[16])); relts_print(EXTRACT_16BITS(&bp[22])); } break; case 5: (void)printf(" Assert"); TCHECK2(bp[16], 4); (void)printf(" for %s > %s", ipaddr_string(&bp[16]), ipaddr_string(&bp[8])); if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) (void)printf("/%s", ipaddr_string(&bp[12])); TCHECK2(bp[24], 4); (void)printf(" %s pref %d metric %d", (bp[20] & 0x80) ? "RP-tree" : "SPT", EXTRACT_32BITS(&bp[20]) & 0x7fffffff, EXTRACT_32BITS(&bp[24])); break; case 6: (void)printf(" Graft"); if (vflag) pimv1_join_prune_print(&bp[8], len - 8); break; case 7: (void)printf(" Graft-ACK"); if (vflag) pimv1_join_prune_print(&bp[8], len - 8); break; case 8: (void)printf(" Mode"); break; default: (void)printf(" [type %d]", type); break; } if ((bp[4] >> 4) != 1) (void)printf(" [v%d]", bp[4] >> 4); return; trunc: (void)printf("[|pim]"); return; } /* * auto-RP is a cisco protocol, documented at * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt * * This implements version 1+, dated Sept 9, 1998. */ void cisco_autorp_print(register const u_char *bp, register u_int len) { int type; int numrps; int hold; TCHECK(bp[0]); (void)printf(" auto-rp "); type = bp[0]; switch (type) { case 0x11: (void)printf("candidate-advert"); break; case 0x12: (void)printf("mapping"); break; default: (void)printf("type-0x%02x", type); break; } TCHECK(bp[1]); numrps = bp[1]; TCHECK2(bp[2], 2); (void)printf(" Hold "); hold = EXTRACT_16BITS(&bp[2]); if (hold) relts_print(EXTRACT_16BITS(&bp[2])); else printf("FOREVER"); /* Next 4 bytes are reserved. */ bp += 8; len -= 8; /*XXX skip unless -v? */ /* * Rest of packet: * numrps entries of the form: * 32 bits: RP * 6 bits: reserved * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2". * 8 bits: # of entries for this RP * each entry: 7 bits: reserved, 1 bit: negative, * 8 bits: mask 32 bits: source * lather, rinse, repeat. */ while (numrps--) { int nentries; char s; TCHECK2(bp[0], 4); (void)printf(" RP %s", ipaddr_string(bp)); TCHECK(bp[4]); switch (bp[4] & 0x3) { case 0: printf(" PIMv?"); break; case 1: printf(" PIMv1"); break; case 2: printf(" PIMv2"); break; case 3: printf(" PIMv1+2"); break; } if (bp[4] & 0xfc) (void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc); TCHECK(bp[5]); nentries = bp[5]; bp += 6; len -= 6; s = ' '; for (; nentries; nentries--) { TCHECK2(bp[0], 6); (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "", ipaddr_string(&bp[2]), bp[1]); if (bp[0] & 0xfe) (void)printf("[rsvd=0x%02x]", bp[0] & 0xfe); s = ','; bp += 6; len -= 6; } } return; trunc: (void)printf("[|autorp]"); return; } void pim_print(register const u_char *bp, register u_int len) { register const u_char *ep; register struct pim *pim = (struct pim *)bp; ep = (const u_char *)snapend; if (bp >= ep) return; #ifdef notyet /* currently we see only version and type */ TCHECK(pim->pim_rsv); #endif switch (PIM_VER(pim->pim_typever)) { case 2: /* avoid hardcoding? */ (void)printf("pim v2"); pimv2_print(bp, len); break; default: (void)printf("pim v%d", PIM_VER(pim->pim_typever)); break; } return; } /* * PIMv2 uses encoded address representations. * * The last PIM-SM I-D before RFC2117 was published specified the * following representation for unicast addresses. However, RFC2117 * specified no encoding for unicast addresses with the unicast * address length specified in the header. Therefore, we have to * guess which encoding is being used (Cisco's PIMv2 implementation * uses the non-RFC encoding). RFC2117 turns a previously "Reserved" * field into a 'unicast-address-length-in-bytes' field. We guess * that it's the draft encoding if this reserved field is zero. * * RFC2362 goes back to the encoded format, and calls the addr length * field "reserved" again. * * The first byte is the address family, from: * * 0 Reserved * 1 IP (IP version 4) * 2 IP6 (IP version 6) * 3 NSAP * 4 HDLC (8-bit multidrop) * 5 BBN 1822 * 6 802 (includes all 802 media plus Ethernet "canonical format") * 7 E.163 * 8 E.164 (SMDS, Frame Relay, ATM) * 9 F.69 (Telex) * 10 X.121 (X.25, Frame Relay) * 11 IPX * 12 Appletalk * 13 Decnet IV * 14 Banyan Vines * 15 E.164 with NSAP format subaddress * * In addition, the second byte is an "Encoding". 0 is the default * encoding for the address family, and no other encodings are currently * specified. * */ static int pimv2_addr_len; enum pimv2_addrtype { pimv2_unicast, pimv2_group, pimv2_source }; /* 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Addr Family | Encoding Type | Unicast Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++ * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Addr Family | Encoding Type | Reserved | Mask Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Group multicast Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Source Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ static int pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent) { int af; char *afstr; int len, hdrlen; TCHECK(bp[0]); if (pimv2_addr_len == 0) { TCHECK(bp[1]); switch (bp[0]) { case 1: af = AF_INET; afstr = "IPv4"; len = 4; break; #ifdef INET6 case 2: af = AF_INET6; afstr = "IPv6"; len = 16; break; #endif default: return -1; } if (bp[1] != 0) return -1; hdrlen = 2; } else { switch (pimv2_addr_len) { case 4: af = AF_INET; afstr = "IPv4"; break; #ifdef INET6 case 16: af = AF_INET6; afstr = "IPv6"; break; #endif default: return -1; break; } len = pimv2_addr_len; hdrlen = 0; } bp += hdrlen; switch (at) { case pimv2_unicast: TCHECK2(bp[0], len); if (af == AF_INET) { if (!silent) (void)printf("%s", ipaddr_string(bp)); } #ifdef INET6 else if (af == AF_INET6) { if (!silent) (void)printf("%s", ip6addr_string(bp)); } #endif return hdrlen + len; case pimv2_group: case pimv2_source: TCHECK2(bp[0], len + 2); if (af == AF_INET) { if (!silent) { (void)printf("%s", ipaddr_string(bp + 2)); if (bp[1] != 32) (void)printf("/%u", bp[1]); } } #ifdef INET6 else if (af == AF_INET6) { if (!silent) { (void)printf("%s", ip6addr_string(bp + 2)); if (bp[1] != 128) (void)printf("/%u", bp[1]); } } #endif if (bp[0] && !silent) { if (at == pimv2_group) { (void)printf("(0x%02x)", bp[0]); } else { (void)printf("(%s%s%s", bp[0] & 0x04 ? "S" : "", bp[0] & 0x02 ? "W" : "", bp[0] & 0x01 ? "R" : ""); if (bp[0] & 0xf8) { (void) printf("+0x%02x", bp[0] & 0xf8); } (void)printf(")"); } } return hdrlen + 2 + len; default: return -1; } trunc: return -1; } static void pimv2_print(register const u_char *bp, register u_int len) { register const u_char *ep; register struct pim *pim = (struct pim *)bp; int advance; ep = (const u_char *)snapend; if (bp >= ep) return; if (ep > bp + len) ep = bp + len; TCHECK(pim->pim_rsv); pimv2_addr_len = pim->pim_rsv; if (pimv2_addr_len != 0) (void)printf("[RFC2117-encoding] "); switch (PIM_TYPE(pim->pim_typever)) { case 0: { u_int16_t otype, olen; (void)printf(" Hello"); bp += 4; while (bp < ep) { TCHECK2(bp[0], 4); otype = EXTRACT_16BITS(&bp[0]); olen = EXTRACT_16BITS(&bp[2]); TCHECK2(bp[0], 4 + olen); switch (otype) { case 1: /* Hold time */ (void)printf(" (Hold-time "); relts_print(EXTRACT_16BITS(&bp[4])); (void)printf(")"); break; case 18: /* Old DR-Priority */ if (olen == 4) (void)printf(" (OLD-DR-Priority: %d)", EXTRACT_32BITS(&bp[4])); else goto unknown; break; case 19: /* DR-Priority */ if (olen == 0) { (void)printf(" (OLD-bidir-capable)"); break; } (void)printf(" (DR-Priority: "); if (olen != 4) { (void)printf("!olen=%d!)", olen); } else { (void)printf("%d)", EXTRACT_32BITS(&bp[4])); } break; case 20: (void)printf(" (Genid: 0x%08x)", EXTRACT_32BITS(&bp[4])); break; case 21: (void)printf(" (State Refresh Capable; v%d", bp[4]); if (bp[5] != 0) { (void)printf(" interval "); relts_print(bp[5]); } if (EXTRACT_16BITS(&bp[6]) != 0) { (void)printf(" ?0x%04x?", EXTRACT_16BITS(&bp[6])); } (void)printf(")"); break; case 22: /* Bidir-Capable */ (void)printf(" (bidir-capable)"); break; default: unknown: if (vflag) (void)printf(" [Hello option %d]", otype); } bp += 4 + olen; } break; } case 1: { struct ip *ip; (void)printf(" Register"); if (vflag && bp + 8 <= ep) { (void)printf(" %s%s", bp[4] & 0x80 ? "B" : "", bp[4] & 0x40 ? "N" : ""); } bp += 8; len -= 8; /* encapsulated multicast packet */ if (bp >= ep) break; ip = (struct ip *)bp; switch (IP_V(ip)) { case 4: /* IPv4 */ printf(" "); ip_print(bp, len); break; #ifdef INET6 case 6: /* IPv6 */ printf(" "); ip6_print(bp, len); break; #endif default: (void)printf(" IP ver %d", IP_V(ip)); break; } break; } case 2: (void)printf(" Register-Stop"); bp += 4; len -= 4; if (bp >= ep) break; (void)printf(" group="); if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { (void)printf("..."); break; } bp += advance; len -= advance; if (bp >= ep) break; (void)printf(" source="); if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { (void)printf("..."); break; } bp += advance; len -= advance; break; case 3: case 6: case 7: { u_int8_t ngroup; u_int16_t holdtime; u_int16_t njoin; u_int16_t nprune; int i, j; switch (PIM_TYPE(pim->pim_typever)) { case 3: (void)printf(" Join/Prune"); break; case 6: (void)printf(" Graft"); break; case 7: (void)printf(" Graft-ACK"); break; } bp += 4; len -= 4; if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/ if (bp >= ep) break; (void)printf(" upstream-neighbor="); if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { (void)printf("..."); break; } bp += advance; len -= advance; } if (bp + 4 > ep) break; ngroup = bp[1]; holdtime = EXTRACT_16BITS(&bp[2]); (void)printf(" groups=%u", ngroup); if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/ (void)printf(" holdtime="); if (holdtime == 0xffff) (void)printf("infty"); else relts_print(holdtime); } bp += 4; len -= 4; for (i = 0; i < ngroup; i++) { if (bp >= ep) goto jp_done; (void)printf(" (group%d: ", i); if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { (void)printf("...)"); goto jp_done; } bp += advance; len -= advance; if (bp + 4 > ep) { (void)printf("...)"); goto jp_done; } njoin = EXTRACT_16BITS(&bp[0]); nprune = EXTRACT_16BITS(&bp[2]); (void)printf(" join=%u", njoin); bp += 4; len -= 4; for (j = 0; j < njoin; j++) { (void)printf(" "); if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) { (void)printf("...)"); goto jp_done; } bp += advance; len -= advance; } (void)printf(" prune=%u", nprune); for (j = 0; j < nprune; j++) { (void)printf(" "); if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) { (void)printf("...)"); goto jp_done; } bp += advance; len -= advance; } (void)printf(")"); } jp_done: break; } case 4: { int i, j, frpcnt; (void)printf(" Bootstrap"); bp += 4; /* Fragment Tag, Hash Mask len, and BSR-priority */ if (bp + sizeof(u_int16_t) >= ep) break; (void)printf(" tag=%x", EXTRACT_16BITS(bp)); bp += sizeof(u_int16_t); if (bp >= ep) break; (void)printf(" hashmlen=%d", bp[0]); if (bp + 1 >= ep) break; (void)printf(" BSRprio=%d", bp[1]); bp += 2; /* Encoded-Unicast-BSR-Address */ if (bp >= ep) break; (void)printf(" BSR="); if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { (void)printf("..."); break; } bp += advance; for (i = 0; bp < ep; i++) { /* Encoded-Group Address */ (void)printf(" (group%d: ", i); if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { (void)printf("...)"); goto bs_done; } bp += advance; /* RP-Count, Frag RP-Cnt, and rsvd */ if (bp >= ep) { (void)printf("...)"); goto bs_done; } (void)printf(" RPcnt=%d", bp[0]); if (bp + 1 >= ep) { (void)printf("...)"); goto bs_done; } (void)printf(" FRPcnt=%d", frpcnt = bp[1]); bp += 4; for (j = 0; j < frpcnt && bp < ep; j++) { /* each RP info */ (void)printf(" RP%d=", j); if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { (void)printf("...)"); goto bs_done; } bp += advance; if (bp + 1 >= ep) { (void)printf("...)"); goto bs_done; } (void)printf(",holdtime="); relts_print(EXTRACT_16BITS(bp)); if (bp + 2 >= ep) { (void)printf("...)"); goto bs_done; } (void)printf(",prio=%d", bp[2]); bp += 4; } (void)printf(")"); } bs_done: break; } case 5: (void)printf(" Assert"); bp += 4; len -= 4; if (bp >= ep) break; (void)printf(" group="); if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { (void)printf("..."); break; } bp += advance; len -= advance; if (bp >= ep) break; (void)printf(" src="); if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { (void)printf("..."); break; } bp += advance; len -= advance; if (bp + 8 > ep) break; if (bp[0] & 0x80) (void)printf(" RPT"); (void)printf(" pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff); (void)printf(" metric=%u", EXTRACT_32BITS(&bp[4])); break; case 8: { int i, pfxcnt; (void)printf(" Candidate-RP-Advertisement"); bp += 4; /* Prefix-Cnt, Priority, and Holdtime */ if (bp >= ep) break; (void)printf(" prefix-cnt=%d", bp[0]); pfxcnt = bp[0]; if (bp + 1 >= ep) break; (void)printf(" prio=%d", bp[1]); if (bp + 3 >= ep) break; (void)printf(" holdtime="); relts_print(EXTRACT_16BITS(&bp[2])); bp += 4; /* Encoded-Unicast-RP-Address */ if (bp >= ep) break; (void)printf(" RP="); if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { (void)printf("..."); break; } bp += advance; /* Encoded-Group Addresses */ for (i = 0; i < pfxcnt && bp < ep; i++) { (void)printf(" Group%d=", i); if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { (void)printf("..."); break; } bp += advance; } break; } case 9: (void)printf(" Prune-Refresh"); (void)printf(" src="); if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { (void)printf("..."); break; } bp += advance; (void)printf(" grp="); if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { (void)printf("..."); break; } bp += advance; (void)printf(" forwarder="); if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { (void)printf("..."); break; } bp += advance; TCHECK2(bp[0], 2); (void)printf(" TUNR "); relts_print(EXTRACT_16BITS(bp)); break; default: (void)printf(" [type %d]", PIM_TYPE(pim->pim_typever)); break; } return; trunc: (void)printf("[|pim]"); } tcpdump-3.7.2/print-ppp.c0100644000076500000240000007431307346547043014461 0ustar fennerstaff/* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Extensively modified by Motonori Shindo (mshindo@mshindo.net) for more * complete PPP support. */ /* * TODO: * o resolve XXX as much as possible * o MP support * o BAP support */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.64 2001/09/09 02:04:19 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #ifdef __bsdi__ #include #include #endif #include #include #include #include #include #include "interface.h" #include "extract.h" #include "addrtoname.h" #include "ppp.h" #include "chdlc.h" #include "ethertype.h" /* * The following constatns are defined by IANA. Please refer to * http://www.isi.edu/in-notes/iana/assignments/ppp-numbers * for the up-to-date information. */ /* Control Protocols (LCP/IPCP/CCP etc.) Codes */ #define CPCODES_VEXT 0 /* Vendor-Specific (RFC2153) */ #define CPCODES_CONF_REQ 1 /* Configure-Request */ #define CPCODES_CONF_ACK 2 /* Configure-Ack */ #define CPCODES_CONF_NAK 3 /* Configure-Nak */ #define CPCODES_CONF_REJ 4 /* Configure-Reject */ #define CPCODES_TERM_REQ 5 /* Terminate-Request */ #define CPCODES_TERM_ACK 6 /* Terminate-Ack */ #define CPCODES_CODE_REJ 7 /* Code-Reject */ #define CPCODES_PROT_REJ 8 /* Protocol-Reject (LCP only) */ #define CPCODES_ECHO_REQ 9 /* Echo-Request (LCP only) */ #define CPCODES_ECHO_RPL 10 /* Echo-Reply (LCP only) */ #define CPCODES_DISC_REQ 11 /* Discard-Request (LCP only) */ #define CPCODES_ID 12 /* Identification (LCP only) */ #define CPCODES_TIME_REM 13 /* Time-Remaining (LCP only) */ #define CPCODES_RESET_REQ 14 /* Reset-Request (CCP only) */ #define CPCODES_RESET_REP 15 /* Reset-Reply (CCP only) */ #define CPCODES_MIN CPCODES_VEXT #define CPCODES_MAX CPCODES_RESET_REP static const char *cpcodes[] = { /* * Control Protocol code values (RFC1661) */ "Vend-Ext", /* (0) RFC2153 */ "Conf-Req", /* (1) */ "Conf-Ack", /* (2) */ "Conf-Nak", /* (3) */ "Conf-Rej", /* (4) */ "Term-Req", /* (5) */ "Term-Ack", /* (6) */ "Code-Rej", /* (7) */ "Prot-Rej", /* (8) */ "Echo-Req", /* (9) */ "Echo-Rep", /* (10) */ "Disc-Req", /* (11) */ "Ident", /* (12) RFC1570 */ "Time-Rem", /* (13) RFC1570 */ "Reset-Req", /* (14) RFC1962 */ "Reset-Ack", /* (15) RFC1962 */ }; /* LCP Config Options */ #define LCPOPT_VEXT 0 #define LCPOPT_MRU 1 #define LCPOPT_ACCM 2 #define LCPOPT_AP 3 #define LCPOPT_QP 4 #define LCPOPT_MN 5 #define LCPOPT_DEP6 6 #define LCPOPT_PFC 7 #define LCPOPT_ACFC 8 #define LCPOPT_FCSALT 9 #define LCPOPT_SDP 10 #define LCPOPT_NUMMODE 11 #define LCPOPT_DEP12 12 #define LCPOPT_CBACK 13 #define LCPOPT_DEP14 14 #define LCPOPT_DEP15 15 #define LCPOPT_DEP16 16 #define LCPOPT_MLMRRU 17 #define LCPOPT_MLSSNHF 18 #define LCPOPT_MLED 19 #define LCPOPT_PROP 20 #define LCPOPT_DCEID 21 #define LCPOPT_MPP 22 #define LCPOPT_LD 23 #define LCPOPT_LCPAOPT 24 #define LCPOPT_COBS 25 #define LCPOPT_PE 26 #define LCPOPT_MLHF 27 #define LCPOPT_I18N 28 #define LCPOPT_SDLOS 29 #define LCPOPT_PPPMUX 30 #define LCPOPT_MIN LCPOPT_VEXT #define LCPOPT_MAX LCPOPT_PPPMUX static const char *lcpconfopts[] = { "Vend-Ext", /* (0) */ "MRU", /* (1) */ "ACCM", /* (2) */ "Auth-Prot", /* (3) */ "Qual-Prot", /* (4) */ "Magic-Num", /* (5) */ "deprecated(6)", /* used to be a Quality Protocol */ "PFC", /* (7) */ "ACFC", /* (8) */ "FCS-Alt", /* (9) */ "SDP", /* (10) */ "Num-Mode", /* (11) */ "deprecated(12)", /* used to be a Multi-Link-Procedure*/ "Call-Back", /* (13) */ "deprecated(14)", /* used to be a Connect-Time */ "deprecated(15)", /* used to be a Compund-Frames */ "deprecated(16)", /* used to be a Nominal-Data-Encap */ "MRRU", /* (17) */ "SSNHF", /* (18) */ "End-Disc", /* (19) */ "Proprietary", /* (20) */ "DCE-Id", /* (21) */ "MP+", /* (22) */ "Link-Disc", /* (23) */ "LCP-Auth-Opt", /* (24) */ "COBS", /* (25) */ "Prefix-elision", /* (26) */ "Multilink-header-Form",/* (27) */ "I18N", /* (28) */ "SDL-over-SONET/SDH", /* (29) */ "PPP-Muxing", /* (30) */ }; /* IPV6CP - to be supported */ /* ECP - to be supported */ /* CCP Config Options */ #define CCPOPT_OUI 0 /* RFC1962 */ #define CCPOPT_PRED1 1 /* RFC1962 */ #define CCPOPT_PRED2 2 /* RFC1962 */ #define CCPOPT_PJUMP 3 /* RFC1962 */ /* 4-15 unassigned */ #define CCPOPT_HPPPC 16 /* RFC1962 */ #define CCPOPT_STACLZS 17 /* RFC1974 */ #define CCPOPT_MPPC 18 /* RFC2118 */ #define CCPOPT_GFZA 19 /* RFC1962 */ #define CCPOPT_V42BIS 20 /* RFC1962 */ #define CCPOPT_BSDCOMP 21 /* RFC1977 */ /* 22 unassigned */ #define CCPOPT_LZSDCP 23 /* RFC1967 */ #define CCPOPT_MVRCA 24 /* RFC1975 */ #define CCPOPT_DEC 25 /* RFC1976 */ #define CCPOPT_DEFLATE 26 /* RFC1979 */ /* 27-254 unassigned */ #define CCPOPT_RESV 255 /* RFC1962 */ #define CCPOPT_MIN CCPOPT_OUI #define CCPOPT_MAX CCPOPT_DEFLATE /* XXX: should be CCPOPT_RESV but... */ static const char *ccpconfopts[] = { "OUI", /* (0) */ "Pred-1", /* (1) */ "Pred-2", /* (2) */ "Puddle", /* (3) */ "unassigned(4)", /* (4) */ "unassigned(5)", /* (5) */ "unassigned(6)", /* (6) */ "unassigned(7)", /* (7) */ "unassigned(8)", /* (8) */ "unassigned(9)", /* (9) */ "unassigned(10)", /* (10) */ "unassigned(11)", /* (11) */ "unassigned(12)", /* (12) */ "unassigned(13)", /* (13) */ "unassigned(14)", /* (14) */ "unassigned(15)", /* (15) */ "HP-PPC", /* (16) */ "Stac-LZS", /* (17) */ "MPPC", /* (18) */ "Gand-FZA", /* (19) */ "V.42bis", /* (20) */ "BSD-Comp", /* (21) */ "unassigned(22)", /* (22) */ "LZS-DCP", /* (23) */ "MVRCA", /* (24) */ "DEC", /* (25) */ "Deflate", /* (26) */ }; /* BACP Config Options */ #define BACPOPT_FPEER 1 /* RFC2125 */ /* SDCP - to be supported */ /* IPCP Config Options */ #define IPCPOPT_2ADDR 1 /* RFC1172, RFC1332 (deprecated) */ #define IPCPOPT_IPCOMP 2 /* RFC1332 */ #define IPCPOPT_ADDR 3 /* RFC1332 */ #define IPCPOPT_MOBILE4 4 /* RFC2290 */ #define IPCPOPT_PRIDNS 129 /* RFC1877 */ #define IPCPOPT_PRINBNS 130 /* RFC1877 */ #define IPCPOPT_SECDNS 131 /* RFC1877 */ #define IPCPOPT_SECNBNS 132 /* RFC1877 */ /* ATCP - to be supported */ /* OSINLCP - to be supported */ /* BVCP - to be supported */ /* BCP - to be supported */ /* IPXCP - to be supported */ /* Auth Algorithms */ /* 0-4 Reserved (RFC1994) */ #define AUTHALG_CHAPMD5 5 /* RFC1994 */ #define AUTHALG_MSCHAP1 128 /* RFC2433 */ #define AUTHALG_MSCHAP2 129 /* RFC2795 */ /* FCS Alternatives - to be supported */ /* Multilink Endpoint Discriminator (RFC1717) */ #define MEDCLASS_NULL 0 /* Null Class */ #define MEDCLASS_LOCAL 1 /* Locally Assigned */ #define MEDCLASS_IPV4 2 /* Internet Protocol (IPv4) */ #define MEDCLASS_MAC 3 /* IEEE 802.1 global MAC address */ #define MEDCLASS_MNB 4 /* PPP Magic Number Block */ #define MEDCLASS_PSNDN 5 /* Public Switched Network Director Number */ /* PPP LCP Callback */ #define CALLBACK_AUTH 0 /* Location determined by user auth */ #define CALLBACK_DSTR 1 /* Dialing string */ #define CALLBACK_LID 2 /* Location identifier */ #define CALLBACK_E164 3 /* E.164 number */ #define CALLBACK_X500 4 /* X.500 distinguished name */ #define CALLBACK_CBCP 6 /* Location is determined during CBCP nego */ /* CHAP */ #define CHAP_CHAL 1 #define CHAP_RESP 2 #define CHAP_SUCC 3 #define CHAP_FAIL 4 #define CHAP_CODEMIN CHAP_CHAL #define CHAP_CODEMAX CHAP_FAIL static const char *chapcode[] = { "Chal", /* (1) */ "Resp", /* (2) */ "Succ", /* (3) */ "Fail", /* (4) */ }; /* PAP */ #define PAP_AREQ 1 #define PAP_AACK 2 #define PAP_ANAK 3 #define PAP_CODEMIN PAP_AREQ #define PAP_CODEMAX PAP_ANAK static const char *papcode[] = { "Auth-Req", /* (1) */ "Auth-Ack", /* (2) */ "Auth-Nak", /* (3) */ }; /* BAP */ #define BAP_CALLREQ 1 #define BAP_CALLRES 2 #define BAP_CBREQ 3 #define BAP_CBRES 4 #define BAP_LDQREQ 5 #define BAP_LDQRES 6 #define BAP_CSIND 7 #define BAP_CSRES 8 static const char *ppp_protoname (u_int proto); static void handle_ctrl_proto (u_int proto,const u_char *p, int length); static void handle_chap (const u_char *p, int length); static void handle_pap (const u_char *p, int length); static void handle_bap (const u_char *p, int length); static int print_lcp_config_options (const u_char *p, int); static int print_ipcp_config_options (const u_char *p, int); static int print_ccp_config_options (const u_char *p, int); static int print_bacp_config_options (const u_char *p, int); static void handle_ppp (u_int proto, const u_char *p, int length); static const char * ppp_protoname(u_int proto) { static char buf[20]; switch (proto) { case PPP_IP: return "IP"; case PPP_IPV6: return "IPv6"; #ifdef PPP_XNS case PPP_XNS: return "XNS"; #endif case PPP_IPX: return "IPX"; case PPP_OSI: return "OSI"; case PPP_VJC: return "VJC"; case PPP_VJNC: return "VJNC"; case PPP_COMP: return "COMP"; case PPP_IPCP: return "IPCP"; case PPP_IPV6CP: return "IPv6CP"; case PPP_IPXCP: return "IPXCP"; case PPP_OSICP: return "OSICP"; case PPP_CCP: return "CCP"; case PPP_LCP: return "LCP"; case PPP_PAP: return "PAP"; #ifdef PPP_LQR case PPP_LQR: return "LQR"; #endif case PPP_CHAP: return "CHAP"; case PPP_BACP: return "BACP"; case PPP_BAP: return "BAP"; default: snprintf(buf, sizeof(buf), "unknown-0x%04x", proto); return buf; } } /* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */ static void handle_ctrl_proto(u_int proto, const u_char *p, int length) { u_int code, len; int (*pfunc)(const u_char *, int); int x, j; if (length < 1) { printf("[|%s]", ppp_protoname(proto)); return; } else if (length < 4) { printf("[|%s 0x%02x]", ppp_protoname(proto), *p); return; } code = *p; if ((code >= CPCODES_MIN) && (code <= CPCODES_MAX)) printf("%s", cpcodes[code]); else { printf("0x%02x", code); return; } p++; printf("(%u)", *p); /* ID */ p++; len = EXTRACT_16BITS(p); p += 2; if (length <= 4) return; /* there may be a NULL confreq etc. */ switch (code) { case CPCODES_VEXT: if (length < 11) break; printf(", Magic-Num=%08x", EXTRACT_32BITS(p)); p += 4; printf(" OUI=%02x%02x%02x", p[0], p[1], p[2]); /* XXX: need to decode Kind and Value(s)? */ break; case CPCODES_CONF_REQ: case CPCODES_CONF_ACK: case CPCODES_CONF_NAK: case CPCODES_CONF_REJ: x = len - 4; /* Code(1), Identifier(1) and Length(2) */ do { switch (proto) { case PPP_LCP: pfunc = print_lcp_config_options; break; case PPP_IPCP: pfunc = print_ipcp_config_options; break; case PPP_CCP: pfunc = print_ccp_config_options; break; case PPP_BACP: pfunc = print_bacp_config_options; break; default: /* * This should never happen, but we set * "pfunc" to squelch uninitialized * variable warnings from compilers. */ pfunc = NULL; break; } if ((j = (*pfunc)(p, len)) == 0) break; x -= j; p += j; } while (x > 0); break; case CPCODES_TERM_REQ: case CPCODES_TERM_ACK: /* XXX: need to decode Data? */ break; case CPCODES_CODE_REJ: /* XXX: need to decode Rejected-Packet? */ break; case CPCODES_PROT_REJ: if (length < 6) break; printf(", Rejected-Protocol=%04x", EXTRACT_16BITS(p)); /* XXX: need to decode Rejected-Information? */ break; case CPCODES_ECHO_REQ: case CPCODES_ECHO_RPL: case CPCODES_DISC_REQ: case CPCODES_ID: if (length < 8) break; printf(", Magic-Num=%08x", EXTRACT_32BITS(p)); /* XXX: need to decode Data? */ break; case CPCODES_TIME_REM: if (length < 12) break; printf(", Magic-Num=%08x", EXTRACT_32BITS(p)); printf(" Seconds-Remaining=%u", EXTRACT_32BITS(p + 4)); /* XXX: need to decode Message? */ break; default: printf(", unknown-Codes-0x%02x", code); break; } } /* LCP config options */ static int print_lcp_config_options(const u_char *p, int length) { int len, opt; if (length < 2) return 0; len = p[1]; opt = p[0]; if (length < len) return 0; if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX)) printf(", %s", lcpconfopts[opt]); else { printf(", unknwhown-%d", opt); return len; } switch (opt) { case LCPOPT_VEXT: if (len >= 6) { printf(" OUI=%02x%02x%02x", p[2], p[3], p[4]); #if 0 printf(" kind=%02x", p[5]); printf(" val=") for (i = 0; i < len - 6; i++) { printf("%02x", p[6 + i]); } #endif } break; case LCPOPT_MRU: if (len == 4) printf("=%u", EXTRACT_16BITS(p + 2)); break; case LCPOPT_ACCM: if (len == 6) printf("=%08x", EXTRACT_32BITS(p + 2)); break; case LCPOPT_AP: if (len >= 4) { if (p[2] == 0xc0 && p[3] == 0x23) printf(" PAP"); else if (p[2] == 0xc2 && p[3] == 0x23) { printf(" CHAP/"); switch (p[4]) { default: printf("unknown-algorithm-%u", p[4]); break; case AUTHALG_CHAPMD5: printf("MD5"); break; case AUTHALG_MSCHAP1: printf("MSCHAPv1"); break; case AUTHALG_MSCHAP2: printf("MSCHAPv2"); break; } } else if (p[2] == 0xc2 && p[3] == 0x27) printf(" EAP"); else if (p[2] == 0xc0 && p[3] == 0x27) printf(" SPAP"); else if (p[2] == 0xc1 && p[3] == 0x23) printf(" Old-SPAP"); else printf("unknown"); } break; case LCPOPT_QP: if (len >= 4) { if (p[2] == 0xc0 && p[3] == 0x25) printf(" LQR"); else printf(" unknown"); } break; case LCPOPT_MN: if (len == 6) printf("=%08x", EXTRACT_32BITS(p + 2)); break; case LCPOPT_PFC: break; case LCPOPT_ACFC: break; case LCPOPT_LD: if (len == 4) printf("=%04x", EXTRACT_16BITS(p + 2)); break; case LCPOPT_CBACK: if (len < 3) break; switch (p[2]) { /* Operation */ case CALLBACK_AUTH: printf(" UserAuth"); break; case CALLBACK_DSTR: printf(" DialString"); break; case CALLBACK_LID: printf(" LocalID"); break; case CALLBACK_E164: printf(" E.164"); break; case CALLBACK_X500: printf(" X.500"); break; case CALLBACK_CBCP: printf(" CBCP"); break; default: printf(" unknown-operation=%u", p[2]); break; } break; case LCPOPT_MLMRRU: if (len == 4) printf("=%u", EXTRACT_16BITS(p + 2)); break; case LCPOPT_MLED: if (len < 3) break; switch (p[2]) { /* class */ case MEDCLASS_NULL: printf(" Null"); break; case MEDCLASS_LOCAL: printf(" Local"); /* XXX */ break; case MEDCLASS_IPV4: if (len != 7) break; printf(" IPv4=%s", ipaddr_string(p + 3)); break; case MEDCLASS_MAC: if (len != 9) break; printf(" MAC=%02x:%02x:%02x:%02x:%02x:%02x", p[3], p[4], p[5], p[6], p[7], p[8]); break; case MEDCLASS_MNB: printf(" Magic-Num-Block"); /* XXX */ break; case MEDCLASS_PSNDN: printf(" PSNDN"); /* XXX */ break; } break; /* XXX: to be supported */ #if 0 case LCPOPT_DEP6: case LCPOPT_FCSALT: case LCPOPT_SDP: case LCPOPT_NUMMODE: case LCPOPT_DEP12: case LCPOPT_DEP14: case LCPOPT_DEP15: case LCPOPT_DEP16: case LCPOPT_MLSSNHF: case LCPOPT_PROP: case LCPOPT_DCEID: case LCPOPT_MPP: case LCPOPT_LCPAOPT: case LCPOPT_COBS: case LCPOPT_PE: case LCPOPT_MLHF: case LCPOPT_I18N: case LCPOPT_SDLOS: case LCPOPT_PPPMUX: break; #endif } return len; } /* CHAP */ static void handle_chap(const u_char *p, int length) { u_int code, len; int val_size, name_size, msg_size; const u_char *p0; int i; p0 = p; if (length < 1) { printf("[|chap]"); return; } else if (length < 4) { printf("[|chap 0x%02x]", *p); return; } code = *p; if ((code >= CHAP_CODEMIN) && (code <= CHAP_CODEMAX)) printf("%s", chapcode[code - 1]); else { printf("0x%02x", code); return; } p++; printf("(%u)", *p); /* ID */ p++; len = EXTRACT_16BITS(p); p += 2; /* * Note that this is a generic CHAP decoding routine. Since we * don't know which flavor of CHAP (i.e. CHAP-MD5, MS-CHAPv1, * MS-CHAPv2) is used at this point, we can't decode packet * specifically to each algorithms. Instead, we simply decode * the GCD (Gratest Common Denominator) for all algorithms. */ switch (code) { case CHAP_CHAL: case CHAP_RESP: if (length - (p - p0) < 1) return; val_size = *p; /* value size */ p++; if (length - (p - p0) < val_size) return; printf(", Value="); for (i = 0; i < val_size; i++) printf("%02x", *p++); name_size = len - (p - p0); printf(", Name="); for (i = 0; i < name_size; i++) safeputchar(*p++); break; case CHAP_SUCC: case CHAP_FAIL: msg_size = len - (p - p0); printf(", Msg="); for (i = 0; i< msg_size; i++) safeputchar(*p++); break; } } /* PAP (see RFC 1334) */ static void handle_pap(const u_char *p, int length) { u_int code, len; int peerid_len, passwd_len, msg_len; const u_char *p0; int i; p0 = p; if (length < 1) { printf("[|pap]"); return; } else if (length < 4) { printf("[|pap 0x%02x]", *p); return; } code = *p; if ((code >= PAP_CODEMIN) && (code <= PAP_CODEMAX)) printf("%s", papcode[code - 1]); else { printf("0x%02x", code); return; } p++; printf("(%u)", *p); /* ID */ p++; len = EXTRACT_16BITS(p); p += 2; switch (code) { case PAP_AREQ: if (length - (p - p0) < 1) return; peerid_len = *p; /* Peer-ID Length */ p++; if (length - (p - p0) < peerid_len) return; printf(", Peer="); for (i = 0; i < peerid_len; i++) safeputchar(*p++); if (length - (p - p0) < 1) return; passwd_len = *p; /* Password Length */ p++; if (length - (p - p0) < passwd_len) return; printf(", Name="); for (i = 0; i < passwd_len; i++) safeputchar(*p++); break; case PAP_AACK: case PAP_ANAK: if (length - (p - p0) < 1) return; msg_len = *p; /* Msg-Length */ p++; if (length - (p - p0) < msg_len) return; printf(", Msg="); for (i = 0; i< msg_len; i++) safeputchar(*p++); break; } return; } /* BAP */ static void handle_bap(const u_char *p, int length) { /* XXX: to be supported!! */ } /* IPCP config options */ static int print_ipcp_config_options(const u_char *p, int length) { int len, opt; if (length < 2) return 0; len = p[1]; opt = p[0]; if (length < len) return 0; switch (opt) { case IPCPOPT_2ADDR: /* deprecated */ if (len != 10) goto invlen; printf(", IP-Addrs src=%s dst=%s", ipaddr_string(p + 2), ipaddr_string(p + 6)); break; case IPCPOPT_IPCOMP: if (len < 4) goto invlen; printf(", IP-Comp"); if (EXTRACT_16BITS(p + 2) == PPP_VJC) { printf(" VJ-Comp"); /* XXX: VJ-Comp parameters should be decoded */ } else printf(" unknown-comp-proto=%04x", EXTRACT_16BITS(p + 2)); break; case IPCPOPT_ADDR: if (len != 6) goto invlen; printf(", IP-Addr=%s", ipaddr_string(p + 2)); break; case IPCPOPT_MOBILE4: if (len != 6) goto invlen; printf(", Home-Addr=%s", ipaddr_string(p + 2)); break; case IPCPOPT_PRIDNS: if (len != 6) goto invlen; printf(", Pri-DNS=%s", ipaddr_string(p + 2)); break; case IPCPOPT_PRINBNS: if (len != 6) goto invlen; printf(", Pri-NBNS=%s", ipaddr_string(p + 2)); break; case IPCPOPT_SECDNS: if (len != 6) goto invlen; printf(", Sec-DNS=%s", ipaddr_string(p + 2)); break; case IPCPOPT_SECNBNS: if (len != 6) goto invlen; printf(", Sec-NBNS=%s", ipaddr_string(p + 2)); break; default: printf(", unknown-%d", opt); break; } return len; invlen: printf(", invalid-length-%d", opt); return 0; } /* CCP config options */ static int print_ccp_config_options(const u_char *p, int length) { int len, opt; if (length < 2) return 0; len = p[1]; opt = p[0]; if (length < len) return 0; if ((opt >= CCPOPT_MIN) && (opt <= CCPOPT_MAX)) printf(", %s", ccpconfopts[opt]); #if 0 /* XXX */ switch (opt) { case CCPOPT_OUI: case CCPOPT_PRED1: case CCPOPT_PRED2: case CCPOPT_PJUMP: case CCPOPT_HPPPC: case CCPOPT_STACLZS: case CCPOPT_MPPC: case CCPOPT_GFZA: case CCPOPT_V42BIS: case CCPOPT_BSDCOMP: case CCPOPT_LZSDCP: case CCPOPT_MVRCA: case CCPOPT_DEC: case CCPOPT_DEFLATE: case CCPOPT_RESV: break; default: printf(", unknown-%d", opt); break; } #endif return len; } /* BACP config options */ static int print_bacp_config_options(const u_char *p, int length) { int len, opt; if (length < 2) return 0; len = p[1]; opt = p[0]; if (length < len) return 0; if (opt == BACPOPT_FPEER) { printf(", Favored-Peer"); printf(" Magic-Num=%08x", EXTRACT_32BITS(p + 2)); } else { printf(", unknown-option-%d", opt); } return len; } /* PPP */ static void handle_ppp(u_int proto, const u_char *p, int length) { switch (proto) { case PPP_LCP: case PPP_IPCP: case PPP_CCP: case PPP_BACP: handle_ctrl_proto(proto, p, length); break; case PPP_CHAP: handle_chap(p, length); break; case PPP_PAP: handle_pap(p, length); break; case PPP_BAP: /* XXX: not yet completed */ handle_bap(p, length); break; case ETHERTYPE_IP: /*XXX*/ case PPP_IP: ip_print(p, length); break; #ifdef INET6 case ETHERTYPE_IPV6: /*XXX*/ case PPP_IPV6: ip6_print(p, length); break; #endif case ETHERTYPE_IPX: /*XXX*/ case PPP_IPX: ipx_print(p, length); break; case PPP_OSI: isoclns_print(p, length, length, NULL, NULL); break; default: break; } } /* Standard PPP printer */ void ppp_print(register const u_char *p, u_int length) { u_int proto; u_int full_length = length; /* * Here, we assume that p points to the Address and Control * field (if they present). */ if (length < 2) goto trunc; if (*p == PPP_ADDRESS && *(p + 1) == PPP_CONTROL) { p += 2; /* ACFC not used */ length -= 2; } if (length < 2) goto trunc; if (*p % 2) { proto = *p; /* PFC is used */ p++; length--; } else { proto = EXTRACT_16BITS(p); p += 2; length -= 2; } if (eflag) printf("%s %d: ", ppp_protoname(proto), full_length); handle_ppp(proto, p, length); return; trunc: printf("[|ppp]"); } /* PPP I/F printer */ void ppp_if_print(u_char *user, const struct pcap_pkthdr *h, register const u_char *p) { register u_int length = h->len; register u_int caplen = h->caplen; ++infodelay; ts_print(&h->ts); if (caplen < PPP_HDRLEN) { printf("[|ppp]"); goto out; } /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; #if 0 /* * XXX: seems to assume that there are 2 octets prepended to an * actual PPP frame. The 1st octet looks like Input/Output flag * while 2nd octet is unknown, at least to me * (mshindo@mshindo.net). * * That was what the original tcpdump code did. * * FreeBSD's "if_ppp.c" *does* set the first octet to 1 for outbound * packets and 0 for inbound packets - but only if the * protocol field has the 0x8000 bit set (i.e., it's a network * control protocol); it does so before running the packet through * "bpf_filter" to see if it should be discarded, and to see * if we should update the time we sent the most recent packet... * * ...but it puts the original address field back after doing * so. * * NetBSD's "if_ppp.c" doesn't set the first octet in that fashion. * * I don't know if any PPP implementation handed up to a BPF * device packets with the first octet being 1 for outbound and * 0 for inbound packets, so I (guy@alum.mit.edu) don't know * whether that ever needs to be checked or not. * * Note that NetBSD has a DLT_PPP_SERIAL, which it uses for PPP, * and its tcpdump appears to assume that the frame always * begins with an address field and a control field, and that * the address field might be 0x0f or 0x8f, for Cisco * point-to-point with HDLC framing as per section 4.3.1 of RFC * 1547, as well as 0xff, for PPP in HDLC-like framing as per * RFC 1662. * * (Is the Cisco framing in question what DLT_C_HDLC, in * BSD/OS, is?) */ if (eflag) printf("%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]); #endif ppp_print(p, length); if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } /* * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547, * is being used (i.e., we don't check for PPP_ADDRESS and PPP_CONTROL, * discard them *if* those are the first two octets, and parse the remaining * packet as a PPP packet, as "ppp_print()" does). * * This handles, for example, DLT_PPP_SERIAL in NetBSD. */ void ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h, register const u_char *p) { register u_int length = h->len; register u_int caplen = h->caplen; u_int proto; ++infodelay; ts_print(&h->ts); if (caplen < 2) { printf("[|ppp]"); goto out; } /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; switch (p[0]) { case PPP_ADDRESS: if (caplen < 4) { printf("[|ppp]"); goto out; } if (eflag) printf("%02x %02x %d ", p[0], p[1], length); p += 2; length -= 2; proto = EXTRACT_16BITS(p); p += 2; length -= 2; if (eflag) printf("%s: ", ppp_protoname(proto)); handle_ppp(proto, p, length); break; case CHDLC_UNICAST: case CHDLC_BCAST: chdlc_print(p, length, caplen); goto out; default: if (eflag) printf("%02x %02x %d ", p[0], p[1], length); p += 2; length -= 2; /* * XXX - NetBSD's "ppp_netbsd_serial_if_print()" treats * the next two octets as an Ethernet type; does that * ever happen? */ printf("unknown addr %02x; ctrl %02x", p[0], p[1]); break; } if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } struct tok ppptype2str[] = { { PPP_IP, "IP" }, { PPP_OSI, "OSI" }, { PPP_NS, "NS" }, { PPP_DECNET, "DECNET" }, { PPP_APPLE, "APPLE" }, { PPP_IPX, "IPX" }, { PPP_VJC, "VJC" }, { PPP_VJNC, "VJNC" }, { PPP_BRPDU, "BRPDU" }, { PPP_STII, "STII" }, { PPP_VINES, "VINES" }, { PPP_HELLO, "HELLO" }, { PPP_LUXCOM, "LUXCOM" }, { PPP_SNS, "SNS" }, { PPP_IPCP, "IPCP" }, { PPP_OSICP, "OSICP" }, { PPP_NSCP, "NSCP" }, { PPP_DECNETCP, "DECNETCP" }, { PPP_APPLECP, "APPLECP" }, { PPP_IPXCP, "IPXCP" }, { PPP_STIICP, "STIICP" }, { PPP_VINESCP, "VINESCP" }, { PPP_LCP, "LCP" }, { PPP_PAP, "PAP" }, { PPP_LQM, "LQM" }, { PPP_CHAP, "CHAP" }, { PPP_BACP, "BACP" }, { PPP_BAP, "BAP" }, { PPP_MP, "MP" }, { 0, NULL } }; #define PPP_BSDI_HDRLEN 24 /* BSD/OS specific PPP printer */ void ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, register const u_char *p) { #ifdef __bsdi__ register u_int length = h->len; register u_int caplen = h->caplen; register int hdrlength; u_int16_t ptype; const u_char *q; int i; ++infodelay; ts_print(&h->ts); if (caplen < PPP_BSDI_HDRLEN) { printf("[|ppp]"); goto out; } /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; hdrlength = 0; #if 0 if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) { if (eflag) printf("%02x %02x ", p[0], p[1]); p += 2; hdrlength = 2; } if (eflag) printf("%d ", length); /* Retrieve the protocol type */ if (*p & 01) { /* Compressed protocol field */ ptype = *p; if (eflag) printf("%02x ", ptype); p++; hdrlength += 1; } else { /* Un-compressed protocol field */ ptype = ntohs(*(u_int16_t *)p); if (eflag) printf("%04x ", ptype); p += 2; hdrlength += 2; } #else ptype = 0; /*XXX*/ if (eflag) printf("%c ", p[SLC_DIR] ? 'O' : 'I'); if (p[SLC_LLHL]) { /* link level header */ struct ppp_header *ph; q = p + SLC_BPFHDRLEN; ph = (struct ppp_header *)q; if (ph->phdr_addr == PPP_ADDRESS && ph->phdr_ctl == PPP_CONTROL) { if (eflag) printf("%02x %02x ", q[0], q[1]); ptype = ntohs(ph->phdr_type); if (eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) { printf("%s ", tok2str(ppptype2str, "proto-#%d", ptype)); } } else { if (eflag) { printf("LLH=["); for (i = 0; i < p[SLC_LLHL]; i++) printf("%02x", q[i]); printf("] "); } } } if (eflag) printf("%d ", length); if (p[SLC_CHL]) { q = p + SLC_BPFHDRLEN + p[SLC_LLHL]; switch (ptype) { case PPP_VJC: ptype = vjc_print(q, length - (q - p), ptype); hdrlength = PPP_BSDI_HDRLEN; p += hdrlength; switch (ptype) { case PPP_IP: ip_print(p, length); break; #ifdef INET6 case PPP_IPV6: ip6_print(p, length); break; #endif } goto printx; case PPP_VJNC: ptype = vjc_print(q, length - (q - p), ptype); hdrlength = PPP_BSDI_HDRLEN; p += hdrlength; switch (ptype) { case PPP_IP: ip_print(p, length); break; #ifdef INET6 case PPP_IPV6: ip6_print(p, length); break; #endif } goto printx; default: if (eflag) { printf("CH=["); for (i = 0; i < p[SLC_LLHL]; i++) printf("%02x", q[i]); printf("] "); } break; } } hdrlength = PPP_BSDI_HDRLEN; #endif length -= hdrlength; p += hdrlength; switch (ptype) { case PPP_IP: ip_print(p, length); break; #ifdef INET6 case PPP_IPV6: ip6_print(p, length); break; #endif default: printf("%s ", tok2str(ppptype2str, "proto-#%d", ptype)); } printx: if (xflag) default_print((const u_char *)p, caplen - hdrlength); out: putchar('\n'); --infodelay; if (infoprint) info(0); #endif /* __bsdi__ */ } tcpdump-3.7.2/print-pppoe.c0100644000076500000240000001320207321133731014757 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.15 2001/07/05 18:54:17 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ppp.h" #include "ethertype.h" #include "ether.h" #include "extract.h" /* must come after interface.h */ /* Codes */ enum { PPPOE_PADI = 0x09, PPPOE_PADO = 0x07, PPPOE_PADR = 0x19, PPPOE_PADS = 0x65, PPPOE_PADT = 0xa7 }; static struct tok pppoecode2str[] = { { PPPOE_PADI, "PADI" }, { PPPOE_PADO, "PADO" }, { PPPOE_PADR, "PADR" }, { PPPOE_PADS, "PADS" }, { PPPOE_PADT, "PADT" }, { 0, "" }, /* PPP Data */ { 0, NULL } }; /* Tags */ enum { PPPOE_EOL = 0, PPPOE_SERVICE_NAME = 0x0101, PPPOE_AC_NAME = 0x0102, PPPOE_HOST_UNIQ = 0x0103, PPPOE_AC_COOKIE = 0x0104, PPPOE_VENDOR = 0x0105, PPPOE_RELAY_SID = 0x0110, PPPOE_SERVICE_NAME_ERROR = 0x0201, PPPOE_AC_SYSTEM_ERROR = 0x0202, PPPOE_GENERIC_ERROR = 0x0203 }; static struct tok pppoetag2str[] = { { PPPOE_EOL, "EOL" }, { PPPOE_SERVICE_NAME, "Service-Name" }, { PPPOE_AC_NAME, "AC-Name" }, { PPPOE_HOST_UNIQ, "Host-Uniq" }, { PPPOE_AC_COOKIE, "AC-Cookie" }, { PPPOE_VENDOR, "Vendor-Specific" }, { PPPOE_RELAY_SID, "Relay-Session-ID" }, { PPPOE_SERVICE_NAME_ERROR, "Service-Name-Error" }, { PPPOE_AC_SYSTEM_ERROR, "AC-System-Error" }, { PPPOE_GENERIC_ERROR, "Generic-Error" }, { 0, NULL } }; #define PPPOE_HDRLEN 6 void pppoe_if_print(u_char *user, const struct pcap_pkthdr *h, register const u_char *p) { register u_int length = h->len; register u_int caplen = h->caplen; ++infodelay; ts_print(&h->ts); /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; pppoe_print(p, length); putchar('\n'); --infodelay; if (infoprint) info(0); } void pppoe_print(register const u_char *bp, u_int length) { u_short pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid, pppoe_length; const u_char *pppoe_packet, *pppoe_payload; pppoe_packet = bp; if (pppoe_packet > snapend) { printf("[|pppoe]"); return; } pppoe_ver = (pppoe_packet[0] & 0xF0) >> 4; pppoe_type = (pppoe_packet[0] & 0x0F); pppoe_code = pppoe_packet[1]; pppoe_sessionid = EXTRACT_16BITS(pppoe_packet + 2); pppoe_length = EXTRACT_16BITS(pppoe_packet + 4); pppoe_payload = pppoe_packet + PPPOE_HDRLEN; if (snapend < pppoe_payload) { printf(" truncated PPPoE"); return; } if (pppoe_ver != 1) { printf(" [ver %d]",pppoe_ver); } if (pppoe_type != 1) { printf(" [type %d]",pppoe_type); } printf("PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code)); if (pppoe_code == PPPOE_PADI && pppoe_length > 1484 - PPPOE_HDRLEN) { printf(" [len %d!]",pppoe_length); } if (pppoe_sessionid) { printf(" [ses 0x%x]", pppoe_sessionid); } if (pppoe_payload + pppoe_length < snapend) { #if 0 const u_char *x = pppoe_payload + pppoe_length; printf(" [length %d (%d extra bytes)]", pppoe_length, snapend - pppoe_payload - pppoe_length); default_print(x, snapend - x); #endif snapend = pppoe_payload+pppoe_length; } if (pppoe_code) { /* PPP session packets don't contain tags */ u_short tag_type = 0xffff, tag_len; const u_char *p = pppoe_payload; /* * loop invariant: * p points to next tag, * tag_type is previous tag or 0xffff for first iteration */ while (tag_type && p + 4 < pppoe_payload + length && p + 4 < snapend) { tag_type = EXTRACT_16BITS(p); tag_len = EXTRACT_16BITS(p + 2); p += 4; /* p points to tag_value */ if (tag_len) { int isascii = 1; const u_char *v = p; u_short l; for (v = p; v < p + tag_len; v++) if (*v >= 127 || *v < 32) { isascii = 0; break; } /* TODO print UTF8 decoded text */ if (isascii) { l = (tag_len < 80 ? tag_len : 80); printf(" [%s \"%*.*s\"]", tok2str(pppoetag2str, "TAG-0x%x", tag_type), l, l, p); } else printf(" [%s UTF8]", tok2str(pppoetag2str, "TAG-0x%x", tag_type)); } else printf(" [%s]", tok2str(pppoetag2str, "TAG-0x%x", tag_type)); p += tag_len; /* p points to next tag */ } } else { printf(" "); ppp_print(pppoe_payload, pppoe_length); } return; } tcpdump-3.7.2/print-pptp.c0100644000076500000240000005671007367736107014652 0ustar fennerstaff/* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net) */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.3 2001/10/31 08:54:31 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "interface.h" static char tstr[] = " [|pptp]"; #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #define PPTP_MSG_TYPE_CTRL 1 /* Control Message */ #define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */ #define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */ #define PPTP_CTRL_MSG_TYPE_SCCRQ 1 #define PPTP_CTRL_MSG_TYPE_SCCRP 2 #define PPTP_CTRL_MSG_TYPE_StopCCRQ 3 #define PPTP_CTRL_MSG_TYPE_StopCCRP 4 #define PPTP_CTRL_MSG_TYPE_ECHORQ 5 #define PPTP_CTRL_MSG_TYPE_ECHORP 6 #define PPTP_CTRL_MSG_TYPE_OCRQ 7 #define PPTP_CTRL_MSG_TYPE_OCRP 8 #define PPTP_CTRL_MSG_TYPE_ICRQ 9 #define PPTP_CTRL_MSG_TYPE_ICRP 10 #define PPTP_CTRL_MSG_TYPE_ICCN 11 #define PPTP_CTRL_MSG_TYPE_CCRQ 12 #define PPTP_CTRL_MSG_TYPE_CDN 13 #define PPTP_CTRL_MSG_TYPE_WEN 14 #define PPTP_CTRL_MSG_TYPE_SLI 15 #define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Aynchronous */ #define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */ #define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */ #define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */ static char *pptp_message_type_string[] = { "NOT_DEFINED", /* 0 Not defined in the RFC2637 */ "SCCRQ", /* 1 Start-Control-Connection-Request */ "SCCRP", /* 2 Start-Control-Connection-Reply */ "StopCCRQ", /* 3 Stop-Control-Connection-Request */ "StopCCRP", /* 4 Stop-Control-Connection-Reply */ "ECHORQ", /* 5 Echo Request */ "ECHORP", /* 6 Echo Reply */ "OCRQ", /* 7 Outgoing-Call-Request */ "OCRP", /* 8 Outgoing-Call-Reply */ "ICRQ", /* 9 Incoming-Call-Request */ "ICRP", /* 10 Incoming-Call-Reply */ "ICCN", /* 11 Incoming-Call-Connected */ "CCRQ", /* 12 Call-Clear-Request */ "CDN", /* 13 Call-Disconnect-Notify */ "WEN", /* 14 WAN-Error-Notify */ "SLI" /* 15 Set-Link-Info */ #define PPTP_MAX_MSGTYPE_INDEX 16 }; /* common for all PPTP control messages */ struct pptp_hdr { u_int16_t length; u_int16_t msg_type; u_int32_t magic_cookie; u_int16_t ctrl_msg_type; u_int16_t reserved0; }; struct pptp_msg_sccrq { u_int16_t proto_ver; u_int16_t reserved1; u_int32_t framing_cap; u_int32_t bearer_cap; u_int16_t max_channel; u_int16_t firm_rev; u_char hostname[64]; u_char vendor[64]; }; struct pptp_msg_sccrp { u_int16_t proto_ver; u_int8_t result_code; u_int8_t err_code; u_int32_t framing_cap; u_int32_t bearer_cap; u_int16_t max_channel; u_int16_t firm_rev; u_char hostname[64]; u_char vendor[64]; }; struct pptp_msg_stopccrq { u_int8_t reason; u_int8_t reserved1; u_int16_t reserved2; }; struct pptp_msg_stopccrp { u_int8_t result_code; u_int8_t err_code; u_int16_t reserved1; }; struct pptp_msg_echorq { u_int32_t id; }; struct pptp_msg_echorp { u_int32_t id; u_int8_t result_code; u_int8_t err_code; u_int16_t reserved1; }; struct pptp_msg_ocrq { u_int16_t call_id; u_int16_t call_ser; u_int32_t min_bps; u_int32_t max_bps; u_int32_t bearer_type; u_int32_t framing_type; u_int16_t recv_winsiz; u_int16_t pkt_proc_delay; u_int16_t phone_no_len; u_int16_t reserved1; u_char phone_no[64]; u_char subaddr[64]; }; struct pptp_msg_ocrp { u_int16_t call_id; u_int16_t peer_call_id; u_int8_t result_code; u_int8_t err_code; u_int16_t cause_code; u_int32_t conn_speed; u_int16_t recv_winsiz; u_int16_t pkt_proc_delay; u_int32_t phy_chan_id; }; struct pptp_msg_icrq { u_int16_t call_id; u_int16_t call_ser; u_int32_t bearer_type; u_int32_t phy_chan_id; u_int16_t dialed_no_len; u_int16_t dialing_no_len; u_char dialed_no[64]; /* DNIS */ u_char dialing_no[64]; /* CLID */ u_char subaddr[64]; }; struct pptp_msg_icrp { u_int16_t call_id; u_int16_t peer_call_id; u_int8_t result_code; u_int8_t err_code; u_int16_t recv_winsiz; u_int16_t pkt_proc_delay; u_int16_t reserved1; }; struct pptp_msg_iccn { u_int16_t peer_call_id; u_int16_t reserved1; u_int32_t conn_speed; u_int16_t recv_winsiz; u_int16_t pkt_proc_delay; u_int32_t framing_type; }; struct pptp_msg_ccrq { u_int16_t call_id; u_int16_t reserved1; }; struct pptp_msg_cdn { u_int16_t call_id; u_int8_t result_code; u_int8_t err_code; u_int16_t cause_code; u_int16_t reserved1; u_char call_stats[128]; }; struct pptp_msg_wen { u_int16_t peer_call_id; u_int16_t reserved1; u_int32_t crc_err; u_int32_t framing_err; u_int32_t hardware_overrun; u_int32_t buffer_overrun; u_int32_t timeout_err; u_int32_t align_err; }; struct pptp_msg_sli { u_int16_t peer_call_id; u_int16_t reserved1; u_int32_t send_accm; u_int32_t recv_accm; }; /* attributes that appear more than once in above messages: Number of occurence attributes -------------------------------------- 2 u_int32_t bearer_cap; 2 u_int32_t bearer_type; 6 u_int16_t call_id; 2 u_int16_t call_ser; 2 u_int16_t cause_code; 2 u_int32_t conn_speed; 6 u_int8_t err_code; 2 u_int16_t firm_rev; 2 u_int32_t framing_cap; 2 u_int32_t framing_type; 2 u_char hostname[64]; 2 u_int32_t id; 2 u_int16_t max_channel; 5 u_int16_t peer_call_id; 2 u_int32_t phy_chan_id; 4 u_int16_t pkt_proc_delay; 2 u_int16_t proto_ver; 4 u_int16_t recv_winsiz; 2 u_int8_t reserved1; 9 u_int16_t reserved1; 6 u_int8_t result_code; 2 u_char subaddr[64]; 2 u_char vendor[64]; so I will prepare print out functions for these attributes (except for reserved*). */ /******************************************/ /* Attribute-specific print out functions */ /******************************************/ /* In these attribute-specific print-out functions, it't not necessary to do TCHECK because they are already checked in the caller of these functions. */ static void pptp_bearer_cap_print(const u_int32_t *bearer_cap) { printf(" BEARER_CAP("); if (ntohl(*bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) { printf("D"); } if (ntohl(*bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) { printf("A"); } printf(")"); } static void pptp_bearer_type_print(const u_int32_t *bearer_type) { printf(" BEARER_TYPE("); switch (ntohl(*bearer_type)) { case 1: printf("A"); /* Analog */ break; case 2: printf("D"); /* Digital */ break; case 3: printf("Any"); break; default: printf("?"); break; } printf(")"); } static void pptp_call_id_print(const u_int16_t *call_id) { printf(" CALL_ID(%u)", ntohs(*call_id)); } static void pptp_call_ser_print(const u_int16_t *call_ser) { printf(" CALL_SER_NUM(%u)", ntohs(*call_ser)); } static void pptp_cause_code_print(const u_int16_t *cause_code) { printf(" CAUSE_CODE(%u)", ntohs(*cause_code)); } static void pptp_conn_speed_print(const u_int32_t *conn_speed) { printf(" CONN_SPEED(%lu)", (unsigned long)ntohl(*conn_speed)); } static void pptp_err_code_print(const u_int8_t *err_code) { printf(" ERR_CODE(%u", *err_code); if (vflag) { switch (*err_code) { case 0: printf(":None"); break; case 1: printf(":Not-Connected"); break; case 2: printf(":Bad-Format"); break; case 3: printf(":Bad-Valude"); break; case 4: printf(":No-Resource"); break; case 5: printf(":Bad-Call-ID"); break; case 6: printf(":PAC-Error"); break; default: printf(":?"); break; } } printf(")"); } static void pptp_firm_rev_print(const u_int16_t *firm_rev) { printf(" FIRM_REV(%u)", ntohs(*firm_rev)); } static void pptp_framing_cap_print(const u_int32_t *framing_cap) { printf(" FRAME_CAP("); if (ntohl(*framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) { printf("A"); /* Async */ } if (ntohl(*framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) { printf("S"); /* Sync */ } printf(")"); } static void pptp_framing_type_print(const u_int32_t *framing_type) { printf(" FRAME_TYPE("); switch (ntohl(*framing_type)) { case 1: printf("A"); /* Async */ break; case 2: printf("S"); /* Sync */ break; case 3: printf("E"); /* Either */ break; default: printf("?"); break; } printf(")"); } static void pptp_hostname_print(const u_char *hostname) { printf(" HOSTNAME(%.64s)", hostname); } static void pptp_id_print(const u_int32_t *id) { printf(" ID(%lu)", (unsigned long)ntohl(*id)); } static void pptp_max_channel_print(const u_int16_t *max_channel) { printf(" MAX_CHAN(%u)", ntohs(*max_channel)); } static void pptp_peer_call_id_print(const u_int16_t *peer_call_id) { printf(" PEER_CALL_ID(%u)", ntohs(*peer_call_id)); } static void pptp_phy_chan_id_print(const u_int32_t *phy_chan_id) { printf(" PHY_CHAN_ID(%lu)", (unsigned long)ntohl(*phy_chan_id)); } static void pptp_pkt_proc_delay_print(const u_int16_t *pkt_proc_delay) { printf(" PROC_DELAY(%u)", ntohs(*pkt_proc_delay)); } static void pptp_proto_ver_print(const u_int16_t *proto_ver) { printf(" PROTO_VER(%u.%u)", /* Version.Revision */ ntohs(*proto_ver) >> 8, ntohs(*proto_ver) & 0xff); } static void pptp_recv_winsiz_print(const u_int16_t *recv_winsiz) { printf(" RECV_WIN(%u)", ntohs(*recv_winsiz)); } static void pptp_result_code_print(const u_int8_t *result_code, int ctrl_msg_type) { printf(" RESULT_CODE(%u", *result_code); if (vflag) { switch (ctrl_msg_type) { case PPTP_CTRL_MSG_TYPE_SCCRP: switch (*result_code) { case 1: printf(":Successful channel establishment"); break; case 2: printf(":General error"); break; case 3: printf(":Command channel already exists"); break; case 4: printf(":Requester is not authorized to establish a command channel"); break; case 5: printf(":The protocol version of the requester is not supported"); break; default: printf(":?"); break; } break; case PPTP_CTRL_MSG_TYPE_StopCCRP: case PPTP_CTRL_MSG_TYPE_ECHORP: switch (*result_code) { case 1: printf(":OK"); break; case 2: printf(":General Error"); break; default: printf(":?"); break; } break; case PPTP_CTRL_MSG_TYPE_OCRP: switch (*result_code) { case 1: printf(":Connected"); break; case 2: printf(":General Error"); break; case 3: printf(":No Carrier"); break; case 4: printf(":Busy"); break; case 5: printf(":No Dial Tone"); break; case 6: printf(":Time-out"); break; case 7: printf(":Do Not Accept"); break; default: printf(":?"); break; } break; case PPTP_CTRL_MSG_TYPE_ICRP: switch (*result_code) { case 1: printf(":Connect"); break; case 2: printf(":General Error"); break; case 3: printf(":Do Not Accept"); break; default: printf(":?"); break; } break; case PPTP_CTRL_MSG_TYPE_CDN: switch (*result_code) { case 1: printf(":Lost Carrier"); break; case 2: printf(":General Error"); break; case 3: printf(":Admin Shutdown"); break; case 4: printf(":Request"); default: printf(":?"); break; break; } default: /* assertion error */ break; } } printf(")"); } static void pptp_subaddr_print(const u_char *subaddr) { printf(" SUB_ADDR(%.64s)", subaddr); } static void pptp_vendor_print(const u_char *vendor) { printf(" VENDOR(%.64s)", vendor); } /************************************/ /* PPTP message print out functions */ /************************************/ static void pptp_sccrq_print(const u_char *dat) { struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat; TCHECK(ptr->proto_ver); pptp_proto_ver_print(&ptr->proto_ver); TCHECK(ptr->reserved1); TCHECK(ptr->framing_cap); pptp_framing_cap_print(&ptr->framing_cap); TCHECK(ptr->bearer_cap); pptp_bearer_cap_print(&ptr->bearer_cap); TCHECK(ptr->max_channel); pptp_max_channel_print(&ptr->max_channel); TCHECK(ptr->firm_rev); pptp_firm_rev_print(&ptr->firm_rev); TCHECK(ptr->hostname); pptp_hostname_print(&ptr->hostname[0]); TCHECK(ptr->vendor); pptp_vendor_print(&ptr->vendor[0]); return; trunc: printf("%s", tstr); } static void pptp_sccrp_print(const u_char *dat) { struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat; TCHECK(ptr->proto_ver); pptp_proto_ver_print(&ptr->proto_ver); TCHECK(ptr->result_code); pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP); TCHECK(ptr->err_code); pptp_err_code_print(&ptr->err_code); TCHECK(ptr->framing_cap); pptp_framing_cap_print(&ptr->framing_cap); TCHECK(ptr->bearer_cap); pptp_bearer_cap_print(&ptr->bearer_cap); TCHECK(ptr->max_channel); pptp_max_channel_print(&ptr->max_channel); TCHECK(ptr->firm_rev); pptp_firm_rev_print(&ptr->firm_rev); TCHECK(ptr->hostname); pptp_hostname_print(&ptr->hostname[0]); TCHECK(ptr->vendor); pptp_vendor_print(&ptr->vendor[0]); return; trunc: printf("%s", tstr); } static void pptp_stopccrq_print(const u_char *dat) { struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat; TCHECK(ptr->reason); printf(" REASON(%u", ptr->reason); if (vflag) { switch (ptr->reason) { case 1: printf(":None"); break; case 2: printf(":Stop-Protocol"); break; case 3: printf(":Stop-Local-Shutdown"); break; default: printf(":?"); break; } } printf(")"); TCHECK(ptr->reserved1); TCHECK(ptr->reserved2); return; trunc: printf("%s", tstr); } static void pptp_stopccrp_print(const u_char *dat) { struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat; TCHECK(ptr->result_code); pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP); TCHECK(ptr->err_code); pptp_err_code_print(&ptr->err_code); TCHECK(ptr->reserved1); return; trunc: printf("%s", tstr); } static void pptp_echorq_print(const u_char *dat) { struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat; TCHECK(ptr->id); pptp_id_print(&ptr->id); return; trunc: printf("%s", tstr); } static void pptp_echorp_print(const u_char *dat) { struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat; TCHECK(ptr->id); pptp_id_print(&ptr->id); TCHECK(ptr->result_code); pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP); TCHECK(ptr->err_code); pptp_err_code_print(&ptr->err_code); TCHECK(ptr->reserved1); return; trunc: printf("%s", tstr); } static void pptp_ocrq_print(const u_char *dat) { struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat; TCHECK(ptr->call_id); pptp_call_id_print(&ptr->call_id); TCHECK(ptr->call_ser); pptp_call_ser_print(&ptr->call_ser); TCHECK(ptr->min_bps); printf(" MIN_BPS(%lu)", (unsigned long)ntohl(ptr->min_bps)); TCHECK(ptr->max_bps); printf(" MAX_BPS(%lu)", (unsigned long)ntohl(ptr->max_bps)); TCHECK(ptr->bearer_type); pptp_bearer_type_print(&ptr->bearer_type); TCHECK(ptr->framing_type); pptp_framing_type_print(&ptr->framing_type); TCHECK(ptr->recv_winsiz); pptp_recv_winsiz_print(&ptr->recv_winsiz); TCHECK(ptr->pkt_proc_delay); pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay); TCHECK(ptr->phone_no_len); printf(" PHONE_NO_LEN(%u)", ntohs(ptr->phone_no_len)); TCHECK(ptr->reserved1); TCHECK(ptr->phone_no); printf(" PHONE_NO(%.64s)", ptr->phone_no); TCHECK(ptr->subaddr); pptp_subaddr_print(&ptr->subaddr[0]); return; trunc: printf("%s", tstr); } static void pptp_ocrp_print(const u_char *dat) { struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat; TCHECK(ptr->call_id); pptp_call_id_print(&ptr->call_id); TCHECK(ptr->peer_call_id); pptp_peer_call_id_print(&ptr->peer_call_id); TCHECK(ptr->result_code); pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP); TCHECK(ptr->err_code); pptp_err_code_print(&ptr->err_code); TCHECK(ptr->cause_code); pptp_cause_code_print(&ptr->cause_code); TCHECK(ptr->conn_speed); pptp_conn_speed_print(&ptr->conn_speed); TCHECK(ptr->recv_winsiz); pptp_recv_winsiz_print(&ptr->recv_winsiz); TCHECK(ptr->pkt_proc_delay); pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay); TCHECK(ptr->phy_chan_id); pptp_phy_chan_id_print(&ptr->phy_chan_id); return; trunc: printf("%s", tstr); } static void pptp_icrq_print(const u_char *dat) { struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat; TCHECK(ptr->call_id); pptp_call_id_print(&ptr->call_id); TCHECK(ptr->call_ser); pptp_call_ser_print(&ptr->call_ser); TCHECK(ptr->bearer_type); pptp_bearer_type_print(&ptr->bearer_type); TCHECK(ptr->phy_chan_id); pptp_phy_chan_id_print(&ptr->phy_chan_id); TCHECK(ptr->dialed_no_len); printf(" DIALED_NO_LEN(%u)", ntohs(ptr->dialed_no_len)); TCHECK(ptr->dialing_no_len); printf(" DIALING_NO_LEN(%u)", ntohs(ptr->dialing_no_len)); TCHECK(ptr->dialed_no); printf(" DIALED_NO(%.64s)", ptr->dialed_no); TCHECK(ptr->dialing_no); printf(" DIALING_NO(%.64s)", ptr->dialing_no); TCHECK(ptr->subaddr); pptp_subaddr_print(&ptr->subaddr[0]); return; trunc: printf("%s", tstr); } static void pptp_icrp_print(const u_char *dat) { struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat; TCHECK(ptr->call_id); pptp_call_id_print(&ptr->call_id); TCHECK(ptr->peer_call_id); pptp_peer_call_id_print(&ptr->peer_call_id); TCHECK(ptr->result_code); pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP); TCHECK(ptr->err_code); pptp_err_code_print(&ptr->err_code); TCHECK(ptr->recv_winsiz); pptp_recv_winsiz_print(&ptr->recv_winsiz); TCHECK(ptr->pkt_proc_delay); pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay); TCHECK(ptr->reserved1); return; trunc: printf("%s", tstr); } static void pptp_iccn_print(const u_char *dat) { struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat; TCHECK(ptr->peer_call_id); pptp_peer_call_id_print(&ptr->peer_call_id); TCHECK(ptr->reserved1); TCHECK(ptr->conn_speed); pptp_conn_speed_print(&ptr->conn_speed); TCHECK(ptr->recv_winsiz); pptp_recv_winsiz_print(&ptr->recv_winsiz); TCHECK(ptr->pkt_proc_delay); pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay); TCHECK(ptr->framing_type); pptp_framing_type_print(&ptr->framing_type); return; trunc: printf("%s", tstr); } static void pptp_ccrq_print(const u_char *dat) { struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat; TCHECK(ptr->call_id); pptp_call_id_print(&ptr->call_id); TCHECK(ptr->reserved1); return; trunc: printf("%s", tstr); } static void pptp_cdn_print(const u_char *dat) { struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat; TCHECK(ptr->call_id); pptp_call_id_print(&ptr->call_id); TCHECK(ptr->result_code); pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN); TCHECK(ptr->err_code); pptp_err_code_print(&ptr->err_code); TCHECK(ptr->cause_code); pptp_cause_code_print(&ptr->cause_code); TCHECK(ptr->reserved1); TCHECK(ptr->call_stats); printf(" CALL_STATS(%.128s)", ptr->call_stats); return; trunc: printf("%s", tstr); } static void pptp_wen_print(const u_char *dat) { struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat; TCHECK(ptr->peer_call_id); pptp_peer_call_id_print(&ptr->peer_call_id); TCHECK(ptr->reserved1); TCHECK(ptr->crc_err); printf(" CRC_ERR(%lu)", (unsigned long)ntohl(ptr->crc_err)); TCHECK(ptr->framing_err); printf(" FRAMING_ERR(%lu)", (unsigned long)ntohl(ptr->framing_err)); TCHECK(ptr->hardware_overrun); printf(" HARDWARE_OVERRUN(%lu)", (unsigned long)ntohl(ptr->hardware_overrun)); TCHECK(ptr->buffer_overrun); printf(" BUFFER_OVERRUN(%lu)", (unsigned long)ntohl(ptr->buffer_overrun)); TCHECK(ptr->timeout_err); printf(" TIMEOUT_ERR(%lu)", (unsigned long)ntohl(ptr->timeout_err)); TCHECK(ptr->align_err); printf(" ALIGN_ERR(%lu)", (unsigned long)ntohl(ptr->align_err)); return; trunc: printf("%s", tstr); } static void pptp_sli_print(const u_char *dat) { struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat; TCHECK(ptr->peer_call_id); pptp_peer_call_id_print(&ptr->peer_call_id); TCHECK(ptr->reserved1); TCHECK(ptr->send_accm); printf(" SEND_ACCM(0x%08lx)", (unsigned long)ntohl(ptr->send_accm)); TCHECK(ptr->recv_accm); printf(" RECV_ACCM(0x%08lx)", (unsigned long)ntohl(ptr->recv_accm)); return; trunc: printf("%s", tstr); } void pptp_print(const u_char *dat, u_int length) { const struct pptp_hdr *hdr; u_int32_t mc; u_int16_t ctrl_msg_type; printf(": pptp"); hdr = (struct pptp_hdr *)dat; TCHECK(hdr->length); if (vflag) { printf(" Length=%u", ntohs(hdr->length)); } TCHECK(hdr->msg_type); if (vflag) { switch(ntohs(hdr->msg_type)) { case PPTP_MSG_TYPE_CTRL: printf(" CTRL-MSG"); break; case PPTP_MSG_TYPE_MGMT: printf(" MGMT-MSG"); break; default: printf(" UNKNOWN-MSG-TYPE"); break; } } TCHECK(hdr->magic_cookie); mc = ntohl(hdr->magic_cookie); if (mc != PPTP_MAGIC_COOKIE) { printf(" UNEXPECTED Magic-Cookie!!(%08x)", mc); } if (vflag || mc != PPTP_MAGIC_COOKIE) { printf(" Magic-Cookie=%08x", mc); } TCHECK(hdr->ctrl_msg_type); ctrl_msg_type = ntohs(hdr->ctrl_msg_type); if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) { printf(" CTRL_MSGTYPE=%s", pptp_message_type_string[ctrl_msg_type]); } else { printf(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type); } TCHECK(hdr->reserved0); dat += 12; switch(ctrl_msg_type) { case PPTP_CTRL_MSG_TYPE_SCCRQ: pptp_sccrq_print(dat); break; case PPTP_CTRL_MSG_TYPE_SCCRP: pptp_sccrp_print(dat); break; case PPTP_CTRL_MSG_TYPE_StopCCRQ: pptp_stopccrq_print(dat); break; case PPTP_CTRL_MSG_TYPE_StopCCRP: pptp_stopccrp_print(dat); break; case PPTP_CTRL_MSG_TYPE_ECHORQ: pptp_echorq_print(dat); break; case PPTP_CTRL_MSG_TYPE_ECHORP: pptp_echorp_print(dat); break; case PPTP_CTRL_MSG_TYPE_OCRQ: pptp_ocrq_print(dat); break; case PPTP_CTRL_MSG_TYPE_OCRP: pptp_ocrp_print(dat); break; case PPTP_CTRL_MSG_TYPE_ICRQ: pptp_icrq_print(dat); break; case PPTP_CTRL_MSG_TYPE_ICRP: pptp_icrp_print(dat); break; case PPTP_CTRL_MSG_TYPE_ICCN: pptp_iccn_print(dat); break; case PPTP_CTRL_MSG_TYPE_CCRQ: pptp_ccrq_print(dat); break; case PPTP_CTRL_MSG_TYPE_CDN: pptp_cdn_print(dat); break; case PPTP_CTRL_MSG_TYPE_WEN: pptp_wen_print(dat); break; case PPTP_CTRL_MSG_TYPE_SLI: pptp_sli_print(dat); break; default: /* do nothing */ break; } return; trunc: printf("%s", tstr); } tcpdump-3.7.2/print-radius.c0100644000076500000240000007207107627054631015146 0ustar fennerstaff/* * Copyright (C) 2000 Alfredo Andres Omella. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* * Radius printer routines as specified on: * * RFC 2865: * "Remote Authentication Dial In User Service (RADIUS)" * * RFC 2866: * "RADIUS Accounting" * * RFC 2867: * "RADIUS Accounting Modifications for Tunnel Protocol Support" * * RFC 2868: * "RADIUS Attributes for Tunnel Protocol Support" * * RFC 2869: * "RADIUS Extensions" * * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15 * * TODO: Among other things to print ok MacIntosh and Vendor values */ #ifndef lint static const char rcsid[] = "$Id: print-radius.c,v 1.10.2.2 2002/07/03 16:35:04 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #include "interface.h" #include "addrtoname.h" #include "extract.h" #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) ) #define PRINT_HEX(bytes_len, ptr_data) \ while(bytes_len) \ { \ printf("%02X", *ptr_data ); \ ptr_data++; \ bytes_len--; \ } /* Radius packet codes */ #define RADCMD_ACCESS_REQ 1 /* Access-Request */ #define RADCMD_ACCESS_ACC 2 /* Access-Accept */ #define RADCMD_ACCESS_REJ 3 /* Access-Reject */ #define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */ #define RADCMD_ACCOUN_RES 5 /* Accounting-Response */ #define RADCMD_ACCESS_CHA 11 /* Access-Challenge */ #define RADCMD_STATUS_SER 12 /* Status-Server */ #define RADCMD_STATUS_CLI 13 /* Status-Client */ #define RADCMD_RESERVED 255 /* Reserved */ /********************************/ /* Begin Radius Attribute types */ /********************************/ #define SERV_TYPE 6 #define FRM_IPADDR 8 #define LOG_IPHOST 14 #define LOG_SERVICE 15 #define FRM_IPX 23 #define SESSION_TIMEOUT 27 #define IDLE_TIMEOUT 28 #define FRM_ATALK_LINK 37 #define FRM_ATALK_NETWORK 38 #define ACCT_DELAY 41 #define ACCT_SESSION_TIME 46 #define TUNNEL_TYPE 64 #define TUNNEL_MEDIUM 65 #define TUNNEL_CLIENT_END 66 #define TUNNEL_SERVER_END 67 #define TUNNEL_PASS 69 #define ARAP_PASS 70 #define ARAP_FEATURES 71 #define TUNNEL_PRIV_GROUP 81 #define TUNNEL_ASSIGN_ID 82 #define TUNNEL_PREFERENCE 83 #define ARAP_CHALLENGE_RESP 84 #define ACCT_INT_INTERVAL 85 #define TUNNEL_CLIENT_AUTH 90 #define TUNNEL_SERVER_AUTH 91 /********************************/ /* End Radius Attribute types */ /********************************/ static void print_attr_string(register u_char *, u_int, u_short ); static void print_attr_num(register u_char *, u_int, u_short ); static void print_attr_address(register u_char *, u_int, u_short); static void print_attr_time(register u_char *, u_int, u_short); static void print_attr_strange(register u_char *, u_int, u_short); struct radius_hdr { u_int8_t code; /* Radius packet code */ u_int8_t id; /* Radius packet id */ u_int16_t len; /* Radius total length */ u_int8_t auth[16]; /* Authenticator */ }; #define MIN_RADIUS_LEN 20 struct radius_attr { u_int8_t type; /* Attribute type */ u_int8_t len; /* Attribute length */ }; /* Service-Type Attribute standard values */ static const char *serv_type[]={ NULL, "Login", "Framed", "Callback Login", "Callback Framed", "Outbound", "Administrative", "NAS Prompt", "Authenticate Only", "Callback NAS Prompt", "Call Check", "Callback Administrative", }; /* Framed-Protocol Attribute standard values */ static const char *frm_proto[]={ NULL, "PPP", "SLIP", "ARAP", "Gandalf proprietary", "Xylogics IPX/SLIP", "X.75 Synchronous", }; /* Framed-Routing Attribute standard values */ static const char *frm_routing[]={ "None", "Send", "Listen", "Send&Listen", }; /* Framed-Compression Attribute standard values */ static const char *frm_comp[]={ "None", "VJ TCP/IP", "IPX", "Stac-LZS", }; /* Login-Service Attribute standard values */ static const char *login_serv[]={ "Telnet", "Rlogin", "TCP Clear", "PortMaster(proprietary)", "LAT", "X.25-PAD", "X.25-T3POS", "Unassigned", "TCP Clear Quiet", }; /* Termination-Action Attribute standard values */ static const char *term_action[]={ "Default", "RADIUS-Request", }; /* NAS-Port-Type Attribute standard values */ static const char *nas_port_type[]={ "Async", "Sync", "ISDN Sync", "ISDN Async V.120", "ISDN Async V.110", "Virtual", "PIAFS", "HDLC Clear Channel", "X.25", "X.75", "G.3 Fax", "SDSL", "ADSL-CAP", "ADSL-DMT", "ISDN-DSL", "Ethernet", "xDSL", "Cable", "Wireless - Other", "Wireless - IEEE 802.11", }; /* Acct-Status-Type Accounting Attribute standard values */ static const char *acct_status[]={ NULL, "Start", "Stop", "Interim-Update", "Unassigned", "Unassigned", "Unassigned", "Accounting-On", "Accounting-Off", "Tunnel-Start", "Tunnel-Stop", "Tunnel-Reject", "Tunnel-Link-Start", "Tunnel-Link-Stop", "Tunnel-Link-Reject", "Failed", }; /* Acct-Authentic Accounting Attribute standard values */ static const char *acct_auth[]={ NULL, "RADIUS", "Local", "Remote", }; /* Acct-Terminate-Cause Accounting Attribute standard values */ static const char *acct_term[]={ NULL, "User Request", "Lost Carrier", "Lost Service", "Idle Timeout", "Session Timeout", "Admin Reset", "Admin Reboot", "Port Error", "NAS Error", "NAS Request", "NAS Reboot", "Port Unneeded", "Port Preempted", "Port Suspended", "Service Unavailable", "Callback", "User Error", "Host Request", }; /* Tunnel-Type Attribute standard values */ static const char *tunnel_type[]={ NULL, "PPTP", "L2F", "L2TP", "ATMP", "VTP", "AH", "IP-IP", "MIN-IP-IP", "ESP", "GRE", "DVS", "IP-in-IP Tunneling", }; /* Tunnel-Medium-Type Attribute standard values */ static const char *tunnel_medium[]={ NULL, "IPv4", "IPv6", "NSAP", "HDLC", "BBN 1822", "802", "E.163", "E.164", "F.69", "X.121", "IPX", "Appletalk", "Decnet IV", "Banyan Vines", "E.164 with NSAP subaddress", }; /* ARAP-Zone-Access Attribute standard values */ static const char *arap_zone[]={ NULL, "Only access to dfl zone", "Use zone filter inc.", "Not used", "Use zone filter exc.", }; static const char *prompt[]={ "No Echo", "Echo", }; struct attrtype { char *name; /* Attribute name */ const char **subtypes; /* Standard Values (if any) */ u_char siz_subtypes; /* Size of total standard values */ u_char first_subtype; /* First standard value is 0 or 1 */ void (*print_func)(register u_char *, u_int, u_short ); } attr_type[]= { { NULL, NULL, 0, 0, NULL }, { "User", NULL, 0, 0, print_attr_string }, { "Pass", NULL, 0, 0, NULL }, { "CHAP-Pass", NULL, 0, 0, NULL }, { "NAS_ipaddr", NULL, 0, 0, print_attr_address }, { "NAS_port", NULL, 0, 0, print_attr_num }, { "Service_type", serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num }, { "Framed_proto", frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num }, { "Framed_ipaddr", NULL, 0, 0, print_attr_address }, { "Framed_ipnet", NULL, 0, 0, print_attr_address }, { "Framed_routing", frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num }, { "Filter_id", NULL, 0, 0, print_attr_string }, { "Framed_mtu", NULL, 0, 0, print_attr_num }, { "Framed_compress", frm_comp, TAM_SIZE(frm_comp), 0, print_attr_num }, { "Login_iphost", NULL, 0, 0, print_attr_address }, { "Login_service", login_serv, TAM_SIZE(login_serv), 0, print_attr_num }, { "Login_TCP_port", NULL, 0, 0, print_attr_num }, /*17*/ { "Unassigned", NULL, 0, 0, NULL }, { "Reply", NULL, 0, 0, print_attr_string }, { "Callback-number", NULL, 0, 0, print_attr_string }, { "Callback-id", NULL, 0, 0, print_attr_string }, /*21*/ { "Unassigned", NULL, 0, 0, NULL }, { "Framed_route", NULL, 0, 0, print_attr_string }, { "Framed_ipx_net", NULL, 0, 0, print_attr_num }, { "State", NULL, 0, 0, print_attr_string }, { "Class", NULL, 0, 0, print_attr_string }, { "Vendor_specific", NULL, 0, 0, print_attr_string }, { "Session_timeout", NULL, 0, 0, print_attr_num }, { "Idle_timeout", NULL, 0, 0, print_attr_num }, { "Term_action", term_action, TAM_SIZE(term_action), 0, print_attr_num }, { "Called_station", NULL, 0, 0, print_attr_string }, { "Calling_station", NULL, 0, 0, print_attr_string }, { "NAS_id", NULL, 0, 0, print_attr_string }, { "Proxy_state", NULL, 0, 0, print_attr_string }, { "Login_LAT_service", NULL, 0, 0, print_attr_string }, { "Login_LAT_node", NULL, 0, 0, print_attr_string }, { "Login_LAT_group", NULL, 0, 0, print_attr_string }, { "Framed_atalk_link", NULL, 0, 0, print_attr_num }, { "Framed_atalk_net", NULL, 0, 0, print_attr_num }, { "Framed_atalk_zone", NULL, 0, 0, print_attr_string }, { "Acct_status", acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num }, { "Acct_delay", NULL, 0, 0, print_attr_num }, { "Acct_in_octets", NULL, 0, 0, print_attr_num }, { "Acct_out_octets", NULL, 0, 0, print_attr_num }, { "Acct_session_id", NULL, 0, 0, print_attr_string }, { "Acct_authentic", acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num }, { "Acct_session_time", NULL, 0, 0, print_attr_num }, { "Acct_in_packets", NULL, 0, 0, print_attr_num }, { "Acct_out_packets", NULL, 0, 0, print_attr_num }, { "Acct_term_cause", acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num }, { "Acct_multi_session_id", NULL, 0, 0, print_attr_string }, { "Acct_link_count", NULL, 0, 0, print_attr_num }, { "Acct_in_giga", NULL, 0, 0, print_attr_num }, { "Acct_out_giga", NULL, 0, 0, print_attr_num }, /*54*/ { "Unassigned", NULL, 0, 0, NULL }, { "Event_timestamp", NULL, 0, 0, print_attr_time }, /*56*/ { "Unassigned", NULL, 0, 0, NULL }, /*57*/ { "Unassigned", NULL, 0, 0, NULL }, /*58*/ { "Unassigned", NULL, 0, 0, NULL }, /*59*/ { "Unassigned", NULL, 0, 0, NULL }, { "CHAP_challenge", NULL, 0, 0, print_attr_string }, { "NAS_port_type", nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num }, { "Port_limit", NULL, 0, 0, print_attr_num }, /*63*/ { "Login_LAT_port", NULL, 0, 0, print_attr_string }, { "Tunnel_type", tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num }, { "Tunnel_medium", tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num }, { "Tunnel_client_end", NULL, 0, 0, print_attr_string }, { "Tunnel_server_end", NULL, 0, 0, print_attr_string }, { "Acct_tunnel_connect", NULL, 0, 0, print_attr_string }, { "Tunnel_pass", NULL, 0, 0, print_attr_string }, { "ARAP_pass", NULL, 0, 0, print_attr_strange }, { "ARAP_feature", NULL, 0, 0, print_attr_strange }, /*72*/ { "ARAP_zone_acces", arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, { "ARAP_security", NULL, 0, 0, print_attr_string }, { "ARAP_security_data", NULL, 0, 0, print_attr_string }, { "Password_retry", NULL, 0, 0, print_attr_num }, { "Prompt", prompt, TAM_SIZE(prompt), 0, print_attr_num }, { "Connect_info", NULL, 0, 0, print_attr_string }, { "Config_token", NULL, 0, 0, print_attr_string }, { "EAP_msg", NULL, 0, 0, print_attr_string }, /*80*/ { "Message_auth", NULL, 0, 0, print_attr_string }, { "Tunnel_priv_group", NULL, 0, 0, print_attr_string }, { "Tunnel_assign_id", NULL, 0, 0, print_attr_string }, { "Tunnel_pref", NULL, 0, 0, print_attr_num }, { "ARAP_challenge_resp", NULL, 0, 0, print_attr_strange }, { "Acct_interim_interval", NULL, 0, 0, print_attr_num }, /*86*/ { "Acct_tunnel_pack_lost", NULL, 0, 0, print_attr_num }, { "NAS_port_id", NULL, 0, 0, print_attr_string }, { "Framed_pool", NULL, 0, 0, print_attr_string }, { "Unassigned", NULL, 0, 0, NULL }, { "Tunnel_client_auth_id", NULL, 0, 0, print_attr_string }, { "Tunnel_server_auth_id", NULL, 0, 0, print_attr_string }, /*92*/ { "Unassigned", NULL, 0, 0, NULL }, /*93*/ { "Unassigned", NULL, 0, 0, NULL } }; /*****************************/ /* Print an attribute string */ /* value pointed by 'data' */ /* and 'length' size. */ /*****************************/ /* Returns nothing. */ /*****************************/ static void print_attr_string(register u_char *data, u_int length, u_short attr_code ) { register u_int i; TCHECK2(data[0],length); printf("{"); switch(attr_code) { case TUNNEL_PASS: if (*data && (*data <=0x1F) ) printf("Tag[%d] ",*data); data++; printf("Salt[%d] ",EXTRACT_16BITS(data) ); data+=2; length-=2; break; case TUNNEL_CLIENT_END: case TUNNEL_SERVER_END: case TUNNEL_PRIV_GROUP: case TUNNEL_ASSIGN_ID: case TUNNEL_CLIENT_AUTH: case TUNNEL_SERVER_AUTH: if (*data <= 0x1F) { printf("Tag[%d] ",*data); data++; length--; } break; } for (i=0; i < length ; i++, data++) printf("%c",(*data < 32 || *data > 128) ? '.' : *data ); printf("}"); return; trunc: printf("|radius"); } /******************************/ /* Print an attribute numeric */ /* value pointed by 'data' */ /* and 'length' size. */ /******************************/ /* Returns nothing. */ /******************************/ static void print_attr_num(register u_char *data, u_int length, u_short attr_code ) { u_int8_t tag; u_int32_t timeout; if (length != 4) { printf("{length %u != 4}", length); return; } TCHECK2(data[0],4); /* This attribute has standard values */ if (attr_type[attr_code].siz_subtypes) { static const char **table; u_int32_t data_value; table = attr_type[attr_code].subtypes; if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) ) { if (!*data) printf("{Tag[Unused]"); else printf("{Tag[%d]", *data); data++; data_value = EXTRACT_24BITS(data); } else { data_value = EXTRACT_32BITS(data); } if ( data_value <= (attr_type[attr_code].siz_subtypes - 1 + attr_type[attr_code].first_subtype) && data_value >= attr_type[attr_code].first_subtype ) printf("{%s}",table[data_value]); else printf("{#%d}",data_value); } else { switch(attr_code) /* Be aware of special cases... */ { case FRM_IPX: if (EXTRACT_32BITS( data) == 0xFFFFFFFE ) printf("{NAS_select}"); else printf("{%d}",EXTRACT_32BITS( data) ); break; case SESSION_TIMEOUT: case IDLE_TIMEOUT: case ACCT_DELAY: case ACCT_SESSION_TIME: case ACCT_INT_INTERVAL: timeout = EXTRACT_32BITS( data); if ( timeout < 60 ) printf( "{%02d secs}", timeout); else { if ( timeout < 3600 ) printf( "{%02d:%02d min}", timeout / 60, timeout % 60); else printf( "{%02d:%02d:%02d hours}", timeout / 3600, (timeout % 3600) / 60, timeout % 60); } break; case FRM_ATALK_LINK: if (EXTRACT_32BITS(data) ) printf("{%d}",EXTRACT_32BITS(data) ); else printf("{Unnumbered}" ); break; case FRM_ATALK_NETWORK: if (EXTRACT_32BITS(data) ) printf("{%d}",EXTRACT_32BITS(data) ); else printf("{NAS_assign}" ); break; case TUNNEL_PREFERENCE: tag = *data; data++; if (tag == 0) printf("{Tag[Unused] %d}",EXTRACT_24BITS(data) ); else printf("{Tag[%d] %d}", tag, EXTRACT_24BITS(data) ); break; default: printf("{%d}",EXTRACT_32BITS( data) ); break; } /* switch */ } /* if-else */ return; trunc: printf("|radius}"); } /*****************************/ /* Print an attribute IPv4 */ /* address value pointed by */ /* 'data' and 'length' size. */ /*****************************/ /* Returns nothing. */ /*****************************/ static void print_attr_address(register u_char *data, u_int length, u_short attr_code ) { if (length != 4) { printf("{length %u != 4}", length); return; } TCHECK2(data[0],4); switch(attr_code) { case FRM_IPADDR: case LOG_IPHOST: if (EXTRACT_32BITS(data) == 0xFFFFFFFF ) printf("{User_select}"); else if (EXTRACT_32BITS(data) == 0xFFFFFFFE ) printf("{NAS_select}"); else printf("{%s}",ipaddr_string(data)); break; default: printf("{%s}",ipaddr_string(data) ); break; } return; trunc: printf("{|radius}"); } /*************************************/ /* Print an attribute of 'secs since */ /* January 1, 1970 00:00 UTC' value */ /* pointed by 'data' and 'length' */ /* size. */ /*************************************/ /* Returns nothing. */ /*************************************/ static void print_attr_time(register u_char *data, u_int length, u_short attr_code) { time_t attr_time; char string[26]; if (length != 4) { printf("{length %u != 4}", length); return; } TCHECK2(data[0],4); attr_time = EXTRACT_32BITS(data); strlcpy(string, ctime(&attr_time), sizeof(string)); /* Get rid of the newline */ string[24] = '\0'; printf("{%.24s}", string); return; trunc: printf("{|radius}"); } /***********************************/ /* Print an attribute of 'strange' */ /* data format pointed by 'data' */ /* and 'length' size. */ /***********************************/ /* Returns nothing. */ /***********************************/ static void print_attr_strange(register u_char *data, u_int length, u_short attr_code) { u_short len_data; switch(attr_code) { case ARAP_PASS: if (length != 16) { printf("{length %u != 16}", length); return; } printf("{User_challenge["); TCHECK2(data[0],8); len_data = 8; PRINT_HEX(len_data, data); printf("] User_resp["); TCHECK2(data[0],8); len_data = 8; PRINT_HEX(len_data, data); printf("]}"); break; case ARAP_FEATURES: if (length != 14) { printf("{length %u != 14}", length); return; } TCHECK2(data[0],1); if (*data) printf("{User_can_change_pass"); else printf("{User_cant_change_pass"); data++; TCHECK2(data[0],1); printf(" Min_pass_len[%d]",*data); data++; printf(" Pass_created_at["); TCHECK2(data[0],4); len_data = 4; PRINT_HEX(len_data, data); printf("] Pass_expired_in["); TCHECK2(data[0],4); len_data = 4; PRINT_HEX(len_data, data); printf("] Current_time["); len_data = 4; TCHECK2(data[0],4); PRINT_HEX(len_data, data); printf("]}"); break; case ARAP_CHALLENGE_RESP: if (length < 8) { printf("{length %u != 8}", length); return; } printf("{"); TCHECK2(data[0],8); len_data = 8; PRINT_HEX(len_data, data); printf("}"); break; } trunc: printf("|radius}"); } static void radius_attr_print(register const u_char *attr, u_int length) { register const struct radius_attr *rad_attr = (struct radius_attr *)attr; if (length < 3) { printf(" [|radius]"); return; } printf(" Attr[ "); while (length > 0) { if (rad_attr->len == 0) { printf("(zero-length attribute)"); return; } if ( rad_attr->len <= length ) { if ( !rad_attr->type || (rad_attr->type > (TAM_SIZE(attr_type)-1)) ) printf("#%d",rad_attr->type); else { printf(" %s",attr_type[rad_attr->type].name); if (rad_attr->len > 2) { if ( attr_type[rad_attr->type].print_func ) (*attr_type[rad_attr->type].print_func)( ((u_char *)(rad_attr+1)), rad_attr->len - 2, rad_attr->type); } } } else { printf(" [|radius]"); return; } length-=(rad_attr->len); rad_attr = (struct radius_attr *)( ((char *)(rad_attr))+rad_attr->len); } printf(" ]"); } void radius_print(const u_char *dat, u_int length) { register const struct radius_hdr *rad; register int i; int len; i = min(length, snapend - dat); if (i < MIN_RADIUS_LEN) { printf(" [|radius]"); return; } rad = (struct radius_hdr *)dat; len = ntohs(rad->len); if (len < MIN_RADIUS_LEN) { printf(" [|radius]"); return; } if (len < i) i = len; i -= MIN_RADIUS_LEN; switch (rad->code) { case RADCMD_ACCESS_REQ: printf(" rad-access-req %d", length); break; case RADCMD_ACCESS_ACC: printf(" rad-access-accept %d", length); break; case RADCMD_ACCESS_REJ: printf(" rad-access-reject %d", length); break; case RADCMD_ACCOUN_REQ: printf(" rad-account-req %d", length); break; case RADCMD_ACCOUN_RES: printf(" rad-account-resp %d", length); break; case RADCMD_ACCESS_CHA: printf(" rad-access-cha %d", length); break; case RADCMD_STATUS_SER: printf(" rad-status-serv %d", length); break; case RADCMD_STATUS_CLI: printf(" rad-status-cli %d", length); break; case RADCMD_RESERVED: printf(" rad-reserved %d", length); break; default: printf(" rad-#%d %d", rad->code, length); break; } printf(" [id %d]", rad->id); if (i) radius_attr_print( dat + MIN_RADIUS_LEN, i); } tcpdump-3.7.2/print-raw.c0100644000076500000240000000423507627054631014445 0ustar fennerstaff/* * Copyright (c) 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.34.4.1 2002/06/01 23:51:15 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "addrtoname.h" #include "interface.h" /* * The DLT_RAW packet has no header. It contains a raw IP packet. */ void raw_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int length = h->len; u_int caplen = h->caplen; ++infodelay; ts_print(&h->ts); /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; if (eflag) printf("ip: "); ipN_print(p, length); if (xflag) default_print(p, caplen); putchar('\n'); --infodelay; if (infoprint) info(0); } tcpdump-3.7.2/print-rip.c0100644000076500000240000001464207276423556014457 0ustar fennerstaff/* * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.49 2001/05/10 05:30:22 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ struct rip { u_char rip_cmd; /* request/response */ u_char rip_vers; /* protocol version # */ u_short rip_zero2; /* unused */ }; #define RIPCMD_REQUEST 1 /* want info */ #define RIPCMD_RESPONSE 2 /* responding to request */ #define RIPCMD_TRACEON 3 /* turn tracing on */ #define RIPCMD_TRACEOFF 4 /* turn it off */ #define RIPCMD_POLL 5 /* want info from everybody */ #define RIPCMD_POLLENTRY 6 /* poll for entry */ #define RIP_AUTHLEN 16 struct rip_netinfo { u_short rip_family; u_short rip_tag; u_int32_t rip_dest; u_int32_t rip_dest_mask; u_int32_t rip_router; u_int32_t rip_metric; /* cost of route */ }; static void rip_printblk(const u_char *cp, const u_char *ep) { for (; cp < ep; cp += 2) printf(" %04x", EXTRACT_16BITS(cp)); return; } static void rip_entry_print_v1(register int vers, register const struct rip_netinfo *ni) { register u_short family; /* RFC 1058 */ family = EXTRACT_16BITS(&ni->rip_family); if (family != AF_INET) { printf(" [family %d:", family); rip_printblk((u_char *)&ni->rip_tag, (u_char *)&ni->rip_metric + sizeof(ni->rip_metric)); printf("]"); return; } if (ni->rip_tag || ni->rip_dest_mask || ni->rip_router) { /* MBZ fields not zero */ printf(" ["); rip_printblk((u_char *)&ni->rip_family, (u_char *)&ni->rip_metric + sizeof(ni->rip_metric)); printf("]"); return; } printf(" {%s}(%d)", ipaddr_string(&ni->rip_dest), EXTRACT_32BITS(&ni->rip_metric)); } static void rip_entry_print_v2(register int vers, register const struct rip_netinfo *ni) { register u_char *p; register u_short family; u_char buf[RIP_AUTHLEN]; /* RFC 1723 */ family = EXTRACT_16BITS(&ni->rip_family); if (family == 0xFFFF) { if (EXTRACT_16BITS(&ni->rip_tag) == 2) { memcpy(buf, &ni->rip_dest, sizeof(buf)); buf[sizeof(buf)-1] = '\0'; for (p = buf; *p; p++) { if (!isprint(*p)) break; } if (!*p) { printf(" [password %s]", buf); } else { printf(" [password: "); rip_printblk((u_char *)&ni->rip_dest, (u_char *)&ni->rip_metric + sizeof(ni->rip_metric)); printf("]"); } } else { printf(" [auth %d:", EXTRACT_16BITS(&ni->rip_tag)); rip_printblk((u_char *)&ni->rip_dest, (u_char *)&ni->rip_metric + sizeof(ni->rip_metric)); printf("]"); } } else if (family != AF_INET) { printf(" [family %d:", family); rip_printblk((u_char *)&ni->rip_tag, (u_char *)&ni->rip_metric + sizeof(ni->rip_metric)); printf("]"); return; } else { /* AF_INET */ printf(" {%s", ipaddr_string(&ni->rip_dest)); if (ni->rip_dest_mask) printf("/%s", ipaddr_string(&ni->rip_dest_mask)); if (ni->rip_router) printf("->%s", ipaddr_string(&ni->rip_router)); if (ni->rip_tag) printf(" tag %04x", EXTRACT_16BITS(&ni->rip_tag)); printf("}(%d)", EXTRACT_32BITS(&ni->rip_metric)); } } void rip_print(const u_char *dat, u_int length) { register const struct rip *rp; register const struct rip_netinfo *ni; register int i, j, trunc; i = min(length, snapend - dat) - sizeof(*rp); if (i < 0) { printf(" [|rip]"); return; } rp = (struct rip *)dat; switch (rp->rip_vers) { case 0: /* * RFC 1058. * * XXX - RFC 1058 says * * 0 Datagrams whose version number is zero are to be ignored. * These are from a previous version of the protocol, whose * packet format was machine-specific. * * so perhaps we should just dump the first few words of * the packet, in hex. */ printf(" RIPv0: "); ni = (struct rip_netinfo *)(rp + 1); rip_printblk((u_char *)&ni->rip_family, (u_char *)&ni->rip_metric + sizeof(ni->rip_metric)); break; default: switch (rp->rip_cmd) { case RIPCMD_REQUEST: printf(" RIPv%d-req %d", rp->rip_vers, length); break; case RIPCMD_RESPONSE: j = length / sizeof(*ni); if (j * sizeof(*ni) != length - 4) printf(" RIPv%d-resp [items %d] [%d]:", rp->rip_vers, j, length); else printf(" RIPv%d-resp [items %d]:", rp->rip_vers, j); trunc = (i / sizeof(*ni)) != j; ni = (struct rip_netinfo *)(rp + 1); for (; (i -= sizeof(*ni)) >= 0; ++ni) { if (rp->rip_vers == 1) rip_entry_print_v1(rp->rip_vers, ni); else rip_entry_print_v2(rp->rip_vers, ni); } if (trunc) printf("[|rip]"); break; case RIPCMD_TRACEON: printf(" RIPv%d-traceon %d: \"", rp->rip_vers, length); (void)fn_print((const u_char *)(rp + 1), snapend); fputs("\"", stdout); break; case RIPCMD_TRACEOFF: printf(" RIPv%d-traceoff %d", rp->rip_vers, length); break; case RIPCMD_POLL: printf(" RIPv%d-poll %d", rp->rip_vers, length); break; case RIPCMD_POLLENTRY: printf(" RIPv%d-pollentry %d", rp->rip_vers, length); break; default: printf(" RIPv%d-#%d %d", rp->rip_vers, rp->rip_cmd, length); break; } } } tcpdump-3.7.2/print-ripng.c0100644000076500000240000000653307375152552014777 0ustar fennerstaff/* * Copyright (c) 1989, 1990, 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.10 2001/11/16 08:59:22 itojun Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef INET6 #include #include #include #include #include #include #include #include "route6d.h" #include "interface.h" #include "addrtoname.h" static int rip6_entry_print(register const struct netinfo6 *ni, int metric) { int l; l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen); if (ni->rip6_tag) l += printf(" [%d]", ntohs(ni->rip6_tag)); if (metric) l += printf(" (%d)", ni->rip6_metric); return l; } void ripng_print(const u_char *dat, unsigned int length) { register const struct rip6 *rp = (struct rip6 *)dat; register const struct netinfo6 *ni; register int amt = snapend - dat; register int i = min(length, amt) - (sizeof(struct rip6) - sizeof(struct netinfo6)); int j; int trunc; if (i < 0) return; switch (rp->rip6_cmd) { case RIP6_REQUEST: j = length / sizeof(*ni); if (j == 1 && rp->rip6_nets->rip6_metric == HOPCNT_INFINITY6 && IN6_IS_ADDR_UNSPECIFIED(&rp->rip6_nets->rip6_dest)) { printf(" ripng-req dump"); break; } if (j * sizeof(*ni) != length - 4) printf(" ripng-req %d[%u]:", j, length); else printf(" ripng-req %d:", j); trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i); for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) { if (vflag > 1) printf("\n\t"); else printf(" "); rip6_entry_print(ni, 0); } break; case RIP6_RESPONSE: j = length / sizeof(*ni); if (j * sizeof(*ni) != length - 4) printf(" ripng-resp %d[%u]:", j, length); else printf(" ripng-resp %d:", j); trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i); for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) { if (vflag > 1) printf("\n\t"); else printf(" "); rip6_entry_print(ni, ni->rip6_metric); } if (trunc) printf("[|ripng]"); break; default: printf(" ripng-%d ?? %u", rp->rip6_cmd, length); break; } if (rp->rip6_vers != RIP6_VERSION) printf(" [vers %d]", rp->rip6_vers); } #endif /* INET6 */ tcpdump-3.7.2/print-rt6.c0100644000076500000240000000547707312504576014377 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.18 2001/06/15 22:17:34 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef INET6 #include #include #include #include #include #include #include "ip6.h" #include "interface.h" #include "addrtoname.h" int rt6_print(register const u_char *bp, register const u_char *bp2) { register const struct ip6_rthdr *dp; register const struct ip6_rthdr0 *dp0; register const struct ip6_hdr *ip; register const u_char *ep; int i, len; register const struct in6_addr *addr; dp = (struct ip6_rthdr *)bp; ip = (struct ip6_hdr *)bp2; len = dp->ip6r_len; /* 'ep' points to the end of available data. */ ep = snapend; TCHECK(dp->ip6r_segleft); printf("srcrt (len=%d", dp->ip6r_len); /*)*/ printf(", type=%d", dp->ip6r_type); printf(", segleft=%d", dp->ip6r_segleft); switch (dp->ip6r_type) { #ifndef IPV6_RTHDR_TYPE_0 #define IPV6_RTHDR_TYPE_0 0 #endif case IPV6_RTHDR_TYPE_0: dp0 = (struct ip6_rthdr0 *)dp; TCHECK(dp0->ip6r0_reserved); if (dp0->ip6r0_reserved || vflag) { printf(", rsv=0x%0x", (u_int32_t)ntohl(dp0->ip6r0_reserved)); } if (len % 2 == 1) goto trunc; len >>= 1; addr = &dp0->ip6r0_addr[0]; for (i = 0; i < len; i++) { if ((u_char *)(addr + 1) > ep) goto trunc; printf(", [%d]%s", i, ip6addr_string(addr)); addr++; } /*(*/ printf(") "); return((dp0->ip6r0_len + 1) << 3); break; default: goto trunc; break; } trunc: fputs("[|srcrt]", stdout); return 65535; /* XXX */ } #endif /* INET6 */ tcpdump-3.7.2/print-rx.c0100644000076500000240000015627407627054632014321 0ustar fennerstaff/* * Copyright: (c) 2000 United States Government as represented by the * Secretary of the Navy. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* * This code unmangles RX packets. RX is the mutant form of RPC that AFS * uses to communicate between clients and servers. * * In this code, I mainly concern myself with decoding the AFS calls, not * with the guts of RX, per se. * * Bah. If I never look at rx_packet.h again, it will be too soon. * * Ken Hornstein */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.27.2.2 2002/07/10 07:17:57 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" #include "rx.h" #include "ip.h" static struct tok rx_types[] = { { RX_PACKET_TYPE_DATA, "data" }, { RX_PACKET_TYPE_ACK, "ack" }, { RX_PACKET_TYPE_BUSY, "busy" }, { RX_PACKET_TYPE_ABORT, "abort" }, { RX_PACKET_TYPE_ACKALL, "ackall" }, { RX_PACKET_TYPE_CHALLENGE, "challenge" }, { RX_PACKET_TYPE_RESPONSE, "response" }, { RX_PACKET_TYPE_DEBUG, "debug" }, { RX_PACKET_TYPE_PARAMS, "params" }, { RX_PACKET_TYPE_VERSION, "version" }, { 0, NULL }, }; static struct double_tok { int flag; /* Rx flag */ int packetType; /* Packet type */ char *s; /* Flag string */ } rx_flags[] = { { RX_CLIENT_INITIATED, 0, "client-init" }, { RX_REQUEST_ACK, 0, "req-ack" }, { RX_LAST_PACKET, 0, "last-pckt" }, { RX_MORE_PACKETS, 0, "more-pckts" }, { RX_FREE_PACKET, 0, "free-pckt" }, { RX_SLOW_START_OK, RX_PACKET_TYPE_ACK, "slow-start" }, { RX_JUMBO_PACKET, RX_PACKET_TYPE_DATA, "jumbogram" } }; static struct tok fs_req[] = { { 130, "fetch-data" }, { 131, "fetch-acl" }, { 132, "fetch-status" }, { 133, "store-data" }, { 134, "store-acl" }, { 135, "store-status" }, { 136, "remove-file" }, { 137, "create-file" }, { 138, "rename" }, { 139, "symlink" }, { 140, "link" }, { 141, "makedir" }, { 142, "rmdir" }, { 143, "oldsetlock" }, { 144, "oldextlock" }, { 145, "oldrellock" }, { 146, "get-stats" }, { 147, "give-cbs" }, { 148, "get-vlinfo" }, { 149, "get-vlstats" }, { 150, "set-vlstats" }, { 151, "get-rootvl" }, { 152, "check-token" }, { 153, "get-time" }, { 154, "nget-vlinfo" }, { 155, "bulk-stat" }, { 156, "setlock" }, { 157, "extlock" }, { 158, "rellock" }, { 159, "xstat-ver" }, { 160, "get-xstat" }, { 161, "dfs-lookup" }, { 162, "dfs-flushcps" }, { 163, "dfs-symlink" }, { 220, "residency" }, { 0, NULL }, }; static struct tok cb_req[] = { { 204, "callback" }, { 205, "initcb" }, { 206, "probe" }, { 207, "getlock" }, { 208, "getce" }, { 209, "xstatver" }, { 210, "getxstat" }, { 211, "initcb2" }, { 212, "whoareyou" }, { 213, "initcb3" }, { 214, "probeuuid" }, { 215, "getsrvprefs" }, { 216, "getcellservdb" }, { 217, "getlocalcell" }, { 218, "getcacheconf" }, { 0, NULL }, }; static struct tok pt_req[] = { { 500, "new-user" }, { 501, "where-is-it" }, { 502, "dump-entry" }, { 503, "add-to-group" }, { 504, "name-to-id" }, { 505, "id-to-name" }, { 506, "delete" }, { 507, "remove-from-group" }, { 508, "get-cps" }, { 509, "new-entry" }, { 510, "list-max" }, { 511, "set-max" }, { 512, "list-entry" }, { 513, "change-entry" }, { 514, "list-elements" }, { 515, "same-mbr-of" }, { 516, "set-fld-sentry" }, { 517, "list-owned" }, { 518, "get-cps2" }, { 519, "get-host-cps" }, { 520, "update-entry" }, { 521, "list-entries" }, { 0, NULL }, }; static struct tok vldb_req[] = { { 501, "create-entry" }, { 502, "delete-entry" }, { 503, "get-entry-by-id" }, { 504, "get-entry-by-name" }, { 505, "get-new-volume-id" }, { 506, "replace-entry" }, { 507, "update-entry" }, { 508, "setlock" }, { 509, "releaselock" }, { 510, "list-entry" }, { 511, "list-attrib" }, { 512, "linked-list" }, { 513, "get-stats" }, { 514, "probe" }, { 515, "get-addrs" }, { 516, "change-addr" }, { 517, "create-entry-n" }, { 518, "get-entry-by-id-n" }, { 519, "get-entry-by-name-n" }, { 520, "replace-entry-n" }, { 521, "list-entry-n" }, { 522, "list-attrib-n" }, { 523, "linked-list-n" }, { 524, "update-entry-by-name" }, { 525, "create-entry-u" }, { 526, "get-entry-by-id-u" }, { 527, "get-entry-by-name-u" }, { 528, "replace-entry-u" }, { 529, "list-entry-u" }, { 530, "list-attrib-u" }, { 531, "linked-list-u" }, { 532, "regaddr" }, { 533, "get-addrs-u" }, { 534, "list-attrib-n2" }, { 0, NULL }, }; static struct tok kauth_req[] = { { 1, "auth-old" }, { 21, "authenticate" }, { 22, "authenticate-v2" }, { 2, "change-pw" }, { 3, "get-ticket-old" }, { 23, "get-ticket" }, { 4, "set-pw" }, { 5, "set-fields" }, { 6, "create-user" }, { 7, "delete-user" }, { 8, "get-entry" }, { 9, "list-entry" }, { 10, "get-stats" }, { 11, "debug" }, { 12, "get-pw" }, { 13, "get-random-key" }, { 14, "unlock" }, { 15, "lock-status" }, { 0, NULL }, }; static struct tok vol_req[] = { { 100, "create-volume" }, { 101, "delete-volume" }, { 102, "restore" }, { 103, "forward" }, { 104, "end-trans" }, { 105, "clone" }, { 106, "set-flags" }, { 107, "get-flags" }, { 108, "trans-create" }, { 109, "dump" }, { 110, "get-nth-volume" }, { 111, "set-forwarding" }, { 112, "get-name" }, { 113, "get-status" }, { 114, "sig-restore" }, { 115, "list-partitions" }, { 116, "list-volumes" }, { 117, "set-id-types" }, { 118, "monitor" }, { 119, "partition-info" }, { 120, "reclone" }, { 121, "list-one-volume" }, { 122, "nuke" }, { 123, "set-date" }, { 124, "x-list-volumes" }, { 125, "x-list-one-volume" }, { 126, "set-info" }, { 127, "x-list-partitions" }, { 128, "forward-multiple" }, { 0, NULL }, }; static struct tok bos_req[] = { { 80, "create-bnode" }, { 81, "delete-bnode" }, { 82, "set-status" }, { 83, "get-status" }, { 84, "enumerate-instance" }, { 85, "get-instance-info" }, { 86, "get-instance-parm" }, { 87, "add-superuser" }, { 88, "delete-superuser" }, { 89, "list-superusers" }, { 90, "list-keys" }, { 91, "add-key" }, { 92, "delete-key" }, { 93, "set-cell-name" }, { 94, "get-cell-name" }, { 95, "get-cell-host" }, { 96, "add-cell-host" }, { 97, "delete-cell-host" }, { 98, "set-t-status" }, { 99, "shutdown-all" }, { 100, "restart-all" }, { 101, "startup-all" }, { 102, "set-noauth-flag" }, { 103, "re-bozo" }, { 104, "restart" }, { 105, "start-bozo-install" }, { 106, "uninstall" }, { 107, "get-dates" }, { 108, "exec" }, { 109, "prune" }, { 110, "set-restart-time" }, { 111, "get-restart-time" }, { 112, "start-bozo-log" }, { 113, "wait-all" }, { 114, "get-instance-strings" }, { 115, "get-restricted" }, { 116, "set-restricted" }, { 0, NULL }, }; static struct tok ubik_req[] = { { 10000, "vote-beacon" }, { 10001, "vote-debug-old" }, { 10002, "vote-sdebug-old" }, { 10003, "vote-getsyncsite" }, { 10004, "vote-debug" }, { 10005, "vote-sdebug" }, { 20000, "disk-begin" }, { 20001, "disk-commit" }, { 20002, "disk-lock" }, { 20003, "disk-write" }, { 20004, "disk-getversion" }, { 20005, "disk-getfile" }, { 20006, "disk-sendfile" }, { 20007, "disk-abort" }, { 20008, "disk-releaselocks" }, { 20009, "disk-truncate" }, { 20010, "disk-probe" }, { 20011, "disk-writev" }, { 20012, "disk-interfaceaddr" }, { 20013, "disk-setversion" }, { 0, NULL }, }; #define VOTE_LOW 10000 #define VOTE_HIGH 10005 #define DISK_LOW 20000 #define DISK_HIGH 20013 static struct tok cb_types[] = { { 1, "exclusive" }, { 2, "shared" }, { 3, "dropped" }, { 0, NULL }, }; static struct tok ubik_lock_types[] = { { 1, "read" }, { 2, "write" }, { 3, "wait" }, { 0, NULL }, }; static char *voltype[] = { "read-write", "read-only", "backup" }; static struct tok afs_fs_errors[] = { { 101, "salvage volume" }, { 102, "no such vnode" }, { 103, "no such volume" }, { 104, "volume exist" }, { 105, "no service" }, { 106, "volume offline" }, { 107, "voline online" }, { 108, "diskfull" }, { 109, "diskquota exceeded" }, { 110, "volume busy" }, { 111, "volume moved" }, { 112, "AFS IO error" }, { -100, "restarting fileserver" }, { 0, NULL } }; /* * Reasons for acknowledging a packet */ static struct tok rx_ack_reasons[] = { { 1, "ack requested" }, { 2, "duplicate packet" }, { 3, "out of sequence" }, { 4, "exceeds window" }, { 5, "no buffer space" }, { 6, "ping" }, { 7, "ping response" }, { 8, "delay" }, { 0, NULL }, }; /* * Cache entries we keep around so we can figure out the RX opcode * numbers for replies. This allows us to make sense of RX reply packets. */ struct rx_cache_entry { u_int32_t callnum; /* Call number (net order) */ struct in_addr client; /* client IP address (net order) */ struct in_addr server; /* server IP address (net order) */ int dport; /* server port (host order) */ u_short serviceId; /* Service identifier (net order) */ u_int32_t opcode; /* RX opcode (host order) */ }; #define RX_CACHE_SIZE 64 static struct rx_cache_entry rx_cache[RX_CACHE_SIZE]; static int rx_cache_next = 0; static int rx_cache_hint = 0; static void rx_cache_insert(const u_char *, const struct ip *, int, int); static int rx_cache_find(const struct rx_header *, const struct ip *, int, int32_t *); static void ack_print(const u_char *, int); static void fs_print(const u_char *, int); static void fs_reply_print(const u_char *, int, int32_t); static void acl_print(u_char *, int, u_char *); static void cb_print(const u_char *, int); static void cb_reply_print(const u_char *, int, int32_t); static void prot_print(const u_char *, int); static void prot_reply_print(const u_char *, int, int32_t); static void vldb_print(const u_char *, int); static void vldb_reply_print(const u_char *, int, int32_t); static void kauth_print(const u_char *, int); static void kauth_reply_print(const u_char *, int, int32_t); static void vol_print(const u_char *, int); static void vol_reply_print(const u_char *, int, int32_t); static void bos_print(const u_char *, int); static void bos_reply_print(const u_char *, int, int32_t); static void ubik_print(const u_char *, int); static void ubik_reply_print(const u_char *, int, int32_t); static void rx_ack_print(const u_char *, int); static int is_ubik(u_int32_t); /* * Handle the rx-level packet. See if we know what port it's going to so * we can peek at the afs call inside */ void rx_print(register const u_char *bp, int length, int sport, int dport, u_char *bp2) { register struct rx_header *rxh; int i; int32_t opcode; if (snapend - bp < sizeof (struct rx_header)) { printf(" [|rx] (%d)", length); return; } rxh = (struct rx_header *) bp; printf(" rx %s", tok2str(rx_types, "type %d", rxh->type)); if (vflag) { int firstflag = 0; if (vflag > 1) printf(" cid %08x call# %d", (int) EXTRACT_32BITS(&rxh->cid), (int) EXTRACT_32BITS(&rxh->callNumber)); printf(" seq %d ser %d", (int) EXTRACT_32BITS(&rxh->seq), (int) EXTRACT_32BITS(&rxh->serial)); if (vflag > 2) printf(" secindex %d serviceid %hu", (int) rxh->securityIndex, EXTRACT_16BITS(&rxh->serviceId)); if (vflag > 1) for (i = 0; i < NUM_RX_FLAGS; i++) { if (rxh->flags & rx_flags[i].flag && (!rx_flags[i].packetType || rxh->type == rx_flags[i].packetType)) { if (!firstflag) { firstflag = 1; printf(" "); } else { printf(","); } printf("<%s>", rx_flags[i].s); } } } /* * Try to handle AFS calls that we know about. Check the destination * port and make sure it's a data packet. Also, make sure the * seq number is 1 (because otherwise it's a continuation packet, * and we can't interpret that). Also, seems that reply packets * do not have the client-init flag set, so we check for that * as well. */ if (rxh->type == RX_PACKET_TYPE_ACK) ack_print(bp, length); else if (rxh->type == RX_PACKET_TYPE_DATA && EXTRACT_32BITS(&rxh->seq) == 1 && rxh->flags & RX_CLIENT_INITIATED) { /* * Insert this call into the call cache table, so we * have a chance to print out replies */ rx_cache_insert(bp, (const struct ip *) bp2, dport, length); switch (dport) { case FS_RX_PORT: /* AFS file service */ fs_print(bp, length); break; case CB_RX_PORT: /* AFS callback service */ cb_print(bp, length); break; case PROT_RX_PORT: /* AFS protection service */ prot_print(bp, length); break; case VLDB_RX_PORT: /* AFS VLDB service */ vldb_print(bp, length); break; case KAUTH_RX_PORT: /* AFS Kerberos auth service */ kauth_print(bp, length); break; case VOL_RX_PORT: /* AFS Volume service */ vol_print(bp, length); break; case BOS_RX_PORT: /* AFS BOS service */ bos_print(bp, length); break; default: ; } /* * If it's a reply (client-init is _not_ set, but seq is one) * then look it up in the cache. If we find it, call the reply * printing functions Note that we handle abort packets here, * because printing out the return code can be useful at times. */ } else if (((rxh->type == RX_PACKET_TYPE_DATA && EXTRACT_32BITS(&rxh->seq) == 1) || rxh->type == RX_PACKET_TYPE_ABORT) && (rxh->flags & RX_CLIENT_INITIATED) == 0 && rx_cache_find(rxh, (const struct ip *) bp2, sport, &opcode)) { switch (sport) { case FS_RX_PORT: /* AFS file service */ fs_reply_print(bp, length, opcode); break; case CB_RX_PORT: /* AFS callback service */ cb_reply_print(bp, length, opcode); break; case PROT_RX_PORT: /* AFS PT service */ prot_reply_print(bp, length, opcode); break; case VLDB_RX_PORT: /* AFS VLDB service */ vldb_reply_print(bp, length, opcode); break; case KAUTH_RX_PORT: /* AFS Kerberos auth service */ kauth_reply_print(bp, length, opcode); break; case VOL_RX_PORT: /* AFS Volume service */ vol_reply_print(bp, length, opcode); break; case BOS_RX_PORT: /* AFS BOS service */ bos_reply_print(bp, length, opcode); break; default: ; } /* * If it's an RX ack packet, then use the appropriate ack decoding * function (there isn't any service-specific information in the * ack packet, so we can use one for all AFS services) */ } else if (rxh->type == RX_PACKET_TYPE_ACK) rx_ack_print(bp, length); printf(" (%d)", length); } /* * Insert an entry into the cache. Taken from print-nfs.c */ static void rx_cache_insert(const u_char *bp, const struct ip *ip, int dport, int length) { struct rx_cache_entry *rxent; const struct rx_header *rxh = (const struct rx_header *) bp; if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) return; rxent = &rx_cache[rx_cache_next]; if (++rx_cache_next >= RX_CACHE_SIZE) rx_cache_next = 0; rxent->callnum = rxh->callNumber; rxent->client = ip->ip_src; rxent->server = ip->ip_dst; rxent->dport = dport; rxent->serviceId = rxh->serviceId; rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header)); } /* * Lookup an entry in the cache. Also taken from print-nfs.c * * Note that because this is a reply, we're looking at the _source_ * port. */ static int rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport, int32_t *opcode) { int i; struct rx_cache_entry *rxent; u_int32_t clip = ip->ip_dst.s_addr; u_int32_t sip = ip->ip_src.s_addr; /* Start the search where we last left off */ i = rx_cache_hint; do { rxent = &rx_cache[i]; if (rxent->callnum == rxh->callNumber && rxent->client.s_addr == clip && rxent->server.s_addr == sip && rxent->serviceId == rxh->serviceId && rxent->dport == sport) { /* We got a match! */ rx_cache_hint = i; *opcode = rxent->opcode; return(1); } if (++i > RX_CACHE_SIZE) i = 0; } while (i != rx_cache_hint); /* Our search failed */ return(0); } /* * These extrememly grody macros handle the printing of various AFS stuff. */ #define FIDOUT() { unsigned long n1, n2, n3; \ TCHECK2(bp[0], sizeof(int32_t) * 3); \ n1 = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ n2 = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ n3 = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \ } #define STROUT(MAX) { unsigned int i; \ TCHECK2(bp[0], sizeof(int32_t)); \ i = EXTRACT_32BITS(bp); \ if (i > (MAX)) \ goto trunc; \ bp += sizeof(int32_t); \ printf(" \""); \ if (fn_printn(bp, i, snapend)) \ goto trunc; \ printf("\""); \ bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \ } #define INTOUT() { int i; \ TCHECK2(bp[0], sizeof(int32_t)); \ i = (int) EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ printf(" %d", i); \ } #define UINTOUT() { unsigned long i; \ TCHECK2(bp[0], sizeof(int32_t)); \ i = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ printf(" %lu", i); \ } #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \ TCHECK2(bp[0], sizeof(int32_t)); \ t = (time_t) EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ tm = localtime(&t); \ strftime(str, 256, "%Y/%m/%d %T", tm); \ printf(" %s", str); \ } #define STOREATTROUT() { unsigned long mask, i; \ TCHECK2(bp[0], (sizeof(int32_t)*6)); \ mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask) printf (" StoreStatus"); \ if (mask & 1) { printf(" date"); DATEOUT(); } \ else bp += sizeof(int32_t); \ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask & 2) printf(" owner %lu", i); \ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask & 4) printf(" group %lu", i); \ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask & 8) printf(" mode %lo", i & 07777); \ i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask & 16) printf(" segsize %lu", i); \ /* undocumented in 3.3 docu */ \ if (mask & 1024) printf(" fsync"); \ } #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \ TCHECK2(bp[0], sizeof(int32_t) * 2); \ epoch = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ counter = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ printf(" %d.%d", epoch, counter); \ } #define AFSUUIDOUT() {u_int32_t temp; int i; \ TCHECK2(bp[0], 11*sizeof(u_int32_t)); \ temp = EXTRACT_32BITS(bp); \ bp += sizeof(u_int32_t); \ printf(" %08x", temp); \ temp = EXTRACT_32BITS(bp); \ bp += sizeof(u_int32_t); \ printf("%04x", temp); \ temp = EXTRACT_32BITS(bp); \ bp += sizeof(u_int32_t); \ printf("%04x", temp); \ for (i = 0; i < 8; i++) { \ temp = EXTRACT_32BITS(bp); \ bp += sizeof(u_int32_t); \ printf("%02x", (unsigned char) temp); \ } \ } /* * This is the sickest one of all */ #define VECOUT(MAX) { u_char *sp; \ u_char s[AFSNAMEMAX]; \ int k; \ if ((MAX) + 1 > sizeof(s)) \ goto trunc; \ TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \ sp = s; \ for (k = 0; k < (MAX); k++) { \ *sp++ = (u_char) EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ } \ s[(MAX)] = '\0'; \ printf(" \""); \ fn_print(s, NULL); \ printf("\""); \ } static void ack_print(register const u_char *bp, int length) { u_char nAcks; int i; if (vflag <= 1) return; if (length <= sizeof(struct rx_header)) return; bp += sizeof(struct rx_header); /* * Packets < firstPacket are implicitly acknowledged and may * be discarded by the sender. * * Packets >= firstPacket+nAcks are implicitly NOT acknowledged. * * No packets with sequence numbers >= firstPacket should be * discarded by the sender (they may thrown out at any time by * the receiver) */ #define RX_ACK_REASONS "RDOXSprn" /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space, * Ping, ping_Response, No_{progress, particular_reason}. */ #if 0 struct rx_ackPacket { u_short bufferSpace; /* Skip! */ u_short maxSkew; /* Skip! */ u_long firstPacket; u_long previousPacket; /* Obsolete! */ u_long serial; /* Serial that prompted the ack, */ u_char reason; /* and the reason why. */ u_char nAcks; u_char acks[RX_MAXACKS]; /* Selective acks (not a bitmap). */ }; #endif #define RX_ACK_TYPE_NACK 0 TCHECK2(bp[0], 8); /* bufferSpace and maxSkew */ bp += 4; printf(" fir %u", (unsigned)EXTRACT_32BITS(bp)); bp += 4; TCHECK2(bp[0], 8); /* previousPacket and serial */ bp += 4; printf(" %u", (unsigned)EXTRACT_32BITS(bp)); bp += 4; TCHECK2(bp[0], 1); printf("%c", RX_ACK_REASONS[(*bp - 1) & 07u]); bp += 1; /* reason */ TCHECK2(bp[0], 1); nAcks = *bp; bp += 1; /* nAcks */ for (i = 0; i < nAcks; i++) { TCHECK2(bp[0], 1); putchar(*bp == RX_ACK_TYPE_NACK? '-' : '*'); bp += 1; } return; trunc: printf(" [|ack]"); } /* * Handle calls to the AFS file service (fs) */ static void fs_print(register const u_char *bp, int length) { int fs_op; unsigned long i; if (length <= sizeof(struct rx_header)) return; if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afsint.xg */ fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" fs call %s", tok2str(fs_req, "op#%d", fs_op)); /* * Print out arguments to some of the AFS calls. This stuff is * all from afsint.xg */ bp += sizeof(struct rx_header) + 4; /* * Sigh. This is gross. Ritchie forgive me. */ switch (fs_op) { case 130: /* Fetch data */ FIDOUT(); printf(" offset"); UINTOUT(); printf(" length"); UINTOUT(); break; case 131: /* Fetch ACL */ case 132: /* Fetch Status */ case 143: /* Old set lock */ case 144: /* Old extend lock */ case 145: /* Old release lock */ case 156: /* Set lock */ case 157: /* Extend lock */ case 158: /* Release lock */ FIDOUT(); break; case 135: /* Store status */ FIDOUT(); STOREATTROUT(); break; case 133: /* Store data */ FIDOUT(); STOREATTROUT(); printf(" offset"); UINTOUT(); printf(" length"); UINTOUT(); printf(" flen"); UINTOUT(); break; case 134: /* Store ACL */ { char a[AFSOPAQUEMAX+1]; FIDOUT(); TCHECK2(bp[0], 4); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); TCHECK2(bp[0], i); i = min(AFSOPAQUEMAX, i); strncpy(a, (char *) bp, i); a[i] = '\0'; acl_print((u_char *) a, sizeof(a), (u_char *) a + i); break; } case 137: /* Create file */ case 141: /* MakeDir */ FIDOUT(); STROUT(AFSNAMEMAX); STOREATTROUT(); break; case 136: /* Remove file */ case 142: /* Remove directory */ FIDOUT(); STROUT(AFSNAMEMAX); break; case 138: /* Rename file */ printf(" old"); FIDOUT(); STROUT(AFSNAMEMAX); printf(" new"); FIDOUT(); STROUT(AFSNAMEMAX); break; case 139: /* Symlink */ FIDOUT(); STROUT(AFSNAMEMAX); printf(" link to"); STROUT(AFSNAMEMAX); break; case 140: /* Link */ FIDOUT(); STROUT(AFSNAMEMAX); printf(" link to"); FIDOUT(); break; case 148: /* Get volume info */ STROUT(AFSNAMEMAX); break; case 149: /* Get volume stats */ case 150: /* Set volume stats */ printf(" volid"); UINTOUT(); break; case 154: /* New get volume info */ printf(" volname"); STROUT(AFSNAMEMAX); break; case 155: /* Bulk stat */ { unsigned long j; TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (i = 0; i < j; i++) { FIDOUT(); if (i != j - 1) printf(","); } if (j == 0) printf(" "); } default: ; } return; trunc: printf(" [|fs]"); } /* * Handle replies to the AFS file service */ static void fs_reply_print(register const u_char *bp, int length, int32_t opcode) { unsigned long i; struct rx_header *rxh; if (length <= sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afsint.xg */ printf(" fs reply %s", tok2str(fs_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response */ if (rxh->type == RX_PACKET_TYPE_DATA) { switch (opcode) { case 131: /* Fetch ACL */ { char a[AFSOPAQUEMAX+1]; TCHECK2(bp[0], 4); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); TCHECK2(bp[0], i); i = min(AFSOPAQUEMAX, i); strncpy(a, (char *) bp, i); a[i] = '\0'; acl_print((u_char *) a, sizeof(a), (u_char *) a + i); break; } case 137: /* Create file */ case 141: /* MakeDir */ printf(" new"); FIDOUT(); break; case 151: /* Get root volume */ printf(" root volume"); STROUT(AFSNAMEMAX); break; case 153: /* Get time */ DATEOUT(); break; default: ; } } else if (rxh->type == RX_PACKET_TYPE_ABORT) { int i; /* * Otherwise, just print out the return code */ TCHECK2(bp[0], sizeof(int32_t)); i = (int) EXTRACT_32BITS(bp); bp += sizeof(int32_t); printf(" error %s", tok2str(afs_fs_errors, "#%d", i)); } else { printf(" strange fs reply of type %d", rxh->type); } return; trunc: printf(" [|fs]"); } /* * Print out an AFS ACL string. An AFS ACL is a string that has the * following format: * * * * .... * * "positive" and "negative" are integers which contain the number of * positive and negative ACL's in the string. The uid/aclbits pair are * ASCII strings containing the UID/PTS record and and a ascii number * representing a logical OR of all the ACL permission bits */ static void acl_print(u_char *s, int maxsize, u_char *end) { int pos, neg, acl; int n, i; char *user; if ((user = (char *)malloc(maxsize)) == NULL) return; if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2) goto finish; s += n; if (s > end) goto finish; /* * This wacky order preserves the order used by the "fs" command */ #define ACLOUT(acl) \ if (acl & PRSFS_READ) \ printf("r"); \ if (acl & PRSFS_LOOKUP) \ printf("l"); \ if (acl & PRSFS_INSERT) \ printf("i"); \ if (acl & PRSFS_DELETE) \ printf("d"); \ if (acl & PRSFS_WRITE) \ printf("w"); \ if (acl & PRSFS_LOCK) \ printf("k"); \ if (acl & PRSFS_ADMINISTER) \ printf("a"); for (i = 0; i < pos; i++) { if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2) goto finish; s += n; printf(" +{"); fn_print((u_char *)user, NULL); printf(" "); ACLOUT(acl); printf("}"); if (s > end) goto finish; } for (i = 0; i < neg; i++) { if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2) goto finish; s += n; printf(" -{"); fn_print((u_char *)user, NULL); printf(" "); ACLOUT(acl); printf("}"); if (s > end) goto finish; } finish: free(user); return; } #undef ACLOUT /* * Handle calls to the AFS callback service */ static void cb_print(register const u_char *bp, int length) { int cb_op; unsigned long i; if (length <= sizeof(struct rx_header)) return; if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afscbint.xg */ cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" cb call %s", tok2str(cb_req, "op#%d", cb_op)); bp += sizeof(struct rx_header) + 4; /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afscbint.xg */ switch (cb_op) { case 204: /* Callback */ { unsigned long j, t; TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (i = 0; i < j; i++) { FIDOUT(); if (i != j - 1) printf(","); } if (j == 0) printf(" "); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); if (j != 0) printf(";"); for (i = 0; i < j; i++) { printf(" ver"); INTOUT(); printf(" expires"); DATEOUT(); TCHECK2(bp[0], 4); t = EXTRACT_32BITS(bp); bp += sizeof(int32_t); tok2str(cb_types, "type %d", t); } } case 214: { printf(" afsuuid"); AFSUUIDOUT(); break; } default: ; } return; trunc: printf(" [|cb]"); } /* * Handle replies to the AFS Callback Service */ static void cb_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; if (length <= sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afscbint.xg */ printf(" cb reply %s", tok2str(cb_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response. */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 213: /* InitCallBackState3 */ AFSUUIDOUT(); break; default: ; } else { /* * Otherwise, just print out the return code */ printf(" errcode"); INTOUT(); } return; trunc: printf(" [|cb]"); } /* * Handle calls to the AFS protection database server */ static void prot_print(register const u_char *bp, int length) { unsigned long i; int pt_op; if (length <= sizeof(struct rx_header)) return; if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from ptserver/ptint.xg */ pt_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" pt"); if (is_ubik(pt_op)) { ubik_print(bp, length); return; } printf(" call %s", tok2str(pt_req, "op#%d", pt_op)); /* * Decode some of the arguments to the PT calls */ bp += sizeof(struct rx_header) + 4; switch (pt_op) { case 500: /* I New User */ STROUT(PRNAMEMAX); printf(" id"); INTOUT(); printf(" oldid"); INTOUT(); break; case 501: /* Where is it */ case 506: /* Delete */ case 508: /* Get CPS */ case 512: /* List entry */ case 514: /* List elements */ case 517: /* List owned */ case 518: /* Get CPS2 */ case 519: /* Get host CPS */ printf(" id"); INTOUT(); break; case 502: /* Dump entry */ printf(" pos"); INTOUT(); break; case 503: /* Add to group */ case 507: /* Remove from group */ case 515: /* Is a member of? */ printf(" uid"); INTOUT(); printf(" gid"); INTOUT(); break; case 504: /* Name to ID */ { unsigned long j; TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); /* * Who designed this chicken-shit protocol? * * Each character is stored as a 32-bit * integer! */ for (i = 0; i < j; i++) { VECOUT(PRNAMEMAX); } if (j == 0) printf(" "); } break; case 505: /* Id to name */ { unsigned long j; printf(" ids:"); TCHECK2(bp[0], 4); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (j = 0; j < i; j++) INTOUT(); if (j == 0) printf(" "); } break; case 509: /* New entry */ STROUT(PRNAMEMAX); printf(" flag"); INTOUT(); printf(" oid"); INTOUT(); break; case 511: /* Set max */ printf(" id"); INTOUT(); printf(" gflag"); INTOUT(); break; case 513: /* Change entry */ printf(" id"); INTOUT(); STROUT(PRNAMEMAX); printf(" oldid"); INTOUT(); printf(" newid"); INTOUT(); break; case 520: /* Update entry */ printf(" id"); INTOUT(); STROUT(PRNAMEMAX); break; default: ; } return; trunc: printf(" [|pt]"); } /* * Handle replies to the AFS protection service */ static void prot_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; unsigned long i; if (length < sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from ptserver/ptint.xg. Check to see if it's a * Ubik call, however. */ printf(" pt"); if (is_ubik(opcode)) { ubik_reply_print(bp, length, opcode); return; } printf(" reply %s", tok2str(pt_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 504: /* Name to ID */ { unsigned long j; printf(" ids:"); TCHECK2(bp[0], 4); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (j = 0; j < i; j++) INTOUT(); if (j == 0) printf(" "); } break; case 505: /* ID to name */ { unsigned long j; TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); /* * Who designed this chicken-shit protocol? * * Each character is stored as a 32-bit * integer! */ for (i = 0; i < j; i++) { VECOUT(PRNAMEMAX); } if (j == 0) printf(" "); } break; case 508: /* Get CPS */ case 514: /* List elements */ case 517: /* List owned */ case 518: /* Get CPS2 */ case 519: /* Get host CPS */ { unsigned long j; TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (i = 0; i < j; i++) { INTOUT(); } if (j == 0) printf(" "); } break; case 510: /* List max */ printf(" maxuid"); INTOUT(); printf(" maxgid"); INTOUT(); break; default: ; } else { /* * Otherwise, just print out the return code */ printf(" errcode"); INTOUT(); } return; trunc: printf(" [|pt]"); } /* * Handle calls to the AFS volume location database service */ static void vldb_print(register const u_char *bp, int length) { int vldb_op; unsigned long i; if (length <= sizeof(struct rx_header)) return; if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from vlserver/vldbint.xg */ vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" vldb"); if (is_ubik(vldb_op)) { ubik_print(bp, length); return; } printf(" call %s", tok2str(vldb_req, "op#%d", vldb_op)); /* * Decode some of the arguments to the VLDB calls */ bp += sizeof(struct rx_header) + 4; switch (vldb_op) { case 501: /* Create new volume */ case 517: /* Create entry N */ VECOUT(VLNAMEMAX); break; case 502: /* Delete entry */ case 503: /* Get entry by ID */ case 507: /* Update entry */ case 508: /* Set lock */ case 509: /* Release lock */ case 518: /* Get entry by ID N */ printf(" volid"); INTOUT(); TCHECK2(bp[0], sizeof(int32_t)); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); if (i <= 2) printf(" type %s", voltype[i]); break; case 504: /* Get entry by name */ case 519: /* Get entry by name N */ case 524: /* Update entry by name */ case 527: /* Get entry by name U */ STROUT(VLNAMEMAX); break; case 505: /* Get new vol id */ printf(" bump"); INTOUT(); break; case 506: /* Replace entry */ case 520: /* Replace entry N */ printf(" volid"); INTOUT(); TCHECK2(bp[0], sizeof(int32_t)); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); if (i <= 2) printf(" type %s", voltype[i]); VECOUT(VLNAMEMAX); break; case 510: /* List entry */ case 521: /* List entry N */ printf(" index"); INTOUT(); break; default: ; } return; trunc: printf(" [|vldb]"); } /* * Handle replies to the AFS volume location database service */ static void vldb_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; unsigned long i; if (length < sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from vlserver/vldbint.xg. Check to see if it's a * Ubik call, however. */ printf(" vldb"); if (is_ubik(opcode)) { ubik_reply_print(bp, length, opcode); return; } printf(" reply %s", tok2str(vldb_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 510: /* List entry */ printf(" count"); INTOUT(); printf(" nextindex"); INTOUT(); case 503: /* Get entry by id */ case 504: /* Get entry by name */ { unsigned long nservers, j; VECOUT(VLNAMEMAX); TCHECK2(bp[0], sizeof(int32_t)); bp += sizeof(int32_t); printf(" numservers"); TCHECK2(bp[0], sizeof(int32_t)); nservers = EXTRACT_32BITS(bp); bp += sizeof(int32_t); printf(" %lu", nservers); printf(" servers"); for (i = 0; i < 8; i++) { TCHECK2(bp[0], sizeof(int32_t)); if (i < nservers) printf(" %s", inet_ntoa(*((struct in_addr *) bp))); bp += sizeof(int32_t); } printf(" partitions"); for (i = 0; i < 8; i++) { TCHECK2(bp[0], sizeof(int32_t)); j = EXTRACT_32BITS(bp); if (i < nservers && j <= 26) printf(" %c", 'a' + (int)j); else if (i < nservers) printf(" %lu", j); bp += sizeof(int32_t); } TCHECK2(bp[0], 8 * sizeof(int32_t)); bp += 8 * sizeof(int32_t); printf(" rwvol"); UINTOUT(); printf(" rovol"); UINTOUT(); printf(" backup"); UINTOUT(); } break; case 505: /* Get new volume ID */ printf(" newvol"); UINTOUT(); break; case 521: /* List entry */ case 529: /* List entry U */ printf(" count"); INTOUT(); printf(" nextindex"); INTOUT(); case 518: /* Get entry by ID N */ case 519: /* Get entry by name N */ { unsigned long nservers, j; VECOUT(VLNAMEMAX); printf(" numservers"); TCHECK2(bp[0], sizeof(int32_t)); nservers = EXTRACT_32BITS(bp); bp += sizeof(int32_t); printf(" %lu", nservers); printf(" servers"); for (i = 0; i < 13; i++) { TCHECK2(bp[0], sizeof(int32_t)); if (i < nservers) printf(" %s", inet_ntoa(*((struct in_addr *) bp))); bp += sizeof(int32_t); } printf(" partitions"); for (i = 0; i < 13; i++) { TCHECK2(bp[0], sizeof(int32_t)); j = EXTRACT_32BITS(bp); if (i < nservers && j <= 26) printf(" %c", 'a' + (int)j); else if (i < nservers) printf(" %lu", j); bp += sizeof(int32_t); } TCHECK2(bp[0], 13 * sizeof(int32_t)); bp += 13 * sizeof(int32_t); printf(" rwvol"); UINTOUT(); printf(" rovol"); UINTOUT(); printf(" backup"); UINTOUT(); } break; case 526: /* Get entry by ID U */ case 527: /* Get entry by name U */ { unsigned long nservers, j; VECOUT(VLNAMEMAX); printf(" numservers"); TCHECK2(bp[0], sizeof(int32_t)); nservers = EXTRACT_32BITS(bp); bp += sizeof(int32_t); printf(" %lu", nservers); printf(" servers"); for (i = 0; i < 13; i++) { if (i < nservers) { printf(" afsuuid"); AFSUUIDOUT(); } else { TCHECK2(bp[0], 44); bp += 44; } } TCHECK2(bp[0], 4 * 13); bp += 4 * 13; printf(" partitions"); for (i = 0; i < 13; i++) { TCHECK2(bp[0], sizeof(int32_t)); j = EXTRACT_32BITS(bp); if (i < nservers && j <= 26) printf(" %c", 'a' + (int)j); else if (i < nservers) printf(" %lu", j); bp += sizeof(int32_t); } TCHECK2(bp[0], 13 * sizeof(int32_t)); bp += 13 * sizeof(int32_t); printf(" rwvol"); UINTOUT(); printf(" rovol"); UINTOUT(); printf(" backup"); UINTOUT(); } default: ; } else { /* * Otherwise, just print out the return code */ printf(" errcode"); INTOUT(); } return; trunc: printf(" [|vldb]"); } /* * Handle calls to the AFS Kerberos Authentication service */ static void kauth_print(register const u_char *bp, int length) { int kauth_op; if (length <= sizeof(struct rx_header)) return; if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from kauth/kauth.rg */ kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" kauth"); if (is_ubik(kauth_op)) { ubik_print(bp, length); return; } printf(" call %s", tok2str(kauth_req, "op#%d", kauth_op)); /* * Decode some of the arguments to the KA calls */ bp += sizeof(struct rx_header) + 4; switch (kauth_op) { case 1: /* Authenticate old */; case 21: /* Authenticate */ case 22: /* Authenticate-V2 */ case 2: /* Change PW */ case 5: /* Set fields */ case 6: /* Create user */ case 7: /* Delete user */ case 8: /* Get entry */ case 14: /* Unlock */ case 15: /* Lock status */ printf(" principal"); STROUT(KANAMEMAX); STROUT(KANAMEMAX); break; case 3: /* GetTicket-old */ case 23: /* GetTicket */ { int i; printf(" kvno"); INTOUT(); printf(" domain"); STROUT(KANAMEMAX); TCHECK2(bp[0], sizeof(int32_t)); i = (int) EXTRACT_32BITS(bp); bp += sizeof(int32_t); TCHECK2(bp[0], i); bp += i; printf(" principal"); STROUT(KANAMEMAX); STROUT(KANAMEMAX); break; } case 4: /* Set Password */ printf(" principal"); STROUT(KANAMEMAX); STROUT(KANAMEMAX); printf(" kvno"); INTOUT(); break; case 12: /* Get password */ printf(" name"); STROUT(KANAMEMAX); break; default: ; } return; trunc: printf(" [|kauth]"); } /* * Handle replies to the AFS Kerberos Authentication Service */ static void kauth_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; if (length <= sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from kauth/kauth.rg */ printf(" kauth"); if (is_ubik(opcode)) { ubik_reply_print(bp, length, opcode); return; } printf(" reply %s", tok2str(kauth_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response. */ if (rxh->type == RX_PACKET_TYPE_DATA) /* Well, no, not really. Leave this for later */ ; else { /* * Otherwise, just print out the return code */ printf(" errcode"); INTOUT(); } return; trunc: printf(" [|kauth]"); } /* * Handle calls to the AFS Volume location service */ static void vol_print(register const u_char *bp, int length) { int vol_op; if (length <= sizeof(struct rx_header)) return; if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from volser/volint.xg */ vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op)); /* * Normally there would be a switch statement here to decode the * arguments to the AFS call, but since I don't have access to * an AFS server (yet) and I'm not an AFS admin, I can't * test any of these calls. Leave this blank for now. */ return; trunc: printf(" [|vol]"); } /* * Handle replies to the AFS Volume Service */ static void vol_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; if (length <= sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from volser/volint.xg */ printf(" vol reply %s", tok2str(vol_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response. */ if (rxh->type == RX_PACKET_TYPE_DATA) /* Well, no, not really. Leave this for later */ ; else { /* * Otherwise, just print out the return code */ printf(" errcode"); INTOUT(); } return; trunc: printf(" [|vol]"); } /* * Handle calls to the AFS BOS service */ static void bos_print(register const u_char *bp, int length) { int bos_op; if (length <= sizeof(struct rx_header)) return; if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t)) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from bozo/bosint.xg */ bos_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" bos call %s", tok2str(bos_req, "op#%d", bos_op)); /* * Decode some of the arguments to the BOS calls */ bp += sizeof(struct rx_header) + 4; switch (bos_op) { case 80: /* Create B node */ printf(" type"); STROUT(BOSNAMEMAX); printf(" instance"); STROUT(BOSNAMEMAX); break; case 81: /* Delete B node */ case 83: /* Get status */ case 85: /* Get instance info */ case 87: /* Add super user */ case 88: /* Delete super user */ case 93: /* Set cell name */ case 96: /* Add cell host */ case 97: /* Delete cell host */ case 104: /* Restart */ case 106: /* Uninstall */ case 108: /* Exec */ case 112: /* Getlog */ case 114: /* Get instance strings */ STROUT(BOSNAMEMAX); break; case 82: /* Set status */ case 98: /* Set T status */ STROUT(BOSNAMEMAX); printf(" status"); INTOUT(); break; case 86: /* Get instance parm */ STROUT(BOSNAMEMAX); printf(" num"); INTOUT(); break; case 84: /* Enumerate instance */ case 89: /* List super users */ case 90: /* List keys */ case 91: /* Add key */ case 92: /* Delete key */ case 95: /* Get cell host */ INTOUT(); break; case 105: /* Install */ STROUT(BOSNAMEMAX); printf(" size"); INTOUT(); printf(" flags"); INTOUT(); printf(" date"); INTOUT(); break; default: ; } return; trunc: printf(" [|bos]"); } /* * Handle replies to the AFS BOS Service */ static void bos_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; if (length <= sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from volser/volint.xg */ printf(" bos reply %s", tok2str(bos_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response. */ if (rxh->type == RX_PACKET_TYPE_DATA) /* Well, no, not really. Leave this for later */ ; else { /* * Otherwise, just print out the return code */ printf(" errcode"); INTOUT(); } return; trunc: printf(" [|bos]"); } /* * Check to see if this is a Ubik opcode. */ static int is_ubik(u_int32_t opcode) { if ((opcode >= VOTE_LOW && opcode <= VOTE_HIGH) || (opcode >= DISK_LOW && opcode <= DISK_HIGH)) return(1); else return(0); } /* * Handle Ubik opcodes to any one of the replicated database services */ static void ubik_print(register const u_char *bp, int length) { int ubik_op; int32_t temp; /* * Print out the afs call we're invoking. The table used here was * gleaned from ubik/ubik_int.xg */ ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); printf(" ubik call %s", tok2str(ubik_req, "op#%d", ubik_op)); /* * Decode some of the arguments to the Ubik calls */ bp += sizeof(struct rx_header) + 4; switch (ubik_op) { case 10000: /* Beacon */ TCHECK2(bp[0], 4); temp = EXTRACT_32BITS(bp); bp += sizeof(int32_t); printf(" syncsite %s", temp ? "yes" : "no"); printf(" votestart"); DATEOUT(); printf(" dbversion"); UBIK_VERSIONOUT(); printf(" tid"); UBIK_VERSIONOUT(); break; case 10003: /* Get sync site */ printf(" site"); UINTOUT(); break; case 20000: /* Begin */ case 20001: /* Commit */ case 20007: /* Abort */ case 20008: /* Release locks */ case 20010: /* Writev */ printf(" tid"); UBIK_VERSIONOUT(); break; case 20002: /* Lock */ printf(" tid"); UBIK_VERSIONOUT(); printf(" file"); INTOUT(); printf(" pos"); INTOUT(); printf(" length"); INTOUT(); temp = EXTRACT_32BITS(bp); bp += sizeof(int32_t); tok2str(ubik_lock_types, "type %d", temp); break; case 20003: /* Write */ printf(" tid"); UBIK_VERSIONOUT(); printf(" file"); INTOUT(); printf(" pos"); INTOUT(); break; case 20005: /* Get file */ printf(" file"); INTOUT(); break; case 20006: /* Send file */ printf(" file"); INTOUT(); printf(" length"); INTOUT(); printf(" dbversion"); UBIK_VERSIONOUT(); break; case 20009: /* Truncate */ printf(" tid"); UBIK_VERSIONOUT(); printf(" file"); INTOUT(); printf(" length"); INTOUT(); break; case 20012: /* Set version */ printf(" tid"); UBIK_VERSIONOUT(); printf(" oldversion"); UBIK_VERSIONOUT(); printf(" newversion"); UBIK_VERSIONOUT(); break; default: ; } return; trunc: printf(" [|ubik]"); } /* * Handle Ubik replies to any one of the replicated database services */ static void ubik_reply_print(register const u_char *bp, int length, int32_t opcode) { struct rx_header *rxh; if (length < sizeof(struct rx_header)) return; rxh = (struct rx_header *) bp; /* * Print out the ubik call we're invoking. This table was gleaned * from ubik/ubik_int.xg */ printf(" ubik reply %s", tok2str(ubik_req, "op#%d", opcode)); bp += sizeof(struct rx_header); /* * If it was a data packet, print out the arguments to the Ubik calls */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 10000: /* Beacon */ printf(" vote no"); break; case 20004: /* Get version */ printf(" dbversion"); UBIK_VERSIONOUT(); break; default: ; } /* * Otherwise, print out "yes" it it was a beacon packet (because * that's how yes votes are returned, go figure), otherwise * just print out the error code. */ else switch (opcode) { case 10000: /* Beacon */ printf(" vote yes until"); DATEOUT(); break; default: printf(" errcode"); INTOUT(); } return; trunc: printf(" [|ubik]"); } /* * Handle RX ACK packets. */ static void rx_ack_print(register const u_char *bp, int length) { struct rx_ackPacket *rxa; int i, start, last; if (length < sizeof(struct rx_header)) return; bp += sizeof(struct rx_header); /* * This may seem a little odd .... the rx_ackPacket structure * contains an array of individual packet acknowledgements * (used for selective ack/nack), but since it's variable in size, * we don't want to truncate based on the size of the whole * rx_ackPacket structure. */ TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS); rxa = (struct rx_ackPacket *) bp; bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS); /* * Print out a few useful things from the ack packet structure */ if (vflag > 2) printf(" bufspace %d maxskew %d", (int) EXTRACT_16BITS(&rxa->bufferSpace), (int) EXTRACT_16BITS(&rxa->maxSkew)); printf(" first %d serial %d reason %s", EXTRACT_32BITS(&rxa->firstPacket), EXTRACT_32BITS(&rxa->serial), tok2str(rx_ack_reasons, "#%d", (int) rxa->reason)); /* * Okay, now we print out the ack array. The way _this_ works * is that we start at "first", and step through the ack array. * If we have a contiguous range of acks/nacks, try to * collapse them into a range. * * If you're really clever, you might have noticed that this * doesn't seem quite correct. Specifically, due to structure * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually * yield the start of the ack array (because RX_MAXACKS is 255 * and the structure will likely get padded to a 2 or 4 byte * boundary). However, this is the way it's implemented inside * of AFS - the start of the extra fields are at * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_ * the exact start of the ack array. Sigh. That's why we aren't * using bp, but instead use rxa->acks[]. But nAcks gets added * to bp after this, so bp ends up at the right spot. Go figure. */ if (rxa->nAcks != 0) { TCHECK2(bp[0], rxa->nAcks); /* * Sigh, this is gross, but it seems to work to collapse * ranges correctly. */ for (i = 0, start = last = -2; i < rxa->nAcks; i++) if (rxa->acks[i] == RX_ACK_TYPE_ACK) { /* * I figured this deserved _some_ explanation. * First, print "acked" and the packet seq * number if this is the first time we've * seen an acked packet. */ if (last == -2) { printf(" acked %d", rxa->firstPacket + i); start = i; } /* * Otherwise, if the there is a skip in * the range (such as an nacked packet in * the middle of some acked packets), * then print the current packet number * seperated from the last number by * a comma. */ else if (last != i - 1) { printf(",%d", rxa->firstPacket + i); start = i; } /* * We always set last to the value of * the last ack we saw. Conversely, start * is set to the value of the first ack * we saw in a range. */ last = i; /* * Okay, this bit a code gets executed when * we hit a nack ... in _this_ case we * want to print out the range of packets * that were acked, so we need to print * the _previous_ packet number seperated * from the first by a dash (-). Since we * already printed the first packet above, * just print the final packet. Don't * do this if there will be a single-length * range. */ } else if (last == i - 1 && start != last) printf("-%d", rxa->firstPacket + i - 1); /* * So, what's going on here? We ran off the end of the * ack list, and if we got a range we need to finish it up. * So we need to determine if the last packet in the list * was an ack (if so, then last will be set to it) and * we need to see if the last range didn't start with the * last packet (because if it _did_, then that would mean * that the packet number has already been printed and * we don't need to print it again). */ if (last == i - 1 && start != last) printf("-%d", rxa->firstPacket + i - 1); /* * Same as above, just without comments */ for (i = 0, start = last = -2; i < rxa->nAcks; i++) if (rxa->acks[i] == RX_ACK_TYPE_NACK) { if (last == -2) { printf(" nacked %d", rxa->firstPacket + i); start = i; } else if (last != i - 1) { printf(",%d", rxa->firstPacket + i); start = i; } last = i; } else if (last == i - 1 && start != last) printf("-%d", rxa->firstPacket + i - 1); if (last == i - 1 && start != last) printf("-%d", rxa->firstPacket + i - 1); bp += rxa->nAcks; } /* * These are optional fields; depending on your version of AFS, * you may or may not see them */ #define TRUNCRET(n) if (snapend - bp + 1 <= n) return; if (vflag > 1) { TRUNCRET(4); printf(" ifmtu"); INTOUT(); TRUNCRET(4); printf(" maxmtu"); INTOUT(); TRUNCRET(4); printf(" rwind"); INTOUT(); TRUNCRET(4); printf(" maxpackets"); INTOUT(); } return; trunc: printf(" [|ack]"); } #undef TRUNCRET tcpdump-3.7.2/print-sctp.c0100644000076500000240000002422607627054632014630 0ustar fennerstaff/* Copyright (c) 2001 NETLAB, Temple University * Copyright (c) 2001 Protocol Engineering Lab, University of Delaware * * Jerry Heinz * John Fiore * Armando L. Caro Jr. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the University nor of the Laboratory may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.7.2.1 2002/07/10 07:20:57 guy Exp $ (NETLAB/PEL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "sctpHeader.h" #include "sctpConstants.h" #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ #include "ip.h" #ifdef INET6 #include "ip6.h" #endif void sctp_print(const u_char *bp, /* beginning of sctp packet */ const u_char *bp2, /* beginning of enclosing */ u_int sctpPacketLength) /* ip packet */ { const struct sctpHeader *sctpPktHdr; const struct ip *ip; #ifdef INET6 const struct ip6_hdr *ip6; #endif const u_char *cp; const void *endPacketPtr; u_short sourcePort, destPort; int chunkCount; const struct sctpChunkDesc *chunkDescPtr; const void *nextChunk; sctpPktHdr = (const struct sctpHeader*) bp; endPacketPtr = (const u_char*)sctpPktHdr+sctpPacketLength; if( (u_long) endPacketPtr > (u_long) snapend) endPacketPtr = (const void *) snapend; ip = (struct ip *)bp2; #ifdef INET6 if (IP_V(ip) == 6) ip6 = (const struct ip6_hdr *)bp2; else ip6 = NULL; #endif /*INET6*/ cp = (const u_char *)(sctpPktHdr + 1); if (cp > snapend) { printf("[|sctp]"); return; } if (sctpPacketLength < sizeof(struct sctpHeader)) { (void)printf("truncated-sctp - %ld bytes missing!", (long)sctpPacketLength-sizeof(struct sctpHeader)); return; } /* sctpPacketLength -= sizeof(struct sctpHeader); packet length */ /* is now only as long as the payload */ sourcePort = ntohs(sctpPktHdr->source); destPort = ntohs(sctpPktHdr->destination); #ifdef INET6 if (ip6) { if (ip6->ip6_nxt == IPPROTO_SCTP) { (void)printf("%s.%d > %s.%d: sctp", ip6addr_string(&ip6->ip6_src), sourcePort, ip6addr_string(&ip6->ip6_dst), destPort); } else { (void)printf("%d > %d: sctp", sourcePort, destPort); } } else #endif /*INET6*/ { if (ip->ip_p == IPPROTO_SCTP) { (void)printf("%s.%d > %s.%d: sctp", ipaddr_string(&ip->ip_src), sourcePort, ipaddr_string(&ip->ip_dst), destPort); } else { (void)printf("%d > %d: sctp", sourcePort, destPort); } } fflush(stdout); if (vflag < 2) return; /* cycle through all chunks, printing information on each one */ for (chunkCount = 0, chunkDescPtr = (const struct sctpChunkDesc *) ((const u_char*) sctpPktHdr + sizeof(struct sctpHeader)); chunkDescPtr != NULL && ( (const void *) ((const u_char *) chunkDescPtr + sizeof(struct sctpChunkDesc)) <= endPacketPtr); chunkDescPtr = (const struct sctpChunkDesc *) nextChunk, chunkCount++) { u_short align; const u_char *chunkEnd; chunkEnd = ((const u_char*)chunkDescPtr + ntohs(chunkDescPtr->chunkLength)); align=ntohs(chunkDescPtr->chunkLength) % 4; if (align != 0) align = 4 - align; nextChunk = (const void *) (chunkEnd + align); printf("\n\t%d) ", chunkCount+1); switch (chunkDescPtr->chunkID) { case SCTP_DATA : { const struct sctpDataPart *dataHdrPtr; printf("[DATA] "); if ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED) == SCTP_DATA_UNORDERED) printf("(U)"); if ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG) == SCTP_DATA_FIRST_FRAG) printf("(B)"); if ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG) == SCTP_DATA_LAST_FRAG) printf("(E)"); if( ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED) == SCTP_DATA_UNORDERED) || ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG) == SCTP_DATA_FIRST_FRAG) || ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG) == SCTP_DATA_LAST_FRAG) ) printf(" "); dataHdrPtr=(const struct sctpDataPart*)(chunkDescPtr+1); printf("[TSN: %u] ", (u_int32_t)ntohl(dataHdrPtr->TSN)); printf("[SID: %u] ", ntohs(dataHdrPtr->streamId)); printf("[SSEQ %u] ", ntohs(dataHdrPtr->sequence)); printf("[PPID 0x%x] ", (u_int32_t)ntohl(dataHdrPtr->payloadtype)); fflush(stdout); if (vflag) /* if verbose output is specified */ { /* at the command line */ const u_char *payloadPtr; printf("[Payload"); if (!xflag && !qflag) { payloadPtr = (const u_char *) (++dataHdrPtr); printf(":"); default_print(payloadPtr, htons(chunkDescPtr->chunkLength)-1 - sizeof(struct sctpDataPart)-sizeof(struct sctpChunkDesc)); } else printf("]"); } break; } case SCTP_INITIATION : { const struct sctpInitiation *init; printf("[INIT] "); init=(const struct sctpInitiation*)(chunkDescPtr+1); printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag)); printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit)); printf("[OS: %u] ", ntohs(init->NumPreopenStreams)); printf("[MIS: %u] ", ntohs(init->MaxInboundStreams)); printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN)); #if(0) /* ALC you can add code for optional params here */ if( (init+1) < chunkEnd ) printf(" @@@@@ UNFINISHED @@@@@@%s\n", "Optional params present, but not printed."); #endif break; } case SCTP_INITIATION_ACK : { const struct sctpInitiation *init; printf("[INIT ACK] "); init=(const struct sctpInitiation*)(chunkDescPtr+1); printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag)); printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit)); printf("[OS: %u] ", ntohs(init->NumPreopenStreams)); printf("[MIS: %u] ", ntohs(init->MaxInboundStreams)); printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN)); #if(0) /* ALC you can add code for optional params here */ if( (init+1) < chunkEnd ) printf(" @@@@@ UNFINISHED @@@@@@%s\n", "Optional params present, but not printed."); #endif break; } case SCTP_SELECTIVE_ACK: { const struct sctpSelectiveAck *sack; const struct sctpSelectiveFrag *frag; int fragNo, tsnNo; const u_long *dupTSN; printf("[SACK] "); sack=(const struct sctpSelectiveAck*)(chunkDescPtr+1); printf("[cum ack %u] ", (u_int32_t)ntohl(sack->highestConseqTSN)); printf("[a_rwnd %u] ", (u_int32_t)ntohl(sack->updatedRwnd)); printf("[#gap acks %u] ", ntohs(sack->numberOfdesc)); printf("[#dup tsns %u] ", ntohs(sack->numDupTsns)); /* print gaps */ for (frag = ( (const struct sctpSelectiveFrag *) ((const struct sctpSelectiveAck *) sack+1)), fragNo=0; (const void *)frag < nextChunk && fragNo < ntohs(sack->numberOfdesc); frag++, fragNo++) printf("\n\t\t[gap ack block #%d: start = %u, end = %u] ", fragNo+1, (u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentStart)), (u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentEnd))); /* print duplicate TSNs */ for (dupTSN = (const u_long*)frag, tsnNo=0; (const void *) dupTSN < nextChunk && tsnNonumDupTsns); dupTSN++, tsnNo++) printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1, (u_int32_t)ntohl(*dupTSN)); break; } case SCTP_HEARTBEAT_REQUEST : { const struct sctpHBsender *hb; hb=(const struct sctpHBsender*)chunkDescPtr; printf("[HB REQ] "); break; } case SCTP_HEARTBEAT_ACK : printf("[HB ACK] "); break; case SCTP_ABORT_ASSOCIATION : printf("[ABORT] "); break; case SCTP_SHUTDOWN : printf("[SHUTDOWN] "); break; case SCTP_SHUTDOWN_ACK : printf("[SHUTDOWN ACK] "); break; case SCTP_OPERATION_ERR : printf("[OP ERR] "); break; case SCTP_COOKIE_ECHO : printf("[COOKIE ECHO] "); break; case SCTP_COOKIE_ACK : printf("[COOKIE ACK] "); break; case SCTP_ECN_ECHO : printf("[ECN ECHO] "); break; case SCTP_ECN_CWR : printf("[ECN CWR] "); break; case SCTP_SHUTDOWN_COMPLETE : printf("[SHUTDOWN COMPLETE] "); break; case SCTP_FORWARD_CUM_TSN : printf("[FOR CUM TSN] "); break; case SCTP_RELIABLE_CNTL : printf("[REL CTRL] "); break; case SCTP_RELIABLE_CNTL_ACK : printf("[REL CTRL ACK] "); break; default : printf("[Unknown chunk type: 0x%x]", chunkDescPtr->chunkID); return; } } } tcpdump-3.7.2/print-sl.c0100644000076500000240000001453007321133731014257 0ustar fennerstaff/* * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.57 2001/07/05 18:54:17 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ #include "ip.h" #include "tcp.h" #include "slip.h" #include "slcompress.h" static u_int lastlen[2][256]; static u_int lastconn = 255; static void sliplink_print(const u_char *, const struct ip *, u_int); static void compressed_sl_print(const u_char *, const struct ip *, u_int, int); void sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { register u_int caplen = h->caplen; register u_int length = h->len; register const struct ip *ip; ++infodelay; ts_print(&h->ts); if (caplen < SLIP_HDRLEN) { printf("[|slip]"); goto out; } /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; length -= SLIP_HDRLEN; ip = (struct ip *)(p + SLIP_HDRLEN); if (eflag) sliplink_print(p, ip, length); switch (IP_V(ip)) { case 4: ip_print((u_char *)ip, length); break; #ifdef INET6 case 6: ip6_print((u_char *)ip, length); break; #endif default: printf ("ip v%d", IP_V(ip)); } if (xflag) default_print((u_char *)ip, caplen - SLIP_HDRLEN); out: putchar('\n'); --infodelay; if (infoprint) info(0); } void sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { register u_int caplen = h->caplen; register u_int length = h->len; register const struct ip *ip; ++infodelay; ts_print(&h->ts); if (caplen < SLIP_HDRLEN) { printf("[|slip]"); goto out; } /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ packetp = p; snapend = p + caplen; length -= SLIP_HDRLEN; ip = (struct ip *)(p + SLIP_HDRLEN); #ifdef notdef if (eflag) sliplink_print(p, ip, length); #endif ip_print((u_char *)ip, length); if (xflag) default_print((u_char *)ip, caplen - SLIP_HDRLEN); out: putchar('\n'); --infodelay; if (infoprint) info(0); } static void sliplink_print(register const u_char *p, register const struct ip *ip, register u_int length) { int dir; u_int hlen; dir = p[SLX_DIR]; putchar(dir == SLIPDIR_IN ? 'I' : 'O'); putchar(' '); if (nflag) { /* XXX just dump the header */ register int i; for (i = SLX_CHDR; i < SLX_CHDR + CHDR_LEN - 1; ++i) printf("%02x.", p[i]); printf("%02x: ", p[SLX_CHDR + CHDR_LEN - 1]); return; } switch (p[SLX_CHDR] & 0xf0) { case TYPE_IP: printf("ip %d: ", length + SLIP_HDRLEN); break; case TYPE_UNCOMPRESSED_TCP: /* * The connection id is stored in the IP protocol field. * Get it from the link layer since sl_uncompress_tcp() * has restored the IP header copy to IPPROTO_TCP. */ lastconn = ((struct ip *)&p[SLX_CHDR])->ip_p; hlen = IP_HL(ip); hlen += TH_OFF((struct tcphdr *)&((int *)ip)[hlen]); lastlen[dir][lastconn] = length - (hlen << 2); printf("utcp %d: ", lastconn); break; default: if (p[SLX_CHDR] & TYPE_COMPRESSED_TCP) { compressed_sl_print(&p[SLX_CHDR], ip, length, dir); printf(": "); } else printf("slip-%d!: ", p[SLX_CHDR]); } } static const u_char * print_sl_change(const char *str, register const u_char *cp) { register u_int i; if ((i = *cp++) == 0) { i = EXTRACT_16BITS(cp); cp += 2; } printf(" %s%d", str, i); return (cp); } static const u_char * print_sl_winchange(register const u_char *cp) { register short i; if ((i = *cp++) == 0) { i = EXTRACT_16BITS(cp); cp += 2; } if (i >= 0) printf(" W+%d", i); else printf(" W%d", i); return (cp); } static void compressed_sl_print(const u_char *chdr, const struct ip *ip, u_int length, int dir) { register const u_char *cp = chdr; register u_int flags, hlen; flags = *cp++; if (flags & NEW_C) { lastconn = *cp++; printf("ctcp %d", lastconn); } else printf("ctcp *"); /* skip tcp checksum */ cp += 2; switch (flags & SPECIALS_MASK) { case SPECIAL_I: printf(" *SA+%d", lastlen[dir][lastconn]); break; case SPECIAL_D: printf(" *S+%d", lastlen[dir][lastconn]); break; default: if (flags & NEW_U) cp = print_sl_change("U=", cp); if (flags & NEW_W) cp = print_sl_winchange(cp); if (flags & NEW_A) cp = print_sl_change("A+", cp); if (flags & NEW_S) cp = print_sl_change("S+", cp); break; } if (flags & NEW_I) cp = print_sl_change("I+", cp); /* * 'hlen' is the length of the uncompressed TCP/IP header (in words). * 'cp - chdr' is the length of the compressed header. * 'length - hlen' is the amount of data in the packet. */ hlen = IP_HL(ip); hlen += TH_OFF((struct tcphdr *)&((int32_t *)ip)[hlen]); lastlen[dir][lastconn] = length - (hlen << 2); printf(" %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr)); } tcpdump-3.7.2/print-sll.c0100644000076500000240000001440507627054632014447 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.6.4.1 2002/06/01 23:51:16 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "ether.h" #include "sll.h" static inline void sll_print(register const struct sll_header *sllp, u_int length) { u_short halen; switch (ntohs(sllp->sll_pkttype)) { case LINUX_SLL_HOST: (void)printf("< "); break; case LINUX_SLL_BROADCAST: (void)printf("B "); break; case LINUX_SLL_MULTICAST: (void)printf("M "); break; case LINUX_SLL_OTHERHOST: (void)printf("P "); break; case LINUX_SLL_OUTGOING: (void)printf("> "); break; default: (void)printf("? "); break; } /* * XXX - check the link-layer address type value? * For now, we just assume 6 means Ethernet. * XXX - print others as strings of hex? */ halen = ntohs(sllp->sll_halen); if (halen == 6) (void)printf("%s ", etheraddr_string(sllp->sll_addr)); if (!qflag) (void)printf("%s ", etherproto_string(sllp->sll_protocol)); (void)printf("%d: ", length); } /* * This is the top level routine of the printer. 'p' is the points * to the ether header of the packet, 'h->tv' is the timestamp, * 'h->length' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ void sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; register const struct sll_header *sllp; u_short pkttype; struct ether_header ehdr; u_short ether_type; u_short extracted_ethertype; ++infodelay; ts_print(&h->ts); if (caplen < SLL_HDR_LEN) { /* * XXX - this "can't happen" because "pcap-linux.c" always * adds this many bytes of header to every packet in a * cooked socket capture. */ printf("[|sll]"); goto out; } sllp = (const struct sll_header *)p; /* * Fake up an Ethernet header for the benefit of printers that * insist on "packetp" pointing to an Ethernet header. */ pkttype = ntohs(sllp->sll_pkttype); /* The source address is in the packet header */ memcpy(ehdr.ether_shost, sllp->sll_addr, ETHER_ADDR_LEN); if (pkttype != LINUX_SLL_OUTGOING) { /* * We received this packet. * * We don't know the destination address, so * we fake it - all 0's except that the * bottommost bit of the bottommost octet * is set for a unicast packet, all 0's except * that the bottommost bit of the uppermost * octet is set for a multicast packet, all * 1's for a broadcast packet. */ if (pkttype == LINUX_SLL_BROADCAST) memset(ehdr.ether_dhost, 0xFF, ETHER_ADDR_LEN); else { memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN); if (pkttype == LINUX_SLL_MULTICAST) ehdr.ether_dhost[0] = 1; else ehdr.ether_dhost[ETHER_ADDR_LEN-1] = 1; } } else { /* * We sent this packet; we don't know whether it's * broadcast, multicast, or unicast, so just make * the destination address all 0's. */ memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN); } if (eflag) sll_print(sllp, length); /* * Some printers want to get back at the ethernet addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ snapend = p + caplen; /* * Actually, the only printers that use packetp are print-arp.c * and print-bootp.c, and they assume that packetp points to an * Ethernet header. The right thing to do is to fix them to know * which link type is in use when they excavate. XXX */ packetp = (u_char *)&ehdr; length -= SLL_HDR_LEN; caplen -= SLL_HDR_LEN; p += SLL_HDR_LEN; ether_type = ntohs(sllp->sll_protocol); /* * Is it (gag) an 802.3 encapsulation, or some non-Ethernet * packet type? */ extracted_ethertype = 0; if (ether_type <= ETHERMTU) { /* * Yes - what type is it? */ switch (ether_type) { case LINUX_SLL_P_802_3: /* * Ethernet_802.3 IPX frame. */ ipx_print(p, length); break; case LINUX_SLL_P_802_2: /* * 802.2. * Try to print the LLC-layer header & higher layers. */ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr), &extracted_ethertype) == 0) goto unknown; /* unknown LLC type */ break; default: unknown: /* ether_type not known, print raw packet */ if (!eflag) sll_print(sllp, length + SLL_HDR_LEN); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } if (!xflag && !qflag) default_print(p, caplen); break; } } else if (ether_encap_print(ether_type, p, length, caplen, &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) sll_print(sllp, length + SLL_HDR_LEN); if (!xflag && !qflag) default_print(p, caplen); } if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } tcpdump-3.7.2/print-smb.c0100644000076500000240000010512407627054633014436 0ustar fennerstaff/* * Copyright (C) Andrew Tridgell 1995-1999 * * This software may be distributed either under the terms of the * BSD-style license that accompanies tcpdump or the GNU GPL version 2 * or later */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.20.2.4 2002/07/11 07:47:01 guy Exp $"; #endif #include #include #include #include #include "interface.h" #include "extract.h" #include "smb.h" static int request = 0; const u_char *startbuf = NULL; struct smbdescript { const char *req_f1; const char *req_f2; const char *rep_f1; const char *rep_f2; void (*fn)(const u_char *, const u_char *, const u_char *, const u_char *); }; struct smbdescriptint { const char *req_f1; const char *req_f2; const char *rep_f1; const char *rep_f2; void (*fn)(const u_char *, const u_char *, int, int); }; struct smbfns { int id; const char *name; int flags; struct smbdescript descript; }; struct smbfnsint { int id; const char *name; int flags; struct smbdescriptint descript; }; #define DEFDESCRIPT { NULL, NULL, NULL, NULL, NULL } #define FLG_CHAIN (1 << 0) static struct smbfns * smbfind(int id, struct smbfns *list) { int sindex; for (sindex = 0; list[sindex].name; sindex++) if (list[sindex].id == id) return(&list[sindex]); return(&list[0]); } static struct smbfnsint * smbfindint(int id, struct smbfnsint *list) { int sindex; for (sindex = 0; list[sindex].name; sindex++) if (list[sindex].id == id) return(&list[sindex]); return(&list[0]); } static void trans2_findfirst(const u_char *param, const u_char *data, int pcnt, int dcnt) { const char *fmt; if (request) fmt = "Attribute=[A]\nSearchCount=[d]\nFlags=[w]\nLevel=[dP5]\nFile=[S]\n"; else fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n"; smb_fdata(param, fmt, param + pcnt); if (dcnt) { printf("data:\n"); print_data(data, dcnt); } } static void trans2_qfsinfo(const u_char *param, const u_char *data, int pcnt, int dcnt) { static int level = 0; const char *fmt=""; if (request) { TCHECK2(*param, 2); level = EXTRACT_LE_16BITS(param); fmt = "InfoLevel=[d]\n"; smb_fdata(param, fmt, param + pcnt); } else { switch (level) { case 1: fmt = "idFileSystem=[W]\nSectorUnit=[D]\nUnit=[D]\nAvail=[D]\nSectorSize=[d]\n"; break; case 2: fmt = "CreationTime=[T2]VolNameLength=[B]\nVolumeLabel=[s12]\n"; break; case 0x105: fmt = "Capabilities=[W]\nMaxFileLen=[D]\nVolNameLen=[D]\nVolume=[S]\n"; break; default: fmt = "UnknownLevel\n"; break; } smb_fdata(data, fmt, data + dcnt); } if (dcnt) { printf("data:\n"); print_data(data, dcnt); } return; trunc: printf("[|SMB]"); return; } struct smbfnsint trans2_fns[] = { { 0, "TRANSACT2_OPEN", 0, { "Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w, w, w, w, w])\nPath=[S]", NULL, "Handle=[d]\nAttrib=[A]\nTime=[T2]\nSize=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nInode=[W]\nOffErr=[d]\n|EALength=[d]\n", NULL, NULL }}, { 1, "TRANSACT2_FINDFIRST", 0, { NULL, NULL, NULL, NULL, trans2_findfirst }}, { 2, "TRANSACT2_FINDNEXT", 0, DEFDESCRIPT }, { 3, "TRANSACT2_QFSINFO", 0, { NULL, NULL, NULL, NULL, trans2_qfsinfo }}, { 4, "TRANSACT2_SETFSINFO", 0, DEFDESCRIPT }, { 5, "TRANSACT2_QPATHINFO", 0, DEFDESCRIPT }, { 6, "TRANSACT2_SETPATHINFO", 0, DEFDESCRIPT }, { 7, "TRANSACT2_QFILEINFO", 0, DEFDESCRIPT }, { 8, "TRANSACT2_SETFILEINFO", 0, DEFDESCRIPT }, { 9, "TRANSACT2_FSCTL", 0, DEFDESCRIPT }, { 10, "TRANSACT2_IOCTL", 0, DEFDESCRIPT }, { 11, "TRANSACT2_FINDNOTIFYFIRST", 0, DEFDESCRIPT }, { 12, "TRANSACT2_FINDNOTIFYNEXT", 0, DEFDESCRIPT }, { 13, "TRANSACT2_MKDIR", 0, DEFDESCRIPT }, { -1, NULL, 0, DEFDESCRIPT } }; static void print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf) { static struct smbfnsint *fn = &trans2_fns[0]; const u_char *data, *param; const u_char *w = words + 1; const char *f1 = NULL, *f2 = NULL; int pcnt, dcnt; TCHECK(words[0]); if (request) { TCHECK2(w[14 * 2], 2); pcnt = EXTRACT_LE_16BITS(w + 9 * 2); param = buf + EXTRACT_LE_16BITS(w + 10 * 2); dcnt = EXTRACT_LE_16BITS(w + 11 * 2); data = buf + EXTRACT_LE_16BITS(w + 12 * 2); fn = smbfindint(EXTRACT_LE_16BITS(w + 14 * 2), trans2_fns); } else { if (words[0] == 0) { printf("%s\n", fn->name); printf("Trans2Interim\n"); return; } TCHECK2(w[7 * 2], 2); pcnt = EXTRACT_LE_16BITS(w + 3 * 2); param = buf + EXTRACT_LE_16BITS(w + 4 * 2); dcnt = EXTRACT_LE_16BITS(w + 6 * 2); data = buf + EXTRACT_LE_16BITS(w + 7 * 2); } printf("%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt); if (request) { if (words[0] == 8) { smb_fdata(words + 1, "Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n", maxbuf); return; } else { smb_fdata(words + 1, "TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[d]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[d]\n", words + 1 + 14 * 2); smb_fdata(data + 1, "TransactionName=[S]\n%", maxbuf); } f1 = fn->descript.req_f1; f2 = fn->descript.req_f2; } else { smb_fdata(words + 1, "TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[d]\n", words + 1 + 10 * 2); f1 = fn->descript.rep_f1; f2 = fn->descript.rep_f2; } if (fn->descript.fn) (*fn->descript.fn)(param, data, pcnt, dcnt); else { smb_fdata(param, f1 ? f1 : "Parameters=\n", param + pcnt); smb_fdata(data, f2 ? f2 : "Data=\n", data + dcnt); } return; trunc: printf("[|SMB]"); return; } static void print_browse(const u_char *param, int paramlen, const u_char *data, int datalen) { const u_char *maxbuf = data + datalen; int command; TCHECK(data[0]); command = data[0]; smb_fdata(param, "BROWSE PACKET\n|Param ", param+paramlen); switch (command) { case 0xF: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n", maxbuf); break; case 0x1: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n", maxbuf); break; case 0x2: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n", maxbuf); break; case 0xc: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n", maxbuf); break; case 0x8: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n", maxbuf); break; case 0xb: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n", maxbuf); break; case 0x9: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken?=[B]\n", maxbuf); break; case 0xa: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken?=[B]*Name=[S]\n", maxbuf); break; case 0xd: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n", maxbuf); break; case 0xe: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf); break; default: data = smb_fdata(data, "Unknown Browser Frame ", maxbuf); break; } return; trunc: printf("[|SMB]"); return; } static void print_ipc(const u_char *param, int paramlen, const u_char *data, int datalen) { if (paramlen) smb_fdata(param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen); if (datalen) smb_fdata(data, "IPC ", data + datalen); } static void print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf) { const char *f1, *f2, *f3, *f4; const u_char *data, *param; const u_char *w = words + 1; int datalen, paramlen; if (request) { TCHECK2(w[12 * 2], 2); paramlen = EXTRACT_LE_16BITS(w + 9 * 2); param = buf + EXTRACT_LE_16BITS(w + 10 * 2); datalen = EXTRACT_LE_16BITS(w + 11 * 2); data = buf + EXTRACT_LE_16BITS(w + 12 * 2); f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nMaxParmCnt=[d] \nMaxDataCnt=[d]\nMaxSCnt=[d] \nTransFlags=[w] \nRes1=[w] \nRes2=[w] \nRes3=[w]\nParamCnt=[d] \nParamOff=[d] \nDataCnt=[d] \nDataOff=[d] \nSUCnt=[d]\n"; f2 = "|Name=[S]\n"; f3 = "|Param "; f4 = "|Data "; } else { TCHECK2(w[7 * 2], 2); paramlen = EXTRACT_LE_16BITS(w + 3 * 2); param = buf + EXTRACT_LE_16BITS(w + 4 * 2); datalen = EXTRACT_LE_16BITS(w + 6 * 2); data = buf + EXTRACT_LE_16BITS(w + 7 * 2); f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nRes1=[d]\nParamCnt=[d] \nParamOff=[d] \nRes2=[d] \nDataCnt=[d] \nDataOff=[d] \nRes3=[d]\nLsetup=[d]\n"; f2 = "|Unknown "; f3 = "|Param "; f4 = "|Data "; } smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf)); smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen)); if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) { print_browse(param, paramlen, data, datalen); return; } if (strcmp((const char *)(data1 + 2), "\\PIPE\\LANMAN") == 0) { print_ipc(param, paramlen, data, datalen); return; } if (paramlen) smb_fdata(param, f3, SMBMIN(param + paramlen, maxbuf)); if (datalen) smb_fdata(data, f4, SMBMIN(data + datalen, maxbuf)); return; trunc: printf("[|SMB]"); return; } static void print_negprot(const u_char *words, const u_char *data, const u_char *buf, const u_char *maxbuf) { const char *f1 = NULL, *f2 = NULL; TCHECK(words[0]); if (request) f2 = "*|Dialect=[Z]\n"; else { if (words[0] == 1) f1 = "Core Protocol\nDialectIndex=[d]"; else if (words[0] == 17) f1 = "NT1 Protocol\nDialectIndex=[d]\nSecMode=[B]\nMaxMux=[d]\nNumVcs=[d]\nMaxBuffer=[D]\nRawSize=[D]\nSessionKey=[W]\nCapabilities=[W]\nServerTime=[T3]TimeZone=[d]\nCryptKey="; else if (words[0] == 13) f1 = "Coreplus/Lanman1/Lanman2 Protocol\nDialectIndex=[d]\nSecMode=[w]\nMaxXMit=[d]\nMaxMux=[d]\nMaxVcs=[d]\nBlkMode=[w]\nSessionKey=[W]\nServerTime=[T1]TimeZone=[d]\nRes=[W]\nCryptKey="; } if (f1) smb_fdata(words + 1, f1, SMBMIN(words + 1 + words[0] * 2, maxbuf)); else print_data(words + 1, SMBMIN(words[0] * 2, PTR_DIFF(maxbuf, words + 1))); TCHECK2(*data, 2); if (f2) smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), maxbuf)); else print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2))); return; trunc: printf("[|SMB]"); return; } static void print_sesssetup(const u_char *words, const u_char *data, const u_char *buf, const u_char *maxbuf) { int wcnt; const char *f1 = NULL, *f2 = NULL; TCHECK(words[0]); wcnt = words[0]; if (request) { if (wcnt == 10) f1 = "Com2=[w]\nOff2=[d]\nBufSize=[d]\nMpxMax=[d]\nVcNum=[d]\nSessionKey=[W]\nPassLen=[d]\nCryptLen=[d]\nCryptOff=[d]\nPass&Name=\n"; else f1 = "Com2=[B]\nRes1=[B]\nOff2=[d]\nMaxBuffer=[d]\nMaxMpx=[d]\nVcNumber=[d]\nSessionKey=[W]\nCaseInsensitivePasswordLength=[d]\nCaseSensitivePasswordLength=[d]\nRes=[W]\nCapabilities=[W]\nPass1&Pass2&Account&Domain&OS&LanMan=\n"; } else { if (words[0] == 3) { f1 = "Com2=[w]\nOff2=[d]\nAction=[w]\n"; } else if (words[0] == 13) { f1 = "Com2=[B]\nRes=[B]\nOff2=[d]\nAction=[w]\n"; f2 = "NativeOS=[S]\nNativeLanMan=[S]\nPrimaryDomain=[S]\n"; } } if (f1) smb_fdata(words + 1, f1, SMBMIN(words + 1 + words[0] * 2, maxbuf)); else print_data(words + 1, SMBMIN(words[0] * 2, PTR_DIFF(maxbuf, words + 1))); TCHECK2(*data, 2); if (f2) smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), maxbuf)); else print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2))); return; trunc: printf("[|SMB]"); return; } static struct smbfns smb_fns[] = { { -1, "SMBunknown", 0, DEFDESCRIPT }, { SMBtcon, "SMBtcon", 0, { NULL, "Path=[Z]\nPassword=[Z]\nDevice=[Z]\n", "MaxXmit=[d]\nTreeId=[d]\n", NULL, NULL } }, { SMBtdis, "SMBtdis", 0, DEFDESCRIPT }, { SMBexit, "SMBexit", 0, DEFDESCRIPT }, { SMBioctl, "SMBioctl", 0, DEFDESCRIPT }, { SMBecho, "SMBecho", 0, { "ReverbCount=[d]\n", NULL, "SequenceNum=[d]\n", NULL, NULL } }, { SMBulogoffX, "SMBulogoffX", FLG_CHAIN, DEFDESCRIPT }, { SMBgetatr, "SMBgetatr", 0, { NULL, "Path=[Z]\n", "Attribute=[A]\nTime=[T2]Size=[D]\nRes=([w,w,w,w,w])\n", NULL, NULL } }, { SMBsetatr, "SMBsetatr", 0, { "Attribute=[A]\nTime=[T2]Res=([w,w,w,w,w])\n", "Path=[Z]\n", NULL, NULL, NULL } }, { SMBchkpth, "SMBchkpth", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBsearch, "SMBsearch", 0, { "Count=[d]\nAttrib=[A]\n", "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\n", "Count=[d]\n", "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n", NULL } }, { SMBopen, "SMBopen", 0, { "Mode=[w]\nAttribute=[A]\n", "Path=[Z]\n", "Handle=[d]\nOAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\n", NULL, NULL } }, { SMBcreate, "SMBcreate", 0, { "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[d]\n", NULL, NULL } }, { SMBmknew, "SMBmknew", 0, { "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[d]\n", NULL, NULL } }, { SMBunlink, "SMBunlink", 0, { "Attrib=[A]\n", "Path=[Z]\n", NULL, NULL, NULL } }, { SMBread, "SMBread", 0, { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL, "Count=[d]\nRes=([w,w,w,w])\n", NULL, NULL } }, { SMBwrite, "SMBwrite", 0, { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL, "Count=[d]\n", NULL, NULL } }, { SMBclose, "SMBclose", 0, { "Handle=[d]\nTime=[T2]", NULL, NULL, NULL, NULL } }, { SMBmkdir, "SMBmkdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBrmdir, "SMBrmdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBdskattr, "SMBdskattr", 0, { NULL, NULL, "TotalUnits=[d]\nBlocksPerUnit=[d]\nBlockSize=[d]\nFreeUnits=[d]\nMedia=[w]\n", NULL, NULL } }, { SMBmv, "SMBmv", 0, { "Attrib=[A]\n", "OldPath=[Z]\nNewPath=[Z]\n", NULL, NULL, NULL } }, /* * this is a Pathworks specific call, allowing the * changing of the root path */ { pSETDIR, "SMBsetdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBlseek, "SMBlseek", 0, { "Handle=[d]\nMode=[w]\nOffset=[D]\n", "Offset=[D]\n", NULL, NULL } }, { SMBflush, "SMBflush", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsplopen, "SMBsplopen", 0, { "SetupLen=[d]\nMode=[w]\n", "Ident=[Z]\n", "Handle=[d]\n", NULL, NULL } }, { SMBsplclose, "SMBsplclose", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsplretq, "SMBsplretq", 0, { "MaxCount=[d]\nStartIndex=[d]\n", NULL, "Count=[d]\nIndex=[d]\n", "*Time=[T2]Status=[B]\nJobID=[d]\nSize=[D]\nRes=[B]Name=[s16]\n", NULL } }, { SMBsplwr, "SMBsplwr", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBlock, "SMBlock", 0, { "Handle=[d]\nCount=[D]\nOffset=[D]\n", NULL, NULL, NULL, NULL } }, { SMBunlock, "SMBunlock", 0, { "Handle=[d]\nCount=[D]\nOffset=[D]\n", NULL, NULL, NULL, NULL } }, /* CORE+ PROTOCOL FOLLOWS */ { SMBreadbraw, "SMBreadbraw", 0, { "Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[d]\n", NULL, NULL, NULL, NULL } }, { SMBwritebraw, "SMBwritebraw", 0, { "Handle=[d]\nTotalCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\n|DataSize=[d]\nDataOff=[d]\n", NULL, "WriteRawAck", NULL, NULL } }, { SMBwritec, "SMBwritec", 0, { NULL, NULL, "Count=[d]\n", NULL, NULL } }, { SMBwriteclose, "SMBwriteclose", 0, { "Handle=[d]\nCount=[d]\nOffset=[D]\nTime=[T2]Res=([w,w,w,w,w,w])", NULL, "Count=[d]\n", NULL, NULL } }, { SMBlockread, "SMBlockread", 0, { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL, "Count=[d]\nRes=([w,w,w,w])\n", NULL, NULL } }, { SMBwriteunlock, "SMBwriteunlock", 0, { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL, "Count=[d]\n", NULL, NULL } }, { SMBreadBmpx, "SMBreadBmpx", 0, { "Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[w]\n", NULL, "Offset=[D]\nTotCount=[d]\nRemaining=[d]\nRes=([w,w])\nDataSize=[d]\nDataOff=[d]\n", NULL, NULL } }, { SMBwriteBmpx, "SMBwriteBmpx", 0, { "Handle=[d]\nTotCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\nDataSize=[d]\nDataOff=[d]\n", NULL, "Remaining=[d]\n", NULL, NULL } }, { SMBwriteBs, "SMBwriteBs", 0, { "Handle=[d]\nTotCount=[d]\nOffset=[D]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\n", NULL, "Count=[d]\n", NULL, NULL } }, { SMBsetattrE, "SMBsetattrE", 0, { "Handle=[d]\nCreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]", NULL, NULL, NULL, NULL } }, { SMBgetattrE, "SMBgetattrE", 0, { "Handle=[d]\n", NULL, "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D]\nAllocSize=[D]\nAttribute=[A]\n", NULL, NULL } }, { SMBtranss, "SMBtranss", 0, DEFDESCRIPT }, { SMBioctls, "SMBioctls", 0, DEFDESCRIPT }, { SMBcopy, "SMBcopy", 0, { "TreeID2=[d]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n", "CopyCount=[d]\n", "|ErrStr=[S]\n", NULL } }, { SMBmove, "SMBmove", 0, { "TreeID2=[d]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n", "MoveCount=[d]\n", "|ErrStr=[S]\n", NULL } }, { SMBopenX, "SMBopenX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nFlags=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]OFun=[w]\nSize=[D]\nTimeOut=[D]\nRes=[W]\n", "Path=[S]\n", "Com2=[w]\nOff2=[d]\nHandle=[d]\nAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nFileID=[W]\nRes=[w]\n", NULL, NULL } }, { SMBreadX, "SMBreadX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nCountLeft=[d]\n", NULL, "Com2=[w]\nOff2=[d]\nRemaining=[d]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\nRes=([w,w,w,w])\n", NULL, NULL } }, { SMBwriteX, "SMBwriteX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nCountLeft=[d]\nRes=[w]\nDataSize=[d]\nDataOff=[d]\n", NULL, "Com2=[w]\nOff2=[d]\nCount=[d]\nRemaining=[d]\nRes=[W]\n", NULL, NULL } }, { SMBlockingX, "SMBlockingX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n", "*Process=[d]\nOffset=[D]\nLength=[D]\n", "Com2=[w]\nOff2=[d]\n", NULL, NULL } }, { SMBffirst, "SMBffirst", 0, { "Count=[d]\nAttrib=[A]\n", "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n", "Count=[d]\n", "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n", NULL } }, { SMBfunique, "SMBfunique", 0, { "Count=[d]\nAttrib=[A]\n", "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n", "Count=[d]\n", "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n", NULL } }, { SMBfclose, "SMBfclose", 0, { "Count=[d]\nAttrib=[A]\n", "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n", "Count=[d]\n", "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n", NULL } }, { SMBfindnclose, "SMBfindnclose", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBfindclose, "SMBfindclose", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsends, "SMBsends", 0, { NULL, "Source=[Z]\nDest=[Z]\n", NULL, NULL, NULL } }, { SMBsendstrt, "SMBsendstrt", 0, { NULL, "Source=[Z]\nDest=[Z]\n", "GroupID=[d]\n", NULL, NULL } }, { SMBsendend, "SMBsendend", 0, { "GroupID=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsendtxt, "SMBsendtxt", 0, { "GroupID=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsendb, "SMBsendb", 0, { NULL, "Source=[Z]\nDest=[Z]\n", NULL, NULL, NULL } }, { SMBfwdname, "SMBfwdname", 0, DEFDESCRIPT }, { SMBcancelf, "SMBcancelf", 0, DEFDESCRIPT }, { SMBgetmac, "SMBgetmac", 0, DEFDESCRIPT }, { SMBnegprot, "SMBnegprot", 0, { NULL, NULL, NULL, NULL, print_negprot } }, { SMBsesssetupX, "SMBsesssetupX", FLG_CHAIN, { NULL, NULL, NULL, NULL, print_sesssetup } }, { SMBtconX, "SMBtconX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nFlags=[w]\nPassLen=[d]\nPasswd&Path&Device=\n", NULL, "Com2=[w]\nOff2=[d]\n", "ServiceType=[S]\n", NULL } }, { SMBtrans2, "SMBtrans2", 0, { NULL, NULL, NULL, NULL, print_trans2 } }, { SMBtranss2, "SMBtranss2", 0, DEFDESCRIPT }, { SMBctemp, "SMBctemp", 0, DEFDESCRIPT }, { SMBreadBs, "SMBreadBs", 0, DEFDESCRIPT }, { SMBtrans, "SMBtrans", 0, { NULL, NULL, NULL, NULL, print_trans } }, { SMBnttrans, "SMBnttrans", 0, DEFDESCRIPT }, { SMBnttranss, "SMBnttranss", 0, DEFDESCRIPT }, { SMBntcreateX, "SMBntcreateX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nRes=[b]\nNameLen=[d]\nFlags=[W]\nRootDirectoryFid=[D]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n", "Path=[S]\n", "Com2=[w]\nOff2=[d]\nOplockLevel=[b]\nFid=[d]\nCreateAction=[W]\nCreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W]\nAllocationSize=[L]\nEndOfFile=[L]\nFileType=[w]\nDeviceState=[w]\nDirectory=[b]\n", NULL } }, { SMBntcancel, "SMBntcancel", 0, DEFDESCRIPT }, { -1, NULL, 0, DEFDESCRIPT } }; /* * print a SMB message */ static void print_smb(const u_char *buf, const u_char *maxbuf) { int command; const u_char *words, *data; struct smbfns *fn; char *fmt_smbheader = "[P4]SMB Command = [B]\nError class = [BP1]\nError code = [d]\nFlags1 = [B]\nFlags2 = [B][P13]\nTree ID = [d]\nProc ID = [d]\nUID = [d]\nMID = [d]\nWord Count = [b]\n"; TCHECK(buf[9]); request = (buf[9] & 0x80) ? 0 : 1; command = buf[4]; fn = smbfind(command, smb_fns); if (vflag > 1) printf("\n"); printf("SMB PACKET: %s (%s)\n", fn->name, request ? "REQUEST" : "REPLY"); if (vflag < 2) return; /* print out the header */ smb_fdata(buf, fmt_smbheader, buf + 33); if (buf[5]) printf("SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7]))); words = buf + 32; TCHECK(words[0]); for (;;) { const char *f1, *f2; int wct; int bcc; TCHECK(words[0]); wct = words[0]; data = words + 1 + wct * 2; if (request) { f1 = fn->descript.req_f1; f2 = fn->descript.req_f2; } else { f1 = fn->descript.rep_f1; f2 = fn->descript.rep_f2; } if (fn->descript.fn) (*fn->descript.fn)(words, data, buf, maxbuf); else { if (wct) { printf("smbvwv[]=\n"); if (f1) smb_fdata(words + 1, f1, words + 1 + wct * 2); else { int i; int v; for (i = 0; i < wct; i++) { TCHECK2(words[1 + 2 * i], 2); v = EXTRACT_LE_16BITS(words + 1 + 2 * i); printf("smb_vwv[%d]=%d (0x%X)\n", i, v, v); } } } TCHECK2(*data, 2); bcc = EXTRACT_LE_16BITS(data); if (f2) { if (bcc > 0) { printf("smbbuf[]=\n"); smb_fdata(data + 2, f2, data + 2 + bcc); } } else { printf("smb_bcc=%d\n", bcc); if (bcc > 0) { printf("smb_buf[]=\n"); print_data(data + 2, SMBMIN(bcc, PTR_DIFF(maxbuf, data + 2))); } } } if ((fn->flags & FLG_CHAIN) == 0) break; if (wct == 0) break; TCHECK(words[1]); command = EXTRACT_LE_16BITS(words + 1); if (command == 0xFF) break; TCHECK2(words[3], 2); words = buf + EXTRACT_LE_16BITS(words + 3); fn = smbfind(command, smb_fns); printf("\nSMB PACKET: %s (%s) (CHAINED)\n", fn->name, request ? "REQUEST" : "REPLY"); } printf("\n"); return; trunc: printf("[|SMB]"); return; } /* * print a NBT packet received across tcp on port 139 */ void nbt_tcp_print(const u_char *data, int length) { const u_char *maxbuf = data + length; int flags; int nbt_len; TCHECK2(data[2], 2); flags = data[0]; nbt_len = EXTRACT_16BITS(data + 2); startbuf = data; if (maxbuf <= data) return; if (vflag > 1) printf ("\n>>>"); printf(" NBT Packet"); if (vflag < 2) return; printf("\n"); switch (flags) { case 1: printf("flags=0x%x\n", flags); case 0: data = smb_fdata(data, "NBT Session Packet\nFlags=[rw]\nLength=[rd]\n", data + 4); if (data == NULL) break; if (memcmp(data,"\377SMB",4) == 0) { if (nbt_len > PTR_DIFF(maxbuf, data)) printf("WARNING: Short packet. Try increasing the snap length (%lu)\n", (unsigned long)PTR_DIFF(maxbuf, data)); print_smb(data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf); } else printf("Session packet:(raw data?)\n"); break; case 0x81: data = smb_fdata(data, "NBT Session Request\nFlags=[rW]\nDestination=[n1]\nSource=[n1]\n", maxbuf); break; case 0x82: data = smb_fdata(data, "NBT Session Granted\nFlags=[rW]\n", maxbuf); break; case 0x83: { int ecode; TCHECK(data[4]); ecode = data[4]; data = smb_fdata(data, "NBT SessionReject\nFlags=[rW]\nReason=[B]\n", maxbuf); switch (ecode) { case 0x80: printf("Not listening on called name\n"); break; case 0x81: printf("Not listening for calling name\n"); break; case 0x82: printf("Called name not present\n"); break; case 0x83: printf("Called name present, but insufficient resources\n"); break; default: printf("Unspecified error 0x%X\n", ecode); break; } } break; case 0x85: data = smb_fdata(data, "NBT Session Keepalive\nFlags=[rW]\n", maxbuf); break; default: printf("flags=0x%x\n", flags); data = smb_fdata(data, "NBT - Unknown packet type\nType=[rW]\n", maxbuf); } printf("\n"); fflush(stdout); return; trunc: printf("[|SMB]"); return; } /* * print a NBT packet received across udp on port 137 */ void nbt_udp137_print(const u_char *data, int length) { const u_char *maxbuf = data + length; int name_trn_id, response, opcode, nm_flags, rcode; int qdcount, ancount, nscount, arcount; char *opcodestr; const u_char *p; int total, i; TCHECK2(data[10], 2); name_trn_id = EXTRACT_16BITS(data); response = (data[2] >> 7); opcode = (data[2] >> 3) & 0xF; nm_flags = ((data[2] & 0x7) << 4) + (data[3] >> 4); rcode = data[3] & 0xF; qdcount = EXTRACT_16BITS(data + 4); ancount = EXTRACT_16BITS(data + 6); nscount = EXTRACT_16BITS(data + 8); arcount = EXTRACT_16BITS(data + 10); startbuf = data; if (maxbuf <= data) return; if (vflag > 1) printf("\n>>> "); printf("NBT UDP PACKET(137): "); switch (opcode) { case 0: opcodestr = "QUERY"; break; case 5: opcodestr = "REGISTRATION"; break; case 6: opcodestr = "RELEASE"; break; case 7: opcodestr = "WACK"; break; case 8: opcodestr = "REFRESH(8)"; break; case 9: opcodestr = "REFRESH"; break; case 15: opcodestr = "MULTIHOMED REGISTRATION"; break; default: opcodestr = "OPUNKNOWN"; break; } printf("%s", opcodestr); if (response) { if (rcode) printf("; NEGATIVE"); else printf("; POSITIVE"); } if (response) printf("; RESPONSE"); else printf("; REQUEST"); if (nm_flags & 1) printf("; BROADCAST"); else printf("; UNICAST"); if (vflag < 2) return; printf("\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n", name_trn_id, opcode, nm_flags, rcode, qdcount, ancount, nscount, arcount); p = data + 12; total = ancount + nscount + arcount; if (qdcount > 100 || total > 100) { printf("Corrupt packet??\n"); return; } if (qdcount) { printf("QuestionRecords:\n"); for (i = 0; i < qdcount; i++) p = smb_fdata(p, "|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#", maxbuf); if (p == NULL) goto out; } if (total) { printf("\nResourceRecords:\n"); for (i = 0; i < total; i++) { int rdlen; int restype; p = smb_fdata(p, "Name=[n1]\n#", maxbuf); if (p == NULL) goto out; restype = EXTRACT_16BITS(p); p = smb_fdata(p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8); if (p == NULL) goto out; rdlen = EXTRACT_16BITS(p); printf("ResourceLength=%d\nResourceData=\n", rdlen); p += 2; if (rdlen == 6) { p = smb_fdata(p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen); if (p == NULL) goto out; } else { if (restype == 0x21) { int numnames; TCHECK(*p); numnames = p[0]; p = smb_fdata(p, "NumNames=[B]\n", p + 1); if (p == NULL) goto out; while (numnames--) { p = smb_fdata(p, "Name=[n2]\t#", maxbuf); TCHECK(*p); if (p[0] & 0x80) printf(" "); switch (p[0] & 0x60) { case 0x00: printf("B "); break; case 0x20: printf("P "); break; case 0x40: printf("M "); break; case 0x60: printf("_ "); break; } if (p[0] & 0x10) printf(" "); if (p[0] & 0x08) printf(" "); if (p[0] & 0x04) printf(" "); if (p[0] & 0x02) printf(" "); printf("\n"); p += 2; } } else { print_data(p, min(rdlen, length - (p - data))); p += rdlen; } } } } if (p < maxbuf) smb_fdata(p, "AdditionalData:\n", maxbuf); out: printf("\n"); fflush(stdout); return; trunc: printf("[|SMB]"); return; } /* * print a NBT packet received across udp on port 138 */ void nbt_udp138_print(const u_char *data, int length) { const u_char *maxbuf = data + length; if (maxbuf > snapend) maxbuf = snapend; if (maxbuf <= data) return; startbuf = data; if (vflag < 2) { printf("NBT UDP PACKET(138)"); return; } data = smb_fdata(data, "\n>>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw]\nSourceName=[n1]\nDestName=[n1]\n#", maxbuf); if (data != NULL) { /* If there isn't enough data for "\377SMB", don't check for it. */ if (&data[3] >= maxbuf) goto out; if (memcmp(data, "\377SMB",4) == 0) print_smb(data, maxbuf); } out: printf("\n"); fflush(stdout); } /* print netbeui frames */ void netbeui_print(u_short control, const u_char *data, int length) { const u_char *maxbuf = data + length; int len; int command; const u_char *data2; int is_truncated = 0; if (maxbuf > snapend) maxbuf = snapend; TCHECK(data[4]); len = EXTRACT_LE_16BITS(data); command = data[4]; data2 = data + len; if (data2 >= maxbuf) { data2 = maxbuf; is_truncated = 1; } startbuf = data; if (vflag < 2) { printf("NetBeui Packet"); return; } printf("\n>>> NetBeui Packet\nType=0x%X ", control); data = smb_fdata(data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf); if (data == NULL) goto out; switch (command) { case 0xA: data = smb_fdata(data, "NameQuery:[P1]\nSessionNumber=[B]\nNameType=[B][P2]\nResponseCorrelator=[w]\nDestination=[n2]\nSource=[n2]\n", data2); break; case 0x8: data = smb_fdata(data, "NetbiosDataGram:[P7]\nDestination=[n2]\nSource=[n2]\n", data2); break; case 0xE: data = smb_fdata(data, "NameRecognise:\n[P1]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nDestination=[n2]\nSource=[n2]\n", data2); break; case 0x19: data = smb_fdata(data, "SessionInitialise:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n", data2); break; case 0x17: data = smb_fdata(data, "SessionConfirm:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n", data2); break; case 0x16: data = smb_fdata(data, "NetbiosDataOnlyLast:\nFlags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n", data2); break; case 0x14: data = smb_fdata(data, "NetbiosDataAck:\n[P3]TransmitCorrelator=[w][P2]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n", data2); break; case 0x18: data = smb_fdata(data, "SessionEnd:\n[P1]Data2=[w][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n", data2); break; case 0x1f: data = smb_fdata(data, "SessionAlive\n", data2); break; default: data = smb_fdata(data, "Unknown Netbios Command ", data2); break; } if (data == NULL) goto out; if (is_truncated) { /* data2 was past the end of the buffer */ goto out; } /* If there isn't enough data for "\377SMB", don't look for it. */ if (&data2[3] >= maxbuf) goto out; if (memcmp(data2, "\377SMB",4) == 0) print_smb(data2, maxbuf); else { int i; for (i = 0; i < 128; i++) { if (&data2[i + 3] >= maxbuf) break; if (memcmp(&data2[i], "\377SMB", 4) == 0) { printf("found SMB packet at %d\n", i); print_smb(&data2[i], maxbuf); break; } } } out: printf("\n"); return; trunc: printf("[|SMB]"); return; } /* * print IPX-Netbios frames */ void ipx_netbios_print(const u_char *data, u_int length) { /* * this is a hack till I work out how to parse the rest of the * NetBIOS-over-IPX stuff */ int i; const u_char *maxbuf; maxbuf = data + length; /* Don't go past the end of the captured data in the packet. */ if (maxbuf > snapend) maxbuf = snapend; startbuf = data; for (i = 0; i < 128; i++) { if (&data[i + 4] > maxbuf) break; if (memcmp(&data[i], "\377SMB", 4) == 0) { smb_fdata(data, "\n>>> IPX transport ", &data[i]); if (data != NULL) print_smb(&data[i], maxbuf); printf("\n"); fflush(stdout); break; } } if (i == 128) smb_fdata(data, "\n>>> Unknown IPX ", maxbuf); } tcpdump-3.7.2/print-snmp.c0100644000076500000240000012035107627054633014631 0ustar fennerstaff/* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 * John Robert LoVerso. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * * This implementation has been influenced by the CMU SNMP release, * by Steve Waldbusser. However, this shares no code with that system. * Additional ASN.1 insight gained from Marshall T. Rose's _The_Open_Book_. * Earlier forms of this implementation were derived and/or inspired by an * awk script originally written by C. Philip Wood of LANL (but later * heavily modified by John Robert LoVerso). The copyright notice for * that work is preserved below, even though it may not rightly apply * to this file. * * Support for SNMPv2c/SNMPv3 and the ability to link the module against * the libsmi was added by J. Schoenwaelder, Copyright (c) 1999. * * This started out as a very simple program, but the incremental decoding * (into the BE structure) complicated things. * # Los Alamos National Laboratory # # Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 # This software was produced under a U.S. Government contract # (W-7405-ENG-36) by Los Alamos National Laboratory, which is # operated by the University of California for the U.S. Department # of Energy. The U.S. Government is licensed to use, reproduce, # and distribute this software. Permission is granted to the # public to copy and use this software without charge, provided # that this Notice and any statement of authorship are reproduced # on all copies. Neither the Government nor the University makes # any warranty, express or implied, or assumes any liability or # responsibility for the use of this software. # @(#)snmp.awk.x 1.1 (LANL) 1/15/90 */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.50.4.2 2002/07/20 23:33:08 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #ifdef HAVE_SMI_H #include #endif #include "interface.h" #include "addrtoname.h" /* * Universal ASN.1 types * (we only care about the tag values for those allowed in the Internet SMI) */ char *Universal[] = { "U-0", "Boolean", "Integer", #define INTEGER 2 "Bitstring", "String", #define STRING 4 "Null", #define ASN_NULL 5 "ObjID", #define OBJECTID 6 "ObjectDes", "U-8","U-9","U-10","U-11", /* 8-11 */ "U-12","U-13","U-14","U-15", /* 12-15 */ "Sequence", #define SEQUENCE 16 "Set" }; /* * Application-wide ASN.1 types from the Internet SMI and their tags */ char *Application[] = { "IpAddress", #define IPADDR 0 "Counter", #define COUNTER 1 "Gauge", #define GAUGE 2 "TimeTicks", #define TIMETICKS 3 "Opaque", #define OPAQUE 4 "C-5", "Counter64" #define COUNTER64 6 }; /* * Context-specific ASN.1 types for the SNMP PDUs and their tags */ char *Context[] = { "GetRequest", #define GETREQ 0 "GetNextRequest", #define GETNEXTREQ 1 "GetResponse", #define GETRESP 2 "SetRequest", #define SETREQ 3 "Trap", #define TRAP 4 "GetBulk", #define GETBULKREQ 5 "Inform", #define INFORMREQ 6 "V2Trap", #define V2TRAP 7 "Report" #define REPORT 8 }; #define NOTIFY_CLASS(x) (x == TRAP || x == V2TRAP || x == INFORMREQ) #define READ_CLASS(x) (x == GETREQ || x == GETNEXTREQ || x == GETBULKREQ) #define WRITE_CLASS(x) (x == SETREQ) #define RESPONSE_CLASS(x) (x == GETRESP) #define INTERNAL_CLASS(x) (x == REPORT) /* * Context-specific ASN.1 types for the SNMP Exceptions and their tags */ char *Exceptions[] = { "noSuchObject", #define NOSUCHOBJECT 0 "noSuchInstance", #define NOSUCHINSTANCE 1 "endOfMibView", #define ENDOFMIBVIEW 2 }; /* * Private ASN.1 types * The Internet SMI does not specify any */ char *Private[] = { "P-0" }; /* * error-status values for any SNMP PDU */ char *ErrorStatus[] = { "noError", "tooBig", "noSuchName", "badValue", "readOnly", "genErr", "noAccess", "wrongType", "wrongLength", "wrongEncoding", "wrongValue", "noCreation", "inconsistentValue", "resourceUnavailable", "commitFailed", "undoFailed", "authorizationError", "notWritable", "inconsistentName" }; #define DECODE_ErrorStatus(e) \ ( e >= 0 && e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \ ? ErrorStatus[e] \ : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf)) /* * generic-trap values in the SNMP Trap-PDU */ char *GenericTrap[] = { "coldStart", "warmStart", "linkDown", "linkUp", "authenticationFailure", "egpNeighborLoss", "enterpriseSpecific" #define GT_ENTERPRISE 7 }; #define DECODE_GenericTrap(t) \ ( t >= 0 && t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \ ? GenericTrap[t] \ : (snprintf(buf, sizeof(buf), "gt=%d", t), buf)) /* * ASN.1 type class table * Ties together the preceding Universal, Application, Context, and Private * type definitions. */ #define defineCLASS(x) { "x", x, sizeof(x)/sizeof(x[0]) } /* not ANSI-C */ struct { char *name; char **Id; int numIDs; } Class[] = { defineCLASS(Universal), #define UNIVERSAL 0 defineCLASS(Application), #define APPLICATION 1 defineCLASS(Context), #define CONTEXT 2 defineCLASS(Private), #define PRIVATE 3 defineCLASS(Exceptions), #define EXCEPTIONS 4 }; /* * defined forms for ASN.1 types */ char *Form[] = { "Primitive", #define PRIMITIVE 0 "Constructed", #define CONSTRUCTED 1 }; /* * A structure for the OID tree for the compiled-in MIB. * This is stored as a general-order tree. */ struct obj { char *desc; /* name of object */ u_char oid; /* sub-id following parent */ u_char type; /* object type (unused) */ struct obj *child, *next; /* child and next sibling pointers */ } *objp = NULL; /* * Include the compiled in SNMP MIB. "mib.h" is produced by feeding * RFC-1156 format files into "makemib". "mib.h" MUST define at least * a value for `mibroot'. * * In particular, this is gross, as this is including initialized structures, * and by right shouldn't be an "include" file. */ #include "mib.h" /* * This defines a list of OIDs which will be abbreviated on output. * Currently, this includes the prefixes for the Internet MIB, the * private enterprises tree, and the experimental tree. */ struct obj_abrev { char *prefix; /* prefix for this abrev */ struct obj *node; /* pointer into object table */ char *oid; /* ASN.1 encoded OID */ } obj_abrev_list[] = { #ifndef NO_ABREV_MIB /* .iso.org.dod.internet.mgmt.mib */ { "", &_mib_obj, "\53\6\1\2\1" }, #endif #ifndef NO_ABREV_ENTER /* .iso.org.dod.internet.private.enterprises */ { "E:", &_enterprises_obj, "\53\6\1\4\1" }, #endif #ifndef NO_ABREV_EXPERI /* .iso.org.dod.internet.experimental */ { "X:", &_experimental_obj, "\53\6\1\3" }, #endif #ifndef NO_ABBREV_SNMPMODS /* .iso.org.dod.internet.snmpV2.snmpModules */ { "S:", &_snmpModules_obj, "\53\6\1\6\3" }, #endif { 0,0,0 } }; /* * This is used in the OID print routine to walk down the object tree * rooted at `mibroot'. */ #define OBJ_PRINT(o, suppressdot) \ { \ if (objp) { \ do { \ if ((o) == objp->oid) \ break; \ } while ((objp = objp->next) != NULL); \ } \ if (objp) { \ printf(suppressdot?"%s":".%s", objp->desc); \ objp = objp->child; \ } else \ printf(suppressdot?"%u":".%u", (o)); \ } /* * This is the definition for the Any-Data-Type storage used purely for * temporary internal representation while decoding an ASN.1 data stream. */ struct be { u_int32_t asnlen; union { caddr_t raw; int32_t integer; u_int32_t uns; const u_char *str; struct { u_int32_t high; u_int32_t low; } uns64; } data; u_short id; u_char form, class; /* tag info */ u_char type; #define BE_ANY 255 #define BE_NONE 0 #define BE_NULL 1 #define BE_OCTET 2 #define BE_OID 3 #define BE_INT 4 #define BE_UNS 5 #define BE_STR 6 #define BE_SEQ 7 #define BE_INETADDR 8 #define BE_PDU 9 #define BE_UNS64 10 #define BE_NOSUCHOBJECT 128 #define BE_NOSUCHINST 129 #define BE_ENDOFMIBVIEW 130 }; /* * SNMP versions recognized by this module */ char *SnmpVersion[] = { "SNMPv1", #define SNMP_VERSION_1 0 "SNMPv2c", #define SNMP_VERSION_2 1 "SNMPv2u", #define SNMP_VERSION_2U 2 "SNMPv3" #define SNMP_VERSION_3 3 }; /* * Defaults for SNMP PDU components */ #define DEF_COMMUNITY "public" /* * constants for ASN.1 decoding */ #define OIDMUX 40 #define ASNLEN_INETADDR 4 #define ASN_SHIFT7 7 #define ASN_SHIFT8 8 #define ASN_BIT8 0x80 #define ASN_LONGLEN 0x80 #define ASN_ID_BITS 0x1f #define ASN_FORM_BITS 0x20 #define ASN_FORM_SHIFT 5 #define ASN_CLASS_BITS 0xc0 #define ASN_CLASS_SHIFT 6 #define ASN_ID_EXT 0x1f /* extension ID in tag field */ /* * truncated==1 means the packet was complete, but we don't have all of * it to decode. */ static int truncated; #define ifNotTruncated if (truncated) fputs("[|snmp]", stdout); else /* * This decodes the next ASN.1 object in the stream pointed to by "p" * (and of real-length "len") and stores the intermediate data in the * provided BE object. * * This returns -l if it fails (i.e., the ASN.1 stream is not valid). * O/w, this returns the number of bytes parsed from "p". */ static int asn1_parse(register const u_char *p, u_int len, struct be *elem) { u_char form, class, id; int i, hdr; elem->asnlen = 0; elem->type = BE_ANY; if (len < 1) { ifNotTruncated fputs("[nothing to parse]", stdout); return -1; } /* * it would be nice to use a bit field, but you can't depend on them. * +---+---+---+---+---+---+---+---+ * + class |frm| id | * +---+---+---+---+---+---+---+---+ * 7 6 5 4 3 2 1 0 */ id = *p & ASN_ID_BITS; /* lower 5 bits, range 00-1f */ #ifdef notdef form = (*p & 0xe0) >> 5; /* move upper 3 bits to lower 3 */ class = form >> 1; /* bits 7&6 -> bits 1&0, range 0-3 */ form &= 0x1; /* bit 5 -> bit 0, range 0-1 */ #else form = (u_char)(*p & ASN_FORM_BITS) >> ASN_FORM_SHIFT; class = (u_char)(*p & ASN_CLASS_BITS) >> ASN_CLASS_SHIFT; #endif elem->form = form; elem->class = class; elem->id = id; p++; len--; hdr = 1; /* extended tag field */ if (id == ASN_ID_EXT) { for (id = 0; *p & ASN_BIT8 && len > 0; len--, hdr++, p++) id = (id << 7) | (*p & ~ASN_BIT8); if (len == 0 && *p & ASN_BIT8) { ifNotTruncated fputs("[Xtagfield?]", stdout); return -1; } elem->id = id = (id << 7) | *p; --len; ++hdr; ++p; } if (len < 1) { ifNotTruncated fputs("[no asnlen]", stdout); return -1; } elem->asnlen = *p; p++; len--; hdr++; if (elem->asnlen & ASN_BIT8) { int noct = elem->asnlen % ASN_BIT8; elem->asnlen = 0; if (len < noct) { ifNotTruncated printf("[asnlen? %d<%d]", len, noct); return -1; } for (; noct-- > 0; len--, hdr++) elem->asnlen = (elem->asnlen << ASN_SHIFT8) | *p++; } if (len < elem->asnlen) { if (!truncated) { printf("[len%dasnlen); return -1; } /* maybe should check at least 4? */ elem->asnlen = len; } if (form >= sizeof(Form)/sizeof(Form[0])) { ifNotTruncated printf("[form?%d]", form); return -1; } if (class >= sizeof(Class)/sizeof(Class[0])) { ifNotTruncated printf("[class?%c/%d]", *Form[form], class); return -1; } if ((int)id >= Class[class].numIDs) { ifNotTruncated printf("[id?%c/%s/%d]", *Form[form], Class[class].name, id); return -1; } switch (form) { case PRIMITIVE: switch (class) { case UNIVERSAL: switch (id) { case STRING: elem->type = BE_STR; elem->data.str = p; break; case INTEGER: { register int32_t data; elem->type = BE_INT; data = 0; if (*p & ASN_BIT8) /* negative */ data = -1; for (i = elem->asnlen; i-- > 0; p++) data = (data << ASN_SHIFT8) | *p; elem->data.integer = data; break; } case OBJECTID: elem->type = BE_OID; elem->data.raw = (caddr_t)p; break; case ASN_NULL: elem->type = BE_NULL; elem->data.raw = NULL; break; default: elem->type = BE_OCTET; elem->data.raw = (caddr_t)p; printf("[P/U/%s]", Class[class].Id[id]); break; } break; case APPLICATION: switch (id) { case IPADDR: elem->type = BE_INETADDR; elem->data.raw = (caddr_t)p; break; case COUNTER: case GAUGE: case TIMETICKS: { register u_int32_t data; elem->type = BE_UNS; data = 0; for (i = elem->asnlen; i-- > 0; p++) data = (data << 8) + *p; elem->data.uns = data; break; } case COUNTER64: { register u_int32_t high, low; elem->type = BE_UNS64; high = 0, low = 0; for (i = elem->asnlen; i-- > 0; p++) { high = (high << 8) | ((low & 0xFF000000) >> 24); low = (low << 8) | *p; } elem->data.uns64.high = high; elem->data.uns64.low = low; break; } default: elem->type = BE_OCTET; elem->data.raw = (caddr_t)p; printf("[P/A/%s]", Class[class].Id[id]); break; } break; case CONTEXT: switch (id) { case NOSUCHOBJECT: elem->type = BE_NOSUCHOBJECT; elem->data.raw = NULL; break; case NOSUCHINSTANCE: elem->type = BE_NOSUCHINST; elem->data.raw = NULL; break; case ENDOFMIBVIEW: elem->type = BE_ENDOFMIBVIEW; elem->data.raw = NULL; break; } break; default: elem->type = BE_OCTET; elem->data.raw = (caddr_t)p; printf("[P/%s/%s]", Class[class].name, Class[class].Id[id]); break; } break; case CONSTRUCTED: switch (class) { case UNIVERSAL: switch (id) { case SEQUENCE: elem->type = BE_SEQ; elem->data.raw = (caddr_t)p; break; default: elem->type = BE_OCTET; elem->data.raw = (caddr_t)p; printf("C/U/%s", Class[class].Id[id]); break; } break; case CONTEXT: elem->type = BE_PDU; elem->data.raw = (caddr_t)p; break; default: elem->type = BE_OCTET; elem->data.raw = (caddr_t)p; printf("C/%s/%s", Class[class].name, Class[class].Id[id]); break; } break; } p += elem->asnlen; len -= elem->asnlen; return elem->asnlen + hdr; } /* * Display the ASN.1 object represented by the BE object. * This used to be an integral part of asn1_parse() before the intermediate * BE form was added. */ static void asn1_print(struct be *elem) { u_char *p = (u_char *)elem->data.raw; u_int32_t asnlen = elem->asnlen; int i; switch (elem->type) { case BE_OCTET: for (i = asnlen; i-- > 0; p++) printf("_%.2x", *p); break; case BE_NULL: break; case BE_OID: { int o = 0, first = -1, i = asnlen; if (!sflag && !nflag && asnlen > 2) { struct obj_abrev *a = &obj_abrev_list[0]; for (; a->node; a++) { if (!memcmp(a->oid, (char *)p, strlen(a->oid))) { objp = a->node->child; i -= strlen(a->oid); p += strlen(a->oid); fputs(a->prefix, stdout); first = 1; break; } } } for (; !sflag && i-- > 0; p++) { o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8); if (*p & ASN_LONGLEN) continue; /* * first subitem encodes two items with 1st*OIDMUX+2nd * (see X.690:1997 clause 8.19 for the details) */ if (first < 0) { int s; if (!nflag) objp = mibroot; first = 0; s = o / OIDMUX; if (s > 2) s = 2; OBJ_PRINT(s, first); o -= s * OIDMUX; } OBJ_PRINT(o, first); if (--first < 0) first = 0; o = 0; } break; } case BE_INT: printf("%d", elem->data.integer); break; case BE_UNS: printf("%u", elem->data.uns); break; case BE_UNS64: { /* idea borrowed from by Marshall Rose */ double d; int j, carry; char *cpf, *cpl, last[6], first[30]; if (elem->data.uns64.high == 0) { printf("%u", elem->data.uns64.low); break; } d = elem->data.uns64.high * 4294967296.0; /* 2^32 */ if (elem->data.uns64.high <= 0x1fffff) { d += elem->data.uns64.low; #if 0 /*is looks illegal, but what is the intention?*/ printf("%.f", d); #else printf("%f", d); #endif break; } d += (elem->data.uns64.low & 0xfffff000); #if 0 /*is looks illegal, but what is the intention?*/ snprintf(first, sizeof(first), "%.f", d); #else snprintf(first, sizeof(first), "%f", d); #endif snprintf(last, sizeof(last), "%5.5d", elem->data.uns64.low & 0xfff); for (carry = 0, cpf = first+strlen(first)-1, cpl = last+4; cpl >= last; cpf--, cpl--) { j = carry + (*cpf - '0') + (*cpl - '0'); if (j > 9) { j -= 10; carry = 1; } else { carry = 0; } *cpf = j + '0'; } fputs(first, stdout); break; } case BE_STR: { register int printable = 1, first = 1; const u_char *p = elem->data.str; for (i = asnlen; printable && i-- > 0; p++) printable = isprint(*p) || isspace(*p); p = elem->data.str; if (printable) { putchar('"'); (void)fn_print(p, p + asnlen); putchar('"'); } else for (i = asnlen; i-- > 0; p++) { printf(first ? "%.2x" : "_%.2x", *p); first = 0; } break; } case BE_SEQ: printf("Seq(%u)", elem->asnlen); break; case BE_INETADDR: if (asnlen != ASNLEN_INETADDR) printf("[inetaddr len!=%d]", ASNLEN_INETADDR); for (i = asnlen; i-- > 0; p++) { printf((i == asnlen-1) ? "%u" : ".%u", *p); } break; case BE_NOSUCHOBJECT: case BE_NOSUCHINST: case BE_ENDOFMIBVIEW: printf("[%s]", Class[EXCEPTIONS].Id[elem->id]); break; case BE_PDU: printf("%s(%u)", Class[CONTEXT].Id[elem->id], elem->asnlen); break; case BE_ANY: fputs("[BE_ANY!?]", stdout); break; default: fputs("[be!?]", stdout); break; } } #ifdef notdef /* * This is a brute force ASN.1 printer: recurses to dump an entire structure. * This will work for any ASN.1 stream, not just an SNMP PDU. * * By adding newlines and spaces at the correct places, this would print in * Rose-Normal-Form. * * This is not currently used. */ static void asn1_decode(u_char *p, u_int length) { struct be elem; int i = 0; while (i >= 0 && length > 0) { i = asn1_parse(p, length, &elem); if (i >= 0) { fputs(" ", stdout); asn1_print(&elem); if (elem.type == BE_SEQ || elem.type == BE_PDU) { fputs(" {", stdout); asn1_decode(elem.data.raw, elem.asnlen); fputs(" }", stdout); } length -= i; p += i; } } } #endif #ifdef LIBSMI struct smi2be { SmiBasetype basetype; int be; }; static struct smi2be smi2betab[] = { { SMI_BASETYPE_INTEGER32, BE_INT }, { SMI_BASETYPE_OCTETSTRING, BE_STR }, { SMI_BASETYPE_OCTETSTRING, BE_INETADDR }, { SMI_BASETYPE_OBJECTIDENTIFIER, BE_OID }, { SMI_BASETYPE_UNSIGNED32, BE_UNS }, { SMI_BASETYPE_INTEGER64, BE_NONE }, { SMI_BASETYPE_UNSIGNED64, BE_UNS64 }, { SMI_BASETYPE_FLOAT32, BE_NONE }, { SMI_BASETYPE_FLOAT64, BE_NONE }, { SMI_BASETYPE_FLOAT128, BE_NONE }, { SMI_BASETYPE_ENUM, BE_INT }, { SMI_BASETYPE_BITS, BE_STR }, { SMI_BASETYPE_UNKNOWN, BE_NONE } }; static void smi_decode_oid(struct be *elem, unsigned int *oid, unsigned int oidsize, unsigned int *oidlen) { u_char *p = (u_char *)elem->data.raw; u_int32_t asnlen = elem->asnlen; int o = 0, first = -1, i = asnlen; for (*oidlen = 0; sflag && i-- > 0; p++) { o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8); if (*p & ASN_LONGLEN) continue; /* * first subitem encodes two items with 1st*OIDMUX+2nd * (see X.690:1997 clause 8.19 for the details) */ if (first < 0) { first = 0; if (*oidlen < oidsize) { oid[*oidlen] = o / OIDMUX; if (oid[*oidlen] > 2) oid[*oidlen] = 2; } o -= oid[*oidlen] * OIDMUX; if (*oidlen < oidsize) (*oidlen)++; } if (*oidlen < oidsize) { oid[(*oidlen)++] = o; } o = 0; } } static int smi_check_type(SmiBasetype basetype, int be) { int i; for (i = 0; smi2betab[i].basetype != SMI_BASETYPE_UNKNOWN; i++) { if (smi2betab[i].basetype == basetype && smi2betab[i].be == be) { return 1; } } return 0; } static int smi_check_a_range(SmiType *smiType, SmiRange *smiRange, struct be *elem) { int ok = 1; switch (smiType->basetype) { case SMI_BASETYPE_OBJECTIDENTIFIER: case SMI_BASETYPE_OCTETSTRING: if (smiRange->minValue.value.unsigned32 == smiRange->maxValue.value.unsigned32) { ok = (elem->asnlen == smiRange->minValue.value.unsigned32); } else { ok = (elem->asnlen >= smiRange->minValue.value.unsigned32 && elem->asnlen <= smiRange->maxValue.value.unsigned32); } break; case SMI_BASETYPE_INTEGER32: ok = (elem->data.integer >= smiRange->minValue.value.integer32 && elem->data.integer <= smiRange->maxValue.value.integer32); break; case SMI_BASETYPE_UNSIGNED32: ok = (elem->data.uns >= smiRange->minValue.value.unsigned32 && elem->data.uns <= smiRange->maxValue.value.unsigned32); break; case SMI_BASETYPE_UNSIGNED64: /* XXX */ break; /* case SMI_BASETYPE_INTEGER64: SMIng */ /* case SMI_BASETYPE_FLOAT32: SMIng */ /* case SMI_BASETYPE_FLOAT64: SMIng */ /* case SMI_BASETYPE_FLOAT128: SMIng */ case SMI_BASETYPE_ENUM: case SMI_BASETYPE_BITS: case SMI_BASETYPE_UNKNOWN: ok = 1; break; } return ok; } static int smi_check_range(SmiType *smiType, struct be *elem) { SmiRange *smiRange; int ok = 1; for (smiRange = smiGetFirstRange(smiType); smiRange; smiRange = smiGetNextRange(smiRange)) { ok = smi_check_a_range(smiType, smiRange, elem); if (ok) { break; } } if (ok) { SmiType *parentType; parentType = smiGetParentType(smiType); if (parentType) { ok = smi_check_range(parentType, elem); } } return ok; } static SmiNode *smi_print_variable(struct be *elem) { unsigned int oid[128], oidlen; SmiNode *smiNode = NULL; int i; smi_decode_oid(elem, oid, sizeof(oid)/sizeof(unsigned int), &oidlen); smiNode = smiGetNodeByOID(oidlen, oid); if (! smiNode) { asn1_print(elem); return NULL; } if (vflag) { fputs(smiGetNodeModule(smiNode)->name, stdout); fputs("::", stdout); } fputs(smiNode->name, stdout); if (smiNode->oidlen < oidlen) { for (i = smiNode->oidlen; i < oidlen; i++) { printf(".%u", oid[i]); } } return smiNode; } static void smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem) { unsigned int oid[128], oidlen; SmiType *smiType; SmiNamedNumber *nn; int i, done = 0; if (! smiNode || ! (smiNode->nodekind & (SMI_NODEKIND_SCALAR | SMI_NODEKIND_COLUMN))) { asn1_print(elem); return; } if (elem->type == BE_NOSUCHOBJECT || elem->type == BE_NOSUCHINST || elem->type == BE_ENDOFMIBVIEW) { asn1_print(elem); return; } if (NOTIFY_CLASS(pduid) && smiNode->access < SMI_ACCESS_NOTIFY) { fputs("[notNotifyable]", stdout); } if (READ_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_ONLY) { fputs("[notReadable]", stdout); } if (WRITE_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_WRITE) { fputs("[notWritable]", stdout); } if (RESPONSE_CLASS(pduid) && smiNode->access == SMI_ACCESS_NOT_ACCESSIBLE) { fputs("[noAccess]", stdout); } smiType = smiGetNodeType(smiNode); if (! smiType) { asn1_print(elem); return; } if (! smi_check_type(smiType->basetype, elem->type)) { fputs("[wrongType]", stdout); } if (! smi_check_range(smiType, elem)) { fputs("[outOfRange]", stdout); } /* resolve bits to named bits */ /* check whether instance identifier is valid */ /* apply display hints (integer, octetstring) */ /* convert instance identifier to index type values */ switch (elem->type) { case BE_OID: if (smiType->basetype == SMI_BASETYPE_BITS) { /* print bit labels */ } else { smi_decode_oid(elem, oid, sizeof(oid)/sizeof(unsigned int), &oidlen); smiNode = smiGetNodeByOID(oidlen, oid); if (smiNode) { if (vflag) { fputs(smiGetNodeModule(smiNode)->name, stdout); fputs("::", stdout); } fputs(smiNode->name, stdout); if (smiNode->oidlen < oidlen) { for (i = smiNode->oidlen; i < oidlen; i++) { printf(".%u", oid[i]); } } done++; } } break; case BE_INT: if (smiType->basetype == SMI_BASETYPE_ENUM) { for (nn = smiGetFirstNamedNumber(smiType); nn; nn = smiGetNextNamedNumber(nn)) { if (nn->value.value.integer32 == elem->data.integer) { fputs(nn->name, stdout); printf("(%d)", elem->data.integer); done++; break; } } } break; } if (! done) { asn1_print(elem); } } #endif /* * General SNMP header * SEQUENCE { * version INTEGER {version-1(0)}, * community OCTET STRING, * data ANY -- PDUs * } * PDUs for all but Trap: (see rfc1157 from page 15 on) * SEQUENCE { * request-id INTEGER, * error-status INTEGER, * error-index INTEGER, * varbindlist SEQUENCE OF * SEQUENCE { * name ObjectName, * value ObjectValue * } * } * PDU for Trap: * SEQUENCE { * enterprise OBJECT IDENTIFIER, * agent-addr NetworkAddress, * generic-trap INTEGER, * specific-trap INTEGER, * time-stamp TimeTicks, * varbindlist SEQUENCE OF * SEQUENCE { * name ObjectName, * value ObjectValue * } * } */ /* * Decode SNMP varBind */ static void varbind_print(u_char pduid, const u_char *np, u_int length) { struct be elem; int count = 0, ind; #ifdef LIBSMI SmiNode *smiNode = NULL; #endif /* Sequence of varBind */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_SEQ) { fputs("[!SEQ of varbind]", stdout); asn1_print(&elem); return; } if (count < length) printf("[%d extra after SEQ of varbind]", length - count); /* descend */ length = elem.asnlen; np = (u_char *)elem.data.raw; for (ind = 1; length > 0; ind++) { const u_char *vbend; u_int vblength; fputs(" ", stdout); /* Sequence */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_SEQ) { fputs("[!varbind]", stdout); asn1_print(&elem); return; } vbend = np + count; vblength = length - count; /* descend */ length = elem.asnlen; np = (u_char *)elem.data.raw; /* objName (OID) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_OID) { fputs("[objName!=OID]", stdout); asn1_print(&elem); return; } #ifdef LIBSMI smiNode = smi_print_variable(&elem); #else asn1_print(&elem); #endif length -= count; np += count; if (pduid != GETREQ && pduid != GETNEXTREQ && pduid != GETBULKREQ) fputs("=", stdout); /* objVal (ANY) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (pduid == GETREQ || pduid == GETNEXTREQ || pduid == GETBULKREQ) { if (elem.type != BE_NULL) { fputs("[objVal!=NULL]", stdout); asn1_print(&elem); } } else { if (elem.type != BE_NULL) { #ifdef LIBSMI smi_print_value(smiNode, pduid, &elem); #else asn1_print(&elem); #endif } } length = vblength; np = vbend; } } /* * Decode SNMP PDUs: GetRequest, GetNextRequest, GetResponse, SetRequest, * GetBulk, Inform, V2Trap, and Report */ static void snmppdu_print(u_char pduid, const u_char *np, u_int length) { struct be elem; int count = 0, error; /* reqId (Integer) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[reqId!=INT]", stdout); asn1_print(&elem); return; } if (vflag) printf("R=%d ", elem.data.integer); length -= count; np += count; /* errorStatus (Integer) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[errorStatus!=INT]", stdout); asn1_print(&elem); return; } error = 0; if ((pduid == GETREQ || pduid == GETNEXTREQ || pduid == SETREQ || pduid == INFORMREQ || pduid == V2TRAP || pduid == REPORT) && elem.data.integer != 0) { char errbuf[10]; printf("[errorStatus(%s)!=0]", DECODE_ErrorStatus(elem.data.integer)); } else if (pduid == GETBULKREQ) { printf(" N=%d", elem.data.integer); } else if (elem.data.integer != 0) { char errbuf[10]; printf(" %s", DECODE_ErrorStatus(elem.data.integer)); error = elem.data.integer; } length -= count; np += count; /* errorIndex (Integer) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[errorIndex!=INT]", stdout); asn1_print(&elem); return; } if ((pduid == GETREQ || pduid == GETNEXTREQ || pduid == SETREQ || pduid == INFORMREQ || pduid == V2TRAP || pduid == REPORT) && elem.data.integer != 0) printf("[errorIndex(%d)!=0]", elem.data.integer); else if (pduid == GETBULKREQ) printf(" M=%d", elem.data.integer); else if (elem.data.integer != 0) { if (!error) printf("[errorIndex(%d) w/o errorStatus]", elem.data.integer); else { printf("@%d", elem.data.integer); error = elem.data.integer; } } else if (error) { fputs("[errorIndex==0]", stdout); error = 0; } length -= count; np += count; varbind_print(pduid, np, length); return; } /* * Decode SNMP Trap PDU */ static void trappdu_print(const u_char *np, u_int length) { struct be elem; int count = 0, generic; putchar(' '); /* enterprise (oid) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_OID) { fputs("[enterprise!=OID]", stdout); asn1_print(&elem); return; } asn1_print(&elem); length -= count; np += count; putchar(' '); /* agent-addr (inetaddr) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INETADDR) { fputs("[agent-addr!=INETADDR]", stdout); asn1_print(&elem); return; } asn1_print(&elem); length -= count; np += count; /* generic-trap (Integer) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[generic-trap!=INT]", stdout); asn1_print(&elem); return; } generic = elem.data.integer; { char buf[10]; printf(" %s", DECODE_GenericTrap(generic)); } length -= count; np += count; /* specific-trap (Integer) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[specific-trap!=INT]", stdout); asn1_print(&elem); return; } if (generic != GT_ENTERPRISE) { if (elem.data.integer != 0) printf("[specific-trap(%d)!=0]", elem.data.integer); } else printf(" s=%d", elem.data.integer); length -= count; np += count; putchar(' '); /* time-stamp (TimeTicks) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_UNS) { /* XXX */ fputs("[time-stamp!=TIMETICKS]", stdout); asn1_print(&elem); return; } asn1_print(&elem); length -= count; np += count; varbind_print (TRAP, np, length); return; } /* * Decode arbitrary SNMP PDUs. */ static void pdu_print(const u_char *np, u_int length, int version) { struct be pdu; int count = 0; /* PDU (Context) */ if ((count = asn1_parse(np, length, &pdu)) < 0) return; if (pdu.type != BE_PDU) { fputs("[no PDU]", stdout); return; } if (count < length) printf("[%d extra after PDU]", length - count); if (vflag) { fputs("{ ", stdout); } asn1_print(&pdu); fputs(" ", stdout); /* descend into PDU */ length = pdu.asnlen; np = (u_char *)pdu.data.raw; if (version == SNMP_VERSION_1 && (pdu.id == GETBULKREQ || pdu.id == INFORMREQ || pdu.id == V2TRAP || pdu.id == REPORT)) { printf("[v2 PDU in v1 message]"); return; } if (version == SNMP_VERSION_2 && pdu.id == TRAP) { printf("[v1 PDU in v2 message]"); return; } switch (pdu.id) { case TRAP: trappdu_print(np, length); break; case GETREQ: case GETNEXTREQ: case GETRESP: case SETREQ: case GETBULKREQ: case INFORMREQ: case V2TRAP: case REPORT: snmppdu_print(pdu.id, np, length); break; } if (vflag) { fputs("} ", stdout); } } /* * Decode a scoped SNMP PDU. */ static void scopedpdu_print(const u_char *np, u_int length, int version) { struct be elem; int i, count = 0; /* Sequence */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_SEQ) { fputs("[!scoped PDU]", stdout); asn1_print(&elem); return; } length = elem.asnlen; np = (u_char *)elem.data.raw; /* contextEngineID (OCTET STRING) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_STR) { fputs("[contextEngineID!=STR]", stdout); asn1_print(&elem); return; } length -= count; np += count; fputs("E= ", stdout); for (i = 0; i < (int)elem.asnlen; i++) { printf("0x%02X", elem.data.str[i]); } fputs(" ", stdout); /* contextName (OCTET STRING) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_STR) { fputs("[contextName!=STR]", stdout); asn1_print(&elem); return; } length -= count; np += count; printf("C=%.*s ", (int)elem.asnlen, elem.data.str); pdu_print(np, length, version); } /* * Decode SNMP Community Header (SNMPv1 and SNMPv2c) */ static void community_print(const u_char *np, u_int length, int version) { struct be elem; int count = 0; /* Community (String) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_STR) { fputs("[comm!=STR]", stdout); asn1_print(&elem); return; } /* default community */ if (!(elem.asnlen == sizeof(DEF_COMMUNITY) - 1 && strncmp((char *)elem.data.str, DEF_COMMUNITY, sizeof(DEF_COMMUNITY) - 1) == 0)) /* ! "public" */ printf("C=%.*s ", (int)elem.asnlen, elem.data.str); length -= count; np += count; pdu_print(np, length, version); } /* * Decode SNMPv3 User-based Security Message Header (SNMPv3) */ static void usm_print(const u_char *np, u_int length) { struct be elem; int count = 0; /* Sequence */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_SEQ) { fputs("[!usm]", stdout); asn1_print(&elem); return; } length = elem.asnlen; np = (u_char *)elem.data.raw; /* msgAuthoritativeEngineID (OCTET STRING) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_STR) { fputs("[msgAuthoritativeEngineID!=STR]", stdout); asn1_print(&elem); return; } length -= count; np += count; /* msgAuthoritativeEngineBoots (INTEGER) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[msgAuthoritativeEngineBoots!=INT]", stdout); asn1_print(&elem); return; } if (vflag) printf("B=%d ", elem.data.integer); length -= count; np += count; /* msgAuthoritativeEngineTime (INTEGER) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[msgAuthoritativeEngineTime!=INT]", stdout); asn1_print(&elem); return; } if (vflag) printf("T=%d ", elem.data.integer); length -= count; np += count; /* msgUserName (OCTET STRING) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_STR) { fputs("[msgUserName!=STR]", stdout); asn1_print(&elem); return; } length -= count; np += count; printf("U=%.*s ", (int)elem.asnlen, elem.data.str); /* msgAuthenticationParameters (OCTET STRING) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_STR) { fputs("[msgAuthenticationParameters!=STR]", stdout); asn1_print(&elem); return; } length -= count; np += count; /* msgPrivacyParameters (OCTET STRING) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_STR) { fputs("[msgPrivacyParameters!=STR]", stdout); asn1_print(&elem); return; } length -= count; np += count; if (count < length) printf("[%d extra after usm SEQ]", length - count); } /* * Decode SNMPv3 Message Header (SNMPv3) */ static void v3msg_print(const u_char *np, u_int length) { struct be elem; int count = 0; u_char flags; int model; const u_char *xnp = np; int xlength = length; /* Sequence */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_SEQ) { fputs("[!message]", stdout); asn1_print(&elem); return; } length = elem.asnlen; np = (u_char *)elem.data.raw; if (vflag) { fputs("{ ", stdout); } /* msgID (INTEGER) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[msgID!=INT]", stdout); asn1_print(&elem); return; } length -= count; np += count; /* msgMaxSize (INTEGER) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[msgMaxSize!=INT]", stdout); asn1_print(&elem); return; } length -= count; np += count; /* msgFlags (OCTET STRING) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_STR) { fputs("[msgFlags!=STR]", stdout); asn1_print(&elem); return; } if (elem.asnlen != 1) { printf("[msgFlags size %d]", elem.asnlen); return; } flags = elem.data.str[0]; if (flags != 0x00 && flags != 0x01 && flags != 0x03 && flags != 0x04 && flags != 0x05 && flags != 0x07) { printf("[msgFlags=0x%02X]", flags); return; } length -= count; np += count; fputs("F=", stdout); if (flags & 0x01) fputs("a", stdout); if (flags & 0x02) fputs("p", stdout); if (flags & 0x04) fputs("r", stdout); fputs(" ", stdout); /* msgSecurityModel (INTEGER) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[msgSecurityModel!=INT]", stdout); asn1_print(&elem); return; } model = elem.data.integer; length -= count; np += count; if (count < length) printf("[%d extra after message SEQ]", length - count); if (vflag) { fputs("} ", stdout); } if (model == 3) { if (vflag) { fputs("{ USM ", stdout); } } else { printf("[security model %d]", model); return; } np = xnp + (np - xnp); length = xlength - (np - xnp); /* msgSecurityParameters (OCTET STRING) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_STR) { fputs("[msgSecurityParameters!=STR]", stdout); asn1_print(&elem); return; } length -= count; np += count; if (model == 3) { usm_print(elem.data.str, elem.asnlen); if (vflag) { fputs("} ", stdout); } } if (vflag) { fputs("{ ScopedPDU ", stdout); } scopedpdu_print(np, length, 3); if (vflag) { fputs("} ", stdout); } } /* * Decode SNMP header and pass on to PDU printing routines */ void snmp_print(const u_char *np, u_int length) { struct be elem; int count = 0; int version = 0; truncated = 0; /* truncated packet? */ if (np + length > snapend) { truncated = 1; length = snapend - np; } putchar(' '); /* initial Sequence */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_SEQ) { fputs("[!init SEQ]", stdout); asn1_print(&elem); return; } if (count < length) printf("[%d extra after iSEQ]", length - count); /* descend */ length = elem.asnlen; np = (u_char *)elem.data.raw; /* Version (INTEGER) */ if ((count = asn1_parse(np, length, &elem)) < 0) return; if (elem.type != BE_INT) { fputs("[version!=INT]", stdout); asn1_print(&elem); return; } switch (elem.data.integer) { case SNMP_VERSION_1: case SNMP_VERSION_2: case SNMP_VERSION_3: if (vflag) printf("{ %s ", SnmpVersion[elem.data.integer]); break; default: printf("[version = %d]", elem.data.integer); return; } version = elem.data.integer; length -= count; np += count; switch (version) { case SNMP_VERSION_1: case SNMP_VERSION_2: community_print(np, length, version); break; case SNMP_VERSION_3: v3msg_print(np, length); break; default: printf("[version = %d]", elem.data.integer); break; } if (vflag) { fputs("} ", stdout); } } tcpdump-3.7.2/print-stp.c0100644000076500000240000000364307627054633014466 0ustar fennerstaff/* * Copyright (c) 2000 Lennert Buytenhek * * This software may be distributed either under the terms of the * BSD-style license that accompanies tcpdump or the GNU General * Public License * * Format and print IEEE 802.1d spanning tree protocol packets. * Contributed by Lennert Buytenhek */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.6.6.1 2002/05/29 10:00:00 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" static void stp_print_bridge_id(const u_char *p) { printf("%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); } static void stp_print_config_bpdu(const u_char *p, u_int length) { printf("config "); if (p[7] & 1) printf("TOP_CHANGE "); if (p[7] & 0x80) printf("TOP_CHANGE_ACK "); stp_print_bridge_id(p+20); printf(".%.2x%.2x ", p[28], p[29]); printf("root "); stp_print_bridge_id(p+8); printf(" pathcost %i ", (p[16] << 24) | (p[17] << 16) | (p[18] << 8) | p[19]); printf("age %i ", p[30]); printf("max %i ", p[32]); printf("hello %i ", p[34]); printf("fdelay %i ", p[36]); } static void stp_print_tcn_bpdu(const u_char *p, u_int length) { printf("tcn"); } /* * Print 802.1d packets. */ void stp_print(const u_char *p, u_int length) { if (length < 7) goto trunc; printf("802.1d "); if (p[2] != 0x03 || p[3] || p[4] || p[5]) { printf("unknown version"); return; } switch (p[6]) { case 0: if (length < 10) goto trunc; stp_print_config_bpdu(p, length); break; case 1: stp_print_tcn_bpdu(p, length); break; default: printf("unknown type %i", p[6]); break; } return; trunc: printf("[|stp %d]", length); } tcpdump-3.7.2/print-sunrpc.c0100644000076500000240000000755507627054633015200 0ustar fennerstaff/* * Copyright (c) 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.39.6.1 2002/06/01 23:51:16 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #ifdef HAVE_RPC_RPCENT_H #include #endif #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ip.h" #ifdef INET6 #include "ip6.h" #endif static struct tok proc2str[] = { { PMAPPROC_NULL, "null" }, { PMAPPROC_SET, "set" }, { PMAPPROC_UNSET, "unset" }, { PMAPPROC_GETPORT, "getport" }, { PMAPPROC_DUMP, "dump" }, { PMAPPROC_CALLIT, "call" }, { 0, NULL } }; /* Forwards */ static char *progstr(u_int32_t); void sunrpcrequest_print(register const u_char *bp, register u_int length, register const u_char *bp2) { register const struct rpc_msg *rp; register const struct ip *ip; #ifdef INET6 register const struct ip6_hdr *ip6; #endif u_int32_t x; char srcid[20], dstid[20]; /*fits 32bit*/ rp = (struct rpc_msg *)bp; if (!nflag) { snprintf(srcid, sizeof(srcid), "0x%x", (u_int32_t)ntohl(rp->rm_xid)); strlcpy(dstid, "sunrpc", sizeof(dstid)); } else { snprintf(srcid, sizeof(srcid), "0x%x", (u_int32_t)ntohl(rp->rm_xid)); snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT); } switch (IP_V((struct ip *)bp2)) { case 4: ip = (struct ip *)bp2; printf("%s.%s > %s.%s: %d", ipaddr_string(&ip->ip_src), srcid, ipaddr_string(&ip->ip_dst), dstid, length); break; #ifdef INET6 case 6: ip6 = (struct ip6_hdr *)bp2; printf("%s.%s > %s.%s: %d", ip6addr_string(&ip6->ip6_src), srcid, ip6addr_string(&ip6->ip6_dst), dstid, length); break; #endif default: printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length); break; } printf(" %s", tok2str(proc2str, " proc #%u", (u_int32_t)ntohl(rp->rm_call.cb_proc))); x = ntohl(rp->rm_call.cb_rpcvers); if (x != 2) printf(" [rpcver %u]", x); switch (ntohl(rp->rm_call.cb_proc)) { case PMAPPROC_SET: case PMAPPROC_UNSET: case PMAPPROC_GETPORT: case PMAPPROC_CALLIT: x = ntohl(rp->rm_call.cb_prog); if (!nflag) printf(" %s", progstr(x)); else printf(" %u", x); printf(".%u", (u_int32_t)ntohl(rp->rm_call.cb_vers)); break; } } static char * progstr(prog) u_int32_t prog; { register struct rpcent *rp; static char buf[32]; static int lastprog = 0; if (lastprog != 0 && prog == lastprog) return (buf); rp = getrpcbynumber(prog); if (rp == NULL) (void) snprintf(buf, sizeof(buf), "#%u", prog); else strlcpy(buf, rp->r_name, sizeof(buf)); return (buf); } tcpdump-3.7.2/print-tcp.c0100644000076500000240000003546507405070204014437 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.95 2001/12/10 08:21:24 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "extract.h" #include "tcp.h" #include "ip.h" #ifdef INET6 #include "ip6.h" #endif #include "nameser.h" static void print_tcp_rst_data(register const u_char *sp, u_int length); #define MAX_RST_DATA_LEN 30 struct tha { #ifndef INET6 struct in_addr src; struct in_addr dst; #else struct in6_addr src; struct in6_addr dst; #endif /*INET6*/ u_int port; }; struct tcp_seq_hash { struct tcp_seq_hash *nxt; struct tha addr; tcp_seq seq; tcp_seq ack; }; #define TSEQ_HASHSIZE 919 /* These tcp optinos do not have the size octet */ #define ZEROLENOPT(o) ((o) == TCPOPT_EOL || (o) == TCPOPT_NOP) static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE]; #ifndef TELNET_PORT #define TELNET_PORT 23 #endif #ifndef BGP_PORT #define BGP_PORT 179 #endif #define NETBIOS_SSN_PORT 139 #ifndef PPTP_PORT #define PPTP_PORT 1723 #endif #define BEEP_PORT 10288 #ifndef NFS_PORT #define NFS_PORT 2049 #endif #define MSDP_PORT 639 static int tcp_cksum(register const struct ip *ip, register const struct tcphdr *tp, register int len) { 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.len = htons(len); /* XXX */ phu.ph.mbz = 0; phu.ph.proto = IPPROTO_TCP; memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t)); memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t)); sp = &phu.pa[0]; return in_cksum((u_short *)tp, len, sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]); } #ifdef INET6 static int tcp6_cksum(const struct ip6_hdr *ip6, const struct tcphdr *tp, int len) { int i, tlen; 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; tlen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr) - ((const char *)tp - (const char*)ip6); /* 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(tlen); phu.ph.ph_nxt = IPPROTO_TCP; sum = 0; for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) sum += phu.pa[i]; sp = (const u_int16_t *)tp; for (i = 0; i < (tlen & ~1); i += 2) sum += *sp++; if (tlen & 1) sum += htons((*(const u_int8_t *)sp) << 8); while (sum > 0xffff) sum = (sum & 0xffff) + (sum >> 16); sum = ~sum & 0xffff; return (sum); } #endif void tcp_print(register const u_char *bp, register u_int length, register const u_char *bp2, int fragmented) { register const struct tcphdr *tp; register const struct ip *ip; register u_char flags; register int hlen; register char ch; u_int16_t sport, dport, win, urp; u_int32_t seq, ack, thseq, thack; int threv; #ifdef INET6 register const struct ip6_hdr *ip6; #endif tp = (struct tcphdr *)bp; ip = (struct ip *)bp2; #ifdef INET6 if (IP_V(ip) == 6) ip6 = (struct ip6_hdr *)bp2; else ip6 = NULL; #endif /*INET6*/ ch = '\0'; if (!TTEST(tp->th_dport)) { (void)printf("%s > %s: [|tcp]", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); return; } sport = ntohs(tp->th_sport); dport = ntohs(tp->th_dport); hlen = TH_OFF(tp) * 4; /* * If data present and NFS port used, assume NFS. * Pass offset of data plus 4 bytes for RPC TCP msg length * to NFS print routines. */ if (!qflag) { if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && dport == NFS_PORT) { nfsreq_print((u_char *)tp + hlen + 4, length - hlen, (u_char *)ip); return; } else if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && sport == NFS_PORT) { nfsreply_print((u_char *)tp + hlen + 4, length - hlen, (u_char *)ip); return; } } #ifdef INET6 if (ip6) { if (ip6->ip6_nxt == IPPROTO_TCP) { (void)printf("%s.%s > %s.%s: ", ip6addr_string(&ip6->ip6_src), tcpport_string(sport), ip6addr_string(&ip6->ip6_dst), tcpport_string(dport)); } else { (void)printf("%s > %s: ", tcpport_string(sport), tcpport_string(dport)); } } else #endif /*INET6*/ { if (ip->ip_p == IPPROTO_TCP) { (void)printf("%s.%s > %s.%s: ", ipaddr_string(&ip->ip_src), tcpport_string(sport), ipaddr_string(&ip->ip_dst), tcpport_string(dport)); } else { (void)printf("%s > %s: ", tcpport_string(sport), tcpport_string(dport)); } } TCHECK(*tp); seq = (u_int32_t)ntohl(tp->th_seq); ack = (u_int32_t)ntohl(tp->th_ack); win = ntohs(tp->th_win); urp = ntohs(tp->th_urp); if (qflag) { (void)printf("tcp %d", length - TH_OFF(tp) * 4); return; } if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH| TH_ECNECHO|TH_CWR)) { if (flags & TH_SYN) putchar('S'); if (flags & TH_FIN) putchar('F'); if (flags & TH_RST) putchar('R'); if (flags & TH_PUSH) putchar('P'); if (flags & TH_CWR) putchar('W'); /* congestion _W_indow reduced (ECN) */ if (flags & TH_ECNECHO) putchar('E'); /* ecn _E_cho sent (ECN) */ } else putchar('.'); if (!Sflag && (flags & TH_ACK)) { register struct tcp_seq_hash *th; register int rev; struct tha tha; /* * Find (or record) the initial sequence numbers for * this conversation. (we pick an arbitrary * collating order so there's only one entry for * both directions). */ #ifdef INET6 memset(&tha, 0, sizeof(tha)); rev = 0; if (ip6) { if (sport > dport) rev = 1; else if (sport == dport) { int i; for (i = 0; i < 4; i++) { if (((u_int32_t *)(&ip6->ip6_src))[i] > ((u_int32_t *)(&ip6->ip6_dst))[i]) { rev = 1; break; } } } if (rev) { tha.src = ip6->ip6_dst; tha.dst = ip6->ip6_src; tha.port = dport << 16 | sport; } else { tha.dst = ip6->ip6_dst; tha.src = ip6->ip6_src; tha.port = sport << 16 | dport; } } else { if (sport > dport || (sport == dport && ip->ip_src.s_addr > ip->ip_dst.s_addr)) { rev = 1; } if (rev) { *(struct in_addr *)&tha.src = ip->ip_dst; *(struct in_addr *)&tha.dst = ip->ip_src; tha.port = dport << 16 | sport; } else { *(struct in_addr *)&tha.dst = ip->ip_dst; *(struct in_addr *)&tha.src = ip->ip_src; tha.port = sport << 16 | dport; } } #else if (sport < dport || (sport == dport && ip->ip_src.s_addr < ip->ip_dst.s_addr)) { tha.src = ip->ip_src, tha.dst = ip->ip_dst; tha.port = sport << 16 | dport; rev = 0; } else { tha.src = ip->ip_dst, tha.dst = ip->ip_src; tha.port = dport << 16 | sport; rev = 1; } #endif threv = rev; for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE]; th->nxt; th = th->nxt) if (!memcmp((char *)&tha, (char *)&th->addr, sizeof(th->addr))) break; if (!th->nxt || (flags & TH_SYN)) { /* didn't find it or new conversation */ if (th->nxt == NULL) { th->nxt = (struct tcp_seq_hash *) calloc(1, sizeof(*th)); if (th->nxt == NULL) error("tcp_print: calloc"); } th->addr = tha; if (rev) th->ack = seq, th->seq = ack - 1; else th->seq = seq, th->ack = ack - 1; } else { if (rev) seq -= th->ack, ack -= th->seq; else seq -= th->seq, ack -= th->ack; } thseq = th->seq; thack = th->ack; } else { /*fool gcc*/ thseq = thack = threv = 0; } if (hlen > length) { (void)printf(" [bad hdr length]"); return; } if (IP_V(ip) == 4 && vflag && !fragmented) { int sum; if (TTEST2(tp->th_sport, length)) { sum = tcp_cksum(ip, tp, length); if (sum != 0) (void)printf(" [bad tcp cksum %x!]", sum); else (void)printf(" [tcp sum ok]"); } } #ifdef INET6 if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) { int sum; if (TTEST2(tp->th_sport, length)) { sum = tcp6_cksum(ip6, tp, length); if (sum != 0) (void)printf(" [bad tcp cksum %x!]", sum); else (void)printf(" [tcp sum ok]"); } } #endif length -= hlen; if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) (void)printf(" %u:%u(%u)", seq, seq + length, length); if (flags & TH_ACK) (void)printf(" ack %u", ack); (void)printf(" win %d", win); if (flags & TH_URG) (void)printf(" urg %d", urp); /* * Handle any options. */ if ((hlen -= sizeof(*tp)) > 0) { register const u_char *cp; register int i, opt, len, datalen; cp = (const u_char *)tp + sizeof(*tp); putchar(' '); ch = '<'; while (hlen > 0) { putchar(ch); TCHECK(*cp); opt = *cp++; if (ZEROLENOPT(opt)) len = 1; else { TCHECK(*cp); len = *cp++; /* total including type, len */ if (len < 2 || len > hlen) goto bad; --hlen; /* account for length byte */ } --hlen; /* account for type byte */ datalen = 0; /* Bail if "l" bytes of data are not left or were not captured */ #define LENCHECK(l) { if ((l) > hlen) goto bad; TCHECK2(*cp, l); } switch (opt) { case TCPOPT_MAXSEG: (void)printf("mss"); datalen = 2; LENCHECK(datalen); (void)printf(" %u", EXTRACT_16BITS(cp)); break; case TCPOPT_EOL: (void)printf("eol"); break; case TCPOPT_NOP: (void)printf("nop"); break; case TCPOPT_WSCALE: (void)printf("wscale"); datalen = 1; LENCHECK(datalen); (void)printf(" %u", *cp); break; case TCPOPT_SACKOK: (void)printf("sackOK"); break; case TCPOPT_SACK: (void)printf("sack"); datalen = len - 2; if (datalen % 8 != 0) { (void)printf(" malformed sack "); } else { u_int32_t s, e; (void)printf(" sack %d ", datalen / 8); for (i = 0; i < datalen; i += 8) { LENCHECK(i + 4); s = EXTRACT_32BITS(cp + i); LENCHECK(i + 8); e = EXTRACT_32BITS(cp + i + 4); if (threv) { s -= thseq; e -= thseq; } else { s -= thack; e -= thack; } (void)printf("{%u:%u}", s, e); } (void)printf(" "); } break; case TCPOPT_ECHO: (void)printf("echo"); datalen = 4; LENCHECK(datalen); (void)printf(" %u", EXTRACT_32BITS(cp)); break; case TCPOPT_ECHOREPLY: (void)printf("echoreply"); datalen = 4; LENCHECK(datalen); (void)printf(" %u", EXTRACT_32BITS(cp)); break; case TCPOPT_TIMESTAMP: (void)printf("timestamp"); datalen = 8; LENCHECK(4); (void)printf(" %u", EXTRACT_32BITS(cp)); LENCHECK(datalen); (void)printf(" %u", EXTRACT_32BITS(cp + 4)); break; case TCPOPT_CC: (void)printf("cc"); datalen = 4; LENCHECK(datalen); (void)printf(" %u", EXTRACT_32BITS(cp)); break; case TCPOPT_CCNEW: (void)printf("ccnew"); datalen = 4; LENCHECK(datalen); (void)printf(" %u", EXTRACT_32BITS(cp)); break; case TCPOPT_CCECHO: (void)printf("ccecho"); datalen = 4; LENCHECK(datalen); (void)printf(" %u", EXTRACT_32BITS(cp)); break; default: (void)printf("opt-%d:", opt); datalen = len - 2; for (i = 0; i < datalen; ++i) { LENCHECK(i); (void)printf("%02x", cp[i]); } break; } /* Account for data printed */ cp += datalen; hlen -= datalen; /* Check specification against observed length */ ++datalen; /* option octet */ if (!ZEROLENOPT(opt)) ++datalen; /* size octet */ if (datalen != len) (void)printf("[len %d]", len); ch = ','; if (opt == TCPOPT_EOL) break; } putchar('>'); } if (length <= 0) return; /* * Decode payload if necessary. */ bp += TH_OFF(tp) * 4; if (flags & TH_RST) { if (vflag) print_tcp_rst_data(bp, length); } else { if (sport == TELNET_PORT || dport == TELNET_PORT) { if (!qflag && vflag) telnet_print(bp, length); } else if (sport == BGP_PORT || dport == BGP_PORT) bgp_print(bp, length); else if (sport == PPTP_PORT || dport == PPTP_PORT) pptp_print(bp, length); #ifdef TCPDUMP_DO_SMB else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT) nbt_tcp_print(bp, length); #endif else if (sport == BEEP_PORT || dport == BEEP_PORT) beep_print(bp, length); else if (length > 2 && (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT)) { /* * TCP DNS query has 2byte length at the head. * XXX packet could be unaligned, it can go strange */ ns_print(bp + 2, length - 2); } else if (sport == MSDP_PORT || dport == MSDP_PORT) { msdp_print(bp, length); } } return; bad: fputs("[bad opt]", stdout); if (ch != '\0') putchar('>'); return; trunc: fputs("[|tcp]", stdout); if (ch != '\0') putchar('>'); } /* * RFC1122 says the following on data in RST segments: * * 4.2.2.12 RST Segment: RFC-793 Section 3.4 * * A TCP SHOULD allow a received RST segment to include data. * * DISCUSSION * It has been suggested that a RST segment could contain * ASCII text that encoded and explained the cause of the * RST. No standard has yet been established for such * data. * */ static void print_tcp_rst_data(register const u_char *sp, u_int length) { int c; if (TTEST2(*sp, length)) printf(" [RST"); else printf(" [!RST"); if (length > MAX_RST_DATA_LEN) { length = MAX_RST_DATA_LEN; /* can use -X for longer */ putchar('+'); /* indicate we truncate */ } putchar(' '); while (length-- && sp <= snapend) { c = *sp++; safeputchar(c); } putchar(']'); } tcpdump-3.7.2/print-telnet.c0100644000076500000240000001444707347060110015141 0ustar fennerstaff/* $NetBSD: print-telnet.c,v 1.2 1999/10/11 12:40:12 sjg Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Simon J. Gerraty. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * @(#)Copyright (c) 1994, Simon J. Gerraty. * * This is free software. It comes with NO WARRANTY. * Permission to use, modify and distribute this source code * is granted subject to the following conditions. * 1/ that the above copyright notice and this notice * are preserved in all copies. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.18 2001/09/10 06:40:08 fenner Exp $"; #endif #include #include #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #define TELCMDS #define TELOPTS #include "telnet.h" /* normal */ static const char *cmds[] = { "IS", "SEND", "INFO", }; /* 37: Authentication */ static const char *authcmd[] = { "IS", "SEND", "REPLY", "NAME", }; static const char *authtype[] = { "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", "SRP", "RSA", "SSL", NULL, NULL, "LOKI", "SSA", "KEA_SJ", "KEA_SJ_INTEG", "DSS", "NTLM", }; /* 38: Encryption */ static const char *enccmd[] = { "IS", "SUPPORT", "REPLY", "START", "END", "REQUEST-START", "REQUEST-END", "END_KEYID", "DEC_KEYID", }; static const char *enctype[] = { "NULL", "DES_CFB64", "DES_OFB64", "DES3_CFB64", "DES3_OFB64", NULL, "CAST5_40_CFB64", "CAST5_40_OFB64", "CAST128_CFB64", "CAST128_OFB64", }; #define STR_OR_ID(x, tab) \ (((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x)) static char * numstr(int x) { static char buf[20]; snprintf(buf, sizeof(buf), "%#x", x); return buf; } /* sp points to IAC byte */ static int telnet_parse(const u_char *sp, u_int length, int print) { int i, c, x; const u_char *osp, *p; #define FETCH(c, sp, length) \ do { \ if (length < 1) \ goto pktend; \ TCHECK(*sp); \ c = *sp++; \ length--; \ } while (0) osp = sp; FETCH(c, sp, length); if (c != IAC) goto pktend; FETCH(c, sp, length); if (c == IAC) { /* ! */ if (print) printf("IAC IAC"); goto done; } i = c - TELCMD_FIRST; if (i < 0 || i > IAC - TELCMD_FIRST) goto pktend; switch (c) { case DONT: case DO: case WONT: case WILL: case SB: /* DONT/DO/WONT/WILL x */ FETCH(x, sp, length); if (x >= 0 && x < NTELOPTS) { if (print) (void)printf("%s %s", telcmds[i], telopts[x]); } else { if (print) (void)printf("%s %#x", telcmds[i], x); } if (c != SB) break; /* IAC SB .... IAC SE */ p = sp; while (length > p + 1 - sp) { if (p[0] == IAC && p[1] == SE) break; p++; } if (*p != IAC) goto pktend; switch (x) { case TELOPT_AUTHENTICATION: if (p <= sp) break; FETCH(c, sp, length); if (print) (void)printf(" %s", STR_OR_ID(c, authcmd)); if (p <= sp) break; FETCH(c, sp, length); if (print) (void)printf(" %s", STR_OR_ID(c, authtype)); break; case TELOPT_ENCRYPT: if (p <= sp) break; FETCH(c, sp, length); if (print) (void)printf(" %s", STR_OR_ID(c, enccmd)); if (p <= sp) break; FETCH(c, sp, length); if (print) (void)printf(" %s", STR_OR_ID(c, enctype)); break; default: if (p <= sp) break; FETCH(c, sp, length); if (print) (void)printf(" %s", STR_OR_ID(c, cmds)); break; } while (p > sp) { FETCH(x, sp, length); if (print) (void)printf(" %#x", x); } /* terminating IAC SE */ if (print) (void)printf(" SE"); sp += 2; length -= 2; break; default: if (print) (void)printf("%s", telcmds[i]); goto done; } done: return sp - osp; trunc: (void)printf("[|telnet]"); pktend: return -1; #undef FETCH } void telnet_print(const u_char *sp, u_int length) { int first = 1; const u_char *osp; int l; osp = sp; while (length > 0 && *sp == IAC) { l = telnet_parse(sp, length, 0); if (l < 0) break; /* * now print it */ if (Xflag && 2 < vflag) { if (first) printf("\nTelnet:"); hex_print_with_offset(sp, l, sp - osp); if (l > 8) printf("\n\t\t\t\t"); else printf("%*s\t", (8 - l) * 3, ""); } else printf("%s", (first) ? " [telnet " : ", "); (void)telnet_parse(sp, length, 1); first = 0; sp += l; length -= l; } if (!first) { if (Xflag && 2 < vflag) printf("\n"); else printf("]"); } } tcpdump-3.7.2/print-tftp.c0100644000076500000240000000747707015736477014652 0ustar fennerstaff/* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Format and print trivial file transfer protocol packets. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.31 1999/11/21 09:37:03 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #ifdef SEGSIZE #undef SEGSIZE /* SINIX sucks */ #endif #include #include #include #include #include "interface.h" #include "addrtoname.h" /* op code to string mapping */ static struct tok op2str[] = { { RRQ, "RRQ" }, /* read request */ { WRQ, "WRQ" }, /* write request */ { DATA, "DATA" }, /* data packet */ { ACK, "ACK" }, /* acknowledgement */ { ERROR, "ERROR" }, /* error code */ { 0, NULL } }; /* error code to string mapping */ static struct tok err2str[] = { { EUNDEF, "EUNDEF" }, /* not defined */ { ENOTFOUND, "ENOTFOUND" }, /* file not found */ { EACCESS, "EACCESS" }, /* access violation */ { ENOSPACE, "ENOSPACE" }, /* disk full or allocation exceeded */ { EBADOP, "EBADOP" }, /* illegal TFTP operation */ { EBADID, "EBADID" }, /* unknown transfer ID */ { EEXISTS, "EEXISTS" }, /* file already exists */ { ENOUSER, "ENOUSER" }, /* no such user */ { 0, NULL } }; /* * Print trivial file transfer program requests */ void tftp_print(register const u_char *bp, u_int length) { register const struct tftphdr *tp; register const char *cp; register const u_char *p; register int opcode, i; static char tstr[] = " [|tftp]"; tp = (const struct tftphdr *)bp; /* Print length */ printf(" %d", length); /* Print tftp request type */ TCHECK(tp->th_opcode); opcode = ntohs(tp->th_opcode); cp = tok2str(op2str, "tftp-#%d", opcode); printf(" %s", cp); /* Bail if bogus opcode */ if (*cp == 't') return; switch (opcode) { case RRQ: case WRQ: /* * XXX Not all arpa/tftp.h's specify th_stuff as any * array; use address of th_block instead */ #ifdef notdef p = (u_char *)tp->th_stuff; #else p = (u_char *)&tp->th_block; #endif fputs(" \"", stdout); i = fn_print(p, snapend); putchar('"'); if (i) goto trunc; break; case ACK: case DATA: TCHECK(tp->th_block); printf(" block %d", ntohs(tp->th_block)); break; case ERROR: /* Print error code string */ TCHECK(tp->th_code); printf(" %s ", tok2str(err2str, "tftp-err-#%d \"", ntohs(tp->th_code))); /* Print error message string */ i = fn_print((const u_char *)tp->th_data, snapend); putchar('"'); if (i) goto trunc; break; default: /* We shouldn't get here */ printf("(unknown #%d)", opcode); break; } return; trunc: fputs(tstr, stdout); return; } tcpdump-3.7.2/print-timed.c0100644000076500000240000000652307301014563014745 0ustar fennerstaff/* * Copyright (c) 2000 Ben Smithurst * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.3 2001/05/17 18:33:23 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "timed.h" #include "interface.h" static char *tsptype[TSPTYPENUMBER] = { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; void timed_print(register const u_char *bp, u_int length) { #define endof(x) ((u_char *)&(x) + sizeof (x)) struct tsp *tsp = (struct tsp *)bp; long sec, usec; const u_char *end; if (endof(tsp->tsp_type) > snapend) { fputs("[|timed]", stdout); return; } if (tsp->tsp_type < TSPTYPENUMBER) printf("TSP_%s", tsptype[tsp->tsp_type]); else printf("(tsp_type %#x)", tsp->tsp_type); if (endof(tsp->tsp_vers) > snapend) { fputs(" [|timed]", stdout); return; } printf(" vers %d", tsp->tsp_vers); if (endof(tsp->tsp_seq) > snapend) { fputs(" [|timed]", stdout); return; } printf(" seq %d", tsp->tsp_seq); if (tsp->tsp_type == TSP_LOOP) { if (endof(tsp->tsp_hopcnt) > snapend) { fputs(" [|timed]", stdout); return; } printf(" hopcnt %d", tsp->tsp_hopcnt); } else if (tsp->tsp_type == TSP_SETTIME || tsp->tsp_type == TSP_ADJTIME || tsp->tsp_type == TSP_SETDATE || tsp->tsp_type == TSP_SETDATEREQ) { if (endof(tsp->tsp_time) > snapend) { fputs(" [|timed]", stdout); return; } sec = ntohl((long)tsp->tsp_time.tv_sec); usec = ntohl((long)tsp->tsp_time.tv_usec); if (usec < 0) /* corrupt, skip the rest of the packet */ return; fputs(" time ", stdout); if (sec < 0 && usec != 0) { sec++; if (sec == 0) fputc('-', stdout); usec = 1000000 - usec; } printf("%ld.%06ld", sec, usec); } end = memchr(tsp->tsp_name, '\0', snapend - (u_char *)tsp->tsp_name); if (end == NULL) fputs(" [|timed]", stdout); else { fputs(" name ", stdout); fwrite(tsp->tsp_name, end - (u_char *)tsp->tsp_name, 1, stdout); } } tcpdump-3.7.2/print-token.c0100644000076500000240000001404107351666135014772 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Hacked version of print-ether.c Larry Lile * * Further tweaked to more closely resemble print-fddi.c * Guy Harris */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.13 2001/09/18 15:46:37 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "ether.h" #include "token.h" /* Extract src, dst addresses */ static inline void extract_token_addrs(const struct token_header *trp, char *fsrc, char *fdst) { memcpy(fdst, (const char *)trp->token_dhost, 6); memcpy(fsrc, (const char *)trp->token_shost, 6); } /* * Print the TR MAC header */ static inline void token_print(register const struct token_header *trp, register u_int length, register const u_char *fsrc, register const u_char *fdst) { const char *srcname, *dstname; srcname = etheraddr_string(fsrc); dstname = etheraddr_string(fdst); if (vflag) (void) printf("%02x %02x %s %s %d: ", trp->token_ac, trp->token_fc, srcname, dstname, length); else printf("%s %s %d: ", srcname, dstname, length); } static const char *broadcast_indicator[] = { "Non-Broadcast", "Non-Broadcast", "Non-Broadcast", "Non-Broadcast", "All-routes", "All-routes", "Single-route", "Single-route" }; static const char *direction[] = { "Forward", "Backward" }; static const char *largest_frame[] = { "516", "1500", "2052", "4472", "8144", "11407", "17800", "??" }; /* * This is the top level routine of the printer. 'p' is the points * to the TR header of the packet, 'tvp' is the timestamp, * 'length' is the length of the packet off the wire, and 'caplen' * is the number of bytes actually captured. */ void token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; const struct token_header *trp; u_short extracted_ethertype; struct ether_header ehdr; u_int route_len = 0, seg; trp = (const struct token_header *)p; ++infodelay; ts_print(&h->ts); if (caplen < TOKEN_HDRLEN) { printf("[|token-ring]"); goto out; } /* * Get the TR addresses into a canonical form */ extract_token_addrs(trp, (char*)ESRC(&ehdr), (char*)EDST(&ehdr)); /* * Some printers want to get back at the ethernet addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ snapend = p + caplen; /* * Actually, the only printers that use packetp are print-arp.c * and print-bootp.c, and they assume that packetp points to an * Ethernet header. The right thing to do is to fix them to know * which link type is in use when they excavate. XXX */ packetp = (u_char *)&ehdr; /* Adjust for source routing information in the MAC header */ if (IS_SOURCE_ROUTED(trp)) { /* Clear source-routed bit */ *ESRC(&ehdr) &= 0x7f; if (eflag) token_print(trp, length, ESRC(&ehdr), EDST(&ehdr)); route_len = RIF_LENGTH(trp); if (vflag) { printf("%s ", broadcast_indicator[BROADCAST(trp)]); printf("%s", direction[DIRECTION(trp)]); for (seg = 0; seg < SEGMENT_COUNT(trp); seg++) printf(" [%d:%d]", RING_NUMBER(trp, seg), BRIDGE_NUMBER(trp, seg)); } else { printf("rt = %x", ntohs(trp->token_rcf)); for (seg = 0; seg < SEGMENT_COUNT(trp); seg++) printf(":%x", ntohs(trp->token_rseg[seg])); } printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]); } else { if (eflag) token_print(trp, length, ESRC(&ehdr), EDST(&ehdr)); } /* Skip over token ring MAC header and routing information */ length -= TOKEN_HDRLEN + route_len; p += TOKEN_HDRLEN + route_len; caplen -= TOKEN_HDRLEN + route_len; /* Frame Control field determines interpretation of packet */ extracted_ethertype = 0; if (FRAME_TYPE(trp) == TOKEN_FC_LLC) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr), &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) token_print(trp, length + TOKEN_HDRLEN + route_len, ESRC(&ehdr), EDST(&ehdr)); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } if (!xflag && !qflag) default_print(p, caplen); } } else { /* Some kinds of TR packet we cannot handle intelligently */ /* XXX - dissect MAC packets if frame type is 0 */ if (!eflag) token_print(trp, length + TOKEN_HDRLEN + route_len, ESRC(&ehdr), EDST(&ehdr)); if (!xflag && !qflag) default_print(p, caplen); } if (xflag) default_print(p, caplen); out: putchar('\n'); --infodelay; if (infoprint) info(0); } tcpdump-3.7.2/print-udp.c0100644000076500000240000004257307360414704014446 0ustar fennerstaff/* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.101 2001/10/08 21:25:24 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #ifdef SEGSIZE #undef SEGSIZE #endif #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "appletalk.h" #include "udp.h" #include "ip.h" #ifdef INET6 #include "ip6.h" #endif #include "nameser.h" #include "nfs.h" #include "bootp.h" struct rtcphdr { u_int16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */ u_int16_t rh_len; /* length of message (in words) */ u_int32_t rh_ssrc; /* synchronization src id */ }; typedef struct { u_int32_t upper; /* more significant 32 bits */ u_int32_t lower; /* less significant 32 bits */ } ntp64; /* * Sender report. */ struct rtcp_sr { ntp64 sr_ntp; /* 64-bit ntp timestamp */ u_int32_t sr_ts; /* reference media timestamp */ u_int32_t sr_np; /* no. packets sent */ u_int32_t sr_nb; /* no. bytes sent */ }; /* * Receiver report. * Time stamps are middle 32-bits of ntp timestamp. */ struct rtcp_rr { u_int32_t rr_srcid; /* sender being reported */ u_int32_t rr_nl; /* no. packets lost */ u_int32_t rr_ls; /* extended last seq number received */ u_int32_t rr_dv; /* jitter (delay variance) */ u_int32_t rr_lsr; /* orig. ts from last rr from this src */ u_int32_t rr_dlsr; /* time from recpt of last rr to xmit time */ }; /*XXX*/ #define RTCP_PT_SR 200 #define RTCP_PT_RR 201 #define RTCP_PT_SDES 202 #define RTCP_SDES_CNAME 1 #define RTCP_SDES_NAME 2 #define RTCP_SDES_EMAIL 3 #define RTCP_SDES_PHONE 4 #define RTCP_SDES_LOC 5 #define RTCP_SDES_TOOL 6 #define RTCP_SDES_NOTE 7 #define RTCP_SDES_PRIV 8 #define RTCP_PT_BYE 203 #define RTCP_PT_APP 204 static void vat_print(const void *hdr, u_int len, register const struct udphdr *up) { /* vat/vt audio */ u_int ts = *(u_int16_t *)hdr; if ((ts & 0xf060) != 0) { /* probably vt */ (void)printf("udp/vt %u %d / %d", (u_int32_t)(ntohs(up->uh_ulen) - sizeof(*up)), ts & 0x3ff, ts >> 10); } else { /* probably vat */ u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]); u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]); printf("udp/vat %u c%d %u%s", (u_int32_t)(ntohs(up->uh_ulen) - sizeof(*up) - 8), i0 & 0xffff, i1, i0 & 0x800000? "*" : ""); /* audio format */ if (i0 & 0x1f0000) printf(" f%d", (i0 >> 16) & 0x1f); if (i0 & 0x3f000000) printf(" s%d", (i0 >> 24) & 0x3f); } } static void rtp_print(const void *hdr, u_int len, register const struct udphdr *up) { /* rtp v1 or v2 */ u_int *ip = (u_int *)hdr; u_int hasopt, hasext, contype, hasmarker; u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]); u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]); u_int dlen = ntohs(up->uh_ulen) - sizeof(*up) - 8; const char * ptype; ip += 2; len >>= 2; len -= 2; hasopt = 0; hasext = 0; if ((i0 >> 30) == 1) { /* rtp v1 */ hasopt = i0 & 0x800000; contype = (i0 >> 16) & 0x3f; hasmarker = i0 & 0x400000; ptype = "rtpv1"; } else { /* rtp v2 */ hasext = i0 & 0x10000000; contype = (i0 >> 16) & 0x7f; hasmarker = i0 & 0x800000; dlen -= 4; ptype = "rtp"; ip += 1; len -= 1; } printf("udp/%s %d c%d %s%s %d %u", ptype, dlen, contype, (hasopt || hasext)? "+" : "", hasmarker? "*" : "", i0 & 0xffff, i1); if (vflag) { printf(" %u", (u_int32_t)ntohl(((u_int *)hdr)[2])); if (hasopt) { u_int i2, optlen; do { i2 = ip[0]; optlen = (i2 >> 16) & 0xff; if (optlen == 0 || optlen > len) { printf(" !opt"); return; } ip += optlen; len -= optlen; } while ((int)i2 >= 0); } if (hasext) { u_int i2, extlen; i2 = ip[0]; extlen = (i2 & 0xffff) + 1; if (extlen > len) { printf(" !ext"); return; } ip += extlen; } if (contype == 0x1f) /*XXX H.261 */ printf(" 0x%04x", ip[0] >> 16); } } static const u_char * rtcp_print(const u_char *hdr, const u_char *ep) { /* rtp v2 control (rtcp) */ struct rtcp_rr *rr = 0; struct rtcp_sr *sr; struct rtcphdr *rh = (struct rtcphdr *)hdr; u_int len; u_int16_t flags; int cnt; double ts, dts; if ((u_char *)(rh + 1) > ep) { printf(" [|rtcp]"); return (ep); } len = (ntohs(rh->rh_len) + 1) * 4; flags = ntohs(rh->rh_flags); cnt = (flags >> 8) & 0x1f; switch (flags & 0xff) { case RTCP_PT_SR: sr = (struct rtcp_sr *)(rh + 1); printf(" sr"); if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh)) printf(" [%d]", len); if (vflag) printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc)); if ((u_char *)(sr + 1) > ep) { printf(" [|rtcp]"); return (ep); } ts = (double)((u_int32_t)ntohl(sr->sr_ntp.upper)) + ((double)((u_int32_t)ntohl(sr->sr_ntp.lower)) / 4294967296.0); printf(" @%.2f %u %up %ub", ts, (u_int32_t)ntohl(sr->sr_ts), (u_int32_t)ntohl(sr->sr_np), (u_int32_t)ntohl(sr->sr_nb)); rr = (struct rtcp_rr *)(sr + 1); break; case RTCP_PT_RR: printf(" rr"); if (len != cnt * sizeof(*rr) + sizeof(*rh)) printf(" [%d]", len); rr = (struct rtcp_rr *)(rh + 1); if (vflag) printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc)); break; case RTCP_PT_SDES: printf(" sdes %d", len); if (vflag) printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc)); cnt = 0; break; case RTCP_PT_BYE: printf(" bye %d", len); if (vflag) printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc)); cnt = 0; break; default: printf(" type-0x%x %d", flags & 0xff, len); cnt = 0; break; } if (cnt > 1) printf(" c%d", cnt); while (--cnt >= 0) { if ((u_char *)(rr + 1) > ep) { printf(" [|rtcp]"); return (ep); } if (vflag) printf(" %u", (u_int32_t)ntohl(rr->rr_srcid)); ts = (double)((u_int32_t)ntohl(rr->rr_lsr)) / 65536.; dts = (double)((u_int32_t)ntohl(rr->rr_dlsr)) / 65536.; printf(" %ul %us %uj @%.2f+%.2f", (u_int32_t)ntohl(rr->rr_nl) & 0x00ffffff, (u_int32_t)ntohl(rr->rr_ls), (u_int32_t)ntohl(rr->rr_dv), ts, dts); } return (hdr + len); } static int udp_cksum(register const struct ip *ip, register const struct udphdr *up, register int 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; register const u_int16_t *sp; /* pseudo-header.. */ phu.ph.len = htons(len); phu.ph.mbz = 0; phu.ph.proto = IPPROTO_UDP; memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t)); memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t)); sp = &phu.pa[0]; return in_cksum((u_short *)up, len, sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]); } #ifdef INET6 static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up, int len) { int i, tlen; 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; tlen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr) - ((const char *)up - (const char*)ip6); /* 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(tlen); phu.ph.ph_nxt = IPPROTO_UDP; sum = 0; for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) sum += phu.pa[i]; sp = (const u_int16_t *)up; for (i = 0; i < (tlen & ~1); i += 2) sum += *sp++; if (tlen & 1) sum += htons((*(const u_int8_t *)sp) << 8); while (sum > 0xffff) sum = (sum & 0xffff) + (sum >> 16); sum = ~sum & 0xffff; return (sum); } #endif /* XXX probably should use getservbyname() and cache answers */ #define TFTP_PORT 69 /*XXX*/ #define KERBEROS_PORT 88 /*XXX*/ #define SUNRPC_PORT 111 /*XXX*/ #define SNMP_PORT 161 /*XXX*/ #define NTP_PORT 123 /*XXX*/ #define SNMPTRAP_PORT 162 /*XXX*/ #define ISAKMP_PORT 500 /*XXX*/ #define TIMED_PORT 525 /*XXX*/ #define RIP_PORT 520 /*XXX*/ #define KERBEROS_SEC_PORT 750 /*XXX*/ #define L2TP_PORT 1701 /*XXX*/ #define ISAKMP_PORT_USER1 7500 /*XXX - nonstandard*/ #define ISAKMP_PORT_USER2 8500 /*XXX - nonstandard*/ #define RX_PORT_LOW 7000 /*XXX*/ #define RX_PORT_HIGH 7009 /*XXX*/ #define NETBIOS_NS_PORT 137 #define NETBIOS_DGRAM_PORT 138 #define CISCO_AUTORP_PORT 496 /*XXX*/ #define RADIUS_PORT 1645 #define RADIUS_NEW_PORT 1812 #define RADIUS_ACCOUNTING_PORT 1646 #define RADIUS_NEW_ACCOUNTING_PORT 1813 #define HSRP_PORT 1985 /*XXX*/ #define LWRES_PORT 921 #define ZEPHYR_SRV_PORT 2103 #define ZEPHYR_CLT_PORT 2104 #ifdef INET6 #define RIPNG_PORT 521 /*XXX*/ #define DHCP6_SERV_PORT 546 /*XXX*/ #define DHCP6_CLI_PORT 547 /*XXX*/ #endif void udp_print(register const u_char *bp, u_int length, register const u_char *bp2, int fragmented) { register const struct udphdr *up; register const struct ip *ip; register const u_char *cp; register const u_char *ep = bp + length; u_int16_t sport, dport, ulen; #ifdef INET6 register const struct ip6_hdr *ip6; #endif if (ep > snapend) ep = snapend; up = (struct udphdr *)bp; ip = (struct ip *)bp2; #ifdef INET6 if (IP_V(ip) == 6) ip6 = (struct ip6_hdr *)bp2; else ip6 = NULL; #endif /*INET6*/ cp = (u_char *)(up + 1); if (cp > snapend) { (void)printf("%s > %s: [|udp]", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); return; } if (length < sizeof(struct udphdr)) { (void)printf("%s > %s: truncated-udp %d", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst), length); return; } length -= sizeof(struct udphdr); sport = ntohs(up->uh_sport); dport = ntohs(up->uh_dport); ulen = ntohs(up->uh_ulen); if (ulen < 8) { (void)printf("%s > %s: truncated-udplength %d", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst), ulen); return; } if (packettype) { register struct rpc_msg *rp; enum msg_type direction; switch (packettype) { case PT_VAT: (void)printf("%s.%s > %s.%s: ", ipaddr_string(&ip->ip_src), udpport_string(sport), ipaddr_string(&ip->ip_dst), udpport_string(dport)); vat_print((void *)(up + 1), length, up); break; case PT_WB: (void)printf("%s.%s > %s.%s: ", ipaddr_string(&ip->ip_src), udpport_string(sport), ipaddr_string(&ip->ip_dst), udpport_string(dport)); wb_print((void *)(up + 1), length); break; case PT_RPC: rp = (struct rpc_msg *)(up + 1); direction = (enum msg_type)ntohl(rp->rm_direction); if (direction == CALL) sunrpcrequest_print((u_char *)rp, length, (u_char *)ip); else nfsreply_print((u_char *)rp, length, (u_char *)ip); /*XXX*/ break; case PT_RTP: (void)printf("%s.%s > %s.%s: ", ipaddr_string(&ip->ip_src), udpport_string(sport), ipaddr_string(&ip->ip_dst), udpport_string(dport)); rtp_print((void *)(up + 1), length, up); break; case PT_RTCP: (void)printf("%s.%s > %s.%s:", ipaddr_string(&ip->ip_src), udpport_string(sport), ipaddr_string(&ip->ip_dst), udpport_string(dport)); while (cp < ep) cp = rtcp_print(cp, ep); break; case PT_SNMP: (void)printf("%s.%s > %s.%s:", ipaddr_string(&ip->ip_src), udpport_string(sport), ipaddr_string(&ip->ip_dst), udpport_string(dport)); snmp_print((const u_char *)(up + 1), length); break; case PT_CNFP: (void)printf("%s.%s > %s.%s:", ipaddr_string(&ip->ip_src), udpport_string(sport), ipaddr_string(&ip->ip_dst), udpport_string(dport)); cnfp_print(cp, length, (const u_char *)ip); break; } return; } if (!qflag) { register struct rpc_msg *rp; enum msg_type direction; rp = (struct rpc_msg *)(up + 1); if (TTEST(rp->rm_direction)) { direction = (enum msg_type)ntohl(rp->rm_direction); if (dport == NFS_PORT && direction == CALL) { nfsreq_print((u_char *)rp, length, (u_char *)ip); return; } if (sport == NFS_PORT && direction == REPLY) { nfsreply_print((u_char *)rp, length, (u_char *)ip); return; } #ifdef notdef if (dport == SUNRPC_PORT && direction == CALL) { sunrpcrequest_print((u_char *)rp, length, (u_char *)ip); return; } #endif } if (TTEST(((struct LAP *)cp)->type) && ((struct LAP *)cp)->type == lapDDP && (atalk_port(sport) || atalk_port(dport))) { if (vflag) fputs("kip ", stdout); llap_print(cp, length); return; } } #ifdef INET6 if (ip6) { if (ip6->ip6_nxt == IPPROTO_UDP) { (void)printf("%s.%s > %s.%s: ", ip6addr_string(&ip6->ip6_src), udpport_string(sport), ip6addr_string(&ip6->ip6_dst), udpport_string(dport)); } else { (void)printf("%s > %s: ", udpport_string(sport), udpport_string(dport)); } } else #endif /*INET6*/ { if (ip->ip_p == IPPROTO_UDP) { (void)printf("%s.%s > %s.%s: ", ipaddr_string(&ip->ip_src), udpport_string(sport), ipaddr_string(&ip->ip_dst), udpport_string(dport)); } else { (void)printf("%s > %s: ", udpport_string(sport), udpport_string(dport)); } } if (IP_V(ip) == 4 && vflag && !fragmented) { int sum = up->uh_sum; if (sum == 0) { (void)printf("[no cksum] "); } else if (TTEST2(cp[0], length)) { sum = udp_cksum(ip, up, length + sizeof(struct udphdr)); if (sum != 0) (void)printf("[bad udp cksum %x!] ", sum); else (void)printf("[udp sum ok] "); } } #ifdef INET6 if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) { int sum = up->uh_sum; /* for IPv6, UDP checksum is mandatory */ if (TTEST2(cp[0], length)) { sum = udp6_cksum(ip6, up, length); if (sum != 0) (void)printf("[bad udp cksum %x!] ", sum); else (void)printf("[udp sum ok] "); } } #endif if (!qflag) { #define ISPORT(p) (dport == (p) || sport == (p)) if (ISPORT(NAMESERVER_PORT)) ns_print((const u_char *)(up + 1), length); else if (ISPORT(TIMED_PORT)) timed_print((const u_char *)(up + 1), length); else if (ISPORT(TFTP_PORT)) tftp_print((const u_char *)(up + 1), length); else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS)) bootp_print((const u_char *)(up + 1), length, sport, dport); else if (ISPORT(RIP_PORT)) rip_print((const u_char *)(up + 1), length); else if (ISPORT(ISAKMP_PORT)) isakmp_print((const u_char *)(up + 1), length, bp2); #if 1 /*???*/ else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2)) isakmp_print((const u_char *)(up + 1), length, bp2); #endif else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT)) snmp_print((const u_char *)(up + 1), length); else if (ISPORT(NTP_PORT)) ntp_print((const u_char *)(up + 1), length); else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT)) krb_print((const void *)(up + 1), length); else if (ISPORT(L2TP_PORT)) l2tp_print((const u_char *)(up + 1), length); #ifdef TCPDUMP_DO_SMB else if (ISPORT(NETBIOS_NS_PORT)) nbt_udp137_print((const u_char *)(up + 1), length); else if (ISPORT(NETBIOS_DGRAM_PORT)) nbt_udp138_print((const u_char *)(up + 1), length); #endif else if (dport == 3456) vat_print((const void *)(up + 1), length, up); else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT)) zephyr_print((const void *)(up + 1), length); /* * Since there are 10 possible ports to check, I think * a <> test would be more efficient */ else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) || (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH)) rx_print((const void *)(up + 1), length, sport, dport, (u_char *) ip); #ifdef INET6 else if (ISPORT(RIPNG_PORT)) ripng_print((const u_char *)(up + 1), length); else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT)) { dhcp6_print((const u_char *)(up + 1), length, sport, dport); } #endif /*INET6*/ /* * Kludge in test for whiteboard packets. */ else if (dport == 4567) wb_print((const void *)(up + 1), length); else if (ISPORT(CISCO_AUTORP_PORT)) cisco_autorp_print((const void *)(up + 1), length); else if (ISPORT(RADIUS_PORT) || ISPORT(RADIUS_NEW_PORT) || ISPORT(RADIUS_ACCOUNTING_PORT) || ISPORT(RADIUS_NEW_ACCOUNTING_PORT) ) radius_print((const u_char *)(up+1), length); else if (dport == HSRP_PORT) hsrp_print((const u_char *)(up + 1), length); else if (ISPORT(LWRES_PORT)) lwres_print((const u_char *)(up + 1), length); else (void)printf("udp %u", (u_int32_t)(ulen - sizeof(*up))); #undef ISPORT } else (void)printf("udp %u", (u_int32_t)(ulen - sizeof(*up))); } tcpdump-3.7.2/print-vjc.c0100644000076500000240000000447707170222421014431 0ustar fennerstaff/* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.9 2000/10/09 01:53:21 guy Exp $ (LBL)"; #endif #include #include #include #include #include #include #include #include "interface.h" #include "addrtoname.h" #include "slcompress.h" #include "ppp.h" int vjc_print(register const char *bp, register u_int length, u_short proto) { int i; switch (bp[0] & 0xf0) { case TYPE_IP: if (eflag) printf("(vjc type=IP) "); return PPP_IP; case TYPE_UNCOMPRESSED_TCP: if (eflag) printf("(vjc type=raw TCP) "); return PPP_IP; case TYPE_COMPRESSED_TCP: if (eflag) printf("(vjc type=compressed TCP) "); for (i = 0; i < 8; i++) { if (bp[1] & (0x80 >> i)) printf("%c", "?CI?SAWU"[i]); } if (bp[1]) printf(" "); printf("C=0x%02x ", bp[2]); printf("sum=0x%04x ", *(u_short *)&bp[3]); return -1; case TYPE_ERROR: if (eflag) printf("(vjc type=error) "); return -1; default: if (eflag) printf("(vjc type=0x%02x) ", bp[0] & 0xf0); return -1; } } tcpdump-3.7.2/print-vrrp.c0100644000076500000240000001046007327122322014630 0ustar fennerstaff/* * Copyright (c) 2000 William C. Fenner. * All rights reserved. * * Kevin Steves July 2000 * Modified to: * - print version, type string and packet length * - print IP address count if > 1 (-v) * - verify checksum (-v) * - print authentication string (-v) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code * distributions retain the above copyright notice and this paragraph * in its entirety, and (2) distributions including binary code include * the above copyright notice and this paragraph in its entirety in * the documentation or other materials provided with the distribution. * The name of William C. Fenner may not be used to endorse or * promote products derived from this software without specific prior * written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.5 2001/07/23 22:27:30 fenner Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "interface.h" #include "extract.h" #include "addrtoname.h" /* * RFC 2338: * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |Version| Type | Virtual Rtr ID| Priority | Count IP Addrs| * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Auth Type | Adver Int | Checksum | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | IP Address (1) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | . | * | . | * | . | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | IP Address (n) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Authentication Data (1) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Authentication Data (2) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ /* Type */ #define VRRP_TYPE_ADVERTISEMENT 1 static const struct tok type2str[] = { { VRRP_TYPE_ADVERTISEMENT, "advertisement" }, { 0, NULL } }; /* Auth Type */ #define VRRP_AUTH_NONE 0 #define VRRP_AUTH_SIMPLE 1 #define VRRP_AUTH_AH 2 static const struct tok auth2str[] = { { VRRP_AUTH_NONE, "none" }, { VRRP_AUTH_SIMPLE, "simple" }, { VRRP_AUTH_AH, "ah" }, { 0, NULL } }; void vrrp_print(register const u_char *bp, register u_int len, int ttl) { int version, type, auth_type; const char *type_s; TCHECK(bp[0]); version = (bp[0] & 0xf0) >> 4; type = bp[0] & 0x0f; type_s = tok2str(type2str, "type#%d", type); printf("VRRPv%d-%s %d: ", version, type_s, len); if (ttl != 255) printf("[ttl=%d!] ", ttl); if (version != 2 || type != VRRP_TYPE_ADVERTISEMENT) return; TCHECK(bp[2]); printf("vrid=%d prio=%d", bp[1], bp[2]); TCHECK(bp[5]); auth_type = bp[4]; printf(" authtype=%s", tok2str(auth2str, NULL, auth_type)); printf(" intvl=%d", bp[5]); if (vflag) { int naddrs = bp[3]; int i; char c; if (TTEST2(bp[0], len) && in_cksum((const u_short*)bp, len, 0)) printf(" (bad vrrp cksum %x!)", EXTRACT_16BITS(&bp[6])); printf(" addrs"); if (naddrs > 1) printf("(%d)", naddrs); printf(":"); c = ' '; bp += 8; for (i = 0; i < naddrs; i++) { TCHECK(bp[3]); printf("%c%s", c, ipaddr_string(bp)); c = ','; bp += 4; } if (auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */ TCHECK(bp[7]); printf(" auth \""); fn_printn(bp, 8, NULL); printf("\""); } } return; trunc: printf("[|vrrp]"); } tcpdump-3.7.2/print-wb.c0100644000076500000240000002412207316270417014256 0ustar fennerstaff/* * Copyright (c) 1993, 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.26 2001/06/27 05:37:19 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "interface.h" #include "addrtoname.h" /* XXX need to add byte-swapping macros! */ /* * Largest packet size. Everything should fit within this space. * For instance, multiline objects are sent piecewise. */ #define MAXFRAMESIZE 1024 /* * Multiple drawing ops can be sent in one packet. Each one starts on a * an even multiple of DOP_ALIGN bytes, which must be a power of two. */ #define DOP_ALIGN 4 #define DOP_ROUNDUP(x) ((((int)(x)) + (DOP_ALIGN - 1)) & ~(DOP_ALIGN - 1)) #define DOP_NEXT(d)\ ((struct dophdr *)((u_char *)(d) + \ DOP_ROUNDUP(ntohs((d)->dh_len) + sizeof(*(d))))) /* * Format of the whiteboard packet header. * The transport level header. */ struct pkt_hdr { u_int32_t ph_src; /* site id of source */ u_int32_t ph_ts; /* time stamp (for skew computation) */ u_short ph_version; /* version number */ u_char ph_type; /* message type */ u_char ph_flags; /* message flags */ }; /* Packet types */ #define PT_DRAWOP 0 /* drawing operation */ #define PT_ID 1 /* announcement packet */ #define PT_RREQ 2 /* repair request */ #define PT_RREP 3 /* repair reply */ #define PT_KILL 4 /* terminate participation */ #define PT_PREQ 5 /* page vector request */ #define PT_PREP 7 /* page vector reply */ #ifdef PF_USER #undef PF_USER /* {Digital,Tru64} UNIX define this, alas */ #endif /* flags */ #define PF_USER 0x01 /* hint that packet has interactive data */ #define PF_VIS 0x02 /* only visible ops wanted */ struct PageID { u_int32_t p_sid; /* session id of initiator */ u_int32_t p_uid; /* page number */ }; struct dophdr { u_int32_t dh_ts; /* sender's timestamp */ u_short dh_len; /* body length */ u_char dh_flags; u_char dh_type; /* body type */ /* body follows */ }; /* * Drawing op sub-types. */ #define DT_RECT 2 #define DT_LINE 3 #define DT_ML 4 #define DT_DEL 5 #define DT_XFORM 6 #define DT_ELL 7 #define DT_CHAR 8 #define DT_STR 9 #define DT_NOP 10 #define DT_PSCODE 11 #define DT_PSCOMP 12 #define DT_REF 13 #define DT_SKIP 14 #define DT_HOLE 15 #define DT_MAXTYPE 15 /* * A drawing operation. */ struct pkt_dop { struct PageID pd_page; /* page that operations apply to */ u_int32_t pd_sseq; /* start sequence number */ u_int32_t pd_eseq; /* end sequence number */ /* drawing ops follow */ }; /* * A repair request. */ struct pkt_rreq { u_int32_t pr_id; /* source id of drawops to be repaired */ struct PageID pr_page; /* page of drawops */ u_int32_t pr_sseq; /* start seqno */ u_int32_t pr_eseq; /* end seqno */ }; /* * A repair reply. */ struct pkt_rrep { u_int32_t pr_id; /* original site id of ops */ struct pkt_dop pr_dop; /* drawing ops follow */ }; struct id_off { u_int32_t id; u_int32_t off; }; struct pgstate { u_int32_t slot; struct PageID page; u_short nid; u_short rsvd; /* seqptr's */ }; /* * An announcement packet. */ struct pkt_id { u_int32_t pi_mslot; struct PageID pi_mpage; /* current page */ struct pgstate pi_ps; /* seqptr's */ /* null-terminated site name */ }; struct pkt_preq { struct PageID pp_page; u_int32_t pp_low; u_int32_t pp_high; }; struct pkt_prep { u_int32_t pp_n; /* size of pageid array */ /* pgstate's follow */ }; static int wb_id(const struct pkt_id *id, u_int len) { int i; const char *cp; const struct id_off *io; char c; int nid; printf(" wb-id:"); if (len < sizeof(*id) || (u_char *)(id + 1) > snapend) return (-1); len -= sizeof(*id); printf(" %u/%s:%u (max %u/%s:%u) ", (u_int32_t)ntohl(id->pi_ps.slot), ipaddr_string(&id->pi_ps.page.p_sid), (u_int32_t)ntohl(id->pi_ps.page.p_uid), (u_int32_t)ntohl(id->pi_mslot), ipaddr_string(&id->pi_mpage.p_sid), (u_int32_t)ntohl(id->pi_mpage.p_uid)); nid = ntohs(id->pi_ps.nid); len -= sizeof(*io) * nid; io = (struct id_off *)(id + 1); cp = (char *)(io + nid); if ((u_char *)cp + len <= snapend) { putchar('"'); (void)fn_print((u_char *)cp, (u_char *)cp + len); putchar('"'); } c = '<'; for (i = 0; i < nid && (u_char *)io < snapend; ++io, ++i) { printf("%c%s:%u", c, ipaddr_string(&io->id), (u_int32_t)ntohl(io->off)); c = ','; } if (i >= nid) { printf(">"); return (0); } return (-1); } static int wb_rreq(const struct pkt_rreq *rreq, u_int len) { printf(" wb-rreq:"); if (len < sizeof(*rreq) || (u_char *)(rreq + 1) > snapend) return (-1); printf(" please repair %s %s:%u<%u:%u>", ipaddr_string(&rreq->pr_id), ipaddr_string(&rreq->pr_page.p_sid), (u_int32_t)ntohl(rreq->pr_page.p_uid), (u_int32_t)ntohl(rreq->pr_sseq), (u_int32_t)ntohl(rreq->pr_eseq)); return (0); } static int wb_preq(const struct pkt_preq *preq, u_int len) { printf(" wb-preq:"); if (len < sizeof(*preq) || (u_char *)(preq + 1) > snapend) return (-1); printf(" need %u/%s:%u", (u_int32_t)ntohl(preq->pp_low), ipaddr_string(&preq->pp_page.p_sid), (u_int32_t)ntohl(preq->pp_page.p_uid)); return (0); } static int wb_prep(const struct pkt_prep *prep, u_int len) { int n; const struct pgstate *ps; const u_char *ep = snapend; printf(" wb-prep:"); if (len < sizeof(*prep)) { return (-1); } n = ntohl(prep->pp_n); ps = (const struct pgstate *)(prep + 1); while (--n >= 0 && (u_char *)ps < ep) { const struct id_off *io, *ie; char c = '<'; printf(" %u/%s:%u", (u_int32_t)ntohl(ps->slot), ipaddr_string(&ps->page.p_sid), (u_int32_t)ntohl(ps->page.p_uid)); io = (struct id_off *)(ps + 1); for (ie = io + ps->nid; io < ie && (u_char *)io < ep; ++io) { printf("%c%s:%u", c, ipaddr_string(&io->id), (u_int32_t)ntohl(io->off)); c = ','; } printf(">"); ps = (struct pgstate *)io; } return ((u_char *)ps <= ep? 0 : -1); } char *dopstr[] = { "dop-0!", "dop-1!", "RECT", "LINE", "ML", "DEL", "XFORM", "ELL", "CHAR", "STR", "NOP", "PSCODE", "PSCOMP", "REF", "SKIP", "HOLE", }; static int wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es) { printf(" <"); for ( ; ss <= es; ++ss) { register int t = dh->dh_type; if (t > DT_MAXTYPE) printf(" dop-%d!", t); else { printf(" %s", dopstr[t]); if (t == DT_SKIP || t == DT_HOLE) { int ts = ntohl(dh->dh_ts); printf("%d", ts - ss + 1); if (ss > ts || ts > es) { printf("[|]"); if (ts < ss) return (0); } ss = ts; } } dh = DOP_NEXT(dh); if ((u_char *)dh > snapend) { printf("[|wb]"); break; } } printf(" >"); return (0); } static int wb_rrep(const struct pkt_rrep *rrep, u_int len) { const struct pkt_dop *dop = &rrep->pr_dop; printf(" wb-rrep:"); if (len < sizeof(*rrep) || (u_char *)(rrep + 1) > snapend) return (-1); len -= sizeof(*rrep); printf(" for %s %s:%u<%u:%u>", ipaddr_string(&rrep->pr_id), ipaddr_string(&dop->pd_page.p_sid), (u_int32_t)ntohl(dop->pd_page.p_uid), (u_int32_t)ntohl(dop->pd_sseq), (u_int32_t)ntohl(dop->pd_eseq)); if (vflag) return (wb_dops((const struct dophdr *)(dop + 1), ntohl(dop->pd_sseq), ntohl(dop->pd_eseq))); return (0); } static int wb_drawop(const struct pkt_dop *dop, u_int len) { printf(" wb-dop:"); if (len < sizeof(*dop) || (u_char *)(dop + 1) > snapend) return (-1); len -= sizeof(*dop); printf(" %s:%u<%u:%u>", ipaddr_string(&dop->pd_page.p_sid), (u_int32_t)ntohl(dop->pd_page.p_uid), (u_int32_t)ntohl(dop->pd_sseq), (u_int32_t)ntohl(dop->pd_eseq)); if (vflag) return (wb_dops((const struct dophdr *)(dop + 1), ntohl(dop->pd_sseq), ntohl(dop->pd_eseq))); return (0); } /* * Print whiteboard multicast packets. */ void wb_print(register const void *hdr, register u_int len) { register const struct pkt_hdr *ph; ph = (const struct pkt_hdr *)hdr; if (len < sizeof(*ph) || (u_char *)(ph + 1) > snapend) { printf("[|wb]"); return; } len -= sizeof(*ph); if (ph->ph_flags) printf("*"); switch (ph->ph_type) { case PT_KILL: printf(" wb-kill"); return; case PT_ID: if (wb_id((struct pkt_id *)(ph + 1), len) >= 0) return; break; case PT_RREQ: if (wb_rreq((struct pkt_rreq *)(ph + 1), len) >= 0) return; break; case PT_RREP: if (wb_rrep((struct pkt_rrep *)(ph + 1), len) >= 0) return; break; case PT_DRAWOP: if (wb_drawop((struct pkt_dop *)(ph + 1), len) >= 0) return; break; case PT_PREQ: if (wb_preq((struct pkt_preq *)(ph + 1), len) >= 0) return; break; case PT_PREP: if (wb_prep((struct pkt_prep *)(ph + 1), len) >= 0) return; break; default: printf(" wb-%d!", ph->ph_type); return; } } tcpdump-3.7.2/print-zephyr.c0100644000076500000240000001625107627054633015200 0ustar fennerstaff/* * Decode and print Zephyr packets. * * Copyright (c) 2001 Nickolai Zeldovich * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code * distributions retain the above copyright notice and this paragraph * in its entirety, and (2) distributions including binary code include * the above copyright notice and this paragraph in its entirety in * the documentation or other materials provided with the distribution. * The name of the author(s) may not be used to endorse or promote * products derived from this software without specific prior written * permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. */ #ifndef lint static const char rcsid[] = "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.2.4.2 2002/07/11 07:49:19 guy Exp $"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "interface.h" struct z_packet { char *version; int numfields; int kind; char *uid; int port; int auth; int authlen; char *authdata; char *class; char *inst; char *opcode; char *sender; char *recipient; char *format; int cksum; int multi; char *multi_uid; /* Other fields follow here.. */ }; enum z_packet_type { Z_PACKET_UNSAFE = 0, Z_PACKET_UNACKED, Z_PACKET_ACKED, Z_PACKET_HMACK, Z_PACKET_HMCTL, Z_PACKET_SERVACK, Z_PACKET_SERVNAK, Z_PACKET_CLIENTACK, Z_PACKET_STAT }; static struct tok z_types[] = { { Z_PACKET_UNSAFE, "unsafe" }, { Z_PACKET_UNACKED, "unacked" }, { Z_PACKET_ACKED, "acked" }, { Z_PACKET_HMACK, "hm-ack" }, { Z_PACKET_HMCTL, "hm-ctl" }, { Z_PACKET_SERVACK, "serv-ack" }, { Z_PACKET_SERVNAK, "serv-nak" }, { Z_PACKET_CLIENTACK, "client-ack" }, { Z_PACKET_STAT, "stat" } }; char z_buf[256]; static char * parse_field(char **pptr, int *len) { char *s; if (*len <= 0 || !pptr || !*pptr) return NULL; if (*pptr > (char *) snapend) return NULL; s = *pptr; while (*pptr <= (char *) snapend && *len >= 0 && **pptr) { (*pptr)++; (*len)--; } (*pptr)++; (*len)--; if (*len < 0 || *pptr > (char *) snapend) return NULL; return s; } static const char * z_triple(char *class, char *inst, char *recipient) { if (!*recipient) recipient = "*"; snprintf(z_buf, sizeof(z_buf), "<%s,%s,%s>", class, inst, recipient); z_buf[sizeof(z_buf)-1] = '\0'; return z_buf; } static const char * str_to_lower(char *string) { strncpy(z_buf, string, sizeof(z_buf)); z_buf[sizeof(z_buf)-1] = '\0'; string = z_buf; while (*string) { *string = tolower((unsigned char)(*string)); string++; } return z_buf; } void zephyr_print(const u_char *cp, int length) { struct z_packet z; char *parse = (char *) cp; int parselen = length; char *s; int lose = 0; #define PARSE_STRING \ s = parse_field(&parse, &parselen); \ if (!s) lose = 1; #define PARSE_FIELD_INT(field) \ PARSE_STRING \ if (!lose) field = strtol(s, 0, 16); #define PARSE_FIELD_STR(field) \ PARSE_STRING \ if (!lose) field = s; PARSE_FIELD_STR(z.version); if (lose) return; if (strncmp(z.version, "ZEPH", 4)) return; PARSE_FIELD_INT(z.numfields); PARSE_FIELD_INT(z.kind); PARSE_FIELD_STR(z.uid); PARSE_FIELD_INT(z.port); PARSE_FIELD_INT(z.auth); PARSE_FIELD_INT(z.authlen); PARSE_FIELD_STR(z.authdata); PARSE_FIELD_STR(z.class); PARSE_FIELD_STR(z.inst); PARSE_FIELD_STR(z.opcode); PARSE_FIELD_STR(z.sender); PARSE_FIELD_STR(z.recipient); PARSE_FIELD_STR(z.format); PARSE_FIELD_INT(z.cksum); PARSE_FIELD_INT(z.multi); PARSE_FIELD_STR(z.multi_uid); if (lose) { printf(" [|zephyr] (%d)", length); return; } printf(" zephyr"); if (strncmp(z.version+4, "0.2", 3)) { printf(" v%s", z.version+4); return; } printf(" %s", tok2str(z_types, "type %d", z.kind)); if (z.kind == Z_PACKET_SERVACK) { /* Initialization to silence warnings */ char *ackdata = NULL; PARSE_FIELD_STR(ackdata); if (!lose && strcmp(ackdata, "SENT")) printf("/%s", str_to_lower(ackdata)); } if (*z.sender) printf(" %s", z.sender); if (!strcmp(z.class, "USER_LOCATE")) { if (!strcmp(z.opcode, "USER_HIDE")) printf(" hide"); else if (!strcmp(z.opcode, "USER_UNHIDE")) printf(" unhide"); else printf(" locate %s", z.inst); return; } if (!strcmp(z.class, "ZEPHYR_ADMIN")) { printf(" zephyr-admin %s", str_to_lower(z.opcode)); return; } if (!strcmp(z.class, "ZEPHYR_CTL")) { if (!strcmp(z.inst, "CLIENT")) { if (!strcmp(z.opcode, "SUBSCRIBE") || !strcmp(z.opcode, "SUBSCRIBE_NODEFS") || !strcmp(z.opcode, "UNSUBSCRIBE")) { printf(" %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "", strcmp(z.opcode, "SUBSCRIBE_NODEFS") ? "" : "-nodefs"); if (z.kind != Z_PACKET_SERVACK) { /* Initialization to silence warnings */ char *c = NULL, *i = NULL, *r = NULL; PARSE_FIELD_STR(c); PARSE_FIELD_STR(i); PARSE_FIELD_STR(r); if (!lose) printf(" %s", z_triple(c, i, r)); } return; } if (!strcmp(z.opcode, "GIMME")) { printf(" ret"); return; } if (!strcmp(z.opcode, "GIMMEDEFS")) { printf(" gimme-defs"); return; } if (!strcmp(z.opcode, "CLEARSUB")) { printf(" clear-subs"); return; } printf(" %s", str_to_lower(z.opcode)); return; } if (!strcmp(z.inst, "HM")) { printf(" %s", str_to_lower(z.opcode)); return; } if (!strcmp(z.inst, "REALM")) { if (!strcmp(z.opcode, "ADD_SUBSCRIBE")) printf(" realm add-subs"); if (!strcmp(z.opcode, "REQ_SUBSCRIBE")) printf(" realm req-subs"); if (!strcmp(z.opcode, "RLM_SUBSCRIBE")) printf(" realm rlm-sub"); if (!strcmp(z.opcode, "RLM_UNSUBSCRIBE")) printf(" realm rlm-unsub"); return; } } if (!strcmp(z.class, "HM_CTL")) { printf(" hm_ctl %s", str_to_lower(z.inst)); printf(" %s", str_to_lower(z.opcode)); return; } if (!strcmp(z.class, "HM_STAT")) { if (!strcmp(z.inst, "HMST_CLIENT") && !strcmp(z.opcode, "GIMMESTATS")) { printf(" get-client-stats"); return; } } if (!strcmp(z.class, "WG_CTL")) { printf(" wg_ctl %s", str_to_lower(z.inst)); printf(" %s", str_to_lower(z.opcode)); return; } if (!strcmp(z.class, "LOGIN")) { if (!strcmp(z.opcode, "USER_FLUSH")) { printf(" flush_locs"); return; } if (!strcmp(z.opcode, "NONE") || !strcmp(z.opcode, "OPSTAFF") || !strcmp(z.opcode, "REALM-VISIBLE") || !strcmp(z.opcode, "REALM-ANNOUNCED") || !strcmp(z.opcode, "NET-VISIBLE") || !strcmp(z.opcode, "NET-ANNOUNCED")) { printf(" set-exposure %s", str_to_lower(z.opcode)); return; } } if (!*z.recipient) z.recipient = "*"; printf(" to %s", z_triple(z.class, z.inst, z.recipient)); if (*z.opcode) printf(" op %s", z.opcode); return; } tcpdump-3.7.2/README0100644000076500000240000002310707627064040013230 0ustar fennerstaff@(#) $Header: /tcpdump/master/tcpdump/README,v 1.60.2.3 2003/02/26 07:08:58 fenner Exp $ (LBL) TCPDUMP 3.7.2 Now maintained by "The Tcpdump Group" See www.tcpdump.org Please send inquiries/comments/reports to tcpdump-workers@tcpdump.org Anonymous CVS is available via: cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master login (password "anoncvs") cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout tcpdump Version 3.7.2 of TCPDUMP can be retrived with the CVS tag "tcpdump_3_7rel2": cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_3_7rel2 tcpdump Please send patches against the master copy to patches@tcpdump.org. formerly from Lawrence Berkeley National Laboratory Network Research Group ftp://ftp.ee.lbl.gov/tcpdump.tar.Z (3.4) This directory contains source code for tcpdump, a tool for network monitoring and data acquisition. This software was originally developed by the Network Research Group at the Lawrence Berkeley National Laboratory. The original distribution is available via anonymous ftp to ftp.ee.lbl.gov, in tcpdump.tar.Z. More recent development is performed at tcpdump.org, http://www.tcpdump.org/ Tcpdump uses libpcap, a system-independent interface for user-level packet capture. Before building tcpdump, you must first retrieve and build libpcap, also originally from LBL and now being maintained by tcpdump.org; see http://www.tcpdump.org/ . Once libpcap is built (either install it or make sure it's in ../libpcap), you can build tcpdump using the procedure in the INSTALL file. The program is loosely based on SMI's "etherfind" although none of the etherfind code remains. It was originally written by Van Jacobson as part of an ongoing research project to investigate and improve tcp and internet gateway performance. The parts of the program originally taken from Sun's etherfind were later re-written by Steven McCanne of LBL. To insure that there would be no vestige of proprietary code in tcpdump, Steve wrote these pieces from the specification given by the manual entry, with no access to the source of tcpdump or etherfind. Over the past few years, tcpdump has been steadily improved by the excellent contributions from the Internet community (just browse through the CHANGES file). We are grateful for all the input. Richard Stevens gives an excellent treatment of the Internet protocols in his book ``TCP/IP Illustrated, Volume 1''. If you want to learn more about tcpdump and how to interpret its output, pick up this book. Some tools for viewing and analyzing tcpdump trace files are available from the Internet Traffic Archive: http://www.acm.org/sigcomm/ITA/ Another tool that tcpdump users might find useful is tcpslice: ftp://ftp.ee.lbl.gov/tcpslice.tar.Z It is a program that can be used to extract portions of tcpdump binary trace files. See the above distribution for further details and documentation. Problems, bugs, questions, desirable enhancements, etc. should be sent to the address "tcpdump-workers@tcpdump.org". Bugs, support requests, and feature requests may also be submitted on the SourceForge site for tcpdump at http://sourceforge.net/projects/tcpdump/ Source code contributions, etc. should be sent to the email address "patches@tcpdump.org", or submitted as patches on the SourceForge site for tcpdump. Current versions can be found at www.tcpdump.org, or the SourceForge site for tcpdump. - The TCPdump team original text by: Steve McCanne, Craig Leres, Van Jacobson ------------------------------------- This directory also contains some short awk programs intended as examples of ways to reduce tcpdump data when you're tracking particular network problems: send-ack.awk Simplifies the tcpdump trace for an ftp (or other unidirectional tcp transfer). Since we assume that one host only sends and the other only acks, all address information is left off and we just note if the packet is a "send" or an "ack". There is one output line per line of the original trace. Field 1 is the packet time in decimal seconds, relative to the start of the conversation. Field 2 is delta-time from last packet. Field 3 is packet type/direction. "Send" means data going from sender to receiver, "ack" means an ack going from the receiver to the sender. A preceding "*" indicates that the data is a retransmission. A preceding "-" indicates a hole in the sequence space (i.e., missing packet(s)), a "#" means an odd-size (not max seg size) packet. Field 4 has the packet flags (same format as raw trace). Field 5 is the sequence number (start seq. num for sender, next expected seq number for acks). The number in parens following an ack is the delta-time from the first send of the packet to the ack. A number in parens following a send is the delta-time from the first send of the packet to the current send (on duplicate packets only). Duplicate sends or acks have a number in square brackets showing the number of duplicates so far. Here is a short sample from near the start of an ftp: 3.00 0.20 send . 512 3.20 0.20 ack . 1024 (0.20) 3.20 0.00 send P 1024 3.40 0.20 ack . 1536 (0.20) 3.80 0.40 * send . 0 (3.80) [2] 3.82 0.02 * ack . 1536 (0.62) [2] Three seconds into the conversation, bytes 512 through 1023 were sent. 200ms later they were acked. Shortly thereafter bytes 1024-1535 were sent and again acked after 200ms. Then, for no apparent reason, 0-511 is retransmitted, 3.8 seconds after its initial send (the round trip time for this ftp was 1sec, +-500ms). Since the receiver is expecting 1536, 1536 is re-acked when 0 arrives. packetdat.awk Computes chunk summary data for an ftp (or similar unidirectional tcp transfer). [A "chunk" refers to a chunk of the sequence space -- essentially the packet sequence number divided by the max segment size.] A summary line is printed showing the number of chunks, the number of packets it took to send that many chunks (if there are no lost or duplicated packets, the number of packets should equal the number of chunks) and the number of acks. Following the summary line is one line of information per chunk. The line contains eight fields: 1 - the chunk number 2 - the start sequence number for this chunk 3 - time of first send 4 - time of last send 5 - time of first ack 6 - time of last ack 7 - number of times chunk was sent 8 - number of times chunk was acked (all times are in decimal seconds, relative to the start of the conversation.) As an example, here is the first part of the output for an ftp trace: # 134 chunks. 536 packets sent. 508 acks. 1 1 0.00 5.80 0.20 0.20 4 1 2 513 0.28 6.20 0.40 0.40 4 1 3 1025 1.16 6.32 1.20 1.20 4 1 4 1561 1.86 15.00 2.00 2.00 6 1 5 2049 2.16 15.44 2.20 2.20 5 1 6 2585 2.64 16.44 2.80 2.80 5 1 7 3073 3.00 16.66 3.20 3.20 4 1 8 3609 3.20 17.24 3.40 5.82 4 11 9 4097 6.02 6.58 6.20 6.80 2 5 This says that 134 chunks were transferred (about 70K since the average packet size was 512 bytes). It took 536 packets to transfer the data (i.e., on the average each chunk was transmitted four times). Looking at, say, chunk 4, we see it represents the 512 bytes of sequence space from 1561 to 2048. It was first sent 1.86 seconds into the conversation. It was last sent 15 seconds into the conversation and was sent a total of 6 times (i.e., it was retransmitted every 2 seconds on the average). It was acked once, 140ms after it first arrived. stime.awk atime.awk Output one line per send or ack, respectively, in the form