Difference between revisions of "MFD:ifTable:mib2c"

From Net-SNMP Wiki
Jump to: navigation, search
(Created page with "== Running mib2c == The first step is to generate the code. Create a new directory somewhere and run: <table><tr><td width=20></td><td><td bgcolor=CCCCCC> ...")
(No difference)

Revision as of 16:59, 13 July 2011

Running mib2c

The first step is to generate the code. Create a new directory somewhere and run:

</table> As before, when finished, you should have several files:
$ <font color=blue>mib2c -c mfd-top.m2c ifXTable</font>
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 : <font color=blue>2</font>

Notes:
Select '2', to change some of the defaults.


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 : <font color=blue>[RETURN]</font>

Notes:
We will be implementing set support.


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 : <font color=blue>[RETURN]</font>

Notes:
While the ifXTable is related to the ifTable, the two tables do not have any dependencies.


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 : <font color=blue>[RETURN]</font>

Notes:
We don't need to track anything at the table level, so we'll just accept the default.


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 : <font color=blue>2</font>
Enter your DATA context : <font color=blue>netsnmp_interface_entry</font>

Notes:
We'll be using the net-snmp access routines to get interface data, so we'll just use the netsnmp_interface_entry structure to keep that data.


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 : <font color=blue>2</font>

Notes:
The net-snmp access routines will provide us with allocated structures, so we'll just use those instead of copying them to an embeded structure.


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 : <font color=blue>[RETURN]</font>

Notes:
We'll be using the net-snmp data access routines to create the netsnmp_interface_entry structures, and those routines will take care of initialization for us.


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 : <font color=blue>[RETURN]</font>

Notes:
We are going to keep a cache and refresh it periodically.


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] : <font color=blue>2</font>

Notes:
We get a copy of the interface data via the netsnmp data access functions.


Do you want example code to be generated?

  1) generate example code [DEFAULT]
  2) do not generate example code

Select your choice : <font color=blue>2</font>

</pre><td> Notes:
We saw the example code in the last tutorial, so we'll skip it this time.

<a href="source/ifXTable.c">ifXTable.c</a>
<a href="source/ifXTable_data_access.c">ifXTable_data_access.c</a>
<a href="source/ifXTable_data_access.h">ifXTable_data_access.h</a>
<a href="source/ifXTable_data_get.c">ifXTable_data_get.c</a>
<a href="source/ifXTable_data_get.h">ifXTable_data_get.h</a>
<a href="source/ifXTable_data_set.c">ifXTable_data_set.c</a>
<a href="source/ifXTable_data_set.h">ifXTable_data_set.h</a>
<a href="source/ifXTable_enums.h">ifXTable_enums.h</a>
<a href="source/ifXTable.h">ifXTable.h</a>
<a href="source/ifXTable_interface.c">ifXTable_interface.c</a>
<a href="source/ifXTable_interface.h">ifXTable_interface.h</a>
<a href="source/ifXTable_Makefile">ifXTable_Makefile</a>
<a href="source/ifXTable_oids.h">ifXTable_oids.h</a>
<a href="source/ifXTable-README-FIRST.txt">ifXTable-README-FIRST.txt</a>
<a href="source/ifXTable-README-ifXTable.txt">ifXTable-README-ifXTable.txt</a>
<a href="source/ifXTable_subagent.c">ifXTable_subagent.c</a>

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.


   
     <a href="structures.html">Next: data structures</a>
     <a href="mib2c.html">Back: running mib2c</a> |
     <a href="../index.html">Up: IF-MIB Tutorials</a>