(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 kumpf 1.13 //	      : 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 humberto 1.15 // l10n
 48               #include <Pegasus/Common/MessageLoader.h>
 49               
 50 mike     1.2  PEGASUS_NAMESPACE_BEGIN
 51               
 52               PEGASUS_USING_STD;
 53               
 54               void snmpIndicationHandler::initialize(CIMRepository* repository)
 55               {
 56                   _repository = repository;
 57               }
 58               
 59 chuck    1.14 // l10n - note: ignoring indication language
 60 kumpf    1.3  void snmpIndicationHandler::handleIndication(CIMInstance& handler, 
 61 chuck    1.14     CIMInstance& indication, String nameSpace,
 62                   ContentLanguages & contentLanguages)
 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.13     Uint32 propertyCount = indication.getPropertyCount();
 82               
 83                   for (Uint32 i=0; i < propertyCount; i++)
 84 mike     1.2      {
 85 kumpf    1.3  	prop = indication.getProperty(i);
 86 mike     1.2  
 87 kumpf    1.11 	if (!prop.isUninitialized())
 88 mike     1.2          {
 89 kumpf    1.12             CIMName propName = prop.getName();
 90 kumpf    1.3              Uint32 propPos = indicationClass.findProperty(propName);
 91 kumpf    1.4              if (propPos != PEG_NOT_FOUND)
 92                           {
 93 kumpf    1.3              CIMProperty trapProp = indicationClass.getProperty(propPos);
 94 mike     1.2  
 95 kumpf    1.12             qualifierPos = trapProp.findQualifier(CIMName ("MappingStrings"));
 96 kumpf    1.10             if (qualifierPos != PEG_NOT_FOUND)
 97 mike     1.2              {
 98 kumpf    1.3  		trapQualifier = trapProp.getQualifier(qualifierPos);
 99               		
100               		mapstr1.clear();
101               		mapstr1 = trapQualifier.getValue().toString();
102               
103               		if ((mapstr1.find("OID.IETF") != PEG_NOT_FOUND) &&
104               		    (mapstr1.find("DataType.IETF") != PEG_NOT_FOUND))
105               		{
106               		    if (mapstr1.subString(0, 8) == "OID.IETF")
107               		    {
108               			mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
109                                       if (mapstr1.find("|") != PEG_NOT_FOUND)
110                                       {
111               			    mapstr2.clear();
112               			    mapstr2 = mapstr1.subString(0, 
113               				mapstr1.find("DataType.IETF")-1);
114               			    propOIDs.append(mapstr2);
115                                           
116               			    propValue.clear();
117                                           propValue = prop.getValue().toString();
118               			    propVALUEs.append(propValue);
119 kumpf    1.3                              
120               			    mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
121 kumpf    1.6                              mapstr2 = mapstr2.subString(0, mapstr2.size()-1);
122 kumpf    1.4  			    propTYPEs.append(mapstr2);
123 kumpf    1.3                          }
124 mike     1.2  		    }
125 kumpf    1.3  		}
126               	    }
127 kumpf    1.4              }
128 mike     1.2          }
129 kumpf    1.3      }
130 mike     1.2  
131                       // Collected complete data in arrays and ready to send the trap.
132                       // trap destination and SNMP type are defined in handlerInstance
133                       // and passing this instance as it is to deliverTrap() call
134               
135               #ifdef HPUX_EMANATE
136                       snmpDeliverTrap_emanate emanateTrap;
137               #else
138                       snmpDeliverTrap_stub emanateTrap;
139               #endif
140               
141 kumpf    1.13     Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));
142                   Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat"));
143                   Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName (
144               				      "OtherTargetHostFormat"));
145                   Uint32 portNumberPos = handler.findProperty(CIMName ("PortNumber"));
146                   Uint32 snmpVersionPos = handler.findProperty(CIMName ("SNMPVersion"));
147                   Uint32 securityNamePos =  handler.findProperty(CIMName ("SNMPSecurityName"));
148                   Uint32 engineIDPos =  handler.findProperty(CIMName ("SNMPEngineID"));
149               
150                   if ((targetHostPos != PEG_NOT_FOUND) &&
151                       (targetHostFormatPos != PEG_NOT_FOUND) && 
152                       (snmpVersionPos != PEG_NOT_FOUND) && 
153 kumpf    1.12         (indicationClass.findQualifier(CIMName ("MappingStrings")) != 
154                           PEG_NOT_FOUND))
155 kumpf    1.3      {
156 kumpf    1.13 	// properties from the handler instance
157                       String targetHost, otherTargetHostFormat;
158               	String securityName, engineID;
159               	Uint16 targetHostFormat, snmpVersion;
160               	Uint32 portNumber;
161 kumpf    1.3  
162 kumpf    1.13 	// trapOid from indication Class
163               
164               	String trapOid = indicationClass.getQualifier(
165                           indicationClass.findQualifier
166 kumpf    1.12                 (CIMName ("MappingStrings"))).getValue().toString();
167 kumpf    1.5  
168 kumpf    1.13 	Uint32 index = trapOid.find("SNMP.");
169 kumpf    1.3  
170 kumpf    1.13 	if (index != PEG_NOT_FOUND)
171               	{
172               	    trapOid = trapOid.subString(index+5);
173               	    trapOid = trapOid.subString(0, (trapOid.size()-1));
174               	}
175               	else
176               	{
177 humberto 1.15 	  // l10n
178               
179               	  // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Invalid MappingStrings Value");
180               
181               	  throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, 
182               					 MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.INVALID_VALUE", 
183               							    "Invalid $0 Value", "MappingStrings"));
184 kumpf    1.13 	}
185               
186               	handler.getProperty(targetHostPos).getValue().get(targetHost);
187               	handler.getProperty(targetHostFormatPos).getValue().get(targetHostFormat);
188               	handler.getProperty(otherTargetHostFormatPos).getValue().get
189               		(otherTargetHostFormat);
190               	handler.getProperty(portNumberPos).getValue().get(portNumber);
191               	handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);
192               	handler.getProperty(securityNamePos).getValue().get(securityName);
193               	handler.getProperty(engineIDPos).getValue().get(engineID);
194 kumpf    1.3  
195               	emanateTrap.deliverTrap(
196                           trapOid,
197 kumpf    1.13             securityName,
198                           targetHost,
199                           targetHostFormat,
200               	    otherTargetHostFormat,
201               	    portNumber,
202               	    snmpVersion,
203               	    engineID,
204 kumpf    1.3              propOIDs,  
205                           propTYPEs, 
206                           propVALUEs);
207 mike     1.2      }
208 kumpf    1.5      else
209 kumpf    1.13     {
210 humberto 1.15 
211                     // l10n
212               
213                     // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, 
214                     // "Invalid IndicationHandlerSNMPMapper instance");
215               
216                     throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, 
217               				     MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.INVALID_INSTANCE", 
218               							"Invalid $0 instance", "IndicationHandlerSNMPMapper"));
219 kumpf    1.13     }
220 mike     1.2  }
221               
222               // This is the dynamic entry point into this dynamic module. The name of
223 kumpf    1.13 // this handler is "snmpIndicationHandler" which is appended to "PegasusCreateHandler_"
224 mike     1.2  // to form a symbol name. This function is called by the HandlerTable
225               // to load this handler.
226               
227               extern "C" PEGASUS_EXPORT CIMHandler* 
228                   PegasusCreateHandler_snmpIndicationHandler() {
229                   return new snmpIndicationHandler;
230               }
231               
232               PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2