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

  1 karl  1.16 //%2003////////////////////////////////////////////////////////////////////////
  2 mike  1.2  //
  3 karl  1.16 // 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.10 // 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.10 // 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.10 // 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.12 // Modified By: Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
 29 mike  1.2  //
 30            //%/////////////////////////////////////////////////////////////////////////////
 31            
 32 kumpf 1.3  #include <Pegasus/Common/System.h>
 33 kumpf 1.12 #include <Pegasus/Common/ArrayInternal.h>
 34 kumpf 1.8  #include <Pegasus/Common/Destroyer.h>
 35 kumpf 1.12 #include <Pegasus/Common/InternalException.h>
 36 mike  1.2  #include "snmpDeliverTrap_emanate.h"
 37 kumpf 1.12 
 38 humberto 1.14 // l10n
 39               #include <Pegasus/Common/MessageLoader.h>
 40               
 41 kumpf    1.12 // EMANATE specific declarations and entry points - MUST be in begining
 42               // and outside NAMESPACE.
 43               
 44               // master agent needs these two declarations for communication with sub-agent.
 45               // Following two declarations must be in the CODE. 
 46               
 47               #include <prnt_lib.h>  // MUST be at the end in include list.
 48 mike     1.2  
 49 kumpf    1.3  static char *sr_filename = __FILE__;
 50               
 51               IPCFunctionP IPCfp;  /* IPC functions pointer  */
 52               
 53 kumpf    1.12 // This code would normally be generated by Emanate from defined MIB objects. 
 54               // Since we do not have MIB objects defined, just defined here to load 
 55               // subagent as library. OidList[] provides objects for entry point to master agent.
 56 kumpf    1.3  
 57               // The objects internal to the agent 
 58               ObjectInfo OidList[] = 
 59               {
 60               { { 0, NULL },
 61               #ifndef LIGHT
 62                   NULL,
 63               #endif /* LIGHT */
 64                   0, 0, 0, 0,
 65                   NULL, NULL }
 66               };
 67               
 68 kumpf    1.12 // This code would normally be generated by Emanate in k_* routine from defined MIB objects.
 69               // Since we do not have MIB objects defined, just define here to pass compile and
 70               // enable entry point for master agent to start communication with library.
 71 kumpf    1.3  
 72               // Called by the master agent during initialization */
 73               int k_initialize()
 74               {
 75                  return 1;
 76               }
 77 kumpf    1.9  
 78 kumpf    1.12 // END EMANATE specific declarations.
 79               
 80 kumpf    1.9  PEGASUS_NAMESPACE_BEGIN
 81               
 82               PEGASUS_USING_STD;
 83 kumpf    1.3  
 84               snmpDeliverTrap_emanate::snmpDeliverTrap_emanate()
 85               {
 86               
 87               }
 88               
 89               snmpDeliverTrap_emanate::~snmpDeliverTrap_emanate()
 90               {
 91               
 92               }
 93               
 94 kumpf    1.12 
 95               // initialize sub-agent
 96               
 97               // This also defines the communication protocol to be used between master
 98               // and sub-agent.
 99               
