original files of m241
This commit is contained in:
@@ -0,0 +1,307 @@
|
||||
/* m2Ipv6IcmpLib.c - MIB-II IPv6 ICMPv6-group API for SNMP Agents */
|
||||
|
||||
/* Copyright 2002-2005 Wind River Systems, Inc. */
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01i,12jan05,vvv osdep.h cleanup
|
||||
01h,02feb04,pas changed for new avlLib without GENERIC_ARGUMENT.
|
||||
01g,20nov03,niq osdep.h cleanup
|
||||
01e,10nov03,rlm 2nd pass of include update for header re-org.
|
||||
01d,06nov03,rlm Ran batch header update for header re-org.
|
||||
01c,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
|
||||
01b,10apr03,ijm fixed diab compiler warnings
|
||||
01a,12apr02,ant written
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
This library provides MIB-II services for the ICMPv6 group for IPv6. It
|
||||
provides routines to initialize the group, and to access the per-interface
|
||||
ICMPv6 statistics table. For a broader description of IPv6 MIB-II services,
|
||||
see the manual entry for m2Ipv6Lib.
|
||||
|
||||
To use this feature, include the following component:
|
||||
INCLUDE_MIB2_ICMPV6
|
||||
|
||||
USING THIS LIBRARY
|
||||
This library can be initialized and deleted by calling the routines
|
||||
m2Ipv6IfIcmpInit() and m2Ipv6IfIcmpDelete() respectively, if only the ICMPv6
|
||||
group's services are needed. If full IPv6 MIB-II support is used, this group
|
||||
and all other IPv6 groups can be initialized and deleted by calling
|
||||
m2Ipv6Init() and m2Ipv6Delete().
|
||||
|
||||
The ICMPv6 table of statistics 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
|
||||
m2Ipv6IfIcmpTblGet() the index retrieved in the previous invocation
|
||||
by giving M2_NEXT_VALUE as the search parameter. For example:
|
||||
.CS
|
||||
M2_IPV6IFICMPTBL icmpv6Entry;
|
||||
int index;
|
||||
|
||||
/@ Specify a zero index to get the first entry in the table @/
|
||||
|
||||
index = 0; /@ Interface index @/
|
||||
|
||||
/@ get the first entry in the table @/
|
||||
|
||||
if ((m2Ipv6IfIcmpTblGet (M2_NEXT_VALUE, &index, &icmpv6Entry) == OK)
|
||||
/@ values in icmpv6Entry in the first entry are valid @/
|
||||
|
||||
/@ process first entry in the table @/
|
||||
|
||||
/@ get the second entry in the table @/
|
||||
|
||||
if ((m2Ipv6IfIcmpTblGet (M2_NEXT_VALUE, &index, &icmpv6Entry) == OK)
|
||||
/@ values in icmpv6Entry in the second entry are valid @/
|
||||
.CE
|
||||
|
||||
INCLUDE FILES: m2Ipv6Lib.h
|
||||
|
||||
SEE ALSO:
|
||||
m2Ipv6Lib, m2Ipv6IfLib, m2Ipv6TcpLib, m2Ipv6UdpLib, m2Ipv6MldLib */
|
||||
|
||||
/* includes */
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <ioctl.h>
|
||||
#include <ioLib.h>
|
||||
|
||||
#include <netconf.h>
|
||||
|
||||
#include <sockLib.h>
|
||||
#include <net/socketvar.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <m2Lib.h>
|
||||
#include <m2Ipv6Lib.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_var.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet6/icmp6.h>
|
||||
#include "errnoLib.h"
|
||||
#include "semLib.h"
|
||||
|
||||
#ifdef VIRTUAL_STACK
|
||||
#include <netinet/vsLib.h>
|
||||
#include <netinet/vsIcmp.h> /* for _icmpstat definition */
|
||||
#include <netinet/vsData.h>
|
||||
#include <netinet/vsM2.h>
|
||||
#endif /* VIRTUAL_STACK */
|
||||
|
||||
/* external declarations */
|
||||
|
||||
#ifndef VIRTUAL_STACK
|
||||
extern AVLU_TREE pM2IfRoot; /* defined in m2IfLib.c */
|
||||
extern int ifsInList; /* defined in m2IfLib.c */
|
||||
#endif /* VIRTUAL_STACK */
|
||||
|
||||
/* forward declarations */
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* m2Ipv6IfIcmpInit - initialize MIB-II IPv6 ICMPv6-group access
|
||||
*
|
||||
* This routine allocates the resources needed to allow access to the MIB-II
|
||||
* ICMPv6-group variables. This routine must be called before any ICMPv6
|
||||
* variables can be accessed.
|
||||
*
|
||||
* RETURNS: OK, always.
|
||||
*
|
||||
* SEE ALSO: m2Ipv6IfIcmpTblGet(), m2Ipv6IfIcmpDelete()
|
||||
*/
|
||||
|
||||
STATUS m2Ipv6IfIcmpInit (void)
|
||||
{
|
||||
return (OK);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* m2Ipv6IfIcmpTblGet - get the MIB-II IPv6 ICMPv6-group table entry
|
||||
*
|
||||
* This routine fills in the structure at <pIcmpv6Info> with the per-interface
|
||||
* ICMPv6 statistics.
|
||||
* This routine traverses the ICMPv6 statistics 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 <index>
|
||||
* parameter. The <index> is the interface index. The first entry in the table is
|
||||
* retrieved by doing a NEXT search with the <index> parameter set to zero.
|
||||
*
|
||||
* RETURNS: OK, or ERROR if the input parameter <pIcmpv6Info> is invalid or the
|
||||
* index <index> is invalid or not found.
|
||||
*
|
||||
* ERRNO:
|
||||
* S_m2Lib_INVALID_PARAMETER
|
||||
* S_m2Lib_ENTRY_NOT_FOUND
|
||||
* S_m2Lib_GEN_ERR
|
||||
*
|
||||
* SEE ALSO: m2Ipv6IfIcmpInit(), m2Ipv6IfIcmpDelete(), m2Ipv6IcmpLib
|
||||
*/
|
||||
|
||||
STATUS m2Ipv6IfIcmpTblGet
|
||||
(
|
||||
int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */
|
||||
int * index, /* requested interface index */
|
||||
M2_IPV6IFICMPTBL * pIcmpv6Info /* pointer to the ICMPv6 structure */
|
||||
)
|
||||
{
|
||||
M2_IFINDEX * pIfIndexEntry = NULL;
|
||||
struct in6_ifreq ifr;
|
||||
int s;
|
||||
struct icmp6_ifstat *icmp6_ifstatLoc; /* ICMP statistics structure */
|
||||
|
||||
/* Validate Pointer to ICMPv6 structure */
|
||||
|
||||
if (pIcmpv6Info == NULL)
|
||||
{
|
||||
errnoSet (S_m2Lib_INVALID_PARAMETER);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* First, Validate the bounds of the requested index */
|
||||
|
||||
if (*index > ifsInList || *index < 0)
|
||||
{
|
||||
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* search exact value */
|
||||
|
||||
if (search == M2_EXACT_VALUE)
|
||||
{
|
||||
pIfIndexEntry = m2Ipv6AvlSearch (pM2IfRoot, *index);
|
||||
if (!pIfIndexEntry)
|
||||
{
|
||||
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
|
||||
return (ERROR);
|
||||
}
|
||||
}
|
||||
else /* M2_NEXT_VALUE */
|
||||
{
|
||||
pIfIndexEntry = m2Ipv6AvlSuccessorGet (pM2IfRoot, *index);
|
||||
if (!pIfIndexEntry)
|
||||
{
|
||||
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
*index = pIfIndexEntry->ifIndex;
|
||||
}
|
||||
|
||||
if (if_indextoname(*index, ifr.ifr_name) == NULL)
|
||||
{
|
||||
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
errnoSet (S_m2Lib_GEN_ERR);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if (ioctl (s, SIOCGIFSTAT_ICMP6, (int) &ifr) < 0)
|
||||
{
|
||||
errnoSet (S_m2Lib_GEN_ERR);
|
||||
close (s);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
icmp6_ifstatLoc = (struct icmp6_ifstat *)&ifr.ifr_ifru.ifru_icmp6stat;
|
||||
|
||||
pIcmpv6Info->ipv6IfIcmpInMsgs
|
||||
= icmp6_ifstatLoc->ifs6_in_msg;
|
||||
pIcmpv6Info->ipv6IfIcmpInErrors
|
||||
= icmp6_ifstatLoc->ifs6_in_error;
|
||||
pIcmpv6Info->ipv6IfIcmpInDestUnreachs
|
||||
= icmp6_ifstatLoc->ifs6_in_dstunreach;
|
||||
pIcmpv6Info->ipv6IfIcmpInAdminProhibs
|
||||
= icmp6_ifstatLoc->ifs6_in_adminprohib;
|
||||
pIcmpv6Info->ipv6IfIcmpInTimeExcds
|
||||
= icmp6_ifstatLoc->ifs6_in_timeexceed;
|
||||
pIcmpv6Info->ipv6IfIcmpInParmProblems
|
||||
= icmp6_ifstatLoc->ifs6_in_paramprob;
|
||||
pIcmpv6Info->ipv6IfIcmpInPktTooBigs
|
||||
= icmp6_ifstatLoc->ifs6_in_pkttoobig;
|
||||
pIcmpv6Info->ipv6IfIcmpInEchos
|
||||
= icmp6_ifstatLoc->ifs6_in_echo;
|
||||
pIcmpv6Info->ipv6IfIcmpInEchoReplies
|
||||
= icmp6_ifstatLoc->ifs6_in_echoreply;
|
||||
pIcmpv6Info->ipv6IfIcmpInRouterSolicits
|
||||
= icmp6_ifstatLoc->ifs6_in_routersolicit;
|
||||
pIcmpv6Info->ipv6IfIcmpInRouterAdvertisements
|
||||
= icmp6_ifstatLoc->ifs6_in_routeradvert;
|
||||
pIcmpv6Info->ipv6IfIcmpInNeighborSolicits
|
||||
= icmp6_ifstatLoc->ifs6_in_neighborsolicit;
|
||||
pIcmpv6Info->ipv6IfIcmpInNeighborAdvertisements
|
||||
= icmp6_ifstatLoc->ifs6_in_neighboradvert;
|
||||
pIcmpv6Info->ipv6IfIcmpInRedirects
|
||||
= icmp6_ifstatLoc->ifs6_in_redirect;
|
||||
pIcmpv6Info->ipv6IfIcmpInGroupMembQueries
|
||||
= icmp6_ifstatLoc->ifs6_in_mldquery;
|
||||
pIcmpv6Info->ipv6IfIcmpInGroupMembResponses
|
||||
= icmp6_ifstatLoc->ifs6_in_mldreport;
|
||||
pIcmpv6Info->ipv6IfIcmpInGroupMembReductions
|
||||
= icmp6_ifstatLoc->ifs6_in_mlddone;
|
||||
pIcmpv6Info->ipv6IfIcmpOutMsgs
|
||||
= icmp6_ifstatLoc->ifs6_out_msg;
|
||||
pIcmpv6Info->ipv6IfIcmpOutErrors
|
||||
= icmp6_ifstatLoc->ifs6_out_error;
|
||||
pIcmpv6Info->ipv6IfIcmpOutDestUnreachs
|
||||
= icmp6_ifstatLoc->ifs6_out_dstunreach;
|
||||
pIcmpv6Info->ipv6IfIcmpOutAdminProhibs
|
||||
= icmp6_ifstatLoc->ifs6_out_adminprohib;
|
||||
pIcmpv6Info->ipv6IfIcmpOutTimeExcds
|
||||
= icmp6_ifstatLoc->ifs6_out_timeexceed;
|
||||
pIcmpv6Info->ipv6IfIcmpOutParmProblems
|
||||
= icmp6_ifstatLoc->ifs6_out_paramprob;
|
||||
pIcmpv6Info->ipv6IfIcmpOutPktTooBigs
|
||||
= icmp6_ifstatLoc->ifs6_out_pkttoobig;
|
||||
pIcmpv6Info->ipv6IfIcmpOutEchos
|
||||
= icmp6_ifstatLoc->ifs6_out_echo;
|
||||
pIcmpv6Info->ipv6IfIcmpOutEchoReplies
|
||||
= icmp6_ifstatLoc->ifs6_out_echoreply;
|
||||
pIcmpv6Info->ipv6IfIcmpOutRouterSolicits
|
||||
= icmp6_ifstatLoc->ifs6_out_routersolicit;
|
||||
pIcmpv6Info->ipv6IfIcmpOutRouterAdvertisements
|
||||
= icmp6_ifstatLoc->ifs6_out_routeradvert;
|
||||
pIcmpv6Info->ipv6IfIcmpOutNeighborSolicits
|
||||
= icmp6_ifstatLoc->ifs6_out_neighborsolicit;
|
||||
pIcmpv6Info->ipv6IfIcmpOutNeighborAdvertisements
|
||||
= icmp6_ifstatLoc->ifs6_out_neighboradvert;
|
||||
pIcmpv6Info->ipv6IfIcmpOutRedirects
|
||||
= icmp6_ifstatLoc->ifs6_out_redirect;
|
||||
pIcmpv6Info->ipv6IfIcmpOutGroupMembQueries
|
||||
= icmp6_ifstatLoc->ifs6_out_mldquery;
|
||||
pIcmpv6Info->ipv6IfIcmpOutGroupMembResponses
|
||||
= icmp6_ifstatLoc->ifs6_out_mldreport;
|
||||
pIcmpv6Info->ipv6IfIcmpOutGroupMembReductions
|
||||
= icmp6_ifstatLoc->ifs6_out_mlddone;
|
||||
|
||||
close (s);
|
||||
return (OK);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* m2Ipv6IfIcmpDelete - delete all resources used to access the ICMPv6 group
|
||||
*
|
||||
* This routine frees all the resources allocated at the time the ICMPv6 group was
|
||||
* initialized. The ICMPv6 group should not be accessed after this routine has
|
||||
* been called.
|
||||
*
|
||||
* RETURNS: OK, always.
|
||||
*
|
||||
* SEE ALSO: m2Ipv6IfIcmpInit(), m2Ipv6IfIcmpTblGet(), m2Ipv6IcmpLib
|
||||
*/
|
||||
|
||||
STATUS m2Ipv6IfIcmpDelete (void)
|
||||
{
|
||||
return (OK);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user