2 * Copyright (c) 1988-1997
3 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1998-2012 Michael Richardson <mcr@tcpdump.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that: (1) source code distributions
10 * retain the above copyright notice and this paragraph in its entirety, (2)
11 * distributions including binary code include the above copyright notice and
12 * this paragraph in its entirety in the documentation or other materials
13 * provided with the distribution, and (3) all advertising materials mentioning
14 * features or use of this software display the following acknowledgement:
15 * ``This product includes software developed by the University of California,
16 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
17 * the University nor the names of its contributors may be used to endorse
18 * or promote products derived from this software without specific prior
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
21 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 #include <netdissect-stdinc.h>
30 #include "netdissect.h"
39 * Initialize anything that must be initialized before dissecting
42 * This should be called at the beginning of the program; it does
43 * not need to be called, and should not be called, for every
44 * netdissect_options structure.
47 nd_init(char *errbuf, size_t errbuf_size)
50 WORD wVersionRequested;
55 * Request Winsock 2.2; we expect Winsock 2.
57 wVersionRequested = MAKEWORD(2, 2);
58 err = WSAStartup(wVersionRequested, &wsaData);
60 strlcpy(errbuf, "Attempting to initialize Winsock failed",
68 * XXX - should we just fail if this fails? Some of the
69 * libsmi calls may fail.
75 * Clears the error buffer, and uses it so we don't get
76 * "unused argument" warnings at compile time.
78 strlcpy(errbuf, "", errbuf_size);
83 * Clean up anything that ndo_init() did.
90 * This appears, in libsmi 0.4.8, to do nothing if smiInit()
91 * wasn't done or failed, so we call it unconditionally.
98 * Undo the WSAStartup() call above.
105 nd_have_smi_support(void)
115 * Indicates whether an SMI module has been loaded, so that we can use
116 * libsmi to translate OIDs.
118 int nd_smi_module_loaded;
121 nd_load_smi_module(const char *module, char *errbuf, size_t errbuf_size)
124 if (smiLoadModule(module) == 0) {
125 snprintf(errbuf, errbuf_size, "could not load MIB module %s",
129 nd_smi_module_loaded = 1;
132 snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support",
139 nd_smi_version_string(void)
142 return (smi_version_string);