⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uxsnmp.h

📁 snmp++支持snmpv1
💻 H
📖 第 1 页 / 共 2 页
字号:
/*_############################################################################  _##   _##  uxsnmp.h    _##  _##  SNMP++v3.2.16  _##  -----------------------------------------------  _##  Copyright (c) 2001-2004 Jochen Katz, Frank Fock  _##  _##  This software is based on SNMP++2.6 from Hewlett Packard:  _##    _##    Copyright (c) 1996  _##    Hewlett-Packard Company  _##    _##  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.  _##  Permission to use, copy, modify, distribute and/or sell this software   _##  and/or its documentation is hereby granted without fee. User agrees   _##  to display the above copyright notice and this license notice in all   _##  copies of the software and any documentation of the software. User   _##  agrees to assume all liability for the use of the software;   _##  Hewlett-Packard and Jochen Katz make no representations about the   _##  suitability of this software for any purpose. It is provided   _##  "AS-IS" without warranty of any kind, either express or implied. User   _##  hereby grants a royalty-free license to any and all derivatives based  _##  upon this software code base.   _##    _##  Stuttgart, Germany, Sun Feb 27 11:34:17 CET 2005   _##    _##########################################################################*/#ifndef _UXSNMP_H_#define _UXSNMP_H_#include "snmp_pp/reentrant.h"#include "snmp_pp/target.h"#include "snmp_pp/oid.h"#include "snmp_pp/address.h"#ifdef SNMP_PP_NAMESPACEnamespace Snmp_pp {#endif#define SNMP_PP_WITH_UDPADDR // Snmp class has constructor with UdpAddress//-----[ internally used defines ]----------------------------------------#define MAXNAME 80                   // maximum name length#define MAX_ADDR_LEN 10              // maximum address len, ipx is 4+6#define SNMP_SHUTDOWN_MSG 0x0400+177 // shut down msg for stoping a blocked message#ifndef INVALID_SOCKET #define INVALID_SOCKET ((SNMPHANDLE)(~0)) // value for invalid socket#endif//-----[ async defines for engine ]---------------------------------------#define sNMP_PDU_GET_ASYNC       21#define sNMP_PDU_GETNEXT_ASYNC   22#define sNMP_PDU_SET_ASYNC       23#define sNMP_PDU_GETBULK_ASYNC   24#define sNMP_PDU_INFORM_ASYNC    25//-----[ trap / notify macros ]-------------------------------------------#define IP_NOTIFY  162     // IP notification#define IPX_NOTIFY 0x2121  // IPX notification//------[ forward declaration of Snmp class ]-----------------------------class Snmp;class EventListHolder;class Pdu;class v3MP;//-----------[ async methods callback ]-----------------------------------/** * Async methods of the class Snmp require the caller to provide a * callback address of a function with this typedef. * * @note It is not allowed to call any synchronous Snmp methods within the *       callback. Async methods are allowed. * * @param reason  - Reason for callback (see snmperrs.h) * @param session - Pointer to Snmp object that was used to send the request * @param pdu     - The received Pdu if reason indicates a received message * @param target  - source target * @param data    - Pointer passed to the async method */typedef void (*snmp_callback)(int reason, Snmp *session,                               Pdu &pdu, SnmpTarget &target, void *data);//------------[ SNMP Class Def ]---------------------------------------------///** * SNMP class defintion. The Snmp class provides an object oriented * approach to SNMP. The SNMP class is an encapsulation of SNMP * sessions, gets, sets and get nexts. The class manages all SNMP * resources and provides complete retry and timeout capability. * * This class is thread save. * * @note If you use the async methods to send requests you MUST call *       Snmp::eventListHolder->SNMPProcessPendingEvents() while waiting *       for the responses. This function triggers the resend of *       packets and calls your callback function if the response is *       received. * * @note Call srand() before creating the first Snmp object. */class DLLOPT Snmp: public SnmpSynchronized{ public:  //------------------[ constructors ]----------------------------------  /** @name Constructors and Destructor */  //@{  /**   * Construct a new SNMP session using the given UDP port.   *   * @param status   *    after creation of the session this parameter will    *    hold the creation status.   * @param port   *    an UDP port to be used for the session   * @param bind_ipv6   *    Set this to true if IPv6 should be used. The default is   *    IPv4.   */  Snmp(int &status, const unsigned short port = 0,       const bool bind_ipv6 = false);  /**   * Construct a new SNMP session using the given UDP address.   * Thus, binds the session on a specific IPv4 or IPv6 address.    *   * @param status   *    after creation of the session this parameter will    *    hold the creation status.   * @param addr   *    an UDP address to be used for the session   */	  Snmp(int &status, const UdpAddress &addr);  /**   * Construct a new SNMP session using the given UDP addresses.   * Using this constructor will bind to both IPv4 and IPv6 ports.   *   * @param status   *    after creation of the session this parameter will    *    hold the creation status.   * @param addr_v4   *    an IPv4 UDP address to be used for the session   * @param addr_v6   *    an IPv6 UDP address to be used for the session   */	  Snmp(int &status,  const UdpAddress& addr_v4, const UdpAddress& addr_v6);  //-------------------[ destructor ]------------------------------------  /**   * Destructor.   */  virtual ~Snmp();  //@}  //--------[ Get the version of the snmp++ library ]--------------------  /**   * Get the version of the snmp++ library.   *   * @return The version of the snmp++ lib at runtime.   */  static const char *get_version();  //-------------------[ returns error string ]--------------------------  /**   * Returns a human readable error string.   *   * @param c - Error code returned by any method of this class   * @return Null terminated error string.   */  static const char *error_msg(const int c);#ifdef _SNMPv3  /**   * Returns a human readable error string.   * If a report message is returned, then the contained Oid can be   * used to get a error string.   *   * @param v3Oid - Oid of a SNMPv3 report Pdu   * @return Null terminated error string.   */  static const char* error_msg(const Oid& v3Oid);#endif  //------------------------[ Windows Sockets ]----------------------------  /**   * Initialize the Winsock library (WSAStartup).   *   * @note on Win32 this method *must* be called before creating Snmp or   *       Address objects.   */  static void socket_startup();  /**   * Shut down the Winsock library (WSACleanup).   */  static void socket_cleanup();  //------------------------[ send requests ]------------------------------  /** @name Sending SNMP Pdus   */  //@{  /**   * Send a blocking SNMP-GET request.   *   * @param pdu    - Pdu to send   * @param target - Target for the get   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int get(Pdu &pdu, const SnmpTarget &target);  /**   * Send a async SNMP-GET request.   *   * @param pdu      - Pdu to send   * @param target   - Target for the get   * @param callback - User callback function to use   * @param callback_data - User definable data pointer   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int get(Pdu &pdu, const SnmpTarget &target,		  const snmp_callback callback,		  const void *callback_data = 0);  /**   * Send a blocking SNMP-GETNEXT request.   *   * @param pdu    - Pdu to send   * @param target - Target for the getnext   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int get_next(Pdu &pdu, const SnmpTarget &target);  /**   * Send a async SNMP-GETNEXT request.   *   * @param pdu      - Pdu to send   * @param target   - Target for the getnext   * @param callback - User callback function to use   * @param callback_data - User definable data pointer   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int get_next(Pdu &pdu, const SnmpTarget &target,                       const snmp_callback callback,		       const void *callback_data = 0);  /**   * Send a blocking SNMP-SET request.   *   * @param pdu    - Pdu to send   * @param target - Target for the set   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int set(Pdu &pdu, const SnmpTarget &target);  /**   * Send a async SNMP-SET request.   *   * @param pdu      - Pdu to send   * @param target   - Target for the set   * @param callback - User callback function to use   * @param callback_data - User definable data pointer   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int set(Pdu &pdu, const SnmpTarget &target,		  const snmp_callback callback,		  const void * callback_data = 0);  /**   * Send a blocking SNMP-GETBULK request.   *   * @param pdu           - Pdu to send   * @param target        - Target for the getbulk   * @param non_repeaters - number of non repeaters   * @param max_reps      - maximum number of repetitions   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int get_bulk(Pdu &pdu, const SnmpTarget &target,		       const int non_repeaters, const int max_reps);  /**   * Send a async SNMP-GETBULK request.   *   * @param pdu           - Pdu to send   * @param target        - Target for the getbulk   * @param non_repeaters - number of non repeaters   * @param max_reps      - maximum number of repetitions   * @param callback      - User callback function to use   * @param callback_data - User definable data pointer   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int get_bulk(Pdu &pdu, const SnmpTarget &target,		       const int non_repeaters, const int max_reps,		       const snmp_callback callback,		       const void *callback_data = 0);  /**   * Send a SNMP-TRAP.   *   * @param pdu    - Pdu to send   * @param target - Target for the trap   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int trap(Pdu &pdu, const SnmpTarget &target);  /**   * Send a SNMPv3-REPORT.   *   * @param pdu    - Pdu to send   * @param target - Target for the report (must be a UTarget)   *   * @return SNMP_CLASS_SUCCES or a negative error code

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -