version 1.11.12.3, 2003/08/14 11:55:42
|
version 1.20.14.1, 2006/02/10 16:11:46
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// 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.; |
|
// 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 |
|
|
| |
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
#include <Pegasus/Common/ArrayInternal.h> | #include <Pegasus/Common/ArrayInternal.h> |
#include <Pegasus/Common/Destroyer.h> |
|
#include <Pegasus/Common/InternalException.h> | #include <Pegasus/Common/InternalException.h> |
#include "snmpDeliverTrap_emanate.h" | #include "snmpDeliverTrap_emanate.h" |
| |
|
|
| |
#include <prnt_lib.h> // MUST be at the end in include list. | #include <prnt_lib.h> // MUST be at the end in include list. |
| |
static char *sr_filename = __FILE__; |
static const char *sr_filename = __FILE__; |
| |
IPCFunctionP IPCfp; /* IPC functions pointer */ | IPCFunctionP IPCfp; /* IPC functions pointer */ |
| |
|
|
| |
snmpDeliverTrap_emanate::snmpDeliverTrap_emanate() | snmpDeliverTrap_emanate::snmpDeliverTrap_emanate() |
{ | { |
|
// |
|
// Initialize Subagent and establish comunication with the Master Agent |
|
// |
|
initialize(); |
} | } |
| |
snmpDeliverTrap_emanate::~snmpDeliverTrap_emanate() | snmpDeliverTrap_emanate::~snmpDeliverTrap_emanate() |
{ | { |
|
// |
|
// Close the connection to the Master Agent and shut down the |
|
// Subagent |
|
// |
|
EndSubagent(); |
} | } |
| |
| |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_INITSUBAGENT_FAILED_KEY, | MessageLoaderParms(_MSG_INITSUBAGENT_FAILED_KEY, |
_MSG_INITSUBAGENT_FAILED, |
_MSG_INITSUBAGENT_FAILED)); |
_MSG_INITSUBAGENT)); |
|
| |
} | } |
} | } |
|
|
const Uint32& portNumber, | const Uint32& portNumber, |
const Uint16& snmpVersion, | const Uint16& snmpVersion, |
const String& engineID, | const String& engineID, |
Array<String>& vbOids, |
const Array<String>& vbOids, |
Array<String>& vbTypes, |
const Array<String>& vbTypes, |
Array<String>& vbValues) |
const Array<String>& vbValues) |
{ | { |
VarBind *vbhead = NULL; | VarBind *vbhead = NULL; |
VarBind *vb = NULL; | VarBind *vb = NULL; |
|
|
| |
OID *object = NULL; | OID *object = NULL; |
| |
// Initialize with Master agent |
|
|
|
initialize(); |
|
|
|
// Translate a string into an OID | // Translate a string into an OID |
OID *sendtrapOid = MakeOIDFromDot(trapOid.getCString()); | OID *sendtrapOid = MakeOIDFromDot(trapOid.getCString()); |
| |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_INVALID_KEY, | MessageLoaderParms(_MSG_INVALID_KEY, |
_MSG_INVALID_TRAPOID, |
_MSG_INVALID_TRAPOID)); |
_MSG_TRAPOID)); |
|
} | } |
| |
// Destination : convert targetHost into Transport | // Destination : convert targetHost into Transport |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED, | throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED, |
MessageLoaderParms(_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY, | MessageLoaderParms(_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY, |
_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED, |
_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED)); |
_MSG_HOSTNAME, |
|
_MSG_IPV4, |
|
_MSG_TARGETHOSTFORMAT)); |
|
| |
break; | break; |
} | } |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_INVALID_SECURITY_NAME_KEY, | MessageLoaderParms(_MSG_INVALID_SECURITY_NAME_KEY, |
_MSG_INVALID_SECURITY_NAME, |
_MSG_INVALID_SECURITY_NAME)); |
_MSG_SECURITY_NAME)); |
|
|
|
} |
|
|
|
switch (targetHostFormat) |
|
{ |
|
case _HOST_NAME: |
|
{ |
|
char * ipAddr = _getIPAddress(trap_dest); |
|
|
|
if (ipAddr == NULL) |
|
{ |
|
|
|
// l10n |
|
|
|
// throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, |
|
// _MSG_DESTINATION_NOT_FOUND); |
|
|
|
throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, |
|
MessageLoaderParms(_MSG_DESTINATION_NOT_FOUND_KEY, |
|
_MSG_DESTINATION_NOT_FOUND)); |
|
|
|
} |
|
global_ti.t_ipAddr = inet_addr(trap_dest); |
|
break; |
|
} |
|
case _IPV4_ADDRESS: |
|
{ |
|
global_ti.t_ipAddr = inet_addr(trap_dest); |
|
break; |
|
} |
|
default: |
|
{ |
|
|
|
// l10n |
|
| |
// throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, |
|
// _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED); |
|
|
|
throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED, |
|
MessageLoaderParms(_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY, |
|
_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED, |
|
_MSG_HOSTNAME, |
|
_MSG_IPV4, |
|
_MSG_TARGETHOSTFORMAT)); |
|
|
|
break; |
|
} | } |
} |
|
|
|
global_ti.t_ipPort = htons((unsigned short)portNumber); |
|
| |
// Community Name, default is public |
|
CString _community; |
|
if (securityName.size() == 0) |
|
{ |
|
String community; |
|
community.assign("public"); |
|
_community = community.getCString(); |
|
} |
|
else |
|
{ |
|
_community = securityName.getCString(); |
|
} |
|
|
|
OctetString* community_name = MakeOctetStringFromText(_community); |
|
|
|
if (community_name == NULL) |
|
{ |
|
|
|
// l10n |
|
|
|
// throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, |
|
// _MSG_INVALID_SECURITY_NAME); |
|
|
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
|
MessageLoaderParms(_MSG_INVALID_SECURITY_NAME_KEY, |
|
_MSG_INVALID_SECURITY_NAME, |
|
_MSG_SECURITY_NAME)); |
|
|
|
} |
|
// getting IP address of the host | // getting IP address of the host |
| |
CString hostname = System::getHostName().getCString(); | CString hostname = System::getHostName().getCString(); |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_CREATE_OCTET_FAILED_KEY, | MessageLoaderParms(_MSG_CREATE_OCTET_FAILED_KEY, |
_MSG_CREATE_OCTET_FAILED, |
_MSG_CREATE_OCTET_FAILED)); |
_MSG_OCTETSTRING)); |
|
| |
} | } |
| |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_INVALID_ENTERPRISEOID_KEY, | MessageLoaderParms(_MSG_INVALID_ENTERPRISEOID_KEY, |
_MSG_INVALID_ENTERPRISEOID, |
_MSG_INVALID_ENTERPRISEOID)); |
_MSG_ENTERPRISEOID)); |
|
} | } |
} | } |
| |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_INVALID_PROPERTYOID_KEY, | MessageLoaderParms(_MSG_INVALID_PROPERTYOID_KEY, |
_MSG_INVALID_PROPERTYOID, |
_MSG_INVALID_PROPERTYOID)); |
_MSG_OID, |
|
_MSG_CIM)); |
|
} | } |
| |
if (String::equalNoCase(vbTypes[i], "OctetString")) | if (String::equalNoCase(vbTypes[i], "OctetString")) |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY, | MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY, |
_MSG_INVALID_PROPERTYVALUE, |
_MSG_INVALID_PROPERTYVALUE)); |
_MSG_CIM)); |
|
} | } |
| |
if ((vb = MakeVarBindWithValue(object, | if ((vb = MakeVarBindWithValue(object, |
|
|
// _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE); | // _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE); |
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_KEY, |
MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE_KEY, |
_MSG_MAKE_VARBIND_FAILED, |
_MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE)); |
_MSG_VARBIND, |
|
_MSG_OCTET_PRIM_TYPE)); |
|
} | } |
} | } |
else if (String::equalNoCase(vbTypes[i], "OID")) | else if (String::equalNoCase(vbTypes[i], "OID")) |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY, | MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY, |
_MSG_INVALID_PROPERTYVALUE, |
_MSG_INVALID_PROPERTYVALUE)); |
_MSG_CIM)); |
|
| |
} | } |
| |
|
|
// _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE); | // _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE); |
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_KEY, |
MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE_KEY, |
_MSG_MAKE_VARBIND_FAILED, |
_MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE)); |
_MSG_VARBIND, |
|
_MSG_OBJECT_ID_TYPE)); |
|
} | } |
} | } |
else | else |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY, | MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY, |
_MSG_INVALID_PROPERTYVALUE, |
_MSG_INVALID_PROPERTYVALUE)); |
_MSG_CIM)); |
|
} | } |
| |
if ((vb = MakeVarBindWithValue(object, | if ((vb = MakeVarBindWithValue(object, |
|
|
// _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE); | // _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE); |
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_KEY, |
MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE_KEY, |
_MSG_MAKE_VARBIND_FAILED, |
_MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE)); |
_MSG_VARBIND, |
|
_MSG_INTEGER_TYPE)); |
|
} | } |
} | } |
| |
|
|
| |
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, |
MessageLoaderParms(_MSG_VERSION_NOT_SUPPORTED_KEY, | MessageLoaderParms(_MSG_VERSION_NOT_SUPPORTED_KEY, |
_MSG_VERSION_NOT_SUPPORTED, |
_MSG_VERSION_NOT_SUPPORTED)); |
_MSG_SNMPv1, |
|
_MSG_SNMPv2C, |
|
_MSG_SNMPVersion)); |
|
| |
break; | break; |
} | } |
|
|
struct hostent *targetHostInfo; | struct hostent *targetHostInfo; |
struct in_addr in; | struct in_addr in; |
| |
#ifdef PEGASUS_OS_SOLARIS |
#if defined(PEGASUS_OS_LINUX) |
#define HOSTENT_BUFF_SIZE 8192 |
char hostEntryBuffer[8192]; |
char buf[HOSTENT_BUFF_SIZE]; |
struct hostent hostEntryStruct; |
struct hostent h_result; |
int hostEntryErrno; |
int h_errorp; |
|
targetHostInfo=gethostbyname_r(hostName, &h_result, buff, |
gethostbyname_r( |
HOSTENT_BUFF_SIZE, &h_errorp); |
hostName, |
|
&hostEntryStruct, |
|
hostEntryBuffer, |
|
sizeof(hostEntryBuffer), |
|
&targetHostInfo, |
|
&hostEntryErrno); |
|
#elif defined(PEGASUS_OS_SOLARIS) |
|
char hostEntryBuffer[8192]; |
|
struct hostent hostEntryStruct; |
|
int hostEntryErrno; |
|
|
|
targetHostInfo = gethostbyname_r( |
|
(char *)hostName, |
|
&hostEntryStruct, |
|
hostEntryBuffer, |
|
sizeof(hostEntryBuffer), |
|
&hostEntryErrno); |
#else | #else |
targetHostInfo = gethostbyname(hostName); | targetHostInfo = gethostbyname(hostName); |
#endif | #endif |