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