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

📄 address.h

📁 JdonFramework need above jdk 1.4.0 This version has passed under Tomcat 4.x/5.x JBoss 3.x/JBoss 4.0
💻 H
📖 第 1 页 / 共 2 页
字号:
/*===================================================================  Copyright (c) 1999  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   makes 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.    SNMP++ A D D R E S S . H  ADDRESS CLASS DEFINITION  VERSION:  2.8  RCS INFO:  $Header: address.h,v 1.36 96/09/11 14:01:20 hmgr Exp $  DESIGN:  Peter E Mellquist  AUTHOR:  Peter E Mellquist  LANGUAGE:  ANSI C++  OPERATING SYSTEMS:  MS-Windows Win32  BSD UNIX  DESCRIPTION:  Address class definition. Encapsulates various network  addresses into easy to use, safe and portable classes.=====================================================================*/#ifndef _ADDRESS#define _ADDRESS//----[ includes ]-----------------------------------------------------extern "C"{#include <string.h>#include <memory.h>}#include "smival.h"#include "collect.h"// include sockets header files// for Windows16 and Windows32 include Winsock// otherwise assume UNIX#ifdef __unix// The /**/ stuff below is meant to fool MS C++ into skipping these // files when creating its makefile.  8-Dec-95 TM#include /**/ <sys/socket.h>#include /**/ <netinet/in.h>#include /**/ <netdb.h>#include /**/ <arpa/inet.h>#include /**/ <unistd.h>typedef in_addr IN_ADDR;extern int h_errno;  // defined in WinSock header, but not for UX?!#endif // __unix#ifdef WIN32#ifndef __unix         // __unix overrides WIN32 if both options are present#include <winsock.h>#endif#endif//----[ macros ]-------------------------------------------------------#define BUFSIZE 40     // worst case of address lens#define OUTBUFF 80     // worst case of output lens#define IPLEN      4#define UDPIPLEN   6#define IPXLEN     10#define IPXSOCKLEN 12#define MACLEN     6#define MAX_FRIENDLY_NAME 80#define HASH0 19#define HASH1 13#define HASH2 7//----[ enumerated types for address types ]---------------------------enum addr_type {  type_ip,  type_ipx,  type_udp,  type_ipxsock,  type_mac,  type_invalid};//---[ forward declarations ]-----------------------------------------class GenAddress; class UdpAddress;class IpxSockAddress;//--------------------------------------------------------------------//----[ Address class ]-----------------------------------------------//--------------------------------------------------------------------class DLLOPT Address: public  SnmpSyntax {public:  // allow destruction of derived classes  virtual ~Address();  // overloaded equivlence operator, are two addresses equal?  DLLOPT friend int operator==( const Address &lhs,const Address &rhs);  // overloaded not equivlence operator, are two addresses not equal?  DLLOPT friend int operator!=( const Address &lhs,const Address &rhs);  // overloaded > operator, is a1 > a2  DLLOPT friend int operator>( const Address &lhs,const Address &rhs);  // overloaded >= operator, is a1 >= a2  DLLOPT friend int operator>=( const Address &lhs,const Address &rhs);  // overloaded < operator, is a1 < a2  DLLOPT friend int operator<( const Address &lhs,const Address &rhs);  // overloaded <= operator, is a1 <= a2  DLLOPT friend int operator<=( const Address &lhs,const Address &rhs);  // equivlence operator overloaded, are an address and a string equal?  DLLOPT friend int operator==( const Address &lhs,const char *rhs);  // overloaded not equivlence operator, are an address and string not equal?  DLLOPT friend int operator!=( const Address &lhs,const char *rhs);  // overloaded < , is an address greater than a string?  DLLOPT friend int operator>( const Address &lhs,const char *rhs);  // overloaded >=, is an address greater than or equal to a string?  DLLOPT friend int operator>=( const Address &lhs,const char *rhs);  // overloaded < , is an address less than a string?  DLLOPT friend int operator<( const Address &lhs,const char *rhs);  // overloaded <=, is an address less than or equal to a string?  DLLOPT friend int operator<=( const Address &lhs,const char *rhs);  // const char * operator overloaded for streaming output  virtual operator const char *() const = 0;  // is the address object valid?  virtual int valid() const;              // syntax type  virtual SmiUINT32 get_syntax() = 0;  // for non const [], allows reading and writing  unsigned char& operator[]( const int position);  // get a printable ASCII value  virtual char *get_printable() = 0;  // create a new instance of this Value  virtual SnmpSyntax *clone() const = 0;  // return the type of address  virtual addr_type get_type() const = 0;   // overloaded assignment operator  virtual SnmpSyntax& operator=( SnmpSyntax &val) = 0;  // return a hash key  virtual unsigned int hashFunction() const { return 0;};protected:  int valid_flag;  unsigned char address_buffer[BUFSIZE]; // internal representation  // parse the address string  // redefined for each specific address subclass  virtual int parse_address( const char * inaddr) =0;  // format the output  // redefined for each specific address subclass  virtual void format_output() =0;  // a reused trimm white space method  void trim_white_space( char * ptr);};//-----------------------------------------------------------------------//---------[ IP Address Class ]------------------------------------------//-----------------------------------------------------------------------class DLLOPT IpAddress : public Address {public:  // construct an IP address with no agrs  IpAddress( void);  // construct an IP address with a string  IpAddress( const char *inaddr);  // construct an IP address with another IP address  IpAddress( const IpAddress  &ipaddr);  // construct an IP address with a GenAddress  IpAddress( const GenAddress &genaddr);  // destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden)  ~IpAddress();  // copy an instance of this Value  SnmpSyntax& operator=( SnmpSyntax &val);  // assignment to another IpAddress object overloaded  IpAddress& operator=( const IpAddress &ipaddress);  // create a new instance of this Value  SnmpSyntax *clone() const;  // return the friendly name  // returns a NULL string if there isn't one  char *friendly_name(int &status);  virtual char *get_printable() ;  // const char * operator overloaded for streaming output  virtual operator const char *() const;  // logically AND two IPaddresses and  // return the new one  void mask( const IpAddress& ipaddr);  // return the type  virtual addr_type get_type() const;  // syntax type  virtual SmiUINT32 get_syntax();protected:  char output_buffer[OUTBUFF];           // output buffer  // friendly name storage  char iv_friendly_name[MAX_FRIENDLY_NAME];  int  iv_friendly_name_status;  // 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();  // parse a dotted string  int parse_dotted_ipstring( const char *inaddr);  // using the currently defined address, do a DNS  // and try to fill up the name  int addr_to_friendly();};//------------------------------------------------------------------------//---------[ UDP Address Class ]------------------------------------------//------------------------------------------------------------------------class DLLOPT UdpAddress : public IpAddress {public:  // constructor, no args  UdpAddress( void);  // constructor with a dotted string  UdpAddress( const char *inaddr);  // construct an Udp address with another Udp address  UdpAddress( const UdpAddress &udpaddr);

⌨️ 快捷键说明

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