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

  1 mike  1.2 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3           // Copyright (c) 2000, 2001 BMC Software, Hewlett Packard, IBM, The Open Group,
  4           // Tivoli Systems
  5           //
  6           // Permission is hereby granted, free of charge, to any person obtaining a copy
  7           // 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           // 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           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
 14           // 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           // 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           // 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 mike  1.2 //==============================================================================
 23           //
 24           // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
 25           //
 26           // Modified By:
 27           //
 28           //%/////////////////////////////////////////////////////////////////////////////
 29           
 30           #include <Pegasus/Common/Config.h>
 31           #include <iostream>
 32           #include <Pegasus/Handler/CIMHandler.h>
 33           #include <Pegasus/Repository/CIMRepository.h>
 34           
 35           #include "snmpIndicationHandler.h"
 36           
 37           #ifdef HPUX_EMANATE
 38           #include "snmpDeliverTrap_emanate.h"
 39           #else
 40           #include "snmpDeliverTrap_stub.h"
 41           #endif
 42           
 43 mike  1.2 PEGASUS_NAMESPACE_BEGIN
 44           
 45           PEGASUS_USING_STD;
 46           
 47           //#define DDD(X) X
 48           #define DDD(X) // X
 49           
 50           DDD(static const char* _SNMPINDICATIONHANDLER = "snmpIndicationHandler::";)
 51           
 52           void snmpIndicationHandler::initialize(CIMRepository* repository)
 53           {
 54               _repository = repository;
 55               DDD(cout << _SNMPINDICATIONHANDLER << "initialize()" << endl;)
 56           }
 57           
 58           void snmpIndicationHandler::handleIndication(CIMInstance& handlerInstance,
 59               CIMInstance& indicationInstance,
 60               String nameSpace)
 61           {
 62               String enterprise, trapOid, destination;
 63               Array<String> propOIDs;
 64 mike  1.2     Array<String> propTYPEs;
 65               Array<String> propVALUEs;
 66           
 67               CIMProperty prop;
 68           
 69               CIMClass indicationClass = _repository->getClass(
 70           	nameSpace, 
 71           	indicationInstance.getClassName(), 
 72           	false);
 73           
 74               Uint32 propPos = indicationClass.findProperty("enterprise");
 75               if (propPos != PEG_NOT_FOUND)
 76               {
 77                   CIMProperty trapProp = indicationClass.getProperty(propPos);
 78           
 79                   Uint32 qualifierPos = trapProp.findQualifier("MappingStrings");
 80                   if (qualifierPos != PEG_NOT_FOUND)
 81                   {
 82                       CIMQualifier trapQualifier = trapProp.getQualifier(qualifierPos);
 83                       // ATTN: Catch TypeMismatch exception on the next line
 84                       trapQualifier.getValue().get(enterprise);
 85 mike  1.2 
 86                       for (Uint32 i=0; i<indicationInstance.getPropertyCount();i++)
 87                       {
 88           	        char* property_oid = NULL;
 89           	        char* property_value = NULL;
 90           	        char* property_datatype = NULL;
 91                   
 92           	        prop = indicationInstance.getProperty(i);
 93           
 94           	        if (prop)
 95                           {
 96                               String propName = prop.getName();
 97                               Uint32 propPos = indicationClass.findProperty(propName);
 98                               CIMProperty trapProp = indicationClass.getProperty(propPos);
 99           
100                               if (trapProp.existsQualifier("MappingStrings"))
101                               {
102                                   if (propName == "trapOid")
103           		        {
104                                       // ATTN: Catch TypeMismatch exception on the next line
105           		            prop.getValue().get(trapOid);
106 mike  1.2 		        }
107           		        else
108           		        {
109           		            Uint32 qualifierPos = trapProp.findQualifier("MappingStrings");
110           			    CIMQualifier trapQualifier = trapProp.getQualifier(qualifierPos);
111           			
112           			    String mapstr1;
113                                       // ATTN: Catch TypeMismatch exception on the next line
114           			    trapQualifier.getValue().get(mapstr1);
115           			    String mapstr2 = "";
116           
117           			    if ((mapstr1.find("OID") != PEG_NOT_FOUND) &&
118           			        (mapstr1.find("SNMP") != PEG_NOT_FOUND))
119           			    {
120           			        if (mapstr1.subString(0, 4) == "OID.")
121           			        {
122           				    mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
123                                               if (mapstr1.find("|") != PEG_NOT_FOUND)
124                                               {
125           				        mapstr2 = mapstr1.subString(0, mapstr1.find("|"));
126           			    
127 mike  1.2 				        propOIDs.append(mapstr2);
128                                                   String propValue;
129                                                   // ATTN: Catch TypeMismatch exception on the next line
130                                                   prop.getValue().get(propValue);
131           				        propVALUEs.append(propValue);
132           				        propTYPEs.append(mapstr1.subString(mapstr1.find("|")+1));
133                                               }
134           			        }
135           			    }
136           		        }
137           		    }
138                           }
139                       }
140                   }
141           
142                   // Collected complete data in arrays and ready to send the trap.
143                   // trap destination and SNMP type are defined in handlerInstance
144                   // and passing this instance as it is to deliverTrap() call
145           
146           #ifdef HPUX_EMANATE
147                   snmpDeliverTrap_emanate emanateTrap;
148 mike  1.2 #else
149                   snmpDeliverTrap_stub emanateTrap;
150           #endif
151           
152                   if ((handlerInstance.findProperty("Destination") != PEG_NOT_FOUND) &&
153                       (handlerInstance.findProperty("trapType") != PEG_NOT_FOUND))
154                   {
155                       String destination;
156                       String trapType;
157                       // ATTN: Add error checking
158                       // ATTN: Catch TypeMismatch exception on the next line
159                       handlerInstance.getProperty(
160                           handlerInstance.findProperty("Destination"))
161                           .getValue().get(destination);
162                       // ATTN: Add error checking
163                       // ATTN: Catch TypeMismatch exception on the next line
164                       handlerInstance.getProperty(
165                           handlerInstance.findProperty("trapType"))
166                           .getValue().get(trapType);
167           
168                       emanateTrap.deliverTrap(trapOid, 
169 mike  1.2                 enterprise,
170                           destination,
171                           trapType,
172                           propOIDs,  
173                           propTYPEs, 
174                           propVALUEs);
175                   }
176               }
177               else
178                   throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
179                       "Indication is without enterprise OID");
180           }
181           
182           // This is the dynamic entry point into this dynamic module. The name of
183           // this handler is "snmpIndicationHandler" which is appened to "PegasusCreateHandler_"
184           // to form a symbol name. This function is called by the HandlerTable
185           // to load this handler.
186           
187           extern "C" PEGASUS_EXPORT CIMHandler* 
188               PegasusCreateHandler_snmpIndicationHandler() {
189               DDD(cout << "Called PegasusCreateHandler_snmpIndicationHandler" << endl;)
190 mike  1.2     return new snmpIndicationHandler;
191           }
192           
193           PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2