1 mike 1.2 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 kumpf 1.9 // 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.9 // 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.9 // 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.9 // 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 kumpf 1.10 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
27 // (carolann_graves@hp.com)
|
28 mike 1.2 //
29 //%/////////////////////////////////////////////////////////////////////////////
30
31 #include <Pegasus/Common/Config.h>
|
32 kumpf 1.7 #include <Pegasus/Common/PegasusVersion.h>
33
|
34 mike 1.2 #include <iostream>
35 #include <Pegasus/Handler/CIMHandler.h>
36 #include <Pegasus/Repository/CIMRepository.h>
37
38 #include "snmpIndicationHandler.h"
39
40 #ifdef HPUX_EMANATE
41 #include "snmpDeliverTrap_emanate.h"
42 #else
43 #include "snmpDeliverTrap_stub.h"
44 #endif
45
46 PEGASUS_NAMESPACE_BEGIN
47
48 PEGASUS_USING_STD;
49
50 //#define DDD(X) X
51 #define DDD(X) // X
52
53 DDD(static const char* _SNMPINDICATIONHANDLER = "snmpIndicationHandler::";)
54
55 mike 1.2 void snmpIndicationHandler::initialize(CIMRepository* repository)
56 {
57 _repository = repository;
58 DDD(cout << _SNMPINDICATIONHANDLER << "initialize()" << endl;)
59 }
60
|
61 kumpf 1.3 void snmpIndicationHandler::handleIndication(CIMInstance& handler,
62 CIMInstance& indication, String nameSpace)
|
63 mike 1.2 {
64 Array<String> propOIDs;
65 Array<String> propTYPEs;
66 Array<String> propVALUEs;
67
68 CIMProperty prop;
|
69 kumpf 1.3 CIMQualifier trapQualifier;
70
71 Uint32 qualifierPos;
72
73 String propValue;
74
75 String mapstr1;
76 String mapstr2;
|
77 mike 1.2
78 CIMClass indicationClass = _repository->getClass(
|
79 kumpf 1.3 nameSpace, indication.getClassName(), false);
|
80 mike 1.2
|
81 kumpf 1.3 for (Uint32 i=0; i<indication.getPropertyCount();i++)
|
82 mike 1.2 {
|
83 kumpf 1.3 prop = indication.getProperty(i);
|
84 mike 1.2
|
85 kumpf 1.8 if (!prop.isNull())
|
86 mike 1.2 {
|
87 kumpf 1.3 String propName = prop.getName();
88 Uint32 propPos = indicationClass.findProperty(propName);
|
89 kumpf 1.4 if (propPos != PEG_NOT_FOUND)
90 {
|
91 kumpf 1.3 CIMProperty trapProp = indicationClass.getProperty(propPos);
|
92 mike 1.2
|
93 kumpf 1.10 qualifierPos = trapProp.findQualifier("MappingStrings");
94 if (qualifierPos != PEG_NOT_FOUND)
|
95 mike 1.2 {
|
96 kumpf 1.3 trapQualifier = trapProp.getQualifier(qualifierPos);
97
98 mapstr1.clear();
99 mapstr1 = trapQualifier.getValue().toString();
100
101 if ((mapstr1.find("OID.IETF") != PEG_NOT_FOUND) &&
102 (mapstr1.find("DataType.IETF") != PEG_NOT_FOUND))
103 {
104 if (mapstr1.subString(0, 8) == "OID.IETF")
105 {
106 mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
107 if (mapstr1.find("|") != PEG_NOT_FOUND)
108 {
109 mapstr2.clear();
110 mapstr2 = mapstr1.subString(0,
111 mapstr1.find("DataType.IETF")-1);
112 propOIDs.append(mapstr2);
113
114 propValue.clear();
115 propValue = prop.getValue().toString();
116 propVALUEs.append(propValue);
117 kumpf 1.3
118 mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
|
119 kumpf 1.6 mapstr2 = mapstr2.subString(0, mapstr2.size()-1);
|
120 kumpf 1.4 propTYPEs.append(mapstr2);
|
121 kumpf 1.3 }
|
122 mike 1.2 }
|
123 kumpf 1.3 }
124 }
|
125 kumpf 1.4 }
|
126 mike 1.2 }
|
127 kumpf 1.3 }
|
128 mike 1.2
129 // Collected complete data in arrays and ready to send the trap.
130 // trap destination and SNMP type are defined in handlerInstance
131 // and passing this instance as it is to deliverTrap() call
132
133 #ifdef HPUX_EMANATE
134 snmpDeliverTrap_emanate emanateTrap;
135 #else
136 snmpDeliverTrap_stub emanateTrap;
137 #endif
138
|
139 kumpf 1.3 if ((handler.findProperty("TrapDestination") != PEG_NOT_FOUND) &&
140 (handler.findProperty("SNMPVersion") != PEG_NOT_FOUND) &&
|
141 kumpf 1.5 (indicationClass.findQualifier("MappingStrings") != PEG_NOT_FOUND))
|
142 kumpf 1.3 {
143 String community, trapType, destination; // from handler instance
|
144 kumpf 1.5 String trapOid; // from indication Class
|
145 kumpf 1.3
|
146 kumpf 1.5 trapOid = indicationClass.getQualifier(
147 indicationClass.findQualifier("MappingStrings")).getValue().toString();
148
149 trapOid = trapOid.subString(trapOid.find("OID.IETF | SNMP.")+16);
|
150 kumpf 1.3
151 community = handler.getProperty(
152 handler.findProperty("SNMPCommunityName")).getValue().toString();
153
154 destination = handler.getProperty(
155 handler.findProperty("TrapDestination")).getValue().toString();
156
157 trapType = handler.getProperty(
158 handler.findProperty("SNMPVersion")).getValue().toString();
159
160 emanateTrap.deliverTrap(
161 trapOid,
162 community,
163 destination,
164 trapType,
165 propOIDs,
166 propTYPEs,
167 propVALUEs);
|
168 mike 1.2 }
|
169 kumpf 1.5 else
170 cout << "Invalid Indication" << endl;
|
171 mike 1.2 }
172
173 // This is the dynamic entry point into this dynamic module. The name of
174 // this handler is "snmpIndicationHandler" which is appened to "PegasusCreateHandler_"
175 // to form a symbol name. This function is called by the HandlerTable
176 // to load this handler.
177
178 extern "C" PEGASUS_EXPORT CIMHandler*
179 PegasusCreateHandler_snmpIndicationHandler() {
180 DDD(cout << "Called PegasusCreateHandler_snmpIndicationHandler" << endl;)
181 return new snmpIndicationHandler;
182 }
183
184 PEGASUS_NAMESPACE_END
|