Ethereal-users: [Ethereal-users] Re: updated net-snmp/ethereal patch

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Wes Hardaker <wjhns36@xxxxxxxxxxxxx>
Date: Wed, 23 Oct 2002 07:55:03 -0700
>>>>> On Tue, 22 Oct 2002 20:50:16 -0700, Wes Hardaker <wjhns36@xxxxxxxxxxxxx> said:

Guy> asn1.h - defines "subid_t" as a "gulong" if HAVE_UCD_SNMP is
Guy> defined and as a "guint" otherwise; does Net-SNMP define an OID
Guy> as a sequence of "unsigned long"s or as a sequence of "unsigned
Guy> int"s?

Ok, how's this for another wack at it.  Untested with ucd-snmp and on
windows, but should be ok (then again, I said that last time).  And
hopefully with glib.

-- 
Wes Hardaker
Network Associates Laboratories
? config.out
? ethereal-net-snmp.patch
? new-configure.patch
? testcpp
Index: acconfig.h
===================================================================
RCS file: /cvsroot/ethereal/acconfig.h,v
retrieving revision 1.26
diff -u -r1.26 acconfig.h
--- acconfig.h	2002/10/22 20:06:15	1.26
+++ acconfig.h	2002/10/23 14:53:12
@@ -49,3 +49,8 @@
 #undef HAVE_UCD_SNMP
 
 #undef PLUGIN_DIR
+
+@BOTTOM@
+#if defined(HAVE_NET_SNMP) || defined(HAVE_UCD_SNMP)
+#define HAVE_SOME_SNMP
+#endif
Index: asn1.h
===================================================================
RCS file: /cvsroot/ethereal/asn1.h,v
retrieving revision 1.10
diff -u -r1.10 asn1.h
--- asn1.h	2002/08/28 21:00:05	1.10
+++ asn1.h	2002/10/23 14:53:13
@@ -90,8 +90,8 @@
  * "config.h", to get the right #defines defined, so that we properly
  * typedef "subid_t".
  */
-#if defined(HAVE_UCD_SNMP)
-typedef gulong	subid_t;	/* UCD SNMP */
+#if defined(HAVE_SOME_SNMP)
+typedef gulong	subid_t;	/* Net-SNMP or UCD SNMP */
 #else
 typedef guint	subid_t;	/* CMU SNMP, libsmi, or nothing */
 #endif
Index: configure.in
===================================================================
RCS file: /cvsroot/ethereal/configure.in,v
retrieving revision 1.184
diff -u -r1.184 configure.in
--- configure.in	2002/10/23 03:54:04	1.184
+++ configure.in	2002/10/23 14:53:13
@@ -574,24 +574,33 @@
 		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)
