(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                                   break;
197                               }
198                           }
199 kumpf            1.12 
200                           global_ti.t_ipPort = htons((unsigned short)portNumber);
201                       
202                           // Community Name, default is public
203                           CString _community;
204                           if (securityName.size() == 0)
205                           {
206 kumpf            1.24         String community;
207                               community.assign("public");
208                               _community = community.getCString();
209 kumpf            1.12     }
210                           else
211                           {
212 kumpf            1.24         _community = securityName.getCString();
213 kumpf            1.12     }
214                       
215                           OctetString* community_name = MakeOctetStringFromText(_community);
216                       
217                           if (community_name == NULL)
218                           {
219 kumpf            1.24         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
220                                   _MSG_INVALID_SECURITY_NAME_KEY,
221                                   _MSG_INVALID_SECURITY_NAME));
222 kumpf            1.12     }
223 kumpf            1.5  
224 kumpf            1.3      // getting IP address of the host
225 kumpf            1.12 
226                           CString hostname = System::getHostName().getCString();
227                           char* IP_string = _getIPAddress(hostname);
228                       
229 kumpf            1.3      // formatting agent(host) address into OctetString format
230 kumpf            1.12 
231 kumpf            1.3      OctetString* agent_addr;
232                       
233                           SR_INT32 s1, s2, s3, s4;
234                           SR_UINT32 ipaddr;
235                       
236                           // pull out each of the 4 octet values from IP address
237 kumpf            1.12 
238 kumpf            1.3      sscanf(IP_string,"%d.%d.%d.%d", &s1, &s2, &s3, &s4);
239 kumpf            1.24 
240 kumpf            1.12     // validate the values for s1, s2, s3, and s4 to make sure values are
241 kumpf            1.3      // between 0 and 255
242 kumpf            1.12     if (!_isValidOctet(s1) || !_isValidOctet(s2) ||
243 kumpf            1.24         !_isValidOctet(s3) || !_isValidOctet(s4))
244 kumpf            1.12     {
245 kumpf            1.24         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
246                                   _MSG_INVALID_OCTET_VALUE_KEY,
247                                   _MSG_INVALID_OCTET_VALUE));
248                           }
249 humberto         1.14 
250 kumpf            1.3      // create an empty 4 length OctetString
251 kumpf            1.12 
252 kumpf            1.3      agent_addr = MakeOctetString(NULL,4);
253 kumpf            1.12 
254                           if (agent_addr == NULL)
255                           {
256 kumpf            1.24         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
257                                   _MSG_CREATE_OCTET_FAILED_KEY,
258                                   _MSG_CREATE_OCTET_FAILED));
259                           }
260 humberto         1.14 
261 kumpf            1.3      // fill in values for OctetString
262 kumpf            1.12 
263 kumpf            1.3      agent_addr->octet_ptr[0] = (unsigned char)s1;
264                           agent_addr->octet_ptr[1] = (unsigned char)s2;
265                           agent_addr->octet_ptr[2] = (unsigned char)s3;
266                           agent_addr->octet_ptr[3] = (unsigned char)s4;
267                       
268 kumpf            1.24     // specTrap from trapOid.
269 kumpf            1.12 
270 kumpf            1.5      SR_INT32 genTrap = 0;
271                           SR_INT32 specTrap = 0;
272 kumpf            1.24 
273 kumpf            1.5      OID* enterpriseOid ;
274                       
275                           Array<String> standard_traps;
276                       
277                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.1"));
278                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.2"));
279                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.3"));
280                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.4"));
281                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.5"));
282                           standard_traps.append(String("1.3.6.1.6.3.1.1.5.6"));
283                       
284                           Array<String> oids;
285                           String tmpoid = trapOid;
286                       
287                           while(tmpoid.find(".") != PEG_NOT_FOUND)
288                           {
289                               oids.append(tmpoid.subString(0, tmpoid.find(".")));
290                               tmpoid = tmpoid.subString(tmpoid.find(".") + 1);
291                           }
292 kumpf            1.12 
293 kumpf            1.5      oids.append(tmpoid);
294                       
295                           String ent;
296                           if (Contains(standard_traps, trapOid))
297                           {
298 kumpf            1.24         //
299                               // if the trapOid is one of the standard traps,
300                               // then the SNMPV1 enterprise parameter must be set
301                               // to the value of the trapOid, the generic-trap
302                               // parameter must be set to one of (0 - 5), and the
303                               // specific-trap parameter must be set to 0
304                               //
305 kumpf            1.5  
306                               enterpriseOid = sendtrapOid;
307 kumpf            1.12 
308 kumpf            1.24         // the generic trap is last sub-identifier of the
309                               // trapOid minus 1
310                               genTrap = atoi(oids[oids.size() - 1].getCString()) - 1;
311                               specTrap = 0;
312 kumpf            1.5      }
313                           else
314                           {
315 kumpf            1.24         //
316                               // if the trapOid is not one of the standard traps:
317                               // then 1) the generic-trap parameter must be set to 6,
318                               // 2) if the next-to-last sub-identifier of the
319                               // trapOid is zero, then the SNMPV1 enterprise
320                               // parameter is the trapOid with the last 2
321                               // sub-identifiers removed, otherwise, the
322                               // SNMPV1 enterprise parameter is the trapOid
323                               // with the last sub-identifier removed;
324                               // 3) the SNMPv1 specific-trap parameter is the last
325                               // sub-identifier of the trapOid;
326                               //
327 kumpf            1.12 
328 kumpf            1.24         genTrap = 6;
329 mike             1.2  
330 kumpf            1.11         specTrap = atoi(oids[oids.size()-1].getCString());
331 mike             1.2  
332 kumpf            1.24         ent = oids[0];
333                               for (Uint8 i = 1; i < oids.size()-2; i++)
334                               {
335                                   ent = ent + "." + oids[i];
336                               }
337                       
338                               if (oids[oids.size()-2] != "0")
339                               {
340                                   ent = ent + "." + oids[oids.size()-2];
341                               }
342                       
343                               enterpriseOid = MakeOIDFromDot(ent.getCString());
344                       
345                               if (enterpriseOid == NULL)
346                               {
347                                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
348                                       _MSG_INVALID_ENTERPRISEOID_KEY,
349                                       _MSG_INVALID_ENTERPRISEOID));
350                               }
351 kumpf            1.5      }
352                       
353 kumpf            1.12     // creates VarBind
354 kumpf            1.24     for (Uint32 i = 0; i < vbOids.size(); i++)
355 mike             1.2      {
356 kumpf            1.24         CString _vbOid = vbOids[i].getCString();
357                               CString _vbValue = vbValues[i].getCString();
358 kumpf            1.12 
359 kumpf            1.24         if ((object = MakeOIDFromDot(_vbOid)) == NULL)
360 kumpf            1.3          {
361 kumpf            1.24             throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
362                                       _MSG_INVALID_PROPERTYOID_KEY,
363                                       _MSG_INVALID_PROPERTYOID));
364                               }
365                       
366                               if (String::equalNoCase(vbTypes[i], "OctetString"))
367                               {
368                                   OctetString* value;
369 humberto         1.14 
370 kumpf            1.24             value = CloneOctetString(MakeOctetStringFromText(_vbValue));
371                                   if (value == NULL)
372 kumpf            1.12             {
373 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
374                                           MessageLoaderParms(
375                                               _MSG_INVALID_PROPERTYVALUE_KEY,
376                                               _MSG_INVALID_PROPERTYVALUE));
377                                   }
378 humberto         1.14 
379 kumpf            1.24             if ((vb = MakeVarBindWithValue(
380                                            object,
381                                            (OID*) NULL,
382                                            OCTET_PRIM_TYPE,
383                                            value)) == NULL)
384                                   {
385                                       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
386                                           MessageLoaderParms(
387                                               _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE_KEY,
388                                               _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE));
389 kumpf            1.12             }
390 kumpf            1.24         }
391                               else if (String::equalNoCase(vbTypes[i], "OID"))
392                               {
393 kumpf            1.12             void* value = MakeOIDFromDot(_vbValue);
394                                   if (value == NULL)
395 kumpf            1.4              {
396 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
397                                           MessageLoaderParms(
398                                               _MSG_INVALID_PROPERTYVALUE_KEY,
399                                               _MSG_INVALID_PROPERTYVALUE));
400 kumpf            1.4              }
401 kumpf            1.12 
402 kumpf            1.24             if ((vb = MakeVarBindWithValue(
403                                            object,
404                                            (OID*) NULL,
405                                            OBJECT_ID_TYPE,
406                                            value)) == NULL)
407 kumpf            1.3              {
408 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
409                                           MessageLoaderParms(
410                                               _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE_KEY,
411                                               _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE));
412 kumpf            1.3              }
413 kumpf            1.24         }
414                               else
415                               {
416 kumpf            1.12             int vbvalue = atoi(_vbValue);
417 kumpf            1.6              void* value = &vbvalue;
418 kumpf            1.3  
419 kumpf            1.12             if (value == NULL)
420 kumpf            1.4              {
421 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
422                                           MessageLoaderParms(
423                                               _MSG_INVALID_PROPERTYVALUE_KEY,
424                                               _MSG_INVALID_PROPERTYVALUE));
425 kumpf            1.4              }
426 kumpf            1.12 
427 kumpf            1.24             if ((vb = MakeVarBindWithValue(
428                                            object,
429                                            (OID*) NULL,
430                                            INTEGER_TYPE,
431                                            value)) == NULL)
432 mike             1.2              {
433 kumpf            1.24                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
434                                           MessageLoaderParms(
435                                               _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE_KEY,
436                                               _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE));
437 mike             1.2              }
438 kumpf            1.24         }
439 kumpf            1.12 
440 kumpf            1.4          if (i == 0)
441                               {
442 kumpf            1.12             vbhead = vb;
443                                   vblast = vb;
444 kumpf            1.4          }
445                               else
446                               {
447 kumpf            1.12             vblast->next_var = vb;
448                                   vblast = vblast->next_var;
449 kumpf            1.4          }
450                       
451 kumpf            1.3      }
452 kumpf            1.5  
453 kumpf            1.12     vblast->next_var = NULL;
454 kumpf            1.3  
455 kumpf            1.12     // Now send the trap
456                           switch (snmpVersion)
457 kumpf            1.3      {
458 kumpf            1.24         case _SNMPv1_TRAP:
459                               {
460 kumpf            1.12             SendNotificationToDestSMIv1Params(
461 kumpf            1.24             1,                                  // notifyType - TRAP
462                                   genTrap,                            // genTrap
463                                   specTrap,                           // specTrap
464                                   enterpriseOid,                      // enterprise
465                                   agent_addr,                         // agent_addr
466                                   vbhead,                             // vb
467                                   NULL,                               // contextName
468                                   1,                                  // retryCount
469                                   1,                                  // timeout
470                                   community_name,                     // securityName,
471                                   SR_SECURITY_LEVEL_NOAUTH,           // securityLevel
472                                   SR_SECURITY_MODEL_V1,               // securityModel
473                                   &global_ti,                         // Transport Info
474                                   0);                                 // cfg_chk
475                                   break;
476                               }
477                               case _SNMPv2C_TRAP:
478                               {
479 kumpf            1.12             SendNotificationToDestSMIv2Params(
480 kumpf            1.24             (SR_INT32)SNMPv2_TRAP_TYPE,         // notifyType - NOTIFICATION
481                                   sendtrapOid,                        // snmpTrapOID
482                                   agent_addr,                         // agent_addr
483                                   vbhead,                             // vb
484                                   NULL,                               // contextName
485                                   1,                                  // retryCount
486                                   100,                                // timeout
487                                   community_name,                     // securityName or community
488                                   SR_SECURITY_LEVEL_NOAUTH,           // securityLevel
489                                   SR_SECURITY_MODEL_V2C,              // securityModel
490                                   &global_ti,                         // TransportInfo
491                                   0);                                 // cfg_chk
492                                   break;
493                               }
494                               default:
495                               {
496                                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
497                                       MessageLoaderParms(
498                                           _MSG_VERSION_NOT_SUPPORTED_KEY,
499                                           _MSG_VERSION_NOT_SUPPORTED));
500                                   break;
501 kumpf            1.24         }
502 kumpf            1.12     }
503                       
504                           // Free OID built by calls MakeOIDFromDot()
505                           FreeOID(sendtrapOid);
506                           FreeOID(enterpriseOid);
507                           FreeOID(object);
508                       
509                           // Free the data structures allocated and built by calls
510                           // MakeOctetString() and MakeOctetStringFrom Text()
511                           FreeOctetString(community_name);
512                           FreeOctetString(agent_addr);
513                       
514 kumpf            1.24     // Free the VarBind data structures allocated and built
515 kumpf            1.12     // by calls MakeVarBindWithValue()
516                           FreeVarBindList(vbhead);
517                           FreeVarBindList(vb);
518                           FreeVarBindList(vblast);
519                       }
520                       
521                       // get the IP address of a host
522 kumpf            1.24 char* snmpDeliverTrap_emanate::_getIPAddress(const CString& hostName)
523 kumpf            1.12 {
524 kumpf            1.24     struct hostent* targetHostInfo;
525 kumpf            1.12     struct in_addr in;
526                       
527 dmitry.mikulin   1.27     char hostEntryBuffer[8192];
528                           struct hostent hostEntryStruct;
529 kumpf            1.30     targetHostInfo = System::getHostByName(hostName,
530 dmitry.mikulin   1.27         &hostEntryStruct, hostEntryBuffer, sizeof (hostEntryBuffer));
531 kumpf            1.12 
532                           if (targetHostInfo == NULL)
533                           {
534 kumpf            1.24         return NULL;
535 kumpf            1.12     }
536 kumpf            1.24 
537                           char** networkAddr;
538 kumpf            1.12     networkAddr = targetHostInfo->h_addr_list;
539                           (void)memcpy(&in.s_addr, *networkAddr, sizeof(in.s_addr));
540 kumpf            1.24     char* ipAddr = inet_ntoa(in);
541 kumpf            1.12     return(ipAddr);
542                       }
543                       
544 kumpf            1.24 // check the value of each part of an IP address which should be
545 kumpf            1.12 // between 0 and 255
546                       Boolean snmpDeliverTrap_emanate::_isValidOctet(const Uint32& octetValue)
547                       {
548                           if (octetValue > 0 && octetValue < 255)
549                           {
550 kumpf            1.24         return true;
551 kumpf            1.3      }
552                           else
553                           {
554 kumpf            1.24         return false;
555 mike             1.2      }
556                       }
557                       
558                       PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2