version 1.12, 2002/09/13 21:40:42
|
version 1.12.12.1, 2003/07/29 15:08:29
|
|
|
// | // |
// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company | // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company |
// (carolann_graves@hp.com) | // (carolann_graves@hp.com) |
|
// : Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
//#define DDD(X) X |
|
#define DDD(X) // X |
|
|
|
DDD(static const char* _SNMPINDICATIONHANDLER = "snmpIndicationHandler::";) |
|
|
|
void snmpIndicationHandler::initialize(CIMRepository* repository) | void snmpIndicationHandler::initialize(CIMRepository* repository) |
{ | { |
_repository = repository; | _repository = repository; |
DDD(cout << _SNMPINDICATIONHANDLER << "initialize()" << endl;) |
|
} | } |
| |
|
// l10n - note: ignoring indication language |
void snmpIndicationHandler::handleIndication(CIMInstance& handler, | void snmpIndicationHandler::handleIndication(CIMInstance& handler, |
CIMInstance& indication, String nameSpace) |
CIMInstance& indication, String nameSpace, |
|
ContentLanguages & contentLanguages) |
{ | { |
Array<String> propOIDs; | Array<String> propOIDs; |
Array<String> propTYPEs; | Array<String> propTYPEs; |
|
|
CIMClass indicationClass = _repository->getClass( | CIMClass indicationClass = _repository->getClass( |
nameSpace, indication.getClassName(), false); | nameSpace, indication.getClassName(), false); |
| |
for (Uint32 i=0; i<indication.getPropertyCount();i++) |
Uint32 propertyCount = indication.getPropertyCount(); |
|
|
|
for (Uint32 i=0; i < propertyCount; i++) |
{ | { |
prop = indication.getProperty(i); | prop = indication.getProperty(i); |
| |
|
|
snmpDeliverTrap_stub emanateTrap; | snmpDeliverTrap_stub emanateTrap; |
#endif | #endif |
| |
if ((handler.findProperty(CIMName ("TrapDestination")) != PEG_NOT_FOUND) && |
Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost")); |
(handler.findProperty(CIMName ("SNMPVersion")) != PEG_NOT_FOUND) && |
Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat")); |
|
Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName ( |
|
"OtherTargetHostFormat")); |
|
Uint32 portNumberPos = handler.findProperty(CIMName ("PortNumber")); |
|
Uint32 snmpVersionPos = handler.findProperty(CIMName ("SNMPVersion")); |
|
Uint32 securityNamePos = handler.findProperty(CIMName ("SNMPSecurityName")); |
|
Uint32 engineIDPos = handler.findProperty(CIMName ("SNMPEngineID")); |
|
|
|
if ((targetHostPos != PEG_NOT_FOUND) && |
|
(targetHostFormatPos != PEG_NOT_FOUND) && |
|
(snmpVersionPos != PEG_NOT_FOUND) && |
(indicationClass.findQualifier(CIMName ("MappingStrings")) != | (indicationClass.findQualifier(CIMName ("MappingStrings")) != |
PEG_NOT_FOUND)) | PEG_NOT_FOUND)) |
{ | { |
String community, trapType, destination; // from handler instance |
// properties from the handler instance |
String trapOid; // from indication Class |
String targetHost, otherTargetHostFormat; |
|
String securityName, engineID; |
|
Uint16 targetHostFormat, snmpVersion; |
|
Uint32 portNumber; |
| |
trapOid = indicationClass.getQualifier( |
// trapOid from indication Class |
|
|
|
String trapOid = indicationClass.getQualifier( |
indicationClass.findQualifier | indicationClass.findQualifier |
(CIMName ("MappingStrings"))).getValue().toString(); | (CIMName ("MappingStrings"))).getValue().toString(); |
| |
trapOid = trapOid.subString(trapOid.find("OID.IETF | SNMP.")+16); |
Uint32 index = trapOid.find("SNMP."); |
|
|
|
if (index != PEG_NOT_FOUND) |
|
{ |
|
trapOid = trapOid.subString(index+5); |
|
trapOid = trapOid.subString(0, (trapOid.size()-1)); |
|
} |
|
else |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Invalid MappingStrings Value"); |
|
} |
| |
community = handler.getProperty( |
handler.getProperty(targetHostPos).getValue().get(targetHost); |
handler.findProperty |
handler.getProperty(targetHostFormatPos).getValue().get(targetHostFormat); |
(CIMName ("SNMPCommunityName"))).getValue().toString(); |
handler.getProperty(otherTargetHostFormatPos).getValue().get |
|
(otherTargetHostFormat); |
destination = handler.getProperty( |
handler.getProperty(portNumberPos).getValue().get(portNumber); |
handler.findProperty |
handler.getProperty(snmpVersionPos).getValue().get(snmpVersion); |
(CIMName ("TrapDestination"))).getValue().toString(); |
handler.getProperty(securityNamePos).getValue().get(securityName); |
|
handler.getProperty(engineIDPos).getValue().get(engineID); |
trapType = handler.getProperty( |
|
handler.findProperty |
|
(CIMName ("SNMPVersion"))).getValue().toString(); |
|
| |
emanateTrap.deliverTrap( | emanateTrap.deliverTrap( |
trapOid, | trapOid, |
community, |
securityName, |
destination, |
targetHost, |
trapType, |
targetHostFormat, |
|
otherTargetHostFormat, |
|
portNumber, |
|
snmpVersion, |
|
engineID, |
propOIDs, | propOIDs, |
propTYPEs, | propTYPEs, |
propVALUEs); | propVALUEs); |
} | } |
else | else |
cout << "Invalid Indication" << endl; |
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, |
|
"Invalid IndicationHandlerSNMPMapper instance"); |
|
} |
} | } |
| |
// This is the dynamic entry point into this dynamic module. The name of | // This is the dynamic entry point into this dynamic module. The name of |
// this handler is "snmpIndicationHandler" which is appened to "PegasusCreateHandler_" |
// this handler is "snmpIndicationHandler" which is appended to "PegasusCreateHandler_" |
// to form a symbol name. This function is called by the HandlerTable | // to form a symbol name. This function is called by the HandlerTable |
// to load this handler. | // to load this handler. |
| |
extern "C" PEGASUS_EXPORT CIMHandler* | extern "C" PEGASUS_EXPORT CIMHandler* |
PegasusCreateHandler_snmpIndicationHandler() { | PegasusCreateHandler_snmpIndicationHandler() { |
DDD(cout << "Called PegasusCreateHandler_snmpIndicationHandler" << endl;) |
|
return new snmpIndicationHandler; | return new snmpIndicationHandler; |
} | } |
| |