VxWorks Reference Manual : Libraries

m2IfLib

NAME

m2IfLib - MIB-II interface-group API for SNMP agents

ROUTINES

m2IfAlloc( ) - Allocate the structure for the interface table
m2IfFree( ) - free an interface data structure
m2IfGenericPacketCount( ) - Increment the interface packet counters
m2If8023PacketCount( ) - Increment the interface packet counters for an 802.3
m2IfCounterUpdate( ) - Increment interface counters
m2IfVariableUpdate( ) - Update the contents of an interface non-counter object
m2IfPktCountRtnInstall( ) - Install an interface packet counter routine
m2IfCtrUpdateRtnInstall( ) - Install an interface counter update routine
m2IfVarUpdateRtnInstall( ) - Install an interface variable update routine
m2IfInit( ) - initialize MIB-II interface-group routines
m2IfTableUpdate( ) - Insert or remove an entry in the ifTable
rcvAddrAdd( ) - populate the rcvAddr fields for the ifRcvAddressTable
rcvAddrAdd( ) - add a physical address into the linked list
m2IfTblEntryGet( ) - get a MIB-II interface-group table entry
m2IfDefaultValsGet( ) - get the default values for the counters
m2IfCommonValsGet( ) - get the common values
m2IfTblEntrySet( ) - set the state of a MIB-II interface entry to UP or DOWN
m2IfGroupInfoGet( ) - get the MIB-II interface-group scalar variables
m2IfStackEntryGet( ) - get a MIB-II interface-group table entry
m2IfStackEntrySet( ) - modify the status of a relationship
m2IfRcvAddrEntryGet( ) - get the rcvAddress table entries for a given address
m2IfRcvAddrEntrySet( ) - modify the entries of the rcvAddressTable
m2IfDelete( ) - delete all resources used to access the interface group
nextIndex( ) - the comparison routine for the AVL tree

DESCRIPTION

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.

USING THIS LIBRARY

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 */

INCLUDE FILES

m2Lib.h

SEE ALSO

m2IfLib, m2Lib, m2SysLib, m2IpLib, m2IcmpLib, m2UdpLib, m2TcpLib


Libraries : Routines

m2IfAlloc( )

NAME

m2IfAlloc( ) - Allocate the structure for the interface table

SYNOPSIS

M2_ID * m2IfAlloc
    (
    ULONG   ifType,    /* If type of the interface */
    UCHAR * pEnetAddr, /* Physical address of interface */
    ULONG   addrLen,   /* Address length */
    ULONG   mtuSize,   /* MTU of interface */
    ULONG   speed,     /* Speed of the interface */
    char *  pName,     /* Name of the device */
    int     unit       /* Unit number of the device */
    )

DESCRIPTION

This routine is called by the driver during initialization of the interface. The memory for the interface table is allocated here. We also set the default update routines in the M2_ID struct. These fields can later be overloaded using the installed routines in the M2_ID. Once this function returns, it is the drivers responsibility to set the pMib2Tbl pointer in the END object to the new M2_ID.

The local flag, mibStyle, is set to MIB_STYLE_2233 here because this routine will be called only if the driver supports RFC 2233 counters.

RETURNS

Pointer to the M2_ID struct that gets allocated.

SEE ALSO

m2IfLib


Libraries : Routines

m2IfFree( )

NAME

m2IfFree( ) - free an interface data structure

SYNOPSIS

STATUS m2IfFree
    (
    M2_ID * pId /* pointer to the driver's M2_ID object */
    )

DESCRIPTION

This routine frees the given M2_ID. Note if the driver is not an RFC 2233 driver then the M2_ID will be NULL and this function simply returns.

RETURNS

OK if successful, ERROR otherwise

SEE ALSO

m2IfLib


Libraries : Routines

m2IfGenericPacketCount( )

NAME

m2IfGenericPacketCount( ) - Increment the interface packet counters

SYNOPSIS

STATUS m2IfGenericPacketCount
    (
    M2_ID * pId,   /* The pointer to the device M2_ID object */
    UINT    ctrl,  /* Update In or Out counters */
    UCHAR * pPkt,  /* The incoming/outgoing packet */
    ULONG   pktLen /* Length of the packet */
    )

DESCRIPTION

