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