100 kumpf    1.3  void snmpDeliverTrap_emanate::initialize()
101               {
102               #ifndef SR_UDS_IPC
103                   InitIPCArrayTCP(&IPCfp);
104               #else /* SR_UDS_IPC */
105                   InitIPCArrayUDS(&IPCfp);
106               #endif /* SR_UDS_IPC */
107               
108                   if(InitSubagent() == -1) 
109                   {
110 humberto 1.14 
111                     // l10n
112               
113                     // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
114                     //   _MSG_INITSUBAGENT_FAILED);
115               
116                     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
117               				    MessageLoaderParms(_MSG_INITSUBAGENT_FAILED_KEY,
118 humberto 1.15 						       _MSG_INITSUBAGENT_FAILED));
119 humberto 1.14 
120 kumpf    1.3      }
121               }
122               
123 humberto 1.14 
124 kumpf    1.3  void snmpDeliverTrap_emanate::deliverTrap(
125 kumpf    1.12         const String& trapOid,
126                       const String& securityName, 
127                       const String& targetHost, 
128                       const Uint16& targetHostFormat, 
129                       const String& otherTargetHostFormat, 
130                       const Uint32& portNumber,
131                       const Uint16& snmpVersion, 
132                       const String& engineID,
133                       Array<String>& vbOids,
134                       Array<String>& vbTypes,
135                       Array<String>& vbValues)
136 mike     1.2  {
137 kumpf    1.12     VarBind *vbhead = NULL;
138 kumpf    1.3      VarBind *vb = NULL;
139 kumpf    1.12     VarBind *vblast = NULL;
140 kumpf    1.3      
141                   OID	    *object = NULL;
142               
143 kumpf    1.12     // Initialize with Master agent
144               
145                   	initialize();
146               
147                   // Translate a string into an OID
148                   OID *sendtrapOid = MakeOIDFromDot(trapOid.getCString());
149               
150                   if (sendtrapOid == NULL)
151                   {
152 humberto 1.14 
153                     // l10n
154               
155                     // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
156                     // _MSG_INVALID_TRAPOID);
157               
158                     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
159               				    MessageLoaderParms(_MSG_INVALID_KEY,
160 humberto 1.15 						       _MSG_INVALID_TRAPOID));
161 kumpf    1.12     }
162               
163                   // Destination : convert targetHost into Transport
164 kumpf    1.5  
165 kumpf    1.12     CString trap_dest = targetHost.getCString();
166 kumpf    1.5  
167                   TransportInfo   global_ti;
168                   global_ti.type = SR_IP_TRANSPORT;
169               
170 kumpf    1.12     switch (targetHostFormat)
171                   {
172               	case _HOST_NAME:
173               	{
174               	    char * ipAddr = _getIPAddress(trap_dest); 
175               
176               	    if (ipAddr == NULL)
177               	    {
178 humberto 1.14 
179               	      // l10n
180               
181               	      // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
182               	      //   _MSG_DESTINATION_NOT_FOUND);
183               
184               	      throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
185               					     MessageLoaderParms(_MSG_DESTINATION_NOT_FOUND_KEY,
186               								_MSG_DESTINATION_NOT_FOUND));
187               
188 kumpf    1.12  	    }
189                   	    global_ti.t_ipAddr = inet_addr(trap_dest);
190               	    break;	    
191               	}
192               	case _IPV4_ADDRESS:
193               	{
194                   	    global_ti.t_ipAddr = inet_addr(trap_dest);
195               	    break;	    
196               	}
197               	default:
198               	{
199 humberto 1.14 
200               	  // l10n
201               
202               	  // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
203               	  // _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED);
204               
205               	  throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
206               					 MessageLoaderParms(_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY,
207 humberto 1.15 							    _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED));
208 humberto 1.14 
209 kumpf    1.12 	    break;	    
210               	}
211                   } 
212               
213                   global_ti.t_ipPort = htons((unsigned short)portNumber);
214               
215                   // Community Name, default is public
216                   CString _community;
217                   if (securityName.size() == 0)
218                   {
219               	String community;
220               	community.assign("public");
221               	_community = community.getCString();
222                   }
223                   else
224                   {
225               	_community = securityName.getCString();
226                   }
227               
228                   OctetString* community_name = MakeOctetStringFromText(_community);
229               
230 kumpf    1.12     if (community_name == NULL)
231                   {
232 humberto 1.14 
233                     // l10n
234               
235                     // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
236                     //   _MSG_INVALID_SECURITY_NAME);
237               
238                     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
239               				    MessageLoaderParms(_MSG_INVALID_SECURITY_NAME_KEY,
240 humberto 1.15 						       _MSG_INVALID_SECURITY_NAME));
241 humberto 1.14 						       
242 kumpf    1.12     }
243 kumpf    1.5  
244 kumpf    1.3      // getting IP address of the host
245 kumpf    1.12 
246                   CString hostname = System::getHostName().getCString();
247                   char* IP_string = _getIPAddress(hostname);
248               
249 kumpf    1.3      // formatting agent(host) address into OctetString format
250 kumpf    1.12 
251 kumpf    1.3      OctetString* agent_addr;
252               
253                   SR_INT32 s1, s2, s3, s4;
254                   SR_UINT32 ipaddr;
255               
256                   // pull out each of the 4 octet values from IP address
257 kumpf    1.12 
258 kumpf    1.3      sscanf(IP_string,"%d.%d.%d.%d", &s1, &s2, &s3, &s4);
259                
260 kumpf    1.12     // validate the values for s1, s2, s3, and s4 to make sure values are
261 kumpf    1.3      // between 0 and 255
262 kumpf    1.12     if (!_isValidOctet(s1) || !_isValidOctet(s2) ||
263               	!_isValidOctet(s3) || !_isValidOctet(s4))
264                   {
265 humberto 1.14 
266                     // l10n
267               
268                     // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
269                     //   _MSG_INVALID_OCTET_VALUE);
270               
271                     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
272               				  MessageLoaderParms(_MSG_INVALID_OCTET_VALUE_KEY,
273               						     _MSG_INVALID_OCTET_VALUE));
274 kumpf    1.12     }
275 kumpf    1.3   
276                   // create an empty 4 length OctetString
277 kumpf    1.12 
278 kumpf    1.3      agent_addr = MakeOctetString(NULL,4);
279 kumpf    1.12 
280                   if (agent_addr == NULL)
281                   {
282 humberto 1.14 
283                     // l10n
284               
285                     // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
286                     //   _MSG_CREATE_OCTET_FAILED);
287               
288                     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
289               				    MessageLoaderParms(_MSG_CREATE_OCTET_FAILED_KEY,
290 humberto 1.15 						       _MSG_CREATE_OCTET_FAILED));
291 humberto 1.14 
292 kumpf    1.12     }
293 kumpf    1.3   
294                   // fill in values for OctetString
295 kumpf    1.12 
296 kumpf    1.3      agent_addr->octet_ptr[0] = (unsigned char)s1;
297                   agent_addr->octet_ptr[1] = (unsigned char)s2;
298                   agent_addr->octet_ptr[2] = (unsigned char)s3;
299                   agent_addr->octet_ptr[3] = (unsigned char)s4;
300               
301 kumpf    1.4      // specTrap from trapOid. 
302 kumpf    1.12 
303 kumpf    1.5      SR_INT32 genTrap = 0;
304                   SR_INT32 specTrap = 0;
305 kumpf    1.3      
306 kumpf    1.5      OID* enterpriseOid ;
307               
308                   Array<String> standard_traps;
309               
310                   standard_traps.append(String("1.3.6.1.6.3.1.1.5.1"));
311                   standard_traps.append(String("1.3.6.1.6.3.1.1.5.2"));
312                   standard_traps.append(String("1.3.6.1.6.3.1.1.5.3"));
313                   standard_traps.append(String("1.3.6.1.6.3.1.1.5.4"));
314                   standard_traps.append(String("1.3.6.1.6.3.1.1.5.5"));
315                   standard_traps.append(String("1.3.6.1.6.3.1.1.5.6"));
316               
317                   Array<String> oids;
318                   String tmpoid = trapOid;
319               
320                   while(tmpoid.find(".") != PEG_NOT_FOUND)
321                   {
322                       oids.append(tmpoid.subString(0, tmpoid.find(".")));
323                       tmpoid = tmpoid.subString(tmpoid.find(".") + 1);
324                   }
325 kumpf    1.12 
326 kumpf    1.5      oids.append(tmpoid);
327               
328                   String ent;
329                   if (Contains(standard_traps, trapOid))
330                   {
331 kumpf    1.12     	//
332                   	// if the trapOid is one of the standard traps,
333                   	// then the SNMPV1 enterprise parameter must be set 
334                   	// to the value of the trapOid, the generic-trap
335                   	// parameter must be set to one of (0 - 5), and the 
336                   	// specific-trap parameter must be set to 0
337                   	//
338 kumpf    1.5  
339                       enterpriseOid = sendtrapOid;
340 kumpf    1.12 
341               	// the generic trap is last sub-identifier of the 
342               	// trapOid minus 1
343               	genTrap = atoi(oids[oids.size() - 1].getCString()) - 1;
344               	specTrap = 0;
345 kumpf    1.5      }
346                   else
347                   {
348 kumpf    1.12 	// 
349               	// if the trapOid is not one of the standard traps:
350               	// then 1) the generic-trap parameter must be set to 6, 
351               	// 2) if the next-to-last sub-identifier of the 
352               	// trapOid is zero, then the SNMPV1 enterprise 
353                	// parameter is the trapOid with the last 2 
354               	// sub-identifiers removed, otherwise, the 
355               	// SNMPV1 enterprise parameter is the trapOid 
356               	// with the last sub-identifier removed;
357               	// 3) the SNMPv1 specific-trap parameter is the last
358               	// sub-identifier of the trapOid;
359               	//
360               
361 kumpf    1.5  	genTrap = 6;
362 mike     1.2  
363 kumpf    1.11         specTrap = atoi(oids[oids.size()-1].getCString());
364 mike     1.2  
365 kumpf    1.12 	ent = oids[0];
366               	for (Uint8 i = 1; i < oids.size()-2; i++)
367               	{
368               	    ent = ent + "." + oids[i];
369               	}
370               
371               	if (oids[oids.size()-2] != "0")
372               	{
373               	    ent = ent + "." + oids[oids.size()-2];
374                  	}
375               
376               	enterpriseOid = MakeOIDFromDot(ent.getCString());
377               	
378               	if (enterpriseOid == NULL)
379               	{
380 humberto 1.14 
381               	  // l10n
382               
383               	  // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
384               	  //   _MSG_INVALID_ENTERPRISEOID);
385               
386               	  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
387               					MessageLoaderParms(_MSG_INVALID_ENTERPRISEOID_KEY,
388 humberto 1.15 							   _MSG_INVALID_ENTERPRISEOID));
389 kumpf    1.12 	}
390 kumpf    1.5      }
391               
392 kumpf    1.12     // creates VarBind
393 kumpf    1.4      for(Uint32 i = 0; i < vbOids.size(); i++)
394 mike     1.2      {
395 kumpf    1.12 	CString _vbOid = vbOids[i].getCString();
396               	CString _vbValue = vbValues[i].getCString();
397               
398               	if ((object = MakeOIDFromDot(_vbOid)) == NULL)
399 kumpf    1.3          {
400 humberto 1.14 
401               	  // l10n
402               	  
403               	  // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
404               	  //   _MSG_INVALID_PROPERTYOID);
405               
406               	  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
407               					MessageLoaderParms(_MSG_INVALID_PROPERTYOID_KEY,
408 humberto 1.15 							   _MSG_INVALID_PROPERTYOID));
409 kumpf    1.3          } 
410               
411 kumpf    1.12 	if (String::equalNoCase(vbTypes[i], "OctetString"))
412               	{
413                   	     OctetString*    value;
414               
415                            value = CloneOctetString(MakeOctetStringFromText(_vbValue));
416                            if (value == NULL)
417                            {
418 humberto 1.14 	       
419               	       // l10n
420               
421               	       // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
422               	       //   _MSG_INVALID_PROPERTYVALUE);
423               
424                      	         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
425               					       MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY,
426 humberto 1.15 								  _MSG_INVALID_PROPERTYVALUE));
427 kumpf    1.12              }
428               
429                            if ((vb = MakeVarBindWithValue(object, 
430               				  	(OID *) NULL, 
431               					OCTET_PRIM_TYPE, 
432               					value)) == NULL)
433                           {
434 humberto 1.14 
435               	      // l10n
436               
437               	      // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
438               	      //    _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE);
439               
440               	      throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
441 humberto 1.15 					    MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE_KEY,
442               							       _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE));
443 kumpf    1.12             }
444                   	}
445               	else if (String::equalNoCase(vbTypes[i], "OID"))
446               	{
447                           void* value = MakeOIDFromDot(_vbValue);
448                           if (value == NULL)
449 kumpf    1.4              {
450 humberto 1.14 	      // l10n
451               
452               	      // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
453               	      //    _MSG_INVALID_PROPERTYVALUE);
454               
455               	      throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
456               					    MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY,
457 humberto 1.15 							       _MSG_INVALID_PROPERTYVALUE));
458 humberto 1.14 							       
459 kumpf    1.4              }
460 kumpf    1.12 
461                           if ((vb = MakeVarBindWithValue(object, 
462               				  	(OID *) NULL, 
463               					OBJECT_ID_TYPE, 
464               					value)) == NULL)
465 kumpf    1.3              {
466 humberto 1.14 
467               	      // l10n
468               
469               	      // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
470               	      //    _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE);
471               
472               	      throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
473 humberto 1.15 					    MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE_KEY,
474               							       _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE));
475 kumpf    1.3              }
476 kumpf    1.12 	}
477               	else
478               	{
479                           int vbvalue = atoi(_vbValue);
480 kumpf    1.6              void* value = &vbvalue;
481 kumpf    1.3  
482 kumpf    1.12             if (value == NULL)
483 kumpf    1.4              {
484 humberto 1.14 
485               	      // l10n
486               
487               	      // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
488               	      //    _MSG_INVALID_PROPERTYVALUE);
489               
490               	      throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
491               					    MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY,
492 humberto 1.15 							       _MSG_INVALID_PROPERTYVALUE));
493 kumpf    1.4              }
494 kumpf    1.12 
495                           if ((vb = MakeVarBindWithValue(object, 
496               				  	(OID *) NULL, 
497               					INTEGER_TYPE, 
498               					value)) == NULL)
499 mike     1.2              {
500 humberto 1.14 
501               	      // l10n
502               
503               	      // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
504               	      //    _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE);
505               
506               	      throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
507 humberto 1.15 					    MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE_KEY,
508               							       _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE));
509 mike     1.2              }
510 kumpf    1.12 	}
511               
512 kumpf    1.4          if (i == 0)
513                       {
514 kumpf    1.12             vbhead = vb;
515                           vblast = vb;
516 kumpf    1.4          }
517                       else
518                       {
519 kumpf    1.12             vblast->next_var = vb;
520                           vblast = vblast->next_var;
521 kumpf    1.4          }
522               
523 kumpf    1.3      }
524 kumpf    1.5  
525 kumpf    1.12     vblast->next_var = NULL;
526 kumpf    1.3  
527 kumpf    1.12     // Now send the trap
528                   switch (snmpVersion)
529 kumpf    1.3      {
530 kumpf    1.12 	case _SNMPv1_TRAP:
531               	{
532                           SendNotificationToDestSMIv1Params(
533               	    1,					// notifyType - TRAP
534 kumpf    1.5              genTrap,				// genTrap
535                           specTrap,				// specTrap
536 kumpf    1.3              enterpriseOid,			// enterprise
537                           agent_addr,				// agent_addr
538 kumpf    1.12             vbhead,				// vb
539 kumpf    1.3              NULL,				// contextName
540                           1,					// retryCount
541                           1,					// timeout
542 kumpf    1.5              community_name,			// securityName,
543 kumpf    1.3              SR_SECURITY_LEVEL_NOAUTH,		// securityLevel
544                           SR_SECURITY_MODEL_V1,		// securityModel
545                           &global_ti,				// Transport Info
546 kumpf    1.12             0);          			// cfg_chk
547               	    break;
548               	}
549               	case _SNMPv2C_TRAP:
550               	{
551                           SendNotificationToDestSMIv2Params(
552               	    (SR_INT32)SNMPv2_TRAP_TYPE,		// notifyType - NOTIFICATION
553 kumpf    1.3              sendtrapOid,			// snmpTrapOID
554                           agent_addr,				// agent_addr
555 kumpf    1.12             vbhead,				// vb
556 kumpf    1.3              NULL,				// contextName
557                           1,					// retryCount
558                           100,				// timeout
559 kumpf    1.5              community_name,			// securityName or community
560 kumpf    1.3              SR_SECURITY_LEVEL_NOAUTH,		// securityLevel
561 kumpf    1.12             SR_SECURITY_MODEL_V2C,		// securityModel
562 kumpf    1.3              &global_ti,				// TransportInfo
563                           0);					// cfg_chk
564 kumpf    1.12 	    break;
565               	}
566               	default:
567               	{
568 humberto 1.14 	  // l10n
569               
570               	  // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
571               	  // _MSG_VERSION_NOT_SUPPORTED);
572               
573               	  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,	  
574               					MessageLoaderParms(_MSG_VERSION_NOT_SUPPORTED_KEY,
575 humberto 1.15 							   _MSG_VERSION_NOT_SUPPORTED));
576 humberto 1.14 
577               	  break;
578 kumpf    1.12 	}
579                   }
580               
581                   // Free OID built by calls MakeOIDFromDot()
582                   FreeOID(sendtrapOid);
583                   FreeOID(enterpriseOid);
584                   FreeOID(object);
585               
586                   // Free the data structures allocated and built by calls
587                   // MakeOctetString() and MakeOctetStringFrom Text()
588                   FreeOctetString(community_name);
589                   FreeOctetString(agent_addr);
590               
591                   // Free the VarBind data structures allocated and built 
592                   // by calls MakeVarBindWithValue()
593                   FreeVarBindList(vbhead);
594                   FreeVarBindList(vb);
595                   FreeVarBindList(vblast);
596               }
597               
598               // get the IP address of a host
599 kumpf    1.12 char * snmpDeliverTrap_emanate::_getIPAddress(const CString& hostName)
600               {
601                   struct hostent *targetHostInfo;
602                   struct in_addr in;
603               
604 keith.petley 1.13 #ifdef PEGASUS_OS_SOLARIS
605                   #define HOSTENT_BUFF_SIZE	8192
606                       char			buf[HOSTENT_BUFF_SIZE];
607                       struct hostent		h_result;
608                       int				h_errorp;
609                       targetHostInfo=gethostbyname_r(hostName, &h_result, buff,
610                   					HOSTENT_BUFF_SIZE, &h_errorp);
611                   #else
612 kumpf        1.12     targetHostInfo = gethostbyname(hostName);
613 keith.petley 1.13 #endif
614 kumpf        1.12 
615                       if (targetHostInfo == NULL)
616                       {
617                   	return(NULL);
618                       }
619                   	    
620                       char ** networkAddr;
621                       networkAddr = targetHostInfo->h_addr_list;
622                       (void)memcpy(&in.s_addr, *networkAddr, sizeof(in.s_addr));
623                       char * ipAddr = inet_ntoa(in);
624                       return(ipAddr);
625                   }
626                   
627                   // check the value of each part of an IP address which should be 
628                   // between 0 and 255
629                   Boolean snmpDeliverTrap_emanate::_isValidOctet(const Uint32& octetValue)
630                   {
631                       if (octetValue > 0 && octetValue < 255)
632                       {
633                   	return true;
634 kumpf        1.3      }
635                       else
636                       {
637 kumpf        1.12 	return false;
638 mike         1.2      }
639                   }
640                   
641                   PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2