Files
m241Neelima/components/ip_net2-6.9/vxcompat/src/m2Ipv6Lib.c
T
2026-07-30 11:19:44 +05:30

223 lines
6.9 KiB
C

/* m2Ipv6Lib.c - MIB-II IPv6 API library for SNMP agents */
/* Copyright 2001 - 2005 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01g,12jan05,vvv osdep.h cleanup
01f,06nov03,rlm Ran batch header update for header re-org.
01e,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
01d,11oct02,ham added m2Ipv6LibInit() (SPR 83041).
01c,02oct02,ham fixed man-page bugs.
01b,02oct02,ham updated the man entries.
01a,06sep02,ant wrote.
*/
/*
DESCRIPTION
This library provides Management Information Base (MIB-II, defined in
RFC 2452, RFC 2454, RFC 2465, RFC 2466, RFC 3019) services for applications
wishing to have access to MIB parameters.
To use this feature, include the following component:
INCLUDE_MIB2_IPV6ALL
There are no specific provisions for MIB-I: all services
are provided at the MIB-II level. Applications that use this library
for MIB-I must hide the MIB-II extensions from higher level protocols.
The library accesses all the MIB-II parameters, and presents them to
the application in data structures based on the MIB-II specifications.
The routines provided by the VxWorks IPv6 MIB-II library are separated
into groups that follow the MIB-II definition. Each supported group
has its own interface library:
.iP m2Ipv6IfLib 15 3
IPv6 general group
.iP m2Ipv6IfIcmpLib
ICMP group for IPv6
.iP m2Ipv6TcpLib
TCP group for IPv6
.iP m2Ipv6UdpLib
UDP group for IPv6
.iP m2Ipv6MldLib
MLD group
.LP
USING THIS LIBRARY
There are four types of operations on each group:
- initializing the group
- getting variables and table entries
- setting variables and table entries
- deleting the group
Applications that require MIB-II support from all groups can
initialize all groups at once by calling the m2Ipv6Init(). All MIB-II group
services can be disabled by calling m2Ipv6Delete(). Applications that need
access only to a particular set of groups need only call the
initialization routines of the desired groups.
To read the scalar variables for each group, call one of the following
routines:
m2Ipv6IfGeneralGet()
m2Ipv6RouteInfoGet()
The input parameter to the routine is always a pointer to a structure
specific to the associated group. The scalar group structures follow
the naming convention "M2_IPV6<groupname>". The get routines fill in the
input structure with the values of all the group variables.
The scalar variables can also be set to a user supplied value. Not all
groups permit setting variables, as specified by the MIB-II definition.
The following group routines allow setting variables:
m2Ipv6IfGeneralSet()
The input parameter to the variable-set routine is a group structure
that contains variables to set and a bit field that specifies which
variables to set. Applications need set only the structure fields
corresponding to the bits that are set in the bit field.
The MIB-II table routines read one entry at a time. Each MIB-II group
that has tables has a get routine for each table. The following
table-get routines are available:
m2Ipv6IfTblEntryGet()
m2Ipv6AddrPfxTblEntryGet()
m2Ipv6AddrTblEntryGet()
m2Ipv6RouteTblEntryGet()
m2Ipv6AtransTblEntryGet()
m2Ipv6IfIcmpTblGet()
m2Ipv6TcpConnEntryGet()
m2Ipv6UdpTblEntryGet()
m2Ipv6MldIfTblEntryGet()
m2Ipv6MldCacheTblEntryGet()
The input parameters are a pointer to a table entry structure, a flag
value specifying one of two types of table search, and some of them have
parameter specifying interface index. Each table entry is a structure,
where the struct type name follows this naming convention:
"M2_IPV6<Groupname><Tablename>TBL". The MIB-II RFC specifies an index
that identifies a table entry. Each get request must specify an
index value. To retrieve the first entry in a table, set all the
index fields of the table-entry structure to zero, and use the search
parameter M2_NEXT_VALUE. To retrieve subsequent entries, pass the
index returned from the previous invocation, incremented to the next
possible lexicographical entry. The search field can only be set to
the constants M2_NEXT_VALUE or M2_EXACT_VALUE:
.iP M2_NEXT_VALUE
retrieves a table entry that is the closest entry
following that value, in lexicographic order.
.iP M2_EXACT_VALUE
retrieves a table entry that exactly matches the index
specified in the input structure.
.LP
Some MIB-II table entries can be added, modified and deleted.
Routines to manipulate such entries are described in the manual pages
for individual groups.
All the IPv6 network addresses that are exchanged with the MIB-II
library must be in host-byte order; use macro NTOHL_IPV6ADDR() to
convert addresses before calling these library routines. Call macro
HTONL_IPV6ADDR() to convert the IPv6 network addresses back to network-
byte order.
The following example shows how to initialize the IPv6 MIB-II library
for all groups.
.CS
unsigned long maxRouteTableSize;
if (m2Ipv6Init (maxRouteTableSize) == OK)
/@ IPv6 MIB-II groups initialized successfully @/
.CE
INCLUDE FILES: m2Ipv6Lib.h
SEE ALSO: m2Lib, m2Ipv6IfLib, m2Ipv6IfIcmpLib, m2Ipv6UdpLib, m2Ipv6TcpLib,
m2Ipv6MldLib
*/
/* includes */
#include <vxWorks.h>
#include <netconf.h>
#include <m2Lib.h>
#include <m2Ipv6Lib.h>
/******************************************************************************
*
* m2Ipv6LibInit - initialize m2Ipv6Lib
*
* This routine initializes m2Ipv6Lib.
*
* RETURNS: OK if successful, otherwise ERROR.
*
*/
STATUS m2Ipv6LibInit (void)
{
return (OK);
}
/******************************************************************************
*
* m2Ipv6Init - initialize the SNMP IPv6 MIB-2 library
*
* This routine initializes the IPv6 MIB-2 library by calling the initialization
* routines for each IPv6 MIB-2 group. The parameter <maxRouteTableSize>
* is passed directly to m2Ipv6IfInit().
*
* RETURNS: OK if successful, otherwise ERROR.
*
* SEE ALSO:
* m2Ipv6IfInit(), m2Ipv6TcpInit(), m2Ipv6IfIcmpInit(), m2Ipv6UdpInit(),
* m2Ipv6MldInit()
*/
STATUS m2Ipv6Init
(
unsigned long maxRouteTableSize /* max size of routing table */
)
{
/* Call the initialization routine for each group in IPv6 MIB-2 */
if ((m2Ipv6IfInit (maxRouteTableSize) == ERROR) ||
(m2Ipv6TcpInit () == ERROR) ||
(m2Ipv6IfIcmpInit () == ERROR) ||
(m2Ipv6UdpInit () == ERROR) ||
(m2Ipv6MldInit () == ERROR))
{
m2Ipv6Delete ();
return (ERROR); /* initialization failed */
}
return (OK);
}
/******************************************************************************
*
* m2Ipv6Delete - delete all the IPv6 MIB-II library groups
*
* This routine cleans up the state associated with the IPv6 MIB-II library.
*
* RETURNS: OK (always).
*
* SEE ALSO: m2Ipv6IfDelete(), m2Ipv6TcpDelete(), m2Ipv6IfIcmpDelete(),
* m2Ipv6UdpDelete(), m2Ipv6MldDelete()
*/
STATUS m2Ipv6Delete (void)
{
m2Ipv6IfDelete ();
m2Ipv6TcpDelete ();
m2Ipv6IfIcmpDelete ();
m2Ipv6UdpDelete ();
m2Ipv6MldDelete ();
return (OK);
}