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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2