This function is used to update basic interface counters for a packet. It has no idea of the underlying media so only the ifInOctets, ifHCInOctets, ifOutOctets, ifHCOutOctets, and ifCounterDiscontinuityTime variables are incremented. The ctrl argument specifies whether the packet is being sent or just received (M2_PACKET_IN or M2_PACKET_OUT).

RETURNS

ERROR if the M2_ID is NULL, OK if the counters were updated.

SEE ALSO

m2IfLib


Libraries : Routines

m2If8023PacketCount( )

NAME

m2If8023PacketCount( ) - Increment the interface packet counters for an 802.3

SYNOPSIS

STATUS m2If8023PacketCount
    (
    M2_ID * pId,   /* The pointer to the device M2_ID object */
    UINT    ctrl,  /* Update In or Out counters */
    UCHAR * pPkt,  /* The incoming/outgoing packet */
    ULONG   pktLen /* Length of the packet */
    )

DESCRIPTION

device

This function is used to update basic interface counters for a packet. The ctrl argument specifies whether the packet is being sent or just received (M2_PACKET_IN or M2_PACKET_OUT). This function only works for 802.3 devices as it understand the Ethernet packet format. The following counters are updated:

 . ifInOctets
 . ifInUcastPkts
 . ifInNUcastPkts
 . ifOutOctets
 . ifOutUcastPkts
 . ifOutNUcastPkts
 . ifInMulticastPkts
 . ifInBroadcastPkts
 . ifOutMulticastPkts
 . ifOutBroadcastPkts
 . ifHCInOctets
 . ifHCInUcastPkts
 . ifHCOutOctets
 . ifHCOutUcastPkts
 . ifHCInMulticastPkts
 . ifHCInBroadcastPkts
 . ifHCOutMulticastPkts
 . ifHCOutBroadcastPkts
 . ifCounterDiscontinuityTime

This function should be called right after the netMblkToBufCopy( ) function has has been completed. The first 6 bytes in the resulting buffer must contain the destination MAC address and the second 6 bytes of the buffer must contain the source MAC address.

The type of MAC address (i.e. broadcast, multicast, or unicast) is determined by the following:

. broadcast address: ff:ff:ff:ff:ff:ff . multicast address: first bit is set . unicast address: any other address not matching the above

RETURNS

ERROR if the M2_ID is NULL or the ctrl is invalid, OK if
         the counters were updated.

SEE ALSO

m2IfLib


Libraries : Routines

m2IfCounterUpdate( )

NAME

m2IfCounterUpdate( ) - Increment interface counters

SYNOPSIS

STATUS m2IfCounterUpdate
    (
    M2_ID * pId,   /* The pointer to the device M2_ID object */
    UINT    ctrId, /* Counter to update */
    ULONG   value  /* Amount to update the counter by */
    )

DESCRIPTION

This function is used to directly update an interface counter. The counter is specified by ctrId and the amount to increment it is specified by value. If the counter would roll over then the ifCounterDiscontinuityTime is updated with the current system uptime.

RETURNS

ERROR if the M2_ID is NULL, OK if the counter was updated.

SEE ALSO

m2IfLib


Libraries : Routines

m2IfVariableUpdate( )

NAME

m2IfVariableUpdate( ) - Update the contents of an interface non-counter object

SYNOPSIS

STATUS m2IfVariableUpdate
    (
    M2_ID * pId,   /* The pointer to the device M2_ID object */
    UINT    varId, /* Variable to update */
    caddr_t pData  /* Data to use */
    )

DESCRIPTION

This function is used to update an interface variable. The variable is specified by varId and the data to use is specified by pData. Note that different variable expect differnet types of data. Here is a list of the variables the the type of data expected. Therefore pData will be cast to the type listed below for each variable.

 . ifDescr                 char *
 . ifType                  UINT
 . ifMtu                   ULONG
 . ifSpeed                 ULONG
 . ifPhysAddress           M2_PHYADDR *
 . ifAdminStatus           ULONG
 . ifOperStatus            ULONG
 . ifLastChange            ULONG
 . ifOutQLen               ULONG
 . ifSpecific              M2_OBJECTID *
 . ifName                  char *
 . ifLinkUpDownTrapEnable  UINT
 . ifHighSpeed             ULONG
 . ifPromiscuousMode       UINT
 . ifConnectorPresent      UINT
 . ifAlias                 char *

RETURNS

ERROR if the M2_ID is NULL, OK if the variable was updated.

SEE ALSO

m2IfLib


Libraries : Routines

