
Juergen Schoenwaelder wrote:
Your program is not loading any MIB modules and hence the only thing libsmi knows are the root nodes of the OID tree and this is what smiGetNodeByOID() returns.
Hello,
Can you have a look at the example libsmi program on the libsmi(3) manpage? I think the confusion comes from there. For me, that example program returns only "iso" for variety of inputs.
I have added this to the example program:
--- a/example.c Thu Jun 04 13:40:03 2009 +0200 +++ b/example.c Thu Jun 04 14:27:13 2009 +0200 @@ -5,14 +5,20 @@ int main(int argc, char *argv[]) { SmiNode *smiNode; - int oidlen, first = 1; - + int i, oidlen, first = 1; + const char *modules[] = { + "SNMPv2-SMI", "SNMPv2-TC", "SNMPv2-CONF", + "SNMPv2-MIB", "IF-MIB", NULL}; + if (argc != 2) { fprintf(stderr, "Usage: smisubtree oid\n"); exit(1); }
smiInit(NULL); + for (i = 0; modules[i]; i++) + fprintf(stderr, "Loading module: %s\n", + smiLoadModule(modules[i]));
for((smiNode = smiGetNode(NULL, argv[1])) && (oidlen = smiNode->oidlen);
And now it seems to return something reasonable for the inputs like "internet", "org", "mib-2".
However it dumps core in smiGetNextNode() for "iso", "ccitt" and "joint-iso-ccitt" values.
The attached patch-rootedge fixed coredumps for some edge cases like above and "0", "." etc., although I have a feeling that results are not correct - the "iso" and root ("0") trees do not get expanded properly).
The proper fix might be a different initialization of the root nodes.