Ethereal-dev: [ethereal-dev] SNMP diff
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Gilbert Ramirez <gramirez@xxxxxxxxxx>
Date: Fri, 30 Apr 1999 11:49:14 -0500
Here is the patch against the very latest CVS image (which is available at http://verdict.uthscsa.edu/gram/ethereal/ethereal-990430.tar.gz) which introduces SNMP decoding to ethereal. I found the file in Gerald's directory on pow.zing.org, and modified it only so that it will compile with the changes in ethereal made since the creation of this code. I sent e-mail to Didier Jorand <Didier.Jorand@xxxxxxxxxx>, the author of this code, to see if he has worked on it any more, but I have not received a response. I quickly hacked the configure.in script to try to properly link in the SNMP library by default. I have not tried this script on a computer w/o the UCD snmp library, so I do not know if the script correctly determines the absence. --gilbert
diff -urN ethereal/Makefile.am ethereal-new/Makefile.am --- ethereal/Makefile.am Fri Apr 30 11:14:31 1999 +++ ethereal-new/Makefile.am Thu Apr 29 16:14:49 1999 @@ -45,6 +45,7 @@ packet-ppp.c \ packet-raw.c \ packet-rip.c \ + packet-snmp.c \ packet-tcp.c \ packet-telnet.c \ packet-tftp.c \ @@ -86,7 +87,7 @@ snprintf-imp.h ethereal_DEPENDENCIES = @SNPRINTF_O@ @LIBWIRETAP_A@ -ethereal_LDADD = @SNPRINTF_O@ @LIBWIRETAP_A@ +ethereal_LDADD = @SNPRINTF_O@ @LIBWIRETAP_A@ @SNMP_A@ ps.c: print.ps rdps ./rdps print.ps ps.c diff -urN ethereal/Makefile.in ethereal-new/Makefile.in --- ethereal/Makefile.in Fri Apr 30 11:16:22 1999 +++ ethereal-new/Makefile.in Fri Apr 30 11:31:04 1999 @@ -68,6 +68,7 @@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +SNMP_A = @SNMP_A@ SNPRINTF_C = @SNPRINTF_C@ SNPRINTF_O = @SNPRINTF_O@ VERSION = @VERSION@ @@ -78,14 +79,14 @@ sysconf_DATA = manuf -ethereal_SOURCES = capture.c column.c ethereal.c ethertype.c file.c filter.c follow.c gtkpacket.c menu.c packet.c packet-aarp.c packet-arp.c packet-atalk.c packet-bootp.c packet-cdp.c packet-data.c packet-dns.c packet-eth.c packet-ftp.c packet-fddi.c packet-giop.c packet-http.c packet-ip.c packet-icmpv6.c packet-ipsec.c packet-ipv6.c packet-ipx.c packet-llc.c packet-lpd.c packet-nbipx.c packet-nbns.c packet-ncp.c packet-nntp.c packet-null.c packet-osi.c packet-ospf.c packet-pop.c packet-ppp.c packet-raw.c packet-rip.c packet-tcp.c packet-telnet.c packet-tftp.c packet-tr.c packet-trmac.c packet-udp.c packet-vines.c prefs.c print.c ps.c resolv.c util.c capture.h column.h config.h ethereal.h etypes.h file.h filter.h follow.h menu.h ! packet.h packet-dns.h packet-ipv6.h packet-ipx.h packet-ncp.h packet-ospf.h packet-rip.h packet-vines.h prefs.h print.h ps.h resolv.h util.h +ethereal_SOURCES = capture.c column.c ethereal.c ethertype.c file.c filter.c follow.c gtkpacket.c menu.c packet.c packet-aarp.c packet-arp.c packet-atalk.c packet-bootp.c packet-cdp.c packet-data.c packet-dns.c packet-eth.c packet-ftp.c packet-fddi.c packet-giop.c packet-http.c packet-ip.c packet-icmpv6.c packet-ipsec.c packet-ipv6.c packet-ipx.c packet-llc.c packet-lpd.c packet-nbipx.c packet-nbns.c packet-ncp.c packet-nntp.c packet-null.c packet-osi.c packet-ospf.c packet-pop.c packet-ppp.c packet-raw.c packet-rip.c packet-snmp.c packet-tcp.c packet-telnet.c packet-tftp.c packet-tr.c packet-trmac.c packet-udp.c packet-vines.c prefs.c print.c ps.c resolv.c util.c capture.h column.h config.h ethereal.h etypes.h file.h filter.h follow.! h menu.h packet.h packet-dns.h packet-ipv6.h packet-ipx.h packet-ncp.h packet-ospf.h packet-rip.h packet-vines.h prefs.h print.h ps.h resolv.h util.h EXTRA_ethereal_SOURCES = snprintf.c snprintf.h snprintf-imp.h ethereal_DEPENDENCIES = @SNPRINTF_O@ @LIBWIRETAP_A@ -ethereal_LDADD = @SNPRINTF_O@ @LIBWIRETAP_A@ +ethereal_LDADD = @SNPRINTF_O@ @LIBWIRETAP_A@ @SNMP_A@ DISTCLEANFILES = rdps ps.c *~ @@ -112,9 +113,9 @@ packet-http.o packet-ip.o packet-icmpv6.o packet-ipsec.o packet-ipv6.o \ packet-ipx.o packet-llc.o packet-lpd.o packet-nbipx.o packet-nbns.o \ packet-ncp.o packet-nntp.o packet-null.o packet-osi.o packet-ospf.o \ -packet-pop.o packet-ppp.o packet-raw.o packet-rip.o packet-tcp.o \ -packet-telnet.o packet-tftp.o packet-tr.o packet-trmac.o packet-udp.o \ -packet-vines.o prefs.o print.o ps.o resolv.o util.o +packet-pop.o packet-ppp.o packet-raw.o packet-rip.o packet-snmp.o \ +packet-tcp.o packet-telnet.o packet-tftp.o packet-tr.o packet-trmac.o \ +packet-udp.o packet-vines.o prefs.o print.o ps.o resolv.o util.o ethereal_LDFLAGS = CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -148,10 +149,11 @@ .deps/packet-nbns.P .deps/packet-ncp.P .deps/packet-nntp.P \ .deps/packet-null.P .deps/packet-osi.P .deps/packet-ospf.P \ .deps/packet-pop.P .deps/packet-ppp.P .deps/packet-raw.P \ -.deps/packet-rip.P .deps/packet-tcp.P .deps/packet-telnet.P \ -.deps/packet-tftp.P .deps/packet-tr.P .deps/packet-trmac.P \ -.deps/packet-udp.P .deps/packet-vines.P .deps/packet.P .deps/prefs.P \ -.deps/print.P .deps/ps.P .deps/resolv.P .deps/snprintf.P .deps/util.P +.deps/packet-rip.P .deps/packet-snmp.P .deps/packet-tcp.P \ +.deps/packet-telnet.P .deps/packet-tftp.P .deps/packet-tr.P \ +.deps/packet-trmac.P .deps/packet-udp.P .deps/packet-vines.P \ +.deps/packet.P .deps/prefs.P .deps/print.P .deps/ps.P .deps/resolv.P \ +.deps/snprintf.P .deps/util.P SOURCES = $(ethereal_SOURCES) $(EXTRA_ethereal_SOURCES) OBJECTS = $(ethereal_OBJECTS) diff -urN ethereal/config.h.in ethereal-new/config.h.in --- ethereal/config.h.in Fri Apr 30 11:16:35 1999 +++ ethereal-new/config.h.in Fri Apr 30 11:31:16 1999 @@ -22,6 +22,9 @@ /* Define if you have the <netinet/in.h> header file. */ #undef HAVE_NETINET_IN_H +/* Define if you have the <snmp/snmp.h> header file. */ +#undef HAVE_SNMP_SNMP_H + /* Define if you have the <stdarg.h> header file. */ #undef HAVE_STDARG_H @@ -36,6 +39,9 @@ /* Define if you have the <sys/types.h> header file. */ #undef HAVE_SYS_TYPES_H + +/* Define if you have the <ucd-snmp/snmp.h> header file. */ +#undef HAVE_UCD_SNMP_SNMP_H /* Define if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H diff -urN ethereal/configure ethereal-new/configure --- ethereal/configure Fri Apr 30 11:16:23 1999 +++ ethereal-new/configure Fri Apr 30 11:31:04 1999 @@ -22,6 +22,8 @@ --without-wiretap Don't include wiretap library (default)" ac_help="$ac_help --enable-ipv6 use ipv6 name resolution, if available. [default=yes]" +ac_help="$ac_help + --enable-snmp use SNMP library, if available. [default=yes]" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -564,7 +566,7 @@ # 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:568: checking for a BSD compatible install" >&5 +echo "configure:570: 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 @@ -617,7 +619,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:621: checking whether build environment is sane" >&5 +echo "configure:623: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -674,7 +676,7 @@ test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:678: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:680: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -720,7 +722,7 @@ missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:724: checking for working aclocal" >&5 +echo "configure:726: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -733,7 +735,7 @@ fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:737: checking for working autoconf" >&5 +echo "configure:739: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -746,7 +748,7 @@ fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:750: checking for working automake" >&5 +echo "configure:752: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -759,7 +761,7 @@ fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:763: checking for working autoheader" >&5 +echo "configure:765: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -772,7 +774,7 @@ fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:776: checking for working makeinfo" >&5 +echo "configure:778: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -793,7 +795,7 @@ fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:797: checking host system type" >&5 +echo "configure:799: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -817,7 +819,7 @@ # 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:821: checking for $ac_word" >&5 +echo "configure:823: 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 @@ -847,7 +849,7 @@ # 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:851: checking for $ac_word" >&5 +echo "configure:853: 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 @@ -898,7 +900,7 @@ # 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:902: checking for $ac_word" >&5 +echo "configure:904: 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 @@ -930,7 +932,7 @@ fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:934: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:936: 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. @@ -941,12 +943,12 @@ cat > conftest.$ac_ext << EOF -#line 945 "configure" +#line 947 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:952: \"$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 @@ -972,12 +974,12 @@ { 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:976: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:978: 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:981: checking whether we are using GNU C" >&5 +echo "configure:983: 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 @@ -986,7 +988,7 @@ yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:990: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:992: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1005,7 +1007,7 @@ ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1009: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1011: 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 @@ -1039,7 +1041,7 @@ # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1043: checking for $ac_word" >&5 +echo "configure:1045: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1069,7 +1071,7 @@ # If we're running gcc, add '-Wall' to CFLAGS. echo $ac_n "checking to see if we can add '-Wall' to CFLAGS""... $ac_c" 1>&6 -echo "configure:1073: checking to see if we can add '-Wall' to CFLAGS" >&5 +echo "configure:1075: checking to see if we can add '-Wall' to CFLAGS" >&5 if test x$GCC != x ; then CFLAGS="-Wall $CFLAGS" echo "$ac_t""yes" 1>&6 @@ -1095,7 +1097,7 @@ case "$host_os" in solaris*) echo $ac_n "checking for LD_LIBRARY_PATH""... $ac_c" 1>&6 -echo "configure:1099: checking for LD_LIBRARY_PATH" >&5 +echo "configure:1101: checking for LD_LIBRARY_PATH" >&5 if test x$LD_LIBRARY_PATH != x ; then LIBS="$LIBS -R$LD_LIBRARY_PATH" echo "$ac_t""yes -- added LD_LIBRARY_PATH to run-time linker path" 1>&6 @@ -1156,7 +1158,7 @@ # Extract the first word of "gtk-config", so it can be a program name with args. set dummy gtk-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1160: checking for $ac_word" >&5 +echo "configure:1162: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GTK_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1191,7 +1193,7 @@ min_gtk_version=1.0.0 echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6 -echo "configure:1195: checking for GTK - version >= $min_gtk_version" >&5 +echo "configure:1197: checking for GTK - version >= $min_gtk_version" >&5 no_gtk="" if test "$GTK_CONFIG" = "no" ; then no_gtk=yes @@ -1214,7 +1216,7 @@ echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext <<EOF -#line 1218 "configure" +#line 1220 "configure" #include "confdefs.h" #include <gtk/gtk.h> @@ -1292,7 +1294,7 @@ } EOF -if { (eval echo configure:1296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1298: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1326,7 +1328,7 @@ CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" cat > conftest.$ac_ext <<EOF -#line 1330 "configure" +#line 1332 "configure" #include "confdefs.h" #include <gtk/gtk.h> @@ -1336,7 +1338,7 @@ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ; return 0; } EOF -if { (eval echo configure:1340: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding GTK or finding the wrong" @@ -1377,7 +1379,7 @@ # Evidently, some systems have pcap.h, etc. in */include/pcap echo $ac_n "checking for extraneous pcap header directories""... $ac_c" 1>&6 -echo "configure:1381: checking for extraneous pcap header directories" >&5 +echo "configure:1383: checking for extraneous pcap header directories" >&5 found_pcap_dir="" for pcap_dir in /usr/include/pcap /usr/local/include/pcap do @@ -1397,7 +1399,7 @@ # Pcap checks echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1401: checking how to run the C preprocessor" >&5 +echo "configure:1403: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1412,13 +1414,13 @@ # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext <<EOF -#line 1416 "configure" +#line 1418 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1422: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1424: \"$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 : @@ -1429,13 +1431,13 @@ rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext <<EOF -#line 1433 "configure" +#line 1435 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1439: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1441: \"$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 : @@ -1446,13 +1448,13 @@ rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext <<EOF -#line 1450 "configure" +#line 1452 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1456: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1458: \"$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 : @@ -1478,17 +1480,17 @@ ac_safe=`echo "net/bpf.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for net/bpf.h""... $ac_c" 1>&6 -echo "configure:1482: checking for net/bpf.h" >&5 +echo "configure:1484: checking for net/bpf.h" >&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 -#line 1487 "configure" +#line 1489 "configure" #include "confdefs.h" #include <net/bpf.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1492: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1494: \"$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* @@ -1512,17 +1514,17 @@ ac_safe=`echo "pcap.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for pcap.h""... $ac_c" 1>&6 -echo "configure:1516: checking for pcap.h" >&5 +echo "configure:1518: checking for pcap.h" >&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 -#line 1521 "configure" +#line 1523 "configure" #include "confdefs.h" #include <pcap.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1526: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1528: \"$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* @@ -1545,7 +1547,7 @@ fi echo $ac_n "checking for pcap_open_offline in -lpcap""... $ac_c" 1>&6 -echo "configure:1549: checking for pcap_open_offline in -lpcap" >&5 +echo "configure:1551: checking for pcap_open_offline in -lpcap" >&5 ac_lib_var=`echo pcap'_'pcap_open_offline | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1553,7 +1555,7 @@ ac_save_LIBS="$LIBS" LIBS="-lpcap $LIBS" cat > conftest.$ac_ext <<EOF -#line 1557 "configure" +#line 1559 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -1564,7 +1566,7 @@ pcap_open_offline() ; return 0; } EOF -if { (eval echo configure:1568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1570: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1595,7 +1597,7 @@ # Wiretap check echo $ac_n "checking whether to include wiretap library""... $ac_c" 1>&6 -echo "configure:1599: checking whether to include wiretap library" >&5 +echo "configure:1601: checking whether to include wiretap library" >&5 # Check whether --with-wiretap or --without-wiretap was given. if test "${with_wiretap+set}" = set; then withval="$with_wiretap" @@ -1637,7 +1639,7 @@ echo $ac_n "checking whether to enable ipv6 name resolution if available""... $ac_c" 1>&6 -echo "configure:1641: checking whether to enable ipv6 name resolution if available" >&5 +echo "configure:1643: checking whether to enable ipv6 name resolution if available" >&5 if test "x$enable_ipv6" = "xno" ; then echo "$ac_t""no" 1>&6 else @@ -1647,12 +1649,12 @@ v6lib=none echo $ac_n "checking ipv6 stack type""... $ac_c" 1>&6 -echo "configure:1651: checking ipv6 stack type" >&5 +echo "configure:1653: checking ipv6 stack type" >&5 for i in v6d toshiba kame inria zeta linux; do case $i in v6d) cat > conftest.$ac_ext <<EOF -#line 1656 "configure" +#line 1658 "configure" #include "confdefs.h" dnl #include </usr/local/v6/include/sys/types.h> @@ -1672,7 +1674,7 @@ ;; toshiba) cat > conftest.$ac_ext <<EOF -#line 1676 "configure" +#line 1678 "configure" #include "confdefs.h" dnl #include <sys/param.h> @@ -1692,7 +1694,7 @@ ;; kame) cat > conftest.$ac_ext <<EOF -#line 1696 "configure" +#line 1698 "configure" #include "confdefs.h" dnl #include <netinet/in.h> @@ -1712,7 +1714,7 @@ ;; inria) cat > conftest.$ac_ext <<EOF -#line 1716 "configure" +#line 1718 "configure" #include "confdefs.h" dnl #include <netinet/in.h> @@ -1730,7 +1732,7 @@ ;; zeta) cat > conftest.$ac_ext <<EOF -#line 1734 "configure" +#line 1736 "configure" #include "confdefs.h" dnl #include <sys/param.h> @@ -1779,12 +1781,12 @@ echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1783: checking for ANSI C header files" >&5 +echo "configure:1785: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1788 "configure" +#line 1790 "configure" #include "confdefs.h" #include <stdlib.h> #include <stdarg.h> @@ -1792,7 +1794,7 @@ #include <float.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1796: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1798: \"$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* @@ -1809,7 +1811,7 @@ if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 1813 "configure" +#line 1815 "configure" #include "confdefs.h" #include <string.h> EOF @@ -1827,7 +1829,7 @@ if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 1831 "configure" +#line 1833 "configure" #include "confdefs.h" #include <stdlib.h> EOF @@ -1848,7 +1850,7 @@ : else cat > conftest.$ac_ext <<EOF -#line 1852 "configure" +#line 1854 "configure" #include "confdefs.h" #include <ctype.h> #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1859,7 +1861,7 @@ exit (0); } EOF -if { (eval echo configure:1863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1886,17 +1888,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1890: checking for $ac_hdr" >&5 +echo "configure:1892: 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 -#line 1895 "configure" +#line 1897 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1900: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1902: \"$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* @@ -1927,17 +1929,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1931: checking for $ac_hdr" >&5 +echo "configure:1933: 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 -#line 1936 "configure" +#line 1938 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1941: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1943: \"$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* @@ -1964,18 +1966,119 @@ done + +# Check whether --enable-snmp or --disable-snmp was given. +if test "${enable_snmp+set}" = set; then + enableval="$enable_snmp" + : +else + enable_snmp=yes +fi + + +SNMP_A='' +echo $ac_n "checking whether to use SNMP library if available""... $ac_c" 1>&6 +echo "configure:1982: checking whether to use SNMP library if available" >&5 +if test "x$enable_snmp" = "xno" ; then + echo "$ac_t""no" 1>&6 +else + echo "$ac_t""yes" 1>&6 + for ac_hdr in ucd-snmp/snmp.h snmp/snmp.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1991: 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 +#line 1996 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2001: \"$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 <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + echo $ac_n "checking for asn_parse_header in -lsnmp""... $ac_c" 1>&6 +echo "configure:2028: checking for asn_parse_header in -lsnmp" >&5 +ac_lib_var=`echo snmp'_'asn_parse_header | 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="-lsnmp $LIBS" +cat > conftest.$ac_ext <<EOF +#line 2036 "configure" +#include "confdefs.h" +/* 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 asn_parse_header(); + +int main() { +asn_parse_header() +; return 0; } +EOF +if { (eval echo configure:2047: \"$ac_link\") 1>&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 + SNMP_A=-lsnmp +else + echo "$ac_t""no" 1>&6 +{ echo "configure: error: Library snmp not found." 1>&2; exit 1; } +fi + +fi + + # AC_C_CONST # We need to know whether "struct sockaddr" has an "sa_len" member # for get_interface_list(). echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6 -echo "configure:1974: checking for sa_len in struct sockaddr" >&5 +echo "configure:2077: checking for sa_len in struct sockaddr" >&5 if eval "test \"`echo '$''{'ac_cv_ethereal_struct_sa_len'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1979 "configure" +#line 2082 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/socket.h> @@ -1983,7 +2086,7 @@ struct sockaddr s; s.sa_len; ; return 0; } EOF -if { (eval echo configure:1987: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2090: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_ethereal_struct_sa_len=yes else @@ -2006,14 +2109,14 @@ # We must know our byte order echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:2010: checking whether byte ordering is bigendian" >&5 +echo "configure:2113: checking whether byte ordering is bigendian" >&5 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext <<EOF -#line 2017 "configure" +#line 2120 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/param.h> @@ -2024,11 +2127,11 @@ #endif ; return 0; } EOF -if { (eval echo configure:2028: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2131: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext <<EOF -#line 2032 "configure" +#line 2135 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/param.h> @@ -2039,7 +2142,7 @@ #endif ; return 0; } EOF -if { (eval echo configure:2043: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2146: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -2059,7 +2162,7 @@ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 2063 "configure" +#line 2166 "configure" #include "confdefs.h" main () { /* Are we little or big endian? From Harbison&Steele. */ @@ -2072,7 +2175,7 @@ exit (u.c[sizeof (long) - 1] == 1); } EOF -if { (eval echo configure:2076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -2098,13 +2201,13 @@ if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:2102: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:2205: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext <<EOF -#line 2108 "configure" +#line 2211 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -2122,7 +2225,7 @@ if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 2126 "configure" +#line 2229 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -2144,12 +2247,12 @@ fi echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:2148: checking for socket" >&5 +echo "configure:2251: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2153 "configure" +#line 2256 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char socket(); below. */ @@ -2172,7 +2275,7 @@ ; return 0; } EOF -if { (eval echo configure:2176: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_socket=yes" else @@ -2198,12 +2301,12 @@ SNPRINTF_C="" SNPRINTF_O="" echo $ac_n "checking for snprintf""... $ac_c" 1>&6 -echo "configure:2202: checking for snprintf" >&5 +echo "configure:2305: checking for snprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_snprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 2207 "configure" +#line 2310 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char snprintf(); below. */ @@ -2226,7 +2329,7 @@ ; return 0; } EOF -if { (eval echo configure:2230: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_snprintf=yes" else @@ -2421,6 +2524,7 @@ s%@CPP@%$CPP%g s%@LIBWIRETAP_A@%$LIBWIRETAP_A%g s%@SUBDIRS@%$SUBDIRS%g +s%@SNMP_A@%$SNMP_A%g s%@SNPRINTF_C@%$SNPRINTF_C%g s%@SNPRINTF_O@%$SNPRINTF_O%g s%@subdirs@%$subdirs%g diff -urN ethereal/configure.in ethereal-new/configure.in --- ethereal/configure.in Fri Apr 30 11:14:38 1999 +++ ethereal-new/configure.in Fri Apr 30 11:30:16 1999 @@ -118,6 +118,24 @@ AC_CHECK_HEADERS(sys/sockio.h sys/types.h netinet/in.h) + +dnl SNMP Check +AC_ARG_ENABLE(snmp, +[ --enable-snmp use SNMP library, if available. [default=yes]],,enable_snmp=yes) + +SNMP_A='' +AC_MSG_CHECKING(whether to use SNMP library if available) +if test "x$enable_snmp" = "xno" ; then + AC_MSG_RESULT(no) +else + AC_MSG_RESULT(yes) + AC_CHECK_HEADERS(ucd-snmp/snmp.h snmp/snmp.h) + AC_CHECK_LIB(snmp, asn_parse_header, + SNMP_A=-lsnmp, + AC_MSG_ERROR(Library snmp not found.)) +fi +AC_SUBST(SNMP_A) + dnl Checks for typedefs, structures, and compiler characteristics. # AC_C_CONST diff -urN ethereal/packet-snmp.c ethereal-new/packet-snmp.c --- ethereal/packet-snmp.c Wed Dec 31 19:00:00 1969 +++ ethereal-new/packet-snmp.c Thu Apr 29 17:11:02 1999 @@ -0,0 +1,883 @@ +/* packet-snmp.c + * Routines for SNMP (simple network management protocol) + * D.Jorand (c) 1998 + * + * $Id: packet-snmp.c,v 1.1 1999/02/22 11:49:53 root Exp root $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@xxxxxxxxxx> + * Copyright 1998 Didier Jorand + * + * + * This program 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#define WITH_SNMP_UCD 1 + +#if defined(HAVE_UCD_SNMP_SNMP_H) + #define WITH_SNMP_UCD 1 +#elif defined(HAVE_SNMP_SNMP_H) + #defined WITH_SNMP_UCD 1 +#endif + +#if defined(WITH_SNMP_CMU) || defined(WITH_SNMP_UCD) + +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif + +#include <glib.h> +#include "packet.h" + +#define in_addr_t u_int + +#ifdef WITH_SNMP_UCD +/* should be defined only if supported in ucd-snmp */ +#define OPAQUE_SPECIAL_TYPES 1 +#include <ucd-snmp/asn1.h> +#include <ucd-snmp/snmp.h> +#include <ucd-snmp/snmp_api.h> +#include <ucd-snmp/snmp_impl.h> +#include <ucd-snmp/mib.h> + +typedef long SNMP_INT; +typedef unsigned long SNMP_UINT; +#define OID_FORMAT_STRING "%ld" +#define OID_FORMAT_STRING1 ".%ld" + +#endif +#ifdef WITH_SNMP_CMU +#include <snmp/snmp.h> + +#define SNMP_MSG_GET GET_REQ_MSG +#define SNMP_MSG_GETNEXT GETNEXT_REQ_MSG +#define SNMP_MSG_RESPONSE GET_RSP_MSG +#define SNMP_MSG_SET SET_REQ_MSG +#define SNMP_MSG_TRAP TRP_REQ_MSG +#define SNMP_MSG_GETBULK SNMP_PDU_GETBULK +#define SNMP_MSG_INFORM SNMP_PDU_INFORM +#define SNMP_MSG_TRAP2 SNMP_PDU_V2TRAP +#define SNMP_MSG_REPORT SNMP_PDU_REPORT + +#ifndef SNMP_VERSION_2c +#define SNMP_VERSION_2c 1 +#endif +#ifndef SNMP_VERSION_2u +#define SNMP_VERSION_2u 2 +#endif +#ifndef SNMP_VERSION_3 +#define SNMP_VERSION_3 3 +#endif + +#define SNMP_TRAP_AUTHFAIL SNMP_TRAP_AUTHENTICATIONFAILURE + +#ifndef COMMUNITY_MAX_LEN +#define COMMUNITY_MAX_LEN 256 +#endif + +#ifndef ASN_INTEGER +#define ASN_INTEGER SMI_INTEGER +#endif +#ifndef ASN_OCTET_STR +#define ASN_OCTET_STR SMI_STRING +#endif +#ifndef ASN_OBJECT_ID +#define ASN_OBJECT_ID SMI_OBJID +#endif +#ifndef ASN_NULL +#define ASN_NULL SMI_NULLOBJ +#endif +#ifndef ASN_IPADDRESS +#define ASN_IPADDRESS SMI_IPADDRESS +#endif +#ifndef ASN_COUNTER +#define ASN_COUNTER SMI_COUNTER32 +#endif +#ifndef ASN_GAUGE +#define ASN_GAUGE SMI_GAUGE32 +#endif +#ifndef ASN_TIMETICKS +#define ASN_TIMETICKS SMI_TIMETICKS +#endif +#ifndef ASN_OPAQUE +#define ASN_OPAQUE SMI_OPAQUE +#endif +#ifndef ASN_COUNTER64 +#define ASN_COUNTER64 SMI_COUNTER64 +#endif +#ifndef ASN_UINTEGER +/* historic: should not be used! */ +#define ASN_UINTEGER (ASN_APPLICATION | 7) +#endif +#ifndef ASN_NSAP +/* historic: should not be used! */ +#define ASN_NSAP (ASN_APPLICATION | 5) +#endif +#ifndef SNMP_NOSUCHOBJECT +#define SNMP_NOSUCHOBJECT SMI_NOSUCHOBJECT +#endif +#ifndef SNMP_NOSUCHINSTANCE +#define SNMP_NOSUCHINSTANCE SMI_NOSUCHINSTANCE +#endif +#ifndef SNMP_ENDOFMIBVIEW +#define SNMP_ENDOFMIBVIEW SMI_ENDOFMIBVIEW +#endif + + +typedef int SNMP_INT; +typedef unsigned int SNMP_UINT; +#define OID_FORMAT_STRING "%d" +#define OID_FORMAT_STRING1 ".%d" + +#endif + +static const char *get_version(int version) +{ + switch(version) { + case SNMP_VERSION_1: + return "VERSION 1"; + break; + case SNMP_VERSION_2c: + return "VERSION 2C"; + break; + case SNMP_VERSION_2u: + return "VERSION 2U"; + break; + case SNMP_VERSION_3: + return "VERSION 3"; + break; + default: + return "UNKNOWN"; + break; + } + return ""; +} + +static const char *get_pdu_type(u_char pdu_type) +{ + switch(pdu_type) { + case SNMP_MSG_GET: + return "GET"; + break; + case SNMP_MSG_GETNEXT: + return "GET-NEXT"; + break; + case SNMP_MSG_SET: + return "SET"; + break; + case SNMP_MSG_RESPONSE: + return "RESPONSE"; + break; + case SNMP_MSG_TRAP: + return "TRAP-V1"; + break; + case SNMP_MSG_GETBULK: + return "GETBULK"; + break; + case SNMP_MSG_INFORM: + return "INFORM"; + break; + case SNMP_MSG_TRAP2: + return "TRAP-V2"; + break; + case SNMP_MSG_REPORT: + return "REPORT"; + break; + default: + return "UNKNOWN"; + break; + } + return ""; +} + +static const char *get_error_status(long status) +{ + switch(status) { + case SNMP_ERR_NOERROR: + return "NO ERROR"; + break; + case SNMP_ERR_TOOBIG: + return "ERROR: TOOBIG"; + break; + case SNMP_ERR_NOSUCHNAME: + return "ERROR: NO SUCH NAME"; + break; + case SNMP_ERR_BADVALUE: + return "ERROR: BAD VALUE"; + break; + case SNMP_ERR_READONLY: + return "ERROR: READ ONLY"; + break; + case SNMP_ERR_GENERR: + return "ERROR: GENERIC ERROR"; + break; + case SNMP_ERR_NOACCESS: + return "ERROR: NO ACCESS"; + break; + case SNMP_ERR_WRONGTYPE: + return "ERROR: WRONG TYPE"; + break; + case SNMP_ERR_WRONGLENGTH: + return "ERROR: WRONG LENGTH"; + break; + case SNMP_ERR_WRONGENCODING: + return "ERROR: WRONG ENCODING"; + break; + case SNMP_ERR_WRONGVALUE: + return "ERROR: WRONG VALUE"; + break; + case SNMP_ERR_NOCREATION: + return "ERROR: NO CREATION"; + break; + case SNMP_ERR_INCONSISTENTVALUE: + return "ERROR: INCONSISTENT VALUE"; + break; + case SNMP_ERR_RESOURCEUNAVAILABLE: + return "ERROR: RESOURCE UNAVAILABLE"; + break; + case SNMP_ERR_COMMITFAILED: + return "ERROR: COMMIT FAILED"; + break; + case SNMP_ERR_UNDOFAILED: + return "ERROR: UNDO FAILED"; + break; + case SNMP_ERR_AUTHORIZATIONERROR: + return "ERROR: AUTHORIZATION ERROR"; + break; + case SNMP_ERR_NOTWRITABLE: + return "ERROR: NOT WRITABLE"; + break; + case SNMP_ERR_INCONSISTENTNAME: + return "ERROR: INCONSISTENT NAME"; + break; + default: + return "ERROR: UNKNOWN"; + break; + } + return ""; +} + +static const char *get_trap_type(long trap_type) +{ + switch(trap_type) { + case SNMP_TRAP_COLDSTART: + return "COLD START"; + break; + case SNMP_TRAP_WARMSTART: + return "WARM START"; + break; + case SNMP_TRAP_LINKDOWN: + return "LINK DOWN"; + break; + case SNMP_TRAP_LINKUP: + return "LINK UP"; + break; + case SNMP_TRAP_AUTHFAIL: + return "AUTHENTICATION FAILED"; + break; + case SNMP_TRAP_EGPNEIGHBORLOSS: + return "EGP NEIGHBORLOSS"; + break; + case SNMP_TRAP_ENTERPRISESPECIFIC: + return "ENTERPRISE SPECIFIC"; + break; + default: + return "UNKNOWN"; + break; + } + return ""; +} + +void +dissect_snmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) +{ + int length=fd->pkt_len-offset; + u_char *data, *tmp_data; + + int all_length, header_length; + u_char type, pdu_type; + int pdu_type_length; + SNMP_INT request_id, error_status, error_index; + int request_id_length, error_status_length, error_index_length; + + SNMP_INT version; + u_char community[COMMUNITY_MAX_LEN]; + int community_length = COMMUNITY_MAX_LEN; + + oid enterprise[MAX_NAME_LEN]; + int enterprise_length; + SNMP_INT trap_type, specific_type; + SNMP_UINT timestamp; + + int tmp_length; + oid vb_name[MAX_NAME_LEN]; + int vb_name_length; + int vb_index; + u_char vb_type; + char vb_string[MAX_NAME_LEN*6]; /* TBC */ + char vb_string2[2048]; /* TBC */ + char tmp_string[12]; + SNMP_INT vb_integer_value; + SNMP_UINT vb_unsigned_value; +#ifdef WITH_SNMP_UCD + struct counter64 vb_counter64_value; +#endif + oid vb_oid_value[MAX_NAME_LEN]; + int vb_oid_value_length; + unsigned char vb_string_value[128]; + int vb_string_value_length; +#ifdef WITH_SNMP_UCD + float vb_float_value; + double vb_double_value; +#endif + + int i; + + proto_tree *snmp_tree=NULL; + proto_item *item=NULL; + + /* NOTE: we have to parse the message piece by piece, since the + * capture length may be less than the message length: a 'global' + * parsing is likely to fail. + */ + +#ifdef WITH_SNMP_UCD + /* parse the SNMP header */ + if(NULL == asn_parse_header( &pd[offset], &length, &type)) { + fprintf(stderr, "<1> asn_parse_header failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + + if (type != (ASN_SEQUENCE | ASN_CONSTRUCTOR)) { + fprintf(stderr, "<2> not a snmp pdu\n"); + dissect_data(pd, offset, fd, tree); + return; + } + + /* authenticates message */ + length=fd->pkt_len-offset; + header_length=length; + data = snmp_comstr_parse(&pd[offset], &length, community, &community_length,&version); + if(NULL == data) { + fprintf(stderr, "<3> authentication failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } +#endif +#ifdef WITH_SNMP_CMU + /* initialize length variables */ + /* length=fd->pkt_len-offset; */ + header_length=length; + + /* parse the SNMP header */ + data = asn_parse_header( &pd[offset], &length, &type); + if(NULL == data) { + fprintf(stderr, "<1> asn_parse_header failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + + if (type != (ASN_SEQUENCE | ASN_CONSTRUCTOR)) { + fprintf(stderr, "<2> not a snmp pdu\n"); + dissect_data(pd, offset, fd, tree); + return; + } + + data = asn_parse_int(data, &length, &type, &version, sizeof(SNMP_INT)); + if(NULL == data) { + fprintf(stderr, "<2.1> parse snmp version failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + data = asn_parse_string(data, &length, &type, community, &community_length); + if(NULL == data) { + fprintf(stderr, "<2.1> parse snmp community failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + community[community_length] = '\0'; +#endif + + header_length-=length; + /* printf("Community is %s, version is %d (header length is %d)\n", community, version, header_length); */ + if(version != SNMP_VERSION_1) { + fprintf(stderr, "<4> only SNMP V1 is supported\n"); + dissect_data(pd, offset, fd, tree); + return; + } + + pdu_type_length=length; + data = asn_parse_header(data, &length, &pdu_type); + if (data == NULL) { + fprintf(stderr, "<5> parsing of pdu type failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + pdu_type_length-=length; + /* printf("pdu type is %#x (length is %d)\n", type, pdu_type_length); */ + + /* get the fields in the PDU preceeding the variable-bindings sequence */ + if (pdu_type != SNMP_MSG_TRAP){ + + /* request id */ + request_id_length=length; + data = asn_parse_int(data, &length, &type, &request_id, sizeof(request_id)); + if (data == NULL) { + fprintf(stderr, "<6> parsing of request-id failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + request_id_length-=length; + /* printf("request id is %#lx (length is %d)\n", request_id, request_id_length); */ + + /* error status (getbulk non-repeaters) */ + error_status_length=length; + data = asn_parse_int(data, &length, &type, &error_status, sizeof(error_status)); + if (data == NULL) { + fprintf(stderr, "<7> parsing of error-status failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + error_status_length-=length; + + /* error index (getbulk max-repetitions) */ + error_index_length=length; + data = asn_parse_int(data, &length, &type, &error_index, sizeof(error_index)); + if (data == NULL) { + fprintf(stderr, "<8> parsing of error-index failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + error_index_length-=length; + + if(tree) { + /* all_length=header_length+pdu_type_length+request_id_length+error_status_length+error_index_length; */ + all_length=fd->pkt_len-offset; + item = proto_tree_add_item(tree, offset, all_length, "Simple Network Management Protocol"); + snmp_tree = proto_tree_new(); + proto_item_add_subtree(item, snmp_tree, ETT_SNMP); + proto_tree_add_item(snmp_tree, offset, header_length, "Community: \"%s\", Version: %s", community, get_version(version)); + offset+=header_length; + proto_tree_add_item(snmp_tree, offset, pdu_type_length, "Pdu type: %s (%#x)", get_pdu_type(pdu_type), pdu_type); + offset+=pdu_type_length; + proto_tree_add_item(snmp_tree, offset, request_id_length, "Request Id.: %#x", (unsigned int)request_id); + offset+=request_id_length; + proto_tree_add_item(snmp_tree, offset, error_status_length, "Error Status: %s (%d)", get_error_status(error_status), (int)error_status); + offset+=error_status_length; + proto_tree_add_item(snmp_tree, offset, error_index_length, "Error Index: %d", (int)error_index); + offset+=error_index_length; + } else { + offset+=header_length; + offset+=pdu_type_length; + offset+=request_id_length; + offset+=error_status_length; + offset+=error_index_length; + } + + } else { + /* an SNMPv1 trap PDU */ + if(tree) { + all_length=fd->pkt_len-offset; + item = proto_tree_add_item(tree, offset, all_length, "Simple Network Management Protocol"); + snmp_tree = proto_tree_new(); + proto_item_add_subtree(item, snmp_tree, ETT_SNMP); + proto_tree_add_item(snmp_tree, offset, header_length, "Community: \"%s\", Version: %s", community, get_version(version)); + offset+=header_length; + proto_tree_add_item(snmp_tree, offset, pdu_type_length, "Pdu type: %s (%#x)", get_pdu_type(pdu_type), pdu_type); + offset+=pdu_type_length; + } else { + offset+=header_length; + offset+=pdu_type_length; + } + + /* enterprise */ + enterprise_length = MAX_NAME_LEN; + tmp_length=length; + data = asn_parse_objid(data, &length, &type, enterprise, &enterprise_length); + if (data == NULL) { + fprintf(stderr, "<9> parsing of enterprise oid failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + tmp_length-=length; + + sprintf(vb_string, OID_FORMAT_STRING, enterprise[0]); + for(i=1; i<enterprise_length;i++) { + sprintf(tmp_string, OID_FORMAT_STRING1, enterprise[i]); + strcat(vb_string,tmp_string); + } + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Enterprise: %s", vb_string); + } + offset+=tmp_length; + + /* agent address */ + vb_string_value_length = 4; + tmp_length=length; + data = asn_parse_string(data, &length, &type, vb_string_value, &vb_string_value_length); + if (data == NULL) { + fprintf(stderr, "<10> parsing of agent address failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + tmp_length-=length; + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Agent address: %d.%d.%d.%d", + vb_string_value[0],vb_string_value[1],vb_string_value[2],vb_string_value[3]); + } + offset+=tmp_length; + + /* generic trap */ + tmp_length=length; + data = asn_parse_int(data, &length, &type, &trap_type, sizeof(trap_type)); + if (data == NULL) { + fprintf(stderr, "<11> parsing of trap type failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + tmp_length-=length; + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Trap type: %s (%ld)", get_trap_type(trap_type), (long)trap_type); + } + offset+=tmp_length; + + /* specific trap */ + tmp_length=length; + data = asn_parse_int(data, &length, &type, &specific_type, sizeof(specific_type)); + if (data == NULL) { + fprintf(stderr, "<12> parsing of specific trap type failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + tmp_length-=length; + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Specific trap type: %ld (%#lx)", (long)specific_type, (long)specific_type); + } + offset+=tmp_length; + + /* timestamp */ + tmp_length=length; + data = asn_parse_unsigned_int(data, &length, &type, ×tamp, sizeof(timestamp)); + if (data == NULL) { + fprintf(stderr, "<13> parsing of timestamp failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + tmp_length-=length; + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Timestamp: %lu", (unsigned long)timestamp); + } + offset+=tmp_length; + } + + /* variable bindings */ + /* get header for variable-bindings sequence */ + tmp_length=length; + data = asn_parse_header(data, &length, &type); + if (data == NULL) { + fprintf(stderr, "<+> parsing of variable-bindings header failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + tmp_length-=length; + if (type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR)) { + fprintf(stderr, "<+> bad type for variable-bindings header\n"); + dissect_data(pd, offset, fd, tree); + return; + } + offset+=tmp_length; + /* printf("VB header: offset is %d; length is %d.\n", offset, tmp_length); */ + + /* loop on variable bindings */ + vb_index=0; + while(length>0) { + vb_index++; + /* printf("VB index is %d (offset=%d; length=%d).\n", vb_index, offset, length); */ + /* parse type */ + tmp_length=length; + tmp_data=data; + data = asn_parse_header(data, &tmp_length, &type); + if (data == NULL) { + fprintf(stderr, "<20> parsing of variable-binding header failed\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if (type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR)) { + fprintf(stderr, "<21> bad type for variable-binding header (%#x)\n", type); + dissect_data(pd, offset, fd, tree); + return; + } + tmp_length=(int)(data-tmp_data); + length-=tmp_length; + offset+=tmp_length; + + /* parse object identifier */ + vb_name_length=MAX_NAME_LEN; + tmp_length=length; + data = asn_parse_objid(data, &length, &type, vb_name, &vb_name_length); + if (data == NULL) { + fprintf(stderr, "<22> no object-identifier for variable-binding\n"); + dissect_data(pd, offset, fd, tree); + return; + } + + if (type != (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID)) { + fprintf(stderr, "<23> bad type for variable-binding (%#x)\n", type); + dissect_data(pd, offset, fd, tree); + return; + } + tmp_length-=length; + + if(tree) { + sprintf(vb_string, OID_FORMAT_STRING, vb_name[0]); + for(i=1; i<vb_name_length;i++) { + sprintf(tmp_string, OID_FORMAT_STRING1, vb_name[i]); + strcat(vb_string,tmp_string); + } + + sprint_objid(vb_string2, vb_name, vb_name_length); + + proto_tree_add_item(snmp_tree, offset, tmp_length, "Object identifier %d: %s (%s)", vb_index, vb_string, vb_string2); + } + offset+=tmp_length; + + /* parse the type of the object */ + tmp_length=length; + if (NULL == asn_parse_header(data, &tmp_length, &vb_type)){ + fprintf(stderr, "<24> no type for variable-binding value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + + /* parse the value */ + switch(vb_type) { + case ASN_NULL: + tmp_length=length; + data=asn_parse_null(data, &length, &type); + tmp_length-=length; + if (data == NULL){ + fprintf(stderr, "<25> parsing failed for null value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: NULL"); + } + offset+=tmp_length; + break; + + case ASN_INTEGER: + tmp_length=length; + data=asn_parse_int(data, &length, &type, &vb_integer_value, sizeof(vb_integer_value)); + tmp_length-=length; + if (data == NULL){ + fprintf(stderr, "<26> parsing failed for integer value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <i> %ld (%#lx)", (long)vb_integer_value, (long)vb_integer_value); + } + offset+=tmp_length; + break; + + case ASN_COUNTER: + case ASN_GAUGE: + case ASN_TIMETICKS: + case ASN_UINTEGER: + tmp_length=length; + data=asn_parse_unsigned_int(data, &length, &type, &vb_unsigned_value, sizeof(vb_unsigned_value)); + tmp_length-=length; + if (data == NULL){ + fprintf(stderr, "<27> parsing failed for unsigned value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <u> %lu (%#lx)", (unsigned long)vb_unsigned_value, (unsigned long)vb_unsigned_value); + } + offset+=tmp_length; + break; + +#ifdef WITH_SNMP_UCD + /* only ucd support 64bits types */ + case ASN_COUNTER64: +#ifdef OPAQUE_SPECIAL_TYPES + case ASN_OPAQUE_COUNTER64: + case ASN_OPAQUE_U64: +#endif /* OPAQUE_SPECIAL_TYPES */ + tmp_length=length; + data=asn_parse_unsigned_int64(data, &length, &type, &vb_counter64_value, sizeof(vb_counter64_value)); + tmp_length-=length; + if (data == NULL){ + fprintf(stderr, "<28> parsing failed for counter64 value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <i64> %lu:%lu (%#lx:%lx)", + vb_counter64_value.high, + vb_counter64_value.low, + vb_counter64_value.high, + vb_counter64_value.low); + } + offset+=tmp_length; + break; +#endif /* WITH_SNMP_UCD */ + + case ASN_OBJECT_ID: + vb_oid_value_length = MAX_NAME_LEN; + tmp_length=length; + data=asn_parse_objid(data, &length, &type, vb_oid_value, &vb_oid_value_length); + tmp_length-=length; + if (data == NULL){ + fprintf(stderr, "<29> parsing failed for oid value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if(tree) { + sprintf(vb_string, OID_FORMAT_STRING, vb_oid_value[0]); + for(i=1; i<vb_oid_value_length;i++) { + sprintf(tmp_string, OID_FORMAT_STRING1, vb_oid_value[i]); + strcat(vb_string,tmp_string); + } + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <oid> %s", vb_string); + } + offset+=tmp_length; + break; + case ASN_OCTET_STR: + case ASN_IPADDRESS: + case ASN_OPAQUE: + case ASN_NSAP: + vb_string_value_length=128; + tmp_length=length; + data=asn_parse_string(data, &length, &type, vb_string_value, &vb_string_value_length); + tmp_length-=length; + if (data == NULL){ + fprintf(stderr, "<30> parsing failed for octet string value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if(tree) { + vb_string_value[vb_string_value_length]=0; + /* if some characters are not printable, display the string as + * bytes */ + for(i=0; i<vb_string_value_length; i++) { + if(!(isprint(vb_string_value[i]) || isspace(vb_string_value[i]))) break; + } + if(i<vb_string_value_length) { + sprintf(vb_string, "%03d", (int)vb_string_value[0]); + for(i=1; i<vb_string_value_length; i++) { + sprintf(tmp_string, ".%03d", (int)vb_string_value[i]); + strcat(vb_string,tmp_string); + } + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <str> %s", vb_string); + }else { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <str> %s", vb_string_value); + } + } + offset+=tmp_length; + break; + +#ifdef OPAQUE_SPECIAL_TYPES + case ASN_OPAQUE_I64: + tmp_length=length; + data=asn_parse_signed_int64(data, &length, &type, &vb_counter64_value, sizeof(vb_counter64_value)); + tmp_length-=length; + if (data == NULL){ + fprintf(stderr, "<31> parsing failed for integer64 value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <i64> %ld:%lu (%#lx:%lx)", + vb_counter64_value.high, + vb_counter64_value.low, + vb_counter64_value.high, + vb_counter64_value.low); + } + offset+=tmp_length; + break; + break; + + case ASN_OPAQUE_FLOAT: + tmp_length=length; + data=asn_parse_float(data, &length, &type,&vb_float_value, sizeof(vb_float_value)); + tmp_length-=length; + if (data == NULL){ + fprintf(stderr, "<32> parsing failed for float value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <f> %f", (double)vb_float_value); + } + offset+=tmp_length; + break; + + case ASN_OPAQUE_DOUBLE: + tmp_length=length; + data=asn_parse_double(data, &length, &type,&vb_double_value, sizeof(vb_double_value)); + tmp_length-=length; + if (data == NULL){ + fprintf(stderr, "<32> parsing failed for double value\n"); + dissect_data(pd, offset, fd, tree); + return; + } + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <d> %f", vb_double_value); + } + offset+=tmp_length; + break; +#endif /* OPAQUE_SPECIAL_TYPES */ + + case SNMP_NOSUCHOBJECT: + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <err> no such object"); + } + break; + case SNMP_NOSUCHINSTANCE: + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <err> no such instance"); + } + break; + case SNMP_ENDOFMIBVIEW: + if(tree) { + proto_tree_add_item(snmp_tree, offset, tmp_length, "Value: <err> end of mib view"); + } + break; + + default: + fprintf(stderr, "<=> unsupported type for variable-binding value: %#x\n", vb_type); + dissect_data(pd, offset, fd, tree); + return; + } + } +} + +#endif /* WITH_SNMP: CMU or UCD */ diff -urN ethereal/packet-udp.c ethereal-new/packet-udp.c --- ethereal/packet-udp.c Fri Apr 30 11:14:54 1999 +++ ethereal-new/packet-udp.c Tue Apr 27 16:59:56 1999 @@ -61,6 +61,7 @@ #define UDP_PORT_IPX 213 #define UDP_PORT_NBNS 137 #define UDP_PORT_NBDGM 138 +#define UDP_PORT_SNMP 161 #define UDP_PORT_RIP 520 #define UDP_PORT_VINES 573 @@ -218,6 +219,9 @@ break; case UDP_PORT_IPX: /* RFC 1234 */ dissect_ipx(pd, offset, fd, tree); + break; + case UDP_PORT_SNMP: + dissect_snmp(pd, offset, fd, tree); break; case UDP_PORT_VINES: /* FIXME: AFAIK, src and dst port must be the same */ diff -urN ethereal/packet.h ethereal-new/packet.h --- ethereal/packet.h Fri Apr 30 11:14:56 1999 +++ ethereal-new/packet.h Fri Apr 30 08:29:24 1999 @@ -223,6 +223,7 @@ ETT_TELNET, ETT_TELNET_SUBOPT, ETT_NNTP, + ETT_SNMP, ETT_NBSS, ETT_NBSS_FLAGS, NUM_TREE_TYPES /* last item number plus one */
- Prev by Date: Re: [ethereal-dev] Can someone post the location of the latest sources?
- Next by Date: [ethereal-dev] OOPS: update to real-time-display patch
- Previous by thread: Re: [ethereal-dev] Can someone post the location of the latest sources?
- Next by thread: [ethereal-dev] OOPS: update to real-time-display patch
- Index(es):