m2IfPktCountRtnInstall( )

NAME

m2IfPktCountRtnInstall( ) - Install an interface packet counter routine

SYNOPSIS

STATUS m2IfPktCountRtnInstall
    (
    M2_ID *          pId,
    M2_PKT_COUNT_RTN pRtn
    )

DESCRIPTION

This function installs a routine in the M2_ID. This routine is a packet counter which is able to update all the interface counters.

RETURNS

ERROR if the M2_ID is NULL, OK if the routine was installed.

SEE ALSO

m2IfLib


Libraries : Routines

m2IfCtrUpdateRtnInstall( )

NAME

m2IfCtrUpdateRtnInstall( ) - Install an interface counter update routine

SYNOPSIS

STATUS m2IfCtrUpdateRtnInstall
    (
    M2_ID *           pId,
    M2_CTR_UPDATE_RTN pRtn
    )

DESCRIPTION

This function installs a routine in the M2_ID. This routine is able to update a single specified interface counter.

RETURNS

ERROR if the M2_ID is NULL, OK if the routine was installed.

SEE ALSO

m2IfLib


Libraries : Routines

m2IfVarUpdateRtnInstall( )

NAME

m2IfVarUpdateRtnInstall( ) - Install an interface variable update routine

SYNOPSIS

STATUS m2IfVarUpdateRtnInstall
    (
    M2_ID *           pId,
    M2_VAR_UPDATE_RTN pRtn
    )

DESCRIPTION

This function installs a routine in the M2_ID. This routine is able to update a single specified interface variable.

RETURNS

ERROR if the M2_ID is NULL, OK if the routine was installed.

SEE ALSO

m2IfLib


Libraries : Routines

m2IfInit( )

NAME

m2IfInit( ) - initialize MIB-II interface-group routines

SYNOPSIS

STATUS m2IfInit
    (
    FUNCPTR pTrapRtn, /* pointer to user trap generator */
    void *  pTrapArg  /* pointer to user trap generator argument */
    )

DESCRIPTION

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.

RETURNS

OK, always.

ERRNO

S_m2Lib_CANT_CREATE_IF_SEM

SEE ALSO

m2IfLib, m2IfGroupInfoGet( ), m2IfTblEntryGet( ), m2IfTblEntrySet( ), m2IfDelete( )


Libraries : Routines

m2IfTableUpdate( )

NAME

m2IfTableUpdate( ) - Insert or remove an entry in the ifTable

SYNOPSIS

STATUS m2IfTableUpdate
    (
    struct ifnet * pIfNet,
    UINT           status  /* attaching or detaching */
    )

DESCRIPTION

This routine is called by if_attach and if_detach to insert/remove an entry from the local m2IfLib ifTable. The status can be one of M2_IF_TABLE_INSERT or M2_IF_TABLE_REMOVE. The ifIndex that is searched for in the AVL tree is specified in given the ifnet struct.

RETURNS

ERROR if entry does not exist, OK if the entry was deleted

SEE ALSO

m2IfLib


Libraries : Routines

rcvAddrAdd( )

NAME

rcvAddrAdd( ) - populate the rcvAddr fields for the ifRcvAddressTable

SYNOPSIS

STATUS rcvAddrGet
    (
    struct arpcom * pIfArpcom,    /* pointer to the interface's arpcom */
    M2_IFINDEX *    pIfIndexEntry /* avl node */
    )

DESCRIPTION

This function needs to be called to add all physical addresses for which an interface may receive or send packets. This includes unicast and multicast addresses. The address is inserted into the linked list maintained in the AVL node corresponding to the interface. Given the arpcom struct and the AVL node correspnding to the interface, this function goes through all the physical addresses associated with this interface and adds them into the linked list.

RETURNS

OK if successful,
         ERROR otherwise

SEE ALSO

m2IfLib


Libraries : Routines

rcvAddrAdd( )

NAME

rcvAddrAdd( ) - add a physical address into the linked list

SYNOPSIS

STATUS rcvAddrAdd
    (
    M2_IFINDEX *    pIfIndexEntry, /* the avl node */
    unsigned char * pEnetAddr      /* the addr to be added */
    )

DESCRIPTION

This function is called to add a single physical address into the linked list of addresses maintained by the AVL node.

RETURNS

OK if successful,
         ERROR otherwise

SEE ALSO

m2IfLib


Libraries : Routines

m2IfTblEntryGet( )

NAME

m2IfTblEntryGet( ) - get a MIB-II interface-group table entry

SYNOPSIS

STATUS m2IfTblEntryGet
    (
    int    search,     /* M2_EXACT_VALUE or M2_NEXT_VALUE */
    void * pIfReqEntry /* pointer to requested interface entry */
    )

DESCRIPTION

This routine maps the MIB-II interface index to the system's internal interface index. The internal representation is in the form of a balanced AVL tree indexed by ifIndex of the interface. 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.

RETURNS

OK, or ERROR if the input parameter is not specified, or a match is not found.

ERRNO

 S_m2Lib_INVALID_PARAMETER
 S_m2Lib_ENTRY_NOT_FOUND

SEE ALSO

m2IfLib, m2Lib, m2IfInit( ), m2IfGroupInfoGet( ), m2IfTblEntrySet( ), m2IfDelete( )


Libraries : Routines

m2IfDefaultValsGet( )

NAME

m2IfDefaultValsGet( ) - get the default values for the counters

SYNOPSIS

void m2IfDefaultValsGet
    (
    M2_DATA *    pM2Data,      /* The requested entry */
    M2_IFINDEX * pIfIndexEntry /* The ifindex node */
    )

DESCRIPTION

This function fills up the given struct with the default values as specified in the RFC. We will enter this routine only if the ioctl to the driver fails.

RETURNS

n/a

SEE ALSO

m2IfLib


Libraries : Routines

m2IfCommonValsGet( )

NAME

m2IfCommonValsGet( ) - get the common values

SYNOPSIS

void m2IfCommonValsGet
    (
    M2_DATA *    pM2Data,      /* The requested struct */
    M2_IFINDEX * pIfIndexEntry /* The ifindex node */
    )

DESCRIPTION

This function updates the requested struct with all the data that is independent of the driver ioctl. This information can be obtained from the ifnet structures.

RETURNS

n/a

SEE ALSO

m2IfLib


Libraries : Routines

m2IfTblEntrySet( )

NAME

m2IfTblEntrySet( ) - set the state of a MIB-II interface entry to UP or DOWN

SYNOPSIS

STATUS m2IfTblEntrySet
    (
    void * pIfReqEntry /* pointer to requested entry to change */
    )

DESCRIPTION

This routine selects the interface specified in the input parameter pIfReqEntry and sets the interface parameters 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).

The fields that can be modified by this routine are the following: ifAdminStatus, ifAlias, ifLinkUpDownTrapEnable and ifName.

RETURNS

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.

ERRNO

  S_m2Lib_INVALID_PARAMETER
  S_m2Lib_ENTRY_NOT_FOUND
  S_m2Lib_IF_CNFG_CHANGED

SEE ALSO

m2IfLib, m2IfInit( ), m2IfGroupInfoGet( ), m2IfTblEntryGet( ), m2IfDelete( )


Libraries : Routines

m2IfGroupInfoGet( )

NAME

m2IfGroupInfoGet( ) - get the MIB-II interface-group scalar variables

SYNOPSIS

STATUS m2IfGroupInfoGet
    (
    M2_INTERFACE * pIfInfo /* pointer to interface group structure */
    )

DESCRIPTION

This routine fills out the interface-group structure at pIfInfo with the values of MIB-II interface-group global variables.

RETURNS

OK, or ERROR if pIfInfo is not a valid pointer.

ERRNO

S_m2Lib_INVALID_PARAMETER

SEE ALSO

m2IfLib, m2IfInit( ), m2IfTblEntryGet( ), m2IfTblEntrySet( ), m2IfDelete( )


Libraries : Routines

m2IfStackEntryGet( )

NAME

m2IfStackEntryGet( ) - get a MIB-II interface-group table entry

SYNOPSIS

STATUS m2IfStackEntryGet
    (
    int             search,     /* M2_EXACT_VALUE or M2_NEXT_VALUE */
    int *           pHighIndex, /* the higher layer's ifIndex */
    M2_IFSTACKTBL * pIfReqEntry /* pointer to the requested entry */
    )

DESCRIPTION

This routine maps the given high and low indexes to the interfaces in the AVL tree. Using the high and low indexes, we retrieve the nodes in question and walk through their linked lists to get to the right relation. Once we get to the correct node, we can return the values based on the M2_EXACT_VALUE and the M2_NEXT_VALUE searches.

