(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 mday  1.5.14.1 // 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                PEGASUS_NAMESPACE_BEGIN
 68 mday  1.5.14.3 
 69                // l10n
 70                // lots of hacking to make up these messages
 71                
 72                static const char _MSG_INITSUBAGENT_FAILED [] = "$0 Failed to initialize";
 73                static const char _MSG_INITSUBAGENT [] = "InitSubagent";
 74                static const char _MSG_INITSUBAGENT_FAILED_KEY [] = 
 75                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INITSUBAGENT_FAILED";
 76                
 77                static const char _MSG_INVALID_TRAPOID [] = "Invalid $0.";
 78                static const char _MSG_TRAPOID [] = "trapOid";
 79                static const char _MSG_INVALID_KEY [] = 
 80                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID";
 81                
 82                static const char _MSG_DESTINATION_NOT_FOUND [] = "Can not find trap destination.";
 83                static const char _MSG_DESTINATION_NOT_FOUND_KEY [] = 
 84                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_DESTINATION_NOT_FOUND";
 85                
 86                static const char _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED [] = 
 87                    "$0 and $1 are the only supported $2 values.";
 88                static const char _MSG_HOSTNAME [] = "Host Name";
 89 mday  1.5.14.3 static const char _MSG_IPV4 [] = "IPV4 Address";
 90                static const char _MSG_TARGETHOSTFORMAT [] = "TargetHostFormat";
 91                static const char _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY [] = 
 92                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_TARGETHOSTFORMAT_NOT_SUPPORTED";
 93                
 94                static const char _MSG_INVALID_SECURITY_NAME [] = "Invalid $0.";
 95                static const char _MSG_SECURITY_NAME [] = "SNMP SecurityName";
 96                static const char _MSG_INVALID_SECURITY_NAME_KEY [] = 
 97                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID";
 98                
 99                static const char _MSG_INVALID_OCTET_VALUE [] = 
100                    "Invalid octet value in trap destination.";
101                static const char _MSG_INVALID_OCTET_VALUE_KEY [] = 
102                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID_OCTET_VALUE";
103                
104                static const char _MSG_CREATE_OCTET_FAILED [] = 
105                    "Creation of empty 4 length $0 failed.";
106                static const char _MSG_OCTETSTRING [] = "OctetString";
107                static const char _MSG_CREATE_OCTET_FAILED_KEY [] = 
108                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_CREATE_OCTET_FAILED";
109                
110 mday  1.5.14.3 static const char _MSG_INVALID_ENTERPRISEOID [] = "Invalid $0.";
111                static const char _MSG_ENTERPRISEOID [] = "enterpriseOid.";
112                static const char _MSG_INVALID_ENTERPRISEOID_KEY [] = 
113                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID";
114                
115                static const char _MSG_INVALID_PROPERTYOID [] = "Invalid $0 of $1 Property.";
116                static const char _MSG_OID [] = "OID";
117                static const char _MSG_CIM [] = "CIM";
118                static const char _MSG_INVALID_PROPERTYOID_KEY [] = 
119                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID_PROPERTYOID";
120                
121                static const char _MSG_INVALID_PROPERTYVALUE [] = "Invalid value of $0 Property.";
122                // declared above static const char _MSG_CIM [] = "CIM";
123                static const char _MSG_INVALID_PROPERTYVALUE_KEY [] = 
124                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID_PROPERTY";
125                
126                static const char _MSG_MAKE_VARBIND_FAILED [] = 
127                    "Failed to $0 for type $1.";
128                static const char _MSG_MAKE_VARBIND_FAILED_KEY [] = 
129                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_MAKE_FAILED";
130                static const char _MSG_VARBIND [] = "MakeVarBindWithValue";
131 mday  1.5.14.3 
132                static const char _MSG_OCTET_PRIM_TYPE [] = "OCTET_PRIM_TYPE";
133                
134                static const char _MSG_OBJECT_ID_TYPE [] = "OBJECT_ID_TYPE";
135                
136                static const char _MSG_INTEGER_TYPE [] = "INTEGER_TYPE";
137                
138                static const char _MSG_VERSION_NOT_SUPPORTED [] = 
139                    "$0 and $1 are the only supported $2 values.";
140                static const char _MSG_SNMPv1 [] = "SNMPv1 Trap";
141                static const char _MSG_SNMPv2C [] = "SNMPv2C Trap";
142                static const char _MSG_SNMPVersion [] = "SNMPVersion";
143                static const char _MSG_VERSION_NOT_SUPPORTED_KEY [] = 
144                    "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_VERSION_NOT_SUPPORTED";
145 mike  1.2      
146 mday  1.5.14.2 // l10n
147                // lots of hacking to make up these messages
148                
149                
150                
151                static const char _MSG_INITSUBAGENT_FAILED [] = "$0 Failed to initialize";
152                static const char _MSG_INITSUBAGENT [] = "InitSubagent";
153                static const char _MSG_INITSUBAGENT_FAILED_KEY [] = 
154                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INITSUBAGENT_FAILED";
155 mday  1.5.14.1 
156 mday  1.5.14.2 static const char _MSG_INVALID_TRAPOID [] = "Invalid $0.";
157                static const char _MSG_TRAPOID [] = "trapOid";
158                static const char _MSG_INVALID_KEY [] = 
159                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID";
160 mday  1.5.14.1 
161                static const char _MSG_DESTINATION_NOT_FOUND [] = "Can not find trap destination.";
162 mday  1.5.14.2 static const char _MSG_DESTINATION_NOT_FOUND_KEY [] = 
163                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_DESTINATION_NOT_FOUND";
164 mday  1.5.14.1 
165                static const char _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED [] = 
166 mday  1.5.14.2     "$0 and $1 are the only supported $2 values.";
167                static const char _MSG_HOSTNAME [] = "Host Name";
168                static const char _MSG_IPV4 [] = "IPV4 Address";
169                static const char _MSG_TARGETHOSTFORMAT [] = "TargetHostFormat";
170                static const char _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY [] = 
171                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_TARGETHOSTFORMAT_NOT_SUPPORTED";
172                
173                static const char _MSG_INVALID_SECURITY_NAME [] = "Invalid $0.";
174                static const char _MSG_SECURITY_NAME [] = "SNMP SecurityName";
175                static const char _MSG_INVALID_SECURITY_NAME_KEY [] = 
176                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID";
177 mday  1.5.14.1 
178                static const char _MSG_INVALID_OCTET_VALUE [] = 
179                    "Invalid octet value in trap destination.";
180 mday  1.5.14.2 static const char _MSG_INVALID_OCTET_VALUE_KEY [] = 
181                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID_OCTET_VALUE";
182 mday  1.5.14.1 
183                static const char _MSG_CREATE_OCTET_FAILED [] = 
184 mday  1.5.14.2     "Creation of empty 4 length $0 failed.";
185                static const char _MSG_OCTETSTRING [] = "OctetString";
186                static const char _MSG_CREATE_OCTET_FAILED_KEY [] = 
187                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_CREATE_OCTET_FAILED";
188                
189                static const char _MSG_INVALID_ENTERPRISEOID [] = "Invalid $0.";
190                static const char _MSG_ENTERPRISEOID [] = "enterpriseOid.";
191                static const char _MSG_INVALID_ENTERPRISEOID_KEY [] = 
192                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID";
193                
194                static const char _MSG_INVALID_PROPERTYOID [] = "Invalid $0 of $1 Property.";
195                static const char _MSG_OID [] = "OID";
196                static const char _MSG_CIM [] = "CIM";
197                static const char _MSG_INVALID_PROPERTYOID_KEY [] = 
198                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID_PROPERTYOID";
199                
200                static const char _MSG_INVALID_PROPERTYVALUE [] = "Invalid value of $0 Property.";
201                // declared above static const char _MSG_CIM [] = "CIM";
202                static const char _MSG_INVALID_PROPERTYVALUE_KEY [] = 
203                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_INVALID_PROPERTY";
204                
205 mday  1.5.14.2 static const char _MSG_MAKE_VARBIND_FAILED [] = 
206                    "Failed to $0 for type $1.";
207                static const char _MSG_MAKE_VARBIND_FAILED_KEY [] = 
208                   "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_MAKE_FAILED";
209                static const char _MSG_VARBIND [] = "MakeVarBindWithValue";
210 mday  1.5.14.1 
211 mday  1.5.14.2 static const char _MSG_OCTET_PRIM_TYPE [] = "OCTET_PRIM_TYPE";
212 mday  1.5.14.1 
213 mday  1.5.14.2 static const char _MSG_OBJECT_ID_TYPE [] = "OBJECT_ID_TYPE";
214 mday  1.5.14.1 
215 mday  1.5.14.2 static const char _MSG_INTEGER_TYPE [] = "INTEGER_TYPE";
216 mday  1.5.14.1 
217                static const char _MSG_VERSION_NOT_SUPPORTED [] = 
218 mday  1.5.14.2     "$0 and $1 are the only supported $2 values.";
219                static const char _MSG_SNMPv1 [] = "SNMPv1 Trap";
220                static const char _MSG_SNMPv2C [] = "SNMPv2C Trap";
221                static const char _MSG_SNMPVersion [] = "SNMPVersion";
222                static const char _MSG_VERSION_NOT_SUPPORTED_KEY [] = 
223                    "Handler.snmpIndicationHandler.snmpDeliverTrap_emanate._MSG_VERSION_NOT_SUPPORTED";
224 mday  1.5.14.1 
225 mike  1.2      class snmpDeliverTrap_emanate : public snmpDeliverTrap
226                {
227                public:
228 kumpf 1.3      
229                    snmpDeliverTrap_emanate();
230                
231                    ~snmpDeliverTrap_emanate();
232                
233                    void initialize();
234                
235 mday  1.5.14.1     /**
236                	Send snmp trap to the target.
237                	@param  trapOid		snmp trap OID
238                	@param  securityName 	either an SNMPv1 or SNMPv2c community 
239                				name or an SNMPv3 user name
240                	@param 	targetHost	address of the trap/infom destination
241                	@param	targetHostFormat targetHost format
242                	@param  otherTargetHostFormat other target format type
243                	@param  portNumber 	UDP port number to send the trap/inform
244                	@param  snmpVersion	snmp version and format to use to send the indication
245                	@param 	engineID 	snmp engine ID used to create the SNMPv3 inform
246                	@param	vbOids		VarBind OIDs
247                	@param 	vbTypes		VarBind types
248                	@param 	vbValues	VarBind values
249                    */
250 mike  1.2          void deliverTrap(
251 mday  1.5.14.1         const String& trapOid,
252                        const String& securityName, 
253                        const String& targetHost, 
254                        const Uint16& targetHostFormat, 
255                        const String& otherTargetHostFormat, 
256                        const Uint32& portNumber,
257                        const Uint16& snmpVersion, 
258                        const String& engineID,
259 mike  1.2              Array<String>& vbOids,
260                        Array<String>& vbTypes,
261                        Array<String>& vbValues);
262 mday  1.5.14.1 
263                private:
264                    char * _getIPAddress(const CString& hostName);
265                    Boolean _isValidOctet(const Uint32& octetValue);
266                
267                    /**
268                        Values for the TargetHostFormat property of the 
269                	PG_IndicationHandlerSNMPMapper class.
270                    */
271                    enum TargetHostFormat {_OTHER = 1, _HOST_NAME = 2,
272                         _IPV4_ADDRESS = 3, _IPV6_ADDRESS = 4};
273                    enum SNMPVersion {_SNMPv1_TRAP = 2, _SNMPv2C_TRAP = 3,
274                         _SNMPv2C_INFORM = 4, _SNMPv3_TRAP = 5, _SNMPv3_INFORM = 6};
275 mike  1.2      };
276                
277                PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2