Logo
Home page Net-SNMP

Archive Search:

Require all words?

Site Search:
Google
MFD: Running mib2c

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 ifTable
writing to ifTable.h
| +-> Processing table ifTable
writing to -
writing to default-table-ifTable.m2d
writing to ifTable.c
writing to ifTable_data_get.h
writing 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 ifSpecific
writing to ifTable_data_set.h
writing to ifTable_data_set.c
| |   +-> Processing nonindex ifAdminStatus
writing to ifTable_oids.h
writing to ifTable_enums.h
writing to ifTable_interface.h
writing to ifTable_interface.c
writing to ifTable_data_access.h
writing to ifTable_data_access.c
writing to ifTable-README-FIRST.txt
writing to ifTable-README-ifTable.txt
writing to ifTable_doxygen.conf
running indent on ifTable_data_get.c
running indent on ifTable_data_get.h
running indent on ifTable_interface.c
running indent on ifTable_interface.h
running indent on ifTable_enums.h
running indent on ifTable_oids.h
running indent on ifTable_data_access.c
running indent on ifTable_data_set.c
running indent on ifTable_data_access.h
running indent on ifTable.c
running indent on ifTable.h
running indent on ifTable_data_set.h
 
$ mib2c -c mfd-makefile.m2m ifTable
writing 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 ifTable
writing to ifTable_subagent.c
running 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.

Next: data structures | Back: Introduction | Up: IF-MIB Tutorials
rstory at freesnmp dot com
Version $Revision$

Valid CSS!


Last modified: Wednesday, 01-Aug-2018 04:41:28 UTC
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.