+		NETSNMPCONFIG=$netsnmpconfig
+		if test ! -x $NETSNMPCONFIG ; then
+			AC_MSG_ERROR(Invalid net-snmp-config: $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
+if test "x$NETSNMPCONFIG" != "xno" -a "x$NETSNMPCONFIG" != "x" -a -x "$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))
+
+	AC_CHECK_HEADERS(net-snmp/net-snmp-config.h net-snmp/library/default_store.h)
+	if test "x$ac_cv_header_net_snmp_net_snmp_config_h" = "xyes" -a "x$ac_cv_header_net_snmp_library_default_store_h" = "xyes" ; then
+		CFLAGS="$CFLAGS `net-snmp-config --cflags`"
+		CPPFLAGS="$CPPLAGS `net-snmp-config --cflags`"
+		SNMP_LIBS=`net-snmp-config --libs`
+		AC_DEFINE(HAVE_NET_SNMP)
+		AC_MSG_RESULT(yes (net-snmp))
+	else
+		# technically, we should retry ucd-snmp but it's
+		# unlikely they have installed net-snmp-config and not
+		# the net-snmp headers but do have the ucd-snmp
+		# headers.  This would likely be a broken system to
+		# try and use anyway.
+		NETSNMPCONFIG="no"
+		AC_MSG_RESULT(no)
+	fi	
 else
 	if test "x$want_ucdsnmp" = "xno" ; then
 		AC_MSG_RESULT(no)
@@ -771,7 +780,7 @@
 	zlib_message="yes"
 fi
 
-if test "x$ac_cv_prog_NETSNMPCONFIG" != "xno" -a "x$ac_cv_prog_NETSNMPCONFIG" != "x" -a -x "$ac_cv_prog_NETSNMPCONFIG" ; then
+if test "x$NETSNMPCONFIG" != "xno" -a "x$NETSNMPCONFIG" != "x" -a -x "$NETSNMPCONFIG" ; then
 	snmp_libs_message="yes (net-snmp)"
 elif test "x$SNMP_LIBS" = "x" ; then
 	snmp_libs_message="no"
Index: packet-snmp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-snmp.c,v
retrieving revision 1.97
diff -u -r1.97 packet-snmp.c
--- packet-snmp.c	2002/10/22 20:06:15	1.97
+++ packet-snmp.c	2002/10/23 14:53:14
@@ -53,11 +53,10 @@
 #include "etypes.h"
 #include "packet-ipx.h"
 
-#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>
+# include <net-snmp/mib_api.h>
+# include <net-snmp/library/default_store.h>
 #else
 # include <ucd-snmp/ucd-snmp-config.h>
 # include <ucd-snmp/asn1.h>
@@ -73,6 +72,8 @@
 # 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
+
+#ifdef HAVE_SOME_SNMP
    /*
     * Define values "sprint_realloc_value()" expects.
     */
Index: tethereal.c
===================================================================
RCS file: /cvsroot/ethereal/tethereal.c,v
retrieving revision 1.162
diff -u -r1.162 tethereal.c
--- tethereal.c	2002/10/23 03:49:10	1.162
+++ tethereal.c	2002/10/23 14:53:15
@@ -314,7 +314,7 @@
 #ifdef WIN32
   WSADATA		wsaData;
 
-# ifdef HAVE_UCD_SNMP
+# ifdef HAVE_SOME_SNMP
   char                *mib_path;
 # define MIB_PATH_APPEND "\\snmp\\mibs"
 # endif	/* HAVE_UCD_SNMP */
@@ -433,16 +433,24 @@
   g_string_append(comp_info_str, ", without libz");
 #endif /* HAVE_LIBZ */
 
-/* Oh, this is pretty */
+/* Oh, this is pretty. */
+/* Oh, ha.  you think that was pretty.  Try this:! --Wes */
+#ifdef HAVE_SOME_SNMP
 #ifdef HAVE_UCD_SNMP
-  g_string_append(comp_info_str, ", with UCD SNMP ");
+  g_string_append(comp_info_str, ", with UCD-SNMP ");
 #ifdef HAVE_UCD_SNMP_VERSION_H
   g_string_append(comp_info_str, VersionInfo);
 #else /* HAVE_UCD_SNMP_VERSION_H */
   g_string_append(comp_info_str, "(version unknown)");
 #endif /* HAVE_UCD_SNMP_VERSION_H */
+#endif /* HAVE_UCD_SNMP */
+
+#ifdef HAVE_NET_SNMP
+  g_string_append(comp_info_str, ", with Net-SNMP ");
+  g_string_append(comp_info_str, netsnmp_get_version());
+#endif /* HAVE_NET_SNMP */
 #else /* no SNMP library */
-  g_string_append(comp_info_str, ", without UCD SNMP");
+  g_string_append(comp_info_str, ", without Net-SNMP");
 #endif
 
   /* Now get our args */
@@ -813,7 +821,7 @@
   /* Start windows sockets */
   WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
 
-# ifdef HAVE_UCD_SNMP
+# ifdef HAVE_SOME_SNMP
   /* Set MIBDIRS so that the SNMP library can find its mibs. */
   /* XXX - Should we set MIBS or MIBFILES as well? */