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

  1 a.dunfey 1.1.2.1 //%2006////////////////////////////////////////////////////////////////////////
  2 yi.zhou  1.1     //
  3                  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4                  // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5                  // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6                  // IBM Corp.; EMC Corporation, The Open Group.
  7                  // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8                  // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9                  // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10                  // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 a.dunfey 1.1.2.1 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12                  // EMC Corporation; Symantec Corporation; The Open Group.
 13 yi.zhou  1.1     //
 14                  // Permission is hereby granted, free of charge, to any person obtaining a copy
 15                  // of this software and associated documentation files (the "Software"), to
 16                  // deal in the Software without restriction, including without limitation the
 17                  // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18                  // sell copies of the Software, and to permit persons to whom the Software is
 19                  // furnished to do so, subject to the following conditions:
 20                  // 
 21                  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22                  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23                  // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24                  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25                  // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26                  // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27                  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28                  // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29                  //
 30                  //==============================================================================
 31                  //
 32                  // Author: Yi Zhou, Hewlett-Packard Company (yi.zhou@hp.com)
 33                  //
 34 yi.zhou  1.1     // Modified By:
 35                  //
 36                  //%/////////////////////////////////////////////////////////////////////////////
 37                  
 38                  #include <iostream>
 39                  
 40                  #include <net-snmp/net-snmp-config.h>
 41                  #include <net-snmp/net-snmp-includes.h>
 42                  #include "snmpDeliverTrap.h"
 43                  
 44                  PEGASUS_NAMESPACE_BEGIN
 45                  
 46                  static const char _MSG_SESSION_OPEN_FAILED [] = 
 47                      "Snmp Indication Handler failed to open the SNMP session: "; 
 48                  static const char _MSG_SESSION_OPEN_FAILED_KEY [] = 
 49                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_SESSION_OPEN_FAILED";
 50                  
 51                  static const char _MSG_GET_SESSION_POINT_FAILED [] = 
 52                      "Snmp Indication Handler failed to get the SNMP session pointer: "; 
 53                  static const char _MSG_GET_SESSION_POINTER_FAILED_KEY [] = 
 54                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_GET_SESSION_POINT_FAILED";
 55 yi.zhou  1.1     
 56                  static const char _MSG_PDU_CREATE_FAILED [] = 
 57                      "Snmp Indication Handler failed to create the SNMP PDU."; 
 58                  static const char _MSG_PDU_CREATE_FAILED_KEY [] = 
 59                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_PDU_CREATE_FAILED";
 60                  
 61                  static const char _MSG_VERSION_NOT_SUPPORTED [] = 
 62                      "SNMPv1 Trap and SNMPv2C Trap are the only supported SNMPVersion values.";
 63                  static const char _MSG_VERSION_NOT_SUPPORTED_KEY [] = 
 64                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_VERSION_NOT_SUPPORTED";
 65                  
 66                  static const char _MSG_SESSION_SEND_FAILED [] = 
 67                      "Snmp Indication Handler failed to send the trap: "; 
 68                  static const char _MSG_SESSION_SEND_FAILED_KEY [] = 
 69                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_SESSION_SEND_FAILED";
 70                  
 71                  static const char _MSG_PACK_TRAP_INFO_INTO_PDU_FAILED [] = 
 72                      "Snmp Indication Handler failed to pack trap information into the SNMP PDU: \"$0\".";
 73                  static const char _MSG_PACK_TRAP_INFO_INTO_PDU_FAILED_KEY [] = 
 74                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_PACK_TRAP_INFO_INTO_PDU_FAILED";
 75                  
 76 yi.zhou  1.1     static const char _MSG_ADD_SYSUPTIME_TO_PDU_FAILED [] = 
 77                      "Snmp Indication Handler failed to add sysUpTime to the SNMP PDU: \"$0\".";
 78                  static const char _MSG_ADD_SYSUPTIME_TO_PDU_FAILED_KEY [] = 
 79                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_ADD_SYSUPTIME_TO_PDU_FAILED";
 80                  
 81                  static const char _MSG_ADD_SNMP_TRAP_TO_PDU_FAILED [] = 
 82                      "Snmp Indication Handler failed to add SNMP Trap to the SNMP PDU: \"$0\".";
 83                  static const char _MSG_ADD_SNMP_TRAP_TO_PDU_FAILED_KEY [] = 
 84                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_ADD_SNMP_TRAP_TO_PDU_FAILED";
 85                  
 86                  static const char _MSG_PACK_CIM_PROPERTY_TO_PDU_FAILED [] = 
 87                      "Snmp Indication Handler failed to pack a CIM Property into the SNMP PDU: \"$0\".";
 88                  static const char _MSG_PACK_CIM_PROPERTY_TO_PDU_FAILED_KEY [] = 
 89                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_PACK_CIM_PROPERTY_TO_PDU_FAILED";
 90                  
 91                  static const char _MSG_READ_OBJID_FAILED [] =
 92                      "Snmp Indication Handler failed to convert trapOid \"$0\" from a "
 93                      "numeric form to a list of subidentifiers.";
 94                  static const char _MSG_READ_OBJID_FAILED_KEY [] =
 95                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_READ_OBJID_FAILED";
 96                  
 97 yi.zhou  1.1     static const char _MSG_PARSE_CIM_PROPERTY_OID_FAILED [] =
 98                      "Snmp Indication Handler failed to convert a CIM property OID \"$0\" from "
 99                      "a numeric form to a list of subidentifiers.";
100                  static const char _MSG_PARSE_CIM_PROPERTY_OID_FAILED_KEY [] =
101                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp.__MSG_PARSE_CIM_PROPERTY_OID_FAILED";
102                  
103                  static const char _MSG_READ_ENTOID_FAILED [] =
104                      "Snmp Indication Handler failed to convert SNMPV1 enterprise OID \"$0\" "
105                      "from a numeric form to a list of subidentifiers.";
106                  static const char _MSG_READ_ENTOID_FAILED_KEY [] =
107                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_READ_ENTOID_FAILED";
108                  
109                  static const char _MSG_UNSUPPORTED_SNMP_DATA_TYPE [] =
110                      "Type \"$0\" is an unsupported SNMP Data Type for the CIM property.";
111                  static const char _MSG_UNSUPPORTED_SNMP_DATA_TYPE_KEY [] =
112                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_UNSUPPORTED_SNMP_DATA_TYPE";
113                  
114                  static const char _MSG_ADD_VAR_TO_PDU_FAILED [] =
115                      "Snmp Indication Handler failed to add a CIM property \"$0\" to the SNMP PDU: \"$1\".";
116                  static const char _MSG_ADD_VAR_TO_PDU_FAILED_KEY [] =
117                      "Handler.snmpIndicationHandler.snmpDeliverTrap_netsnmp._MSG_ADD_VAR_TO_PDU_FAILED";
118 yi.zhou  1.1     
119                  class snmpDeliverTrap_netsnmp : public snmpDeliverTrap
120                  {
121                  public:
122                  
123                      void deliverTrap(
124                          const String& trapOid,
125                          const String& securityName, 
126                          const String& targetHost, 
127                          const Uint16& targetHostFormat, 
128                          const String& otherTargetHostFormat, 
129                          const Uint32& portNumber,
130                          const Uint16& snmpVersion, 
131                          const String& engineID,
132                          const Array<String>& vbOids,
133                          const Array<String>& vbTypes,
134                          const Array<String>& vbValues);
135                  
136                  private:
137                  
138                      /**
139 yi.zhou  1.1             Creates a SNMP session.
140                        
141                          @param targetHost     the target system of a hostname or an IPv4 
142                                                address
143                                                to receive a trap
144                          @param portNumber     the port number to receive a trap
145                          @param securityName   the human readable community name
146                          @param snmpSession    the SNMP session
147                          @param sessionHandle  an opaque pointer of the SNMP session
148                          @param sessionPtr     the SNMP session pointer to its associated 
149                                                struct snmp_session
150                          
151                      */
152                  
153                      void _createSession(const String & targetHost,
154                                          Uint32 portNumber,
155                                          const String & securityName,
156                                          struct snmp_session & snmpSession,
157                                          void *&sessionHandle,
158                                          struct snmp_session *&sessionPtr);
159                  
160 yi.zhou  1.1         /**
161                          Creates a SNMP session.
162                        
163                          @param sessionHandle  an opaque pointer of the SNMP session
164                      */
165                      void _destroySession(void *sessionHandle);
166                  
167                      /**
168                          Creates a SNMP PDU.
169                  
170                          @param snmpVersion  the SNMP version
171                          @param trapOid      the trap OID
172                          @param sessionPtr   the SNMP session pointer
173                          @param snmpPdu      the SNMP PDU
174                  
175                      */
176                  
177                      void _createPdu(Uint16 snmpVersion,
178                                     const String& trapOid,
179                                     struct snmp_session *&sessionPtr,
180                                     struct snmp_pdu *& snmpPdu);
181 yi.zhou  1.1     
182                      /**
183                          Pack the trap information into the PDU.
184                  
185                          @param trapOid  the trap OID
186                          @param snmpPdu  the SNMP PDU
187                      */
188                      void _packTrapInfoIntoPdu(const String & trapOid,
189                                                snmp_pdu * snmpPdu);
190                  
191                      /**
192                          Pack CIM properties into PDU.
193                  
194                          @param vbOids    the array of CIM property OIDs
195                          @param vbTypes   the array of CIM property data types
196                          @param vbValues  the array of CIM property values
197                          @param snmpPdu   the SNMP PDU
198                      */
199                      void _packOidsIntoPdu(const Array<String>& vbOids,
200                                            const Array<String>& vbTypes,
201                                            const Array<String>& vbValues,
202 yi.zhou  1.1                               snmp_pdu * snmpPdu);
203                  
204                      enum SNMPVersion {_SNMPv1_TRAP = 2, _SNMPv2C_TRAP = 3,
205                          _SNMPv2C_INFORM = 4, _SNMPv3_TRAP = 5, _SNMPv3_INFORM = 6};
206                  
207                  };
208                  
209                  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2