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

  1 martin 1.28 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.29 //
  3 martin 1.28 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.29 //
 10 martin 1.28 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.29 //
 17 martin 1.28 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.29 //
 20 martin 1.28 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.29 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.29 //
 28 martin 1.28 //////////////////////////////////////////////////////////////////////////
 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             #include <Pegasus/Common/InternalException.h>
 35 mike   1.2  #include "snmpDeliverTrap_emanate.h"
 36 kumpf  1.12 
 37 humberto 1.14 #include <Pegasus/Common/MessageLoader.h>
 38               
 39 kumpf    1.12 // EMANATE specific declarations and entry points - MUST be in begining
 40               // and outside NAMESPACE.
 41               
 42               // master agent needs these two declarations for communication with sub-agent.
 43 kumpf    1.24 // Following two declarations must be in the CODE.
 44 kumpf    1.12 
 45               #include <prnt_lib.h>  // MUST be at the end in include list.
 46 mike     1.2  
 47 kumpf    1.24 static const char* sr_filename = __FILE__;
 48 kumpf    1.3  
 49 kumpf    1.24 IPCFunctionP IPCfp;  /* IPC functions pointer */
 50 kumpf    1.3  
 51 kumpf    1.24 // This code would normally be generated by Emanate from defined MIB objects.
 52               // Since we do not have MIB objects defined, just defined here to load
 53               // subagent as library. OidList[] provides objects for entry point to master
 54               // agent.
 55 kumpf    1.3  
 56 kumpf    1.24 // The objects internal to the agent
 57               ObjectInfo OidList[] =
 58 kumpf    1.3  {
 59 kumpf    1.24     {
 60                       { 0, NULL },
 61 kumpf    1.3  #ifndef LIGHT
 62 kumpf    1.24         NULL,
 63 kumpf    1.3  #endif /* LIGHT */
 64 kumpf    1.24         0, 0, 0, 0,
 65                       NULL, NULL
 66                   }
 67 kumpf    1.3  };
 68               
 69 kumpf    1.24 // This code would normally be generated by Emanate in k_* routine from
 70               // defined MIB objects.  Since we do not have MIB objects defined, just
 71               // define here to pass compile and enable entry point for master agent to
 72               // start communication with library.
 73 kumpf    1.3  
 74               // Called by the master agent during initialization */
 75               int k_initialize()
 76               {
 77 kumpf    1.24     return 1;
 78 kumpf    1.3  }
 79 kumpf    1.9  
 80 kumpf    1.12 // END EMANATE specific declarations.
 81               
 82 kumpf    1.9  PEGASUS_NAMESPACE_BEGIN
 83               
 84               PEGASUS_USING_STD;
 85 kumpf    1.3  
 86               snmpDeliverTrap_emanate::snmpDeliverTrap_emanate()
 87               {
 88               }
 89               
 90               snmpDeliverTrap_emanate::~snmpDeliverTrap_emanate()
 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 kumpf    1.24     if (InitSubagent() == -1)
