(file) Return to snmpIndicationHandler.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Handler / snmpIndicationHandler

  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 mday  1.12.12.1 //	      : Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
 29 mike  1.2       //
 30                 //%/////////////////////////////////////////////////////////////////////////////
 31                 
 32                 #include <Pegasus/Common/Config.h>
 33 kumpf 1.7       #include <Pegasus/Common/PegasusVersion.h>
 34                 
 35 mike  1.2       #include <iostream>
 36                 #include <Pegasus/Handler/CIMHandler.h>
 37                 #include <Pegasus/Repository/CIMRepository.h>
 38                 
 39                 #include "snmpIndicationHandler.h"
 40                 
 41                 #ifdef HPUX_EMANATE
 42                 #include "snmpDeliverTrap_emanate.h"
 43                 #else
 44                 #include "snmpDeliverTrap_stub.h"
 45                 #endif
 46                 
 47                 PEGASUS_NAMESPACE_BEGIN
 48                 
 49                 PEGASUS_USING_STD;
 50                 
 51                 void snmpIndicationHandler::initialize(CIMRepository* repository)
 52                 {
 53                     _repository = repository;
 54                 }
 55                 
 56 mday  1.12.12.1 // l10n - note: ignoring indication language
 57 kumpf 1.3       void snmpIndicationHandler::handleIndication(CIMInstance& handler, 
 58 mday  1.12.12.1     CIMInstance& indication, String nameSpace,
 59                     ContentLanguages & contentLanguages)
 60 mike  1.2       {
 61                     Array<String> propOIDs;
 62                     Array<String> propTYPEs;
 63                     Array<String> propVALUEs;
 64                 
 65                     CIMProperty prop;
 66 kumpf 1.3           CIMQualifier trapQualifier;
 67                 
 68                     Uint32 qualifierPos;
 69                     
 70                     String propValue;
 71                 
 72                     String mapstr1;
 73                     String mapstr2;
 74 mike  1.2       
 75                     CIMClass indicationClass = _repository->getClass(
 76 kumpf 1.3       	nameSpace, indication.getClassName(), false);
 77 mike  1.2       
 78 mday  1.12.12.1     Uint32 propertyCount = indication.getPropertyCount();
 79                 
 80                     for (Uint32 i=0; i < propertyCount; i++)
 81 mike  1.2           {
 82 kumpf 1.3       	prop = indication.getProperty(i);
 83 mike  1.2       
 84 kumpf 1.11      	if (!prop.isUninitialized())
 85 mike  1.2               {
 86 kumpf 1.12                  CIMName propName = prop.getName();
 87 kumpf 1.3                   Uint32 propPos = indicationClass.findProperty(propName);
 88 kumpf 1.4                   if (propPos != PEG_NOT_FOUND)
 89                             {
 90 kumpf 1.3                   CIMProperty trapProp = indicationClass.getProperty(propPos);
 91 mike  1.2       
 92 kumpf 1.12                  qualifierPos = trapProp.findQualifier(CIMName ("MappingStrings"));
 93 kumpf 1.10                  if (qualifierPos != PEG_NOT_FOUND)
 94 mike  1.2                   {
 95 kumpf 1.3       		trapQualifier = trapProp.getQualifier(qualifierPos);
 96                 		
 97                 		mapstr1.clear();
 98                 		mapstr1 = trapQualifier.getValue().toString();
 99                 
100                 		if ((mapstr1.find("OID.IETF") != PEG_NOT_FOUND) &&
101                 		    (mapstr1.find("DataType.IETF") != PEG_NOT_FOUND))
102                 		{
103                 		    if (mapstr1.subString(0, 8) == "OID.IETF")
104                 		    {
105                 			mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
106                                         if (mapstr1.find("|") != PEG_NOT_FOUND)
107                                         {
108                 			    mapstr2.clear();
109                 			    mapstr2 = mapstr1.subString(0, 
110                 				mapstr1.find("DataType.IETF")-1);
111                 			    propOIDs.append(mapstr2);
112                                             
113                 			    propValue.clear();
114                                             propValue = prop.getValue().toString();
115                 			    propVALUEs.append(propValue);
116 kumpf 1.3                                   
117                 			    mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
118 kumpf 1.6                                   mapstr2 = mapstr2.subString(0, mapstr2.size()-1);
119 kumpf 1.4       			    propTYPEs.append(mapstr2);
120 kumpf 1.3                               }
121 mike  1.2       		    }
122 kumpf 1.3       		}
123                 	    }
124 kumpf 1.4                   }
125 mike  1.2               }
126 kumpf 1.3           }
127 mike  1.2       
128                         // Collected complete data in arrays and ready to send the trap.
129                         // trap destination and SNMP type are defined in handlerInstance
130                         // and passing this instance as it is to deliverTrap() call
131                 
132                 #ifdef HPUX_EMANATE
133                         snmpDeliverTrap_emanate emanateTrap;
134                 #else
135                         snmpDeliverTrap_stub emanateTrap;
136                 #endif
137                 
138 mday  1.12.12.1     Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));
139                     Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat"));
140                     Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName (
141                 				      "OtherTargetHostFormat"));
142                     Uint32 portNumberPos = handler.findProperty(CIMName ("PortNumber"));
143                     Uint32 snmpVersionPos = handler.findProperty(CIMName ("SNMPVersion"));
144                     Uint32 securityNamePos =  handler.findProperty(CIMName ("SNMPSecurityName"));
145                     Uint32 engineIDPos =  handler.findProperty(CIMName ("SNMPEngineID"));
146                 
147                     if ((targetHostPos != PEG_NOT_FOUND) &&
148                         (targetHostFormatPos != PEG_NOT_FOUND) && 
149                         (snmpVersionPos != PEG_NOT_FOUND) && 
150 kumpf 1.12              (indicationClass.findQualifier(CIMName ("MappingStrings")) != 
151                             PEG_NOT_FOUND))
152 kumpf 1.3           {
153 mday  1.12.12.1 	// properties from the handler instance
154                         String targetHost, otherTargetHostFormat;
155                 	String securityName, engineID;
156                 	Uint16 targetHostFormat, snmpVersion;
157                 	Uint32 portNumber;
158 kumpf 1.3       
159 mday  1.12.12.1 	// trapOid from indication Class
160                 
161                 	String trapOid = indicationClass.getQualifier(
162                             indicationClass.findQualifier
163 kumpf 1.12                      (CIMName ("MappingStrings"))).getValue().toString();
164 kumpf 1.5       
165 mday  1.12.12.1 	Uint32 index = trapOid.find("SNMP.");
166 kumpf 1.3       
167 mday  1.12.12.1 	if (index != PEG_NOT_FOUND)
168                 	{
169                 	    trapOid = trapOid.subString(index+5);
170                 	    trapOid = trapOid.subString(0, (trapOid.size()-1));
171                 	}
172                 	else
173                 	{
174                 	    throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Invalid MappingStrings Value");
175                 	}
176                 
177                 	handler.getProperty(targetHostPos).getValue().get(targetHost);
178                 	handler.getProperty(targetHostFormatPos).getValue().get(targetHostFormat);
179                 	handler.getProperty(otherTargetHostFormatPos).getValue().get
180                 		(otherTargetHostFormat);
181                 	handler.getProperty(portNumberPos).getValue().get(portNumber);
182                 	handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);
183                 	handler.getProperty(securityNamePos).getValue().get(securityName);
184                 	handler.getProperty(engineIDPos).getValue().get(engineID);
185 kumpf 1.3       
186                 	emanateTrap.deliverTrap(
187                             trapOid,
188 mday  1.12.12.1             securityName,
189                             targetHost,
190                             targetHostFormat,
191                 	    otherTargetHostFormat,
192                 	    portNumber,
193                 	    snmpVersion,
194                 	    engineID,
195 kumpf 1.3                   propOIDs,  
196                             propTYPEs, 
197                             propVALUEs);
198 mike  1.2           }
199 kumpf 1.5           else
200 mday  1.12.12.1     {
201                         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, 
202                 		"Invalid IndicationHandlerSNMPMapper instance");
203                     }
204 mike  1.2       }
205                 
206                 // This is the dynamic entry point into this dynamic module. The name of
207 mday  1.12.12.1 // this handler is "snmpIndicationHandler" which is appended to "PegasusCreateHandler_"
208 mike  1.2       // to form a symbol name. This function is called by the HandlerTable
209                 // to load this handler.
210                 
211                 extern "C" PEGASUS_EXPORT CIMHandler* 
212                     PegasusCreateHandler_snmpIndicationHandler() {
213                     return new snmpIndicationHandler;
214                 }
215                 
216                 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2