get libsmi into the picture
authorlego <lego@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 25 Aug 2007 20:27:58 +0000 (20:27 +0000)
committerlego <lego@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 25 Aug 2007 20:27:58 +0000 (20:27 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@22661 f5534014-38df-0310-8fa8-9805f1628bb7

aclocal-fallback/libsmi.m4 [new file with mode: 0644]
configure.in
epan/oids.c

diff --git a/aclocal-fallback/libsmi.m4 b/aclocal-fallback/libsmi.m4
new file mode 100644 (file)
index 0000000..29ce719
--- /dev/null
@@ -0,0 +1,38 @@
+# Configure paths for libsmi.
+
+dnl AM_PATH_LIBSMI()
+dnl Test for libsmi and defines the symbol LIBSMI if the test is
+dnl successful. Also defines HAVE_LIBSMI_H and adds -llibsmi to the 
+dnl LIBS variable.
+dnl 
+AC_DEFUN([AM_PATH_LIBSMI],
+[
+  AC_CHECK_HEADERS(smi.h)
+  AC_CHECK_LIB(smi, smiInit)
+  AC_MSG_CHECKING([whether to enable libsmi])
+  AC_TRY_RUN([ /* libsmi available check */
+#include <smi.h>
+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", &current, &revision, &age);
+  if (n != 3)
+    exit(3);
+  if (required < current - age || required > current)
+    exit(4);
+  exit(0);
+}
+],
+  [ AC_MSG_RESULT(yes)
+    libsmi=yes],
+  [ AC_MSG_RESULT(no)
+    libsmi=no],
+  [ AC_MSG_RESULT(not when cross-compiling)
+    libsmi=no]
+  )
+])
index 9d8aee5a9382f59115c9d64ad1ae707894c72424..160c90906834e92908c2ef5d22d8a7707b0c324e 100644 (file)
@@ -116,13 +116,24 @@ if test "x$with_gcrypt" = "xyes"; then
                 if test x$libgcrypt_config_prefix != x ; then
                        AC_MSG_ERROR([[libgcrypt not found; install libgcrypt-devel package for your system]])
                 else
-                        echo echo "libgcrypt not found, disabling ipsec decryption"
+                        echo "libgcrypt not found, disabling ipsec decryption"
                         gcrypt_message="no"
                 fi
         ]
   )
 fi
 
+# libsmi
+libsmi_message="no"
+AC_ARG_WITH([libsmi],
+  AC_HELP_STRING( [--with-libsmi=@<:@yes/no@:>@],
+                 [use smi library @<:@default=yes@:>@]),
+  with_libsmi="$withval", with_libsmi="yes")
+if test "x$with_libsmi" = "xyes"; then
+  AM_PATH_LIBSMI
+  AM_CONDITIONAL(HAVE_SMI, "x$with_libsmi" = "xyes")
+fi
+
 # Check for xsltproc
 AC_PATH_PROG(XSLTPROC, xsltproc)
 AC_CHECK_PROG(HAVE_XSLTPROC, xsltproc, "yes", "no")
@@ -1635,6 +1646,7 @@ echo "                   Use zlib library : $zlib_message"
 echo "                   Use pcre library : $pcre_message"
 echo "               Use kerberos library : $krb5_message"
 echo "               Use GNU ADNS library : $adns_message"
+echo "               Use SMI SNMP library : $libsmi"
 echo "             Use GNU crypto library : $gcrypt_message"
 echo "             Use SSL crypto library : $ssl_message"
 echo "           Use IPv6 name resolution : $enable_ipv6"
index baf32687cab0026c9f9a824fce2d2e08ee541fc1..8ae72b23b8daa25e1bb8673e645c2e03e76dbbb2 100644 (file)
@@ -41,7 +41,7 @@
 #include "filesystem.h"
 #include "dissectors/packet-ber.h"
 
-#ifdef HAVE_SMI
+#ifdef HAVE_LIBSMI
 #include <smi.h>
 #endif
 
@@ -175,7 +175,7 @@ extern void oid_add_from_encoded(const char* name, const guint8 *oid, gint oid_l
        }
 }
 
-#ifdef HAVE_SMI
+#ifdef HAVE_LIBSMI
 typedef struct smi_module_t {
        char* name;
 } smi_module_t;
@@ -374,15 +374,15 @@ static inline oid_kind_t smikind(SmiNode* sN, oid_key_t** key_p) {
                                        kl->key_type = typedata->keytype_implicit;
                                } else switch (kl->key_type) {
                                        case OID_KEY_TYPE_BYTES:
-                                               if (k->num_subids)
+                                               if (kl->num_subids)
                                                        kl->key_type = OID_KEY_TYPE_FIXED_BYTES;
                                                break;
                                        case OID_KEY_TYPE_STRING:
-                                               if (k->num_subids)
+                                               if (kl->num_subids)
                                                        kl->key_type = OID_KEY_TYPE_FIXED_STRING;
                                                break;
                                        default:
-                                               
+                                               break;
                                }
                        
                        }
@@ -404,6 +404,12 @@ static inline oid_kind_t smikind(SmiNode* sN, oid_key_t** key_p) {
                                                   || (ft == FT_INT8) || (ft == FT_INT16) || (ft == FT_INT24) || (ft == FT_INT32) \
                                                   || (ft == FT_UINT64) || (ft == FT_INT64) )
 
+#ifdef WIN32
+#define PATH_SEPARATOR ";"
+#else
+#define PATH_SEPARATOR ":"
+#endif
+
 void register_mibs(void) {
        SmiModule *smiModule;
     SmiNode *smiNode;
@@ -636,7 +642,7 @@ void register_mibs(void) {
 
 
 void oids_init(void) {
-#ifdef HAVE_SMI
+#ifdef HAVE_LIBSMI
        register_mibs();
 #else
        D(1,("libsmi disabled oid resolution not enabled"));