]> The Tcpdump Group git mirrors - tcpdump/blobdiff - netdissect.c
CVE-2017-13040/MPTCP: Clean up printing DSS suboption.
[tcpdump] / netdissect.c
index 80b6e94dcab7f214ddb71db62ae9d306f4d33f51..0215c83b7f23ab3483e08d357f3ae7b19c4d7b38 100644 (file)
@@ -27,8 +27,9 @@
 #endif
 
 #include <netdissect-stdinc.h>
-
 #include "netdissect.h"
+#include <string.h>
+#include <stdio.h>
 
 #ifdef USE_LIBSMI
 #include <smi.h>
@@ -48,6 +49,7 @@ nd_init(char *errbuf, size_t errbuf_size)
 #ifdef _WIN32
        WORD wVersionRequested;
        WSADATA wsaData;
+       int err;
 
        /*
         * Request Winsock 2.2; we expect Winsock 2.
@@ -73,7 +75,7 @@ nd_init(char *errbuf, size_t errbuf_size)
         * Clears the error buffer, and uses it so we don't get
         * "unused argument" warnings at compile time.
         */
-       snprintf(errbuf, errbuf_size, "");
+       strlcpy(errbuf, "", errbuf_size);
        return (0);
 }
 
@@ -98,3 +100,47 @@ nd_cleanup(void)
        WSACleanup();
 #endif
 }
+
+int
+nd_have_smi_support(void)
+{
+#ifdef USE_LIBSMI
+       return (1);
+#else
+       return (0);
+#endif
+}
+
+/*
+ * Indicates whether an SMI module has been loaded, so that we can use
+ * libsmi to translate OIDs.
+ */
+int nd_smi_module_loaded;
+
+int
+nd_load_smi_module(const char *module, char *errbuf, size_t errbuf_size)
+{
+#ifdef USE_LIBSMI
+       if (smiLoadModule(module) == 0) {
+               snprintf(errbuf, errbuf_size, "could not load MIB module %s",
+                   module);
+               return (-1);
+       }
+       nd_smi_module_loaded = 1;
+       return (0);
+#else
+       snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support",
+           module);
+       return (-1);
+#endif
+}
+
+const char *
+nd_smi_version_string(void)
+{
+#ifdef USE_LIBSMI
+       return (smi_version_string);
+#else
+       return (NULL);
+#endif
+}