X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/bab54e3e567a7a895c6e3afaf9494660cb41b827..0f328b4aa16b0b47f05a85c440ce1d07719e3cac:/netdissect.c diff --git a/netdissect.c b/netdissect.c index 80b6e94d..0215c83b 100644 --- a/netdissect.c +++ b/netdissect.c @@ -27,8 +27,9 @@ #endif #include - #include "netdissect.h" +#include +#include #ifdef USE_LIBSMI #include @@ -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 +}