original files of m241

This commit is contained in:
neelimap
2026-07-30 11:19:44 +05:30
parent 170c2b3f3a
commit afc7070c1f
12254 changed files with 7655111 additions and 0 deletions
@@ -0,0 +1,207 @@
/******************************************************************************
******************************************************************************
**** This file was automatically generated by Wind River's
**** MIB Compiler, version 10.2.
**** This file was generated using the -mib.c switch.
****
**** This file contains a representation of a MIB tree suitable
**** for use by an SNMP agent running Wind River's WindManage SNMP package.
****
**** DO NOT EDIT THIS FILE BY HAND.
****
**** Last build date: Wed Jun 11 14:10:00 2008
**** from files:
****
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1213.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2571.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2575.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1907.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/iftype.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2233.mib,
**** rfc2233.ctl, snmpmib2.mib
**** starting from node: icmp
******************************************************************************
******************************************************************************
*/
#define _MIB 1
#include <wrn/wm/snmp/engine/mib.h>
#include <wrn/wm/snmp/engine/snmpdefs.h>
#include <wrn/wm/snmp/engine/snmpstat.h>
#include <wrn/wm/snmp/vxagent/mibhand.h>
#ifndef STATIC
#define STATIC static
#endif
/**
** Subtree Object Identifier for Add_Node_From_Root
** icmp OBJECT IDENTIFIER ::= { mib-2 5 }
**/
STATIC OIDC_T oid_icmp1213_root_node[] = { 1, 3, 6, 1, 2, 1, 5 };
OBJ_ID_T objid_icmp1213_root_node = {
sizeof(oid_icmp1213_root_node)/sizeof(OIDC_T),
oid_icmp1213_root_node
};
LEAF_NT_ASYS( l_icmpInMsgs, REPLACEABLE, "icmpInMsgs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInErrors, REPLACEABLE, "icmpInErrors", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInDestUnreachs, REPLACEABLE, "icmpInDestUnreachs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInTimeExcds, REPLACEABLE, "icmpInTimeExcds", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInParmProbs, REPLACEABLE, "icmpInParmProbs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInSrcQuenchs, REPLACEABLE, "icmpInSrcQuenchs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInRedirects, REPLACEABLE, "icmpInRedirects", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInEchos, REPLACEABLE, "icmpInEchos", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInEchoReps, REPLACEABLE, "icmpInEchoReps", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInTimestamps, REPLACEABLE, "icmpInTimestamps", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInTimestampReps, REPLACEABLE, "icmpInTimestampReps", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInAddrMasks, REPLACEABLE, "icmpInAddrMasks", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpInAddrMaskReps, REPLACEABLE, "icmpInAddrMaskReps", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutMsgs, REPLACEABLE, "icmpOutMsgs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutErrors, REPLACEABLE, "icmpOutErrors", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutDestUnreachs, REPLACEABLE, "icmpOutDestUnreachs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutTimeExcds, REPLACEABLE, "icmpOutTimeExcds", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutParmProbs, REPLACEABLE, "icmpOutParmProbs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutSrcQuenchs, REPLACEABLE, "icmpOutSrcQuenchs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutRedirects, REPLACEABLE, "icmpOutRedirects", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutEchos, REPLACEABLE, "icmpOutEchos", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutEchoReps, REPLACEABLE, "icmpOutEchoReps", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutTimestamps, REPLACEABLE, "icmpOutTimestamps", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutTimestampReps, REPLACEABLE, "icmpOutTimestampReps", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutAddrMasks, REPLACEABLE, "icmpOutAddrMasks", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_icmpOutAddrMaskReps, REPLACEABLE, "icmpOutAddrMaskReps", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
icmpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_icmp[] = {
ARC(1, l_icmpInMsgs),
ARC(2, l_icmpInErrors),
ARC(3, l_icmpInDestUnreachs),
ARC(4, l_icmpInTimeExcds),
ARC(5, l_icmpInParmProbs),
ARC(6, l_icmpInSrcQuenchs),
ARC(7, l_icmpInRedirects),
ARC(8, l_icmpInEchos),
ARC(9, l_icmpInEchoReps),
ARC(10, l_icmpInTimestamps),
ARC(11, l_icmpInTimestampReps),
ARC(12, l_icmpInAddrMasks),
ARC(13, l_icmpInAddrMaskReps),
ARC(14, l_icmpOutMsgs),
ARC(15, l_icmpOutErrors),
ARC(16, l_icmpOutDestUnreachs),
ARC(17, l_icmpOutTimeExcds),
ARC(18, l_icmpOutParmProbs),
ARC(19, l_icmpOutSrcQuenchs),
ARC(20, l_icmpOutRedirects),
ARC(21, l_icmpOutEchos),
ARC(22, l_icmpOutEchoReps),
ARC(23, l_icmpOutTimestamps),
ARC(24, l_icmpOutTimestampReps),
ARC(25, l_icmpOutAddrMasks),
ARC(26, l_icmpOutAddrMaskReps),
END_OF_ARC_LIST };
MIBNODE_T icmp1213_root_node = NODE_NT("icmp",
REPLACEABLE, a_icmp);
@@ -0,0 +1,205 @@
/******************************************************************************
******************************************************************************
**** This file was automatically generated by Wind River's
**** MIB Compiler, version 10.2.
**** This file was generated using the -mib.c switch.
****
**** This file contains a representation of a MIB tree suitable
**** for use by an SNMP agent running Wind River's WindManage SNMP package.
****
**** DO NOT EDIT THIS FILE BY HAND.
****
**** Last build date: Wed Jun 11 13:30:11 2008
**** from files:
****
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1213.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2571.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2575.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1907.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/iftype.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2233.mib,
**** rfc2233.ctl, snmpmib2.mib
**** starting from node: interfaces
******************************************************************************
******************************************************************************
*/
#define _MIB 1
#include <wrn/wm/snmp/engine/mib.h>
#include <wrn/wm/snmp/engine/snmpdefs.h>
#include <wrn/wm/snmp/engine/snmpstat.h>
#include <wrn/wm/snmp/vxagent/mibhand.h>
#ifndef STATIC
#define STATIC static
#endif
/**
** Subtree Object Identifier for Add_Node_From_Root
** interfaces OBJECT IDENTIFIER ::= { mib-2 2 }
**/
STATIC OIDC_T oid_if1213_root_node[] = { 1, 3, 6, 1, 2, 1, 2 };
OBJ_ID_T objid_if1213_root_node = {
sizeof(oid_if1213_root_node)/sizeof(OIDC_T),
oid_if1213_root_node
};
LEAF_NT_ASYS( l_ifNumber, REPLACEABLE, "ifNumber", VT_NUMBER,
READ_ACCESS, SCALAR, null_test_async,
interfacesGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifIndex, REPLACEABLE, "ifIndex", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifDescr, REPLACEABLE, "ifDescr", VT_STRING,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifType, REPLACEABLE, "ifType", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifMtu, REPLACEABLE, "ifMtu", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifSpeed, REPLACEABLE, "ifSpeed", VT_GAUGE,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifPhysAddress, REPLACEABLE, "ifPhysAddress", VT_STRING,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifAdminStatus, REPLACEABLE, "ifAdminStatus", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ifEntryTest,
ifEntryGet, ifEntrySet, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifOperStatus, REPLACEABLE, "ifOperStatus", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifLastChange, REPLACEABLE, "ifLastChange", VT_TIMETICKS,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifInOctets, REPLACEABLE, "ifInOctets", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifInUcastPkts, REPLACEABLE, "ifInUcastPkts", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifInNUcastPkts, REPLACEABLE, "ifInNUcastPkts", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifInDiscards, REPLACEABLE, "ifInDiscards", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifInErrors, REPLACEABLE, "ifInErrors", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifInUnknownProtos, REPLACEABLE, "ifInUnknownProtos", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifOutOctets, REPLACEABLE, "ifOutOctets", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifOutUcastPkts, REPLACEABLE, "ifOutUcastPkts", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifOutNUcastPkts, REPLACEABLE, "ifOutNUcastPkts", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifOutDiscards, REPLACEABLE, "ifOutDiscards", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifOutErrors, REPLACEABLE, "ifOutErrors", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifOutQLen, REPLACEABLE, "ifOutQLen", VT_GAUGE,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifSpecific, REPLACEABLE, "ifSpecific", VT_OBJECT,
READ_ACCESS, TABULAR, null_test_async,
ifEntryGet, null_set_async, ifEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_ifEntry[] = {
ARC(1, l_ifIndex),
ARC(2, l_ifDescr),
ARC(3, l_ifType),
ARC(4, l_ifMtu),
ARC(5, l_ifSpeed),
ARC(6, l_ifPhysAddress),
ARC(7, l_ifAdminStatus),
ARC(8, l_ifOperStatus),
ARC(9, l_ifLastChange),
ARC(10, l_ifInOctets),
ARC(11, l_ifInUcastPkts),
ARC(12, l_ifInNUcastPkts),
ARC(13, l_ifInDiscards),
ARC(14, l_ifInErrors),
ARC(15, l_ifInUnknownProtos),
ARC(16, l_ifOutOctets),
ARC(17, l_ifOutUcastPkts),
ARC(18, l_ifOutNUcastPkts),
ARC(19, l_ifOutDiscards),
ARC(20, l_ifOutErrors),
ARC(21, l_ifOutQLen),
ARC(22, l_ifSpecific),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ifEntry = NODE_NT("ifEntry",
REPLACEABLE, a_ifEntry);
STATIC
MIBARC_T a_ifTable[] = {
ARC(1, n_ifEntry),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ifTable = NODE_NT("ifTable",
REPLACEABLE, a_ifTable);
STATIC
MIBARC_T a_interfaces[] = {
ARC(1, l_ifNumber),
ARC(2, n_ifTable),
END_OF_ARC_LIST };
MIBNODE_T if1213_root_node = NODE_NT("interfaces",
REPLACEABLE, a_interfaces);
@@ -0,0 +1,202 @@
/******************************************************************************
******************************************************************************
**** This file was automatically generated by Wind River's
**** MIB Compiler, version 10.2.
**** This file was generated using the -mib.c switch.
****
**** This file contains a representation of a MIB tree suitable
**** for use by an SNMP agent running Wind River's WindManage SNMP package.
****
**** DO NOT EDIT THIS FILE BY HAND.
****
**** Last build date: Thu Oct 23 12:03:26 2008
**** from files:
****
**** /folk/zruan/my-home/m4cd28/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1213.mib,
**** /folk/zruan/my-home/m4cd28/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2571.mib,
**** /folk/zruan/my-home/m4cd28/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2575.mib,
**** /folk/zruan/my-home/m4cd28/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1907.mib,
**** /folk/zruan/my-home/m4cd28/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/iftype.mib,
**** /folk/zruan/my-home/m4cd28/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2233.mib,
**** /folk/zruan/my-home/m4cd28/vxworks-6.7/target/src/wrn/wm/snmp/vxagent/rfc2233.ctl,
**** /folk/zruan/my-home/m4cd28/vxworks-6.7/target/src/wrn/wm/snmp/vxagent/snmpmib2.mib
**** starting from node: ifMIB
******************************************************************************
******************************************************************************
*/
#define _MIB 1
#include <wrn/wm/snmp/engine/mib.h>
#include <wrn/wm/snmp/engine/snmpdefs.h>
#include <wrn/wm/snmp/engine/snmpstat.h>
#include <wrn/wm/snmp/vxagent/mibhand.h>
#ifndef STATIC
#define STATIC static
#endif
/**
** Subtree Object Identifier for Add_Node_From_Root
** ifMIB OBJECT IDENTIFIER ::= { mib-2 31 }
**/
STATIC OIDC_T oid_if2233_root_node[] = { 1, 3, 6, 1, 2, 1, 31 };
OBJ_ID_T objid_if2233_root_node = {
sizeof(oid_if2233_root_node)/sizeof(OIDC_T),
oid_if2233_root_node
};
LEAF_NT_ASYS( l_ifName, REPLACEABLE, "ifName", VT_STRING,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifInMulticastPkts, REPLACEABLE, "ifInMulticastPkts", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifInBroadcastPkts, REPLACEABLE, "ifInBroadcastPkts", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifOutMulticastPkts, REPLACEABLE, "ifOutMulticastPkts", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifOutBroadcastPkts, REPLACEABLE, "ifOutBroadcastPkts", VT_COUNTER,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifHCInOctets, REPLACEABLE, "ifHCInOctets", VT_COUNTER64,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifHCInUcastPkts, REPLACEABLE, "ifHCInUcastPkts", VT_COUNTER64,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifHCInMulticastPkts, REPLACEABLE, "ifHCInMulticastPkts", VT_COUNTER64,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifHCInBroadcastPkts, REPLACEABLE, "ifHCInBroadcastPkts", VT_COUNTER64,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifHCOutOctets, REPLACEABLE, "ifHCOutOctets", VT_COUNTER64,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifHCOutUcastPkts, REPLACEABLE, "ifHCOutUcastPkts", VT_COUNTER64,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifHCOutMulticastPkts, REPLACEABLE, "ifHCOutMulticastPkts", VT_COUNTER64,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifHCOutBroadcastPkts, REPLACEABLE, "ifHCOutBroadcastPkts", VT_COUNTER64,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifLinkUpDownTrapEnable, REPLACEABLE, "ifLinkUpDownTrapEnable", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ifEntryTest,
ifXEntryGet, ifEntrySet, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifHighSpeed, REPLACEABLE, "ifHighSpeed", VT_GAUGE,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifPromiscuousMode, REPLACEABLE, "ifPromiscuousMode", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ifEntryTest,
ifXEntryGet, ifEntrySet, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifConnectorPresent, REPLACEABLE, "ifConnectorPresent", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifAlias, REPLACEABLE, "ifAlias", VT_STRING,
READ_WRITE_ACCESS, TABULAR, ifEntryTest,
ifXEntryGet, ifEntrySet, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifCounterDiscontinuityTime, REPLACEABLE, "ifCounterDiscontinuityTime", VT_TIMETICKS,
READ_ACCESS, TABULAR, null_test_async,
ifXEntryGet, null_set_async, ifXEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_ifXEntry[] = {
ARC(1, l_ifName),
ARC(2, l_ifInMulticastPkts),
ARC(3, l_ifInBroadcastPkts),
ARC(4, l_ifOutMulticastPkts),
ARC(5, l_ifOutBroadcastPkts),
ARC(6, l_ifHCInOctets),
ARC(7, l_ifHCInUcastPkts),
ARC(8, l_ifHCInMulticastPkts),
ARC(9, l_ifHCInBroadcastPkts),
ARC(10, l_ifHCOutOctets),
ARC(11, l_ifHCOutUcastPkts),
ARC(12, l_ifHCOutMulticastPkts),
ARC(13, l_ifHCOutBroadcastPkts),
ARC(14, l_ifLinkUpDownTrapEnable),
ARC(15, l_ifHighSpeed),
ARC(16, l_ifPromiscuousMode),
ARC(17, l_ifConnectorPresent),
ARC(18, l_ifAlias),
ARC(19, l_ifCounterDiscontinuityTime),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ifXEntry = NODE_NT("ifXEntry",
REPLACEABLE, a_ifXEntry);
STATIC
MIBARC_T a_ifXTable[] = {
ARC(1, n_ifXEntry),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ifXTable = NODE_NT("ifXTable",
REPLACEABLE, a_ifXTable);
LEAF_NT_ASYS( l_ifTableLastChange, REPLACEABLE, "ifTableLastChange", VT_TIMETICKS,
READ_ACCESS, SCALAR, null_test_async,
interfacesGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ifStackLastChange, REPLACEABLE, "ifStackLastChange", VT_TIMETICKS,
READ_ACCESS, SCALAR, null_test_async,
interfacesGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_ifMIBObjects[] = {
ARC(1, n_ifXTable),
ARC(5, l_ifTableLastChange),
ARC(6, l_ifStackLastChange),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ifMIBObjects = NODE_NT("ifMIBObjects",
REPLACEABLE, a_ifMIBObjects);
STATIC
MIBARC_T a_ifMIB[] = {
ARC(1, n_ifMIBObjects),
END_OF_ARC_LIST };
MIBNODE_T if2233_root_node = NODE_NT("ifMIB",
REPLACEABLE, a_ifMIB);
@@ -0,0 +1,764 @@
/* if6Lib.c - IPv6 interface address library */
/* Copyright 2003 - 2005 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01p,29sep10,h_x Fix build and coverity warnings
01o,21jun10,h_x Fix WIND00217113
01n,21oct08,spw Use ipnet_suspend/resume_stack
01m,02jul08,spw Bug fixes
01l,26Nov07,brg Reinstated after rewriting 4 ipnet integration
*/
/*
DESCRIPTION
This library contains routines to configure IPv6 interface addresses.
Generally, each routine corresponds to one of the functions of the UNIX
command 'ifconfig'.
To use this feature, include the component INCLUDE_IF6LIB.
INCLUDE FILES: if6Lib.h
SEE ALSO: ifLib, ifconfig()
*/
#include <vxWorks.h>
#include <ioctl.h>
#include <ioLib.h>
#include <errnoLib.h>
#include <errno.h>
#include <types.h>
#include <ctype.h>
#include <string.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <netinet/in.h>
#include <netinet6/in6_var.h>
#include <arpa/inet.h>
#include <inetLib.h>
#include <sys/ioctl.h>
#include <net/utils/ifconfig.h>
#include <sockLib.h>
#include <if6Lib.h>
/* ipnet includes */
#include <ipcom_config.h>
#include <ipnet_config.h>
#include <ipcom_clib.h>
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#include <ipcom_err.h>
#include <ipcom_vxworks.h>
#include <ipnet.h>
#include <ipnet_h.h>
#include <ipcom_sock.h>
#include <ipcom_sock2.h>
#include <ipnet_ip6.h>
#include <ipnet_netif.h>
#include <ipnet_routesock.h>
LOCAL STATUS if6NameLoad(char *interfaceName, struct Ip_in6_aliasreq *ifr);
LOCAL STATUS if6AddrLoad(char *interfaceAddress, struct Ip_sockaddr_in6 *sin6);
LOCAL STATUS if6IoctlCall(int code, void *req);
LOCAL STATUS ifaddrGet(char *interfaceName,char *interfaceAddress,
struct Ip_in6_aliasreq *iareq);
#if 0
LOCAL void ifaddrToAliasreq(char *interfaceName, struct Ip_ifaddrs *ia,
struct in6_aliasreq *ifra);
#endif
/******************************************************************************
*
* ifLibInit - initialize if6Lib
*
* RETURNS: NONE
*
* NOMANUAL
*/
void if6LibInit
(
void
)
{
return;
}
/******************************************************************************
*
* if6AddrGet - get an IPv6 address of a network interface
*
* This routine gets an IPv6 address of a specified network interface,
* and copies it to <interfaceAddress>, which must be large enough to
* contain INET6_ADDRSTRLEN (46) bytes.
*
* NOTE
* If the specified address is not found on the interface, this returns
* the first address, usually the link-local address.
*
* To get all addresses, use ifconfig(), ifShow(), or 'ioctl(IP_SIOCGIFCONF)'.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6AddrAdd(), if6AddrDelete()
*/
STATUS if6AddrGet
(
char *interfaceName, /* name of interface */
char *interfaceAddress /* buffer for IPv6 address */
)
{
struct Ip_in6_aliasreq iareq;
char isAddr[INET6_ADDRSTRLEN];
int ret;
if (interfaceName == NULL || interfaceAddress == NULL)
return ERROR;
/* Did the user enter a valid address, or is it a buffer ? */
ret = ipcom_inet_pton(IP_AF_INET6, interfaceAddress, isAddr);
if (ret == -1)
return ERROR;
if (ret == 0)
{
/* not a valid address ... assume it's a buffer and mark it as such */
*interfaceAddress = '\0';
}
if ((ifaddrGet(interfaceName, interfaceAddress, &iareq)) == ERROR)
{
return ERROR;
}
if (inet_ntop(AF_INET6, &(iareq.ifra_addr.sin6_addr),
interfaceAddress, IP_INET6_ADDRSTRLEN) == NULL)
{
return ERROR;
}
return OK;
}
/******************************************************************************
*
* if6AddrAdd - add an IPv6 address to a network interface
*
* This routine assigns an IPv6 address to a specified network interface.
* The address can be a host name or a standard IPv6 address format (e.g.,
* 3ffe:1::1111). If a host name is specified, it should already have been
* added to the host table with hostAdd().
*
* A <prefixLen> value of 0 is treated as equivalent to 128.
*
* See if6FlagSet() for flag values.
*
* The new address is created with a destination address of "::" (the
* unspecified address). To change the destination address, use
* if6DstAddrSet().
*
* The new address is created with Valid Lifetime and Preferred Lifetime
* values of infinity. To change the lifetime values, use if6LifetimeSet().
*
* RETURNS: OK, or ERROR if the address cannot be set.
*
* SEE ALSO: if6AddrDelete(), if6AddrGet(), if6DstAddrSet(), if6FlagSet(),
* if6LifetimeSet(), if6PrefixlenSet()
*/
STATUS if6AddrAdd
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address to assign to interface */
int prefixLen, /* prefix length */
int flags /* address flags */
)
{
struct Ip_in6_aliasreq ifareq;
ipcom_memset(&ifareq,0,sizeof(ifareq));
if (if6NameLoad(interfaceName, &ifareq) == ERROR)
return ERROR;
if (if6AddrLoad(interfaceAddress, &ifareq.ifra_addr) == ERROR)
/* XXX host lookup */
return ERROR;
ifareq.ifra_prefixmask.sin6_family = IP_AF_INET6;
ifareq.ifra_prefixmask.sin6_len = sizeof(struct Ip_sockaddr_in6);
ipnet_route_create_mask(&ifareq.ifra_prefixmask.sin6_addr, prefixLen);
ifareq.ifra_lifetime.ia6t_preferred = (Ip_time_t)IPCOM_ADDR_INFINITE;
ifareq.ifra_lifetime.ia6t_expire = (Ip_time_t)IPCOM_ADDR_INFINITE;
ifareq.ifra_flags = flags;
return (if6IoctlCall((int)IP_SIOCAIFADDR_IN6, (void *) &ifareq));
}
/******************************************************************************
*
* if6AddrDelete - delete an IPv6 address from a network interface
*
* This routine deletes an IPv6 address from a specified network interface.
* The address can be a host name or a standard IPv6 address format (e.g.,
* 3ffe:1::1111). If a host name is specified, it should already have been
* added to the host table with hostAdd().
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6AddrAdd(), if6AddrGet()
*/
STATUS if6AddrDelete
(
char *interfaceName, /* name of interface */
char *interfaceAddress /* IPv6 address to delete from interface */
)
{
struct Ip_in6_aliasreq ifareq;
ipcom_memset(&ifareq,0,sizeof(ifareq));
if (if6NameLoad(interfaceName, &ifareq) == ERROR)
return ERROR;
if (if6AddrLoad(interfaceAddress, &ifareq.ifra_addr) == ERROR)
/* XXX host lookup */
return ERROR;
return (if6IoctlCall((int)IP_SIOCDIFADDR_IN6, (void *) &ifareq));
}
/******************************************************************************
*
* if6DstAddrGet - get the IPv6 address of a point-to-point peer
*
* This routine gets the IPv6 address of a node connected to the opposite
* end of a point-to-point network connection. The address is copied to the
* buffer <dstAddress>, which must be large enough to contain
* INET6_ADDRSTRLEN (46) bytes.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6DstAddrSet()
*/
STATUS if6DstAddrGet
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address on interface */
char *dstAddress /* buffer for destination address */
)
{
struct Ip_in6_aliasreq iareq;
if (if6NameLoad(interfaceName, &iareq) == ERROR)
return ERROR;
if ((if6IoctlCall((int)IP_SIOCGIFDSTADDR_IN6,(void*)&iareq)) == ERROR)
return ERROR;
if (ipcom_inet_ntop(IP_AF_INET6, &(iareq.ifra_addr.sin6_addr),
dstAddress, IP_INET6_ADDRSTRLEN) == NULL)
return ERROR;
return OK;
}
/******************************************************************************
*
* if6DstAddrSet - set the IPv6 address of a point-to-point peer
*
* This routine assigns the IPv6 address of a node connected to the
* opposite end of a point-to-point network connection, such as a PPP
* connection.
*
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6AddrAdd(), if6DstAddrGet()
*/
STATUS if6DstAddrSet
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address on interface */
char *dstAddress /* buffer for destination address */
)
{
return ERROR;
#if 0
struct Ip_in6_aliasreq iareq;
if ((ifaddrGet(interfaceName, interfaceAddress,&iareq)) == ERROR)
return ERROR;
/* Warning! in6_alias req and Ip_in6_aliasreq should be the same
ipcom_bsdsocket.h assumption
*/
if (if6AddrLoad(dstAddress, &iareq.ifra_dstaddr) == ERROR)
return ERROR;
return (if6IoctlCall((int)IP_SIOCAIFADDR_IN6, (void *) &iareq));
#endif
}
/******************************************************************************
*
* if6PrefixlenGet - get the prefix length of an IPv6 address
*
* This routine gets the prefix length of an IPv6 address, and copies it to
* <prefixLen>.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6PrefixlenSet()
*/
STATUS if6PrefixlenGet
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address on interface */
int *prefixLen /* prefix length returned here */
)
{
struct Ip_in6_aliasreq iareq;
if ((ifaddrGet(interfaceName, interfaceAddress,&iareq)) == ERROR)
return ERROR;
*prefixLen = ipcom_sockaddr_to_prefixlen((struct Ip_sockaddr *) &iareq.ifra_prefixmask);
return OK;
}
/******************************************************************************
*
* if6PrefixlenSet - set the prefix length of an IPv6 address
*
* This routine sets the prefix length of an IPv6 address.
*
* A <prefixLen> value of 0 is treated as equivalent to 128.
*
* NOTE
* The kernel does not allow the prefix length to be changed on an existing
* address. Therefore, this routine deletes the old address, and adds a new
* address with the new prefix length.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6AddrAdd(), if6PrefixlenGet()
*/
STATUS if6PrefixlenSet
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address on interface */
int prefixLen /* prefix length */
)
{
struct Ip_in6_aliasreq iareq;
if ((ifaddrGet(interfaceName, interfaceAddress,&iareq)) == ERROR)
return ERROR;
iareq.ifra_prefixmask.sin6_family = IP_AF_INET6;
iareq.ifra_prefixmask.sin6_len = sizeof(struct Ip_sockaddr_in6);
ipnet_route_create_mask(&iareq.ifra_prefixmask.sin6_addr, prefixLen);
/* AddrGet returns absolute value */
iareq.ifra_lifetime.ia6t_preferred = (Ip_time_t)IPCOM_ADDR_INFINITE;
iareq.ifra_lifetime.ia6t_expire = (Ip_time_t)IPCOM_ADDR_INFINITE;
if (if6AddrDelete(interfaceName, interfaceAddress) == ERROR)
return ERROR;
return (if6IoctlCall((int)IP_SIOCAIFADDR_IN6, (void *) &iareq));
}
/******************************************************************************
*
* if6FlagGet - get the flags for an IPv6 interface address
*
* This routine gets the flags for a specified IPv6 address, and copies them
* to <flags>.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6FlagSet()
*/
STATUS if6FlagGet
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address on interface */
int *flags /* network flags returned here */
)
{
struct Ip_in6_aliasreq iareq;
if ((ifaddrGet(interfaceName, interfaceAddress,&iareq)) == ERROR)
return ERROR;
*flags = iareq.ifra_flags;
return OK;
}
/******************************************************************************
*
* if6FlagSet - set the flags for an IPv6 address
*
* This routine set the flags for a specified IPv6 address.
* Any combination of the following flags can be specified:
* \is
* \i IP_IN6_IFF_TEMPORARY (0x01)
* Temporary address.
* \i IP_IN6_IFF_TENTATIVE (0x02)
* Do DAD before assigning this address.
* \i IP_IN6_IFF_HOMEADDRESS (0x04)
* Home address
* \i IP_IN6_IFF_AUTONOMOUS (0x20)
* Created based on prefix adv.
* \i IP_IN6_IFF_ANYCAST (0x40)
* This is an anycast address.
* \ie
*
* NOTE
* The kernel does not allow the flags to be changed on an existing
* address. Therefore, this routine deletes the old address, and adds a new
* address with the new flags.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6AddrAdd(), if6FlagGet()
*/
STATUS if6FlagSet
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address on interface */
int flags /* address flags */
)
{
struct Ip_in6_aliasreq iareq;
if ((ifaddrGet(interfaceName, interfaceAddress,&iareq)) == ERROR)
return ERROR;
iareq.ifra_flags = flags;
if (if6AddrDelete(interfaceName, interfaceAddress) == ERROR)
return ERROR;
return (if6IoctlCall((int)IP_SIOCAIFADDR_IN6, (void *) &iareq));
}
/******************************************************************************
*
* if6FlagChange - change the flags for an IPv6 address
*
* This routine changes the flags for the specified network interfaces. If
* the parameter <on> is TRUE, the specified flags are turned on; otherwise,
* they are turned off.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6FlagGet(), if6FlagSet()
*/
STATUS if6FlagChange
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address on interface */
int flags, /* the flags to be changed */
BOOL on /* TRUE=turn on, FALSE=turn off */
)
{
struct Ip_in6_aliasreq iareq;
if ((ifaddrGet(interfaceName, interfaceAddress,&iareq)) == ERROR)
return ERROR;
if (on)
iareq.ifra_flags |= flags;
else
iareq.ifra_flags &= ~flags;
return (if6FlagSet(interfaceName,interfaceAddress,iareq.ifra_flags));
}
/******************************************************************************
*
* if6LifetimeGet - get the lifetime of an IPv6 address
*
* This routine gets the "absolute" time corressponding to the Valid
* Lifetime and Preferred Lifetime values for an IPv6 address.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6LifetimeSet()
*/
STATUS if6LifetimeGet
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address on interface */
Ip_time_t *vltime, /* valid lifetime */
Ip_time_t *pltime /* preferred lifetime */
)
{
struct Ip_in6_aliasreq iareq;
if ((ifaddrGet(interfaceName, interfaceAddress,&iareq)) == ERROR)
return ERROR;
*vltime = iareq.ifra_lifetime.ia6t_expire;
*pltime = iareq.ifra_lifetime.ia6t_preferred;
return OK;
}
/******************************************************************************
*
* if6LifetimeSet - set the lifetime of an IPv6 address
*
* This routine sets the Valid Lifetime and Preferred Lifetime values
* in seconds for an IPv6 address.
*
* A lifetime value of all ones (0xffffffff) is treated as infinity.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO: if6AddrAdd(), if6LifetimeGet()
*/
STATUS if6LifetimeSet
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* IPv6 address on interface */
Ip_time_t vltime, /* valid lifetime */
Ip_time_t pltime /* preferred lifetime */
)
{
struct Ip_in6_aliasreq iareq;
if ((ifaddrGet(interfaceName, interfaceAddress,&iareq)) == ERROR)
return ERROR;
iareq.ifra_lifetime.ia6t_expire = vltime;
iareq.ifra_lifetime.ia6t_preferred = pltime;
return (if6IoctlCall((int)IP_SIOCAIFADDR_IN6, (void *) &iareq));
}
/******************************************************************************
*
* ifaddrGet - look up an Ip_ifaddrs struct for an IPv6 interface address
*
* RETURNS: pointer or NULL
*/
LOCAL STATUS ifaddrGet
(
char *interfaceName, /* name of interface */
char *interfaceAddress, /* string representation of address */
struct Ip_in6_aliasreq *ifareq /* interface aliasreq */
)
{
struct Ip_in6_addr sin6_addr;
Ipnet_netif *netif;
Ipnet_ip6_addr_entry *address;
STATUS err=OK;
void *handle = IP_NULL;
if (interfaceName == NULL) {
err = ERROR;
goto out;
}
ipcom_strncpy(ifareq->ifra_name, interfaceName, sizeof(char)*IP_IFNAMSIZ);
if(interfaceAddress == NULL || *interfaceAddress == '\0')
{
/* Return 1 address from interface */
handle = ipnet_suspend_stack();
if (handle == IP_NULL)
{
err = ERROR;
goto out;
}
netif = ipnet_if_nametonetif((Ip_u16)ipcom_proc_vr_get(), ifareq->ifra_name);
if (netif == IP_NULL) {
ipnet_resume_stack(handle);
err = ERROR;
goto out;
}
address = (Ipnet_ip6_addr_entry *)netif->inet6_addr_list;
if(address == IP_NULL)
{
ipnet_resume_stack(handle);
err=ERROR;
goto out;
}
ipcom_memcpy(&ifareq->ifra_addr.sin6_addr,&address->addr,sizeof(struct Ip_in6_addr));
ifareq->ifra_addr.sin6_family=IP_AF_INET6;
ifareq->ifra_addr.sin6_len = sizeof(struct Ip_sockaddr_in6);
ifareq->ifra_flags=0;
if (IP_BIT_ISSET(address->flags, IPNET_IP6_ADDR_FLAG_TEMPORARY))
ifareq->ifra_flags |= IP_IN6_IFF_TEMPORARY;
if (IP_BIT_ISSET(address->flags, IPNET_IP6_ADDR_FLAG_TENTATIVE))
ifareq->ifra_flags |= IP_IN6_IFF_TENTATIVE;
if (IP_BIT_ISSET(address->flags, IPNET_IP6_ADDR_FLAG_HOMEADDRESS))
ifareq->ifra_flags |= IP_IN6_IFF_HOMEADDRESS;
if (IP_BIT_ISSET(address->flags, IPNET_IP6_ADDR_FLAG_AUTONOMOUS))
ifareq->ifra_flags |= IP_IN6_IFF_AUTONOMOUS;
if (IP_BIT_ISSET(address->flags, IPNET_IP6_ADDR_FLAG_ANYCAST))
ifareq->ifra_flags |= IP_IN6_IFF_ANYCAST;
if (IP_BIT_ISSET(address->flags, IPNET_IP6_ADDR_FLAG_DEPRECATED))
ifareq->ifra_flags |= IP_IN6_IFF_DEPRECATED;
if (IP_BIT_ISSET(address->flags, IPNET_IP6_ADDR_FLAG_AUTOMATIC))
ifareq->ifra_flags |= IP_IN6_IFF_AUTOMATIC;
ifareq->ifra_lifetime.ia6t_expire = address->expires_sec;
ifareq->ifra_lifetime.ia6t_preferred = address->preferred_sec;
ifareq->ifra_lifetime.ia6t_pltime = 0;
ifareq->ifra_lifetime.ia6t_vltime = 0;
ifareq->ifra_prefixmask.sin6_family = IP_AF_INET6;
ipcom_memset(&ifareq->ifra_prefixmask, 0, sizeof(ifareq->ifra_prefixmask));
ipnet_route_create_mask(&ifareq->ifra_prefixmask.sin6_addr, (int)(address->prefixlen));
ipnet_resume_stack(handle);
err=OK;
goto out;
}
if (ipcom_inet_pton(IP_AF_INET6, interfaceAddress,(void *) &sin6_addr) <= 0)
{
err=ERROR;
goto out;
}
ifareq->ifra_addr.sin6_family=IP_AF_INET6;
ifareq->ifra_addr.sin6_len=sizeof(struct Ip_sockaddr_in6);
ipcom_memcpy(&ifareq->ifra_addr.sin6_addr, &sin6_addr, sizeof(struct Ip_in6_addr));
ipcom_memset(&ifareq->ifra_prefixmask, 0, sizeof(ifareq->ifra_prefixmask));
/* Get address information */
if (if6IoctlCall((int)IP_SIOCXGIFADDR_IN6, (void*)ifareq) != OK)
{
err=ERROR;
goto out;
}
/* Needed for prefixLenxx functions as the ioctl call doesnt set
* the addr family and size */
ifareq->ifra_prefixmask.sin6_family = IP_AF_INET6;
ifareq->ifra_prefixmask.sin6_len = sizeof(struct Ip_sockaddr_in6);
out:
return err;
}
/******************************************************************************
*
* if6NameLoad - load an interface name into a request struct
*
* RETURNS: OK or ERROR
*/
LOCAL STATUS if6NameLoad
(
char *interfaceName, /* name of the network interface, i.e. ei0 */
struct Ip_in6_aliasreq *ifr /* request struct */
)
{
/* in6_ifreq.ifr_name and in6_aliasreq.ifra_name are equal-size
* buffers at the beginnings of their respective structs
*/
return (strncpy (ifr->ifra_name, interfaceName, sizeof(ifr->ifra_name))
? OK : ERROR);
}
/******************************************************************************
*
* if6AddrLoad - load an interface address into a request struct
*
* RETURNS: OK or ERROR
*/
LOCAL STATUS if6AddrLoad
(
char *interfaceAddress, /* string representation of address */
struct Ip_sockaddr_in6 *sin6 /* binary representation of address */
)
{
if (ipcom_inet_pton(IP_AF_INET6, interfaceAddress, (void *) &sin6->sin6_addr) <= 0)
return ERROR;
sin6->sin6_len = sizeof(*sin6);
sin6->sin6_family = AF_INET6;
return OK;
}
/******************************************************************************
*
* if6IoctlCall - make ioctl call to socket layer
*
* RETURNS: OK or ERROR
*/
LOCAL STATUS if6IoctlCall
(
int code, /* ioctl code */
void *req /* pointer to the interface ioctl request */
)
{
Ip_fd sock;
Ip_s32 status;
if ((sock = ipcom_socket (IP_AF_INET6, IP_SOCK_RAW, 0)) == IP_SOCKERR)
return (ERROR);
status = ipcom_socketioctl(sock, (unsigned long)code, req);
(void) ipcom_socketclose(sock);
if (status < 0)
{
return (ERROR);
}
return (OK);
}
@@ -0,0 +1,145 @@
#include "vxWorks.h"
#include "ioLib.h"
#include "logLib.h"
#include "memLib.h"
#include "socket.h"
#include "sockLib.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "if6Lib.h"
#include "ipcom_sock2.h"
void if6Lib_test(char *dev)
{
char addr[46],dstaddr[46];
int prefix=0,flags=0,total_count=0,failed_count=0;
Ip_time_t vltime,pltime;
memset(dstaddr,'\0',sizeof(char)*46);
memset(addr,'\0',sizeof(char)*46);
if(dev == NULL || *dev == '\0')
return;
if6LibInit();
printf("Beginning if6Lib tests... \n");
total_count++;
if(if6AddrGet(dev,addr)!=OK)
{
failed_count++;
printf("if6AddrGet failed for device %s \n",dev);
}
else
printf("if6AddrGet:%s \n",addr);
/*
total_count++;
if(if6DstAddrGet(dev,addr,dstaddr)!=OK)
{
failed_count++;
printf("if6DstAddrGet failed for device %s \n",dev);
}
else
printf("if6DstAddrGet:%s \n",dstaddr);
*/
total_count++;
if(if6PrefixlenGet(dev,addr,&prefix)!=OK)
{
failed_count++;
printf("if6Prefixlen failed for device %s \n",dev);
}
else
printf("if6Prefixlen:%d \n",prefix);
total_count++;
if(if6FlagGet(dev,addr,&flags)!=OK)
{
failed_count++;
printf("if6FlagGet failed for device %s \n",dev);
}
else
printf("if6FlagGet:%d \n",flags);
total_count++;
if(if6LifetimeGet(dev,addr,&vltime,&pltime)!=OK)
{
failed_count++;
printf("if6LifetimeGet failed for device %s \n",dev);
}
else
printf("if6LifetimeGet: valid:%x pref:%x \n",vltime,pltime);
total_count++;
if(if6AddrDelete(dev,addr)!=OK)
{
failed_count++;
printf("if6AddrDelete failed for device %s address %s\n",dev,addr);
}
else
printf("if6Delete: OK dev:%s addr:%s \n",dev,addr);
total_count++;
if(if6AddrAdd(dev,addr,prefix,flags)!=OK)
{
failed_count++;
printf("if6AddrAdd failed for device %s address %s\n",dev,addr);
}
else
printf("if6AddrAdd: OK dev:%s addr:%s \n",dev,addr);
total_count++;
if(if6PrefixlenSet(dev,addr,72)!=OK)
{
failed_count++;
printf("if6PrefixlenSet failed for device %s address %s\n len:72",dev,addr);
}
else
printf("if6PrefixlenSet: OK dev:%s addr:%s len:72 \n",dev,addr);
total_count++;
if(if6FlagSet(dev,addr,IP_IN6_IFF_ANYCAST)!=OK)
{
failed_count++;
printf("if6FlagSet failed for device %s address %s\n flag:0x40",dev,addr);
}
else
printf("if6PrefixlenSet: OK dev:%s addr:%s flag:0x40 \n",dev,addr);
total_count++;
if(if6FlagChange(dev,addr,IP_IN6_IFF_ANYCAST,0)!=OK)
{
failed_count++;
printf("if6FlagChange to OFF failed for device %s address %s\n flag:0x40",dev,addr);
}
else
printf("if6PrefixlenSet: OK. dev:%s addr:%s flag:0x40:OFF \n",dev,addr);
ifconfig(dev);
total_count++;
if(if6LifetimeSet(dev,addr,20,30)!=OK)
{
failed_count++;
printf("if6Lifetimeset failed for device %s address %s vltime 20s %pltime 30s \n",dev,addr);
}
else
printf("if6Lifetimeset: OK. dev %s address %s vltime 20s %pltime 30s \n",dev,addr);
ifconfig(dev);
printf(" Total tests: %d \n",total_count);
printf(" Failed tests: %d \n",failed_count);
printf(" Passed tests: %d \n",total_count-failed_count);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,205 @@
#include "vxWorks.h"
#include "ioLib.h"
#include "logLib.h"
#include "memLib.h"
#include "socket.h"
#include "sockLib.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "ifLib.h"
void ifLib_test(char *deviceName, char *ppp)
{
char addr[16],dstaddr[16],brdaddr[16];
int netmask,flags,metric, failed_count=0,test_count=0;;
if(deviceName == NULL || ppp == NULL) return;
ifconfig(deviceName);
printf("Beginning ifLib tests..\n");
test_count++;
if(ifAddrGet(deviceName,addr)!= OK)
{
failed_count++;
printf("ifAddrGet failed for device %s \n",deviceName);
}
else
{
printf("ifAddrGet:%s \n",addr);
}
test_count++;
if(ifBroadcastGet(deviceName,brdaddr)!=OK)
{
failed_count++;
printf("ifBrdAddrGet failed for device %s \n",deviceName);
}
else
{
printf("ifBroadcastGet:%s \n",brdaddr);
}
test_count++;
if(ifMaskGet(deviceName,&netmask)!= OK)
{
failed_count++;
printf("ifMaskget failed for device %s \n",deviceName);
}
else
{
printf("ifMaskGet:%x \n",netmask);
}
test_count++;
if(ifAddrDelete(deviceName,addr)!=OK)
{
failed_count++;
printf("ifAddrDelete failed for device %s address %s \n",deviceName,addr);
}
else
{
printf("ifAddrDelete:OK. \n");
}
ifconfig(deviceName);
test_count++;
if(ifAddrAdd(deviceName,addr,brdaddr,netmask) != OK)
{
failed_count++;
printf("ifAddrAdd failed for device %s address %s broadcastaddr %s netmask %x \n",deviceName,addr,brdaddr,netmask);
}
else
printf("ifAddrAdd:OK. \n");
ifconfig(deviceName);
test_count++;
if(ifAddrSet(deviceName,"192.168.1.3") != OK)
{
failed_count++;
printf("ifAddrSet failed for device %s address %s \n",deviceName,"192.168.1.3");
}
else
printf("ifAddrSet:%s \n","192.168.1.3");
ifconfig(deviceName);
test_count++;
if(ifDstAddrSet(ppp,"192.168.2.3") != OK)
{
failed_count++;
printf("ifDstAddrSet failed for device %s address %s \n ",deviceName,"192.168.2.3");
}
else
printf("ifDstAddrSet:%s \n","192.168.2.3");
ifconfig(deviceName);
test_count++;
if(ifDstAddrGet(ppp,dstaddr)!= OK)
{
failed_count++;
printf("ifDstAddrGet failed for device %s \n",deviceName);
}
else
printf("ifDstAddrGet:%s \n",dstaddr);
test_count++;
if(ifBroadcastSet(deviceName,"192.168.1.0") != OK)
{
failed_count++;
printf("ifBroadcastSet failed for device %s address %s \n",deviceName,"192.168.1.0");
}
else
printf("ifBroadcastSet:%s \n","192.168.1.0");
ifconfig(deviceName);
test_count++;
netmask = 0xffff0000;
if(ifMaskSet(deviceName,netmask)!= OK)
{
failed_count++;
printf("ifMaskset failed for device %s mask %x \n",deviceName,netmask);
}
else
printf("ifMaskSet:%x \n",netmask);
ifconfig(deviceName);
test_count++;
if(ifFlagGet(deviceName,&flags)!=OK)
{
failed_count++;
printf("ifFlagGet failed for device %s \n",deviceName);
}
else
printf("ifFlagGet:%x \n",flags);
test_count++;
flags = 0x01;
if(ifFlagSet(deviceName,flags)!=OK)
{
failed_count++;
printf("ifFlagSet failed for device %s %x \n",deviceName,flags);
}
else
printf("ifFlagSet:%x \n",flags);
ifconfig(deviceName);
test_count++;
if(ifFlagChange(deviceName,flags,TRUE)!=OK)
{
failed_count++;
printf("ifFlagChange failed for device %s flag:%x status:%s \n",deviceName,flags,"ON");
}
else
printf("ifFlagChange:OK. \n");
ifconfig(deviceName);
test_count++;
if(ifMetricGet(deviceName,&metric)!=OK)
{
failed_count++;
printf("ifMetricGet failed for device %s \n",deviceName);
}
else
printf("ifMetricGet:%d \n",metric);
metric=20;
test_count++;
if(ifMetricSet(deviceName,metric)!=OK)
{
failed_count++;
printf("ifMetricSet failed for device %s %d \n",deviceName,metric);
}
else
printf("ifMetricSet:%d \n",metric);
ifconfig(deviceName);
printf(" Total tests: %d \n",test_count);
printf(" Failed tests: %d \n",failed_count);
printf(" Passed tests: %d \n",test_count - failed_count);
}
@@ -0,0 +1,351 @@
/******************************************************************************
******************************************************************************
**** This file was automatically generated by Wind River's
**** MIB Compiler, version 10.2.
**** This file was generated using the -mib.c switch.
****
**** This file contains a representation of a MIB tree suitable
**** for use by an SNMP agent running Wind River's WindManage SNMP package.
****
**** DO NOT EDIT THIS FILE BY HAND.
****
**** Last build date: Wed Jun 11 14:03:52 2008
**** from files:
****
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1213.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2571.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2575.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1907.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/iftype.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2233.mib,
**** rfc2233.ctl, snmpmib2.mib
**** starting from node: ip
******************************************************************************
******************************************************************************
*/
#define _MIB 1
#include <wrn/wm/snmp/engine/mib.h>
#include <wrn/wm/snmp/engine/snmpdefs.h>
#include <wrn/wm/snmp/engine/snmpstat.h>
#include <wrn/wm/snmp/vxagent/mibhand.h>
#ifndef STATIC
#define STATIC static
#endif
/**
** Subtree Object Identifier for Add_Node_From_Root
** ip OBJECT IDENTIFIER ::= { mib-2 4 }
**/
STATIC OIDC_T oid_ip1213_root_node[] = { 1, 3, 6, 1, 2, 1, 4 };
OBJ_ID_T objid_ip1213_root_node = {
sizeof(oid_ip1213_root_node)/sizeof(OIDC_T),
oid_ip1213_root_node
};
LEAF_NT_ASYS( l_ipForwarding, REPLACEABLE, "ipForwarding", VT_NUMBER,
READ_WRITE_ACCESS, SCALAR, ipTest,
ipGet, ipSet, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipDefaultTTL, REPLACEABLE, "ipDefaultTTL", VT_NUMBER,
READ_WRITE_ACCESS, SCALAR, ipTest,
ipGet, ipSet, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipInReceives, REPLACEABLE, "ipInReceives", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipInHdrErrors, REPLACEABLE, "ipInHdrErrors", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipInAddrErrors, REPLACEABLE, "ipInAddrErrors", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipForwDatagrams, REPLACEABLE, "ipForwDatagrams", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipInUnknownProtos, REPLACEABLE, "ipInUnknownProtos", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipInDiscards, REPLACEABLE, "ipInDiscards", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipInDelivers, REPLACEABLE, "ipInDelivers", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipOutRequests, REPLACEABLE, "ipOutRequests", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipOutDiscards, REPLACEABLE, "ipOutDiscards", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipOutNoRoutes, REPLACEABLE, "ipOutNoRoutes", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipReasmTimeout, REPLACEABLE, "ipReasmTimeout", VT_NUMBER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipReasmReqds, REPLACEABLE, "ipReasmReqds", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipReasmOKs, REPLACEABLE, "ipReasmOKs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipReasmFails, REPLACEABLE, "ipReasmFails", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipFragOKs, REPLACEABLE, "ipFragOKs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipFragFails, REPLACEABLE, "ipFragFails", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipFragCreates, REPLACEABLE, "ipFragCreates", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipAdEntAddr, REPLACEABLE, "ipAdEntAddr", VT_IPADDRESS,
READ_ACCESS, TABULAR, null_test_async,
ipAddrEntryGet, null_set_async, ipAddrEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipAdEntIfIndex, REPLACEABLE, "ipAdEntIfIndex", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
ipAddrEntryGet, null_set_async, ipAddrEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipAdEntNetMask, REPLACEABLE, "ipAdEntNetMask", VT_IPADDRESS,
READ_ACCESS, TABULAR, null_test_async,
ipAddrEntryGet, null_set_async, ipAddrEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipAdEntBcastAddr, REPLACEABLE, "ipAdEntBcastAddr", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
ipAddrEntryGet, null_set_async, ipAddrEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipAdEntReasmMaxSize, REPLACEABLE, "ipAdEntReasmMaxSize", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
ipAddrEntryGet, null_set_async, ipAddrEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_ipAddrEntry[] = {
ARC(1, l_ipAdEntAddr),
ARC(2, l_ipAdEntIfIndex),
ARC(3, l_ipAdEntNetMask),
ARC(4, l_ipAdEntBcastAddr),
ARC(5, l_ipAdEntReasmMaxSize),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ipAddrEntry = NODE_NT("ipAddrEntry",
REPLACEABLE, a_ipAddrEntry);
STATIC
MIBARC_T a_ipAddrTable[] = {
ARC(1, n_ipAddrEntry),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ipAddrTable = NODE_NT("ipAddrTable",
REPLACEABLE, a_ipAddrTable);
LEAF_NT_ASYS( l_ipRouteDest, REPLACEABLE, "ipRouteDest", VT_IPADDRESS,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteIfIndex, REPLACEABLE, "ipRouteIfIndex", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteMetric1, REPLACEABLE, "ipRouteMetric1", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteMetric2, REPLACEABLE, "ipRouteMetric2", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteMetric3, REPLACEABLE, "ipRouteMetric3", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteMetric4, REPLACEABLE, "ipRouteMetric4", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteNextHop, REPLACEABLE, "ipRouteNextHop", VT_IPADDRESS,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteType, REPLACEABLE, "ipRouteType", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteProto, REPLACEABLE, "ipRouteProto", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
ipRouteEntryGet, null_set_async, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteAge, REPLACEABLE, "ipRouteAge", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteMask, REPLACEABLE, "ipRouteMask", VT_IPADDRESS,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteMetric5, REPLACEABLE, "ipRouteMetric5", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipRouteEntryTest,
ipRouteEntryGet, ipRouteEntrySet, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipRouteInfo, REPLACEABLE, "ipRouteInfo", VT_OBJECT,
READ_ACCESS, TABULAR, null_test_async,
ipRouteEntryGet, null_set_async, ipRouteEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_ipRouteEntry[] = {
ARC(1, l_ipRouteDest),
ARC(2, l_ipRouteIfIndex),
ARC(3, l_ipRouteMetric1),
ARC(4, l_ipRouteMetric2),
ARC(5, l_ipRouteMetric3),
ARC(6, l_ipRouteMetric4),
ARC(7, l_ipRouteNextHop),
ARC(8, l_ipRouteType),
ARC(9, l_ipRouteProto),
ARC(10, l_ipRouteAge),
ARC(11, l_ipRouteMask),
ARC(12, l_ipRouteMetric5),
ARC(13, l_ipRouteInfo),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ipRouteEntry = NODE_NT("ipRouteEntry",
REPLACEABLE, a_ipRouteEntry);
STATIC
MIBARC_T a_ipRouteTable[] = {
ARC(1, n_ipRouteEntry),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ipRouteTable = NODE_NT("ipRouteTable",
REPLACEABLE, a_ipRouteTable);
LEAF_NT_ASYS( l_ipNetToMediaIfIndex, REPLACEABLE, "ipNetToMediaIfIndex", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipNetToMediaEntryTest,
ipNetToMediaEntryGet, ipNetToMediaEntrySet, ipNetToMediaEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipNetToMediaPhysAddress, REPLACEABLE, "ipNetToMediaPhysAddress", VT_STRING,
READ_WRITE_ACCESS, TABULAR, ipNetToMediaEntryTest,
ipNetToMediaEntryGet, ipNetToMediaEntrySet, ipNetToMediaEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipNetToMediaNetAddress, REPLACEABLE, "ipNetToMediaNetAddress", VT_IPADDRESS,
READ_WRITE_ACCESS, TABULAR, ipNetToMediaEntryTest,
ipNetToMediaEntryGet, ipNetToMediaEntrySet, ipNetToMediaEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_ipNetToMediaType, REPLACEABLE, "ipNetToMediaType", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, ipNetToMediaEntryTest,
ipNetToMediaEntryGet, ipNetToMediaEntrySet, ipNetToMediaEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_ipNetToMediaEntry[] = {
ARC(1, l_ipNetToMediaIfIndex),
ARC(2, l_ipNetToMediaPhysAddress),
ARC(3, l_ipNetToMediaNetAddress),
ARC(4, l_ipNetToMediaType),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ipNetToMediaEntry = NODE_NT("ipNetToMediaEntry",
REPLACEABLE, a_ipNetToMediaEntry);
STATIC
MIBARC_T a_ipNetToMediaTable[] = {
ARC(1, n_ipNetToMediaEntry),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_ipNetToMediaTable = NODE_NT("ipNetToMediaTable",
REPLACEABLE, a_ipNetToMediaTable);
LEAF_NT_ASYS( l_ipRoutingDiscards, REPLACEABLE, "ipRoutingDiscards", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
ipGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_ip[] = {
ARC(1, l_ipForwarding),
ARC(2, l_ipDefaultTTL),
ARC(3, l_ipInReceives),
ARC(4, l_ipInHdrErrors),
ARC(5, l_ipInAddrErrors),
ARC(6, l_ipForwDatagrams),
ARC(7, l_ipInUnknownProtos),
ARC(8, l_ipInDiscards),
ARC(9, l_ipInDelivers),
ARC(10, l_ipOutRequests),
ARC(11, l_ipOutDiscards),
ARC(12, l_ipOutNoRoutes),
ARC(13, l_ipReasmTimeout),
ARC(14, l_ipReasmReqds),
ARC(15, l_ipReasmOKs),
ARC(16, l_ipReasmFails),
ARC(17, l_ipFragOKs),
ARC(18, l_ipFragFails),
ARC(19, l_ipFragCreates),
ARC(20, n_ipAddrTable),
ARC(21, n_ipRouteTable),
ARC(22, n_ipNetToMediaTable),
ARC(23, l_ipRoutingDiscards),
END_OF_ARC_LIST };
MIBNODE_T ip1213_root_node = NODE_NT("ip",
REPLACEABLE, a_ip);
@@ -0,0 +1,167 @@
/* m2IcmpLib.c - MIB-II ICMP-group API for SNMP Agents */
/* Copyright 1984 - 2005 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01l,18aug10,h_x Fix WIND00226752
01k,28mar08,zhr Migrated to IPNET
01j,12jan05,vvv osdep.h cleanup
01i,06nov03,rlm Ran batch header update for header re-org.
01h,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
01g,16may02,ant integration into Clarinet
01f,26oct01,spm isolated virtual stack data structures (SPR #71092)
01e,29mar01,spm merged changes from version 01d of tor2_0.open_stack
branch (wpwr VOB, base 01c) for unified code base
01d,25oct00,ham doc: cleanup for vxWorks AE 1.0.
01c,25jan95,jdi doc cleanup.
01b,11nov94,rhp edited man pages
01a,08dec93,jag written
*/
/*
DESCRIPTION
This library provides MIB-II services for the ICMP group. It provides routines
to initialize the group, and to access the group scalar variables. For a
broader description of MIB-II services, see the manual entry for m2Lib.
To use this feature, include the following component:
INCLUDE_MIB2_ICMP
USING THIS LIBRARY
This library can be initialized and deleted by calling the routines
m2IcmpInit() and m2IcmpDelete() respectively, if only the ICMP 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 scalar variables are accessed by calling
m2IcmpGroupInfoGet() as follows:
.CS
M2_ICMP icmpVars;
if (m2IcmpGroupInfoGet (&icmpVars) == OK)
/@ values in icmpVars are valid @/
.CE
INCLUDE FILES: m2Lib.h
SEE ALSO:
m2Lib, m2IfLib, m2IpLib, m2TcpLib, m2SysLib
*/
/* includes */
#include <m2Lib.h>
#include "errnoLib.h"
#include "vwModNum.h"
#include "in.h"
#include <ipcom_mib2_api.h>
#include <ipcom_type.h>
/*******************************************************************************
*
* m2IcmpInit - initialize MIB-II ICMP-group access
*
* This routine allocates the resources needed to allow access to the MIB-II
* ICMP-group variables. This routine must be called before any ICMP variables
* can be accessed.
*
* RETURNS: OK, always.
*
* SEE ALSO: m2IcmpGroupInfoGet(), m2IcmpDelete()
*/
STATUS m2IcmpInit (void)
{
return (OK);
}
/******************************************************************************
*
* m2IcmpGroupInfoGet - get the MIB-II ICMP-group global variables
*
* This routine fills in the ICMP structure at <pIcmpInfo> with the
* MIB-II ICMP scalar variables.
*
* RETURNS: OK, or ERROR if the input parameter <pIcmpInfo> is invalid.
*
* ERRNO:
* S_m2Lib_INVALID_PARAMETER
*
* SEE ALSO: m2IcmpInit(), m2IcmpDelete()
*/
STATUS m2IcmpGroupInfoGet
(
M2_ICMP * pIcmpInfo /* pointer to the ICMP group structure */
)
{
#ifdef IPCOM_USE_INET
Ipcom_mib2_icmp_group icmpGroup;
if (ipcom_mib2_get_icmp_group (&icmpGroup) == -1)
{
return (ERROR);
}
/* Validate Pointer to ICMP structure */
if (pIcmpInfo == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
/* Add the counts of all the packet types Sent and Received */
pIcmpInfo->icmpInMsgs = icmpGroup.icmpInMsgs;
pIcmpInfo->icmpOutMsgs = icmpGroup.icmpOutMsgs;
/* Add to the Input count the ICMP packets received in error */
pIcmpInfo->icmpInErrors = icmpGroup.icmpInErrors;
pIcmpInfo->icmpInDestUnreachs = icmpGroup.icmpInDestUnreachs;
pIcmpInfo->icmpInTimeExcds = icmpGroup.icmpInTimeExcds;
pIcmpInfo->icmpInParmProbs = icmpGroup.icmpInParmProbs;
pIcmpInfo->icmpInSrcQuenchs = icmpGroup.icmpInSrcQuenchs;
pIcmpInfo->icmpInRedirects = icmpGroup.icmpInRedirects;
pIcmpInfo->icmpInEchos = icmpGroup.icmpInEchos;
pIcmpInfo->icmpInEchoReps = icmpGroup.icmpInEchoReps;
pIcmpInfo->icmpInTimestamps = icmpGroup.icmpInTimestamps;
pIcmpInfo->icmpInTimestampReps = icmpGroup.icmpInTimestampReps;
pIcmpInfo->icmpInAddrMasks = icmpGroup.icmpInAddrMasks;
pIcmpInfo->icmpInAddrMaskReps = icmpGroup.icmpInAddrMaskReps;
pIcmpInfo->icmpOutErrors = icmpGroup.icmpOutErrors;
pIcmpInfo->icmpOutDestUnreachs = icmpGroup.icmpOutDestUnreachs;
pIcmpInfo->icmpOutTimeExcds = icmpGroup.icmpOutTimeExcds;
pIcmpInfo->icmpOutParmProbs = icmpGroup.icmpOutParmProbs;
pIcmpInfo->icmpOutSrcQuenchs = icmpGroup.icmpOutSrcQuenchs;
pIcmpInfo->icmpOutRedirects = icmpGroup.icmpOutRedirects;
pIcmpInfo->icmpOutEchos = icmpGroup.icmpOutEchos;
pIcmpInfo->icmpOutEchoReps = icmpGroup.icmpOutEchoReps;
pIcmpInfo->icmpOutTimestamps = icmpGroup.icmpOutTimestamps;
pIcmpInfo->icmpOutTimestampReps = icmpGroup.icmpOutTimestampReps;
pIcmpInfo->icmpOutAddrMasks = icmpGroup.icmpOutAddrMasks;
pIcmpInfo->icmpOutAddrMaskReps = icmpGroup.icmpOutAddrMaskReps;
#endif
return (OK);
}
/*******************************************************************************
*
* m2IcmpDelete - delete all resources used to access the ICMP group
*
* This routine frees all the resources allocated at the time the ICMP group was
* initialized. The ICMP group should not be accessed after this routine has
* been called.
*
* RETURNS: OK, always.
*
* SEE ALSO: m2IcmpInit(), m2IcmpGroupInfoGet()
*/
STATUS m2IcmpDelete (void)
{
return (OK);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,853 @@
/* m2IfMgtLib.c - MIB-II interface management APIs for SNMP */
/* Copyright 1993 - 2013,2014 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
02j,02feb16,rjq Incorrect calling ipnet API(VXW6-217).
02i,15Apr14,rjq Fix for VXW6-81779.
02h,22May13,bbz m2IfTblEntryGet() in m2IfMgtLib.c does not use the result
value from muxTkCookieGet() correctly.(WIND00415873)
02g,10Apr13,rjq Implement ifType and ifLastChange value.
02f,25mar13,rjq Fixed memory leak after calling ipnet_if_get_index_array
02e,14mar13,rjq set ifStackLastChange return 0
02d,29sep10,h_x Fix build and coverity warnings
02c,18aug10,h_x Fix WIND00226752
02b,21jun10,h_x Fix WIND00217113
02a,23apr10,h_x Fix WIND00208662
01z,01apr10,h_x Fix warnings
01y,31jul08,zhr Fixed WIND00129362, mottsec interface
01x,14jul08,zhr Updated for ixe interface and clean compiling warning
01w,11jul08,zhr Updated for apigen and clean up the code
01v,10jun08,zhr Fixed WIND00125256
01u,28Feb08,zhr Migrated to IPNET
01s,14apr05,sar Remove the attempted optimization when using admin status
to bring an interface up or down as it wasn't quite correct
01r,25jan05,sar Modify sysuptime to be based on 64 bit ticks
01q,12jan05,vvv osdep.h cleanup
01p,26aug04,vvv fixed Diab warning
01o,26aug04,niq unified stack merge
01n,13may04,vvv fixed incorrect dereference in m2IfRcvAddrEntrySet() (SPR
#97098)
01m,05dec03,xli change include path
01l,02dec03,zl use avlUintLib instead of avlLib
01k,20nov03,niq osdep.h cleanup
01i,06nov03,rlm Ran batch header update for header re-org
01h,20oct03,zl changed for new avlLib without GENERIC_ARGUMENT
01g,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
01f,01may03,spm Tornado 2.2 CP1 merge (from m2IfLib, ver 02b,20mar03,wap:
TOR2_2-CP1-F label, tor2_2-patch branch, /wind/river VOB)
01e,10apr03,ijm fixed diab compiler warnings
01d,10feb03,vvv added INET6 protection
01c,30sep02,kbw making man page edits
01b,30sep02,vvv fixed problem in stackEntryIsTop (SPR #71316)
01a,25sep02,ham split m2IfLib to m2IfLib and m2IfMgtLib
*/
/*
DESCRIPTION
This library provides MIB-II interface management APIs for SNMP. This
library does not include the counter-related APIs. The counter-related
APIs are provided in m2IfLib.
To use this library, include the INCLUDE_MIB2_IFMGT configuration component.
To retrieve an interface table entry:
.CS
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 @/
.CE
To retrieve an interface's operational state:
.CS
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 @/
.CE
INCLUDE FILES: m2Lib.h
SEE ALSO: m2Lib, m2SysLib, m2IpLib, m2IcmpLib, m2UdpLib, m2TcpLib
*/
/* includes */
#include <vxWorks.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <m2IfLib.h>
#include "sysLib.h"
#include <muxLib.h>
#include <muxTkLib.h>
#include <end.h>
#include <net/if.h>
#include <ipnet_h.h>
#include <ipcom_vxworks.h>
#include <ipcom_route.h>
#include <ipcom_clib.h>
#include <oemtypes.h>
#include <m2wrsnmp.h>
#include <private/muxLibP.h>
/* defines */
#define END_OBJ_MIB 1 /* Used in ifnetToEndFieldsGet() */
#define END_OBJ_FLAGS 2 /* Used in ifnetToEndFieldsGet() */
#define bits32_t sbits32_t
#define MAX_DEV_NAME_LEN 10
#define INVALID_UNIT_NUM 99
#define CNT_2233_ENABLE 1
#define IPNET_CODE_LOCK_M2()
#define IPNET_CODE_LOCK_M2_READ(handle) \
handle = ipnet_suspend_stack(); \
if (handle == IP_NULL) \
return -1;
#define IPNET_CODE_M2_UNLOCK(handle) \
ipnet_resume_stack(handle);
/* imports */
#ifndef VIRTUAL_STACK
IMPORT int ifsInList; /* Actual number of interfaces in our list */
IMPORT int m2IfCount; /* Number of network interfaces */
#ifdef WRSNMP
IMPORT int ifxAccess; /* ifxTalbe access */
#else
int ifxAccess;
#endif
IMPORT int m2If64BitCounters;
IMPORT FUNCPTR pM2TrapRtn; /* Pointer to trap routine supplied by the user */
IMPORT void * pM2TrapRtnArg;/* Pointer to trap routine argument supplied by */
/* the user */
/* last time a row was added/removed from the ifTable/ifXTable */
IMPORT ULONG m2IfTableLastChange;
/* last time a row was added/removed from the ifStackTable or when the
* ifStackStatus was last changed */
IMPORT ULONG m2IfStackLastChange;
BOOL pollUpdateOn = FALSE;
/* Semaphore used to protect the Interface group */
IMPORT SEM_ID m2InterfaceSem;
#ifndef END_POLL_STATS_ROUTINE_HOOK
#define END_POLL_STATS_ROUTINE_HOOK m2PollStatsIfPoll
#endif
IMPORT FUNCPTR _func_m2PollStatsIfPoll;
#endif /* VIRTUAL_STACK */
/* locals */
LOCAL STATUS m2IfDefaultValsGet (M2_DATA *, M2_IFINDEX *);
LOCAL STATUS m2IfCommonValsGet (M2_DATA *, M2_IFINDEX *);
/******************************************************************************
*
* m2IfMgtLibInit - initialize MIB2 I/F Management Library
*
* This routine initializes the MIB2 interface management library which
* provides APIs for interface management.
*
* RETURNS: OK if successful, ERROR if an error occured
*
* ERRNO: N/A
*/
STATUS m2IfMgtLibInit
(
void
)
{
return (OK);
}
/******************************************************************************
*
* m2IfTblEntryGet - get a MIB-II interface-group table entry
*
* 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. The interface table values are returned in a
* structure of type M2_DATA, which is passed as the second argument to this
* routine.
*
* NOTE: m2IfTblEntryGet() automatically increments the value of ifIndex when
* search parameter is set to M2_NEXT_VALUE
*
* 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:
* m2Lib, m2IfInit(), m2IfGroupInfoGet(), m2IfTblEntrySet(), m2IfDelete()
*/
STATUS m2IfTblEntryGet
(
int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */
void * pIfReqEntry /* pointer to requested interface entry */
)
{
M2_IFINDEX * pIfIndexEntry = NULL;
M2_ID * pM2Id = NULL;
M2_DATA * pM2Entry = (M2_DATA *)pIfReqEntry;
/* ipnet variables for m2Lib migration. */
Ipnet_netif * best_netif;
bits32_t * ifindexes = NULL;
unsigned int ifTable_num_entries;
unsigned int i;
Ip_u32 tlist;
void * pCookie = NULL;
char * mapdevName = NULL;
char devName[MAX_DEV_NAME_LEN];
int unit = INVALID_UNIT_NUM;
M2_INTERFACETBL * pM2IntTblEntry = &pM2Entry->mibIfTbl;
void * suspend_handle;
char name[IP_IFNAMSIZ]; /* interface name */
Ip_u32 ifindex; /* Interface index */
memset (devName, 0, sizeof(devName));
/* Validate pointer to requeste structure */
if (pIfReqEntry == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
tlist = pM2Entry->mibIfTbl.ifIndex;
ifTable_num_entries = IPNET_NETIF_NUM_ATTACHED;
IPNET_CODE_LOCK_M2_READ(suspend_handle);
ifindexes = (bits32_t *) ipnet_if_get_index_array (IPCOM_VR_ANY, 0,
(unsigned *)&ifTable_num_entries);
if (ifindexes == IP_NULL)
{
IPNET_CODE_M2_UNLOCK(suspend_handle);
return ERROR;
}
/* Get entry of interface table from ipnet */
best_netif = 0;
for ( i=0; i < ifTable_num_entries ; i++ )
{
if ( search == M2_NEXT_VALUE)
{
if (ifindexes[i]>tlist)
{
if ((best_netif = ipnet_if_indextonetif(IPCOM_VR_ANY, (Ip_u32)ifindexes[i])) == (Ipnet_netif*) NULL)
continue;
else
{
break;
}
}
}
else /* M2_EXECT_VALUE */
{
if (ifindexes[i] == tlist )
{
if ((best_netif = ipnet_if_indextonetif(IPCOM_VR_ANY, (Ip_u32)ifindexes[i])) == NULL)
break;
}
}
}
free(ifindexes);
if ( best_netif == 0)
{
IPNET_CODE_M2_UNLOCK(suspend_handle);
return (ERROR);
}
memset(name, 0, sizeof(name));
strncpy(name, best_netif->ipcom.name, IP_IFNAMSIZ - 1);
ifindex = best_netif->ipcom.ifindex;
IPNET_CODE_M2_UNLOCK(suspend_handle);
/* Try to map net stack interface name to end interface name. */
if ((mapdevName = (char *)ipcom_get_mux_dev_name(name)) != NULL)
strncpy(devName, mapdevName, strlen(mapdevName)-1);
else
strncpy(devName, name, strlen(name) - 1);
unit = (name[strlen(name)-1])-0x30;
/* Initialize the provided structure */
bzero ((char *) pM2Entry, sizeof (M2_DATA));
pIfIndexEntry = (M2_IFINDEX*) malloc(sizeof(M2_IFINDEX));
if(pIfIndexEntry == NULL)
{
return ERROR;
}
pIfIndexEntry->ifIndex = ifindex;
/*
* Get the interface data from the driver via the muxIoctl
* For driver such as ixe, gei and mottsec needs to turn endPollStats
*/
pCookie = muxTkCookieGet(devName, unit);
if ((strncmp(devName, "ixe",3) == 0) && !pollUpdateOn)
{
_func_m2PollStatsIfPoll = (FUNCPTR)END_POLL_STATS_ROUTINE_HOOK;
endPollStatsInit (PCOOKIE_TO_ENDOBJ(pCookie), END_POLL_STATS_ROUTINE_HOOK);
pollUpdateOn = TRUE;
}
if (((strncmp(devName, "mottsec",7) == 0) || (strstr (devName, "gei") != NULL)) && !pollUpdateOn)
{
_func_m2PollStatsIfPoll = (FUNCPTR)END_POLL_STATS_ROUTINE_HOOK;
endPollStatsInit (PCOOKIE_TO_ENDOBJ(pCookie), END_POLL_STATS_ROUTINE_HOOK);
pollUpdateOn = TRUE;
}
if (ifxAccess & IF_MIB_2233)
{
/* RFC 2233 */
if ( strcmp(name, "lo0") == 0)
{
m2IfDefaultValsGet (pM2Entry, pIfIndexEntry);
pM2Entry->mibIfTbl.ifIndex = ifindex;
m2IfCommonValsGet (pM2Entry, pIfIndexEntry);
ifxAccess &= 0;
free(pIfIndexEntry);
return (OK);
}
if ( pCookie == NULL ||
(muxIoctl( pCookie, EIOCGMIB2233, (caddr_t)&pM2Id) != OK))
{
free(pIfIndexEntry);
return (ERROR);
}
memcpy ((char *)pM2Entry, (char *)&pM2Id->m2Data, sizeof (M2_DATA));
pM2Entry->mibIfTbl.ifIndex = ifindex;
ifxAccess &= 0;
free(pIfIndexEntry);
return (OK);
}
else
{
/* Declare variables for RFC 1213 support */
pM2Entry->mibIfTbl.ifIndex = ifindex;
if (muxIoctl( pCookie, EIOCGMIB2233, (caddr_t)&pM2Id) == OK)
{
/* Fill parameters with driver counters */
m2IfDefaultValsGet (pM2Entry, pIfIndexEntry);
pM2IntTblEntry->ifSpeed = pM2Id->m2Data.mibIfTbl.ifSpeed;
pM2IntTblEntry->ifType = pM2Id->m2Data.mibIfTbl.ifType;
pM2IntTblEntry->ifLastChange = pM2Id->m2Data.mibIfTbl.ifLastChange;
pM2IntTblEntry->ifInOctets = pM2Id->m2Data.mibIfTbl.ifInOctets;
pM2IntTblEntry->ifInUcastPkts = pM2Id->m2Data.mibIfTbl.ifInUcastPkts;
pM2IntTblEntry->ifInNUcastPkts = pM2Id->m2Data.mibIfTbl.ifInNUcastPkts;
pM2IntTblEntry->ifInDiscards = pM2Id->m2Data.mibIfTbl.ifInDiscards;
pM2IntTblEntry->ifInUnknownProtos = pM2Id->m2Data.mibIfTbl.ifInUnknownProtos;
pM2IntTblEntry->ifInErrors = pM2Id->m2Data.mibIfTbl.ifInErrors;
pM2IntTblEntry->ifOutOctets = pM2Id->m2Data.mibIfTbl.ifOutOctets;
pM2IntTblEntry->ifOutUcastPkts = pM2Id->m2Data.mibIfTbl.ifOutUcastPkts;
pM2IntTblEntry->ifOutNUcastPkts = pM2Id->m2Data.mibIfTbl.ifOutNUcastPkts;
pM2IntTblEntry->ifOutDiscards = pM2Id->m2Data.mibIfTbl.ifOutDiscards;
pM2IntTblEntry->ifOutErrors = pM2Id->m2Data.mibIfTbl.ifOutErrors;
/* memcpy ((char *)pM2Entry, (char *)&pM2Id->m2Data, sizeof (M2_DATA)); */
}
else if ((devName[0] != 0) && (unit != INVALID_UNIT_NUM))
{
/*
* no info from ioctl, make an educated guess at
* the driver configuration
*/
m2IfDefaultValsGet (pM2Entry, pIfIndexEntry);
if (strncmp(devName, "lo", 2) == 0)
{
/* IP Loop back interface. */
sprintf ((char *)(pM2Entry->mibXIfTbl.ifName), "%s", name);
pM2IntTblEntry->ifType = M2_ifType_softwareLoopback;
pM2IntTblEntry->ifSpeed = 0;
}
else
if (strncmp(devName, "sl", 2) == 0)
{
/* Slip Network Interface */
pM2IntTblEntry->ifType = M2_ifType_slip;
pM2IntTblEntry->ifSpeed = 19200; /* Baud Rate ??? */
}
else
if (strncmp(devName, "ppp", 3) == 0)
{
/* PPP Network Interface */
pM2IntTblEntry->ifType = M2_ifType_ppp;
pM2IntTblEntry->ifSpeed = 19200; /* Baud Rate ??? */
}
else
{
/* Use Ethernet parameters as defaults */
pM2IntTblEntry->ifType =
M2_ifType_ethernet_csmacd;
pM2IntTblEntry->ifSpeed = 10000000;
}
}
/* Fill in the other parameters */
m2IfCommonValsGet (pM2Entry, pIfIndexEntry);
pM2Entry->mibIfTbl.ifIndex = ifindex;
}
free(pIfIndexEntry);
return (OK);
}
/******************************************************************************
* m2IfDefaultValsGet - get the default values for the counters
*
* This function fills 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
*/
LOCAL STATUS m2IfDefaultValsGet
(
M2_DATA * pM2Data, /* The requested entry */
M2_IFINDEX * pIfIndexEntry /* The ifindex node */
)
{
if (!(ifxAccess & IF_MIB_2233))
{
pM2Data->mibIfTbl.ifInOctets = 0;
pM2Data->mibIfTbl.ifInUcastPkts = 0;
pM2Data->mibIfTbl.ifInNUcastPkts = 0;
pM2Data->mibIfTbl.ifInDiscards = 0;
pM2Data->mibIfTbl.ifInErrors = 0;
pM2Data->mibIfTbl.ifInUnknownProtos = 0;
pM2Data->mibIfTbl.ifOutOctets = 0;
pM2Data->mibIfTbl.ifOutUcastPkts = 0;
pM2Data->mibIfTbl.ifOutNUcastPkts = 0;
pM2Data->mibIfTbl.ifOutDiscards = 0;
pM2Data->mibIfTbl.ifOutErrors = 0;
pM2Data->mibIfTbl.ifOutQLen = 0;
}
pM2Data->mibXIfTbl.ifInMulticastPkts = 0;
pM2Data->mibXIfTbl.ifInBroadcastPkts = 0;
pM2Data->mibXIfTbl.ifOutMulticastPkts = 0;
pM2Data->mibXIfTbl.ifOutBroadcastPkts = 0;
memset(&(pM2Data->mibXIfTbl.ifHCInOctets), 0, sizeof(UI64));
memset(&(pM2Data->mibXIfTbl.ifHCInUcastPkts), 0, sizeof(UI64));
memset(&(pM2Data->mibXIfTbl.ifHCInMulticastPkts), 0, sizeof(UI64));
memset(&(pM2Data->mibXIfTbl.ifHCInBroadcastPkts), 0, sizeof(UI64));
memset(&(pM2Data->mibXIfTbl.ifHCOutOctets), 0, sizeof(UI64));
memset(&(pM2Data->mibXIfTbl.ifHCOutUcastPkts), 0, sizeof(UI64));
memset(&(pM2Data->mibXIfTbl.ifHCOutMulticastPkts), 0, sizeof(UI64));
memset(&(pM2Data->mibXIfTbl.ifHCOutBroadcastPkts), 0, sizeof(UI64));
memset(pM2Data->mibXIfTbl.ifName, 0, M2DISPLAYSTRSIZE);
pM2Data->mibXIfTbl.ifLinkUpDownTrapEnable = M2_LINK_UP_DOWN_TRAP_DISABLED;
pM2Data->mibXIfTbl.ifHighSpeed = 0;
pM2Data->mibXIfTbl.ifPromiscuousMode = M2_PROMISCUOUS_MODE_OFF;
pM2Data->mibXIfTbl.ifConnectorPresent = M2_CONNECTOR_NOT_PRESENT;
memset(pM2Data->mibXIfTbl.ifAlias, 0, M2DISPLAYSTRSIZE);
pM2Data->mibXIfTbl.ifCounterDiscontinuityTime = 0;
return (OK);
}
/******************************************************************************
* m2IfCommonValsGet - get the common values
*
* 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
*/
LOCAL int m2IfCommonValsGet
(
M2_DATA * pM2Data, /* The requested struct */
M2_IFINDEX * pIfIndexEntry /* The ifindex node */
)
{
M2_INTERFACETBL * pM2IntTblEntry = &pM2Data->mibIfTbl;
Ipnet_netif * best_netif = NULL;
bits32_t * ifindexes = NULL;
unsigned int i;
unsigned int ifTable_num_entries;
void * suspend_handle;
ifTable_num_entries = IPNET_NETIF_NUM_ATTACHED;
IPNET_CODE_LOCK_M2_READ(suspend_handle);
ifindexes = (bits32_t*) ipnet_if_get_index_array (IPCOM_VR_ANY, 0,
(unsigned *)&ifTable_num_entries);
for ( i=0; i < ifTable_num_entries; i++ )
if (ifindexes[i] == pIfIndexEntry->ifIndex )
{
if ((best_netif = ipnet_if_indextonetif(IPCOM_VR_ANY, (Ip_u32)ifindexes[i])) == (Ipnet_netif*) NULL)
continue;
else
{
break;
}
}
free(ifindexes);
if(best_netif == NULL)
{
IPNET_CODE_M2_UNLOCK(suspend_handle);
return ERROR;
}
sprintf ((char *)(pM2IntTblEntry->ifDescr), "%s", best_netif->ipcom.name);
pM2IntTblEntry->ifMtu = best_netif->ipcom.mtu;
/* If the device does not have a hardware address set it to zero */
if (best_netif->ipcom.flags & (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_NOARP))
{
memset(&(pM2IntTblEntry->ifPhysAddress), 0, sizeof(M2_PHYADDR));
}
else
{
bcopy (((char *) best_netif->ipcom.link_addr),
((char *) pM2IntTblEntry->ifPhysAddress.phyAddress),
ETHERADDRLEN);
pM2IntTblEntry->ifPhysAddress.addrLength = ETHERADDRLEN;
}
/* Get the ifAdminStatus, ifLastChange, and ifOperStatus */
if (IP_BIT_ISSET (best_netif->ipcom.flags, IP_IFF_UP))
{
pM2IntTblEntry->ifAdminStatus = VAL_ifAdminStatus_up;
}
else
{
pM2IntTblEntry->ifAdminStatus = VAL_ifAdminStatus_down;
}
if (IP_BIT_ARESET (best_netif->ipcom.flags, IP_IFF_UP | IP_IFF_RUNNING))
{
pM2IntTblEntry->ifOperStatus = VAL_ifOperStatus_up;
}
else
{
pM2IntTblEntry->ifOperStatus = VAL_ifOperStatus_down;
}
pM2IntTblEntry->ifLastChange = best_netif->ipcom.mib2.ifLastChange;
/* If the device does not have a value set it with values of ipnet stack */
if (strncmp (best_netif->ipcom.name, "lo0", 3) == 0)
{
if (!ifxAccess)
{
pM2IntTblEntry->ifLastChange = best_netif->ipcom.mib2.ifLastChange;
pM2IntTblEntry->ifInOctets = best_netif->ipcom.mib2.ifInOctets;
pM2IntTblEntry->ifInUcastPkts = best_netif->ipcom.mib2.ifInUcastPkts;
pM2IntTblEntry->ifInDiscards = best_netif->ipcom.mib2.ifInDiscards;
pM2IntTblEntry->ifInErrors = best_netif->ipcom.mib2.ifInErrors;
pM2IntTblEntry->ifInUnknownProtos = best_netif->ipcom.mib2.ifInUnknownProtos;
pM2IntTblEntry->ifOutOctets = best_netif->ipcom.mib2.ifOutOctets;
pM2IntTblEntry->ifOutUcastPkts = best_netif->ipcom.mib2.ifOutUcastPkts;
pM2IntTblEntry->ifOutDiscards = best_netif->ipcom.mib2.ifOutDiscards;
pM2IntTblEntry->ifOutErrors = best_netif->ipcom.mib2.ifOutErrors;
}
if (ifxAccess)/* ifXtable common variables */
{
sprintf ((char *)(pM2Data->mibXIfTbl.ifName), "%s", best_netif->ipcom.name);
pM2Data->mibXIfTbl.ifInMulticastPkts = best_netif->ipcom.mib2.ifOutMulticastPkts;
pM2Data->mibXIfTbl.ifInBroadcastPkts = best_netif->ipcom.mib2.ifInBroadcastPkts;
pM2Data->mibXIfTbl.ifOutMulticastPkts = best_netif->ipcom.mib2.ifOutMulticastPkts;
pM2Data->mibXIfTbl.ifOutBroadcastPkts = best_netif->ipcom.mib2.ifOutBroadcastPkts;
pM2Data->mibXIfTbl.ifLinkUpDownTrapEnable = best_netif->ipcom.mib2.ifLinkUpDownTrapEnable;
if (IP_BIT_ISSET (best_netif->ipcom.flags, IP_IFF_PROMISC))
pM2Data->mibXIfTbl.ifPromiscuousMode = VAL_ifPromiscuousMode_true;
else
pM2Data->mibXIfTbl.ifPromiscuousMode = VAL_ifPromiscuousMode_false;
pM2Data->mibXIfTbl.ifConnectorPresent = VAL_ifConnectorPresent_false;
pM2Data->mibXIfTbl.ifLinkUpDownTrapEnable = (ULONG)best_netif->ipcom.mib2.ifLinkUpDownTrapEnable;
pM2Data->mibXIfTbl.ifHighSpeed = (best_netif->ipcom.type == IP_IFT_PPP)? (Mib2_Gauge32)0UL:(Mib2_Gauge32)100UL;
memset((char *)(pM2Data->mibXIfTbl.ifAlias), 0, M2DISPLAYSTRSIZE);
pM2Data->mibXIfTbl.ifCounterDiscontinuityTime = 0;
}
}
else /* interface is not loopback */
{
if (ifxAccess)
{
sprintf ((char *)(pM2Data->mibXIfTbl.ifName), "%s", best_netif->ipcom.name);
pM2Data->mibXIfTbl.ifLinkUpDownTrapEnable = (ULONG)best_netif->ipcom.mib2.ifLinkUpDownTrapEnable;
if (IP_BIT_ISSET (best_netif->ipcom.flags, IP_IFF_PROMISC))
pM2Data->mibXIfTbl.ifPromiscuousMode = VAL_ifPromiscuousMode_true;
else
pM2Data->mibXIfTbl.ifPromiscuousMode = VAL_ifPromiscuousMode_false;
pM2Data->mibXIfTbl.ifConnectorPresent = VAL_ifConnectorPresent_false;
}
}
IPNET_CODE_M2_UNLOCK(suspend_handle);
return OK;
}
/******************************************************************************
*
* m2IfTblEntrySet - set the state of a MIB-II interface entry to UP or DOWN
*
* 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
*
* 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:
* m2IfInit(), m2IfGroupInfoGet(), m2IfTblEntryGet(), m2IfDelete()
*/
STATUS m2IfTblEntrySet
(
void * pIfReqEntry /* pointer to requested entry to change */
)
{
int index;
IF_SETENTRY * pM2Entry = (IF_SETENTRY *)pIfReqEntry;
bits32_t * ifindexes;
Ipnet_netif * best_netif = NULL;
unsigned int ifTable_num_entries;
unsigned int i;
struct Ip_ifreq ifreq;
Ip_fd fd;
void *suspend_handle;
char name[IP_IFNAMSIZ]; /* interface name */
/* Validate the bounds of the requested index */
index = pM2Entry->ifIndex;
ifTable_num_entries = IPNET_NETIF_NUM_ATTACHED;
if (index < 0 || index > ifTable_num_entries)
{
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
IPNET_CODE_LOCK_M2_READ(suspend_handle);
/* Get the node associated with the index */
ifindexes = (bits32_t*) ipnet_if_get_index_array (IPCOM_VR_ANY, 0,
(unsigned *)&ifTable_num_entries);
if (ifindexes == IP_NULL)
{
IPNET_CODE_M2_UNLOCK(suspend_handle);
return (ERROR);
}
for (i=0; i < ifTable_num_entries ; i++)
{
if (ifindexes[i] == index)
{
best_netif = ipnet_if_indextonetif(IPCOM_VR_ANY, (Ip_u32)ifindexes[i]);
break;
}
}
free(ifindexes);
if (best_netif == NULL)
{
IPNET_CODE_M2_UNLOCK(suspend_handle);
return (ERROR);
}
memset(name, 0, sizeof(name));
strncpy(name, best_netif->ipcom.name, IP_IFNAMSIZ - 1);
IPNET_CODE_M2_UNLOCK(suspend_handle);
/*
* The only supported state changes for the interface are UP and DOWN.
* The TEST case is not supported by the drivers. If our caller does
* set the status to TEST, which they shouldn't, the interface will be
* brought down with an status of TEST.
*/
/* Do we need to call the Ioctl as a result of any of the above */
if (pM2Entry->varToSet & (M2_varId_ifAdminStatus |
M2_varId_ifPromiscuousMode))
{
/*
* The network semaphore is not taken for this operation because the
* called routine takes the network semphore. Issue the IOCTL to the
* driver routine, and verify that the request is honored.
*/
fd = ipcom_socket(IP_AF_INET, IP_SOCK_DGRAM, IP_IPPROTO_UDP);
if (fd != IP_INVALID_SOCKET)
{
/* Change interface status */
ipcom_memset(&ifreq, 0, sizeof(struct Ip_ifreq));
ipcom_strcpy(ifreq.ifr_name, best_netif->ipcom.name);
if (ipcom_socketioctl(fd, IP_SIOCGIFFLAGS,
&ifreq) < 0)
{
(void)ipcom_socketclose(fd);
return ERROR;
}
if (pM2Entry->ifAdminStatus == 1)
IP_BIT_SET(ifreq.ip_ifr_flags, IP_IFF_UP);
else
IP_BIT_CLR(ifreq.ip_ifr_flags, IP_IFF_UP);
if (ipcom_socketioctl (fd, IP_SIOCSIFFLAGS,
&ifreq) < 0)
{
(void)ipcom_socketclose(fd);
return ERROR;
}
(void)ipcom_socketclose(fd);
}
}
return OK;
}
/******************************************************************************
*
* m2IfGroupInfoGet - get the MIB-II interface-group scalar variables
*
* This routine fills 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:
* m2IfInit(), m2IfTblEntryGet(), m2IfTblEntrySet(), m2IfDelete()
*/
STATUS m2IfGroupInfoGet
(
M2_INTERFACE * pIfInfo /* pointer to interface group structure */
)
{
#ifdef IPCOM_USE_INET
Ipcom_mib2_TimeStamp timeStp;
void *suspend_handle;
if (pIfInfo == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
/*
* Number of network interfaces in the system independent of
* their state
*/
IPNET_CODE_LOCK_M2_READ(suspend_handle);
pIfInfo->ifNumber = IPNET_NETIF_NUM_ATTACHED;
IPNET_CODE_M2_UNLOCK(suspend_handle);
if (ipcom_mib2_get_ipv4InterfaceTableLastChange(&timeStp) == -1 )
return (ERROR);
pIfInfo->ifTableLastChange = timeStp;
pIfInfo->ifStackLastChange = 0;
#endif
return OK;
}
/*
* The following function have not been implemented to support vxWorks-6.7
*/
STATUS m2IfRcvAddrEntryGet
(
int search, /* exact search or next search */
int * pIndex, /* pointer to the ifIndex */
M2_IFRCVADDRTBL * pIfReqEntry /* struct for the values */
)
{
return OK;
}
STATUS m2IfRcvAddrEntrySet
(
int varToSet, /* entries that need to be modified */
int index, /* search type */
M2_IFRCVADDRTBL * pIfReqEntry /* struct containing the new values */
)
{
return OK;
}
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 */
)
{
return OK;
}
@@ -0,0 +1,456 @@
/* m2Igmp.c - helper file for igmp Mib */
/* Copyright 2000 - 2005 Wind River Systems, Inc. */
/*
modification history
--------------------
01o,01apr05,kch Removed ROUTER_STACK define.
01n,02mar05,kc Fixed warning.
01m,12jan05,vvv osdep.h cleanup
01l,13sep04,rae fix hooks
01k,11aug04,rae fix VIRTUAL_STACK
01j,14jan03,rae Merged from velocecp branch
01i,11jul01,rae code clean up
01h,29mar01,spm file creation: copied from version 01g of tor2_0.open_stack
branch (wpwr VOB) for unified code base
01g,21jul00,gnn adjusted for include file move into a subdirectory of wrn
01f,20jul00,rae adjusted for move of src/WRN/include to h/wrn
01e,20jul00,rae added igmpMSem
01d,14jul00,rae turn off debug code
01c,22may00,kbw minor man page changes to allow refgen processing
01b,15may00,rae added VIRTUAL_STACK support
01a,08mar00,rae written
*/
/*
DESCRIPTION
This library provides an interface between the Berkeley multicast code
and the IGMP Mib code
INCLUDE FILES:
*/
/* includes */
#include "vxWorks.h"
#include "stdio.h"
#include "sysLib.h"
#include "logLib.h"
#include "semLib.h"
#include "errnoLib.h"
#include "stdlib.h"
#include "tickLib.h"
#include "m2Lib.h"
#include "netinet/in.h"
#include "netinet/in_var.h"
#include "netinet/igmp_var.h"
#include "net/protosw.h"
#include "IGMPv2/igmpR.h"
#include "IGMPv2/igmp_externs.h"
#include "IGMPv2/igmpRouterLib.h"
#include "IGMPv2/igmpPortLib.h"
#include "IGMPv2/igmpCacheLib.h"
#ifdef VIRTUAL_STACK
#include "netinet/vsLib.h"
#include "netinet/vsData.h"
#include "netinet/vsIgmpR.h"
#include "netinet/vsIgmp.h"
#endif
/* defines */
#define DEBUG noOperation /* change noOperation to printf for debugging */
/* externs */
/* globals */
#ifndef VIRTUAL_STACK
extern SEM_ID igmpMSem;
extern VOIDFUNCPTR _igmpJoinAlertHook;
extern VOIDFUNCPTR _igmpLeaveAlertHook;
extern VOIDFUNCPTR _igmpQuerierTimeUpdateHook;
#endif
/* locals */
/* forward declarations */
void igmpJoinAlert(int if_index);
void igmpLeaveAlert(int if_index);
void igmpQuerierTimeUpdate(int if_index, int time);
/*******************************************************************************
*
* noOperation - ignores its many arguments
*
* This do nothing code is replaced by printf, if debugging is enabled.
*
* NOMANUAL
*
* RETURNS: N/A
*/
void noOperation
(
const char *cptr_format,
...
)
{
}
/*******************************************************************************
*
* m2IgmpInit - fills in some hooks
*
* Fills in hooks with appropriate routines. For scalability.
*
* NOMANUAL
*
* RETURNS: OK always
*/
STATUS m2IgmpInit
(
void
)
{
_igmpJoinAlertHook = (VOIDFUNCPTR)igmpJoinAlert; /* fill in functions */
_igmpLeaveAlertHook = (VOIDFUNCPTR)igmpLeaveAlert;
_igmpQuerierTimeUpdateHook = (VOIDFUNCPTR)igmpQuerierTimeUpdate;
return (OK);
}
/*******************************************************************************
*
* m2IgmpCacheEntryGet - fills in M2_IGMP_CACHE struct with cache data
*
* Uses the cache address, and cache interface index to look up the cache entry
* associated with those values. Fills in provided structure with information
* from that entry.
*
* NOMANUAL
*
* RETURNS: OK or ERROR if if_index not valid
*/
STATUS m2IgmpCacheEntryGet
(
M2_IGMP_CACHE *pData /* this is filled in */
)
{
struct in_multi * inm;
struct ifnet * ifnet;
struct in_addr addr;
IGMP_GROUP_CLASS groupClass;
IGMP_GROUP_CLASS * pgroupClass = &groupClass;
if (igmpCacheGet (pData->igmpCacheAddress, pData->igmpCacheIfIndex,
(void*)&pgroupClass) != OK)
return ERROR;
if (pgroupClass == NULL)
{
DEBUG ("Null groupClass returned \n");
return ERROR;
}
if (semTake (igmpMSem, WAIT_FOREVER) == ERROR)
return ERROR;
addr.s_addr = htonl (pData->igmpCacheAddress);
if ((ifnet = portToIfnet (pgroupClass->port_number)) != NULL)
{
IN_LOOKUP_MULTI (addr, ifnet, inm); /* are we in this group? */
pData->igmpCacheSelf = inm ? M2_TRUE : M2_FALSE;
}
else
{
DEBUG ("lookup of ifnet failed on port %d\n", pgroupClass->port_number);
pData->igmpCacheSelf = M2_FALSE;
}
pData->igmpCacheLastReporter = pgroupClass->ip_address_of_last_reporter;
pData->igmpCacheUpTime = ((tickGet() - pgroupClass->start_time) * 100) /
sysClkRateGet();
if (pgroupClass->router_group.group_specific_timer.enabled)
pData->igmpCacheExpiryTime = (pgroupClass->
router_group.group_specific_timer.expiry_time -
pgroupClass->
router_group.group_specific_timer.second_counter) *
100;
else
pData->igmpCacheExpiryTime = 0;
pData->igmpCacheStatus = pgroupClass->enabled ? ROW_ACTIVE: ROW_NOTINSERVICE;
if (pgroupClass->router_group.v1_host_timer.enabled)
pData->igmpCacheVersion1HostTimer = (pgroupClass->
router_group.v1_host_timer.expiry_time -
pgroupClass->
router_group.v1_host_timer.second_counter) *
100;
else
pData->igmpCacheVersion1HostTimer = 0;
semGive (igmpMSem);
return OK;
}
/*******************************************************************************
*
* m2IgmpCacheEntryNextGet - fills in M2_IGMP_CACHE struct with cache data
*
* Uses the cache address, and cache interface index to look up the next cache entry
* lexicographically greater than those values. Fills in provided structure with
* information from that entry.
*
* NOMANUAL
*
* RETURNS: OK or ERROR if if_index not valid
*/
STATUS m2IgmpCacheEntryNextGet
(
M2_IGMP_CACHE *pData
)
{
UINT32 nextMcastAddr = 0;
UINT32 nextIfIndex =0;
IGMP_GROUP_CLASS groupClass;
IGMP_GROUP_CLASS * pGroupClass = &groupClass;
if (igmpCacheNextGet (pData->igmpCacheAddress, pData->igmpCacheIfIndex,
&nextMcastAddr, &nextIfIndex, (void*)&pGroupClass) != OK)
{
return ERROR;
}
pData->igmpCacheIfIndex = nextIfIndex;
pData->igmpCacheAddress = nextMcastAddr;
if (m2IgmpCacheEntryGet (pData) != OK)
{
return ERROR;
}
return OK;
}
/*******************************************************************************
*
* m2IgmpInterfaceEntryNextGet - fills in M2_IGMP struct with interface data
*
* Uses the compl argument (which is if_index) to look up the igmp port associated
* with the next interface. Fills in provided structure with information gathered
* from the interface.
*
* RETURNS: OK or ERROR if if_index not valid
*
* NOMANUAL
*/
STATUS m2IgmpInterfaceEntryNextGet
(
M2_IGMP * pData /* Interface Data structure */
)
{
UINT32 nextIndex;
UINT32 vif;
if (igmpPortNextGet (pData->igmpInterfaceIfIndex, &nextIndex, &vif) == ERROR)
{
DEBUG ("NextGet on if_index %d failed \n", (int)(pData->igmpInterfaceIfIndex));
return ERROR;
}
pData->igmpInterfaceIfIndex = nextIndex;
if (m2IgmpInterfaceEntryGet (pData) == ERROR)
{
DEBUG ("Get on index %d failed \n", nextIndex);
return ERROR;
}
return OK;
}
/*******************************************************************************
*
* m2IgmpInterfaceEntryGet - fills in M2_IGMP struct with interface data
*
* Uses the if_index to look up the igmp port associated
* with that interface. Fills in provided structure with information gathered
* from the interface.
*
* NOMANUAL
*
* RETURNS: OK or ERROR if if_index not valid
*/
STATUS m2IgmpInterfaceEntryGet
(
M2_IGMP *pData
)
{
UINT32 vif;
if (igmpPortGet (pData->igmpInterfaceIfIndex, &vif) == ERROR)
return ERROR;
if (semTake(igmpMSem, WAIT_FOREVER) == ERROR)
return ERROR;
pData->igmpInterfaceQueryInterval =
vs_igmp.port_table[vif].router_port.general_query_interval;
pData->igmpInterfaceStatus=
vs_igmp.port_table[vif].router_enabled ? ROW_ACTIVE : ROW_NOTINSERVICE;
pData->igmpInterfaceVersion=
vs_igmp.port_table[vif].version;
pData->igmpInterfaceQuerier=
vs_igmp.port_table[vif].igmpInterfaceEntry.igmpInterfaceQuerier;
pData->igmpInterfaceQueryMaxResponseTime=
vs_igmp.port_table[vif].router_port.general_query_max_response_time;
pData->igmpInterfaceQuerierPresentTimeout=
vs_igmp.port_table[vif].router_port.other_querier_present_timer.enabled ?
(vs_igmp.port_table[vif].router_port.other_querier_present_timer.expiry_time -
vs_igmp.port_table[vif].router_port.other_querier_present_timer.second_counter) *
100 : 0;
pData->igmpInterfaceVersion1QuerierTimer= /* updated by BSD code */
vs_igmp.port_table[vif].igmpInterfaceEntry.igmpInterfaceVersion1QuerierTimer;
pData->igmpInterfaceWrongVersionQueries=
vs_igmp.port_table[vif].igmpInterfaceEntry.igmpInterfaceWrongVersionQueries;
pData->igmpInterfaceJoins=
vs_igmp.port_table[vif].igmpInterfaceEntry.igmpInterfaceJoins;
pData->igmpInterfaceGroups=
vs_igmp.port_table[vif].igmpInterfaceEntry.igmpInterfaceGroups;
pData->igmpInterfaceRobustness=
vs_igmp.port_table[vif].robustness;
pData->igmpInterfaceQuerierUpTime=
((tickGet() -
vs_igmp.port_table[vif].igmpInterfaceEntry.igmpInterfaceQuerierUpTime) * 100) /
sysClkRateGet();
pData->igmpInterfaceLastMembQueryIntvl=
vs_igmp.port_table[vif].igmpInterfaceEntry.igmpInterfaceLastMembQueryIntvl;
semGive(igmpMSem);
return OK;
}
/*******************************************************************************
*
* m2IgmpInterfaceEntrySet - fills in interface data as per SNMP request
*
* Uses the if_index to look up the igmp port associated
* with that interface. Fills in interface structure with information provided
* by SNMP
*
* NOMANUAL
*
* RETURNS: OK or ERROR if if_index not valid
*/
STATUS m2IgmpInterfaceEntrySet
(
M2_IGMP *pData, /* the data from SNMP */
int varsToSet /* which of the above we really use */
)
{
UINT32 vif;
if (igmpPortGet (pData->igmpInterfaceIfIndex, &vif) == ERROR)
return ERROR;
if (semTake (igmpMSem, WAIT_FOREVER) == ERROR)
return ERROR;
if (varsToSet & M2_var_igmpInterfaceStatus)
{
/* bring if up or down */
}
if (varsToSet & M2_var_igmpInterfaceQueryInterval)
vs_igmp.port_table[vif].router_port.general_query_interval =
pData->igmpInterfaceQueryInterval;
if (varsToSet & M2_var_igmpInterfaceVersion)
vs_igmp.port_table[vif].version = pData->igmpInterfaceVersion;
if (varsToSet & M2_var_igmpInterfaceQueryMaxResponseTime)
vs_igmp.port_table[vif].router_port.general_query_max_response_time =
pData->igmpInterfaceQueryMaxResponseTime;
if (varsToSet & M2_var_igmpInterfaceRobustness)
vs_igmp.port_table[vif].robustness = pData->igmpInterfaceRobustness;
if (varsToSet & M2_var_igmpInterfaceLastMembQueryIntvl)
vs_igmp.port_table[vif].igmpInterfaceEntry.igmpInterfaceLastMembQueryIntvl =
pData->igmpInterfaceLastMembQueryIntvl;
semGive (igmpMSem);
return OK;
}
/******************************************************************************
*
* igmpJoinAlert - updates Mib variables on join
*
* Increments the igmpInterfaceJoins and igmpInterfaceGroups values on the given
* interface.
*
* RETURNS: N/A
*
* NOMANUAL
*/
void igmpJoinAlert
(
int if_index /* index of port on which to add */
)
{
UINT32 port;
if ((igmpPortGet (if_index, &port) == ERROR))
return;
semTake (igmpMSem, WAIT_FOREVER);
++vs_igmp.port_table[port].igmpInterfaceEntry.igmpInterfaceJoins;
++vs_igmp.port_table[port].igmpInterfaceEntry.igmpInterfaceGroups;
semGive (igmpMSem);
}
/******************************************************************************
*
* igmpLeaveAlert - update Mib variables on leave
*
* Decrements the igmpInterfaceGroups value on the given interface.
*
* RETURNS: N/A
*
* NOMANUAL
*/
void igmpLeaveAlert
(
int if_index /* index of port where leave occurred */
)
{
UINT32 port;
if ((igmpPortGet(if_index, &port) == ERROR))
return;
semTake (igmpMSem, WAIT_FOREVER);
--vs_igmp.port_table[port].igmpInterfaceEntry.igmpInterfaceGroups;
semGive (igmpMSem);
}
/******************************************************************************
*
* igmpQuerierTimeUpdate - update Mib variable for version one querier
*
* Sets the igmpInterfaceEntry.igmpInterfaceVersion1QuerierTimer to the
* new value.
*
* RETURNS: N/A
*
* NOMANUAL
*/
void igmpQuerierTimeUpdate
(
int if_index, /* index of port on which to add */
int time /* half seconds left until v1 querier timer expires */
)
{
UINT32 port;
if ((igmpPortGet (if_index, &port) == ERROR))
return;
if (time < 0) /* sanity check */
time = 0;
semTake (igmpMSem, WAIT_FOREVER);
vs_igmp.port_table[port].igmpInterfaceEntry.igmpInterfaceVersion1QuerierTimer =
(IGMP_AGE_THRESHOLD - time) * 100/PR_SLOWHZ;
semGive (igmpMSem);
/* must convert from halfs to hundredths */
}
File diff suppressed because it is too large Load Diff
@@ -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);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,222 @@
/* 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);
}
@@ -0,0 +1,667 @@
/* m2Ipv6MldLib.c - MIB-II IPv6 MLD-group API for SNMP agents */
/* Copyright 2002-2005 Wind River Systems, Inc. */
/*
modification history
--------------------
01k,12jan05,vvv osdep.h cleanup
01j,02feb04,pas changed for new avlLib without GENERIC_ARGUMENT.
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,24apr02,ant written
*/
/*
DESCRIPTION
This library provides MIB-II services for the MLD group for IPv6. It provides
routines to initialize the group, read the MLD Interface tables, MLD Cache
table and change the state of a MLD Cache Entry. 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_MLD
USING THIS LIBRARY
This library can be initialized and deleted by calling m2Ipv6MldInit() and
m2Ipv6MldDelete() respectively, if only the MLD group's services are needed.
If full IPv6 MIB-II support is used, this group and all other groups can be
initialized and deleted by calling m2Ipv6Init() and m2Ipv6Delete().
The MLD Interface Table is accessed in lexicographical order by calling
m2Ipv6MldIfTblEntryGet(). The first entry in the table can be accessed by
setting the table index to zero. The table index is the interface index. Every
other entry thereafter can be accessed by passing to m2Ipv6MldIfTblEntryGet()
the index retrieved in the previous invocation by giving M2_NEXT_VALUE as the
search parameter. For example:
.CS
M2_MLDINTERFACETBL mldIfEntry
/@ Specify a zero index to get the first entry in the table @/
mldIfEntry.mldInterfaceIfIndex = 0; /@ Interface index @/
/@ get the first entry in the table @/
if ((m2Ipv6MldIfTblEntryGet (M2_NEXT_VALUE, &mldIfEntry) == OK)
/@ values in mldIfEntry in the first entry are valid @/
/@ process first entry in the table @/
/@ get the second entry in the table @/
if ((m2Ipv6MldIfTblEntryGet (M2_NEXT_VALUE, &mldIfEntry) == OK)
/@ values in mldIfEntry in the second entry are valid @/
.CE
The MLD Cache Table is accessed in lexicographical order by calling
m2Ipv6MldCacheTblEntryGet(). The first entry in the table can be accessed by
setting the table index to zero. The table index is the 'mldCacheAddress' and
the 'mldCacheIfIndex'. Every other entry thereafter can be accessed by passing
to m2Ipv6MldCacheTblEntryGet() the index retrieved in the previous invocation
by giving M2_NEXT_VALUE as the search parameter. For example:
.CS
M2_MLDCACHETBL mldCacheEntry
/@ Specify a zero index to get the first entry in the table @/
/@ MLD Cache address @/
memset (mldCacheEntry.mldCacheAddress, 0, sizeof (struct in6_addr));
mldCacheEntry.mldCacheIfIndex = 0; /@ Interface index @/
/@ get the first entry in the table @/
if ((m2Ipv6MldCacheTblEntryGet (M2_NEXT_VALUE, &mldCacheEntry) == OK)
/@ values in mldCacheEntry in the first entry are valid @/
/@ process first entry in the table @/
/@ get the second entry in the table @/
if ((m2Ipv6MldCacheTblEntryGet (M2_NEXT_VALUE, &mldCacheEntry) == OK)
/@ values in mldCacheEntry in the second entry are valid @/
.CE
The MLD Cache Entry table allows an entry to be created as well as deleted as
specified in the MIB-II. For example:
.CS
M2_MLDCACHETBL mldCacheEntry;
char mldAddress[] = "FF02::9ABC";
/@ Fill in the index and the multicast to be listened to @/
/@ convert a presentation format address to a network format address @/
inet_pton (AF_INET6, mldAddress, mldCacheEntry.mldCacheAddress);
/@ MLD Cache address must be in host-byte order @/
NTOHL_IPV6ADDR (mldCacheEntry.mldCacheAddress);
mldCacheEntry.mldCacheIfIndex = 2; /@ interface with index 2 @/
mldCacheEntry.mldCacheStatus = ROW_CREATEANDGO; /@ state create and go @/
/@ set the entry in the table @/
/@ mldCacheEntry.mldCacheStatus = ROW_CREATEANDWAIT will have the same effect @/
if ((m2Ipv6MldCacheTblEntrySet (&mldCacheEntry) == OK)
/@ Cache Table entry created successfully @/
/@ deletion is done with ROW_DESTROY @/
.CE
INCLUDE FILES: m2Ipv6Lib.h
SEE ALSO:
m2Ipv6Lib, m2Ipv6IfLib, m2Ipv6IfIcmpLib, m2Ipv6TcpLib, m2Ipv6UdpLib */
/* includes */
#include <vxWorks.h>
#include <netconf.h>
#include <m2Lib.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <netinet/tcp_var.h>
#include "errnoLib.h"
#include <private/m2LibP.h>
#include <m2Ipv6Lib.h>
#include <protos/mld6_var.h>
#ifdef VIRTUAL_STACK
#include <netinet/vsLib.h>
#include <netinet/vsTcp.h>
#include <netinet/vsData.h>
#include <netinet/vsM2.h>
#include <vs/vsMld.h>
#endif /* VIRTUAL_STACK */
/* imports */
#ifndef VIRTUAL_STACK
extern SEM_ID m2InterfaceSem; /* defined in m2IfLib.c */
extern int ifsInList; /* defined in m2IfLib.c */
extern struct mld6QuerierHead _mld6Querier; /* defined in mld6.c */
extern BOOL mld6Enabled;
#endif /* VIRTUAL_STACK */
/* forward declaration */
/*******************************************************************************
*
* m2Ipv6MldInit - initialize MIB-II IPv6 MLD-group access
*
* This routine allocates the resources needed to allow access to the MIB-II
* MLD-group variables. This routine must be called before any MLD variables
* can be accessed.
*
* RETURNS: OK, always.
*
* SEE ALSO: m2Ipv6MldIfTblEntryGet(), m2Ipv6MldCacheTblEntryGet(),
* m2Ipv6MldCacheTblEntrySet(), m2Ipv6MldDelete(), m2Ipv6MldLib
*/
STATUS m2Ipv6MldInit (void)
{
return (OK);
}
/******************************************************************************
*
* m2Ipv6AddrCmp - compare two ipv6 addresses
*/
LOCAL int m2Ipv6AddrCmp
(
struct in6_addr * pAddr1,
struct in6_addr * pAddr2
)
{
int ix;
for (ix = 0; ix < 4; ix++)
{
if (pAddr1->s6_addr32[ix] > pAddr2->s6_addr32[ix])
return (1);
else if (pAddr1->s6_addr32[ix] < pAddr2->s6_addr32[ix])
return (-1);
}
return (0);
}
/*******************************************************************************
*
* m2Ipv6MldIfTblEntryGet - get a MIB-II MLD interface table entry
*
* This routine traverses the MLD interface table and does an M2_EXACT_VALUE
* or a M2_NEXT_VALUE search based on the <search> parameter (see m2Ipv6Lib).
* The calling routine is responsible for supplying a valid MIB-II entry index
* in the input structure <pMldIfEntry>. The index is the interface index.
* 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 <pMldIfEntry> is not specified or a match
* is not found.
*
* ERRNO:
* S_m2Lib_INVALID_PARAMETER
* S_m2Lib_ENTRY_NOT_FOUND
*
* SEE ALSO: m2Ipv6MldInit(), m2Ipv6MldCacheTblEntryGet(),
* m2Ipv6MldCacheTblEntrySet(), m2Ipv6MldDelete(), m2Ipv6MldLib
*/
STATUS m2Ipv6MldIfTblEntryGet
(
int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */
M2_MLDINTERFACETBL * pMldIfEntry /* ptr to the requested entry */
)
{
int index;
M2_IFINDEX * pIfIndexEntry = NULL;
BOOL found;
struct mld6Querier * pMld6QuerierSource;
/* Validate Pointer to MLD Interface Table Entry structure */
if (pMldIfEntry == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
semTake (m2InterfaceSem, WAIT_FOREVER);
/* First, Validate the bounds of the requested index */
index = pMldIfEntry->mldInterfaceIfIndex;
if (index > ifsInList || index < 0)
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
/* Check to see if it is a EXACT search or a next search */
if (search == M2_EXACT_VALUE)
{
pIfIndexEntry = m2Ipv6AvlSearch (pM2IfRoot, index);
}
else
{
pIfIndexEntry = m2Ipv6AvlSuccessorGet (pM2IfRoot, index);
}
if (!pIfIndexEntry)
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
pMldIfEntry->mldInterfaceIfIndex = pIfIndexEntry->ifIndex;
/* if mld6 not enabled fill Querier address to ::0 and status to
ROW_NOTINSERVICE, otherwise search the address in the
mld6Querier list */
if (mld6Enabled)
pMldIfEntry->mldInterfaceStatus = ROW_ACTIVE;
else
{
pMldIfEntry->mldInterfaceStatus = ROW_NOTINSERVICE;
memset (pMldIfEntry->mldInterfaceQuerier, 0x00,
sizeof (struct in6_addr));
semGive (m2InterfaceSem);
return (OK);
}
found = FALSE;
for (pMld6QuerierSource = _mld6Querier.tqh_first; pMld6QuerierSource;
pMld6QuerierSource = pMld6QuerierSource->mld6_link.tqe_next)
if (pMld6QuerierSource->mld6IfIndex == pMldIfEntry->mldInterfaceIfIndex)
{
memcpy (pMldIfEntry->mldInterfaceQuerier, &pMld6QuerierSource->mld6QuerierAddr, sizeof (struct in6_addr));
found = TRUE;
break;
}
/* mld6 is enabled, but listener has not received any query yet. */
if (!found)
memset (pMldIfEntry->mldInterfaceQuerier, 0x00, sizeof (struct in6_addr));
NTOHL_IPV6ADDR(pMldIfEntry->mldInterfaceQuerier);
semGive (m2InterfaceSem);
return (OK);
}
/*******************************************************************************
*
* m2Ipv6MldCacheTblEntryGet - get a MIB-II MLD cache table entry
*
* This routine traverses the MLD cache table and does an M2_EXACT_VALUE
* or a M2_NEXT_VALUE search based on the <search> parameter (see m2Ipv6Lib).
* The calling routine is responsible for supplying a valid MIB-II entry index
* in the input structure <pMldCacheEntry>. The index is made up of the IPv6
* multicast address, and the interface index. 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 <pMldCacheEntry> is not specified or
* a match is not found.
*
* ERRNO:
* S_m2Lib_INVALID_PARAMETER
* S_m2Lib_ENTRY_NOT_FOUND
*
* SEE ALSO: m2Ipv6MldInit(), m2Ipv6MldIfTblEntryGet(),
* m2Ipv6MldCacheTblEntrySet(), m2Ipv6MldDelete(), m2Ipv6MldLib
*/
STATUS m2Ipv6MldCacheTblEntryGet
(
int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */
M2_MLDCACHETBL * pMldCacheEntry /* ptr to the requested entry */
)
{
int index;
int reqIndex;
M2_IFINDEX * pIfIndexEntry = NULL;
struct in6_addr ip6Addr; /* Caller IPv6 address Table index req */
struct in6_addr currIp6Addr; /* Current IPv6 address Table index req */
struct in6_addr * pIp6Multi;
M2_MLDCACHETBL entrySaved; /* IPv6 address selected */
struct ifnet * pIfNetEntry = NULL;
struct ifmultiaddr *ifma;
BOOL found = FALSE;
/* Validate Pointer to MLD Cache Table Entry structure */
if (pMldCacheEntry == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
semTake (m2InterfaceSem, WAIT_FOREVER);
/* First, Validate the bounds of the requested index */
reqIndex = pMldCacheEntry->mldCacheIfIndex;
if (reqIndex > ifsInList || reqIndex < 0)
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
/* Requested IP address */
memcpy (&ip6Addr, pMldCacheEntry->mldCacheAddress,
sizeof (struct in6_addr));
/* Largest IP address */
memset (entrySaved.mldCacheAddress, 0xff, sizeof (struct in6_addr));
/* Largest ifIndex */
entrySaved.mldCacheIfIndex = ifsInList;
/* Check to see if it is a EXACT search or a next search */
if (search == M2_EXACT_VALUE)
{
pIfIndexEntry = m2Ipv6AvlSearch (pM2IfRoot, reqIndex);
if (!pIfIndexEntry)
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
pIfNetEntry = (struct ifnet *) pIfIndexEntry->pIfStats;
HTONL_IPV6ADDR(&ip6Addr);
/* search the address in the multicast addr list */
for (ifma = pIfNetEntry->if_multiaddrs.lh_first; ifma;
ifma = ifma->ifma_link.le_next)
{
if (ifma->ifma_addr->sa_family != AF_INET6)
continue;
pIp6Multi= &((struct sockaddr_in6 *)ifma->ifma_addr)->sin6_addr;
if (IN6_ARE_ADDR_EQUAL(&ip6Addr, pIp6Multi))
{
/*
* NOTE - condition in the method routine, create and
* wait not possible.
*/
memcpy (entrySaved.mldCacheAddress, pIp6Multi,
sizeof (struct in6_addr));
NTOHL_IPV6ADDR(entrySaved.mldCacheAddress);
entrySaved.mldCacheIfIndex = pIfIndexEntry->ifIndex;
found = TRUE;
break;
}
}
}
else /* M2_NEXT_VALUE */
{
/*
* Find the first IPv6 ifIndex in AVL tree and search the next
* address in all IPv6 interfaces.
*/
pIfIndexEntry = m2Ipv6AvlSuccessorGet (pM2IfRoot, 0);
if (!pIfIndexEntry)
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
do
{
index = pIfIndexEntry->ifIndex;
/* Get the pointer to the ifnet struct for this ifIndex */
pIfNetEntry = (struct ifnet *) pIfIndexEntry->pIfStats;
/*
* Go through the list, pick up IPV6 addresses and remember
* the first higher to the required one.
*/
for (ifma = pIfNetEntry->if_multiaddrs.lh_first; ifma;
ifma = ifma->ifma_link.le_next)
{
if (ifma->ifma_addr->sa_family != AF_INET6)
continue;
pIp6Multi= &((struct sockaddr_in6 *)ifma->ifma_addr)->sin6_addr;
memcpy (&currIp6Addr, pIp6Multi, sizeof (struct in6_addr));
NTOHL_IPV6ADDR(&currIp6Addr);
if (((m2Ipv6AddrCmp(&currIp6Addr, &ip6Addr) > 0) ||
((m2Ipv6AddrCmp(&currIp6Addr, &ip6Addr) == 0) &&
index > reqIndex)) &&
(m2Ipv6AddrCmp(&currIp6Addr, (struct in6_addr *)entrySaved.mldCacheAddress) < 0))
{
memcpy (entrySaved.mldCacheAddress, &currIp6Addr,
sizeof (struct in6_addr));
entrySaved.mldCacheIfIndex = index;
found = TRUE;
}
}
/* The required address was the biggest in the required ifIndex.
Move to the next ifIndex and choose the smallest one */
pIfIndexEntry = m2Ipv6AvlSuccessorGet (pM2IfRoot, index);
} while (pIfIndexEntry);
}
if (found) /* there was bigger address, otherwise try the next ifIndex */
{
memcpy (pMldCacheEntry->mldCacheAddress, entrySaved.mldCacheAddress,
sizeof (struct in6_addr));
pMldCacheEntry->mldCacheIfIndex = entrySaved.mldCacheIfIndex;
pMldCacheEntry->mldCacheSelf = M2_TRUE; /* TrueValue */
/*
* NOTE - condition in the method routine, create and
* wait not possible.
*/
pMldCacheEntry->mldCacheStatus = ROW_ACTIVE;
}
if (!found)
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
semGive (m2InterfaceSem);
return (OK);
}
/*******************************************************************************
*
* m2Ipv6MldCacheTblEntrySet - set a MIB-II MLD cache table entry
*
* This routine traverses the MLD cache entry table and searches for the entry
* specified in the input parameter <pMldCacheEntry>. The calling routine is
* responsible for providing a valid index as the input parameter <pMldCacheEntry>.
* The index is made up of the multicast address and the interface index. An entry
* can be added by setting the status field in the input parameter
* <pMldCacheEntry> to the MIB-II value ROW_CREATEANDGO or ROW_CREATEANDWAIT.
* An entry is deleted by setting the status to the MIB-II value ROW_NOTINSERVICE,
* or ROW_NOTREADY, or ROW_DESTROY.
*
* 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
* S_m2Lib_BAD_VALUE
* S_m2Lib_GEN_ERR
*
* SEE ALSO: m2Ipv6MldInit(), m2Ipv6MldIfTblEntryGet(),
* m2Ipv6MldCacheTblEntryGet(), m2Ipv6MldDelete(), m2Ipv6MldLib
*/
STATUS m2Ipv6MldCacheTblEntrySet
(
M2_MLDCACHETBL * pMldCacheEntry /* ptr to the requested entry */
)
{
int index;
M2_IFINDEX * pIfIndexEntry = NULL;
struct in6_addr ip6Addr; /* Caller IPv6 address Table index req */
struct ifnet * pIfNetEntry = NULL;
int error = 0;
struct in6_multi * in6m;
/* Validate Pointer to mld Cache Table Entry structure */
if (pMldCacheEntry == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
semTake (m2InterfaceSem, WAIT_FOREVER);
/* First, Validate the bounds of the requested index */
index = pMldCacheEntry->mldCacheIfIndex;
if (index > ifsInList || index < 0)
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
/* Requested IP address */
memcpy (&ip6Addr, pMldCacheEntry->mldCacheAddress,
sizeof (struct in6_addr));
/* open issue IPv6 interface table */
pIfIndexEntry = m2Ipv6AvlSearch (pM2IfRoot, index);
if (!pIfIndexEntry)
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
pIfNetEntry = (struct ifnet *) pIfIndexEntry->pIfStats;
HTONL_IPV6ADDR(&ip6Addr);
switch (pMldCacheEntry->mldCacheStatus)
{
case ROW_CREATEANDGO:
case ROW_CREATEANDWAIT:
(void)in6_addmulti(&ip6Addr, pIfNetEntry, &error);
if (error != 0)
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_GEN_ERR);
return (ERROR);
}
break;
case ROW_NOTINSERVICE:
case ROW_NOTREADY:
case ROW_DESTROY:
IN6_LOOKUP_MULTI(ip6Addr, pIfNetEntry, in6m);
if (in6m)
{
in6_delmulti(in6m);
semGive (m2InterfaceSem);
return (OK);
}
else
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
break;
case ROW_ACTIVE:
IN6_LOOKUP_MULTI(ip6Addr, pIfNetEntry, in6m);
if (in6m)
{
semGive (m2InterfaceSem);
return (OK);
}
else
{
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
break;
default:
semGive (m2InterfaceSem);
errnoSet (S_m2Lib_BAD_VALUE);
return (ERROR);
}
semGive (m2InterfaceSem);
return (OK);
}
/*******************************************************************************
*
* m2Ipv6MldDelete - delete all resources used to access the MLD group
*
* This routine frees all the resources allocated at the time the MLD group was
* initialized. The MLD group should not be accessed after this routine has
* been called.
*
* RETURNS: OK, always.
*
* SEE ALSO: m2Ipv6MldInit(), m2Ipv6MldIfTblEntryGet(),
* m2Ipv6MldCacheTblEntryGet(), m2Ipv6MldCacheTblEntrySet(), m2Ipv6MldLib
*/
STATUS m2Ipv6MldDelete (void)
{
return (OK);
}
@@ -0,0 +1,599 @@
/* m2Ipv6TcpLib.c - MIB-II IPv6 TCP-group API for SNMP agents */
/*
* Copyright (c) 1984-2005 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01n,11apr05,sar Removed hz as it wasn't being used.
01m,25feb05,niq fix compiler warnings
01l,12jan05,vvv osdep.h cleanup
01k,26aug04,niq unified stack merge
01j,02jun04,rp removed extern declaration of fdTable
01i,23apr04,rp ported changes from m2TcpLib.c ver 01u
01h,02feb04,pas fixed header paths
01g,05deco3,xli change include path
01f,20nov03,niq osdep.h cleanup
01d,06nov03,rlm Ran batch header update for header re-org.
01c,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
01b,11jul02,qli provide vxworks version guard on fdTable
01a,20mar02,ant taken from m2TcpLib.c
*/
/*
DESCRIPTION
This library provides MIB-II services for the TCP group for IPv6. It provides
routines to initialize the group, read the table of IPv6 TCP connections, and
change the state of a IPv6 TCP connection. 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_TCPV6
USING THIS LIBRARY
This library can be initialized and deleted by calling m2Ipv6TcpInit() and
m2Ipv6TcpDelete() respectively, if only the IPv6 TCP group's services are needed.
If full IPv6 MIB-II support is used, this group and all other groups can be
initialized and deleted by calling m2Ipv6Init() and m2Ipv6Delete().
The IPv6 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
m2Ipv6TcpConnEntryGet() the index retrieved in the previous invocation
by giving M2_NEXT_VALUE as the search parameter. For example:
.CS
M2_IPV6TCPCONNTBL tcpEntry;
/@ Specify a zero index to get the first entry in the table @/
/@ Local IPv6 address in host byte order @/
memset (tcpEntry.ipv6tcpConnLocalAddress, 0, sizeof (struct in6_addr));
tcpEntry.ipv6tcpConnLocalPort = 0; /@ local TCP port in host byte order @/
/@ Remote IPv6 address in host byte order @/
memset (tcpEntry.ipv6tcpConnRemAddress, 0, sizeof (struct in6_addr));
tcpEntry.ipv6tcpConnRemPort = 0; /@ remote TCP port in host byte order @/
/@ get the first entry in the table @/
if ((m2Ipv6TcpConnEntryGet (M2_NEXT_VALUE, &tcpEntry) == OK)
/@ values in tcpEntry in the first entry are valid @/
/@ process first entry in the table @/
/@ get the second entry in the table @/
if ((m2Ipv6TcpConnEntryGet (M2_NEXT_VALUE, &tcpEntry) == OK)
/@ values in tcpEntry in the second entry are valid @/
.CE
The IPv6 TCP table of connections allows only for a connection to be deleted as
specified in the MIB-II. For example:
.CS
M2_IPV6TCPCONNTBL tcpEntry;
char tcpLocalAddr[] = "3000::40";
char tcpRemAddr[] = "3000::42";
/@ Fill in the index for the connection to be deleted in the table @/
/@ Local IPv6 address in host byte order, and local port number @/
/@ convert a presentation format address to a network format address @/
inet_pton (AF_INET6, tcpLocalAddr, tcpEntry.ipv6tcpConnLocalAddress);
NTOHL_IPV6ADDR (tcpEntry.ipv6tcpConnLocalAddress);
tcpEntry.ipv6tcpConnLocalPort = 3000;
/@ Remote IPv6 address in host byte order, and remote port number @/
/@ convert a presentation format address to a network format address @/
inet_pton (AF_INET6, tcpRemAddr, tcpEntry.ipv6tcpConnRemAddress);
NTOHL_IPV6ADDR (tcpEntry.ipv6tcpConnRemAddress);
tcpEntry.ipv6tcpConnRemPort = 3000;
tcpEntry.ipv6tcpConnState = 12; /@ MIB-II state value for delete @/
/@ set the entry in the table @/
if ((m2Ipv6TcpConnEntrySet (&tcpEntry) == OK)
/@ tcpEntry deleted successfuly @/
.CE
INCLUDE FILES: m2Ipv6Lib.h
SEE ALSO:
m2Ipv6Lib, m2Ipv6IfLib, m2Ipv6IfIcmpLib, m2Ipv6UdpLib, m2Ipv6MldLib
*/
/* includes */
#include <vxWorks.h>
#include <limits.h>
#include <errnoLib.h>
#include <netconf.h>
#include <m2Lib.h>
#include <sys/socket.h>
#include <net/socketvar.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/in_pcb.h>
#include <netinet6/in6_pcb.h>
#include <net/protosw.h>
#if _WRS_VXWORKS_MAJOR >= 6
# include <iosLib.h> /* base6 */
# include <sockFunc.h>
#else
# include <private/iosLibP.h> /* pre-base6 */
#endif
#include <m2Ipv6Lib.h>
#ifdef VIRTUAL_STACK
#include <netinet/vsLib.h>
#include <netinet/vsTcp.h>
#include <netinet/vsData.h>
#endif
/* defines */
/* MIB-II TCP state definitions */
#define M2TCP_CLOSED 1
#define M2TCP_LISTEN 2
#define M2TCP_SYNSENT 3
#define M2TCP_SYNRECEIVED 4
#define M2TCP_ESTABLISHED 5
#define M2TCP_FINWAIT1 6
#define M2TCP_FINWAIT2 7
#define M2TCP_CLOSEWAIT 8
#define M2TCP_LASTACK 9
#define M2TCP_CLOSING 10
#define M2TCP_TIMEWAIT 11
#define M2TCP_DELETETCB 12
/* globals */
/* external declarations */
#ifndef VIRTUAL_STACK
extern struct inpcbhead tcb; /* defined in tcp_input.c */
#endif /* VIRTUAL_STACK */
/*
* This table maps the BSD TCP states to the MIB-II TCP specified states. The
* table is indexed using the BSD TCP states.
*/
LOCAL long m2TcpStates [TCP_NSTATES] =
{
M2TCP_CLOSED, /* TCPS_CLOSED -> M2TCP_CLOSED */
M2TCP_LISTEN, /* TCPS_LISTEN -> M2TCP_LISTEN */
M2TCP_SYNSENT, /* TCPS_SYN_SENT -> M2TCP_SYNSENT */
M2TCP_SYNRECEIVED, /* TCPS_SYN_RECEIVED -> M2TCP_SYNRECEIVED */
M2TCP_ESTABLISHED, /* TCPS_ESTABLISHED -> M2TCP_ESTABLISHED */
M2TCP_CLOSEWAIT, /* TCPS_CLOSE_WAIT -> M2TCP_CLOSEWAIT */
M2TCP_FINWAIT1, /* TCPS_FIN_WAIT_1 -> M2TCP_FINWAIT1 */
M2TCP_CLOSING, /* TCPS_CLOSING -> M2TCP_CLOSING */
M2TCP_LASTACK, /* TCPS_LAST_ACK -> M2TCP_LASTACK */
M2TCP_FINWAIT2, /* TCPS_FIN_WAIT_2 -> M2TCP_FINWAIT2 */
M2TCP_TIMEWAIT, /* TCPS_TIME_WAIT -> M2TCP_TIMEWAIT */
};
/*******************************************************************************
*
* m2Ipv6TcpInit - initialize MIB-II IPv6 TCP-group access
*
* This routine allocates the resources needed to allow access to the IPv6 MIB-II
* TCP-group variables. This routine must be called before any IPv6 TCP variables
* can be accessed.
*
* RETURNS: OK, always.
*
* SEE ALSO: m2Ipv6TcpConnEntryGet(), m2Ipv6TcpConnEntrySet(), m2Ipv6TcpDelete()
*/
STATUS m2Ipv6TcpInit (void)
{
return (OK);
}
/******************************************************************************
*
* m2Ipv6AddrCmp - compare two ipv6 addresses
*/
LOCAL int m2Ipv6AddrCmp
(
struct in6_addr * addr1,
struct in6_addr * addr2
)
{
int ix;
for (ix = 0; ix < 4; ix++)
{
if (addr1->s6_addr32[ix] > addr2->s6_addr32[ix])
return (1);
else if (addr1->s6_addr32[ix] < addr2->s6_addr32[ix])
return (-1);
}
return (0);
}
/******************************************************************************
*
* m2Ipv6TcpConnCmp - compare two IPv6 TCP connections in lexicographical order
*
* This routine compares two IPv6 TCP connection control blocks. It compares the
* value 1 with value 2. It returns equal, value 1 greater than
* value 2, or value 1 less than value 2. The comparison is done based on the
* lexicographical order specified by MIB-II.
*
* RETURNS: 0 = equal, 1 > greater than, and -1 < less than.
*
* SEE ALSO: N/A
*/
LOCAL int m2Ipv6TcpConnCmp
(
M2_IPV6TCPCONNTBL * pConnVal1, /* pointer to table entry (Compare against) */
M2_IPV6TCPCONNTBL * pConnVal2 /* pointer to table entry (Second entry) */
)
{
int result;
/* Comparison of two IPv6 addresses */
result = m2Ipv6AddrCmp((struct in6_addr *)pConnVal1->ipv6TcpConnLocalAddress,
(struct in6_addr *)pConnVal2->ipv6TcpConnLocalAddress);
if (result > 0)
{
return 1; /* First Entry is Greater */
}
if (result < 0)
{
return -1; /* First Entry is Smaller */
}
/* Comparison of two signed values */
result = pConnVal1->ipv6TcpConnLocalPort - pConnVal2->ipv6TcpConnLocalPort;
if (result != 0)
return (result); /* Value > 0 or < 0 */
/* Comparison of two ipv6 addresses */
result = m2Ipv6AddrCmp((struct in6_addr *)pConnVal1->ipv6TcpConnRemAddress,
(struct in6_addr *)pConnVal2->ipv6TcpConnRemAddress);
if (result > 0)
{
return 1; /* First Entry is Greater */
}
if (result < 0)
{
return -1; /* First Entry is Smaller */
}
/* Comparison of two signed values */
result = pConnVal1->ipv6TcpConnRemPort - pConnVal2->ipv6TcpConnRemPort;
if (result != 0)
return (result); /* Value > 0 or < 0 */
/* Result will determine Equal, Less than or Greater than */
return (pConnVal1->ipv6TcpConnIfIndex - pConnVal2->ipv6TcpConnIfIndex);
}
/******************************************************************************
*
* m2Ipv6TcpConnEntryGet - get a MIB-II IPV6 TCP connection table entry
*
* This routine traverses the IPv6 TCP table and does an M2_EXACT_VALUE or
* a M2_NEXT_VALUE search based on the <search> parameter (see m2Ipv6Lib). 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
* IPv6 address, the local port number, the remote IPv6 address, the remote
* port, and the 'ipv6TcpConnIfIndex'. 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 <pReqTcpConnEntry> is not specified or a
* match is not found.
*
* ERRNO:
* S_m2Lib_INVALID_PARAMETER
* S_m2Lib_ENTRY_NOT_FOUND
*
* SEE ALSO: m2Ipv6TcpInit(), m2Ipv6TcpConnEntrySet(), m2Ipv6TcpDelete(),
* m2Ipv6TcpLib
*/
STATUS m2Ipv6TcpConnEntryGet
(
int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */
M2_IPV6TCPCONNTBL * pReqTcpConnEntry /* input = Index, Output = Entry */
)
{
M2_IPV6TCPCONNTBL savedEntry; /* Use to save the table entry to return */
M2_IPV6TCPCONNTBL tableEntry; /* Use to test an entry in the table */
int netLock; /* Use to secure the Network Code Access */
struct inpcb * pPcb; /* Pointer to an entry in TCP Connection List */
/* Validate Pointer to IPv6 TCP Table Entry structure */
if (pReqTcpConnEntry == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
/* Setup structure used in the search for the requested TCP entry */
savedEntry.ipv6TcpConnState = TCP_NSTATES; /* Invalid TCP State */
/* Largest local IPv6 Addr */
memset (savedEntry.ipv6TcpConnLocalAddress, 0xff, sizeof (struct in6_addr));
savedEntry.ipv6TcpConnLocalPort = -1; /* Largest local port */
/* Largest Remote IPv6 Addr */
memset (savedEntry.ipv6TcpConnRemAddress, 0xff, sizeof (struct in6_addr));
savedEntry.ipv6TcpConnRemPort = -1; /* Largest Remote Port */
savedEntry.ipv6TcpConnIfIndex = -1; /* Largest ifIndex */
netLock = splnet (); /* Get exclusive access to Network Code */
/*
* Traverse the circular list of TCP control blocks. The first item in the
* list is a dummy header, skip it and used it as the loop exit condition.
*/
for (pPcb = tcb.lh_first; pPcb != NULL; pPcb = pPcb->inp_list.le_next)
{
if ((pPcb->inp_vflag & INP_IPV6) == 0) /* check only IPv6 blocks */
continue;
/* Convert control block format into a more convenient format */
memcpy (tableEntry.ipv6TcpConnLocalAddress, &pPcb->in6p_laddr,
sizeof (struct in6_addr));
NTOHL_IPV6ADDR(tableEntry.ipv6TcpConnLocalAddress);
tableEntry.ipv6TcpConnLocalPort = ntohs(pPcb->inp_lport);
memcpy (tableEntry.ipv6TcpConnRemAddress, &pPcb->in6p_faddr,
sizeof (struct in6_addr));
NTOHL_IPV6ADDR(tableEntry.ipv6TcpConnRemAddress);
tableEntry.ipv6TcpConnRemPort = ntohs(pPcb->inp_fport);
tableEntry.ipv6TcpConnIfIndex = pPcb->inp6_ifindex;
if (search == M2_EXACT_VALUE &&
(m2Ipv6TcpConnCmp(&tableEntry, pReqTcpConnEntry) == 0))
{
/* Match, map the connection state to MIB-II format and exit */
pReqTcpConnEntry->ipv6TcpConnState =
m2TcpStates [((struct tcpcb *) pPcb->inp_ppcb)->t_state];
splx (netLock); /* Give up exclusive access to Network Code */
return (OK);
}
else
{
/*
* A NEXT search is satisfied by an entry that is lexicographicaly
* greater than the input TCP connection entry. Because the TCP
* connection list is not in order, the list must be traverse
* completly before a selection is made. The rules for a
* lexicographical comparison are built in the routine
* m2Ipv6TcpConnCmp().
*/
if ((m2Ipv6TcpConnCmp(&tableEntry, pReqTcpConnEntry) > 0) &&
(m2Ipv6TcpConnCmp(&tableEntry, &savedEntry) < 0))
{
memcpy (savedEntry.ipv6TcpConnLocalAddress, &pPcb->in6p_laddr,
sizeof (struct in6_addr));
NTOHL_IPV6ADDR(savedEntry.ipv6TcpConnLocalAddress);
savedEntry.ipv6TcpConnLocalPort = ntohs(pPcb->inp_lport);
memcpy (savedEntry.ipv6TcpConnRemAddress, &pPcb->in6p_faddr,
sizeof (struct in6_addr));
NTOHL_IPV6ADDR(savedEntry.ipv6TcpConnRemAddress);
savedEntry.ipv6TcpConnRemPort = ntohs(pPcb->inp_fport);
savedEntry.ipv6TcpConnIfIndex = pPcb->inp6_ifindex;
/* Save the connection state in BSD format */
savedEntry.ipv6TcpConnState =
((struct tcpcb *) pPcb->inp_ppcb)->t_state;
}
}
}
splx (netLock); /* Give up exclusive access to Network Code */
if (savedEntry.ipv6TcpConnState == TCP_NSTATES)
{
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR); /* Requested Entry Not Found */
}
pReqTcpConnEntry->ipv6TcpConnState = m2TcpStates [savedEntry.ipv6TcpConnState];
memcpy (pReqTcpConnEntry->ipv6TcpConnLocalAddress, savedEntry.ipv6TcpConnLocalAddress,
sizeof (struct in6_addr));
pReqTcpConnEntry->ipv6TcpConnLocalPort = savedEntry.ipv6TcpConnLocalPort;
memcpy (pReqTcpConnEntry->ipv6TcpConnRemAddress, savedEntry.ipv6TcpConnRemAddress,
sizeof (struct in6_addr));
pReqTcpConnEntry->ipv6TcpConnRemPort = savedEntry.ipv6TcpConnRemPort;
pReqTcpConnEntry->ipv6TcpConnIfIndex = savedEntry.ipv6TcpConnIfIndex;
return (OK);
}
/******************************************************************************
*
* m2Ipv6TcpConnEntrySet - set a MIB-II IPv6 TCP connection to the closed state
*
* This routine traverses the IPv6 TCP connection table and searches for the
* connection specified in 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 IPv6 address, the local port number, the remote IPv6 address,
* the remote port, and the 'ipv6TcpConnIfIndex'. 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 IPv6 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.
*
* ERRNO:
* S_m2Lib_INVALID_PARAMETER
* S_m2Lib_ENTRY_NOT_FOUND
* S_m2Lib_TCPCONN_FD_NOT_FOUND
*
* SEE ALSO: m2Ipv6TcpInit(), m2Ipv6TcpConnEntryGet(), m2Ipv6TcpDelete(),
* m2Ipv6TcpLib
*/
STATUS m2Ipv6TcpConnEntrySet
(
M2_IPV6TCPCONNTBL * pReqTcpConnEntry /* pointer to TCP connection to close */
)
{
int fdToClose; /* Selected File Descriptor to close */
int netLock; /* Use to secure the Network Code Access */
struct inpcb * pInp; /* Pointer to BSD PCB list */
struct in6_addr loc_addr; /* Local IPv6 Address structure */
struct in6_addr rem_addr; /* Remote IPv6 Address structure */
unsigned short locPort;
unsigned short remPort;
int maxFd;
#ifndef _WRS_VXWORKS_MAJOR /* pre-base6 */
extern int maxFiles;
#endif
/* Validate Pointer to IPv6 TCP Table Entry structure and operation */
if (pReqTcpConnEntry == NULL ||
pReqTcpConnEntry->ipv6TcpConnState != M2TCP_DELETETCB)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
/* Look for the Internet Control Block which maps to the TCP Entry */
locPort = pReqTcpConnEntry->ipv6TcpConnLocalPort;
remPort = pReqTcpConnEntry->ipv6TcpConnRemPort;
memcpy (&loc_addr, pReqTcpConnEntry->ipv6TcpConnLocalAddress,
sizeof (struct in6_addr));
HTONL_IPV6ADDR(&loc_addr);
locPort = htons(locPort);
memcpy (&rem_addr, pReqTcpConnEntry->ipv6TcpConnRemAddress,
sizeof (struct in6_addr));
HTONL_IPV6ADDR(&rem_addr);
remPort = htons(remPort);
netLock = splnet (); /* Get exclusive access to Network Code */
/* ifIndex, ipv6TcpConnIfIndex ??? */
if ((pInp = in6_pcblookup_hash (&tcbinfo, &rem_addr,
remPort, &loc_addr, locPort, 0, NULL)) == NULL)
{
splx (netLock); /* Give up exclusive access to Network Code */
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR); /* Entry not found */
}
splx (netLock); /* Give up exclusive access to Network Code */
#if _WRS_VXWORKS_MAJOR >= 6
maxFd = iosFdMaxFiles (); /* base6 */
#else
maxFd = maxFiles; /* pre-base6 */
#endif
/* Look for the FD to issue close in the File Descriptor Table */
for (fdToClose = 0; fdToClose < maxFd ; fdToClose++)
{
#if _WRS_VXWORKS_MAJOR >= 6
/* base 6 */
if (iosFdDrvValue(fdToClose, socketDevHdr.drvNum)
== (int)pInp->inp_socket)
break;
#else
/* pre-base6 */
if (fdTable [fdToClose].value == (int) pInp->inp_socket)
break;
#endif
}
if (fdToClose >= maxFd)
{
errnoSet (S_m2Lib_TCPCONN_FD_NOT_FOUND);
return (ERROR);
}
/* Issue Close */
#ifndef _WRS_VXWORKS_MAJOR
fdToClose = STD_FIX(fdToClose);
#endif
return (close (fdToClose));
}
/*******************************************************************************
*
* m2Ipv6TcpDelete - delete all resources used to access the IPv6 TCP group
*
* This routine frees all the resources allocated at the time the group was
* initialized. The IPv6 TCP group should not be accessed after this routine has
* been called.
*
* RETURNS: OK, always.
*
* SEE ALSO: m2Ipv6TcpInit(), m2Ipv6TcpConnEntryGet(), m2Ipv6TcpConnEntrySet(),
* m2Ipv6TcpLib
*/
STATUS m2Ipv6TcpDelete (void)
{
return (OK);
}
@@ -0,0 +1,315 @@
/* m2Ipv6UdpLib.c - MIB-II IPv6 UDP-group API for SNMP agents */
/* Copyright 1984 - 2003 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01d,12jan05,vvv osdep.h cleanup
01c,06nov03,rlm Ran batch header update for header re-org.
01b,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
01a,20mar02,ant taken from m2UdpLib.c
*/
/*
DESCRIPTION
This library provides MIB-II services for the UDP group for IPv6. It provides
routines to initialize the group, and read the table of IPv6 UDP listeners. 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_UDPV6
USING THIS LIBRARY
This library can be initialized and deleted by calling m2Ipv6UdpInit() and
m2Ipv6UdpDelete() respectively, if only the IPv6 UDP 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 IPv6 UDP table of listeners can be accessed in lexicographical order.
The first entry in the table can be accessed by setting the table index to zero
in a call to m2Ipv6UdpTblEntryGet(). Every other entry thereafter can be
accessed by repeatedly calling m2Ipv6UdpTblEntryGet() with the M2_NEXT_VALUE
constant as the search parameter. For example:
.CS
M2_IPV6UDPTBL udpEntry;
/@ Specify zero index to get the first entry in the table @/
/@ local IPv6 Address in host byte order @/
memset (udpEntry.ipv6udpLocalAddress, 0, sizeof (struct in6_addr));
udpEntry.ipv6udpLocalPort = 0; /@ local port number in host byte order @/
/@ get the first entry in the table @/
if ((m2Ipv6UdpTblEntryGet (M2_NEXT_VALUE, &udpEntry) == OK)
/@ values in udpEntry in the first entry are valid @/
/@ process first entry in the table @/
/@ get the second entry in the table @/
if ((m2Ipv6UdpTblEntryGet (M2_NEXT_VALUE, &udpEntry) == OK)
/@ values in udpEntry in the second entry are valid @/
.CE
INCLUDE FILES: m2Ipv6Lib.h
SEE ALSO:
m2Ipv6Lib, m2Ipv6IfLib, m2Ipv6IfIcmpLib, m2Ipv6TcpLib, m2Ipv6MldLib
*/
/* includes */
#include <vxWorks.h>
#include <netconf.h>
#include <vwModNum.h>
#include <m2Lib.h>
#include <sys/socket.h>
#include <net/route.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/in_pcb.h>
#include "errnoLib.h"
#include <m2Ipv6Lib.h>
#ifdef VIRTUAL_STACK
#include <netinet/vsLib.h>
#include <netinet/vsUdp.h>
#include <netinet/vsData.h>
#endif /* VIRTUAL_STACK */
/* external declarations */
#ifndef VIRTUAL_STACK
extern struct udpstat udpstat; /* UDP statistics variable */
extern struct inpcbhead udb; /* UDP link list of listen requests */
#endif /* VIRTUAL_STACK */
/*******************************************************************************
*
* m2Ipv6UdpInit - initialize MIB-II IPv6 UDP-group access
*
* This routine allocates the resources needed to allow access to the IPv6 UDP
* MIB-II variables. This routine must be called before any IPv6 UDP variables
* can be accessed.
*
* RETURNS: OK, always.
*
* SEE ALSO: m2Ipv6UdpTblEntryGet(), m2Ipv6UdpDelete()
*/
STATUS m2Ipv6UdpInit (void)
{
return (OK);
}
/******************************************************************************
*
* m2Ipv6AddrCmp - compare two ipv6 addresses
*/
LOCAL int m2Ipv6AddrCmp
(
struct in6_addr * pAddr1,
struct in6_addr * pAddr2
)
{
int ix;
for (ix = 0; ix < 4; ix++)
{
if (pAddr1->s6_addr32[ix] > pAddr2->s6_addr32[ix])
return (1);
else if (pAddr1->s6_addr32[ix] < pAddr2->s6_addr32[ix])
return (-1);
}
return (0);
}
/******************************************************************************
*
* m2Ipv6UdpCmp - compare two entry indexes of the IPv6 UDP listeners table
*
* RETURNS: 0 = equal, 1 > greater than, and -1 < less than.
*
* SEE ALSO: N/A
*/
LOCAL int m2Ipv6UdpCmp
(
M2_IPV6UDPTBL * pVal1, /* pointer to UDP table entry (Compare againts) */
M2_IPV6UDPTBL * pVal2 /* pointer to UDP table entry (Second entry) */
)
{
int result;
/* Comparison of two IPv6 addresses */
result = m2Ipv6AddrCmp((struct in6_addr *)pVal1->ipv6UdpLocalAddress,
(struct in6_addr *)pVal2->ipv6UdpLocalAddress);
if (result > 0)
{
return 1; /* First Entry is Greater */
}
if (result < 0)
{
return -1; /* First Entry is Smaller */
}
/* Comparison of two signed values */
result = pVal1->ipv6UdpLocalPort - pVal2->ipv6UdpLocalPort;
if (result != 0)
return (result); /* Value > 0 or < 0 */
/* Result will determine Equal, Less than or Greater than */
return (pVal1->ipv6UdpIfIndex - pVal2->ipv6UdpIfIndex);
}
/*******************************************************************************
*
* m2Ipv6UdpTblEntryGet - get a MIB-II IPv6 UDP listener table entry
*
* This routine traverses the IPv6 UDP 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
* <pUdpEntry>. The index is made up of the IPv6 address, the local port number,
* and the 'ipv6UdpIfIndex'. 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: m2Ipv6UdpInit(), m2Ipv6UdpDelete(), m2Ipv6UdpLib
*/
STATUS m2Ipv6UdpTblEntryGet
(
int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */
M2_IPV6UDPTBL * pUdpEntry /* ptr to the requested entry */
)
{
M2_IPV6UDPTBL savedEntry; /* Possible M2_NEXT_VALUE Entry in UDP */
/* table */
M2_IPV6UDPTBL currEntry;
int netLock; /* Use to secure the Network Code Access */
struct inpcb * pPcb; /* Pointer to UDP Listener structure. */
/* Validate Pointer to UDP Table Entry structure */
if (pUdpEntry == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
/*
* Initialize Entry for M2_NEXT_VALUE entry search. Not used in
* M2_EXACT_VALUE search.
*/
/* Largest possible value. */
memset (savedEntry.ipv6UdpLocalAddress, 0xff, sizeof (struct in6_addr));
savedEntry.ipv6UdpLocalPort = -1; /* Largest possible value. */
savedEntry.ipv6UdpIfIndex = -1; /* Largest ifIndex */
netLock = splnet (); /* Get exclusive access to Network Code */
for (pPcb = udb.lh_first; pPcb != NULL; pPcb = pPcb->inp_list.le_next )
{
if ((pPcb->inp_vflag & INP_IPV6) == 0) /* check only ipv6 blocks */
continue;
memcpy (currEntry.ipv6UdpLocalAddress, &pPcb->in6p_laddr, sizeof (struct in6_addr));
NTOHL_IPV6ADDR(currEntry.ipv6UdpLocalAddress);
currEntry.ipv6UdpLocalPort = ntohs (pPcb->inp_lport);
currEntry.ipv6UdpIfIndex = pPcb->inp6_ifindex;
if (search == M2_EXACT_VALUE)
{
/* Check that the specified index matches the current entry */
if (m2Ipv6UdpCmp(&currEntry, pUdpEntry) == 0)
{
splx (netLock); /* Give up exclusive access to Network Code */
return (OK); /* The answer is in the structure pUdpEntry */
}
}
else
{
/*
* A NEXT search is satisfied by an entry that is lexicographicaly
* equal to or greater than the input UDP connection entry. Because
* the UDP connection list is not in order, the list must be
* traverse completely before a selection is made. The rules for a
* lexicographical comparison are built in the next statement.
*/
if ((m2Ipv6UdpCmp(&currEntry, pUdpEntry) > 0) &&
(m2Ipv6UdpCmp(&currEntry, &savedEntry) < 0))
{
/*
* Save the entry which qualifies as the NEXT greater
* lexicographic entry. Because the table is not order the
* search must proceed to the end of the table.
*/
memcpy (savedEntry.ipv6UdpLocalAddress, currEntry.ipv6UdpLocalAddress,
sizeof (struct in6_addr));
savedEntry.ipv6UdpIfIndex = currEntry.ipv6UdpIfIndex;
savedEntry.ipv6UdpLocalPort = currEntry.ipv6UdpLocalPort;
}
}
}
splx (netLock); /* Give up exclusive access to Network Code */
/* If a match was found fill, the requested structure */
if (savedEntry.ipv6UdpLocalPort != -1)
{
memcpy (pUdpEntry->ipv6UdpLocalAddress, savedEntry.ipv6UdpLocalAddress,
sizeof (struct in6_addr));
pUdpEntry->ipv6UdpLocalPort = savedEntry.ipv6UdpLocalPort;
pUdpEntry->ipv6UdpIfIndex = savedEntry.ipv6UdpIfIndex;
return (OK);
}
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
return (ERROR);
}
/*******************************************************************************
*
* m2Ipv6UdpDelete - delete all resources used to access the IPv6 UDP group
*
* This routine frees all the resources allocated at the time the group was
* initialized. The IPv6 UDP group should not be accessed after this routine has
* been called.
*
* RETURNS: OK, always.
*
* SEE ALSO: m2Ipv6UdpInit(), m2Ipv6UdpTblEntryGet(), m2Ipv6UdpLib
*/
STATUS m2Ipv6UdpDelete (void)
{
return (OK);
}
+261
View File
@@ -0,0 +1,261 @@
/* m2Lib.c - MIB-II API library for SNMP agents */
/* Copyright 1984 - 2005 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
03i,27mar08,zhr migrated to IPNET
01l,12jan05,vvv osdep.h cleanup
01k,06nov03,rlm Ran batch header update for header re-org.
01j,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
01i,11oct02,ham added m2LibInit() (SPR 83041).
01h,01oct02,ham added m2IfMgtLibInit() in m2LibInit().
01g,16may02,ant integration into Clarinet
01f,25oct00,ham doc: cleanup for vxWorks AE 1.0.
01e,25jan95,jdi doc cleanup.
01d,11nov94,rhp minor correction to library man page.
01c,10nov94,rhp edited man pages.
01b,15feb94,jag added MIB-II library documentation.
01a,05jan94,elh written
*/
/*
DESCRIPTION
This library provides Management Information Base (MIB-II, defined in
RFC 1213) services for applications wishing to have access to MIB
parameters.
To use this feature, include the following component:
INCLUDE_MIB2_ALL
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 MIB-II library are separated
into groups that follow the MIB-II definition. Each supported group
has its own interface library:
.iP m2SysLib 15 3
systems group
.iP m2IfLib
interface group
.iP m2IpLib
IP group (includes AT)
.iP m2IcmpLib
ICMP group
.iP m2TcpLib
TCP group
.iP m2UdpLib
UDP group
.LP
MIB-II retains the AT group for backward compatibility, but
includes its functionality in the IP group. The EGP and SNMP groups
are not supported by this interface. The variables in each group have
been subdivided into two types: table entries and scalar variables.
Each type has a pair of routines that get and set the variables.
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
Only the groups that are to be used need be initialized. There is one
exception: to use the IP group, the interface group must also be
initialized. Applications that require MIB-II support from all groups can
initialize all groups at once by calling the m2Init(). All MIB-II group
services can be disabled by calling m2Delete(). 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:
m2SysGroupInfoGet()
m2IfGroupInfoGet()
m2IpGroupInfoGet()
m2IcmpGroupInfoGet()
m2TcpGroupInfoGet()
m2UdpGroupInfoGet()
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_<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:
m2SysGroupInfoSet()
m2IpGroupInfoSet()
The input parameters to the variable-set routines are a bit field
that specifies which variables to set, and a group structure. The
structure is the same structure type used in the get operation.
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:
m2IfTblEntryGet()
m2IpAddrTblEntryGet()
m2IpAtransTblEntryGet()
m2IpRouteTblEntryGet()
m2TcpConnEntryGet()
m2UdpTblEntryGet()
The input parameters are a pointer to a table entry structure, and a
flag value specifying one of two types of table search. Each table
entry is a structure, where the struct type name follows this naming
convention: "M2_<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 either identical to the index value
specified as input, or 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 IP network addresses that are exchanged with the MIB-II
library must be in host-byte order; use ntohl() to convert addresses
before calling these library routines.
The following example shows how to initialize the MIB-II library for
all groups.
.CS
extern FUNCPTR myTrapGenerator;
extern void * myTrapGeneratorArg;
M2_OBJECTID mySysObjectId = { 8, {1,3,6,1,4,1,731,1} };
if (m2Init ("VxWorks 5.1.1 MIB-II library (sysDescr)",
"support@wrs.com (sysContact)",
"1010 Atlantic Avenue Alameda, California 94501 (sysLocation)",
&mySysObjectId,
myTrapGenerator,
myTrapGeneratorArg,
0) == OK)
/@ MIB-II groups initialized successfully @/
.CE
INCLUDE FILES: m2Lib.h
SEE ALSO: m2IfLib, m2IpLib, m2IcmpLib, m2UdpLib, m2TcpLib, m2SysLib
*/
/* includes */
#include <m2Lib.h>
IMPORT STATUS m2TestInit ();
/******************************************************************************
*
* m2LibInit - initialize m2Lib
*
* This routine initializes m2Lib.
*
* RETURNS: OK if successful, otherwise ERROR.
*
*/
STATUS m2LibInit (void)
{
#ifdef TEST_M2LIB
if(m2TestInit() == ERROR)
return (ERROR);
#endif
return (OK);
}
/******************************************************************************
*
* m2Init - initialize the SNMP MIB-2 library
*
* This routine initializes the MIB-2 library by calling the initialization
* routines for each MIB-2 group. The parameters <pMib2SysDescr>
* <pMib2SysContact>, <pMib2SysLocation>, and <pMib2SysObjectId> are passed
* directly to m2SysInit(); <pTrapRtn> and <pTrapArg> are passed directly to
* m2IfInit(); and <maxRouteTableSize> is passed to m2IpInit().
*
* RETURNS: OK if successful, otherwise ERROR.
*
* SEE ALSO:
* m2SysInit(), m2TcpInit(), m2UdpInit(), m2IcmpInit(), m2IfInit(), m2IpInit()
*/
STATUS m2Init
(
char * pMib2SysDescr, /* sysDescr */
char * pMib2SysContact, /* sysContact */
char * pMib2SysLocation, /* sysLocation */
M2_OBJECTID * pMib2SysObjectId, /* sysObjectID */
FUNCPTR pTrapRtn, /* link up/down -trap routine */
void * pTrapArg, /* trap routine arg */
int maxRouteTableSize /* max size of routing table */
)
{
/* Call the initialization routine for each group in MIB-2 */
if ((m2SysInit (pMib2SysDescr, pMib2SysContact, pMib2SysLocation,
pMib2SysObjectId) == ERROR) ||
(m2IfInit (pTrapRtn, pTrapArg) == ERROR) ||
(m2IfMgtLibInit () == ERROR) ||
(m2IpInit (maxRouteTableSize) == ERROR) ||
(m2TcpInit () == ERROR) ||
(m2IcmpInit () == ERROR) ||
(m2TestInit () == ERROR) ||
(m2UdpInit () == ERROR))
{
m2Delete ();
return (ERROR); /* initialization failed */
}
return (OK);
}
/******************************************************************************
*
* m2Delete - delete all the MIB-II library groups
*
* This routine cleans up the state associated with the MIB-II library.
*
* RETURNS: OK (always).
*
* SEE ALSO: m2SysDelete(), m2TcpDelete(), m2UdpDelete(), m2IcmpDelete(),
* m2IfDelete(), m2IpDelete()
*/
STATUS m2Delete (void)
{
m2SysDelete ();
m2IfDelete ();
m2IpDelete ();
m2TcpDelete ();
m2IcmpDelete ();
m2UdpDelete ();
return (OK);
}
@@ -0,0 +1,76 @@
/* Copyright 1993 - 2008 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01u,10jun08,zhr written
*/
#ifdef _WRS_KERNEL
#include <vxWorks.h>
#endif
#include <string.h>
#include <m2Lib.h>
#include "errnoLib.h"
#include "vwModNum.h"
#include "in.h"
#include <ipcom_mib2_api.h>
#include <ipcom_type.h>
#include <applUtilLib.h>
#ifndef _WRS_KERNEL
#include <strings.h> /* bzero */
#endif /* _WRS_KERNEL */
STATUS testM2LibIcmp (int);
STATUS testM2LibSystem(int);
STATUS testM2LibIp (int);
STATUS testM2LibIfTable(int);
STATUS m2TestInit (void);
STATUS (*func[])(int) = {
testM2LibIcmp,
testM2LibIp,
testM2LibIfTable,
testM2LibSystem
};
STATUS m2TestInit (void)
{
return OK;
}
STATUS testM2LibIcmp (int flag)
{
M2_ICMP pIcmpInfo;
if (m2IcmpGroupInfoGet (&pIcmpInfo) == ERROR)
return (ERROR);
printf (" icmpInMsgs = %d\n",pIcmpInfo.icmpInMsgs);
printf (" icmpOutMsgs = %d\n",pIcmpInfo.icmpOutMsgs);
/*
* display all message here
*/
return OK;
}
STATUS testM2LibSystem(int flag)
{
/* func to be implemented */
return OK;
}
STATUS testM2LibIp(int flag)
{
/* func to be implemented */
return OK;
}
STATUS testM2LibIfTable(int flag)
{
/* func to be implemented */
return OK;
}
@@ -0,0 +1,521 @@
/* m2SysLib.c - MIB-II system-group API for SNMP agents */
/* Copyright 1984 - 2005 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
02a,24nov10,h_x Fix WIND00239714
01z,29sep10,h_x Fix build and coverity warnings
01y,18aug10,h_x Fix WIND00226752
01x,21jun10,h_x Fix WIND00217113
01w,21apr10,h_x Fixed WIND00207296
01v,01aug08,zhr Fixed WIND00128350
01u,27mar08,zhr Migrated to IPNET
01t,25jan05,sar Modify sysuptime to be based on 64 bit ticks
01s,12jan05,vvv osdep.h cleanup
01r,19sep04,spm updated virtual stack startup: restored use of published
init routine and removed packing/unpacking parameters
01q,26aug04,niq unified stack merge
01p,06nov03,rlm Ran batch header update for header re-org.
01o,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
01n,01may03,spm Tornado 2.2 CP1 merge (from ver 01i,14jan03,rae:
TOR2_2-CP1-F label, tor2_2-patch branch, /wind/river VOB)
01m,06feb03,vvv fixed previous checkin
01l,06feb03,vvv merged from tor2_2-patch.alameda, ver01i (SPR #27993)
01k,16may02,ant integration into Clarinet
01j,26oct01,spm isolated virtual stack data structures (SPR #71092)
01i,29mar01,spm merged changes from version 01i of tor2_0.open_stack
branch (wpwr VOB, base 01g) for unified code base
01h,25oct00,ham doc: cleanup for vxWorks AE 1.0.
01g,30dec97,vin fixed SPR 20090
01f,03apr96,rjc set the m2SystemSem semaphore to NULL in m2SysDelete.
01d,25jan95,jdi doc cleanup.
01c,11nov94,rhp additional man-page corrections
01b,10nov94,rhp edit man pages
01b,22feb94,elh put in check for null parameters in m2SysInit.
01a,08dec93,jag written
*/
/*
DESCRIPTION
This library provides MIB-II services for the system group. It provides
routines to initialize the group and to access the group scalar variables.
For a broader description of MIB-II services, see the manual entry for m2Lib.
To use this feature, include the following component:
INCLUDE_MIB2_SYSTEM
USING THIS LIBRARY
This library can be initialized and deleted by calling m2SysInit() and
m2SysDelete() respectively, if only the system 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 system group provides the option to set the system variables at the
time m2Sysinit() is called. The MIB-II variables `sysDescr' and `sysobjectId'
are read-only, and can be set only by the system-group initialization routine.
The variables `sysContact', `sysName' and `sysLocation' can be set through
m2SysGroupInfoSet() at any time.
The following is an example of system group initialization:
.CS
M2_OBJECTID mySysObjectId = { 8, {1,3,6,1,4,1,731,1} };
if (m2SysInit ("VxWorks MIB-II library ",
"support@wrs.com",
"1010 Atlantic Avenue Alameda, California 94501",
&mySysObjectId) == OK)
/@ System group initialized successfully @/
.CE
The system group variables can be accessed as follows:
.CS
M2_SYSTEM sysVars;
if (m2SysGroupInfoGet (&sysVars) == OK)
/@ values in sysVars are valid @/
.CE
The system group variables can be set as follows:
.CS
M2_SYSTEM sysVars;
unsigned int varToSet; /@ bit field of variables to set @/
/@ Set the new system Name @/
strcpy (m2SysVars.sysName, "New System Name");
varToSet |= M2SYSNAME;
/@ Set the new contact name @/
strcpy (m2SysVars.sysContact, "New Contact");
varToSet |= M2SYSCONTACT;
if (m2SysGroupInfoGet (varToSet, &sysVars) == OK)
/@ values in sysVars set @/
.CE
INCLUDE FILES: m2Lib.h
SEE ALSO:
m2Lib, m2IfLib, m2IpLib, m2IcmpLib, m2UdpLib, m2TcpLib
*/
/* includes */
#include <vxWorks.h>
#include <m2Lib.h>
#include <m2IfLib.h>
#include "errnoLib.h"
#include "vwModNum.h"
#include "semLibCommon.h"
#include <ipnet_h.h>
#include <ipcom_clib.h>
#include <ipcom_mib2_api.h>
#include <oemtypes.h>
#include <sys/sysctl.h>
#include <string.h>
#include <unistd.h>
#ifndef VIRTUAL_STACK
/*
* The system group is supported by the structure defined below. All changes to
* the system group are reflected in this structure.
*/
LOCAL M2_SYSTEM priv_m2SystemVars;
/*
* This semaphore protects the priv_m2SystemVars from multiple readers and
* writers.
*/
LOCAL SEM_ID priv_m2SystemSem;
LOCAL UINT64 priv_startTicks; /* 64 bit ticks at start */
#else
#define priv_m2SystemVars VS_M2_SYS_DATA->priv_m2SystemVars
#define priv_m2SystemSem VS_M2_SYS_DATA->priv_m2SystemSem
#define priv_startTicks VS_M2_SYS_DATA->priv_startTicks
#endif /* VIRTUAL_STACK */
/* externals not associated with virtual stacks */
extern UINT64 tick64Get (void); /* This should be removed when it is added
* to tickLib.h, until then we need it to
* ensure proper processing of 64 bit ticks */
/*
* The zero object id is used throught out the MIB-II library to fill OID
* requests when an object ID is not provided by a group variable.
*/
LOCAL M2_OBJECTID sysZeroObjectId = { 2, {0,0} };
/* globals */
IMPORT int m2SysClkRateGet (void);
IMPORT int gethostname(char *name, size_t nameLen);
/******************************************************************************
*
* centiSecsStart - get the starting timestamp
*
* Set the timestamp we use to determine the starting point for sys up time.
*
* RETURNS: void
*
* SEE ALSO: N/A
*/
LOCAL void centiSecsStart (void)
{
priv_startTicks = tick64Get();
return;
}
/******************************************************************************
*
* centiSecsGet - get hundredths of a second
*
* The time, in hundredths of a second, since we started the network.
* centiSecsStart is used to start the clock.
*
* RETURNS: Hundredths of a second since the group was initialized.
*
* SEE ALSO: N/A
*/
#ifdef IPCOM_USE_INET
LOCAL Mib2_TimeTicks centiSecsGet (void)
{
UINT64 currCentiSecs;
currCentiSecs = ((tick64Get() - priv_startTicks) * 100) / m2SysClkRateGet();
return (Mib2_TimeTicks)(currCentiSecs & 0xFFFFFFFF);
}
#endif
/******************************************************************************
*
* m2SysInit - initialize MIB-II system-group routines
*
* This routine allocates the resources needed to allow access to the
* system-group MIB-II variables. This routine must be called before
* any system-group variables can be accessed. The 'pMib2SysDescr',
* 'pMib2SysContact', 'pMib2SysLocation', and 'pMib2SysObjectId' parameters
* are optional. The members 'pMib2SysDescr', 'pMib2SysObjectId' are read
* only, as specified by MIB-II, and can be set only by this routine.
*
* RETURNS: OK, always.
*
* ERRNO:
* S_m2Lib_CANT_CREATE_SYS_SEM
*
* SEE ALSO: m2SysGroupInfoGet(), m2SysGroupInfoSet(), m2SysDelete()
*/
STATUS m2SysInit
(
char * pMib2SysDescr, /* sysDescr */
char * pMib2SysContact, /* sysContact */
char * pMib2SysLocation, /* sysLocation */
M2_OBJECTID * pMib2SysObjectId /* sysObjectID */
)
{
#ifdef VIRTUAL_STACK
/* Allocate space for former global variables. */
if (vsTbl[myStackNum]->pM2SysGlobals == NULL)
{
vsTbl[myStackNum]->pM2SysGlobals =
(VS_M2_SYS *) KHEAP_ALLOC (sizeof (VS_M2_SYS));
if (vsTbl[myStackNum]->pM2SysGlobals == NULL)
return (ERROR);
bzero ( (char *)vsTbl [myStackNum]->pM2SysGlobals, sizeof (VS_M2_SYS));
}
#endif /* VIRTUAL_STACK */
/* Initialize System Group with defaults */
if ((pMib2SysDescr != NULL) && (pMib2SysDescr [0] != '\0')
&& (strlen(pMib2SysDescr) < M2DISPLAYSTRSIZE))
strcpy ((char *) priv_m2SystemVars.sysDescr, pMib2SysDescr);
if ((pMib2SysContact != NULL) && (pMib2SysContact [0] != '\0')
&& (strlen(pMib2SysContact) < M2DISPLAYSTRSIZE))
strcpy ((char *) priv_m2SystemVars.sysContact, pMib2SysContact);
if ((pMib2SysLocation != NULL) && (pMib2SysLocation [0] != '\0')
&& (strlen(pMib2SysLocation) < M2DISPLAYSTRSIZE))
strcpy ((char *) priv_m2SystemVars.sysLocation, pMib2SysLocation);
/* Use targets host name as a the system name */
if(gethostname((char *) priv_m2SystemVars.sysName, sizeof(priv_m2SystemVars.sysName)) == -1)
{
return ERROR;
}
if ((pMib2SysObjectId != NULL) && (pMib2SysObjectId->idLength > 0))
{
bcopy (((char *) (pMib2SysObjectId->idArray)),
((char *) (priv_m2SystemVars.sysObjectID.idArray)),
(u_long)pMib2SysObjectId->idLength * sizeof(Mib2_Integer));
priv_m2SystemVars.sysObjectID.idLength = pMib2SysObjectId->idLength;
}
else
{
/* Initialize System group OID with the Zero OID */
bcopy (((char *) (sysZeroObjectId.idArray)),
((char *) (priv_m2SystemVars.sysObjectID.idArray)),
(size_t)sysZeroObjectId.idLength * sizeof(Mib2_Integer));
priv_m2SystemVars.sysObjectID.idLength = sysZeroObjectId.idLength;
}
/* Create semaphore */
if (priv_m2SystemSem == NULL)
{
priv_m2SystemSem = semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE |
SEM_DELETE_SAFE);
if (priv_m2SystemSem == NULL)
{
#ifdef VIRTUAL_STACK
KHEAP_FREE (vsTbl[myStackNum]->pM2SysGlobals);
vsTbl[myStackNum]->pM2SysGlobals = NULL;
#endif /* VIRTUAL_STACK */
errnoSet (S_m2Lib_CANT_CREATE_SYS_SEM);
return (ERROR);
}
}
(void) centiSecsStart (); /* Initialize group time reference */
return (OK);
}
/*******************************************************************************
*
* m2SysDestructor - Clean up the resources used by VS Portion of the code
*
* RETURNS: ERROR if it could not free the memory
* OK otherwise
*
* NOMANUAL
*/
#ifdef VIRTUAL_STACK
STATUS m2SysDestructor
(
VSNUM vsnum
)
{
/* Free system semaphore */
if (priv_m2SystemSem != NULL)
{
semDelete (priv_m2SystemSem);
priv_m2SystemSem = NULL;
}
if (vsTbl [vsnum]->pM2SysGlobals != NULL)
{
KHEAP_FREE (vsTbl [vsnum]->pM2SysGlobals);
vsTbl [vsnum]->pM2SysGlobals = NULL;
}
return (OK);
}
#endif /* VIRTUAL_STACK */
/******************************************************************************
*
* m2SysGroupInfoGet - get system-group MIB-II variables
*
* This routine fills in the structure at <pSysInfo> with the values of MIB-II
* system-group variables.
*
*
* RETURNS: OK, or ERROR if <pSysInfo> is not a valid pointer.
*
* ERRNO:
* S_m2Lib_INVALID_PARAMETER
*
* SEE ALSO: m2SysInit(), m2SysGroupInfoSet(), m2SysDelete()
*/
STATUS m2SysGroupInfoGet
(
M2_SYSTEM * pSysInfo /* pointer to MIB-II system group structure */
)
{
#ifdef IPCOM_USE_INET
Ipcom_mib2_ip_general_group ipGGroup;
int ipforwarding = 0;
/* Validate Pointer to the requested System structure */
if (pSysInfo == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
pSysInfo->sysUpTime = centiSecsGet ();
/* Take the System semaphore before reading the system variables */
strcpy ((char *) pSysInfo->sysDescr, (char *) priv_m2SystemVars.sysDescr);
strcpy ((char *) pSysInfo->sysContact, (char *) priv_m2SystemVars.sysContact);
strcpy ((char *) pSysInfo->sysName, (char *) priv_m2SystemVars.sysName);
strcpy ((char *) pSysInfo->sysLocation,
(char *) priv_m2SystemVars.sysLocation);
bcopy (((char *) priv_m2SystemVars.sysObjectID.idArray),
((char *) pSysInfo->sysObjectID.idArray),
(size_t)priv_m2SystemVars.sysObjectID.idLength * sizeof (Mib2_Integer));
pSysInfo->sysObjectID.idLength = priv_m2SystemVars.sysObjectID.idLength;
if (ipcom_mib2_get_ip_general_group(&ipGGroup) == -1)
{
return (ERROR);
}
ipforwarding = ipGGroup.ipForwarding;
/* Compute type of targets service based on the IP forwarding variables */
if (ipforwarding)
pSysInfo->sysServices |= (1 << (3 - 1));
else
pSysInfo->sysServices &= ~(1 << (3 - 1));
#endif
return (OK);
}
/******************************************************************************
*
* m2SysGroupInfoSet - set system-group MIB-II variables to new values
*
* This routine sets one or more variables in the system group as specified in
* the input structure at <pSysInfo> and the bit field parameter <varToSet>.
*
* RETURNS:
* OK, or ERROR if <pSysInfo> 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: m2SysInit(), m2SysGroupInfoGet(), m2SysDelete()
*/
STATUS m2SysGroupInfoSet
(
unsigned int varToSet, /* bit field of variables to set */
M2_SYSTEM * pSysInfo /* pointer to the system structure */
)
{
/* Validate Pointer to System structure and bit field in varToSet */
if (pSysInfo == NULL ||
(varToSet & (M2SYSNAME | M2SYSCONTACT | M2SYSLOCATION)) == 0)
{
if (pSysInfo == NULL)
errnoSet (S_m2Lib_INVALID_PARAMETER);
else
errnoSet (S_m2Lib_INVALID_VAR_TO_SET);
return (ERROR);
}
/* Set requested variables */
if (varToSet & M2SYSNAME)
strcpy ((char *) priv_m2SystemVars.sysName, (char *) pSysInfo->sysName);
if (varToSet & M2SYSCONTACT)
strcpy ((char *) priv_m2SystemVars.sysContact,
(char *) pSysInfo->sysContact);
if (varToSet & M2SYSLOCATION)
strcpy ((char *) priv_m2SystemVars.sysLocation,
(char *) pSysInfo->sysLocation);
return (OK);
}
/*******************************************************************************
*
* m2SysDelete - delete resources used to access the MIB-II system group
*
* This routine frees all the resources allocated at the time the group was
* initialized. Do not access the system group after calling this routine.
*
* RETURNS: OK, always.
*
* SEE ALSO: m2SysInit(), m2SysGroupInfoGet(), m2SysGroupInfoSet().
*/
STATUS m2SysDelete (void)
{
/* Do nothing if cleanup already completed. */
if (priv_m2SystemSem == NULL)
return (OK);
semDelete (priv_m2SystemSem);
priv_m2SystemSem = NULL;
#ifdef VIRTUAL_STACK
KHEAP_FREE (vsTbl[myStackNum]->pM2SysGlobals);
vsTbl[myStackNum]->pM2SysGlobals = NULL;
#endif /* VIRTUAL_STACK */
return (OK);
}
/******************************************************************************
*
* m2SysClkRateGet - get the system clock rate
*
* DESCRIPTION
* This routine returns the system clock rate.
*
* RETURNS: The number of ticks per second of the system clock.
*
* ERRNO: N/A
*
* SEE ALSO: tickGet()
* the VxWorks programmer guides.
*
*\NOMANUAL
*
*/
int m2SysClkRateGet(void)
{
int clockRate;
#ifdef _WRS_KERNEL
clockRate = sysClkRateGet();
#else
int clockRateSize = sizeof(int);
int mib[2];
mib[0] = CTL_KERN;
mib[1] = KERN_CLOCKRATE;
sysctl(mib, 2, (void *) &clockRate, (size_t *) &clockRateSize,
(void *) NULL, 0);
#endif
return clockRate;
}
@@ -0,0 +1,714 @@
/* m2TcpLib.c - MIB-II TCP-group API for SNMP agents */
/*
* Copyright (c) 1984-2014 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
02l,15feb14,rjq Fix incorrect merge in tcpConnCmp()
02k,15dec11,h_x Back port to 6.9.2.1 for WIND00297079
02j,29oct10,h_x Fix WIND00238817
02i,14oct10,h_x Fix WIND00236294
02h,04Aug10,lzq Fix WIND00225083
02g,21jun10,h_x Fix WIND00217113
02f,07May10,lzq let m2TcpConnEntryGet function get data from both
ConnTable and ListenerTable
02e,28may09,zhr Fixed WIND00168052 list stops at TIME_WAIT
02e,28may09,zhr Fixed WIND00168313 tcpRetransSegs
02d,15jul08,zhr Updated for apigen and compiling waring
02c,10jun08,zhr Fixed WIND00124866 tcpConnState
02b,05jun08,zhr updated for GPP
02a,20mar08,zhr Migrated it to IPNET
01z,24oct05,dlk Fix scaling of tcpRtoMin and tcpRtoMax (SPR#114300).
01y,15jul05,vvv replaced iosFdValue() with iosFdDrvValue()
01y,25feb05,niq fix compiler warnings
01w,12jan05,vvv osdep.h cleanup
01v,02jun04,rp removed extern declaration of fdTable
01u,01mar04,dat rework for iosLib changes
01t,20nov03,niq osdep.h cleanup
01r,06nov03,rlm Ran batch header update for header re-org.
01q,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
01p,09feb03,pas include socketvar.h to silence a compiler warning
01o,06feb03,vvv merged from tor2_2-patch.alameda, ver01g (SPR #29667)
01n,01oct02,ann reverted the comparison logic in the Get routines
01m,21may02,ppp porting it for t202
01l,16may02,ant integration into Clarinet
01k,19nov01,rae renamed build macro to support different T2.x versions
01j,26oct01,spm isolated virtual stack data structures (SPR #71092)
01i,28jun01,rae add BUILD_FOR_T2 macro for truestack
01h,29mar01,spm merged changes from version 01f of tor2_0.open_stack
branch (wpwr VOB, base 01e) for unified code base
01g,25oct00,ham doc: cleanup for vxWorks AE 1.0
01f,14mar00,mak updated access of fdTable[] in m2TcpConnEntrySet().
01e,08mar97,vin added changes to accomodate changes in pcb structure.
01d,25jan95,jdi doc cleanup.
01c,11nov94,rhp edit man pages
01b,10nov94,rhp fixed typo in m2TcpInit man page
01a,08dec93,jag written
*/
/*
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.
To use this feature, include the following component:
INCLUDE_MIB2_TCP
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:
.CS
M2_TCP tcpVars;
if (m2TcpGroupInfoGet (&tcpVars) == OK)
/@ values in tcpVars are valid @/
.CE
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:
.CS
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.
* 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 @/
.CE
The TCP table of connections allows only for a connection to be deleted as
specified in the MIB-II. For example:
.CS
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 @/
.CE
INCLUDE FILES: m2Lib.h
SEE ALSO:
m2Lib, m2IfLib, m2IpLib, m2IcmpLib, m2UdpLib, m2SysLib
*/
/* includes */
#include <m2Lib.h>
#include <errnoLib.h>
#include <in.h>
#include <asn1conf.h>
#include <ipcom_mib2_api.h>
#include <ipnet_h.h>
#include <stdlib.h>
#include <string.h>
#include <ipnet_config.h>
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#include <ipcom_clib.h>
#include <iptcp.h>
/* MIB-II TCP state definitions */
#define M2TCP_CLOSED 1
#define M2TCP_LISTEN 2
#define M2TCP_SYNSENT 3
#define M2TCP_SYNRECEIVED 4
#define M2TCP_ESTABLISHED 5
#define M2TCP_FINWAIT1 6
#define M2TCP_FINWAIT2 7
#define M2TCP_CLOSEWAIT 8
#define M2TCP_LASTACK 9
#define M2TCP_CLOSING 10
#define M2TCP_TIMEWAIT 11
#define M2TCP_DELETETCB 12
#define M2TCP_NSTATES 13
/* type for m2Lib migration to IPNET */
typedef struct M2_ipcom_mib2_TcpConnectionEntry_cookie_t
{
int tcount;
OIDC_T * tlist;
M2_TCPCONNTBL * reqInstance;
Ipcom_mib2_TcpConnectionEntry * dataPtr;
boolean_t getnext; /* FALSE = getexact */
} M2_ipcom_mib2_TcpConnectionEntry_cookie_t;
/* locals & global */
LOCAL Ipcom_mib2_TcpConnectionEntry *Ipcom_mib2_TcpConnectionEntry_lookup
(M2_TCPCONNTBL *, boolean_t);
IP_PUBLIC int tcpConnectionEntry_callback
(Ipcom_mib2_TcpConnectionEntry *, void *);
/*
* This table maps the BSD TCP states to the MIB-II TCP specified states. The
* table is indexed using the BSD TCP states.
*/
#if 0
LOCAL long m2TcpStates [11] =
{
M2TCP_CLOSED, /* TCPS_CLOSED -> M2TCP_CLOSED */
M2TCP_LISTEN, /* TCPS_LISTEN -> M2TCP_LISTEN */
M2TCP_SYNSENT, /* TCPS_SYN_SENT -> M2TCP_SYNSENT */
M2TCP_SYNRECEIVED, /* TCPS_SYN_RECEIVED -> M2TCP_SYNRECEIVED */
M2TCP_ESTABLISHED, /* TCPS_ESTABLISHED -> M2TCP_ESTABLISHED */
M2TCP_CLOSEWAIT, /* TCPS_CLOSE_WAIT -> M2TCP_CLOSEWAIT */
M2TCP_FINWAIT1, /* TCPS_FIN_WAIT_1 -> M2TCP_FINWAIT1 */
M2TCP_CLOSING, /* TCPS_CLOSING -> M2TCP_CLOSING */
M2TCP_LASTACK, /* TCPS_LAST_ACK -> M2TCP_LASTACK */
M2TCP_FINWAIT2, /* TCPS_FIN_WAIT_2 -> M2TCP_FINWAIT2 */
M2TCP_TIMEWAIT, /* TCPS_TIME_WAIT -> M2TCP_TIMEWAIT */
};
#endif
/*******************************************************************************
*
* m2TcpInit - initialize MIB-II TCP-group access
*
* 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:
* m2TcpGroupInfoGet(), m2TcpConnEntryGet(), m2TcpConnEntrySet(), m2TcpDelete()
*/
STATUS m2TcpInit (void)
{
return (OK);
}
/******************************************************************************
*
* m2TcpGroupInfoGet - get MIB-II TCP-group scalar variables
*
* 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:
* m2TcpInit(), m2TcpConnEntryGet(), m2TcpConnEntrySet(), m2TcpDelete()
*/
STATUS m2TcpGroupInfoGet
(
M2_TCPINFO * pTcpInfo /* pointer to the TCP group structure */
)
{
Ipcom_mib2_tcp_group tcpGroup;
/* Validate Pointer to TCP structure */
if (pTcpInfo == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
if (ipcom_mib2_get_tcp_group (&tcpGroup) == -1)
{
return (ERROR);
}
pTcpInfo->tcpRtoAlgorithm = tcpGroup.tcpRtoAlgorithm;
pTcpInfo->tcpRtoMin = tcpGroup.tcpRtoMin;
pTcpInfo->tcpRtoMax = tcpGroup.tcpRtoMax;
pTcpInfo->tcpMaxConn = tcpGroup.tcpMaxConn;
pTcpInfo->tcpActiveOpens = tcpGroup.tcpActiveOpens;
pTcpInfo->tcpPassiveOpens = tcpGroup.tcpPassiveOpens;
pTcpInfo->tcpAttemptFails = tcpGroup.tcpAttemptFails;
pTcpInfo->tcpEstabResets = tcpGroup.tcpEstabResets;
pTcpInfo->tcpCurrEstab = tcpGroup.tcpCurrEstab;
pTcpInfo->tcpInSegs = tcpGroup.tcpInSegs;
pTcpInfo->tcpOutSegs = tcpGroup.tcpOutSegs;
pTcpInfo->tcpInErrs = tcpGroup.tcpInErrs;
pTcpInfo->tcpOutRsts = tcpGroup.tcpOutRsts;
pTcpInfo->tcpRetransSegs = tcpGroup.tcpRetransSegs;
return (OK);
}
/******************************************************************************
*
* tcpConnCmp - compare two TCP connections in lexicographical order
*
* This routine compares two TCP connection control blocks. It compares the
* value 1 with value 2. It returns equal, value 1 greater than
* value 2, or value 1 less than value 2. The comparison is done based on the
* lexicographical order specified by MIB-II.
*
* RETURNS: 0 = equal, 1 > greater than, and -1 < less than.
*
* SEE ALSO: N/A
*
* \NOMANUAL
*/
LOCAL long tcpConnCmp
(
M2_TCPCONNTBL * pConnVal1, /* pointer to control block (Compare against) */
M2_TCPCONNTBL * pConnVal2 /* pointer to control block (Second entry) */
)
{
Mib2_Integer result;
if (pConnVal1->tcpConnLocalAddress > pConnVal2->tcpConnLocalAddress)
return 1; /* First Entry is Greater */
if (pConnVal1->tcpConnLocalAddress < pConnVal2->tcpConnLocalAddress)
return -1; /* First Entry is Smaller */
/* Subtract two values INTEGER(0 .. 65535), result is signed Mib2_Integer */
result = pConnVal1->tcpConnLocalPort - pConnVal2->tcpConnLocalPort;
if (result > 0)
return 1;
if (result < 0)
return -1;
/* Comparison of two unsigned values */
if (pConnVal1->tcpConnRemAddress > pConnVal2->tcpConnRemAddress)
return 1; /* First Entry is Greater */
if (pConnVal1->tcpConnRemAddress < pConnVal2->tcpConnRemAddress)
return -1; /* First Entry is Smaller */
result = pConnVal1->tcpConnRemPort - pConnVal2->tcpConnRemPort;
if (result > 0)
return 1;
if (result < 0)
return -1;
return 0;
}
/************************************************************************************
*
* tcpConnectionEntry_callback - RFC1213 tcpConnTable callback
*
* The routine compares a TCP connection entry with an index key given by the "user"
* repeatedly in iterations. The compariation is carried out based on the request type.
* The request type can be "get" M2_EXACT_VALUE or "getnext" M2_NEXT_VALU which is in a
* lexicographicl order specified by MIB-II.
*
* RETURNS: 1 stop - find a matched entry , 0 - not match and continue iterations.
*
* SEE ALSO: N/A
*
* \NOMANUAL
*/
IP_PUBLIC int tcpConnectionEntry_callback
(
Ipcom_mib2_TcpConnectionEntry * entry,
void * user
)
{
/* Dont do v6 - the MIB code doesn't handle it and attempts to interpret it as v4. */
if(entry->tcpConnectionLocalAddressType != 1)
return 1;
M2_ipcom_mib2_TcpConnectionEntry_cookie_t * cookie = (M2_ipcom_mib2_TcpConnectionEntry_cookie_t *) user;
boolean_t stopIterating = FALSE;
boolean_t saveData = FALSE;
M2_TCPCONNTBL tableEntry;
M2_TCPCONNTBL prevEntry;
/* Dont do v6 - the MIB code doesn't handle it and attempts to interpret it as v4. */
if(entry->tcpConnectionLocalAddressType != 1)
return 1;
tableEntry.tcpConnLocalAddress = ntohl(*(Ip_u32 *)entry->tcpConnectionLocalAddress);
tableEntry.tcpConnLocalPort = entry->tcpConnectionLocalPort;
tableEntry.tcpConnRemAddress = ntohl(*(Ip_u32 *)entry->tcpConnectionRemAddress);
tableEntry.tcpConnRemPort = entry->tcpConnectionRemPort;
if (cookie->getnext)
{
if (tcpConnCmp (&tableEntry, cookie->reqInstance) > 0 )
{
if (cookie->dataPtr == NULL)
/* first entry in the table */
{
saveData = TRUE;
}
else
/* Compare it with the entry alreay stored in data.
* Keep the smaller one.
*/
{
prevEntry.tcpConnLocalAddress = ntohl(*(Ip_u32 *)cookie->dataPtr->tcpConnectionLocalAddress);
prevEntry.tcpConnLocalPort = cookie->dataPtr->tcpConnectionLocalPort;
prevEntry.tcpConnRemAddress = ntohl(*(Ip_u32 *)cookie->dataPtr->tcpConnectionRemAddress);
prevEntry.tcpConnRemPort = cookie->dataPtr->tcpConnectionRemPort;
if (tcpConnCmp (&tableEntry, &prevEntry) < 0 )
saveData = TRUE;
}
}
else if (tcpConnCmp (&tableEntry, cookie->reqInstance) == 0 )
/* Next instance in pReqTcpConnEntry is found */
{
saveData = TRUE;
stopIterating = TRUE;
}
}
else /* Get exact */
{
if (tcpConnCmp(&tableEntry, cookie->reqInstance) == 0)
{
saveData = TRUE;
stopIterating = TRUE;
}
}
if ( saveData)
{
if (cookie->dataPtr == NULL)
cookie->dataPtr = (Ipcom_mib2_TcpConnectionEntry *)SNMP_memory_alloc (sizeof (Ipcom_mib2_TcpConnectionEntry));
if (cookie->dataPtr != NULL)
memcpy(cookie->dataPtr, entry, sizeof (Ipcom_mib2_TcpConnectionEntry));
/* Return values defined are part of callback API. */
}
return (stopIterating? 1: 0);
}
/*
*===========================================================================
* ipcom_mib2_iterate_tcpConnectionListenerTable
*===========================================================================
* Description:
* Parameters:
* Returns:
*/
IP_STATIC int
ipcom_mib2_iterate_tcpConnectionListenerTable(Ipcom_mib2_tcpConnectionTableCb cb, void *user)
{
void *suspend_handle;
int i, count = 0;
Ipcom_mib2_TcpConnectionEntry entry;
if (cb == IP_NULL)
return -1;
ipcom_memset(&entry, 0, sizeof(entry));
suspend_handle = ipnet_suspend_stack();
if (suspend_handle == IP_NULL)
return -1;
for(i = 0; i < ipnet_conf_max_sockets; i++)
{
if (ipnet->sockets[i] != IP_NULL
&& ipnet->sockets[i]->ipcom.type == IP_SOCK_STREAM
&& ipnet->sockets[i]->proto == IP_IPPROTO_TCP
&& ipnet->sockets[i]->tcb != IP_NULL
&& (ipnet->sockets[i]->ipcom.domain == IP_AF_INET
|| ipnet->sockets[i]->ipcom.domain == IP_AF_INET6))
{
#ifdef IPCOM_USE_INET
if (ipnet->sockets[i]->ipcom.domain == IP_AF_INET)
{
entry.tcpConnectionLocalAddressType = 1; /* ipv4(1) */
entry.tcpConnectionRemAddressType = 1; /* ipv4(1) */
*(Ip_u32 *)entry.tcpConnectionLocalAddress = ipnet->sockets[i]->ip4->saddr_n;
*(Ip_u32 *)entry.tcpConnectionRemAddress = ipnet->sockets[i]->ip4->daddr_n;
}
#endif
#ifdef IPCOM_USE_INET6
if (ipnet->sockets[i]->ipcom.domain == IP_AF_INET6)
{
entry.tcpConnectionLocalAddressType = IP_IN6_IS_ADDR_LINK_LOCAL(&ipnet->sockets[i]->ip6->saddr)
? 4 : 2; /* ipv6(2) ipv6z(4) */
entry.tcpConnectionRemAddressType = IP_IN6_IS_ADDR_LINK_LOCAL(&ipnet->sockets[i]->ip6->daddr)
? 4 : 2; /* ipv6(2) ipv6z(4) */
((Ip_u32 *)entry.tcpConnectionLocalAddress)[0] = ipnet->sockets[i]->ip6->saddr.in6.addr32[0];
((Ip_u32 *)entry.tcpConnectionLocalAddress)[1] = ipnet->sockets[i]->ip6->saddr.in6.addr32[1];
((Ip_u32 *)entry.tcpConnectionLocalAddress)[2] = ipnet->sockets[i]->ip6->saddr.in6.addr32[2];
((Ip_u32 *)entry.tcpConnectionLocalAddress)[3] = ipnet->sockets[i]->ip6->saddr.in6.addr32[3];
((Ip_u32 *)entry.tcpConnectionLocalAddress)[4] = IP_IN6_IS_ADDR_LINK_LOCAL(&ipnet->sockets[i]->ip6->saddr)
? ipnet->sockets[i]->ip6->iscope_id : 0;
((Ip_u32 *)entry.tcpConnectionRemAddress)[0] = ipnet->sockets[i]->ip6->daddr.in6.addr32[0];
((Ip_u32 *)entry.tcpConnectionRemAddress)[1] = ipnet->sockets[i]->ip6->daddr.in6.addr32[1];
((Ip_u32 *)entry.tcpConnectionRemAddress)[2] = ipnet->sockets[i]->ip6->daddr.in6.addr32[2];
((Ip_u32 *)entry.tcpConnectionRemAddress)[3] = ipnet->sockets[i]->ip6->daddr.in6.addr32[3];
((Ip_u32 *)entry.tcpConnectionRemAddress)[4] = IP_IN6_IS_ADDR_LINK_LOCAL(&ipnet->sockets[i]->ip6->daddr)
? ipnet->sockets[i]->ip6->iscope_id : 0;
}
#endif
entry.tcpConnectionLocalPort = (Ipcom_mib2_InetPortNumber)ipnet->sockets[i]->sport;
entry.tcpConnectionRemPort = (Ipcom_mib2_InetPortNumber)ipnet->sockets[i]->dport;
entry.tcpConnectionState = ipnet->sockets[i]->tcb->state;
entry.tcpConnectionProcess = (Ip_u32)ipnet->sockets[i]->ipcom.pid;
/* Callback function */
count++;
if (cb(&entry, user) == 1)
goto exit;
}
}
exit:
ipnet_resume_stack(suspend_handle);
return count;
}
/**************************************************************************
*
* Ipcom_mib2_TcpConnectionEntry_lookup - Search a RFC1213 tcpConnTable
*
* The routine search a tcpConnTable through a API provided by the IPNET,
* which is ipcom_mib2_iterate_tcpConnectionTable. It executes a user
* defined callback function for each iteration. Note that if the table
* is empty the callback will not be called and the routine will return
* zero.
*
* RETURNS: a entry found or NULL
*
* SEE ALSO: N/A
*
* \NOMANUAL
*/
LOCAL Ipcom_mib2_TcpConnectionEntry *Ipcom_mib2_TcpConnectionEntry_lookup
(
M2_TCPCONNTBL * reqInstance,
boolean_t getnext
)
{
M2_ipcom_mib2_TcpConnectionEntry_cookie_t cookie;
cookie.dataPtr = NULL;
cookie.getnext = getnext;
cookie.reqInstance = reqInstance;
ipcom_mib2_iterate_tcpConnectionListenerTable (tcpConnectionEntry_callback,
(void *)&cookie);
return (cookie.dataPtr);
}
/******************************************************************************
*
* m2TcpConnEntryGet - get a MIB-II TCP connection table entry
*
* 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:
* m2Lib, m2TcpInit(), m2TcpGroupInfoGet(), m2TcpConnEntrySet(), m2TcpDelete()
*/
STATUS m2TcpConnEntryGet
(
int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */
M2_TCPCONNTBL * pReqTcpConnEntry /* input = Index, Output = Entry */
)
{
Ipcom_mib2_TcpConnectionEntry * data;
/* Validate Pointer to TCP Table Entry structure */
if (pReqTcpConnEntry == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
/*
* traverse the tcp connections table from the stack of ipnet
* until findng a one, which matches the instance.
*/
if (search == M2_EXACT_VALUE)
{
if ((data = (Ipcom_mib2_TcpConnectionEntry *)
Ipcom_mib2_TcpConnectionEntry_lookup (pReqTcpConnEntry, FALSE)) == NULL)
{
return (ERROR);
}
}
else /* getNext */
{
if ((data = (Ipcom_mib2_TcpConnectionEntry *)
Ipcom_mib2_TcpConnectionEntry_lookup (pReqTcpConnEntry, TRUE)) == NULL)
{
return (ERROR);
}
}
if (data->tcpConnectionState == M2TCP_NSTATES)
{
errnoSet (S_m2Lib_ENTRY_NOT_FOUND);
free(data);
return (ERROR); /* Requested Entry Not Found */
}
pReqTcpConnEntry->tcpConnState = data->tcpConnectionState;
pReqTcpConnEntry->tcpConnLocalAddress = ntohl(*(Ip_u32 *)data->tcpConnectionLocalAddress);
pReqTcpConnEntry->tcpConnLocalPort = data->tcpConnectionLocalPort;
pReqTcpConnEntry->tcpConnRemAddress = ntohl(*(Ip_u32 *) data->tcpConnectionRemAddress);
pReqTcpConnEntry->tcpConnRemPort = data->tcpConnectionRemPort;
free(data);
return (OK);
}
/******************************************************************************
*
* m2TcpConnEntrySet - set a TCP connection to the closed state
*
* 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:
* m2TcpInit(), m2TcpGroupInfoGet(), m2TcpConnEntryGet(), m2TcpDelete()
*/
STATUS m2TcpConnEntrySet
(
M2_TCPCONNTBL * pReqTcpConnEntry /* pointer to TCP connection to close */
)
{
Ipcom_mib2_TcpConnectionEntry pSetEntry;
pReqTcpConnEntry->tcpConnLocalAddress = htonl(pReqTcpConnEntry->tcpConnLocalAddress);
pReqTcpConnEntry->tcpConnRemAddress = htonl(pReqTcpConnEntry->tcpConnRemAddress);
/* Fill the request info. and set address type to 1 as only IPV4 is required */
pSetEntry.tcpConnectionLocalPort = pReqTcpConnEntry->tcpConnLocalPort;
memcpy(&pSetEntry.tcpConnectionLocalAddress,
&pReqTcpConnEntry->tcpConnLocalAddress, sizeof(Mib2_IpAddress));
pSetEntry.tcpConnectionRemPort = pReqTcpConnEntry->tcpConnRemPort;
memcpy(&pSetEntry.tcpConnectionRemAddress,
&pReqTcpConnEntry->tcpConnRemAddress, sizeof(Mib2_IpAddress));
pSetEntry.tcpConnectionLocalAddressType = 1;
pSetEntry.tcpConnectionRemAddressType = 1;
/* tcpConnState must be 12 (deleteTCB) for closing the connection */
if(ipcom_mib2_set_tcpConnectionState(&pSetEntry, pReqTcpConnEntry->tcpConnState) != OK)
return (ERROR);
return (OK);
}
/*******************************************************************************
*
* m2TcpDelete - delete all resources used to access the TCP group
*
* 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:
* m2TcpInit(), m2TcpGroupInfoGet(), m2TcpConnEntryGet(), m2TcpConnEntrySet()
*/
STATUS m2TcpDelete (void)
{
return (OK);
}
@@ -0,0 +1,452 @@
/* m2UdpLib.c - MIB-II UDP-group API for SNMP agents */
/* Copyright 1984 - 2005 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01t,14oct10,h_x Fix WIND00236294
01s,15jul08,zhr Fixed WIND00125371 and updated for apigen and warning
01r,05jun08,zhr updated for GPP
01q,25mar08,zhr Migratied to IPNET
01p,12jan05,vvv osdep.h cleanup
01o,12may04,vvv fixed udpInDatagrams (SPR #94780)
01n,06nov03,rlm Ran batch header update for header re-org.
01m,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE
01l,01oct02,ann reverted the compARISON LOgic in the Get routines
01k,16may02,ant integration into Clarinet
01j,26oct01,spm isolated virtual stack data structures (SPR #71092)
01i,23jul01,vvv fixed documentation for UDP connection table NEXT_VALUE
search
01h,20jul01,vvv reversed previous fix for SPR #68596
01g,29jun01,vvv fixed SPR #68596 (NEXT_VALUE search in listener table
returns current entry instead of next one);
fixed SPR #68597 (in m2UdpTblEntryGet address and port
are converted to network order instead of host order)
01f,29mar01,spm merged changes from version 01e of tor2_0.open_stack
branch (wpwr VOB, base 01d) for unified code base
01e,25oct00,ham doc: cleanup for vxWorks AE 1.0.
01d,08mar97,vin added changes to accomodate changes in pcb structure.
01c,25jan95,jdi doc cleanup.
01b,11nov94,rhp edited man pages
01a,08dec93,jag written
*/
/*
DESCRIPTION
This library provides MIB-II services for the UDP group. It provides
routines to initialize the group, access the group scalar variables, and
read the table of UDP listeners. For a broader description of MIB-II
services, see the manual entry for m2Lib.
To use this feature, include the following component:
INCLUDE_MIB2_UDP
USING THIS LIBRARY
This library can be initialized and deleted by calling
m2UdpInit() and m2UdpDelete() respectively, if only the UDP 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 scalar variables are accessed by calling m2UdpGroupInfoGet()
as follows:
.CS
M2_UDP udpVars;
if (m2UdpGroupInfoGet (&udpVars) == OK)
/@ values in udpVars are valid @/
.CE
The UDP table of listeners can be accessed in lexicographical order.
The first entry in the table can be accessed by setting the table
index to zero in a call to m2UdpTblEntryGet(). Every other entry
thereafter can be accessed by incrementing the index returned from the
previous invocation to the next possible lexicographical index, and
repeatedly calling m2UdpTblEntryGet() with the M2_NEXT_VALUE constant
as the search parameter. For example:
.CS
M2_UDPTBL udpEntry;
/@ Specify zero index to get the first entry in the table @/
udpEntry.udpLocalAddress = 0; /@ local IP Address in host byte order @/
udpEntry.udpLocalPort = 0; /@ local port Number @/
/@ get the first entry in the table @/
if ((m2UdpTblEntryGet (M2_NEXT_VALUE, &udpEntry) == OK)
/@ values in udpEntry 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 0.0.0.0.3000 the index passed in the
* next invocation should be 0.0.0.0.3001. 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 ((m2UdpTblEntryGet (M2_NEXT_VALUE, &udpEntry) == OK)
/@ values in udpEntry in the second entry are valid @/
.CE
INCLUDE FILES: m2Lib.h
SEE ALSO:
m2Lib, m2IfLib, m2IpLib, m2IcmpLib, m2TcpLib, m2SysLib
*/
/* includes */
#include <m2Lib.h>
#include <errnoLib.h>
#include <in.h>
#include <asn1conf.h>
#include <ipnet_h.h>
#include <ipcom_mib2_api.h>
#include <stdlib.h>
#include <string.h>
/* typedef for tcpConnectionEntry migration to ipnet */
typedef struct
{
int tcount;
OIDC_T * tlist;
M2_UDPTBL * reqInstance;
Ipcom_mib2_UdpEndpointEntry * dataPtr;
boolean_t getnext; /* FALSE = getexact */
} M2_ipcom_mib2_Ipnet_udp_entry_cookie_t;
/* locals */
LOCAL Ipcom_mib2_UdpEndpointEntry * ipcom_mib2_Ipcom_mib2_udpEntry_lookup
(M2_UDPTBL *, boolean_t);
LOCAL int udpEntry_callback (Ipcom_mib2_UdpEndpointEntry *, void *);
LOCAL long udpCmp( M2_UDPTBL *, M2_UDPTBL *);
/* external declarations */
IMPORT Ipnet_data * getIpnet();
/*******************************************************************************
*
* m2UdpInit - initialize MIB-II UDP-group access
*
* This routine allocates the resources needed to allow access to the UDP
* MIB-II variables. This routine must be called before any UDP variables
* can be accessed.
*
* RETURNS: OK, always.
*
* SEE ALSO:
* m2UdpGroupInfoGet(), m2UdpTblEntryGet(), m2UdpDelete()
*
* \NOMANUAL
*/
STATUS m2UdpInit (void)
{
return (OK);
}
/*******************************************************************************
*
* m2UdpGroupInfoGet - get MIB-II UDP-group scalar variables
*
* This routine fills in the UDP structure at <pUdpInfo> with the MIB-II
* UDP scalar variables.
*
* RETURNS: OK, or ERROR if <pUdpInfo> is not a valid pointer.
*
* ERRNO:
* S_m2Lib_INVALID_PARAMETER
*
* SEE ALSO:
* m2UdpInit(), m2UdpTblEntryGet(), m2UdpDelete()
*/
STATUS m2UdpGroupInfoGet
(
M2_UDP * pUdpInfo /* pointer to the UDP group structure */
)
{
Ipcom_mib2_udp_group udpGroup;
/* Validate Pointer to UDP structure */
if (ipcom_mib2_get_udp_group(&udpGroup) == -1 )
return (ERROR);
if (pUdpInfo == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
pUdpInfo->udpNoPorts = udpGroup.udpNoPorts;
pUdpInfo->udpInDatagrams = udpGroup.udpInDatagrams;
/* The number UDP packets deliever to UDP users. */
pUdpInfo->udpOutDatagrams = udpGroup.udpOutDatagrams;
/* The number UDP packets not deliever due to errors */
pUdpInfo->udpInErrors = udpGroup.udpInErrors;
return (OK);
}
/************************************************************************************
*
* udpCmp - compare index key of an entry in udpTable with a key in the request
*
* The routine compares a udp connection entry with an index key given by the pConnVal2
* repeatedly in iterations. The compariation is carried out based on the request type.
*
* RETURNS: 1 - greater than the key, 0 - find a matched entry , -1 - less than the key .
*
* SEE ALSO: N/A
*
* \NOMANUAL
*/
LOCAL long udpCmp
(
M2_UDPTBL * pConnVal1, /* pointer to control block (Compare againts) */
M2_UDPTBL * pConnVal2 /* pointer to control block (Second entry) */
)
{
long result;
if (pConnVal1->udpLocalAddress > pConnVal2->udpLocalAddress)
{
return 1; /* First Entry is Greater */
}
if (pConnVal1->udpLocalAddress < pConnVal2->udpLocalAddress)
{
return -1; /* First Entry is Smaller */
}
/* Comparison of two signed values */
result = pConnVal1->udpLocalPort - pConnVal2->udpLocalPort;
return (result); /* Value > 0 or < 0 or == 0 */
}
/************************************************************************************
*
* udpEntry_callback - RFC1213 udpTable callback
*
* The routine compares a udp connection entry with an index key given by the "user"
* repeatedly in iterations. The compariation is carried out based on the request type.
* The request type can be "get" M2_EXACT_VALUE or "getnext" M2_NEXT_VALU which is in a
* lexicographicl order specified by MIB-II.
*
* RETURNS: 1 stop - find a matched entry , 0 - not match and continue iterations.
*
* SEE ALSO: N/A
*
* \NOMANUAL
*/
LOCAL int udpEntry_callback(Ipcom_mib2_UdpEndpointEntry * entry, void * user)
{
M2_ipcom_mib2_Ipnet_udp_entry_cookie_t *cookie = (M2_ipcom_mib2_Ipnet_udp_entry_cookie_t *) user;
boolean_t stopIterating = FALSE;
boolean_t saveData = FALSE;
M2_UDPTBL tableEntry;
M2_UDPTBL prevEntry;
if ( entry == NULL )
return 0;
tableEntry.udpLocalAddress = ntohl(*(Ip_u32 *)entry->udpEndpointLocalAddress);
tableEntry.udpLocalPort = entry->udpEndpointLocalPort;
if (cookie->getnext)
{
if ( ((cookie->reqInstance->udpLocalAddress == 0) &&
(cookie->reqInstance->udpLocalPort == 0))||
(udpCmp(&tableEntry, cookie->reqInstance) > 0) )
{
if (cookie->dataPtr == NULL)
/* first entry in the table */
{
saveData = TRUE;
}
else /* There is alreay a entry stored in data and compare it with the new
* entry. Keep the smaller one.
*/
{
prevEntry.udpLocalAddress = ntohl(*(Ip_u32 *)cookie->dataPtr->udpEndpointLocalAddress) ;
prevEntry.udpLocalPort = cookie->dataPtr->udpEndpointLocalPort;
if (udpCmp(&tableEntry, &prevEntry) < 0 )
saveData = TRUE;
}
}
else if (udpCmp (&tableEntry, cookie->reqInstance) == 0 )
/* supporsed next instance of pReqTcpConnEntry is found */
{
saveData = TRUE;
stopIterating = TRUE;
}
}
else /* Get exact */
{
if (udpCmp(&tableEntry, cookie->reqInstance) == 0)
{
saveData = TRUE;
stopIterating = TRUE;
}
}
if ( saveData)
{
if (cookie->dataPtr == NULL)
cookie->dataPtr = (Ipcom_mib2_UdpEndpointEntry *)SNMP_memory_alloc (sizeof (Ipcom_mib2_UdpEndpointEntry));
if (cookie->dataPtr != NULL)
memcpy (cookie->dataPtr, entry, sizeof (Ipcom_mib2_UdpEndpointEntry));
/* Return values defined are part of callback API. */
}
return (stopIterating? 1: 0);
}
/**************************************************************************
*
* ipcom_mib2_Ipcom_mib2_udpEntry_lookup - Search a RFC1213 udpTable
*
* The routine search a udpTable through a API provided by the IPNET,
* which is ipcom_mib2_iterate_udpEndpointTable. It executes a user
* defined callback function for each iteration. Note that if the table
* is empty the callback will not be called and the routine will return
* zero.
*
* RETURNS: a entry found or NULL
*
* SEE ALSO: N/A
*
* \NOMANUAL
*/
LOCAL Ipcom_mib2_UdpEndpointEntry * ipcom_mib2_Ipcom_mib2_udpEntry_lookup
(
M2_UDPTBL * reqInstance,
boolean_t getnext
)
{
M2_ipcom_mib2_Ipnet_udp_entry_cookie_t cookie;
cookie.dataPtr = NULL;
cookie.getnext = getnext;
cookie.reqInstance = reqInstance;
ipcom_mib2_iterate_udpEndpointTable(udpEntry_callback,
(void *)&cookie);
return (cookie.dataPtr);
}
/*******************************************************************************
*
* m2UdpTblEntryGet - get a UDP MIB-II entry from the UDP list of listeners
*
* This routine traverses the UDP table of listeners 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
* <pUdpEntry>. The index is made up of the IP address and the local
* port number. 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:
* m2Lib, m2UdpInit(), m2UdpGroupInfoGet(), m2UdpDelete()
*/
STATUS m2UdpTblEntryGet
(
int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */
M2_UDPTBL * pUdpEntry /* ptr to the requested entry with index */
)
{
Ipcom_mib2_UdpEndpointEntry *data;
/* Validate Pointer to UDP Table Entry structure */
if (pUdpEntry == NULL)
{
errnoSet (S_m2Lib_INVALID_PARAMETER);
return (ERROR);
}
/*
* Initialize Entry for M2_NEXT_VALUE entry search. Not used in
* M2_EXACT_VALUE search.
*/
if ((pUdpEntry == NULL) || ((search != M2_EXACT_VALUE) &&
(search != M2_NEXT_VALUE)))
{
errnoSet(S_m2Lib_INVALID_PARAMETER);
return (ERROR); /* invalid argument */
}
if (search == M2_EXACT_VALUE)
{
if ((data = (Ipcom_mib2_UdpEndpointEntry *) ipcom_mib2_Ipcom_mib2_udpEntry_lookup
(pUdpEntry, FALSE)) == NULL)
{
return (ERROR);
}
}
else /* getNext */
{
if ((data = (Ipcom_mib2_UdpEndpointEntry *) ipcom_mib2_Ipcom_mib2_udpEntry_lookup
(pUdpEntry, TRUE)) == NULL)
{
return (ERROR);
}
}
/* Fill the request structure with the found entry */
pUdpEntry->udpLocalAddress = ntohl(*(Ip_u32 *)data->udpEndpointLocalAddress);
pUdpEntry->udpLocalPort = data->udpEndpointLocalPort;
free(data);
return (OK);
}
/*******************************************************************************
*
* m2UdpDelete - delete all resources used to access the UDP group
*
* This routine frees all the resources allocated at the time the group was
* initialized. The UDP group should not be accessed after this routine has been
* called.
*
* RETURNS: OK, always.
*
* SEE ALSO:
* m2UdpInit(), m2UdpGroupInfoGet(), m2UdpTblEntryGet()
*/
STATUS m2UdpDelete (void)
{
return (OK);
}
@@ -0,0 +1,138 @@
/* m2Util.c - snmp APIs */
/* Copyright 2004 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
01b,01aug08,zhr Fixed WIND00128350
01a,05jun08,zhr written from sysLib.c for m2Lib
*/
/*
DESCRIPTION
This library contains various APIs for m2Lib independantly from
SNMP stuff.
*/
#include "vxWorks.h"
#include <sys/sysctl.h>
#include "sysLib.h"
#include "asn1conf.h"
int oidcmp2(int n1, OIDC_T *idp1, int n2, OIDC_T *idp2);
int ip_to_llist(UINT_32_T ip,INT_32_T *llist);
/*******************************************************************************
*
* oidcmp2 - compare any two objects identifiers
* SYNOPSIS
*
* \cs
* int oidcmp2
* (
* int n1,
* OIDC_T * idp1,
* int n2,
* OIDC_T * idp2
* )
* \ce
*
* DESCRIPTION
*
* This routine compares any two objects identifiers. This routine combines the
* functions of both oidorder() and oidcmp().
*
* PARAMETERS
* \is
* \i <n1>
* Specify the length of the first object identifier
* \i <*idp1>
* Specify the first object identifier.
* \i <n2>
* Specify the length of the second object identifier.
* \i <*idp2>
* Specify the second object identifier.
* \i <*idp1>
* Specify the first object identifier.
* \i <n2>
* Specify the length of the second object identifier.
* \i <*idp2>
* Specify the second object identifier.
* \ie
*
* RETURNS: If <idp1> is greater than <idp2>, this routine returns 1. If <idp1>
* is less than <idp2>, it returns -1. If they are the same, it returns 0.
*
* ERRNO: N/A
*
* SEE ALSO: llist_cmp(), oidcmp(), oidorder()
*/
int
oidcmp2(int n1, OIDC_T *idp1, int n2, OIDC_T *idp2)
{
while ((n1 > 0) && (n2 > 0)) {
if (*idp1 != *idp2)
return (*idp1 < *idp2) ? -1 : 1;
idp1++; idp2++; n1--; n2--;
}
if (n1 == n2)
return 0; /* OIDs are the same */
else if (n1 > n2)
return 1;
else
return -1;
}
/*******************************************************************************
*
* ip_to_llist - fill an object ID with the byte components of an IP address
* SYNOPSIS
*
* \cs
* int ip_to_llist
* (
* UINT_32_T ip_address,
* INT_32_T * long_list
* )
* \ce
*
*
* DESCRIPTION
*
* This routine fills an object ID with the byte components of an IP address.
*
* PARAMETERS
* \is
* \i <ip_address>
* Specify an IP address.
* \i <*long_list>
* Specify an object ID.
* \ie
*
* RETURNS: This routine always returns the number of components (4).
*
* ERRNO: N/A
*
* SEE ALSO: ip_to_rlist(), oid_to_ip()
*/
int
ip_to_llist(UINT_32_T ip,
INT_32_T *llist)
{
union {
UINT_32_T laddr;
OCTET_T baddr[4];
} ip_address;
int i;
ip_address.laddr = ip;
for (i = 0; i < 4; i++)
*llist++ = ip_address.baddr[i];
return 4;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,181 @@
/******************************************************************************
******************************************************************************
**** This file was automatically generated by Wind River's
**** MIB Compiler, version 10.2.
**** This file was generated using the -mib.c switch.
****
**** This file contains a representation of a MIB tree suitable
**** for use by an SNMP agent running Wind River's WindManage SNMP package.
****
**** DO NOT EDIT THIS FILE BY HAND.
****
**** Last build date: Wed Jun 11 14:43:47 2008
**** from files:
****
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1213.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2571.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2575.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1907.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/iftype.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2233.mib,
**** rfc2233.ctl, snmpmib2.mib
**** starting from node: tcp
******************************************************************************
******************************************************************************
*/
#define _MIB 1
#include <wrn/wm/snmp/engine/mib.h>
#include <wrn/wm/snmp/engine/snmpdefs.h>
#include <wrn/wm/snmp/engine/snmpstat.h>
#include <wrn/wm/snmp/vxagent/mibhand.h>
#ifndef STATIC
#define STATIC static
#endif
/**
** Subtree Object Identifier for Add_Node_From_Root
** tcp OBJECT IDENTIFIER ::= { mib-2 6 }
**/
STATIC OIDC_T oid_tcp1213_root_node[] = { 1, 3, 6, 1, 2, 1, 6 };
OBJ_ID_T objid_tcp1213_root_node = {
sizeof(oid_tcp1213_root_node)/sizeof(OIDC_T),
oid_tcp1213_root_node
};
LEAF_NT_ASYS( l_tcpRtoAlgorithm, REPLACEABLE, "tcpRtoAlgorithm", VT_NUMBER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpRtoMin, REPLACEABLE, "tcpRtoMin", VT_NUMBER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpRtoMax, REPLACEABLE, "tcpRtoMax", VT_NUMBER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpMaxConn, REPLACEABLE, "tcpMaxConn", VT_NUMBER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpActiveOpens, REPLACEABLE, "tcpActiveOpens", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpPassiveOpens, REPLACEABLE, "tcpPassiveOpens", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpAttemptFails, REPLACEABLE, "tcpAttemptFails", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpEstabResets, REPLACEABLE, "tcpEstabResets", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpCurrEstab, REPLACEABLE, "tcpCurrEstab", VT_GAUGE,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpInSegs, REPLACEABLE, "tcpInSegs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpOutSegs, REPLACEABLE, "tcpOutSegs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpRetransSegs, REPLACEABLE, "tcpRetransSegs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpConnState, REPLACEABLE, "tcpConnState", VT_NUMBER,
READ_WRITE_ACCESS, TABULAR, tcpConnEntryTest,
tcpConnEntryGet, tcpConnEntrySet, tcpConnEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpConnLocalAddress, REPLACEABLE, "tcpConnLocalAddress", VT_IPADDRESS,
READ_ACCESS, TABULAR, null_test_async,
tcpConnEntryGet, null_set_async, tcpConnEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpConnLocalPort, REPLACEABLE, "tcpConnLocalPort", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
tcpConnEntryGet, null_set_async, tcpConnEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpConnRemAddress, REPLACEABLE, "tcpConnRemAddress", VT_IPADDRESS,
READ_ACCESS, TABULAR, null_test_async,
tcpConnEntryGet, null_set_async, tcpConnEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpConnRemPort, REPLACEABLE, "tcpConnRemPort", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
tcpConnEntryGet, null_set_async, tcpConnEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_tcpConnEntry[] = {
ARC(1, l_tcpConnState),
ARC(2, l_tcpConnLocalAddress),
ARC(3, l_tcpConnLocalPort),
ARC(4, l_tcpConnRemAddress),
ARC(5, l_tcpConnRemPort),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_tcpConnEntry = NODE_NT("tcpConnEntry",
REPLACEABLE, a_tcpConnEntry);
STATIC
MIBARC_T a_tcpConnTable[] = {
ARC(1, n_tcpConnEntry),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_tcpConnTable = NODE_NT("tcpConnTable",
REPLACEABLE, a_tcpConnTable);
LEAF_NT_ASYS( l_tcpInErrs, REPLACEABLE, "tcpInErrs", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_tcpOutRsts, REPLACEABLE, "tcpOutRsts", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
tcpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_tcp[] = {
ARC(1, l_tcpRtoAlgorithm),
ARC(2, l_tcpRtoMin),
ARC(3, l_tcpRtoMax),
ARC(4, l_tcpMaxConn),
ARC(5, l_tcpActiveOpens),
ARC(6, l_tcpPassiveOpens),
ARC(7, l_tcpAttemptFails),
ARC(8, l_tcpEstabResets),
ARC(9, l_tcpCurrEstab),
ARC(10, l_tcpInSegs),
ARC(11, l_tcpOutSegs),
ARC(12, l_tcpRetransSegs),
ARC(13, n_tcpConnTable),
ARC(14, l_tcpInErrs),
ARC(15, l_tcpOutRsts),
END_OF_ARC_LIST };
MIBNODE_T tcp1213_root_node = NODE_NT("tcp",
REPLACEABLE, a_tcp);
@@ -0,0 +1,103 @@
/******************************************************************************
******************************************************************************
**** This file was automatically generated by Wind River's
**** MIB Compiler, version 10.2.
**** This file was generated using the -mib.c switch.
****
**** This file contains a representation of a MIB tree suitable
**** for use by an SNMP agent running Wind River's WindManage SNMP package.
****
**** DO NOT EDIT THIS FILE BY HAND.
****
**** Last build date: Wed Jun 11 18:03:44 2008
**** from files:
****
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1213.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2571.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2575.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc1907.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/iftype.mib,
**** /home/cdinstall/MSP0708Cd/vxworks-6.7/target/src/wrn/wm/snmp/std-mibs/rfc2233.mib,
**** rfc2233.ctl, snmpmib2.mib
**** starting from node: udp
******************************************************************************
******************************************************************************
*/
#define _MIB 1
#include <wrn/wm/snmp/engine/mib.h>
#include <wrn/wm/snmp/engine/snmpdefs.h>
#include <wrn/wm/snmp/engine/snmpstat.h>
#include <wrn/wm/snmp/vxagent/mibhand.h>
#ifndef STATIC
#define STATIC static
#endif
/**
** Subtree Object Identifier for Add_Node_From_Root
** udp OBJECT IDENTIFIER ::= { mib-2 7 }
**/
STATIC OIDC_T oid_udp1213_root_node[] = { 1, 3, 6, 1, 2, 1, 7 };
OBJ_ID_T objid_udp1213_root_node = {
sizeof(oid_udp1213_root_node)/sizeof(OIDC_T),
oid_udp1213_root_node
};
LEAF_NT_ASYS( l_udpInDatagrams, REPLACEABLE, "udpInDatagrams", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
udpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_udpNoPorts, REPLACEABLE, "udpNoPorts", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
udpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_udpInErrors, REPLACEABLE, "udpInErrors", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
udpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_udpOutDatagrams, REPLACEABLE, "udpOutDatagrams", VT_COUNTER,
READ_ACCESS, SCALAR, null_test_async,
udpGet, null_set_async, std_next_async,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_udpLocalAddress, REPLACEABLE, "udpLocalAddress", VT_IPADDRESS,
READ_ACCESS, TABULAR, null_test_async,
udpEntryGet, null_set_async, udpEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
LEAF_NT_ASYS( l_udpLocalPort, REPLACEABLE, "udpLocalPort", VT_NUMBER,
READ_ACCESS, TABULAR, null_test_async,
udpEntryGet, null_set_async, udpEntryNext,
(char*) 0,
0x0000, 0xFF, 0xFF);
STATIC
MIBARC_T a_udpEntry[] = {
ARC(1, l_udpLocalAddress),
ARC(2, l_udpLocalPort),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_udpEntry = NODE_NT("udpEntry",
REPLACEABLE, a_udpEntry);
STATIC
MIBARC_T a_udpTable[] = {
ARC(1, n_udpEntry),
END_OF_ARC_LIST };
STATIC
MIBNODE_T n_udpTable = NODE_NT("udpTable",
REPLACEABLE, a_udpTable);
STATIC
MIBARC_T a_udp[] = {
ARC(1, l_udpInDatagrams),
ARC(2, l_udpNoPorts),
ARC(3, l_udpInErrors),
ARC(4, l_udpOutDatagrams),
ARC(5, n_udpTable),
END_OF_ARC_LIST };
MIBNODE_T udp1213_root_node = NODE_NT("udp",
REPLACEABLE, a_udp);