VxWorks Reference Manual : Libraries
m2IfLib - MIB-II interface-group API for SNMP agents
m2IfInit( ) - initialize MIB-II interface-group routines
m2IfGroupInfoGet( ) - get the MIB-II interface-group scalar variables
m2IfTblEntryGet( ) - get a MIB-II interface-group table entry
m2IfTblEntrySet( ) - set the state of a MIB-II interface entry to UP or DOWN
m2IfDelete( ) - delete all resources used to access the interface group
This library provides MIB-II services for the interface group. It provides routines to initialize the group, access the group scalar variables, read the table interfaces and change the state of the interfaces. For a broader description of MIB-II services, see the manual entry for m2Lib.
This library can be initialized and deleted by calling m2IfInit( ) and m2IfDelete( ) respectively, if only the interface group's services are needed. If full MIB-II support is used, this group and all other groups can be initialized and deleted by calling m2Init( ) and m2Delete( ).
The interface group supports the Simple Network Management Protocol (SNMP) concept of traps, as specified by RFC 1215. The traps supported by this group are "link up" and "link down." This library enables an application to register a hook routine and an argument. This hook routine can be called by the library when a "link up" or "link down" condition is detected. The hook routine must have the following prototype:
void TrapGenerator (int trapType, /* M2_LINK_DOWN_TRAP or M2_LINK_UP_TRAP */ int interfaceIndex, void * myPrivateArg);The trap routine and argument can be specified at initialization time as input parameters to the routine m2IfInit( ) or to the routine m2Init( ).The interface-group global variables can be accessed as follows:
M2_INTERFACE ifVars; if (m2IfGroupInfoGet (&ifVars) == OK) /* values in ifVars are valid */An interface table entry can be retrieved as follows:M2_INTERFACETBL interfaceEntry; /* Specify zero as the index to get the first entry in the table */ interfaceEntry.ifIndex = 2; /* Get interface with index 2 */ if (m2IfTblEntryGet (M2_EXACT_VALUE, &interfaceEntry) == OK) /* values in interfaceEntry are valid */An interface entry operational state can be changed as follows:M2_INTERFACETBL ifEntryToSet; ifEntryToSet.ifIndex = 2; /* Select interface with index 2 */ /* MIB-II value to set the interface */ /* to the down state. */ ifEntryToSet.ifAdminStatus = M2_ifAdminStatus_down; if (m2IfTblEntrySet (&ifEntryToSet) == OK) /* Interface is now in the down state */
m2Lib.h
m2IfLib, m2Lib, m2SysLib, m2IpLib, m2IcmpLib, m2UdpLib, m2TcpLib
m2IfInit( ) - initialize MIB-II interface-group routines
STATUS m2IfInit ( FUNCPTR pTrapRtn, /* pointer to user trap generator */ void * pTrapArg /* pointer to user trap generator argument */ )
This routine allocates the resources needed to allow access to the MIB-II interface-group variables. This routine must be called before any interface variables can be accessed. The input parameter pTrapRtn is an optional pointer to a user-supplied SNMP trap generator. The input parameter pTrapArg is an optional argument to the trap generator. Only one trap generator is supported.
OK, always.
S_m2Lib_CANT_CREATE_IF_SEM
m2IfLib, m2IfGroupInfoGet( ), m2IfTblEntryGet( ), m2IfTblEntrySet( ), m2IfDelete( )
m2IfGroupInfoGet( ) - get the MIB-II interface-group scalar variables
STATUS m2IfGroupInfoGet ( M2_INTERFACE * pIfInfo /* pointer to interface group structure */ )
This routine fills out the interface-group structure at pIfInfo with the values of MIB-II interface-group global variables.
OK, or ERROR if pIfInfo is not a valid pointer.
S_m2Lib_INVALID_PARAMETER
m2IfLib, m2IfInit( ), m2IfTblEntryGet( ), m2IfTblEntrySet( ), m2IfDelete( )
m2IfTblEntryGet( ) - get a MIB-II interface-group table entry
STATUS m2IfTblEntryGet ( int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */ M2_INTERFACETBL * pIfReqEntry /* pointer to requested interface entry */ )
This routine maps the MIB-II interface index to the system's internal interface index. The search parameter is set to either M2_EXACT_VALUE or M2_NEXT_VALUE; for a discussion of its use, see the manual entry for m2Lib. If the status of the interface has changed since it was last read, the user trap routine is called.
OK, or ERROR if the input parameter is not specified, or a match is not found.
S_m2Lib_INVALID_PARAMETER
S_m2Lib_ENTRY_NOT_FOUND
m2IfLib, m2Lib, m2IfInit( ), m2IfGroupInfoGet( ), m2IfTblEntrySet( ), m2IfDelete( )
m2IfTblEntrySet( ) - set the state of a MIB-II interface entry to UP or DOWN
STATUS m2IfTblEntrySet ( M2_INTERFACETBL * pIfTblEntry /* pointer to requested entry to change */ )
This routine selects the interface specified in the input parameter pIfTblEntry and sets the interface to the requested state. It is the responsibility of the calling routine to set the interface index, and to make sure that the state specified in the ifAdminStatus field of the structure at pIfTblEntry is a valid MIB-II state, up(1) or down(2).
OK, or ERROR if the input parameter is not specified, an interface is no longer valid, the interface index is incorrect, or the ioctl( ) command to the interface fails.
S_m2Lib_INVALID_PARAMETER
S_m2Lib_ENTRY_NOT_FOUND
S_m2Lib_IF_CNFG_CHANGED
m2IfLib, m2IfInit( ), m2IfGroupInfoGet( ), m2IfTblEntryGet( ), m2IfDelete( )
m2IfDelete( ) - delete all resources used to access the interface group
STATUS m2IfDelete (void)
This routine frees all the resources allocated at the time the group was initialized. The interface group should not be accessed after this routine has been called.
OK, always.
m2IfLib, m2IfInit( ), m2IfGroupInfoGet( ), m2IfTblEntryGet( ), m2IfTblEntrySet( )