123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #include <netdissect-stdinc.h>
- #include "netdissect.h"
- #include <string.h>
- #include <stdio.h>
- #ifdef USE_LIBSMI
- #include <smi.h>
- #endif
- int
- nd_init(char *errbuf, size_t errbuf_size)
- {
- #ifdef _WIN32
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
-
- wVersionRequested = MAKEWORD(2, 2);
- err = WSAStartup(wVersionRequested, &wsaData);
- if (err != 0) {
- strlcpy(errbuf, "Attempting to initialize Winsock failed",
- errbuf_size);
- return (-1);
- }
- #endif
- #ifdef USE_LIBSMI
-
- smiInit("tcpdump");
- #endif
-
- strlcpy(errbuf, "", errbuf_size);
- return (0);
- }
- void
- nd_cleanup(void)
- {
- #ifdef USE_LIBSMI
-
- smiExit();
- #endif
- #ifdef _WIN32
-
- WSACleanup();
- #endif
- }
- int
- nd_have_smi_support(void)
- {
- #ifdef USE_LIBSMI
- return (1);
- #else
- return (0);
- #endif
- }
- 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
- }
|