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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2