version 1.7, 2007/06/29 17:43:11
|
version 1.8, 2007/08/09 17:05:34
|
|
|
| |
const String SNMPV1_HANDLER_NAME = String ("SNMPHandler01"); | const String SNMPV1_HANDLER_NAME = String ("SNMPHandler01"); |
const String SNMPV2C_HANDLER_NAME = String ("SNMPHandler02"); | const String SNMPV2C_HANDLER_NAME = String ("SNMPHandler02"); |
|
const String SNMPV2C_IPV6_HANDLER_NAME = String ("SNMPHandler03"); |
const String FILTER_NAME = String ("IPFilter01"); | const String FILTER_NAME = String ("IPFilter01"); |
| |
enum SNMPVersion {_SNMPV1_TRAP = 2, _SNMPV2C_TRAP = 3}; | enum SNMPVersion {_SNMPV1_TRAP = 2, _SNMPV2C_TRAP = 3}; |
|
|
| |
#define PORT_NUMBER 2006 | #define PORT_NUMBER 2006 |
| |
Uint32 indicationSendCountTotal = 0; |
|
|
|
AtomicInt errorsEncountered(0); | AtomicInt errorsEncountered(0); |
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
|
|
CIMObjectPath filterObjectPath; | CIMObjectPath filterObjectPath; |
CIMObjectPath snmpv1HandlerObjectPath; | CIMObjectPath snmpv1HandlerObjectPath; |
CIMObjectPath snmpv2HandlerObjectPath; | CIMObjectPath snmpv2HandlerObjectPath; |
|
CIMObjectPath snmpv2IPV6HandlerObjectPath; |
| |
try | try |
{ | { |
|
|
throw; | throw; |
} | } |
} | } |
|
|
|
#if defined(PEGASUS_ENABLE_IPV6) |
|
// create a subscription with trap destination of IPV6 address format |
|
try |
|
{ |
|
// Create SNMPv2 IPV6 trap handler |
|
snmpv2IPV6HandlerObjectPath = _createHandlerInstance (client, |
|
SNMPV2C_IPV6_HANDLER_NAME, |
|
String("::1"), |
|
"public", |
|
_IPV6_ADDRESS, |
|
_SNMPV2C_TRAP); |
|
} |
|
catch (CIMException& e) |
|
{ |
|
if (e.getCode() == CIM_ERR_ALREADY_EXISTS) |
|
{ |
|
snmpv2IPV6HandlerObjectPath = _getHandlerObjectPath( |
|
SNMPV2C_IPV6_HANDLER_NAME); |
|
cerr << "----- Warning: SNMPv2c IPV6 Trap Handler Instance " |
|
"Not Created: " << e.getMessage () << endl; |
|
} |
|
else |
|
{ |
|
cerr << "----- Error: SNMPv2c IPV6 Trap Handler Instance Not " |
|
"Created: " << endl; |
|
throw; |
|
} |
|
} |
|
|
|
try |
|
{ |
|
_createSubscriptionInstance (client, filterObjectPath, |
|
snmpv2IPV6HandlerObjectPath); |
|
} |
|
catch (CIMException& e) |
|
{ |
|
if (e.getCode() == CIM_ERR_ALREADY_EXISTS) |
|
{ |
|
cerr << "----- Warning: Client Subscription Instance: " |
|
<< e.getMessage () << endl; |
|
} |
|
else |
|
{ |
|
cerr << "----- Error: Client Subscription Instance: " << endl; |
|
throw; |
|
} |
|
} |
|
#endif |
} | } |
| |
void _cleanup (CIMClient & client) | void _cleanup (CIMClient & client) |
|
|
throw; | throw; |
} | } |
} | } |
|
|
|
#if defined(PEGASUS_ENABLE_IPV6) |
|
try |
|
{ |
|
_deleteSubscriptionInstance (client, FILTER_NAME, |
|
SNMPV2C_IPV6_HANDLER_NAME); |
|
} |
|
catch (CIMException& e) |
|
{ |
|
if (e.getCode() != CIM_ERR_NOT_FOUND) |
|
{ |
|
cerr << "----- Error: deleteSubscriptionInstance failure: " |
|
<< endl; |
|
throw; |
|
} |
|
} |
|
#endif |
|
|
try | try |
{ | { |
_deleteFilterInstance (client, FILTER_NAME); | _deleteFilterInstance (client, FILTER_NAME); |
|
|
throw; | throw; |
} | } |
} | } |
|
#if defined(PEGASUS_ENABLE_IPV6) |
|
try |
|
{ |
|
_deleteHandlerInstance (client, SNMPV2C_IPV6_HANDLER_NAME); |
|
} |
|
catch (CIMException& e) |
|
{ |
|
if (e.getCode() != CIM_ERR_NOT_FOUND) |
|
{ |
|
cerr << "----- Error: deleteHandlerInstance failure: " << endl; |
|
throw; |
|
} |
|
} |
|
#endif |
} | } |
| |
static void _testEnd(const String& uniqueID, const double elapsedTime) | static void _testEnd(const String& uniqueID, const double elapsedTime) |
|
|
snmptrapdCmd.append( " -F \"\nTrap Info: %P\nVariable: %v\n\""); | snmptrapdCmd.append( " -F \"\nTrap Info: %P\nVariable: %v\n\""); |
| |
// Specify listening address | // Specify listening address |
|
#if defined(PEGASUS_ENABLE_IPV6) |
|
snmptrapdCmd.append(" UDP6:"); |
|
snmptrapdCmd.append(portNumberStr); |
|
snmptrapdCmd.append(",UDP:"); |
|
#else |
snmptrapdCmd.append(" UDP:"); | snmptrapdCmd.append(" UDP:"); |
|
#endif |
snmptrapdCmd.append(System::getFullyQualifiedHostName ()); | snmptrapdCmd.append(System::getFullyQualifiedHostName ()); |
| |
snmptrapdCmd.append(":"); | snmptrapdCmd.append(":"); |
|
|
Uint32 indicationSendCount, | Uint32 indicationSendCount, |
Uint32 runClientThreadCount) | Uint32 runClientThreadCount) |
{ | { |
|
Uint32 indicationTrapV1SendCount = 0; |
|
Uint32 indicationTrapV2SendCount = 0; |
|
|
CIMClient * clientConnections = new CIMClient[runClientThreadCount]; | CIMClient * clientConnections = new CIMClient[runClientThreadCount]; |
| |
// determine total number of indication send count | // determine total number of indication send count |
indicationSendCountTotal = indicationSendCount * runClientThreadCount; |
indicationTrapV1SendCount = |
|
indicationSendCount * runClientThreadCount; |
|
|
|
// if IPV6 is enabled, an additional SNMPv2c trap is sent to IPV6 address |
|
#if defined(PEGASUS_ENABLE_IPV6) |
|
indicationTrapV2SendCount = 2 * indicationTrapV1SendCount; |
|
#else |
|
indicationTrapV2SendCount = indicationTrapV1SendCount; |
|
#endif |
| |
// calculate the timeout based on the total send count allowing | // calculate the timeout based on the total send count allowing |
// using the MSG_PER_SEC rate | // using the MSG_PER_SEC rate |
|
|
#define MSG_PER_SEC 4 | #define MSG_PER_SEC 4 |
| |
Uint32 testTimeout = PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS | Uint32 testTimeout = PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS |
+ (indicationSendCountTotal/MSG_PER_SEC)*1000; |
+ (indicationTrapV2SendCount/MSG_PER_SEC)*1000; |
| |
// connect the clients | // connect the clients |
for(Uint32 i = 0; i < runClientThreadCount; i++) | for(Uint32 i = 0; i < runClientThreadCount; i++) |
|
|
| |
// | // |
// Wait for the trap receiver to receive the expected | // Wait for the trap receiver to receive the expected |
// number of Indication traps, indicationSendCountTotal. |
// number of Indication traps, indicationTrapV1SendCount |
|
// and indicationTrapV2SendCount. |
// | // |
// We will continue to wait until either indicationSendCountTotal |
// We will continue to wait until either (indicationTrapV1SendCount |
// Indications have been received by the trap receiver or no new |
// and indicationTrapV2SendCount) Indications have been received |
|
// by the trap receiver or no new |
// Indications have been received in the previous | // Indications have been received in the previous |
// MAX_NO_CHANGE_ITERATIONS. | // MAX_NO_CHANGE_ITERATIONS. |
// iterations. | // iterations. |
|
|
{ | { |
cout << "++++ The trap receiver has received " | cout << "++++ The trap receiver has received " |
<< currentReceivedTrap1Count << " of " | << currentReceivedTrap1Count << " of " |
<< indicationSendCountTotal << " SNMPv1 trap." |
<< indicationTrapV1SendCount << " SNMPv1 trap." |
<< endl; | << endl; |
cout << "++++ The trap receiver has received " | cout << "++++ The trap receiver has received " |
<< currentReceivedTrap2Count << " of " | << currentReceivedTrap2Count << " of " |
<< indicationSendCountTotal << " SNMPv2c trap." |
<< indicationTrapV2SendCount << " SNMPv2c trap." |
<< endl; | << endl; |
} | } |
| |
if ((indicationSendCountTotal == currentReceivedTrap1Count) && |
if ((indicationTrapV1SendCount == currentReceivedTrap1Count) && |
(indicationSendCountTotal == currentReceivedTrap2Count)) |
(indicationTrapV2SendCount == currentReceivedTrap2Count)) |
{ | { |
receivedTrapCountComplete = true; | receivedTrapCountComplete = true; |
trapReceiverElapsedTime.stop(); | trapReceiverElapsedTime.stop(); |
|
|
{ | { |
cout << "++++ The trap receiver has received " | cout << "++++ The trap receiver has received " |
<< currentReceivedTrap1Count << " of " | << currentReceivedTrap1Count << " of " |
<< indicationSendCountTotal << " SNMPv1 trap." |
<< indicationTrapV1SendCount << " SNMPv1 trap." |
<< endl; | << endl; |
cout << "++++ The trap receiver has received " | cout << "++++ The trap receiver has received " |
<< currentReceivedTrap2Count << " of " | << currentReceivedTrap2Count << " of " |
<< indicationSendCountTotal << " SNMPv2c trap." |
<< indicationTrapV2SendCount << " SNMPv2c trap." |
<< endl; | << endl; |
| |
break; | break; |
|
|
} | } |
| |
// assert that all indications sent have been received. | // assert that all indications sent have been received. |
PEGASUS_TEST_ASSERT(indicationSendCountTotal == |
PEGASUS_TEST_ASSERT(indicationTrapV1SendCount == |
currentReceivedTrap1Count); | currentReceivedTrap1Count); |
PEGASUS_TEST_ASSERT(indicationSendCountTotal == |
PEGASUS_TEST_ASSERT(indicationTrapV2SendCount == |
currentReceivedTrap2Count); | currentReceivedTrap2Count); |
} | } |
| |