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