

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.net-snmp.org/wiki/index.php?action=history&amp;feed=atom&amp;title=MFD%3AifTable%3AGet_Data</id>
		<title>MFD:ifTable:Get Data - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.net-snmp.org/wiki/index.php?action=history&amp;feed=atom&amp;title=MFD%3AifTable%3AGet_Data"/>
		<link rel="alternate" type="text/html" href="http://www.net-snmp.org/wiki/index.php?title=MFD:ifTable:Get_Data&amp;action=history"/>
		<updated>2026-05-04T21:20:23Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.3</generator>

	<entry>
		<id>http://www.net-snmp.org/wiki/index.php?title=MFD:ifTable:Get_Data&amp;diff=5162&amp;oldid=prev</id>
		<title>Wes: Created page with &quot;{{MFDTutorial}}  == MFD : ifTable data GET ==  Once the correct table context has been found, the individual node get routines will be called. These are generated in the file &#039;&#039;i...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.net-snmp.org/wiki/index.php?title=MFD:ifTable:Get_Data&amp;diff=5162&amp;oldid=prev"/>
				<updated>2011-07-13T17:42:56Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{MFDTutorial}}  == MFD : ifTable data GET ==  Once the correct table context has been found, the individual node get routines will be called. These are generated in the file &amp;#039;&amp;#039;i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{MFDTutorial}}&lt;br /&gt;
&lt;br /&gt;
== MFD : ifTable data GET ==&lt;br /&gt;
&lt;br /&gt;
Once the correct table context has been found, the individual node&lt;br /&gt;
get routines will be called. These are generated in the file&lt;br /&gt;
&amp;#039;&amp;#039;ifTable_data_get.c&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
Because we used the &amp;#039;&amp;#039;data context&amp;#039;&amp;#039; that is generated by&lt;br /&gt;
default, we populated the data in the data structure during&lt;br /&gt;
the data access phase and our MIB only has simple data types, &lt;br /&gt;
the code which was generated for the get routines does not need&lt;br /&gt;
much modification.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementing the get routines ===&lt;br /&gt;
&lt;br /&gt;
There is, however, a case where the data format specified by the&lt;br /&gt;
MIB does not match the data format we got from our datastore. The&lt;br /&gt;
&amp;#039;&amp;#039;ifType&amp;#039;&amp;#039; enumerations need to be mapped from the&lt;br /&gt;
Linux specific ARPHDR values. Here again, we haven&amp;#039;t tried to&lt;br /&gt;
provide a complete implementation, but enought to give you the&lt;br /&gt;
an overview.&lt;br /&gt;
&lt;br /&gt;
==== ifType mapping ====&lt;br /&gt;
&lt;br /&gt;
The PhysAddr ioctl call provides us with an ARPHRD type for&lt;br /&gt;
an interface. This type must be mapped to one of the valid&lt;br /&gt;
IANAifType enumerated values. The file &amp;#039;&amp;#039;ifTable_enums.h&amp;#039;&amp;#039;&lt;br /&gt;
contains macro definitions for all the allow values. It also&lt;br /&gt;
contains a list of the same macros prefixed with &amp;#039;INTERNAL_&amp;#039;. For&lt;br /&gt;
the case where there is a one to one mapping between a MIB type&lt;br /&gt;
and the implementation&amp;#039;s type, this provides a way to map&lt;br /&gt;
without having to update the code.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the ifType isn&amp;#039;t one of those cases. Only a&lt;br /&gt;
small subset of the possible values are available in our&lt;br /&gt;
implementation, and often there are several ARPHDR types that&lt;br /&gt;
map to a single IANAifType. The first step is to whittle down&lt;br /&gt;
the internal list to the ones with a direct mapping that we are&lt;br /&gt;
going to support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td bgcolor=CCCCCC&amp;gt;&lt;br /&gt;
 /*&lt;br /&gt;
 * TODO:&lt;br /&gt;
 * value mapping (see notes at top of file)&lt;br /&gt;
 */&amp;lt;font color=blue&amp;gt;&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_ETHERNETCSMACD  ARPHRD_ETHER&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_FDDI  ARPHRD_FDDI&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_PPP  ARPHRD_PPP&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_SOFTWARELOOPBACK  ARPHRD_LOOPBACK&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_SLIP  ARPHRD_SLIP&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_ARCNET  ARPHRD_ARCNET&lt;br /&gt;
 #ifdef ARPHRD_ATM&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_ATM  ARPHRD_ATM&lt;br /&gt;
 #endif&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_LOCALTALK  ARPHRD_LOCALTLK&lt;br /&gt;
 #ifdef ARPHRD_HIPPI&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_HIPPI  ARPHRD_HIPPI&lt;br /&gt;
 #endif&lt;br /&gt;
 #define INTERNAL_IANAIFTYPE_TUNNEL  ARPHRD_TUNNEL&amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we update the implementation to remove all the extras,&lt;br /&gt;
