Can libsmi give me the name from OID?

Hi,
I tried looking at the documentation and searching the mailing list but could not find the answer to this question: Is it possible to use libsmi to get the name and description from an OID (which is defined in a MIB that is present in the MIB search path)?
I tried this code:
SmiNode *smiNode = ::smiGetNodeByOID(oidLen, oidArr);
with oidArr = {1,3,6,1,2,1,1,3} and oidLen = 8,
but smiNode->description is NULL and ->name is "iso". I expected name to be "sysUpTime" and description to be "The time (in hundredths of a second) since the network management portion of the system was last re-initialized." (see http://www.alvestrand.no/objectid/1.3.6.1.2.1.1.3.html)
The ->oid member is simply {1}. Shouldn't it be {1,3,6,1,2,1,1,3}?
Initializations is done like this:
smiInit(NULL); char* pc = smiGetPath(); // For verification.
where pc is a list of directories where I have my MIBs.
Thanks for any suggestions you might have. I am running on Win2k and libsmi-0.3.1. I had to modify dump-scli.c to make it compile, since msvc 6 does not have regexp.h.
Thanks, Henrik

Henrik Nordberg writes:
Henrik> I tried looking at the documentation and searching the mailing Henrik> list but could not find the answer to this question: Is it Henrik> possible to use libsmi to get the name and description from an Henrik> OID (which is defined in a MIB that is present in the MIB Henrik> search path)?
You have to load the module first. Here is some example code:
#include <stdio.h> #include <smi.h>
int main() { int oid[] = {1,3,6,1,2,1,1,3}; SmiNode *smiNode;
smiInit(NULL); smiLoadModule("SNMPv2-MIB"); smiNode = smiGetNodeByOID(sizeof(oid)/sizeof(int), oid); if (smiNode && smiNode->name) { printf("%s\n", smiNode->name); }
smiExit(); return 0; }
Note that you can use the ~/.smirc file to preload modules in case you want to load many modules all the time.
Henrik> Thanks for any suggestions you might have. I am running on Henrik> Win2k and libsmi-0.3.1. I had to modify dump-scli.c to make it Henrik> compile, since msvc 6 does not have regexp.h.
There is already a patch for this regex problem in the CVS. Rather than adding a complete regex implementation to libsmi, we decided to just disable this option on boxes that lack regex.h.
/js
participants (2)
-
Henrik Nordberg
-
Juergen Schoenwaelder