diff options
author | Jörg Mayer <jmayer@loplof.de> | 2002-10-22 20:06:15 +0000 |
---|---|---|
committer | Jörg Mayer <jmayer@loplof.de> | 2002-10-22 20:06:15 +0000 |
commit | 4c80b2ac3fbb12ba37ac93664b89642a8c09b359 (patch) | |
tree | 447197bef6c202f082c842b42cfc5fb14546d5bc | |
parent | 671ba8b6a6aa973004173b84d8bbd462ab0d878e (diff) | |
download | wireshark-4c80b2ac3fbb12ba37ac93664b89642a8c09b359.tar.gz wireshark-4c80b2ac3fbb12ba37ac93664b89642a8c09b359.tar.bz2 wireshark-4c80b2ac3fbb12ba37ac93664b89642a8c09b359.zip |
Wes Hardaker: Support NET-SNMP in addition to UCD-SNMP
svn path=/trunk/; revision=6475
-rw-r--r-- | AUTHORS | 3 | ||||
-rw-r--r-- | acconfig.h | 4 | ||||
-rw-r--r-- | configure.in | 49 | ||||
-rw-r--r-- | packet-snmp.c | 72 |
4 files changed, 90 insertions, 38 deletions
@@ -469,8 +469,9 @@ Phil Techau <phil_t[AT]altavista.net> { Additional NTP reference clock identifiers } -Wes Hardaker <wjhardaker[AT]ucdavis.edu> { +Wes Hardaker <hardaker[AT]users.sourceforge.net> { Kerberos 5 support + occasional ucd-snmp/net-snmp help. } Robert Tsai <rtsai[AT]netapp.com> { diff --git a/acconfig.h b/acconfig.h index 7a814c295c..a0c5bc74fa 100644 --- a/acconfig.h +++ b/acconfig.h @@ -1,7 +1,7 @@ /* acconfig.h * #ifdefs to be controlled by "configure" * - * $Id: acconfig.h,v 1.25 2002/08/28 21:00:05 jmayer Exp $ + * $Id: acconfig.h,v 1.26 2002/10/22 20:06:15 jmayer Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.org> @@ -44,6 +44,8 @@ #undef HAVE_LIBZ +#undef HAVE_NET_SNMP + #undef HAVE_UCD_SNMP #undef PLUGIN_DIR diff --git a/configure.in b/configure.in index e8cbf58016..cb5ab6a475 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -# $Id: configure.in,v 1.182 2002/10/09 22:58:49 jmayer Exp $ +# $Id: configure.in,v 1.183 2002/10/22 20:06:15 jmayer Exp $ dnl dnl Process this file with autoconf 2.13 or later to produce a dnl configure script; 2.12 doesn't generate a "configure" script that @@ -540,6 +540,11 @@ dnl UCD SNMP Check SNMP_LIBS='' AC_MSG_CHECKING(whether to use UCD SNMP/NET-SNMP library if available) +AC_ARG_WITH(net-snmp, +[ --with-net-snmp=PATH use PATH as thee location of the net-snmp-config shell script that comes with the net-snmp package.], +[netsnmpconfig=$withval] +) + AC_ARG_WITH(ucdsnmp, [ --with-ucdsnmp[=DIR] use UCD SNMP/NET-SNMP client library (located in directory DIR, if supplied). [default=yes, if present]], [ @@ -562,12 +567,40 @@ AC_ARG_WITH(ucdsnmp, ucdsnmp_dir= ]) -if test "x$want_ucdsnmp" = "xno" ; then - AC_MSG_RESULT(no) +dnl try net-snmp first +if test "x$netsnmpconfig" != "xno" ; then + dnl get the net-snmp-config binary + if test "x$netsnmpconfig" = "xyes" -o "x$netsnmpconfig" = "x" ; then + dnl search for it + AC_PATH_PROG(NETSNMPCONFIG,net-snmp-config) + else + ac_cv_prog_NETSNMPCONFIG=$netsnmpconfig + if test ! -x $ac_cv_prog_NETSNMPCONFIG ; then + AC_MSG_ERROR(Invalid net-snmp-config: $ac_cv_prog_NETSNMPCONFIG) + fi + fi +fi + +if test "x$ac_cv_prog_NETSNMPCONFIG" != "xno" -a "x$ac_cv_prog_NETSNMPCONFIG" != "x" -a -x "$ac_cv_prog_NETSNMPCONFIG" ; then + dnl other choices for flags to use here: could also use + dnl --prefix or --exec-prefix if you don't want the full list. + CFLAGS="$CFLAGS `net-snmp-config --cflags`" + CPPFLAGS="$CPPLAGS `net-snmp-config --cflags`" + SNMP_LIBS=`net-snmp-config --libs` + + # XXX: make sure we can find net-snmp/net-snmp-config.h + # XXX: make sure we can find net-snmp/net-snmp-includes.h + AC_DEFINE(HAVE_NET_SNMP) + AC_MSG_RESULT(yes (net-snmp)) else - AC_MSG_RESULT(yes) - AC_ETHEREAL_UCDSNMP_CHECK + if test "x$want_ucdsnmp" = "xno" ; then + AC_MSG_RESULT(no) + else + AC_MSG_RESULT(yes (ucd-snmp)) + AC_ETHEREAL_UCDSNMP_CHECK + fi fi + AC_SUBST(SNMP_LIBS) dnl Checks for typedefs, structures, and compiler characteristics. @@ -738,10 +771,12 @@ else zlib_message="yes" fi -if test "x$SNMP_LIBS" = "x" ; then +if test "x$ac_cv_prog_NETSNMPCONFIG" != "xno" -a "x$ac_cv_prog_NETSNMPCONFIG" != "x" -a -x "$ac_cv_prog_NETSNMPCONFIG" ; then + snmp_libs_message="yes (net-snmp)" +elif test "x$SNMP_LIBS" = "x" ; then snmp_libs_message="no" else - snmp_libs_message="yes" + snmp_libs_message="yes (ucd-snmp)" fi echo "" diff --git a/packet-snmp.c b/packet-snmp.c index 36de33e0e4..d9b1ea5029 100644 --- a/packet-snmp.c +++ b/packet-snmp.c @@ -6,9 +6,11 @@ * * See RFCs 1901, 1905, and 1906 for SNMPv2c. * - * See RFCs 1905, 1906, 1909, and 1910 for SNMPv2u. + * See RFCs 1905, 1906, 1909, and 1910 for SNMPv2u [historic]. * - * $Id: packet-snmp.c,v 1.96 2002/08/28 21:00:34 jmayer Exp $ + * See RFCs 2570-2576 for SNMPv3 + * + * $Id: packet-snmp.c,v 1.97 2002/10/22 20:06:15 jmayer Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -51,7 +53,12 @@ #include "etypes.h" #include "packet-ipx.h" -#ifdef HAVE_UCD_SNMP +#if defined(HAVE_UCD_SNMP) || defined(HAVE_NET_SNMP) +#define HAVE_SOME_SNMP +#ifdef HAVE_NET_SNMP +# include <net-snmp/net-snmp-config.h> +# include <net-snmp/net-snmp-includes.h> +#else # include <ucd-snmp/ucd-snmp-config.h> # include <ucd-snmp/asn1.h> # include <ucd-snmp/snmp_api.h> @@ -60,7 +67,12 @@ # include <ucd-snmp/default_store.h> # include <ucd-snmp/read_config.h> # include <ucd-snmp/tools.h> - +# define netsnmp_ds_set_boolean ds_set_boolean +# define netsnmp_ds_set_int ds_set_int +# define NETSNMP_DS_LIBRARY_ID DS_LIBRARY_ID +# define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS DS_LIB_NO_TOKEN_WARNINGS +# define NETSNMP_DS_LIB_PRINT_SUFFIX_ONLY DS_LIB_PRINT_SUFFIX_ONLY +#endif /* * Define values "sprint_realloc_value()" expects. */ @@ -441,7 +453,7 @@ format_oid(subid_t *oid, guint oid_length) int len; unsigned int i; char *buf; -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP guchar *oid_string; size_t oid_string_len; size_t oid_out_len; @@ -449,7 +461,7 @@ format_oid(subid_t *oid, guint oid_length) result_len = oid_length * 22; -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP /* * Get the decoded form of the OID, and add its length to the * length of the result string. @@ -474,7 +486,7 @@ format_oid(subid_t *oid, guint oid_length) buf += len; } -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP /* * Append the decoded form of the OID. */ @@ -485,7 +497,7 @@ format_oid(subid_t *oid, guint oid_length) return result; } -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP static guchar * check_var_length(guint vb_length, guint required_length) { @@ -598,12 +610,12 @@ format_var(struct variable_list *variable, subid_t *variable_oid, static int snmp_variable_decode(proto_tree *snmp_tree, subid_t *variable_oid -#ifndef HAVE_UCD_SNMP +#ifndef HAVE_SOME_SNMP _U_ #endif , guint variable_oid_length -#ifndef HAVE_UCD_SNMP +#ifndef HAVE_SOME_SNMP _U_ #endif , @@ -628,14 +640,14 @@ snmp_variable_decode(proto_tree *snmp_tree, gchar *vb_display_string; -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP struct variable_list variable; long value; -#else /* HAVE_UCD_SNMP */ +#else /* HAVE_SOME_SNMP */ unsigned int i; gchar *buf; int len; -#endif /* HAVE_UCD_SNMP */ +#endif /* HAVE_SOME_SNMP */ /* parse the type of the object */ start = asn1->offset; @@ -666,7 +678,7 @@ snmp_variable_decode(proto_tree *snmp_tree, return ret; length = asn1->offset - start; if (snmp_tree) { -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP value = vb_integer_value; variable.val.integer = &value; vb_display_string = format_var(&variable, @@ -676,12 +688,12 @@ snmp_variable_decode(proto_tree *snmp_tree, length, "Value: %s", vb_display_string); free(vb_display_string); -#else /* HAVE_UCD_SNMP */ +#else /* HAVE_SOME_SNMP */ proto_tree_add_text(snmp_tree, asn1->tvb, offset, length, "Value: %s: %d (%#x)", vb_type_name, vb_integer_value, vb_integer_value); -#endif /* HAVE_UCD_SNMP */ +#endif /* HAVE_SOME_SNMP */ } break; @@ -694,7 +706,7 @@ snmp_variable_decode(proto_tree *snmp_tree, return ret; length = asn1->offset - start; if (snmp_tree) { -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP value = vb_uinteger_value; variable.val.integer = &value; vb_display_string = format_var(&variable, @@ -704,12 +716,12 @@ snmp_variable_decode(proto_tree *snmp_tree, length, "Value: %s", vb_display_string); free(vb_display_string); -#else /* HAVE_UCD_SNMP */ +#else /* HAVE_SOME_SNMP */ proto_tree_add_text(snmp_tree, asn1->tvb, offset, length, "Value: %s: %u (%#x)", vb_type_name, vb_uinteger_value, vb_uinteger_value); -#endif /* HAVE_UCD_SNMP */ +#endif /* HAVE_SOME_SNMP */ } break; @@ -725,7 +737,7 @@ snmp_variable_decode(proto_tree *snmp_tree, return ret; length = asn1->offset - start; if (snmp_tree) { -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP variable.val.string = vb_octet_string; vb_display_string = format_var(&variable, variable_oid, variable_oid_length, vb_type, @@ -734,7 +746,7 @@ snmp_variable_decode(proto_tree *snmp_tree, length, "Value: %s", vb_display_string); free(vb_display_string); -#else /* HAVE_UCD_SNMP */ +#else /* HAVE_SOME_SNMP */ /* * If some characters are not printable, display * the string as bytes. @@ -771,7 +783,7 @@ snmp_variable_decode(proto_tree *snmp_tree, (int)vb_length, SAFE_STRING(vb_octet_string)); } -#endif /* HAVE_UCD_SNMP */ +#endif /* HAVE_SOME_SNMP */ } g_free(vb_octet_string); break; @@ -794,7 +806,7 @@ snmp_variable_decode(proto_tree *snmp_tree, return ret; length = asn1->offset - start; if (snmp_tree) { -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP variable.val.objid = vb_oid; vb_display_string = format_var(&variable, variable_oid, variable_oid_length, vb_type, @@ -803,13 +815,13 @@ snmp_variable_decode(proto_tree *snmp_tree, length, "Value: %s", vb_display_string); free(vb_display_string); -#else /* HAVE_UCD_SNMP */ +#else /* HAVE_SOME_SNMP */ vb_display_string = format_oid(vb_oid, vb_oid_length); proto_tree_add_text(snmp_tree, asn1->tvb, offset, length, "Value: %s: %s", vb_type_name, vb_display_string); g_free(vb_display_string); -#endif /* HAVE_UCD_SNMP */ +#endif /* HAVE_SOME_SNMP */ } g_free(vb_oid); break; @@ -2013,7 +2025,7 @@ proto_register_snmp(void) &ett_secur, }; -#ifdef HAVE_UCD_SNMP +#ifdef HAVE_SOME_SNMP /* * Suppress warnings about unknown tokens - we aren't initializing * UCD SNMP in its entirety, we're just initializing the @@ -2022,13 +2034,15 @@ proto_register_snmp(void) * pars of the library will not be handled, and we don't want * the config file reading code to whine about that. */ - ds_set_boolean(DS_LIBRARY_ID, DS_LIB_NO_TOKEN_WARNINGS, TRUE); - ds_set_int(DS_LIBRARY_ID, DS_LIB_PRINT_SUFFIX_ONLY, 2); + netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, + NETSNMP_DS_LIB_NO_TOKEN_WARNINGS, TRUE); + netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, + NETSNMP_DS_LIB_PRINT_SUFFIX_ONLY, 2); register_mib_handlers(); read_premib_configs(); init_mib(); read_configs(); -#endif /* HAVE_UCD_SNMP */ +#endif /* HAVE_SOME_SNMP */ proto_snmp = proto_register_protocol("Simple Network Management Protocol", "SNMP", "snmp"); proto_smux = proto_register_protocol("SNMP Multiplex Protocol", |