(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 mike  1.2  //
 29            //%/////////////////////////////////////////////////////////////////////////////
 30            
 31            #include <Pegasus/Common/Config.h>
 32 kumpf 1.7  #include <Pegasus/Common/PegasusVersion.h>
 33            
 34 mike  1.2  #include <iostream>
 35            #include <Pegasus/Handler/CIMHandler.h>
 36            #include <Pegasus/Repository/CIMRepository.h>
 37            
 38            #include "snmpIndicationHandler.h"
 39            
 40            #ifdef HPUX_EMANATE
 41            #include "snmpDeliverTrap_emanate.h"
 42            #else
 43            #include "snmpDeliverTrap_stub.h"
 44            #endif
 45            
 46            PEGASUS_NAMESPACE_BEGIN
 47            
 48            PEGASUS_USING_STD;
 49            
 50            //#define DDD(X) X
 51            #define DDD(X) // X
 52            
 53            DDD(static const char* _SNMPINDICATIONHANDLER = "snmpIndicationHandler::";)
 54            
 55 mike  1.2  void snmpIndicationHandler::initialize(CIMRepository* repository)
 56            {
 57                _repository = repository;
 58                DDD(cout << _SNMPINDICATIONHANDLER << "initialize()" << endl;)
 59            }
 60            
 61 kumpf 1.3  void snmpIndicationHandler::handleIndication(CIMInstance& handler, 
 62                CIMInstance& indication, String nameSpace)
 63 mike  1.2  {
 64                Array<String> propOIDs;
 65                Array<String> propTYPEs;
 66                Array<String> propVALUEs;
 67            
 68                CIMProperty prop;
 69 kumpf 1.3      CIMQualifier trapQualifier;
 70            
 71                Uint32 qualifierPos;
 72                
 73                String propValue;
 74            
 75                String mapstr1;
 76                String mapstr2;
 77 mike  1.2  
 78                CIMClass indicationClass = _repository->getClass(
 79 kumpf 1.3  	nameSpace, indication.getClassName(), false);
 80 mike  1.2  
 81 kumpf 1.3      for (Uint32 i=0; i<indication.getPropertyCount();i++)
 82 mike  1.2      {
 83 kumpf 1.3  	prop = indication.getProperty(i);
 84 mike  1.2  
 85 kumpf 1.11 	if (!prop.isUninitialized())
 86 mike  1.2          {
 87 kumpf 1.12             CIMName propName = prop.getName();
 88 kumpf 1.3              Uint32 propPos = indicationClass.findProperty(propName);
 89 kumpf 1.4              if (propPos != PEG_NOT_FOUND)
 90                        {
 91 kumpf 1.3              CIMProperty trapProp = indicationClass.getProperty(propPos);
 92 mike  1.2  
 93 kumpf 1.12             qualifierPos = trapProp.findQualifier(CIMName ("MappingStrings"));
 94 kumpf 1.10             if (qualifierPos != PEG_NOT_FOUND)
 95 mike  1.2              {
 96 kumpf 1.3  		trapQualifier = trapProp.getQualifier(qualifierPos);
 97            		
 98            		mapstr1.clear();
 99            		mapstr1 = trapQualifier.getValue().toString();
100            
101            		if ((mapstr1.find("OID.IETF") != PEG_NOT_FOUND) &&
102            		    (mapstr1.find("DataType.IETF") != PEG_NOT_FOUND))
103            		{
104            		    if (mapstr1.subString(0, 8) == "OID.IETF")
105            		    {
106            			mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
107                                    if (mapstr1.find("|") != PEG_NOT_FOUND)
108                                    {
109            			    mapstr2.clear();
110            			    mapstr2 = mapstr1.subString(0, 
111            				mapstr1.find("DataType.IETF")-1);
112            			    propOIDs.append(mapstr2);
113                                        
114            			    propValue.clear();
115                                        propValue = prop.getValue().toString();
116            			    propVALUEs.append(propValue);
117 kumpf 1.3                              
118            			    mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
119 kumpf 1.6                              mapstr2 = mapstr2.subString(0, mapstr2.size()-1);
120 kumpf 1.4  			    propTYPEs.append(mapstr2);
121 kumpf 1.3                          }
122 mike  1.2  		    }
123 kumpf 1.3  		}
124            	    }
125 kumpf 1.4              }
126 mike  1.2          }
127 kumpf 1.3      }
128 mike  1.2  
129                    // Collected complete data in arrays and ready to send the trap.
130                    // trap destination and SNMP type are defined in handlerInstance
131                    // and passing this instance as it is to deliverTrap() call
132            
133            #ifdef HPUX_EMANATE
134                    snmpDeliverTrap_emanate emanateTrap;
135            #else
136                    snmpDeliverTrap_stub emanateTrap;
137            #endif
138            
139 kumpf 1.12     if ((handler.findProperty(CIMName ("TrapDestination")) != PEG_NOT_FOUND) &&
140                    (handler.findProperty(CIMName ("SNMPVersion")) != PEG_NOT_FOUND) && 
141                    (indicationClass.findQualifier(CIMName ("MappingStrings")) != 
142                        PEG_NOT_FOUND))
143 kumpf 1.3      {
144                    String community, trapType, destination;   // from handler instance
145 kumpf 1.5  	String trapOid;	    // from indication Class
146 kumpf 1.3  
147 kumpf 1.5  	trapOid = indicationClass.getQualifier(
148 kumpf 1.12 	    indicationClass.findQualifier
149                            (CIMName ("MappingStrings"))).getValue().toString();
150 kumpf 1.5  
151                    trapOid = trapOid.subString(trapOid.find("OID.IETF | SNMP.")+16);
152 kumpf 1.3  
153            	community = handler.getProperty(
154 kumpf 1.12 	    handler.findProperty
155                            (CIMName ("SNMPCommunityName"))).getValue().toString();
156 kumpf 1.3  
157            	destination = handler.getProperty(
158 kumpf 1.12 	    handler.findProperty
159                            (CIMName ("TrapDestination"))).getValue().toString();
160 kumpf 1.3  
161            	trapType = handler.getProperty(
162 kumpf 1.12 	    handler.findProperty
163                            (CIMName ("SNMPVersion"))).getValue().toString();
164 kumpf 1.3  
165            	emanateTrap.deliverTrap(
166                        trapOid,
167                        community,
168                        destination,
169                        trapType,
170                        propOIDs,  
171                        propTYPEs, 
172                        propVALUEs);
173 mike  1.2      }
174 kumpf 1.5      else
175                    cout << "Invalid Indication" << endl;
176 mike  1.2  }
177            
178            // This is the dynamic entry point into this dynamic module. The name of
179            // this handler is "snmpIndicationHandler" which is appened to "PegasusCreateHandler_"
180            // to form a symbol name. This function is called by the HandlerTable
181            // to load this handler.
182            
183            extern "C" PEGASUS_EXPORT CIMHandler* 
184                PegasusCreateHandler_snmpIndicationHandler() {
185                DDD(cout << "Called PegasusCreateHandler_snmpIndicationHandler" << endl;)
186                return new snmpIndicationHandler;
187            }
188            
189            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2