MFD:ifTable:mib2c - fenner/net-snmp-wiki-experiment GitHub Wiki
Running mib2c: Generating the template code
The first step is to generate the code. First, create a new directory
for the code. For this tutorial, e will assume you have a directory
named ifTable. You have two options to generate the code. One is
mib2c, and the other is
mib2c-update. If you are simply walking
through the the tutorial as a learning experience, run mib2c directly.
If you are just using the tutorial as a guide for generating your own
code, I recommend using the mib2c-update script, so you can take
advantage enhancements or bug-fixes in future releases. See the
mib2c-update page for more details.
For the tutorial, we will use mib2c directly.
$ mib2c -c mib2c.mfd.conf ifTablewriting to ifTable.h| +-> Processing table ifTablewriting to -writing to default-table-ifTable.m2dwriting to ifTable.cwriting to ifTable_data_get.hwriting to ifTable_data_get.c| | +-> Processing nonindex ifDescr| | +-> Processing nonindex ifType| | +-> Processing nonindex ifMtu| | +-> Processing nonindex ifSpeed| | +-> Processing nonindex ifPhysAddress| | +-> Processing nonindex ifAdminStatus| | +-> Processing nonindex ifOperStatus| | +-> Processing nonindex ifLastChange| | +-> Processing nonindex ifInOctets| | +-> Processing nonindex ifInUcastPkts| | +-> Processing nonindex ifInNUcastPkts| | +-> Processing nonindex ifInDiscards| | +-> Processing nonindex ifInErrors| | +-> Processing nonindex ifInUnknownProtos| | +-> Processing nonindex ifOutOctets| | +-> Processing nonindex ifOutUcastPkts| | +-> Processing nonindex ifOutNUcastPkts| | +-> Processing nonindex ifOutDiscards| | +-> Processing nonindex ifOutErrors| | +-> Processing nonindex ifOutQLen| | +-> Processing nonindex ifSpecificwriting to ifTable_data_set.hwriting to ifTable_data_set.c| | +-> Processing nonindex ifAdminStatuswriting to ifTable_oids.hwriting to ifTable_enums.hwriting to ifTable_interface.hwriting to ifTable_interface.cwriting to ifTable_data_access.hwriting to ifTable_data_access.cwriting to ifTable-README-FIRST.txtwriting to ifTable-README-ifTable.txtwriting to ifTable_doxygen.confrunning indent on ifTable_data_get.crunning indent on ifTable_data_get.hrunning indent on ifTable_interface.crunning indent on ifTable_interface.hrunning indent on ifTable_enums.hrunning indent on ifTable_oids.hrunning indent on ifTable_data_access.crunning indent on ifTable_data_set.crunning indent on ifTable_data_access.hrunning indent on ifTable.crunning indent on ifTable.hrunning indent on ifTable_data_set.h
$ mib2c -c mfd-makefile.m2m ifTablewriting to ifTable_Makefile/usr/share/snmp/mib2c-data/mfd-makefile.m2m:120 contained a line that started with a @ but did not match any mib2c configuration tokens.(maybe missing the trailing @?)/usr/share/snmp/mib2c-data/mfd-makefile.m2m:120 [ @set -e; $(CC) -M $(COPTS) $(CFLAGS) $(CPPFLAGS) $< \]
$ mib2c -c subagent.m2c ifTablewriting to ifTable_subagent.crunning indent on ifTable_subagent.c
When mib2c finishes, you should have several files. Here is a list, with
links to the complete source for this tutorial:
default-table-ifTable.m2d
ifTable-README-FIRST.txt
ifTable-README-ifTable.txt
ifTable.c
ifTable.h
ifTable_data_access.c
ifTable_data_access.h
ifTable_data_get.c
ifTable_data_get.h
ifTable_data_set.c
ifTable_data_set.h
ifTable_enums.h
ifTable_interface.c
ifTable_interface.h
ifTable_oids.h
ifTable_Makefile
ifTable_subagent.c
ifTable-README-FIRST.txt contains a basic overview of MFD, similar to
this tutorial. The basic steps outlined in ifTable-README-ifTable.txt
were used to write this tutorial.
Another new idea introduced with the MFD configuration files is user
settable variables to influence the code which is generated. The file
default-table-ifTable.m2d contains some of the values used when mib2
was run. (Note: this file is only generated if it does not already
exist. It is not updated during subsequent runs of mib2c.) For this
simple example, we are going to use all the defaults. In later
tutorials, we'll look more closely at these mib2c variables.