71 #if defined (CPU) && CPU == PPC603
80 #include <sys/socket.h>
81 #include <netinet/in.h>
83 #include <arpa/inet.h>
88 #if !defined __CYGWIN32__ && !defined __hpux && !defined linux && !defined _AIX
93 #ifdef SNMP_PP_NAMESPACE
98 #define ADDRBUF 50 // worst case of address lens
99 #define OUTBUFF 80 // worst case of output lens
103 #define IP6LEN_NO_SCOPE 16
104 #define IP6LEN_WITH_SCOPE 20
105 #define UDPIP6LEN_NO_SCOPE 18
106 #define UDPIP6LEN_WITH_SCOPE 22
107 #define IS_IP6LEN(n) ((n==16) || (n==20))
108 #define IS_UDPIP6LEN(n) ((n==18) || (n==22))
110 #define IPXSOCKLEN 12
112 #define MAX_FRIENDLY_NAME 80
113 #define PP_MAC_HASH0 19
114 #define PP_MAC_HASH1 13
115 #define PP_MAC_HASH2 7
169 {
return !(lhs == rhs); }
176 {
if ((lhs > rhs) || (lhs == rhs))
return true;
return false; }
183 {
if ((lhs < rhs) || (lhs == rhs))
return true;
return false; }
190 {
return !(lhs == rhs); }
209 virtual operator const char *()
const = 0;
257 using SnmpSyntax::operator =;
342 using Address::operator =;
373 char *friendly_name(
int &status);
381 {
if (addr_changed) format_output();
return output_buffer; }
388 virtual operator const char *()
const
389 {
if (addr_changed) format_output();
return output_buffer; }
404 int get_match_bits(
const IpAddress match_ip)
const;
410 {
return (ip_version == version_ipv4) ?
IPLEN :
431 {
return get_length() + 2; }
445 virtual bool map_to_ipv6();
450 virtual unsigned int get_scope()
const;
455 virtual bool set_scope(
const unsigned int scope);
463 {
return (ip_version == version_ipv6) && have_ipv6_scope; }
474 virtual bool parse_address(
const char *inaddr);
478 virtual void format_output()
const;
481 int parse_dotted_ipstring(
const char *inaddr);
484 int parse_coloned_ipstring(
const char *inaddr);
488 int addr_to_friendly();
548 using IpAddress::operator =;
595 {
if (addr_changed) format_output();
return output_buffer; }
602 virtual operator const char *()
const
603 {
if (addr_changed) format_output();
return output_buffer; }
610 void set_port(
const unsigned short p);
617 unsigned short get_port()
const;
623 {
return (ip_version == version_ipv4) ?
UDPIPLEN :
638 virtual bool map_to_ipv6();
644 {
Address::clear(); memset(output_buffer, 0,
sizeof(output_buffer)); }
649 virtual bool set_scope(
const unsigned int scope);
657 virtual bool parse_address(
const char *inaddr);
661 virtual void format_output()
const;
675 MacAddress(
const char *inaddr);
678 MacAddress(
const MacAddress &macaddr);
696 virtual int get_asn1_length()
const {
return MACLEN + 2; }
698 using Address::operator =;
705 MacAddress& operator=(
const MacAddress &macaddress);
719 virtual const char *get_printable()
const
720 {
if (addr_changed) format_output();
return output_buffer; }
727 virtual operator const char *()
const
728 {
if (addr_changed) format_output();
return output_buffer; }
733 virtual int get_length()
const {
return MACLEN; }
740 virtual addr_type get_type()
const {
return type_mac; }
743 unsigned int hashFunction()
const;
749 {
Address::clear(); memset(output_buffer, 0,
sizeof(output_buffer)); }
755 virtual bool parse_address(
const char *inaddr);
758 virtual void format_output()
const;
760 #endif // _MAC_ADDRESS
773 IpxAddress(
const char *inaddr);
776 IpxAddress(
const IpxAddress &ipxaddr);
794 virtual int get_asn1_length()
const {
return IPXLEN + 2; }
796 using Address::operator =;
803 virtual IpxAddress& operator=(
const IpxAddress &ipxaddress);
807 int get_hostid(MacAddress& mac)
const;
822 virtual const char *get_printable()
const
823 {
if (addr_changed) format_output();
return output_buffer; }
830 virtual operator const char *()
const
831 {
if (addr_changed) format_output();
return output_buffer; }
836 virtual int get_length()
const {
return IPXLEN; }
843 virtual addr_type get_type()
const {
return type_ipx; }
849 {
Address::clear(); memset(output_buffer, 0,
sizeof(output_buffer)); }
857 virtual bool parse_address(
const char *inaddr);
861 virtual void format_output()
const;
870 class DLLOPT IpxSockAddress :
public IpxAddress {
877 IpxSockAddress(
const char *inaddr);
880 IpxSockAddress(
const IpxSockAddress &ipxaddr);
887 IpxSockAddress(
const IpxAddress &ipxaddr);
898 virtual int get_asn1_length()
const {
return IPXSOCKLEN + 2; }
900 using IpxAddress::operator =;
907 virtual IpxSockAddress& operator=(
const IpxSockAddress &ipxaddr);
917 void set_socket(
const unsigned short s);
920 unsigned short get_socket()
const;
927 virtual const char *get_printable()
const
928 {
if (addr_changed) format_output();
return output_buffer; }
935 virtual operator const char *()
const
936 {
if (addr_changed) format_output();
return output_buffer; }
941 virtual int get_length()
const {
return IPXSOCKLEN; }
948 virtual addr_type get_type()
const {
return type_ipxsock; }
954 {
Address::clear(); memset(output_buffer, 0,
sizeof(output_buffer)); }
960 virtual bool parse_address(
const char *inaddr);
964 virtual void format_output()
const;
966 #endif // _IPX_ADDRESS
1028 {
return address ? address->get_asn1_length() : 2; }
1037 using Address::operator =;
1059 {
return (address) ? address->get_printable() : output_buffer; }
1066 virtual operator const char *()
const
1067 {
return address ? (
const char *)*address : output_buffer; }
1073 {
return (address) ? address->get_length() : 0; }
1078 void clear() {
if (address) address->clear(); }
1087 {
return (valid()) ? address->get_type() : type_invalid; }
1109 const MacAddress &cast_macaddress()
const {
return (MacAddress&)*address; }
1118 const IpxAddress &cast_ipxaddress()
const {
return (IpxAddress&)*address; }
1125 const IpxSockAddress &cast_ipxsockaddress()
const
1126 {
return (IpxSockAddress&)*address; }
1132 char output_buffer[1];
1138 virtual bool parse_address(
const char *addr,
1154 #ifdef SNMP_PP_NAMESPACE
SNMP_PP_MUTABLE bool addr_changed
virtual void format_output() const
virtual version_type get_ip_version() const
Return the IP version of the address.
~IpAddress()
Destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden).
#define IP6LEN_WITH_SCOPE
unsigned char & operator[](const int position)
Access as an array (read and write).
SmiUINT32 get_syntax() const
Return the syntax.
#define UDPIP6LEN_WITH_SCOPE
virtual bool valid() const
Return if the object contains a valid address.
virtual SmiUINT32 get_syntax() const
Return the syntax.
#define sNMP_SYNTAX_IPADDR
void clear()
Reset the object.
virtual const char * get_printable() const
Get a printable ASCII value of the address.
DLLOPT friend int operator!=(const Address &lhs, const Address &rhs)
overloaded not equivlence operator, are two addresses not equal?
#define sNMP_SYNTAX_OCTETS
DLLOPT friend int operator<=(const Address &lhs, const Address &rhs)
overloaded <= operator, is a1 <= a2
UdpAddress (IPv4 or IPv6)
virtual int get_asn1_length() const
Return the space needed for serialization.
int iv_friendly_name_status
virtual GenAddress & operator=(const GenAddress &addr)
Overloaded assignment operator for a GenAddress.
void trim_white_space(char *ptr)
Trim of whitespaces at the start and the end of the string.
#define MAX_FRIENDLY_NAME
DLLOPT friend int operator!=(const Address &lhs, const char *rhs)
overloaded not equivlence operator, are an address and string not equal?
SnmpCollection< GenAddress > AddressCollection
SmiUINT32 get_syntax() const
Return the syntax.
virtual const char * get_printable() const
Get a printable ASCII value of the address.
Base class of all Address classes.
addr_type
Type returned by Address::get_type().
virtual addr_type get_type() const
Return the type of the address.
SnmpCollection< UdpAddress > UdpAddressCollection
virtual unsigned int hashFunction() const
const UdpAddress & cast_udpaddress() const
Access the protected address.
bool has_ipv6_scope() const
virtual bool is_gen_address() const
Is this a GenAddress object.
Used by GenAddress::get_type() if address is not valid.
const IpAddress & cast_ipaddress() const
Access the protected address.
virtual int get_length() const
Get the length of the binary address (accessible through operator[]).
void clear()
Reset the object.
virtual ~Address()
Allow destruction of derived classes.
unsigned char operator[](const int position) const
Access as an array (read only).
virtual int get_asn1_length() const
Return the space needed for serialization.
DLLOPT friend int operator>(const Address &lhs, const Address &rhs)
overloaded > operator, is a1 > a2
#define UDPIP6LEN_NO_SCOPE
virtual addr_type get_type() const
Return the type of the address.
virtual const char * get_printable() const
Get a printable ASCII value of the address.
virtual int get_asn1_length() const
Return the space needed for serialization.
unsigned char address_buffer[ADDRBUF]
DLLOPT friend int operator<(const Address &lhs, const Address &rhs)
overloaded < operator, is a1 < a2
SnmpSyntax * clone() const
Clone this object.
SnmpSyntax * clone() const
Clone this object.
virtual int get_length() const
Get the length of the binary address (accessible through operator[]).
struct sockaddr_in ipaddr
Address()
Default constructor, clears the buffer and sets valid flag to false.
DLLOPT friend int operator>=(const Address &lhs, const Address &rhs)
overloaded >= operator, is a1 >= a2
virtual bool parse_address(const char *addr)
virtual addr_type get_type() const
Return the type of the address.
An "abstract" (pure virtual) class that serves as the base class for all specific SNMP syntax types...
~GenAddress()
Destructor, free memory.
virtual bool is_gen_address() const
Is this a GenAddress object.
DLLOPT friend int operator==(const Address &lhs, const Address &rhs)
overloaded equivlence operator, are two addresses equal?
SnmpSyntax * clone() const
Clone this object.
void clear()
Reset the object.
version_type
Type returned by IpAddress::get_ip_version() and UdpAddress::get_ip_version().
virtual int get_length() const
Get the length of the binary address (accessible through operator[]).
~UdpAddress()
Destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden).