(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 kumpf 1.3 void snmpIndicationHandler::handleIndication(CIMInstance& handler, 
 59               CIMInstance& indication, String nameSpace)
 60 mike  1.2 {
 61               Array<String> propOIDs;
 62               Array<String> propTYPEs;
 63               Array<String> propVALUEs;
 64           
 65               CIMProperty prop;
 66 kumpf 1.3     CIMQualifier trapQualifier;
 67           
 68               Uint32 qualifierPos;
 69               
 70               String propValue;
 71           
 72               String mapstr1;
 73               String mapstr2;
 74 mike  1.2 
 75               CIMClass indicationClass = _repository->getClass(
 76 kumpf 1.3 	nameSpace, indication.getClassName(), false);
 77 mike  1.2 
 78 kumpf 1.3     for (Uint32 i=0; i<indication.getPropertyCount();i++)
 79 mike  1.2     {
 80 kumpf 1.3 	prop = indication.getProperty(i);
 81 mike  1.2 
 82 kumpf 1.3 	if (prop)
 83 mike  1.2         {
 84 kumpf 1.3             String propName = prop.getName();
 85                       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.3             if (trapProp.existsQualifier("MappingStrings"))
 91 mike  1.2             {
 92 kumpf 1.3 		qualifierPos = trapProp.findQualifier("MappingStrings");
 93           		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 kumpf 1.3 			    propVALUEs.append(propValue);
114                                       
115           			    mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
116 kumpf 1.4 			    propTYPEs.append(mapstr2);
117 kumpf 1.3                         }
118 mike  1.2 		    }
119 kumpf 1.3 		}
120           	    }
121 kumpf 1.4             }
122 mike  1.2         }
123 kumpf 1.3     }
124 mike  1.2 
125                   // Collected complete data in arrays and ready to send the trap.
126                   // trap destination and SNMP type are defined in handlerInstance
127                   // and passing this instance as it is to deliverTrap() call
128           
129           #ifdef HPUX_EMANATE
130                   snmpDeliverTrap_emanate emanateTrap;
131           #else
132                   snmpDeliverTrap_stub emanateTrap;
133           #endif
134           
135 kumpf 1.3     if ((handler.findProperty("TrapDestination") != PEG_NOT_FOUND) &&
136                   (handler.findProperty("SNMPVersion") != PEG_NOT_FOUND) && 
137                   (indication.findQualifier("TrapOid") != PEG_NOT_FOUND))
138               {
139                   String community, trapType, destination;   // from handler instance
140           	String trapOid;	    // from indication instance
141           
142           	trapOid = indication.getQualifier(
143           	    indication.findQualifier("TrapOid")).getValue().toString();
144           
145           	community = handler.getProperty(
146           	    handler.findProperty("SNMPCommunityName")).getValue().toString();
147           
148           	destination = handler.getProperty(
149           	    handler.findProperty("TrapDestination")).getValue().toString();
150           
151           	trapType = handler.getProperty(
152           	    handler.findProperty("SNMPVersion")).getValue().toString();
153           
154           	emanateTrap.deliverTrap(
155                       trapOid,
156 kumpf 1.3             community,
157                       destination,
158                       trapType,
159                       propOIDs,  
160                       propTYPEs, 
161                       propVALUEs);
162 mike  1.2     }
163           }
164           
165           // This is the dynamic entry point into this dynamic module. The name of
166           // this handler is "snmpIndicationHandler" which is appened to "PegasusCreateHandler_"
167           // to form a symbol name. This function is called by the HandlerTable
168           // to load this handler.
169           
170           extern "C" PEGASUS_EXPORT CIMHandler* 
171               PegasusCreateHandler_snmpIndicationHandler() {
172               DDD(cout << "Called PegasusCreateHandler_snmpIndicationHandler" << endl;)
173               return new snmpIndicationHandler;
174           }
175           
176           PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2