VxWorks Reference Manual : Libraries

m2IpLib

NAME

m2IpLib - MIB-II IP-group API for SNMP agents

ROUTINES

m2IpInit( ) - initialize MIB-II IP-group access
m2IpGroupInfoGet( ) - get the MIB-II IP-group scalar variables
m2IpGroupInfoSet( ) - set MIB-II IP-group variables to new values
m2IpAddrTblEntryGet( ) - get an IP MIB-II address entry
m2IpAtransTblEntryGet( ) - get a MIB-II ARP table entry
m2IpAtransTblEntrySet( ) - add, modify, or delete a MIB-II ARP entry
m2IpRouteTblEntryGet( ) - get a MIB-2 routing table entry
m2IpRouteTblEntrySet( ) - set a MIB-II routing table entry
m2IpDelete( ) - delete all resources used to access the IP group

DESCRIPTION

This library provides MIB-II services for the IP group. It provides routines to initialize the group, access the group scalar variables, read the table IP address, route and ARP table. The route and ARP table can also be modified. For a broader description of MIB-II services, see the manual entry for m2Lib.

USING THIS LIBRARY

To use this library, the MIB-II interface group must also be initialized; see the manual entry for m2IfLib. This library (m2IpLib) can be initialized and deleted by calling m2IpInit( ) and m2IpDelete( ) respectively, if only the IP 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 following example demonstrates how to access and change IP scalar variables:

    M2_IP   ipVars;
    int     varToSet;

    if (m2IpGroupInfoGet (&ipVars) == OK)
        /* values in ipVars are valid */

    /* if IP is forwarding packets (MIB-II value is 1) turn it off */

    if (ipVars.ipForwarding == M2_ipForwarding_forwarding)
        {
                                    /* Not forwarding (MIB-II value is 2) */
        ipVars.ipForwarding = M2_ipForwarding_not_forwarding;      
        varToSet |= M2_IPFORWARDING;
        }

    /* change the IP default time to live parameter */

    ipVars.ipDefaultTTL = 55;

    if (m2IpGroupInfoSet (varToSet, &ipVars) == OK)
        /* values in ipVars are valid */
