4.8.0.0R6
Software Development Kit
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
MIB Struct Reference

Data Fields

int(* index )(int varix, int tabix)
 
void(* init )(uint16_t type)
 
const MIBTABmtp
 
const MIBVARmvp
 
int(* numtabs )(void)
 
int(* numvars )(void)
 
int(* set )(int varix, int tabix)
 

Detailed Description

This struct is used to define SNMP access to a particular MIB.

The get(), set(), init(), and check() callback functions can be defined as NULL. The index() function must be defined if the MIB contains a table. Additionally the get() and/or set() should be defined if a MIB variable is defined using MIBOPT_CAR and/or MIB_OPT_CAW.

When a MIB variable is defined with MIBOPT_CAR the get() function is called when an SNMP GET operation is performed on the variable.

void (*get)(int varix, int tabix, uint8_t ** vvptr);

Parameters
varix(in) current 'MIBVAR' index
tabix(in) current data storage table/struct index
vvptr(out) store value here
Return values
voidWhen a MIB variable is defined with MIBOPT_CAW the set() function is called when an SNMP Set operation is performed on the variable. The data value to be set is first written to the area specified by 'ptr' in the variable MIBVAR definition. The set() function is used to performed post processing on the data value (i.e. copy the data elsewhere and/or trigger some event). If your MIB Handler contains a table and you use the index() function then you should use set(). Likewise if you use the index2() function then you should use set2(). The table index/data passed to the set2() function is that returned by a previous call to your index2() function.

int (*set)(int varix, int tabix);

Parameters
varix(in) current 'MIBVAR' index
tabix(in) current data storage table/struct index
Return values
intan SNMP_RV code

int (*set2)(int varix, const uint8_t * pIndex, uint32_t indexLen, void * pData);

Parameters
varix(in) current 'MIBVAR' index
pIndex(in) encoded OID Table index
indexLen(in) length of the encoded OID Table index
pData(in) data being set (encoded)
Return values
intan SNMP_RV code

If the MIB contains a table then an index() function must be implemented.

The basic index() function is used by the agent to determine what table indexes (tabix) are valid. Using this routine is very inefficient. The agent will call your index() routine for every entry in your table until you return -1. After every call to your index() function, assuming the function returns 1, the agent will then call your get() routine to get the actual table index for that tabix. It will then do some lexicographic OID compares and keep track of the best match (for SNMP GetNext operations). If your table data is unorganized by SNMP standards then implementing this function makes things easy at a cost of bad performance.

int (*index)(int varix, int tabix);

Parameters
varix(in) current 'MIBVAR' index
tabix(in) current data storage table/struct index
Return values
-1end of table reached
0skip entry
1valid entry

This index2() function is a more traditional MIB Handler index function in that the entire requested table index is passed to the function and there are variables used to return the resulting index/value for the SNMP operation back to the agent. Note that the passed in index is the exact data from the SNMP message. The index is BER encoded so you must handle any single index values that are potentially greater than

  1. If you don't then you most likely will break lexicographic ordering or the table data. For example the BER format of an integer can result in the first (most sig) bit being set and make a small number look larger than a larger num. For example 30718 encodes to 0x81 0xef 0x7e and 10001 encodes to 0xce 0x11. If a basic byte comparison is made then 10001 will be considered larger than 30718 which is lexicraphically incorrect. You can safely assume the pointers returned are reentrant-safe since there is only a single SNMP Agent processing requests. If you implement this then you don't need to support the get() function for getting table data since you return the get data from this function directly.

int (*index2)(int varix, SnmpOperationType oflag, const uint8_t * index, uint32_t indexLen, const uint8_t * resCharIndex, uint32_t * resIndexLen, void ** retValue);

Parameters
varix(in) current 'MIBVAR' index
oflag(in) type of SNMP operation
index(in) encoded OID Table index
indexLen(in) length of the encoded OID Table index
resIndex(out) resulting encoded OID Table index
resIndexLen(out) length of the resulting encoded OID Table index
retValue(out) data for resulting OID Table index (get/set)
Return values
-1end of table reached or error (i.e. invalid index)
0valid entry (results in resIndex, resIndexLen, retValue)

An initialization function that is called when the MIB is registered with the SNMP Agent.

int (*init)(uint16_t type);

Parameters
type(in) always 0
Return values
voidThis routine is called to check the validity of a value before it is set via an SNMP SET operation. If your MIB Handler contains a table and you use the index() function then you should use check(). Likewise if you use the index2() function then you should use check2(). The table index passed to the check2() function is that returned by a previous call to your index2() function.

int (*check)(int varix, int tabix, const uint8_t * inp);

Parameters
varix(in) current 'MIBVAR' index
tabix(in) current data storage table/struct index
inp(in) pointer to the BER encoded value to be set
Return values
intan SNMP_RV code

int (*check2)(int varix, const uint8_t * pIndex, uint32_t indexLen, const uint8_t * inp);

Parameters
varix(in) current 'MIBVAR' index
index(in) encoded OID Table index
indexLen(in) length of the encoded OID Table index
inp(in) pointer to the BER encoded value to be set
Return values
intan SNMP_RV code

Field Documentation

int(* MIB::index)(int varix, int tabix)

index cbk

void(* MIB::init)(uint16_t type)

init cbk

const MIBTAB* MIB::mtp

array of MIB tables

const MIBVAR* MIB::mvp

array of MIB variables

int(* MIB::numtabs)(void)

function to return the number of tables

int(* MIB::numvars)(void)

function to return the number of variables

int(* MIB::set)(int varix, int tabix)

set cbk


The documentation for this struct was generated from the following file: