version 1.23, 2004/01/08 19:13:39
|
version 1.32, 2006/08/11 19:47:07
|
|
|
//%2003//////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; | // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
// IBM Corp.; EMC Corporation, The Open Group. | // IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) |
|
// |
|
// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
|
// : Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
|
| |
#ifdef HPUX_EMANATE | #ifdef HPUX_EMANATE |
#include "snmpDeliverTrap_emanate.h" | #include "snmpDeliverTrap_emanate.h" |
|
#elif defined (PEGASUS_USE_NET_SNMP) |
|
#include "snmpDeliverTrap_netsnmp.h" |
#else | #else |
#include "snmpDeliverTrap_stub.h" | #include "snmpDeliverTrap_stub.h" |
#endif | #endif |
|
|
// l10n | // l10n |
#include <Pegasus/Common/MessageLoader.h> | #include <Pegasus/Common/MessageLoader.h> |
| |
|
PEGASUS_USING_STD; |
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
PEGASUS_USING_STD; |
snmpIndicationHandler::snmpIndicationHandler() |
|
{ |
|
PEG_METHOD_ENTER (TRC_IND_HANDLER, |
|
"snmpIndicationHandler::snmpIndicationHandler"); |
|
|
|
#ifdef HPUX_EMANATE |
|
_snmpTrapSender = new snmpDeliverTrap_emanate(); |
|
#elif defined (PEGASUS_USE_NET_SNMP) |
|
_snmpTrapSender = new snmpDeliverTrap_netsnmp(); |
|
#else |
|
_snmpTrapSender = new snmpDeliverTrap_stub(); |
|
#endif |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
| |
void snmpIndicationHandler::initialize(CIMRepository* repository) | void snmpIndicationHandler::initialize(CIMRepository* repository) |
{ | { |
|
PEG_METHOD_ENTER (TRC_IND_HANDLER, |
|
"snmpIndicationHandler::initialize"); |
|
|
_repository = repository; | _repository = repository; |
|
|
|
_snmpTrapSender->initialize(); |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
void snmpIndicationHandler::terminate() |
|
{ |
|
PEG_METHOD_ENTER (TRC_IND_HANDLER, |
|
"snmpIndicationHandler::terminate"); |
|
|
|
_snmpTrapSender->terminate(); |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
snmpIndicationHandler::~snmpIndicationHandler() |
|
{ |
|
PEG_METHOD_ENTER (TRC_IND_HANDLER, |
|
"snmpIndicationHandler::~snmpIndicationHandler"); |
|
|
|
delete _snmpTrapSender; |
|
|
|
PEG_METHOD_EXIT(); |
} | } |
| |
// l10n - note: ignoring indication language | // l10n - note: ignoring indication language |
void snmpIndicationHandler::handleIndication( | void snmpIndicationHandler::handleIndication( |
const OperationContext& context, | const OperationContext& context, |
|
const String nameSpace, |
|
CIMInstance& indication, |
CIMInstance& handler, | CIMInstance& handler, |
CIMInstance& indication, String nameSpace, |
CIMInstance& subscription, |
ContentLanguages & contentLanguages) |
ContentLanguageList & contentLanguages) |
{ | { |
Array<String> propOIDs; | Array<String> propOIDs; |
Array<String> propTYPEs; | Array<String> propTYPEs; |
|
|
// trap destination and SNMP type are defined in handlerInstance | // trap destination and SNMP type are defined in handlerInstance |
// and passing this instance as it is to deliverTrap() call | // and passing this instance as it is to deliverTrap() call |
| |
#ifdef HPUX_EMANATE |
|
static snmpDeliverTrap_emanate emanateTrap; |
|
#else |
|
static snmpDeliverTrap_stub emanateTrap; |
|
#endif |
|
|
|
Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost")); | Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost")); |
Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat")); | Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat")); |
Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName ( | Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName ( |
|
|
| |
if ((targetHostPos != PEG_NOT_FOUND) && | if ((targetHostPos != PEG_NOT_FOUND) && |
(targetHostFormatPos != PEG_NOT_FOUND) && | (targetHostFormatPos != PEG_NOT_FOUND) && |
(snmpVersionPos != PEG_NOT_FOUND) && |
(snmpVersionPos != PEG_NOT_FOUND)) |
(indicationClass.findQualifier(CIMName ("MappingStrings")) != |
|
PEG_NOT_FOUND)) |
|
{ | { |
// properties from the handler instance | // properties from the handler instance |
String targetHost; | String targetHost; |
|
|
// | // |
// Get snmpTrapOid from context | // Get snmpTrapOid from context |
// | // |
try |
if (context.contains(SnmpTrapOidContainer::NAME)) |
{ | { |
SnmpTrapOidContainer trapContainer = context.get | SnmpTrapOidContainer trapContainer = context.get |
(SnmpTrapOidContainer::NAME); | (SnmpTrapOidContainer::NAME); |
| |
trapOid = trapContainer.getSnmpTrapOid(); | trapOid = trapContainer.getSnmpTrapOid(); |
} | } |
catch (Exception& e) |
else |
{ | { |
// get trapOid from indication Class | // get trapOid from indication Class |
| |
|
|
handler.getProperty(engineIDPos).getValue().get(engineID); | handler.getProperty(engineIDPos).getValue().get(engineID); |
} | } |
| |
emanateTrap.deliverTrap( |
_snmpTrapSender->deliverTrap( |
trapOid, | trapOid, |
securityName, | securityName, |
targetHost, | targetHost, |
|
|
MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.FAILED_TO_DELIVER_TRAP", | MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.FAILED_TO_DELIVER_TRAP", |
"Failed to deliver trap.")); | "Failed to deliver trap.")); |
} | } |
|
|
|
PEG_METHOD_EXIT(); |
} | } |
| |
|
PEGASUS_NAMESPACE_END |
|
|
|
PEGASUS_USING_PEGASUS; |
|
|
// 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 appended 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 |
PegasusCreateHandler_snmpIndicationHandler() { |
CIMHandler* PegasusCreateHandler_snmpIndicationHandler() |
|
{ |
return new snmpIndicationHandler; | return new snmpIndicationHandler; |
} | } |
|
|
PEGASUS_NAMESPACE_END |
|