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