and use a default of &amp;#039;other&amp;#039; for any unknown types.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td bgcolor=CCCCCC&amp;gt;&lt;br /&gt;
 int&lt;br /&gt;
 ifType_map(u_long * mib_ifType_val_ptr, u_long raw_ifType_val)&lt;br /&gt;
 {&lt;br /&gt;
 netsnmp_assert(NULL != mib_ifType_val_ptr);&lt;br /&gt;
 &lt;br /&gt;
 DEBUGMSGTL((&amp;quot;verbose:ifType_map&amp;quot;, &amp;quot;called\n&amp;quot;));&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
 * TODO:&lt;br /&gt;
 * value mapping&lt;br /&gt;
 */&lt;br /&gt;
 /** TODO: update INTERNAL_* macros defined in the header */&lt;br /&gt;
 switch (raw_ifType_val) {&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_ETHERNETCSMACD:&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_ETHERNETCSMACD;&lt;br /&gt;
 break;&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_TUNNEL:&amp;lt;font color=blue&amp;gt;&lt;br /&gt;
 case ARPHRD_TUNNEL6:&lt;br /&gt;
 #ifdef ARPHRD_IPGRE&lt;br /&gt;
 case ARPHRD_IPGRE:&lt;br /&gt;
 #endif&lt;br /&gt;
 case ARPHRD_SIT:&amp;lt;/font&amp;gt;&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_TUNNEL;&lt;br /&gt;
 break;          /* tunnel */&amp;lt;font color=blue&amp;gt;&lt;br /&gt;
 case ARPHRD_CSLIP:&lt;br /&gt;
 case ARPHRD_SLIP6:&lt;br /&gt;
 case ARPHRD_CSLIP6:&amp;lt;/font&amp;gt;&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_SLIP:&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_SLIP;&lt;br /&gt;
 break;          /* slip */&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_PPP:&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_PPP;&lt;br /&gt;
 break;          /* ppp */&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_SOFTWARELOOPBACK:&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_SOFTWARELOOPBACK;&lt;br /&gt;
 break;          /* softwareLoopback */&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_FDDI:&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_FDDI;&lt;br /&gt;
 break;&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_ARCNET:&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_ARCNET;&lt;br /&gt;
 break;&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_LOCALTALK:&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_LOCALTALK;&lt;br /&gt;
 break;&amp;lt;font color=blue&amp;gt;&lt;br /&gt;
 #ifdef INTERNAL_IANAIFTYPE_HIPPI&amp;lt;/font&amp;gt;&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_HIPPI:&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_HIPPI;&lt;br /&gt;
 break;&amp;lt;font color=blue&amp;gt;&lt;br /&gt;
 #endif&lt;br /&gt;
 #ifdef INTERNAL_IANAIFTYPE_ATM&amp;lt;/font&amp;gt;&lt;br /&gt;
 case INTERNAL_IANAIFTYPE_ATM:&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_ATM;&lt;br /&gt;
 break;&amp;lt;font color=blue&amp;gt;&lt;br /&gt;
 #endif&lt;br /&gt;
 /*&lt;br /&gt;
 * XXX: more if_arp.h:ARPHDR_xxx to IANAifType mappings... &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
 default:&lt;br /&gt;
 snmp_log(LOG_ERR, &amp;quot;couldn&amp;#039;t map value %d for ifType\n&amp;quot;,&lt;br /&gt;
 raw_ifType_val);&lt;br /&gt;
 (*mib_ifType_val_ptr) = IANAIFTYPE_OTHER;&amp;lt;/font&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 return MFD_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Unimplemented columns ===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, we are leaving some colums unimplemented.&lt;br /&gt;
There are several reasons a column might be left unimplemnted.&lt;br /&gt;
The data may not be available, or a particular column might not&lt;br /&gt;
make sense for an implementation.&lt;br /&gt;
&lt;br /&gt;
We omitted some columns from the valid columns structure, because&lt;br /&gt;
we don&amp;#039;t want to provide data for those columns, ever. If you have&lt;br /&gt;
columns that might have data, depending on the row, then those&lt;br /&gt;
columns should be in the valid columns structure. When the column&lt;br /&gt;
get routine is called for a row which had not data for the column,&lt;br /&gt;
simply return &amp;#039;&amp;#039;MFD_SKIP&amp;#039;&amp;#039; from the object&amp;#039;s&lt;br /&gt;
get routine, and the agent will move on to the next object.&lt;br /&gt;
&lt;br /&gt;
You should also consult your MIB to see if, for a particular column&lt;br /&gt;
for which you don&amp;#039;t have data, a special value is specified which&lt;br /&gt;
should be returned when the data isn&amp;#039;t available. For example,&lt;br /&gt;
the ifPhysAddress object states:&lt;br /&gt;
&amp;#039;&amp;#039;For interfaces which do not have such an address (e.g., a serial&lt;br /&gt;
line), this object should contain an octet string of zero length.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==== Skipping ifMtu ====&lt;br /&gt;
&lt;br /&gt;
Even though we&amp;#039;ve eliminated some columns from the valid columns, here&lt;br /&gt;
is a simple example if skipping a column:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td bgcolor=CCCCCC&amp;gt;&lt;br /&gt;
 int&lt;br /&gt;
 ifMtu_get(ifTable_rowreq_ctx * rowreq_ctx, long *ifMtu_ptr)&lt;br /&gt;
 {&lt;br /&gt;
 /** we should have a non-NULL pointer */&lt;br /&gt;
 netsnmp_assert(NULL != ifMtu_ptr);&lt;br /&gt;
 &lt;br /&gt;
 netsnmp_assert(NULL != rowreq_ctx);&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
 * TODO:&lt;br /&gt;
 * set (* ifMtu_ptr ) from rowreq_ctx-&amp;gt;data.&lt;br /&gt;
 */&lt;br /&gt;
 /*&lt;br /&gt;
 * TODO:&lt;br /&gt;
 * update, replace or delete, if needed.&lt;br /&gt;
 */&amp;lt;font color=blue&amp;gt;&lt;br /&gt;
 if (rowreq_ctx-&amp;gt;data.ifMtu == 0)&lt;br /&gt;
 return MFD_SKIP;&lt;br /&gt;
 &amp;lt;/font&amp;gt;&lt;br /&gt;
 (*ifMtu_ptr) = rowreq_ctx-&amp;gt;data.ifMtu;&lt;br /&gt;
 &lt;br /&gt;
 return MFD_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wes</name></author>	</entry>

	</feed>