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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2