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

📄 address.h

📁 SNMP的一个例子
💻 H
📖 第 1 页 / 共 2 页
字号:

  // construct a Udp address with a GenAddress
  UdpAddress( const GenAddress &genaddr);

  // construct a Udp address with an IpAddress
  // default port # to zero
  UdpAddress( const IpAddress &ipaddr);

  // destructor
  ~UdpAddress();

  // syntax type
  SmiUINT32 get_syntax();

  // copy an instance of this Value
  SnmpSyntax& operator=( SnmpSyntax &val);

  // assignment to another IpAddress object overloaded
  UdpAddress& operator=( const UdpAddress &udpaddr);

  // create a new instance of this Value
  SnmpSyntax *clone() const;

  virtual char *get_printable() ;

  // const char * operator overloaded for streaming output
  virtual operator const char *() const;

  // set the port number
  void set_port( const unsigned short p);

  // get the port number
  unsigned short get_port() const; 

  // return the type
  virtual addr_type get_type() const;

protected:
  char output_buffer[OUTBUFF];           // output buffer

  // redefined parse address
  // specific to IP addresses
  virtual int parse_address( const char *inaddr);

  // redefined format output
  // specific to IP addresses
  virtual void format_output();
};

//-------------------------------------------------------------------------
//---------[ 802.3 MAC Address Class ]-------------------------------------
//-------------------------------------------------------------------------
class DLLOPT MacAddress : public Address {

public:
  // constructor, no arguments
  MacAddress( void);

  // constructor with a string argument
  MacAddress( const char  *inaddr);

  // constructor with another MAC object
  MacAddress( const MacAddress  &macaddr);

  // construct a MacAddress with a GenAddress
  MacAddress( const GenAddress &genaddr);

  // destructor 
  ~MacAddress();

  // syntax type
  SmiUINT32 get_syntax();

  // copy an instance of this Value
  SnmpSyntax& operator=( SnmpSyntax &val);

  // assignment to another IpAddress object overloaded
  MacAddress& operator=( const MacAddress &macaddress);

  // create a new instance of this Value
  SnmpSyntax *clone() const; 

  virtual char *get_printable();

  // const char * operator overloaded for streaming output
  virtual operator const char *() const;

  // return the type
  virtual addr_type get_type() const;

  // return a hash key
  unsigned int hashFunction() const;


protected:
  char output_buffer[OUTBUFF];           // output buffer

  // redefined parse address for macs
  virtual int parse_address( const char *inaddr);

  // redefined format output for MACs
  virtual void format_output();
};

//------------------------------------------------------------------------
//---------[ IPX Address Class ]------------------------------------------
//------------------------------------------------------------------------
class DLLOPT IpxAddress : public Address {

public:
  // constructor no args
  IpxAddress( void);

  // constructor with a string arg
  IpxAddress( const char  *inaddr);

  // constructor with another ipx object
  IpxAddress( const IpxAddress  &ipxaddr);

  // construct with a GenAddress
  IpxAddress( const GenAddress &genaddr);

  // destructor 
  ~IpxAddress();

  // syntax type
  virtual SmiUINT32 get_syntax();

  // copy an instance of this Value
  SnmpSyntax& operator=( SnmpSyntax &val); 

  // assignment to another IpAddress object overloaded
  IpxAddress& operator=( const IpxAddress &ipxaddress);

  // get the host id portion of an ipx address
  int get_hostid( MacAddress& mac);

  // create a new instance of this Value
  SnmpSyntax *clone() const; 

  virtual char *get_printable();

  // const char * operator overloaded for streaming output
  virtual operator const char *() const;

  // return the type
  virtual addr_type get_type() const;

protected:
  // ipx format separator
  char separator;
  char output_buffer[OUTBUFF];           // output buffer

  // redefined parse address for ipx strings
  virtual int parse_address( const char  *inaddr);

  // redefined format output for ipx strings
  // uses same separator as when constructed
  virtual void format_output();
 
};



//------------------------------------------------------------------------
//---------[ IpxSock Address Class ]--------------------------------------
//------------------------------------------------------------------------
class DLLOPT IpxSockAddress : public IpxAddress {

public:
  // constructor, no args
  IpxSockAddress( void);

  // constructor with a dotted string
  IpxSockAddress( const char *inaddr);

  // construct an Udp address with another Udp address
  IpxSockAddress( const IpxSockAddress &ipxaddr);

  //constructor with a GenAddress
  IpxSockAddress( const GenAddress &genaddr);

  //constructor with a IpxAddress
  // default socket # is 0
  IpxSockAddress( const IpxAddress &ipxaddr);

  // destructor
  ~IpxSockAddress();

  // syntax type
  virtual SmiUINT32 get_syntax();

  // copy an instance of this Value
  SnmpSyntax& operator=( SnmpSyntax &val); 

  // assignment to another IpAddress object overloaded
  IpxSockAddress& operator=( const IpxSockAddress &ipxaddr);

  // create a new instance of this Value
  SnmpSyntax *clone() const;

  // set the socket number
  void set_socket( const unsigned short s);

  // get the socket number
  unsigned short get_socket() const;

  virtual char *get_printable();

  // const char * operator overloaded for streaming output
  virtual operator const char *() const;

  // return the type
  virtual addr_type get_type() const;

protected:
  char output_buffer[OUTBUFF];           // output buffer

  // redefined parse address for ipx strings
  virtual int parse_address( const char  *inaddr);

  // redefined format output
  // specific to IP addresses
  virtual void format_output();

};




//-------------------------------------------------------------------------
//--------[ Generic Address ]----------------------------------------------
//-------------------------------------------------------------------------
class DLLOPT GenAddress : public Address {

public:
  // constructor, no arguments
  GenAddress( void);

  // constructor with a string argument
  GenAddress( const char  *addr);

  // constructor with an Address
  GenAddress( const Address &addr);

  // constructor with another GenAddress
  GenAddress( const GenAddress &addr);

  // destructor
  ~GenAddress();

  // get the snmp syntax of the contained address
  SmiUINT32 get_syntax();

  // create a new instance of this Value
  SnmpSyntax *clone() const;

  // assignment of a GenAddress
  GenAddress& operator=( const GenAddress &addr);

  // copy an instance of this Value
  SnmpSyntax& operator=( SnmpSyntax &val);

  virtual char *get_printable();

  // const char * operator overloaded for streaming output
  virtual operator const char *() const;

  // return the type
  virtual addr_type get_type() const;

protected:
  // pointer to a a concrete address
  Address *address;
  char output_buffer[OUTBUFF];           // output buffer

  // redefined parse address for macs
  virtual int parse_address( const char *addr);

  // format output for a generic address
  virtual void format_output();

};

// create OidCollection type
typedef SnmpCollection <GenAddress> AddressCollection;

#endif  //_ADDRESS

⌨️ 快捷键说明

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