The following piece of C code shows a very simple program that uses libsmi to dump the identifiers and numerical OIDs of all subtree nodes under a given MIB node.
#include <stdio.h> #include <string.h> #include <smi.h> int main(int argc, char *argv[]) { SmiNode *smiNode; int oidlen, first = 1; if (argc != 2) { fprintf(stderr, "Usage: smisubtree oid\n"); exit(1); } smiInit("example"); for((smiNode = smiGetNode(NULL, argv[1])) && (oidlen = smiNode->oidlen); smiNode && (first || smiNode->oidlen > oidlen); smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_ANY), first = 0) { printf("%*s%-32s\n", (smiNode->oidlen - oidlen + 1) * 2, " ", smiNode->name); }; exit(0); }