
Hi!
sndtrn4> I'm having a problem finding a node by the oid. After loading sndtrn4> the mib, I'm using the following code segment:
sndtrn4> scanf("%s", strNode); sndtrn4> node = smiGetNode(NULL, strNode); sndtrn4> child = smiGetNodeByOID(node->oidlen, node->oid); sndtrn4> if (node) sndtrn4> { sndtrn4> printf("Node name: %s\n", node->name); sndtrn4> } sndtrn4> else sndtrn4> { sndtrn4> printf("Node not found"); sndtrn4> }
This code segment dereferences node in the third line, even if smiGetNode() failed and returned NULL. Furthermore, you never make use of child, although your question is about node retrieval by OID. -- I'm a bit confused.
sndtrn4> With the input "enterprises", I'm getting the output "ccitt", sndtrn4> which isn't even there in my mib (SNMPv2-SMI).
I cannot reconstruct a case where smiGetNode(NULL, "enterprises") returns the ccitt toplevel node.
The fact, that libsmi can return nodes that are not defined in the modules that you have explicitly loaded, is absolutely correct, since all modules from which your module imports any items are loaded implicitly. Furthermore, note that SNMPv2-SMI is NOT a usual MIB module. Ususally, there is no reason to load it explicitly.
sndtrn4> With a mib sndtrn4> loaded that imports this one, I can get correct output till sndtrn4> the level of "enterprises", but below this I get the result sndtrn4> "enterprises" for all inputs. I have verified that the node sndtrn4> is being found correctly in the first call smiGetNode().
This works fine for me, e.g.:
#include <smi.h>
main(int argc, char *argv[]) { SmiNode *node, *node2; char s[65];
smiInit(NULL); smiLoadModule("TUBS-IBR-LINUX-MIB"); node = smiGetNode(NULL, argv[1]);
if (node) { printf("found by name: %s\n", node->name);
node2 = smiGetNodeByOID(node->oidlen, node->oid); if (node2) printf("found by OID: %s\n", node2->name); else printf("not found by OID\n"); } else { printf("not found by name\n"); } }
$ ./test linuxMIB found by name: linuxMIB found by OID: linuxMIB
Maybe, your enterprise module is syntactically not valid. Please check it first with smilint. Only if it contains no severe errors you can expect libsmi to return correct data.
-frank -- !! This message is brought to you via the `libsmi' mailing list. !! Please do not reply to this message to unsubscribe. To subscribe or !! unsubscribe, send a mail message to libsmi-request@ibr.cs.tu-bs.de. !! See http://www.ibr.cs.tu-bs.de/projects/libsmi/ for more information.