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