RETURNS

OK, or ERROR if the input parameter is not specified, or a match is not found.

ERRNO

 S_m2Lib_INVALID_PARAMETER
 S_m2Lib_ENTRY_NOT_FOUND

SEE ALSO

m2IfLib


Libraries : Routines

m2IfStackEntrySet( )

NAME

m2IfStackEntrySet( ) - modify the status of a relationship

SYNOPSIS

STATUS m2IfStackEntrySet
    (
    int             highIndex,  /* The higher layer's ifIndex */
    M2_IFSTACKTBL * pIfReqEntry /* The requested entry */
    )

DESCRIPTION

This routine selects the interfaces specified in the input parameters pIfReqEntry and highIndex and sets the interface's status to the requested state.

RETURNS

OK, or ERROR if the input parameter is not specified, an interface is no longer valid, or the interface index is incorrect.

ERRNO

  S_m2Lib_INVALID_PARAMETER
  S_m2Lib_ENTRY_NOT_FOUND
  S_m2Lib_IF_CNFG_CHANGED

SEE ALSO

m2IfLib


Libraries : Routines

m2IfRcvAddrEntryGet( )

NAME

m2IfRcvAddrEntryGet( ) - get the rcvAddress table entries for a given address

SYNOPSIS

STATUS m2IfRcvAddrEntryGet
    (
    int               search,     /* exact search or next search */
    int *             pIndex,     /* pointer to the ifIndex */
    M2_IFRCVADDRTBL * pIfReqEntry /* struct containing the new values */
    )

DESCRIPTION

This function returns the exact or the next value in the ifRcvAddressTable based on the value of the search parameter. In order to identify the appropriate entry, this function needs two identifiers - the ifIndex of the interface and the physical address for which the status or the type is being requested. For a M2_EXACT_VALUE search, this function returns the status and the type of the physical address in the instance. For a M2_NEXT_VALUE search, it returns the type and status of the lexicographic successor of the physical address seen in the instance.

RETURNS

OK, or ERROR if the input parameter is not specified, an interface is no longer valid, or the interface index is incorrect.

ERRNO

  S_m2Lib_INVALID_PARAMETER
  S_m2Lib_ENTRY_NOT_FOUND
  S_m2Lib_IF_CNFG_CHANGED

SEE ALSO

m2IfLib


Libraries : Routines

m2IfRcvAddrEntrySet( )

NAME

m2IfRcvAddrEntrySet( ) - modify the entries of the rcvAddressTable

SYNOPSIS

STATUS m2IfRcvAddrEntrySet
    (
    int               varToSet,   /* entries that need to be modified */
    int               index,      /* search type */
    M2_IFRCVADDRTBL * pIfReqEntry /* struct containing the new values */
    )

DESCRIPTION

This function modifies the status and type fields of a given recieve address associated with a given interface. varToSet identifies the fields for which the change is being requested. We can also add multicast addresses by creating a new row in the table. The physical address is stripped from the instance value of the SNMP request. This routine does not allow the deletion of a unicast address. Neither does it allow the unicast address to be modified or created.

RETURNS

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.

ERRNO

  S_m2Lib_INVALID_PARAMETER
  S_m2Lib_ENTRY_NOT_FOUND
  S_m2Lib_IF_CNFG_CHANGED

SEE ALSO

m2IfLib, m2IfInit( ), m2IfGroupInfoGet( ), m2IfTblEntryGet( ), m2IfDelete( )


Libraries : Routines

m2IfDelete( )

NAME

m2IfDelete( ) - delete all resources used to access the interface group

SYNOPSIS

STATUS m2IfDelete (void)

DESCRIPTION

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.

RETURNS

OK, always.

SEE ALSO

m2IfLib, m2IfInit( ), m2IfGroupInfoGet( ), m2IfTblEntryGet( ), m2IfTblEntrySet( )


Libraries : Routines

nextIndex( )

NAME

nextIndex( ) - the comparison routine for the AVL tree

SYNOPSIS

int nextIndex
    (
    void *           pAvlNode, /* The node to compare with */
    GENERIC_ARGUMENT key       /* The given index */
    )

DESCRIPTION

This routine compares the two indexes and returns a code based on wether the index, in question, is lesser than, equal to or greater than the one being compared.

RETURNS

-1 if the given index is lesser,
          0 if equal and
          1 if greater.

SEE ALSO

m2IfLib