VxWorks Reference Manual : Libraries

m2TcpLib

NAME

m2TcpLib - MIB-II TCP-group API for SNMP agents

ROUTINES

m2TcpInit( ) - initialize MIB-II TCP-group access
m2TcpGroupInfoGet( ) - get MIB-II TCP-group scalar variables
m2TcpConnEntryGet( ) - get a MIB-II TCP connection table entry
m2TcpConnEntrySet( ) - set a TCP connection to the closed state
m2TcpDelete( ) - delete all resources used to access the TCP group

DESCRIPTION

This library provides MIB-II services for the TCP group. It provides routines to initialize the group, access the group global variables, read the table of TCP connections, and change the state of a TCP connection. 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 m2TcpInit( ) and m2TcpDelete( ) respectively, if only the TCP 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 group global variables are accessed by calling m2TcpGroupInfoGet( ) as follows:

    M2_TCP   tcpVars;

    if (m2TcpGroupInfoGet (&tcpVars) == OK)
        /* values in tcpVars are valid */
The TCP table of connections can be accessed in lexicographical order. The first entry in the table can be accessed by setting the table index to zero. Every other entry thereafter can be accessed by passing to m2TcpConnTblEntryGet( ) the index retrieved in the previous invocation incremented to the next lexicographical value by giving M2_NEXT_VALUE as the search parameter. For example:
M2_TCPCONNTBL  tcpEntry;

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

    tcpEntry.tcpConnLocalAddress = 0; /* Local IP address in host byte order */
    tcpEntry.tcpConnLocalPort    = 0; /* Local TCP port                    */
    tcpEntry.tcpConnRemAddress   = 0; /* remote IP address                 */
    tcpEntry.tcpConnRemPort      = 0; /* remote TCP port in host byte order  */


    /* get the first entry in the table */

    if ((m2TcpConnTblEntryGet (M2_NEXT_VALUE, &tcpEntry) == OK)
        /* values in tcpEntry 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.2000.147.11.46.158.1000
     * the index passed in the next invocation should be 
     * 147.11.46.8.2000.147.11.46.158.1001.  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 ((m2TcpConnTblEntryGet (M2_NEXT_VALUE, &tcpEntry) == OK)
        /* values in tcpEntry in the second entry are valid  */
The TCP table of connections allows only for a connection to be deleted as specified in the MIB-II. For example:
    M2_TCPCONNTBL  tcpEntry;

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

    /* Local IP address in host byte order, and local port number */

    tcpEntry.tcpConnLocalAddress = 0x930b2e08;
    tcpEntry.tcpConnLocalPort    = 3000;

    /* Remote IP address in host byte order, and remote port number */

    tcpEntry.tcpConnRemAddress   = 0x930b2e9e;
    tcpEntry.tcpConnRemPort      = 3000;

    tcpEntry.tcpConnState        = 12;  /* MIB-II state value for delete */

    /* set the entry in the table */

    if ((m2TcpConnTblEntrySet (&tcpEntry) == OK)
        /* tcpEntry deleted successfuly */

INCLUDE FILES

m2Lib.h

SEE ALSO

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


Libraries : Routines

m2TcpInit( )

NAME

m2TcpInit( ) - initialize MIB-II TCP-group access

SYNOPSIS


STATUS m2TcpInit (void)

DESCRIPTION

This routine allocates the resources needed to allow access to the TCP MIB-II variables. This routine must be called before any TCP variables can be accessed.

RETURNS

OK, always.

SEE ALSO

m2TcpLib, m2TcpGroupInfoGet( ), m2TcpConnEntryGet( ), m2TcpConnEntrySet( ), m2TcpDelete( )


Libraries : Routines

m2TcpGroupInfoGet( )

NAME

m2TcpGroupInfoGet( ) - get MIB-II TCP-group scalar variables

SYNOPSIS

STATUS m2TcpGroupInfoGet
    (
    M2_TCPINFO * pTcpInfo /* pointer to the TCP group structure */
    )

DESCRIPTION

This routine fills in the TCP structure pointed to by pTcpInfo with the values of MIB-II TCP-group scalar variables.

RETURNS

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

ERRNO

S_m2Lib_INVALID_PARAMETER

SEE ALSO

m2TcpLib, m2TcpInit( ), m2TcpConnEntryGet( ), m2TcpConnEntrySet( ), m2TcpDelete( )


Libraries : Routines

m2TcpConnEntryGet( )

NAME

m2TcpConnEntryGet( ) - get a MIB-II TCP connection table entry

SYNOPSIS

STATUS m2TcpConnEntryGet
    (
    int             search,          /* M2_EXACT_VALUE or M2_NEXT_VALUE */
    M2_TCPCONNTBL * pReqTcpConnEntry /* input = Index, Output = Entry */
    )

DESCRIPTION

This routine traverses the TCP table of users and does an M2_EXACT_VALUE or a M2_NEXT_VALUE search based on the search parameter (see m2Lib). The calling routine is responsible for supplying a valid MIB-II entry index in the input structure pReqTcpConnEntry. The index is made up of the local IP address, the local port number, the remote IP address, and the remote port. The first entry in the table is retrieved by doing a M2_NEXT_VALUE search with the index fields set to zero.

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

m2TcpLib, m2Lib, m2TcpInit( ), m2TcpGroupInfoGet( ), m2TcpConnEntrySet( ), m2TcpDelete( )


Libraries : Routines

m2TcpConnEntrySet( )

NAME

m2TcpConnEntrySet( ) - set a TCP connection to the closed state

SYNOPSIS

STATUS m2TcpConnEntrySet
    (
    M2_TCPCONNTBL * pReqTcpConnEntry /* pointer to TCP connection to close */
    )

DESCRIPTION

This routine traverses the TCP connection table and searches for the connection specified by the input parameter pReqTcpConnEntry. The calling routine is responsible for providing a valid index as the input parameter pReqTcpConnEntry. The index is made up of the local IP address, the local port number, the remote IP address, and the remote port. This call can only succeed if the connection is in the MIB-II state "deleteTCB" (12). If a match is found, the socket associated with the TCP connection is closed.

RETURNS

OK, or ERROR if the input parameter is invalid, the state of the connection specified at pReqTcpConnEntry is not "closed," the specified connection is not found, a socket is not associated with the connection, or the close( ) call fails.

SEE ALSO

m2TcpLib, m2TcpInit( ), m2TcpGroupInfoGet( ), m2TcpConnEntryGet( ), m2TcpDelete( )


Libraries : Routines

m2TcpDelete( )

NAME

m2TcpDelete( ) - delete all resources used to access the TCP group

SYNOPSIS


STATUS m2TcpDelete (void)

DESCRIPTION

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

RETURNS

OK, always.

SEE ALSO

m2TcpLib, m2TcpInit( ), m2TcpGroupInfoGet( ), m2TcpConnEntryGet( ), m2TcpConnEntrySet( )