MFD:ifXTable:mib2c
MFD Tutorial | |
Running mib2c
The first step is to generate the code. Create a new directory somewhere and run:
$ mib2c -c mfd-top.m2c ifXTable writing to ifXTable.h | +-> Processing table ifXTable writing to - There are no defaults for ifXTable. Would you like to 1) Accept hard-coded defaults [DEFAULT] 2) Set defaults now Select your choice : 2 |
Notes: | ||
This table has writable columns. Do you want to generate code for writeable columns, or restrict the table to read-only? 1) generate code with writeable columns [DEFAULT] 2) generate code with read-only columns Select your choice : [RETURN] |
Notes: | ||
Writable tables sometimes have dependencies beteen columns or with other tables. If there are no dependencies in this table, you might want the extra code. 1) do not generate dependency code [DEFAULT] 2) generate dependency code Select your choice : [RETURN] |
Notes: | ||
Do you want to use an existing data structure for the USER context? 1) No, use netsnmp_data_list * [DEFAULT] 2) Yes, use my own structure Select your choice : [RETURN] |
Notes: | ||
Do you want to use an existing data structure for the DATA context? 1) No, use generated [DEFAULT] 2) Yes, use my own structure Select your choice : 2 Enter your DATA context : netsnmp_interface_entry |
Notes: | ||
Do you want to allocate your 'netsnmp_interface_entry', or embed it directly? 1) directly embed structure [DEFAULT] 2) dynamically allocate structure Select your choice : 2 |
Notes: | ||
Do you need to initialize elements in your 'netsnmp_interface_entry' when a new instance is created? 1) no, no initialization needed [DEFAULT] 2) yes, initilization is needed Select your choice : [RETURN] |
Notes: | ||
Which method would you like to use to gather data about available rows? 1) container-cached : [DEFAULT] This access method uses a netsnmp_container to keep track of the indexes (and data, usually) for each row. Thi method is best for: - Internal data (maintained by the agent) - External data (maintained by another process) which can be cached (minumum cache time is 1 second) 2) unsorted-external : This access method iterates over all of your data to find the row with the appropriate index. This method is best for - External data that cannot be cached. Select your choice : [RETURN] |
Notes: | ||
When accessing your data, is your data TRANSIENT? 1) Yes. My data is TRANSIENT (e.g. a pointer to a static buffer that my be overwritten during a request) and needs to be copied during processing. 2) Yes. My data is SEMI-TRANSIENT (e.g. an allocated pointer to a copy of the data). 3) No, my data is PERSISTENT (e.g. an allocated pointer to the actual data, which is under the agent's control) Select your choice [DEFAULT=1] : 2 |
Notes: | ||
Do you want example code to be generated? 1) generate example code [DEFAULT] 2) do not generate example code Select your choice : 2 |
Notes: |
As before, when finished, you should have several files:
- ifXTable.c
- ifXTable_data_access.c
- ifXTable_data_access.h
- ifXTable_data_get.c
- ifXTable_data_get.h
- ifXTable_data_set.c
- ifXTable_data_set.h
- ifXTable_enums.h
- ifXTable.h
- ifXTable_interface.c
- ifXTable_interface.h
- ifXTable_Makefile
- ifXTable_oids.h
- ifXTable-README-FIRST.txt
- ifXTable-README-ifXTable.txt
- ifXTable_subagent.c
You should read ifXTable-README-FIRST.txt for a basic overview of MFD. The basic steps outlined in ifXTable-README-ifXTable.txt were used to write this tutorial.