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

  1 kumpf 1.1.2.1 //%/////////////////////////////////////////////////////////////////////////////
  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 kumpf 1.1.2.1 //==============================================================================
 23               //
 24               // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
 25               //
 26               // Modified By:
 27               //
 28               //%/////////////////////////////////////////////////////////////////////////////
 29               
 30               #include <iostream>
 31               #include <Pegasus/Common/Config.h>
 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 kumpf 1.1.2.1 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 kumpf 1.1.2.2     String enterprise, trapOid, destination;
 63 kumpf 1.1.2.1     Array<String> propOIDs;
 64                   Array<String> propTYPEs;
 65                   Array<String> propVALUEs;
 66               
 67 kumpf 1.1.2.2     CIMProperty prop;
 68 kumpf 1.1.2.1 
 69                   CIMClass indicationClass = _repository->getClass(
 70               	nameSpace, 
 71               	indicationInstance.getClassName(), 
 72               	false);
 73               
 74 kumpf 1.1.2.2     Uint32 propPos = indicationClass.findProperty("enterprise");
 75 kumpf 1.1.2.1     if (propPos != PEG_NOT_FOUND)
 76                   {
 77 kumpf 1.1.2.2         CIMProperty trapProp = indicationClass.getProperty(propPos);
 78 kumpf 1.1.2.1 
 79 kumpf 1.1.2.2         Uint32 qualifierPos = trapProp.findQualifier("MappingStrings");
 80                       if (qualifierPos != PEG_NOT_FOUND)
 81 kumpf 1.1.2.1         {
 82 kumpf 1.1.2.2             CIMQualifier trapQualifier = trapProp.getQualifier(qualifierPos);
 83                           enterprise = trapQualifier.getValue().toString();
 84               
 85                           for (int i=0; i<indicationInstance.getPropertyCount();i++)
 86 kumpf 1.1.2.1             {
 87 kumpf 1.1.2.2 	        char* property_oid = NULL;
 88               	        char* property_value = NULL;
 89               	        char* property_datatype = NULL;
 90                       
 91               	        prop = indicationInstance.getProperty(i);
 92 kumpf 1.1.2.1 
 93 kumpf 1.1.2.2 	        if (prop != NULL)
 94 kumpf 1.1.2.1                 {
 95 kumpf 1.1.2.2                     String propName = prop.getName();
 96                                   Uint32 propPos = indicationClass.findProperty(propName);
 97                                   CIMProperty trapProp = indicationClass.getProperty(propPos);
 98               
 99                                   if (trapProp.existsQualifier("MappingStrings"))
100                                   {
101                                       if (propName == "trapOid")
102               		        {
103               		            trapOid = prop.getValue().toString();
104               		        }
105               		        else
106               		        {
107               		            Uint32 qualifierPos = trapProp.findQualifier("MappingStrings");
108               			    CIMQualifier trapQualifier = trapProp.getQualifier(qualifierPos);
109               			
110               			    String mapstr1 = trapQualifier.getValue().toString();
111               			    String mapstr2 = "";
112               
113               			    if ((mapstr1.find("OID") != PEG_NOT_FOUND) &&
114               			        (mapstr1.find("SNMP") != PEG_NOT_FOUND))
115               			    {
116 kumpf 1.1.2.2 			        if (mapstr1.subString(0, 4) == "OID.")
117               			        {
118               				    mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
119                                                   if (mapstr1.find("|") != PEG_NOT_FOUND)
120                                                   {
121               				        mapstr2 = mapstr1.subString(0, mapstr1.find("|"));
122               			    
123               				        propOIDs.append(mapstr2);
124               				        propVALUEs.append(prop.getValue().toString());
125               				        propTYPEs.append(mapstr1.subString(mapstr1.find("|")+1));
126                                                   }
127               			        }
128               			    }
129               		        }
130 kumpf 1.1.2.1 		    }
131 kumpf 1.1.2.2                 }
132 kumpf 1.1.2.1             }
133                       }
134               
135 kumpf 1.1.2.2         // Collected complete data in arrays and ready to send the trap.
136 kumpf 1.1.2.1         // trap destination and SNMP type are defined in handlerInstance
137                       // and passing this instance as it is to deliverTrap() call
138 kumpf 1.1.2.2 
139 kumpf 1.1.2.1 #ifdef HPUX_EMANATE
140 kumpf 1.1.2.2         snmpDeliverTrap_emanate emanateTrap;
141 kumpf 1.1.2.1 #else
142 kumpf 1.1.2.2         snmpDeliverTrap_stub emanateTrap;
143 kumpf 1.1.2.1 #endif
144 kumpf 1.1.2.2 
145                       if ((handlerInstance.findProperty("Destination") != PEG_NOT_FOUND) &&
146                           (handlerInstance.findProperty("trapType") != PEG_NOT_FOUND))
147                       {
148                           emanateTrap.deliverTrap(trapOid, 
149                               enterprise,
150                               handlerInstance.getProperty(handlerInstance.findProperty("Destination"))
151                                   .getValue().toString(),
152                               handlerInstance.getProperty(handlerInstance.findProperty("trapType"))
153                                   .getValue().toString(), 
154                               propOIDs,  
155                               propTYPEs, 
156                               propVALUEs);
157                       }
158 kumpf 1.1.2.1     }
159                   else
160 kumpf 1.1.2.2         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
161                           "Indication is without enterprise OID");
162 kumpf 1.1.2.1 }
163               
164               // This is the dynamic entry point into this dynamic module. The name of
165               // this handler is "snmpIndicationHandler" which is appened to "PegasusCreateHandler_"
166               // to form a symbol name. This function is called by the HandlerTable
167               // to load this handler.
168               
169               extern "C" PEGASUS_EXPORT CIMHandler* 
170                   PegasusCreateHandler_snmpIndicationHandler() {
171                   DDD(cout << "Called PegasusCreateHandler_snmpIndicationHandler" << endl;)
172                   return new snmpIndicationHandler;
173               }
174               
175               PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2