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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2