(file) Return to snmpDeliverTrap_emanate.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Handler / snmpIndicationHandler

  1 mike  1.2 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3 kumpf 1.5 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4           // The Open Group, Tivoli Systems
  5 mike  1.2 //
  6           // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 kumpf 1.5 // of this software and associated documentation files (the "Software"), to
  8           // deal in the Software without restriction, including without limitation the
  9           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10 mike  1.2 // sell copies of the Software, and to permit persons to whom the Software is
 11           // furnished to do so, subject to the following conditions:
 12           // 
 13 kumpf 1.5 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 mike  1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16 kumpf 1.5 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19 mike  1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21           //
 22           //==============================================================================
 23           //
 24           // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
 25           //
 26 kumpf 1.6 // Modified By: Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
 27 mike  1.2 //
 28           //%/////////////////////////////////////////////////////////////////////////////
 29           
 30 kumpf 1.3 #include "sr_conf.h"
 31           #include <stdio.h>
 32           #include <stdarg.h>
 33           #include <unistd.h>
 34           #include <fcntl.h>
 35           #include <string.h>
 36           #include <stdlib.h>
 37           
 38           #include <sys/types.h>
 39           #include <sys/sem.h>
 40           #include <sys/stat.h>
 41           #include <sys/param.h>
 42           
 43           #include <signal.h>
 44           #include <netinet/in.h>
 45           #include <sys/socket.h>
 46           #include <arpa/inet.h>
 47           #include <netdb.h>
 48           #include <errno.h>
 49           
 50           #include "sr_snmp.h"
 51 kumpf 1.3 #include "comunity.h"
 52           #include "v2clssc.h"
 53           #include "sr_trans.h"
 54           #include "context.h"
 55           #include "method.h"
 56           #include "diag.h"
 57           #include "subagent.h"
 58           #include "agentsoc.h"
 59           #include "evq.h"
 60           #include "sig.h"
 61           
 62 mike  1.2 #include <iostream>
 63           #include <Pegasus/Common/Config.h>
 64           
 65           #include "snmpDeliverTrap.h"
 66           
 67 kumpf 1.6 PEGASUS_NAMESPACE_BEGIN
 68           
 69           static const char _MSG_INITSUBAGENT_FAILED [] = "InitSubagent Failed to initialize";
 70           
 71           static const char _MSG_INVALID_TRAPOID [] = "Invalid trapOid.";
 72           
 73           static const char _MSG_DESTINATION_NOT_FOUND [] = "Can not find trap destination.";
 74           
 75           static const char _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED [] = 
 76               "Host Name and IPV4 Address are the only supported TargetHostFormat values.";
 77           
 78           static const char _MSG_INVALID_SECURITY_NAME [] = 
 79               "Invalid SNMP SecurityName.";
 80           
 81           static const char _MSG_INVALID_OCTET_VALUE [] = 
 82               "Invalid octet value in trap destination.";
 83           
 84           static const char _MSG_CREATE_OCTET_FAILED [] = 
 85               "Creation of empty 4 length OctetString failed.";
 86 mike  1.2 
 87 kumpf 1.6 static const char _MSG_INVALID_ENTERPRISEOID [] = "Invalid enterpriseOid.";
 88           
 89           static const char _MSG_INVALID_PROPERTYOID [] = "Invalid OID of CIM Property.";
 90           
 91           static const char _MSG_INVALID_PROPERTYVALUE [] = "Invalid value of CIM Property.";
 92           
 93           static const char _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE [] = 
 94               "Failed to MakeVarBindWithValue for type OCTET_PRIM_TYPE.";
 95           
 96           static const char _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE [] = 
 97               "Failed to MakeVarBindWithValue for type OBJECT_ID_TYPE.";
 98           
 99           static const char _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE [] = 
100               "Failed to MakeVarBindWithValue for type INTEGER_TYPE.";
101           
102           static const char _MSG_VERSION_NOT_SUPPORTED [] = 
103               "SNMPv1 Trap and SNMPv2C Trap are the only supported SNMPVersion values.";
104 mike  1.2 
105           class snmpDeliverTrap_emanate : public snmpDeliverTrap
106           {
107           public:
108 kumpf 1.3 
109               snmpDeliverTrap_emanate();
110           
111               ~snmpDeliverTrap_emanate();
112           
113               void initialize();
114           
115 kumpf 1.6     /**
116           	Send snmp trap to the target.
117           	@param  trapOid		snmp trap OID
118           	@param  securityName 	either an SNMPv1 or SNMPv2c community 
119           				name or an SNMPv3 user name
120           	@param 	targetHost	address of the trap/infom destination
121           	@param	targetHostFormat targetHost format
122           	@param  otherTargetHostFormat other target format type
123           	@param  portNumber 	UDP port number to send the trap/inform
124           	@param  snmpVersion	snmp version and format to use to send the indication
125           	@param 	engineID 	snmp engine ID used to create the SNMPv3 inform
126           	@param	vbOids		VarBind OIDs
127           	@param 	vbTypes		VarBind types
128           	@param 	vbValues	VarBind values
129               */
130 mike  1.2     void deliverTrap(
131 kumpf 1.6         const String& trapOid,
132                   const String& securityName, 
133                   const String& targetHost, 
134                   const Uint16& targetHostFormat, 
135                   const String& otherTargetHostFormat, 
136                   const Uint32& portNumber,
137                   const Uint16& snmpVersion, 
138                   const String& engineID,
139 mike  1.2         Array<String>& vbOids,
140                   Array<String>& vbTypes,
141                   Array<String>& vbValues);
142 kumpf 1.6 
143           private:
144               char * _getIPAddress(const CString& hostName);
145               Boolean _isValidOctet(const Uint32& octetValue);
146           
147               /**
148                   Values for the TargetHostFormat property of the 
149           	PG_IndicationHandlerSNMPMapper class.
150               */
151               enum TargetHostFormat {_OTHER = 1, _HOST_NAME = 2,
152                    _IPV4_ADDRESS = 3, _IPV6_ADDRESS = 4};
153               enum SNMPVersion {_SNMPv1_TRAP = 2, _SNMPv2C_TRAP = 3,
154                    _SNMPv2C_INFORM = 4, _SNMPv3_TRAP = 5, _SNMPv3_INFORM = 6};
155 mike  1.2 };
156           
157           PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2