109 kumpf    1.3      {
110 kumpf    1.24         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
111                           _MSG_INITSUBAGENT_FAILED_KEY,
112                           _MSG_INITSUBAGENT_FAILED));
113 humberto 1.14 
114 kumpf    1.3      }
115               }
116               
117 kumpf    1.23 void snmpDeliverTrap_emanate::terminate()
118               {
119                   //
120 kumpf    1.24     // Close the connection to the Master Agent and shut down the
121 kumpf    1.23     // Subagent
122                   //
123                   EndSubagent();
124               }
125               
126 humberto 1.14 
127 kumpf    1.3  void snmpDeliverTrap_emanate::deliverTrap(
128 kumpf    1.12         const String& trapOid,
129 kumpf    1.24         const String& securityName,
130                       const String& targetHost,
131                       const Uint16& targetHostFormat,
132                       const String& otherTargetHostFormat,
133 kumpf    1.12         const Uint32& portNumber,
134 kumpf    1.24         const Uint16& snmpVersion,
135 kumpf    1.12         const String& engineID,
136 sahana.prabhakar 1.31         const Uint8& snmpSecLevel,
137                               const Uint8& snmpSecAuthProto,
138                               const Array<Uint8>& snmpSecAuthKey,
139                               const Uint8& snmpSecPrivProto,
140                               const Array<Uint8>& snmpSecPrivKey,
141 kumpf            1.17         const Array<String>& vbOids,
142                               const Array<String>& vbTypes,
143                               const Array<String>& vbValues)
144 mike             1.2  {
145 kumpf            1.24     VarBind* vbhead = NULL;
146                           VarBind* vb = NULL;
147                           VarBind* vblast = NULL;
148                       
149                           OID* object = NULL;
150 kumpf            1.12 
151                           // Translate a string into an OID
152 kumpf            1.24     OID* sendtrapOid = MakeOIDFromDot(trapOid.getCString());
153 kumpf            1.12 
154                           if (sendtrapOid == NULL)
155                           {
156 kumpf            1.24         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
157                                   _MSG_INVALID_KEY,
158                                   _MSG_INVALID_TRAPOID));
159 kumpf            1.12     }
160                       
161                           // Destination : convert targetHost into Transport
162 kumpf            1.5  
163 kumpf            1.12     CString trap_dest = targetHost.getCString();
164 kumpf            1.5  
165 kumpf            1.24     TransportInfo global_ti;
166 kumpf            1.5      global_ti.type = SR_IP_TRANSPORT;
167                       
168 kumpf            1.12     switch (targetHostFormat)
169                           {
170 kumpf            1.24         case _HOST_NAME:
171                               {
172                                   char* ipAddr = _getIPAddress(trap_dest);
173                       
174                                   if (ipAddr == NULL)
175                                   {
176                                       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
177                                           MessageLoaderParms(
178                                              _MSG_DESTINATION_NOT_FOUND_KEY,
179                                              _MSG_DESTINATION_NOT_FOUND));
180                       
181                                   }
182                                   global_ti.t_ipAddr = inet_addr(trap_dest);
183                                   break;
184                               }
185                               case _IPV4_ADDRESS:
186                               {
187                                   global_ti.t_ipAddr = inet_addr(trap_dest);
188                                   break;
189                               }
190                               default:
191 kumpf            1.24         {
192                                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
193                                       MessageLoaderParms(
194                                           _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY,
195                                           _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED));
196                               }
197                           }
198 kumpf            1.12 
199                           global_ti.t_ipPort = htons((unsigned short)portNumber);
200                       
201                           // Community Name, default is public
202                           CString _community;
203                           if (securityName.size() == 0)
204                           {
205 kumpf            1.24         String community;
206                               community.assign("public");
207                               _community = community.getCString();
208 kumpf            1.12     }
209                           else
210                           {
211 kumpf            1.24         _community = securityName.getCString();
212 kumpf            1.12     }
213                       
214                           OctetString* community_name = MakeOctetStringFromText(_community);
215                       
216                           if (community_name == NULL)
217                           {
218 kumpf            1.24         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
219                                   _MSG_INVALID_SECURITY_NAME_KEY,
220                                   _MSG_INVALID_SECURITY_NAME));
221 kumpf            1.12     }
222 kumpf            1.5  
223 kumpf            1.3      // getting IP address of the host
224 kumpf            1.12 
225                           CString hostname = System::getHostName().getCString();
226                           char* IP_string = _getIPAddress(hostname);
227                       
228 kumpf            1.3      // formatting agent(host) address into OctetString format
229 kumpf            1.12 
230 kumpf            1.3      OctetString* agent_addr;
231                       
232                           SR_INT32 s1, s2, s3, s4;
233                           SR_UINT32 ipaddr;
234                       
235                           // pull out each of the 4 octet values from IP address
236 kumpf            1.12 
237 kumpf            1.3      sscanf(IP_string,"%d.%d.%d.%d", &s1, &s2, &s3, &s4);
238 kumpf            1.24 
239 kumpf            1.12     // validate the values for s1, s2, s3, and s4 to make sure values are
240 kumpf            1.3      // between 0 and 255
241 kumpf            1.12     if (!_isValidOctet(s1) || !_isValidOctet(s2) ||
242 kumpf            1.24         !_isValidOctet(s3) || !_isValidOctet(s4))
243 kumpf            1.12     {
244 kumpf            1.24         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
245                                   _MSG_INVALID_OCTET_VALUE_KEY,
246                                   _MSG_INVALID_OCTET_VALUE));
247                           }
248 humberto         1.14 
249 kumpf            1.3      // create an empty 4 length OctetString
250 kumpf            1.12 
251 kumpf            1.3      agent_addr = MakeOctetString(NULL,4);
252 kumpf            1.12 
253                           if (agent_addr == NULL)
254                           {
255 kumpf            1.24         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
256                                   _MSG_CREATE_OCTET_FAILED_KEY,
257                                   _MSG_CREATE_OCTET_FAILED));
258                           }
259 humberto         1.14 
260 kumpf            1.3      // fill in values for OctetString
261 kumpf            1.12 
262 kumpf            1.3      agent_addr->octet_ptr[0] = (unsigned char)s1;
263                           agent_addr->octet_ptr[1] = (unsigned char)s2;
264                           agent_addr->octet_ptr[2] = (unsigned char)s3;
265                           agent_addr->octet_ptr[3] = (unsigned char)s4;
266                       
267 kumpf            1.24     // specTrap from trapOid.
268 kumpf            1.12 
269 kumpf            1.5      SR_INT32 genTrap = 0;
270                           SR_INT32 specTrap = 0;
271 kumpf            1.24 
272 kumpf            1.5      OID* enterpriseOid ;
273                       
274                           Array<String> standard_traps;
275                       
276                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.1"));
277                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.2"));
278                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.3"));
279                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.4"));
280                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.5"));
281                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.6"));
282                       
283                           Array<String> oids;
284                           String tmpoid = trapOid;
285                       
286                           while(tmpoid.find(".") != PEG_NOT_FOUND)
287                           {
288                               oids.append(tmpoid.subString(0, tmpoid.find(".")));
289                               tmpoid = tmpoid.subString(tmpoid.find(".") + 1);
290                           }
291 kumpf            1.12 
292 kumpf            1.5      oids.append(tmpoid);
293                       
294                           String ent;
295                           if (Contains(standard_traps, trapOid))
296                           {
297 kumpf            1.24         //
298                               // if the trapOid is one of the standard traps,
299                               // then the SNMPV1 enterprise parameter must be set
300                               // to the value of the trapOid, the generic-trap
301                               // parameter must be set to one of (0 - 5), and the
302                               // specific-trap parameter must be set to 0
303                               //
304 kumpf            1.5  
305                               enterpriseOid = sendtrapOid;
306 kumpf            1.12 
307 kumpf            1.24         // the generic trap is last sub-identifier of the
308                               // trapOid minus 1
309                               genTrap = atoi(oids[oids.size() - 1].getCString()) - 1;
310                               specTrap = 0;
311 kumpf            1.5      }
312                           else
313                           {
314 kumpf            1.24         //
315                               // if the trapOid is not one of the standard traps:
316                               // then 1) the generic-trap parameter must be set to 6,
317                               // 2) if the next-to-last sub-identifier of the
318                               // trapOid is zero, then the SNMPV1 enterprise
319                               // parameter is the trapOid with the last 2
320                               // sub-identifiers removed, otherwise, the
321                               // SNMPV1 enterprise parameter is the trapOid
322                               // with the last sub-identifier removed;
323                               // 3) the SNMPv1 specific-trap parameter is the last
324                               // sub-identifier of the trapOid;
325                               //
326 kumpf            1.12 
327 kumpf            1.24         genTrap = 6;
328 mike             1.2  
329 kumpf            1.11         specTrap = atoi(oids[oids.size()-1].getCString());
330 mike             1.2  
331 kumpf            1.24         ent = oids[0];
332                               for (Uint8 i = 1; i < oids.size()-2; i++)
333                               {
334                                   ent = ent + "." + oids[i];
335                               }
336                       
337                               if (oids[oids.size()-2] != "0")
338                               {
339                                   ent = ent + "." + oids[oids.size()-2];
340                               }
341                       
342                               enterpriseOid = MakeOIDFromDot(ent.getCString());
343                       
344                               if (enterpriseOid == NULL)
345                               {
346                                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
347                                       _MSG_INVALID_ENTERPRISEOID_KEY,
348                                       _MSG_INVALID_ENTERPRISEOID));
349                               }
350 kumpf            1.5      }
351                       
352 kumpf            1.12     // creates VarBind
353 kumpf            1.24     for (Uint32 i = 0; i < vbOids.size(); i++)
354 mike             1.2      {
355 kumpf            1.24         CString _vbOid = vbOids[i].getCString();
356                               CString _vbValue = vbValues[i].getCString();
357 kumpf            1.12 
358 kumpf            1.24         if ((object = MakeOIDFromDot(_vbOid)) == NULL)
359 kumpf            1.3          {
360 kumpf            1.24             throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
361                                       _MSG_INVALID_PROPERTYOID_KEY,
362                                       _MSG_INVALID_PROPERTYOID));
363                               }
364                       
365                               if (String::equalNoCase(vbTypes[i], "OctetString"))
366                               {
367                                   OctetString* value;
368 humberto         1.14 
369 kumpf            1.24             value = CloneOctetString(MakeOctetStringFromText(_vbValue));
370                                   if (value == NULL)
371 kumpf            1.12             {
372 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
373                                           MessageLoaderParms(
374                                               _MSG_INVALID_PROPERTYVALUE_KEY,
375                                               _MSG_INVALID_PROPERTYVALUE));
376                                   }
377 humberto         1.14 
378 kumpf            1.24             if ((vb = MakeVarBindWithValue(
379                                            object,
380                                            (OID*) NULL,
381                                            OCTET_PRIM_TYPE,
382                                            value)) == NULL)
383                                   {
384                                       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
385                                           MessageLoaderParms(
386                                               _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE_KEY,
387                                               _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE));
388 kumpf            1.12             }
389 kumpf            1.24         }
390                               else if (String::equalNoCase(vbTypes[i], "OID"))
391                               {
392 kumpf            1.12             void* value = MakeOIDFromDot(_vbValue);
393                                   if (value == NULL)
394 kumpf            1.4              {
395 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
396                                           MessageLoaderParms(
397                                               _MSG_INVALID_PROPERTYVALUE_KEY,
398                                               _MSG_INVALID_PROPERTYVALUE));
399 kumpf            1.4              }
400 kumpf            1.12 
401 kumpf            1.24             if ((vb = MakeVarBindWithValue(
402                                            object,
403                                            (OID*) NULL,
404                                            OBJECT_ID_TYPE,
405                                            value)) == NULL)
406 kumpf            1.3              {
407 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
408                                           MessageLoaderParms(
409                                               _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE_KEY,
410                                               _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE));
411 kumpf            1.3              }
412 kumpf            1.24         }
413                               else
414                               {
415 kumpf            1.12             int vbvalue = atoi(_vbValue);
416 kumpf            1.6              void* value = &vbvalue;
417 kumpf            1.3  
418 kumpf            1.12             if (value == NULL)
419 kumpf            1.4              {
420 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
421                                           MessageLoaderParms(
422                                               _MSG_INVALID_PROPERTYVALUE_KEY,
423                                               _MSG_INVALID_PROPERTYVALUE));
424 kumpf            1.4              }
425 kumpf            1.12 
426 kumpf            1.24             if ((vb = MakeVarBindWithValue(
427                                            object,
428                                            (OID*) NULL,
429                                            INTEGER_TYPE,
430                                            value)) == NULL)
431 mike             1.2              {
432 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
433                                           MessageLoaderParms(
434                                               _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE_KEY,
435                                               _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE));
436 mike             1.2              }
437 kumpf            1.24         }
438 kumpf            1.12 
439 kumpf            1.4          if (i == 0)
440                               {
441 kumpf            1.12             vbhead = vb;
442                                   vblast = vb;
443 kumpf            1.4          }
444                               else
445                               {
446 kumpf            1.12             vblast->next_var = vb;
447                                   vblast = vblast->next_var;
448 kumpf            1.4          }
449                       
450 kumpf            1.3      }
451 kumpf            1.5  
452 kumpf            1.12     vblast->next_var = NULL;
453 kumpf            1.3  
454 kumpf            1.12     // Now send the trap
455                           switch (snmpVersion)
456 kumpf            1.3      {
457 kumpf            1.24         case _SNMPv1_TRAP:
458                               {
459 kumpf            1.12             SendNotificationToDestSMIv1Params(
460 kumpf            1.24             1,                                  // notifyType - TRAP
461                                   genTrap,                            // genTrap
462                                   specTrap,                           // specTrap
463                                   enterpriseOid,                      // enterprise
464                                   agent_addr,                         // agent_addr
465                                   vbhead,                             // vb
466                                   NULL,                               // contextName
467                                   1,                                  // retryCount
468                                   1,                                  // timeout
469                                   community_name,                     // securityName,
470                                   SR_SECURITY_LEVEL_NOAUTH,           // securityLevel
471                                   SR_SECURITY_MODEL_V1,               // securityModel
472                                   &global_ti,                         // Transport Info
473                                   0);                                 // cfg_chk
474                                   break;
475                               }
476                               case _SNMPv2C_TRAP:
477                               {
478 kumpf            1.12             SendNotificationToDestSMIv2Params(
479 kumpf            1.24             (SR_INT32)SNMPv2_TRAP_TYPE,         // notifyType - NOTIFICATION
480                                   sendtrapOid,                        // snmpTrapOID
481                                   agent_addr,                         // agent_addr
482                                   vbhead,                             // vb
483                                   NULL,                               // contextName
484                                   1,                                  // retryCount
485                                   100,                                // timeout
486                                   community_name,                     // securityName or community
487                                   SR_SECURITY_LEVEL_NOAUTH,           // securityLevel
488                                   SR_SECURITY_MODEL_V2C,              // securityModel
489                                   &global_ti,                         // TransportInfo
490                                   0);                                 // cfg_chk
491                                   break;
492                               }
493                               default:
494                               {
495                                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
496                                       MessageLoaderParms(
497                                           _MSG_VERSION_NOT_SUPPORTED_KEY,
498                                           _MSG_VERSION_NOT_SUPPORTED));
499                               }
500 kumpf            1.12     }
501                       
502                           // Free OID built by calls MakeOIDFromDot()
503                           FreeOID(sendtrapOid);
504                           FreeOID(enterpriseOid);
505                           FreeOID(object);
506                       
507                           // Free the data structures allocated and built by calls
508                           // MakeOctetString() and MakeOctetStringFrom Text()
509                           FreeOctetString(community_name);
510                           FreeOctetString(agent_addr);
511                       
512 kumpf            1.24     // Free the VarBind data structures allocated and built
513 kumpf            1.12     // by calls MakeVarBindWithValue()
514                           FreeVarBindList(vbhead);
515                           FreeVarBindList(vb);
516                           FreeVarBindList(vblast);
517                       }
518                       
519                       // get the IP address of a host
520 kumpf            1.24 char* snmpDeliverTrap_emanate::_getIPAddress(const CString& hostName)
521 kumpf            1.12 {
522 kumpf            1.24     struct hostent* targetHostInfo;
523 kumpf            1.12     struct in_addr in;
524                       
525 dmitry.mikulin   1.27     char hostEntryBuffer[8192];
526                           struct hostent hostEntryStruct;
527 kumpf            1.30     targetHostInfo = System::getHostByName(hostName,
528 dmitry.mikulin   1.27         &hostEntryStruct, hostEntryBuffer, sizeof (hostEntryBuffer));
529 kumpf            1.12 
530                           if (targetHostInfo == NULL)
531                           {
532 kumpf            1.24         return NULL;
533 kumpf            1.12     }
534 kumpf            1.24 
535                           char** networkAddr;
536 kumpf            1.12     networkAddr = targetHostInfo->h_addr_list;
537                           (void)memcpy(&in.s_addr, *networkAddr, sizeof(in.s_addr));
538 kumpf            1.24     char* ipAddr = inet_ntoa(in);
539 kumpf            1.12     return(ipAddr);
540                       }
541                       
542 kumpf            1.24 // check the value of each part of an IP address which should be
543 kumpf            1.12 // between 0 and 255
544                       Boolean snmpDeliverTrap_emanate::_isValidOctet(const Uint32& octetValue)
545                       {
546                           if (octetValue > 0 && octetValue < 255)
547                           {
548 kumpf            1.24         return true;
549 kumpf            1.3      }
550                           else
551                           {
552 kumpf            1.24         return false;
553 mike             1.2      }
554                       }
555                       
556                       PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2