I have the following code to parse the mibs in a folder called mibp .
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <string.h>
#include<stdlib.h>
int main(int argc, char ** argv)
{
FILE *fp=NULL;
fp=fopen("/root/mib2.txt","w");
if (fp == NULL )
{
printf("error");;
exit(2);
}
netsnmp_init_mib();
add_mibdir("/home/pradipta/snmp/share/snmp/mibp");
//netsnmp_set_mib_directory( "/home/pradipta/snmp/share/snmp/mibp" );
struct tree *node;
//node=read_all_mibs();
node=read_mib("/home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt");
print_subtree(fp,node,0);
}
when I am running this I error as follows
MIB search path: /root/.snmp/mibs:/home/pradipta/snmp/share/snmp/mibs
Cannot find module (SNMPv2-MIB): At line 1 in (none)
Cannot find module (IF-MIB): At line 1 in (none)
Cannot find module (IP-MIB): At line 1 in (none)
Cannot find module (TCP-MIB): At line 1 in (none)
Cannot find module (UDP-MIB): At line 1 in (none)
Cannot find module (SNMP-VIEW-BASED-ACM-MIB): At line 1 in (none)
Cannot find module (SNMP-COMMUNITY-MIB): At line 1 in (none)
Cannot find module (SNMPv2-SMI): At line 6 in /home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt
Cannot find module (SNMPv2-TC): At line 10 in /home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt
Cannot find module (IF-MIB): At line 12 in /home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt
Did not find 'mib-2' in module #-1 (/home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt)
Did not find 'transmission' in module #-1 (/home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt)
Did not find 'TruthValue' in module #-1 (/home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt)
Did not find 'ifIndex' in module #-1 (/home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt)
Did not find 'InterfaceIndex' in module #-1 (/home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt)
Unlinked OID in EtherLike-MIB: etherMIB ::= { mib-2 35 }
Undefined identifier: mib-2 near line 14 of /home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt
Unlinked OID in EtherLike-MIB: dot3 ::= { transmission 7 }
Undefined identifier: transmission near line 118 of /home/pradipta/snmp/share/snmp/mibp/EtherLike-MIB.txt
I have changed the folder name mibs
to mibp
and added as above in the code to test for the changing of mib search path working or not.it is giving me this error why.
what is the use of netsnmp_init_mib();
Also tell me
- which function I will use to change the MIB searching directory.
- what is the use of the function
netsnmp_set_mib_directory()
. - IF i want to add one MIB then can it possible to give the path of that MIB only or it is mandatory to include this in the path where all the MIBs are present previously as I am getting error when doing like this.
- also what is the difference between
read_all_mibs() and read_mib()
;
Kindly tell me some idea.