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

📄 uxsnmp.h

📁 snmp++支持snmpv1
💻 H
📖 第 1 页 / 共 2 页
字号:
   */  virtual int report(Pdu &pdu, const SnmpTarget &target);  /**   * Send a blocking INFORM-REQ.   *   * @param pdu    - Pdu to send   * @param target - Target for the inform   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int inform(Pdu &pdu, const SnmpTarget &target);  /**   * Send a async INFORM-REQ.   *   * @param pdu    - Pdu to send   * @param target - Target for the inform   * @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 inform(Pdu &pdu, const SnmpTarget &target,		     const snmp_callback callback,		     const void * callback_data = 0);  /**   * Send a RESPONSE.   *   * @param pdu    - Pdu to send   * @param target - Target for the response   * @param fd     - file descriptor to use, should be the one   *                 that was passed to the callback function   *   * @return SNMP_CLASS_SUCCES or a negative error code   */  virtual int response(Pdu &pdu, const SnmpTarget &target,		       const int fd = INVALID_SOCKET);  /**   * Send a SNMP Broadcast message.   *   * This member function sends out a valid SNMP message to a   * broadcast address and waits for responses. The source addresses   * of the response messages are added to the collection.   *   * The message is sent only once.   *   * @note SNMP_BROADCAST has to be defined in config_snmp_pp.h.   *   * @note There is no SNMP standard that defines "SNMP Broadcast   *       discovery". SNMP agents are not forced to answer requests   *       that are sent to a broadcast address.   *   * @note Do not use this method while waiting for other responses,   *       as these responses will be added to the collection and dropped   *       by this method. Solution for this problem: Use a special   *       Snmp object only for broadcasts.   *   * @param addresses   - The addresses of the agents, that answered.   * @param timeout_sec - Timeout in seconds   * @param addr        - Broadcast address   * @param version     - SNMP version to use   * @param community   - Only needed for SNMPv1/v2c, defaults to "public"   *   */  virtual int broadcast_discovery(UdpAddressCollection &addresses,				  const int timeout_sec,				  const UdpAddress &addr,				  const snmp_version version,				  const OctetStr *community = 0);  //@}  /**   * Cancel a pending request.   *   * @param rid - The request id to cancel   *   * @return SNMP_CLASS_SUCCES or SNMP_CLASS_INVALID_REQID on failure   */  virtual int cancel(const unsigned long rid);  /** @name Trap and Inform handling   */  //@{  /**   * Register to get traps and informs.   *   * @note Every call to one of the notify_register() methods overwrites   *       the previous given values.   *   * @param trapids       - ids to listen for   * @param targets       - targets to listen for   * @param callback      - User callback function to use   * @param callback_data - User definable data pointer   *   * @return SNMP_CLASS_SUCCESS, SNMP_CLASS_TL_FAILED or SNMP_CLASS_TL_IN_USE   */  virtual int notify_register(const OidCollection    &trapids,                              const TargetCollection &targets,                              const snmp_callback callback,                              const void *callback_data=0);  /**   * Register to get traps and informs.   *   * @note listen_addresses param is ignored!   *   * @note Every call to one of the notify_register() methods overwrites   *       the previous given values.   *   * @param trapids       - ids to listen for   * @param targets       - targets to listen for   * @param listen_addresses - interfaces to listen on   * @param callback      - User callback function to use   * @param callback_data - User definable data pointer   *   * @return SNMP_CLASS_SUCCESS, SNMP_CLASS_TL_FAILED or SNMP_CLASS_TL_IN_USE   */  virtual int notify_register( const OidCollection    &trapids,                               const TargetCollection &targets,                               const AddressCollection &listen_addresses,                               const snmp_callback callback,                               const void *callback_data=0);  /**   * Unregister to get traps and informs.   * Undo the call to notify_register().   *   * @return Always SNMP_CLASS_SUCCESS   */  virtual int notify_unregister();  /**   * Get notify register info.   *   * @param trapids       - ids listened for   * @param targets       - targets listened for   *   * @return SNMP_CLASS_SUCCESS or SNMP_CLASS_INVALID if not registered   */  virtual int get_notify_filter( OidCollection &trapids,				 TargetCollection &targets)    { AddressCollection a; return get_notify_filter(trapids, targets, a); }  /**   * Get notify register info.   *   * @param trapids       - ids listened for   * @param targets       - targets listened for   * @param listen_addresses - interfaces listened on   *   * @return SNMP_CLASS_SUCCESS or SNMP_CLASS_INVALID if not registered   */  virtual int get_notify_filter( OidCollection &trapids,				 TargetCollection &targets,				 AddressCollection &listen_addresses);  //-----------------------[ access the trap reception info ]---------------  /**   * Get a pointer to the callback function used for trap reception.   *   * @return Pointer to the function set through notify_register()   */  snmp_callback get_notify_callback() { return notifycallback; };  /**   * Get a pointer to the data that is passed to the callback function.   *   * @return Pointer to the data set through notify_register()   */  void *get_notify_callback_data() { return notifycallback_data; };  //@}  /**   * Send raw UDP data.   * This method may be used to send any data to the recepient.   *   * @param send_buf - Data buffer   * @param send_len - Length of the data   * @param address  - Recepient   * @param fd       - socket to use, if not specified, the socket of the   *                   object is used   *   * @return 0 on success, -1 on failure   */  virtual int send_raw_data( unsigned char *send_buf,                             size_t send_len, UdpAddress &address,                             int fd = 0);  const IpAddress &get_listen_address() const {return listen_address; };  // this member var will simulate a global var  EventListHolder *eventListHolder;#ifdef _SNMPv3  // lock for v3 cache information  static SnmpSynchronized v3Lock;#endif  bool start_poll_thread(const int select_timeout);  void stop_poll_thread();protected:  /**   * Check for the status of the worker thread.   * @return BOOL - TRUE - if running, FALSE - otherwise   */  bool is_running(void) const      { return m_bThreadRunning; };	  /**   * This is a working thread for the recovery of the pending events.   *   * @param pSnmp [in] pointer to the whole object   *   * @return int   *          0 - if succesful,   *          1 - in the case of error   */#ifdef WIN32  static int process_thread(Snmp *pSnmp);#else  static void* process_thread(void *arg);#endif protected:  /**   * Generate a unique (for this Snmp obect) request id.   *   * @return Unique id between PDU_MIN_RID and PDU_MAX_RID   */  long MyMakeReqId();  /**   * Common init function used by constructors.   */  void init(int& status, IpAddress*[2],            const unsigned short port_v4, const unsigned short port_v6);  /**   * Set the notify timestamp of a trap pdu if the user did not set it.   */  void check_notify_timestamp(Pdu &pdu);  //-----------[ Snmp Engine ]----------------------------------------  /**   * gets, sets and get nexts go through here....   * This mf does all snmp sending and reception   * except for traps which are sent using trap().   *   * @note that for a UTarget with an empty engine id the   *       Utarget::set_engine_id() may be called.   */  int snmp_engine( Pdu &pdu,                  // pdu to use                   long int non_reps,         // get bulk only                   long int max_reps,         // get bulk only                   const SnmpTarget &target,        // destination target                   const snmp_callback cb,    // async callback function                   const void *cbd,          // callback data		   int fd = INVALID_SOCKET);  //--------[ map action ]------------------------------------------------  // map the snmp++ action to a SMI pdu type  void map_action(unsigned short action, unsigned short &pdu_action);#ifdef _SNMPv3  friend void v3CallBack( int reason, Snmp *snmp, Pdu &pdu,			  SnmpTarget &target, void *v3cd);  /**   * Internal used callback data structure for async v3 requests.   */  struct V3CallBackData  {    Pdu *pdu;                  ///< The Pdu that was sent    long int non_reps;         ///< For GET-BULK requests    long int max_reps;         ///< For GET-BULK requests    SnmpTarget *target;        ///< Pointer to the Target object to use    snmp_callback oldCallback; ///< User callback function    const void *cbd;           ///< User callback data  };#endif  //---[ instance variables ]#ifdef WIN32  unsigned long iv_snmp_session;  unsigned long iv_snmp_session_ipv6;#else  SNMPHANDLE iv_snmp_session;         // session handle  SNMPHANDLE iv_snmp_session_ipv6;    // session handle#endif  IpAddress listen_address;  int iv_notify_fd;                   // fd for notify session - DLD  SNMPHANDLE pdu_handler;             // pdu handler win proc  SNMPHANDLE pdu_handler_ipv6;        // pdu handler win proc  int construct_status;               // status of construction  int construct_status_ipv6;          // status of construction ipv6  long current_rid;                   // current rid to use  // inform receive member variables  snmp_callback  notifycallback;  void * notifycallback_data;private:  bool m_bThreadRunning;  int m_iPollTimeOut;  // Keep track of the thread.#ifdef _THREADS#ifdef WIN32  HANDLE m_hThread;#else  pthread_t m_hThread;#endif#endif};#ifdef SNMP_PP_NAMESPACE}; // end of namespace Snmp_pp#endif #endif

⌨️ 快捷键说明

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