(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 <Pegasus/Common/Config.h>
 31 sage  1.1.2.5 #include <iostream>
 32 kumpf 1.1.2.1 #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               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 kumpf 1.1.2.1 {
 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 kumpf 1.1.2.3             // ATTN: Catch TypeMismatch exception on the next line
 84                           trapQualifier.getValue().get(enterprise);
 85 kumpf 1.1.2.2 
 86 mike  1.1.2.4             for (Uint32 i=0; i<indicationInstance.getPropertyCount();i++)
 87 kumpf 1.1.2.1             {
 88 kumpf 1.1.2.2 	        char* property_oid = NULL;
 89               	        char* property_value = NULL;
 90               	        char* property_datatype = NULL;
 91                       
 92               	        prop = indicationInstance.getProperty(i);
 93 kumpf 1.1.2.1 
 94 mike  1.1.2.4 	        if (prop)
 95 kumpf 1.1.2.1                 {
 96 kumpf 1.1.2.2                     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 kumpf 1.1.2.3                             // ATTN: Catch TypeMismatch exception on the next line
105               		            prop.getValue().get(trapOid);
106 kumpf 1.1.2.2 		        }
107               		        else
108               		        {
109               		            Uint32 qualifierPos = trapProp.findQualifier("MappingStrings");
110               			    CIMQualifier trapQualifier = trapProp.getQualifier(qualifierPos);
111               			
112 kumpf 1.1.2.3 			    String mapstr1;
113                                           // ATTN: Catch TypeMismatch exception on the next line
114               			    trapQualifier.getValue().get(mapstr1);
115 kumpf 1.1.2.2 			    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               				        propOIDs.append(mapstr2);
128 kumpf 1.1.2.3                                         String propValue;
129                                                       // ATTN: Catch TypeMismatch exception on the next line
130                                                       prop.getValue().get(propValue);
131               				        propVALUEs.append(propValue);
132 kumpf 1.1.2.2 				        propTYPEs.append(mapstr1.subString(mapstr1.find("|")+1));
133                                                   }
134               			        }
135               			    }
136               		        }
137 kumpf 1.1.2.1 		    }
138 kumpf 1.1.2.2                 }
139 kumpf 1.1.2.1             }
140                       }
141               
142 kumpf 1.1.2.2         // Collected complete data in arrays and ready to send the trap.
143 kumpf 1.1.2.1         // trap destination and SNMP type are defined in handlerInstance
144                       // and passing this instance as it is to deliverTrap() call
145 kumpf 1.1.2.2 
146 kumpf 1.1.2.1 #ifdef HPUX_EMANATE
147 kumpf 1.1.2.2         snmpDeliverTrap_emanate emanateTrap;
148 kumpf 1.1.2.1 #else
149 kumpf 1.1.2.2         snmpDeliverTrap_stub emanateTrap;
150 kumpf 1.1.2.1 #endif
151 kumpf 1.1.2.2 
152                       if ((handlerInstance.findProperty("Destination") != PEG_NOT_FOUND) &&
153                           (handlerInstance.findProperty("trapType") != PEG_NOT_FOUND))
154                       {
155 kumpf 1.1.2.3             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 kumpf 1.1.2.2             emanateTrap.deliverTrap(trapOid, 
169                               enterprise,
170 kumpf 1.1.2.3                 destination,
171                               trapType,
172 kumpf 1.1.2.2                 propOIDs,  
173                               propTYPEs, 
174                               propVALUEs);
175                       }
176 kumpf 1.1.2.1     }
177                   else
178 kumpf 1.1.2.2         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
179                           "Indication is without enterprise OID");
180 kumpf 1.1.2.1 }
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                   return new snmpIndicationHandler;
191               }
192               
193               PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2