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

  1 martin 1.40 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.41 //
  3 martin 1.40 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.41 //
 10 martin 1.40 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.41 //
 17 martin 1.40 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.41 //
 20 martin 1.40 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.41 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.40 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.41 //
 28 martin 1.40 //////////////////////////////////////////////////////////////////////////
 29 mike   1.2  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #include <Pegasus/Common/Config.h>
 33 kumpf  1.7  #include <Pegasus/Common/PegasusVersion.h>
 34             
 35 mike   1.2  #include <iostream>
 36             #include <Pegasus/Handler/CIMHandler.h>
 37             #include <Pegasus/Repository/CIMRepository.h>
 38 kumpf  1.23 #include <Pegasus/Common/Tracer.h>
 39 mike   1.2  
 40             #include "snmpIndicationHandler.h"
 41             
 42             #ifdef HPUX_EMANATE
 43 kumpf  1.34 # include "snmpDeliverTrap_emanate.h"
 44 yi.zhou 1.27 #elif defined (PEGASUS_USE_NET_SNMP)
 45 kumpf   1.34 # include "snmpDeliverTrap_netsnmp.h"
 46 mike    1.2  #else
 47 kumpf   1.34 # include "snmpDeliverTrap_stub.h"
 48 mike    1.2  #endif
 49              
 50 humberto 1.15 #include <Pegasus/Common/MessageLoader.h>
 51               
 52 kumpf    1.32 PEGASUS_USING_STD;
 53               
 54 mike     1.2  PEGASUS_NAMESPACE_BEGIN
 55               
 56 kumpf    1.32 snmpIndicationHandler::snmpIndicationHandler()
 57               {
 58                   PEG_METHOD_ENTER (TRC_IND_HANDLER,
 59                       "snmpIndicationHandler::snmpIndicationHandler");
 60 mike     1.2  
 61 yi.zhou  1.30 #ifdef HPUX_EMANATE
 62 kumpf    1.32     _snmpTrapSender = new snmpDeliverTrap_emanate();
 63 yi.zhou  1.30 #elif defined (PEGASUS_USE_NET_SNMP)
 64 kumpf    1.32     _snmpTrapSender = new snmpDeliverTrap_netsnmp();
 65 yi.zhou  1.30 #else
 66 kumpf    1.32     _snmpTrapSender = new snmpDeliverTrap_stub();
 67 yi.zhou  1.30 #endif
 68               
 69                   PEG_METHOD_EXIT();
 70               }
 71               
 72 mike     1.2  void snmpIndicationHandler::initialize(CIMRepository* repository)
 73               {
 74 yi.zhou  1.30     PEG_METHOD_ENTER (TRC_IND_HANDLER,
 75                       "snmpIndicationHandler::initialize");
 76               
 77 mike     1.2      _repository = repository;
 78 yi.zhou  1.30 
 79 kumpf    1.32     _snmpTrapSender->initialize();
 80 yi.zhou  1.30 
 81                   PEG_METHOD_EXIT();
 82               }
 83               
 84               void snmpIndicationHandler::terminate()
 85               {
 86 kumpf    1.34     PEG_METHOD_ENTER(TRC_IND_HANDLER,
 87 yi.zhou  1.30         "snmpIndicationHandler::terminate");
 88               
 89 kumpf    1.32     _snmpTrapSender->terminate();
 90 yi.zhou  1.30 
 91                   PEG_METHOD_EXIT();
 92               }
 93               
 94               snmpIndicationHandler::~snmpIndicationHandler()
 95               {
 96 kumpf    1.34     PEG_METHOD_ENTER(TRC_IND_HANDLER,
 97 yi.zhou  1.30         "snmpIndicationHandler::~snmpIndicationHandler");
 98               
 99 kumpf    1.32     delete _snmpTrapSender;
100 yi.zhou  1.30 
101                   PEG_METHOD_EXIT();
102 mike     1.2  }
103               
104 chuck    1.14 // l10n - note: ignoring indication language
105 kumpf    1.16 void snmpIndicationHandler::handleIndication(
106                   const OperationContext& context,
107 dl.meetei 1.44     const String &nameSpace,
108 yi.zhou   1.26     CIMInstance& indication,
109 kumpf     1.34     CIMInstance& handler,
110 yi.zhou   1.26     CIMInstance& subscription,
111 kumpf     1.28     ContentLanguageList & contentLanguages)
112 mike      1.2  {
113                    Array<String> propOIDs;
114                    Array<String> propTYPEs;
115                    Array<String> propVALUEs;
116                
117 yi.zhou   1.36     Array<String> mapStr;
118 mike      1.2  
119 kumpf     1.34     PEG_METHOD_ENTER(TRC_IND_HANDLER,
120                        "snmpIndicationHandler::handleIndication");
121 mike      1.2  
122 kumpf     1.20     try
123                    {
124 marek     1.38         PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4,
125 w.otsuka  1.37             "snmpIndicationHandler %s:%s.%s processing %s Indication",
126                           (const char*)(nameSpace.getCString()),
127                           (const char*)(handler.getClassName().getString().getCString()),
128                           (const char*)(handler.getProperty(
129                           handler.findProperty(PEGASUS_PROPERTYNAME_NAME)).
130                           getValue().toString().getCString()),
131                           (const char*)(indication.getClassName().getString().
132                           getCString())));
133 kumpf     1.34         CIMClass indicationClass = _repository->getClass(
134                            nameSpace, indication.getClassName(), false, true,
135                            false, CIMPropertyList());
136 kumpf     1.20 
137 kumpf     1.34         Uint32 propertyCount = indication.getPropertyCount();
138 kumpf     1.13 
139 kumpf     1.34         for (Uint32 i=0; i < propertyCount; i++)
140                        {
141 yi.zhou   1.36             CIMProperty prop = indication.getProperty(i);
142 mike      1.2  
143 yi.zhou   1.36             Uint32 propDeclPos = indicationClass.findProperty(prop.getName());
144                            if (propDeclPos != PEG_NOT_FOUND)
145 kumpf     1.4              {
146 yi.zhou   1.36                 CIMProperty propDecl = indicationClass.getProperty(propDeclPos);
147                
148                                Uint32 qualifierPos =
149                                    propDecl.findQualifier(CIMName("MappingStrings"));
150                                if (qualifierPos != PEG_NOT_FOUND)
151 kumpf     1.20                 {
152 yi.zhou   1.36                     //
153                                    // We are looking for following fields:
154 kumpf     1.42                     // MappingStrings {"OID.IETF | SNMP." oidStr,
155 yi.zhou   1.36                     //     "DataType.IETF |" dataType}
156                                    // oidStr is the object identifier (e.g. "1.3.6.1.2.1.5..."
157 kumpf     1.42                     // dataType is either Integer, or OctetString,
158 yi.zhou   1.36                     // or OID
159                                    // Following is one example:
160                                    // MappingStrings {"OID.IETF | SNMP.1.3.6.6.3.1.1.5.2",
161                                    //    "DataType.IETF | Integer"}
162                                    //
163                
164                                    propDecl.getQualifier(qualifierPos).getValue().get(
165                                        mapStr);
166 kumpf     1.42 
167 yi.zhou   1.36                     String oidStr, dataType;
168                                    String mapStr1, mapStr2;
169                                    Boolean isValidAuthority = false;
170                                    Boolean isValidDataType = false;
171 mike      1.2  
172 yi.zhou   1.36                     for (Uint32 j=0; j < mapStr.size(); j++)
173 kumpf     1.20                     {
174 yi.zhou   1.36                         Uint32 barPos = mapStr[j].find("|");
175 kumpf     1.42 
176                                        if (barPos != PEG_NOT_FOUND)
177 yi.zhou   1.36                         {
178                                            mapStr1 = mapStr[j].subString(0, barPos);
179                                            mapStr2 = mapStr[j].subString(barPos + 1);
180 kumpf     1.34 
181 yi.zhou   1.36                             _trimWhitespace(mapStr1);
182                                            _trimWhitespace(mapStr2);
183 kumpf     1.42 
184 yi.zhou   1.36                             if ((mapStr1 == "OID.IETF") &&
185 kumpf     1.42                                 (String::compare(mapStr2,
186 yi.zhou   1.36                                  String("SNMP."), 5) == 0))
187                                            {
188                                                isValidAuthority = true;
189                                                oidStr = mapStr2.subString(5);
190                                            }
191                                            else if (mapStr1 == "DataType.IETF")
192                                            {
193                                                isValidDataType = true;
194                                                dataType = mapStr2;
195                                            }
196 kumpf     1.34 
197 kumpf     1.42                             if (isValidAuthority && isValidDataType)
198 kumpf     1.34                             {
199 yi.zhou   1.36                                 propOIDs.append(oidStr);
200                                                propTYPEs.append(dataType);
201                                                propVALUEs.append(prop.getValue().toString());
202                
203                                                break;
204 kumpf     1.34                             }
205                                        }
206                                    }
207 kumpf     1.20                 }
208 kumpf     1.4              }
209 mike      1.2          }
210                
211                        // Collected complete data in arrays and ready to send the trap.
212                        // trap destination and SNMP type are defined in handlerInstance
213                        // and passing this instance as it is to deliverTrap() call
214                
215 kumpf     1.34         Uint32 targetHostPos = handler.findProperty(CIMName("TargetHost"));
216                        Uint32 targetHostFormatPos =
217                            handler.findProperty(CIMName("TargetHostFormat"));
218                        Uint32 otherTargetHostFormatPos =
219                            handler.findProperty(CIMName("OtherTargetHostFormat"));
220                        Uint32 portNumberPos = handler.findProperty(CIMName("PortNumber"));
221                        Uint32 snmpVersionPos = handler.findProperty(CIMName("SNMPVersion"));
222                        Uint32 securityNamePos =
223                            handler.findProperty(CIMName("SNMPSecurityName"));
224                        Uint32 engineIDPos = handler.findProperty(CIMName("SNMPEngineID"));
225 sahana.prabhakar 1.43         Uint32 snmpSecLevelPos = 
226                                   handler.findProperty(CIMName("SNMPSecurityLevel"));
227                               Uint32 snmpSecAuthProtoPos = 
228                                   handler.findProperty(CIMName("SNMPSecurityAuthProtocol"));
229                               Uint32 snmpSecAuthKeyPos =
230                                   handler.findProperty(CIMName("SNMPSecurityAuthKey"));
231                               Uint32 snmpSecPrivProtoPos =
232                                   handler.findProperty(CIMName("SNMPSecurityPrivProtocol"));
233                               Uint32 snmpSecPrivKeyPos =
234                                   handler.findProperty(CIMName("SNMPSecurityPrivKey"));
235 kumpf            1.20 
236 w.otsuka         1.37         if (targetHostPos == PEG_NOT_FOUND)
237                               {
238 marek            1.38             PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
239 w.otsuka         1.37                 "Target host is not set for IndicationHandlerSNMPMapper %s"
240                                       " Indication.",
241                                       (const char*)(indication.getClassName().getString().
242                                       getCString())));
243                                   PEG_METHOD_EXIT();
244                                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
245                                       "Handler.snmpIndicationHandler.snmpIndicationHandler."
246                                       "INVALID_SNMP_INSTANCE",
247                                       "Invalid IndicationHandlerSNMPMapper instance"));
248                               }
249                               if (targetHostFormatPos == PEG_NOT_FOUND)
250                               {
251 marek            1.38             PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
252 w.otsuka         1.37                 "Target host format is not set for IndicationHandlerSNMPMapper"
253                                       " %s Indication.",
254                                       (const char*)(indication.getClassName().getString().
255                                       getCString())));
256                                   PEG_METHOD_EXIT();
257                                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
258                                       "Handler.snmpIndicationHandler.snmpIndicationHandler."
259                                       "INVALID_SNMP_INSTANCE",
260                                       "Invalid IndicationHandlerSNMPMapper instance"));
261                               }
262                               if (snmpVersionPos == PEG_NOT_FOUND)
263                               {
264 marek            1.38             PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
265 w.otsuka         1.37                 "SNMP Version is not set for IndicationHandlerSNMPMapper %s"
266                                       " Indication.",
267                                       (const char*)(indication.getClassName().getString().
268                                       getCString())));
269                                   PEG_METHOD_EXIT();
270                                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
271                                       "Handler.snmpIndicationHandler.snmpIndicationHandler."
272                                       "INVALID_SNMP_INSTANCE",
273                                       "Invalid IndicationHandlerSNMPMapper instance"));
274                               }
275                               else
276 kumpf            1.16         {
277 kumpf            1.34             // properties from the handler instance
278 kumpf            1.20             String targetHost;
279 kumpf            1.34             String otherTargetHostFormat = String();
280                                   String securityName = String();
281                                   String engineID = String();
282                                   Uint16 targetHostFormat = 0;
283                                   Uint16 snmpVersion = 0;
284                                   Uint32 portNumber;
285 sahana.prabhakar 1.43             Uint8 snmpSecLevel = 1; // noAuthnoPriv
286                                   Uint8 snmpSecAuthProto = 0; 
287                                   Array<Uint8> snmpSecAuthKey;// no key
288                                   Uint8 snmpSecPrivProto = 0; 
289                                   Array<Uint8> snmpSecPrivKey ;// no key
290 kumpf            1.20 
291 kumpf            1.34             String trapOid;
292 yi.zhou          1.36             Boolean trapOidAvailable = false;
293 kumpf            1.34             //
294 kumpf            1.20             //  Get snmpTrapOid from context
295                                   //
296 kumpf            1.34             if (context.contains(SnmpTrapOidContainer::NAME))
297                                   {
298                                       SnmpTrapOidContainer trapContainer =
299                                           context.get(SnmpTrapOidContainer::NAME);
300 kumpf            1.16 
301 kumpf            1.20                 trapOid = trapContainer.getSnmpTrapOid();
302 yi.zhou          1.36                 trapOidAvailable = true;
303 kumpf            1.34             }
304                                   else
305 kumpf            1.20             {
306 kumpf            1.34                 // get trapOid from indication Class
307 kumpf            1.16 
308 kumpf            1.34                 Uint32 pos =
309                                           indicationClass.findQualifier(CIMName("MappingStrings"));
310                                       if (pos != PEG_NOT_FOUND)
311                                       {
312 yi.zhou          1.36                     Array<String> classMapStr;
313                                           indicationClass.getQualifier(pos).getValue().
314                                               get(classMapStr);
315 kumpf            1.20 
316 yi.zhou          1.36                     for (Uint32 i=0; i < classMapStr.size(); i++)
317                                           {
318                                               Uint32 barPos = classMapStr[i].find("|");
319 kumpf            1.20 
320 kumpf            1.42                         if (barPos != PEG_NOT_FOUND)
321 yi.zhou          1.36                         {
322 kumpf            1.42                             String authorityName =
323 yi.zhou          1.36                                 classMapStr[i].subString(0, barPos);
324                                                   String oidStr = classMapStr[i].subString(
325                                                       barPos+1, PEG_NOT_FOUND);
326                       
327                                                   _trimWhitespace(authorityName);
328                                                   _trimWhitespace(oidStr);
329                       
330                                                   if ((authorityName == "OID.IETF") &&
331 kumpf            1.42                                 (String::compare(oidStr,
332 yi.zhou          1.36                                  String("SNMP."), 5) == 0))
333                                                   {
334 kumpf            1.42                                 trapOid = oidStr.subString(5);
335 yi.zhou          1.36                                 trapOidAvailable = true;
336                                                       break;
337                                                   }
338                                               }
339 kumpf            1.20                     }
340 yi.zhou          1.36 
341                                           if (!trapOidAvailable)
342 kumpf            1.34                     {
343 marek            1.38                         PEG_TRACE((
344                                                   TRC_IND_HANDLER,
345                                                   Tracer::LEVEL1,
346                                                   "No MappingStrings for snmp trap is specified "
347                                                       "for class: %s",
348                                                   (const char*)
349                                                     indication.getClassName().getString().getCString()
350                                                   ));
351 yi.zhou          1.36 
352 kumpf            1.34                         PEG_METHOD_EXIT();
353 yi.zhou          1.36 
354 marek            1.38                         throw PEGASUS_CIM_EXCEPTION_L(
355                                                   CIM_ERR_FAILED,
356 kumpf            1.34                             MessageLoaderParms(
357                                                       "Handler.snmpIndicationHandler."
358 yi.zhou          1.36                                 "snmpIndicationHandler.NO_MS_FOR_SNMP_TRAP",
359 marek            1.38                                 "No MappingStrings for snmp trap is specified "
360                                                           "for class: $0",
361                                                       indication.getClassName().getString()));
362 kumpf            1.34                     }
363                                       }
364                                       else
365                                       {
366 marek            1.38                     PEG_TRACE_CSTRING(TRC_IND_HANDLER, Tracer::LEVEL1,
367 kumpf            1.34                         "Qualifier MappingStrings can not be found.");
368                                           PEG_METHOD_EXIT();
369                                           MessageLoaderParms parms(
370                                               "Handler.snmpIndicationHandler.snmpIndicationHandler."
371                                                   "QUALIFIER_MAPPINGS_NOT_FOUND",
372                                               "Qualifier MappingStrings can not be found");
373                                           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
374                                       }
375                                   }
376                       
377                                   handler.getProperty(targetHostPos).getValue().get(targetHost);
378                                   handler.getProperty(targetHostFormatPos).getValue().get(
379                                       targetHostFormat);
380                                   if (otherTargetHostFormatPos != PEG_NOT_FOUND)
381                                   {
382                                       handler.getProperty(otherTargetHostFormatPos).getValue().get(
383                                           otherTargetHostFormat);
384                                   }
385                                   if (portNumberPos != PEG_NOT_FOUND)
386                                   {
387                                       handler.getProperty(portNumberPos).getValue().get(portNumber);
388 kumpf            1.34             }
389                                   else
390                                   {
391                                       // default port
392                                       portNumber = SNMP_TRAP_DEFAULT_PORT;
393                                   }
394                       
395                                   handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);
396                                   if (securityNamePos != PEG_NOT_FOUND)
397                                   {
398                                       handler.getProperty(securityNamePos).getValue().get(
399                                           securityName);
400                                   }
401                                   if (engineIDPos != PEG_NOT_FOUND)
402                                   {
403                                       handler.getProperty(engineIDPos).getValue().get(engineID);
404                                   }
405 kumpf            1.13 
406 sahana.prabhakar 1.43             if(snmpVersion == 5) // SNMPv3 Trap
407                                   {
408                                       //fetch the security data
409                                       if(snmpSecLevelPos != PEG_NOT_FOUND)
410                                       {
411                                           handler.getProperty(snmpSecLevelPos).getValue(). \
412                                               get(snmpSecLevel);
413                                       }
414                                       if(snmpSecAuthProtoPos != PEG_NOT_FOUND)
415                                       {
416                                           handler.getProperty(snmpSecAuthProtoPos).getValue(). \
417                                               get(snmpSecAuthProto);
418                                       }
419                                       if(snmpSecAuthKeyPos != PEG_NOT_FOUND)
420                                       {
421                                           handler.getProperty(snmpSecAuthKeyPos).getValue(). \
422                                               get(snmpSecAuthKey);
423                                       }
424                                       if(snmpSecPrivProtoPos != PEG_NOT_FOUND)
425                                       {
426                                           handler.getProperty(snmpSecPrivProtoPos).getValue(). \
427 sahana.prabhakar 1.43                         get(snmpSecPrivProto);
428                                       }
429                                       if(snmpSecPrivKeyPos!= PEG_NOT_FOUND)
430                                       {
431                                           handler.getProperty(snmpSecPrivKeyPos).getValue(). \
432                                               get(snmpSecPrivKey);
433                                       }
434                                   }
435                       
436 marek            1.38             PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4,
437 w.otsuka         1.37                "snmpIndicationHandler sending %s Indication trap %s to target"
438                                      " host %s target port %d",
439                                      (const char*)(indication.getClassName().getString().
440                                      getCString()),
441                                      (const char*)(trapOid.getCString()),
442                                      (const char*)(targetHost.getCString()),portNumber));
443                                  _snmpTrapSender->deliverTrap(
444 kumpf            1.20                 trapOid,
445                                       securityName,
446                                       targetHost,
447                                       targetHostFormat,
448 kumpf            1.34                 otherTargetHostFormat,
449                                       portNumber,
450                                       snmpVersion,
451                                       engineID,
452 sahana.prabhakar 1.43                 snmpSecLevel,
453                                       snmpSecAuthProto,
454                                       snmpSecAuthKey,
455                                       snmpSecPrivProto,
456                                       snmpSecPrivKey,
457 kumpf            1.34                 propOIDs,
458                                       propTYPEs,
459 kumpf            1.20                 propVALUEs);
460 w.otsuka         1.37 
461 marek            1.38         PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4,
462 w.otsuka         1.37            "%s Indication trap %s sent to target host %s target port %d "
463                                  "successfully",
464                                  (const char*)(indication.getClassName().getString().getCString()),
465                                  (const char*)(trapOid.getCString()),
466                                  (const char*)(targetHost.getCString()),portNumber));
467 kumpf            1.20         }
468 kumpf            1.34     }
469                           catch (CIMException& c)
470 kumpf            1.20     {
471 thilo.boehm      1.39         PEG_TRACE((TRC_IND_HANDLER, Tracer::LEVEL1, "CIMException %s",
472                                   (const char*)c.getMessage().getCString()));
473 kumpf            1.34         PEG_METHOD_EXIT();
474                               throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, c.getMessage());
475 kumpf            1.20     }
476                           catch (Exception& e)
477                           {
478 thilo.boehm      1.39         PEG_TRACE((TRC_IND_HANDLER, Tracer::LEVEL1, "Exception %s",
479                                   (const char*)e.getMessage().getCString()));
480 kumpf            1.34         PEG_METHOD_EXIT();
481 kumpf            1.20 
482 kumpf            1.34         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
483 kumpf            1.20     }
484                           catch (...)
485                           {
486 marek            1.38         PEG_TRACE_CSTRING(TRC_IND_HANDLER, Tracer::LEVEL1,
487 kumpf            1.34             "Failed to deliver trap.");
488                               PEG_METHOD_EXIT();
489                       
490                               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
491                                   "Handler.snmpIndicationHandler.snmpIndicationHandler."
492                                       "FAILED_TO_DELIVER_TRAP",
493                                   "Failed to deliver trap."));
494 kumpf            1.13     }
495 yi.zhou          1.30     PEG_METHOD_EXIT();
496 mike             1.2  }
497                       
498 yi.zhou          1.36 void snmpIndicationHandler::_trimWhitespace(
499                           String & nameStr)
500                       {
501                           PEG_METHOD_ENTER(TRC_IND_HANDLER,
502                               "snmpIndicationHandler::_trimWhitespace");
503                       
504                           Uint32 ps = 0;
505                           // skip begining whitespace
506                           for (ps = 0; ps < nameStr.size(); ps++)
507                           {
508                               if (nameStr[ps] != ' ')
509                               {
510                                   break;
511                               }
512                           }
513                       
514                           if (ps != 0)
515                           {
516                               nameStr.remove(0, ps);
517                           }
518                       
519 yi.zhou          1.36     // skip the appended whitespace
520                           for (ps = nameStr.size(); ps != 0; ps--)
521                           {
522                               if (nameStr[ps-1] != ' ')
523                               {
524                                   break;
525                               }
526                           }
527                       
528                           if (ps !=  nameStr.size())
529                           {
530                               nameStr.remove(ps);
531                           }
532                       
533                           PEG_METHOD_EXIT();
534                       }
535                       
536 kumpf            1.32 PEGASUS_NAMESPACE_END
537                       
538                       PEGASUS_USING_PEGASUS;
539                       
540 kumpf            1.33 // This is the entry point into this dynamic module.
541 mike             1.2  
542 kumpf            1.33 extern "C" PEGASUS_EXPORT CIMHandler* PegasusCreateHandler(
543                           const String& handlerName)
544 kumpf            1.32 {
545 kumpf            1.33     if (handlerName == "snmpIndicationHandler")
546                           {
547                               return new snmpIndicationHandler;
548                           }
549                       
550                           return 0;
551 mike             1.2  }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2