diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-08-04 14:35:35 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-08-04 14:35:35 -0700 |
commit | 6080cff326699607f6435aa38270f4e76e54edff (patch) | |
tree | 79242151e713e34a7748fb1f83b262abe48b2cf5 /netdissect.c | |
parent | bab54e3e567a7a895c6e3afaf9494660cb41b827 (diff) | |
download | tcpdump-6080cff326699607f6435aa38270f4e76e54edff.tar.gz |
Move more libsmi stuff to netdissect.c.
Have the call to smiLoadModule() be in a nd_load_smi_module() routine.
Have it set a *global* flag indicating whether a module has been loaded;
that's not per-netdissect_options. Use that global flag in print-snmp.c
- and don't test it once per loop iteration, it's not going to change
while the loop is running.
Have a routine to return the version of the library if we're built with
it or NULL if we're not.
That removes the last of the code that tests USE_LIBSMI or uses libsmi
from tcpdump.c.
Diffstat (limited to 'netdissect.c')
-rw-r--r-- | netdissect.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/netdissect.c b/netdissect.c index 80b6e94d..0c7d661d 100644 --- a/netdissect.c +++ b/netdissect.c @@ -98,3 +98,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 +} |