The IP address table is a read-only table. Entries to this table can be retrieved as follows:
    M2_IPADDRTBL ipAddrEntry;

    /* Specify the index as zero to get the first entry in the table */

    ipAddrEntry.ipAdEntAddr = 0;       /* Local IP address in host byte order */

    /* get the first entry in the table */

    if ((m2IpAddrTblEntryGet (M2_NEXT_VALUE, &ipAddrEntry) == OK)
        /* values in ipAddrEntry in the first entry are valid  */

    /* Process first entry in the table */

    /* 
     * For the next call, increment the index returned in the previous call.
     * The increment is to the next possible lexicographic entry; for
     * example, if the returned index was 147.11.46.8 the index passed in the
     * next invocation should be 147.11.46.9.  If an entry in the table
     * matches the specified index, then that entry is returned.
     * Otherwise the closest entry following it, in lexicographic order,
     * is returned.
     */

    /* get the second entry in the table */

    if ((m2IpAddrTblEntryGet (M2_NEXT_VALUE, &ipAddrEntryEntry) == OK)
        /* values in ipAddrEntry in the second entry are valid  */
The IP Address Translation Table (ARP table) includes the functionality of the AT group plus additional functionality. The AT group is supported through this MIB-II table. Entries in this table can be added and deleted. An entry is deleted (with a set operation) by setting the ipNetToMediaType field to the MIB-II "invalid" value (2). The following example shows how to delete an entry:
M2_IPATRANSTBL        atEntry;

    /* Specify the index for the connection to be deleted in the table */

    atEntry.ipNetToMediaIfIndex     = 1       /* interface index */

    /* destination IP address in host byte order */

    atEntry.ipNetToMediaNetAddress  = 0x930b2e08;

                                            /* mark entry as invalid */
    atEntry.ipNetToMediaType        = M2_ipNetToMediaType_invalid; 

    /* set the entry in the table */

    if ((m2IpAtransTblEntrySet (&atEntry) == OK)
        /* Entry deleted successfully */
The IP route table allows for entries to be read, deleted, and modified. This example demonstrates how an existing route is deleted:
    M2_IPROUTETBL        routeEntry;

    /* Specify the index for the connection to be deleted in the table */
    /* destination IP address in host byte order */

    routeEntry.ipRouteDest       = 0x930b2e08;
                                                /* mark entry as invalid */
    routeEntry.ipRouteType       = M2_ipRouteType_invalid;

    /* set the entry in the table */

    if ((m2IpRouteTblEntrySet (M2_IP_ROUTE_TYPE, &routeEntry) == OK)
        /* Entry deleted successfully */

INCLUDE FILES

m2Lib.h

SEE ALSO

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


Libraries : Routines

m2IpInit( )

NAME

m2IpInit( ) - initialize MIB-II IP-group access

SYNOPSIS

STATUS m2IpInit
    (
    int maxRouteTableSize /* max size of routing table */
    )

DESCRIPTION

This routine allocates the resources needed to allow access to the MIB-II IP variables. This routine must be called before any IP variables can be accessed. The parameter maxRouteTableSize is used to increase the default size of the MIB-II route table cache.

RETURNS

OK, or ERROR if the route table or the route semaphore cannot be allocated.

ERRNO

S_m2Lib_CANT_CREATE_ROUTE_SEM

SEE ALSO

m2IpLib, m2IpGroupInfoGet( ), m2IpGroupInfoSet( ), m2IpAddrTblEntryGet( ), m2IpAtransTblEntrySet( ), m2IpRouteTblEntryGet( ), m2IpRouteTblEntrySet( ), m2IpDelete( )


Libraries : Routines

m2IpGroupInfoGet( )

NAME

m2IpGroupInfoGet( ) - get the MIB-II IP-group scalar variables

SYNOPSIS

STATUS m2IpGroupInfoGet
    (
    M2_IP * pIpInfo /* pointer to IP MIB-II global group variables */
    )

DESCRIPTION

This routine fills in the IP structure at pIpInfo with the values of MIB-II IP global variables.

RETURNS

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

ERRNO

S_m2Lib_INVALID_PARAMETER

SEE ALSO

m2IpLib, m2IpInit( ), m2IpGroupInfoSet( ), m2IpAddrTblEntryGet( ), m2IpAtransTblEntrySet( ), m2IpRouteTblEntryGet( ), m2IpRouteTblEntrySet( ), m2IpDelete( )


Libraries : Routines

m2IpGroupInfoSet( )

NAME

m2IpGroupInfoSet( ) - set MIB-II IP-group variables to new values

SYNOPSIS

STATUS m2IpGroupInfoSet
    (
    unsigned int varToSet, /* bit field used to set variables */
    M2_IP *      pIpInfo   /* ptr to the MIB-II IP group global variables */
    )

DESCRIPTION

This routine sets one or more variables in the IP group, as specified in the input structure pIpInfo and the bit field parameter varToSet.

RETURNS

OK, or ERROR if pIpInfo is not a valid pointer, or varToSet has an invalid bit field.

ERRNO

 S_m2Lib_INVALID_PARAMETER
 S_m2Lib_INVALID_VAR_TO_SET

SEE ALSO

m2IpLib, m2IpInit( ), m2IpGroupInfoGet( ), m2IpAddrTblEntryGet( ), m2IpAtransTblEntrySet( ), m2IpRouteTblEntryGet( ), m2IpRouteTblEntrySet( ), m2IpDelete( )


Libraries : Routines

m2IpAddrTblEntryGet( )

NAME

m2IpAddrTblEntryGet( ) - get an IP MIB-II address entry

SYNOPSIS

STATUS m2IpAddrTblEntryGet
    (
    int            search,         /* M2_EXACT_VALUE or M2_NEXT_VALUE */
    M2_IPADDRTBL * pIpAddrTblEntry /* ptr to requested IP address entry */
    )

DESCRIPTION

This routine traverses the IP address table and does an M2_EXACT_VALUE or a M2_NEXT_VALUE search based on the search parameter. The calling routine is responsible for supplying a valid MIB-II entry index in the input structure pIpAddrTblEntry. The index is the local IP address. The first entry in the table is retrieved by doing a NEXT search with the index field set to zero.

RETURNS

OK, 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

m2IpLib, m2Lib, m2IpInit( ), m2IpGroupInfoGet( ), m2IpGroupInfoSet( ), m2IpAtransTblEntrySet( ), m2IpRouteTblEntryGet( ), m2IpRouteTblEntrySet( ), m2IpDelete( )


Libraries : Routines

m2IpAtransTblEntryGet( )

NAME

m2IpAtransTblEntryGet( ) - get a MIB-II ARP table entry

SYNOPSIS

STATUS m2IpAtransTblEntryGet
    (
    int              search,       /* M2_EXACT_VALUE or M2_NEXT_VALUE */
    M2_IPATRANSTBL * pReqIpAtEntry /* ptr to the requested ARP entry */
    )

DESCRIPTION

This routine traverses the ARP table and does an M2_EXACT_VALUE or a M2_NEXT_VALUE search based on the search parameter. The calling routine is responsible for supplying a valid MIB-II entry index in the input structure pReqIpatEntry. The index is made up of the network interface index and the IP address corresponding to the physical address. The first entry in the table is retrieved by doing a NEXT search with the index fields set to zero.

RETURNS

OK, 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

m2IpLib, m2Lib, m2IpInit( ), m2IpGroupInfoGet( ), m2IpGroupInfoSet( ), m2IpAtransTblEntrySet( ), m2IpRouteTblEntryGet( ), m2IpRouteTblEntrySet( ), m2IpDelete( )


Libraries : Routines

m2IpAtransTblEntrySet( )

NAME

m2IpAtransTblEntrySet( ) - add, modify, or delete a MIB-II ARP entry

SYNOPSIS

STATUS m2IpAtransTblEntrySet
    (
    M2_IPATRANSTBL * pReqIpAtEntry /* pointer to MIB-II ARP entry */
    )

DESCRIPTION

This routine traverses the ARP table for the entry specified in the parameter pReqIpAtEntry. An ARP entry can be added, modified, or deleted. A MIB-II entry index is specified by the destination IP address and the physical media address. A new ARP entry can be added by specifying all the fields in the parameter pReqIpAtEntry. An entry can be modified by specifying the MIB-II index and the field that is to be modified. An entry is deleted by specifying the index and setting the type field in the input parameter pReqIpAtEntry to the MIB-II value "invalid" (2).

RETURNS

OK, or ERROR if the input parameter is not specified, the physical address is not specified for an add/modify request, or the ioctl( ) request to the ARP module fails.

ERRNO

 S_m2Lib_INVALID_PARAMETER
 S_m2Lib_ARP_PHYSADDR_NOT_SPECIFIED

SEE ALSO

m2IpLib, m2IpInit( ), m2IpGroupInfoGet( ), m2IpGroupInfoSet( ), m2IpAddrTblEntryGet( ), m2IpRouteTblEntryGet( ), m2IpRouteTblEntrySet( ), m2IpDelete( )


Libraries : Routines

m2IpRouteTblEntryGet( )

NAME

m2IpRouteTblEntryGet( ) - get a MIB-2 routing table entry

SYNOPSIS

STATUS m2IpRouteTblEntryGet
    (
    int             search,          /* M2_EXACT_VALUE or M2_NEXT_VALUE */
    M2_IPROUTETBL * pIpRouteTblEntry /* route table entry */
    )

DESCRIPTION

This routine retrieves MIB-II information about an entry in the network routing table and returns it in the caller-supplied structure pIpRouteTblEntry.

The routine compares routing table entries to the address specified by the ipRouteDest member of the pIpRouteTblEntry structure, and retrieves an entry chosen by the search type (M2_EXACT_VALUE or M2_NEXT_VALUE, as described in the manual entry for m2Lib).

RETURNS

OK if successful, otherwise ERROR.

ERRNO

  S_m2Lib_INVALID_PARAMETER   
  S_m2Lib_ENTRY_NOT_FOUND

SEE ALSO

m2IpLib, m2Lib, m2IpInit( ), m2IpGroupInfoGet( ), m2IpGroupInfoSet( ), m2IpAddrTblEntryGet( ), m2IpRouteTblEntryGet( ), m2IpRouteTblEntrySet( ), m2IpDelete( )


Libraries : Routines

m2IpRouteTblEntrySet( )

NAME

m2IpRouteTblEntrySet( ) - set a MIB-II routing table entry

SYNOPSIS

STATUS m2IpRouteTblEntrySet
    (
    int             varToSet,        /* variable to set */
    M2_IPROUTETBL * pIpRouteTblEntry /* route table entry */
    )

DESCRIPTION

This routine adds, changes, or deletes a network routing table entry. The table entry to be modified is specified by the ipRouteDest and ipRouteNextHop members of the pIpRouteTblEntry structure.

The varToSet parameter is a bit-field mask that specifies which values in the route table entry are to be set.

If varToSet has the M2_IP_ROUTE_TYPE bit set and ipRouteType has the value of M2_ROUTE_TYPE_INVALID, then the the routing table entry is deleted.

If varToSet has the either the M2_IP_ROUTE_DEST or M2_IP_ROUTE_NEXT_HOP bit set, then either a new route entry is added to the table or an existing route entry is changed.

RETURNS

OK if successful, otherwise ERROR.

SEE ALSO

m2IpLib, m2IpInit( ), m2IpGroupInfoGet( ), m2IpGroupInfoSet( ), m2IpAddrTblEntryGet( ), m2IpRouteTblEntryGet( ), m2IpRouteTblEntrySet( ), m2IpDelete( )


Libraries : Routines

m2IpDelete( )

NAME

m2IpDelete( ) - delete all resources used to access the IP group

SYNOPSIS


STATUS m2IpDelete (void)

DESCRIPTION

This routine frees all the resources allocated when the IP group was initialized. The IP group should not be accessed after this routine has been called.

RETURNS

OK, always.

SEE ALSO

m2IpLib, m2IpInit( ), m2IpGroupInfoGet( ), m2IpGroupInfoSet( ), m2IpAddrTblEntryGet( ), m2IpAtransTblEntrySet( ), m2IpRouteTblEntryGet( ), m2IpRouteTblEntrySet( )