📄 target.h
字号:
* Clone operator. * * Clone operation for creating a new CTarget from an existing * CTarget. * * @note The caller MUST use the delete operation on the return * value when done. * * @return A pointer to the new object on success, 0 on failure. */ SnmpTarget *clone() const { return (SnmpTarget *) new CTarget(*this); }; /** * Get the read community name. * * @return C string of the read community. */ const char * get_readcommunity() const { return (const char *) read_community.get_printable(); }; /** * Get the read community name. * * @param oct - OctetStr that will be filled with the read community name. */ void get_readcommunity( OctetStr& oct) const { oct = read_community; }; /** * Set the read community name. * * @param str - The new read community name */ void set_readcommunity( const char * str) { read_community = str; }; /** * Set the read community name. * * @param oct - The new read community name */ void set_readcommunity( const OctetStr& oct) { read_community = oct; }; /** * Get the write community name. * * @return C string of the write community. */ const char * get_writecommunity() const { return (const char *) write_community.get_printable(); }; /** * Get the write community name. * * @param oct - OctetStr that will be filled with the write community name. */ void get_writecommunity( OctetStr &oct) const { oct = write_community; }; /** * Set the write community name. * * @param str - The new write community name */ void set_writecommunity( const char * str) { write_community = str; }; /** * Set the write community name. * * @param oct - The new write community name */ void set_writecommunity( const OctetStr &oct) { write_community = oct; }; /** * Overloaded assignment operator. */ CTarget& operator=( const CTarget& target); /** * Overloeaded compare operator. * * Two CTarget objects are considered equal, if all member variables * and the base classes are equal. * * @return 1 if targets are equal, 0 if not. */ int operator==( const CTarget &rhs) const; /** * Get all values of a CTarget object. * * @param read_comm - Read community name * @param write_comm - Write community name * @param address - Address of the target * @param t - Timeout value * @param r - Retries value * @param v - The SNMP version of this target * * @return TRUE on success and FALSE on failure. */ int resolve_to_C( OctetStr& read_comm, OctetStr& write_comm, GenAddress &address, unsigned long &t, int &r, unsigned char &v) const; /** * Reset the object. */ void clear(); protected: OctetStr read_community; // get community OctetStr write_community; // set community};// create OidCollection typetypedef SnmpCollection<SnmpTarget> TargetCollection;#ifdef _SNMPv3#define INITIAL_USER "initial"#else#define INITIAL_USER "public"#endif//----[ UTarget class ]----------------------------------------------/** * User based Target. * * This class is used for SNMPv3 targets. */class DLLOPT UTarget: public SnmpTarget{ public: /** * Constructor with no args. * The validity of the target will be false. */ UTarget(); /** * Constructor with all args. * * @param address - Address of the target host (cann be any address object) * @param sec_name - The security name * @param sec_model - The security model to use */ UTarget( const Address &address, const char *sec_name, const int sec_model); /** * Constructor with all args. * * @param address - Address of the target host (cann be any address object) * @param sec_name - The security name * @param sec_model - The security model to use */ UTarget( const Address &address, const OctetStr &sec_name, const int sec_model); /** * Constructor with only address. * * Assumes the following defaults: security_name: initial, version: SNMPv3, * security_model: v3MP. * * @param address - Address of the target host (cann be any address object) */ UTarget( const Address &address); /** * Constructor from existing UTarget. */ UTarget( const UTarget &target); /** * Destructor, that has nothing to do. */ ~UTarget() {}; /** * Clone operator. * * Clone operation for creating a new UTarget from an existing * UTarget. * * @note The caller MUST use the delete operation on the return * value when done. * * @return A pointer to the new object on success, 0 on failure. */ SnmpTarget *clone() const { return (SnmpTarget *) new UTarget(*this); }; /** * Set the address object. * * This method is the same as in SnmpTarget, but it deletes engine_id. * * @param address - The address that this target should use. * @return TRUE on success. */ int set_address(const Address &address); /** * Get the security name. * * @return A const reference to the security name. */ const OctetStr& get_security_name() const { return security_name;} ; /** * Get the security name. * * @param oct - OctetStr that will be filled with the security name. */ void get_security_name( OctetStr& oct) const { oct = security_name; }; /** * Set the security name. * * @param str - The new security name */ void set_security_name( const char * str) { security_name = str; }; /** * Set the security name. * * @param oct - The new security name */ void set_security_name( const OctetStr& oct) { security_name = oct; };#ifdef _SNMPv3 /** * Set the engine id. * * In most cases it is not necessary for the user to set the engine * id as snmp++ performs engine id discovery. If the engine id is * set by the user, no engine_id discovery is made, even if the * engine id set by the user is wrong. * * @param str - The engine id to use */ void set_engine_id( const char * str) { engine_id = str; }; /** * Set the engine id. * * In most cases it is not necessary for the user to set the engine * id as snmp++ performs engine id discovery. If the engine id is * set by the user, no engine_id discovery is made, even if the * engine id set by the user is wrong. * * @param oct - The engine id to use */ void set_engine_id( const OctetStr &oct) { engine_id = oct; }; /** * Get the engine id. * * @return A const reference to the enigne id of this target. */ const OctetStr& get_engine_id() const { return engine_id; }; /** * Get the engine id. * * @param oct - OctetStr that will be filled with the engine id */ void get_engine_id( OctetStr& oct) const { oct = engine_id; };#endif /** * Get the security_model. * * @return An integer representing the security_model of this target. */ int get_security_model() const { return security_model; }; /** * Set the security_model. * * @param sec_model - The security model to use. */ void set_security_model(int sec_model) { security_model = sec_model; }; /** * Overloaded assignment operator. */ UTarget& operator=( const UTarget& target); /** * Overloeaded compare operator. * * Two UTarget objects are considered equal, if all member variables * (beside the engine id) and the base classes are equal. * * @return 1 if targets are equal, 0 if not. */ virtual int operator==( const UTarget &rhs) const; /** * Get all values of a UTarget object. * * @param sec_name - security name * @param sec_model - security model * @param address - Address of the target * @param t - Timeout value * @param r - Retries value * @param v - The SNMP version of this target * * @return TRUE on success and FALSE on failure. */ int resolve_to_U( OctetStr& sec_name, int &sec_model, GenAddress &address, unsigned long &t, int &r, unsigned char &v) const; /** * Reset the object. */ void clear(); protected: OctetStr security_name; int security_model;#ifdef _SNMPv3 OctetStr engine_id;#endif};#ifdef SNMP_PP_NAMESPACE}; // end of namespace Snmp_pp#endif #endif //_TARGET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -