Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

IpAddress Class Reference

#include <address.h>

Inheritance diagram for IpAddress:

[legend]
Collaboration diagram for IpAddress:
[legend]
List of all members.

Public Member Functions

 IpAddress ()
 Construct an empty invalid IP address.

 IpAddress (const char *inaddr)
 Construct an IP address from a string.

 IpAddress (const IpAddress &ipaddr)
 Construct an IP address from another IP address.

 IpAddress (const GenAddress &genaddr)
 Construct an IP address from a GenAddress.

 ~IpAddress ()
 Destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden).

SnmpSyntaxoperator= (const SnmpSyntax &val)
 Map other SnmpSyntax objects to IpAddress.

IpAddressoperator= (const IpAddress &ipaddress)
 Overloaded assignment operator for other IP addresses.

IpAddressoperator= (const char *inaddr)
 Overloaded assignment operator for strings.

SnmpSyntaxclone () const
 Clone this object.

char * friendly_name (int &status)
 Return the friendly name.

virtual const char * get_printable () const
 Get a printable ASCII value of the address.

virtual operator const char * () const
 Overloaded operator for streaming output.

void mask (const IpAddress &ipaddr)
 Logically AND the address with the param.

virtual int get_length () const
 Get the length of the binary address (accessible through operator[]).

virtual addr_type get_type () const
 Return the type of the address.

virtual SmiUINT32 get_syntax () const
 Return the syntax.

virtual int get_asn1_length () const
 Return the space needed for serialization.

virtual version_type get_ip_version () const
 Return the IP version of the address.

virtual int map_to_ipv6 ()
 Map a IPv4 address to a IPv6 address.

void clear ()
 Reset the object.


Protected Member Functions

virtual bool parse_address (const char *inaddr)
virtual void format_output () const
int parse_dotted_ipstring (const char *inaddr)
int parse_coloned_ipstring (const char *inaddr)
int addr_to_friendly ()

Protected Attributes

char output_buffer [OUTBUFF]
char iv_friendly_name [MAX_FRIENDLY_NAME]
int iv_friendly_name_status
version_type ip_version

Constructor & Destructor Documentation

IpAddress::IpAddress  ) 
 

Construct an empty invalid IP address.

IpAddress::IpAddress const char *  inaddr  ) 
 

Construct an IP address from a string.

The following formats can be used:

  • hostname with or without domain ("www.agentpp.com", "printsrv")
  • Numerical IPv4 address ("192.168.17.1")
  • Numerical IPv6 address ("abcd:1234::a:b:1", "::abcd:1")

Parameters:
inaddr - Hostname or IP address

IpAddress::IpAddress const IpAddress ipaddr  ) 
 

Construct an IP address from another IP address.

Parameters:
ipaddr - address to copy

IpAddress::IpAddress const GenAddress genaddr  ) 
 

Construct an IP address from a GenAddress.

Parameters:
genaddr - address to copy

IpAddress::~IpAddress  )  [inline]
 

Destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden).

Definition at line 347 of file address.h.


Member Function Documentation

int IpAddress::addr_to_friendly  )  [protected]
 

void IpAddress::clear  )  [virtual]
 

Reset the object.

Reimplemented from Address.

Reimplemented in UdpAddress.

SnmpSyntax* IpAddress::clone  )  const [inline, virtual]
 

Clone this object.

Returns:
Pointer to the newly created object (allocated through new).

Implements SnmpSyntax.

Reimplemented in UdpAddress.

Definition at line 369 of file address.h.

virtual void IpAddress::format_output  )  const [protected, virtual]
 

Implements Address.

Reimplemented in UdpAddress.

char* IpAddress::friendly_name int &  status  ) 
 

Return the friendly name.

Does a reverse DNS lookup for the IP address.

Parameters:
status - The errno value for the lookup
Returns:
the friendly name or a zero length string (no null pointer)

virtual int IpAddress::get_asn1_length  )  const [inline, virtual]
 

Return the space needed for serialization.

Implements Address.

Reimplemented in UdpAddress.

Definition at line 426 of file address.h.

References IP6LEN, and IPLEN.

virtual version_type IpAddress::get_ip_version  )  const [inline, virtual]
 

Return the IP version of the address.

Returns:
one of Address::version_type

Definition at line 434 of file address.h.

virtual int IpAddress::get_length  )  const [inline, virtual]
 

Get the length of the binary address (accessible through operator[]).

Implements Address.

Reimplemented in UdpAddress.

Definition at line 406 of file address.h.

References IP6LEN, and IPLEN.

virtual const char* IpAddress::get_printable  )  const [inline, virtual]
 

Get a printable ASCII value of the address.

Returns:
String containing the numerical address

Implements SnmpSyntax.

Reimplemented in UdpAddress.

Definition at line 385 of file address.h.

virtual SmiUINT32 IpAddress::get_syntax  )  const [inline, virtual]
 

Return the syntax.

Returns:
This method always returns sNMP_SYNTAX_IPADDR.

Implements SnmpSyntax.

Reimplemented in UdpAddress.

Definition at line 421 of file address.h.

References SmiUINT32, and sNMP_SYNTAX_IPADDR.

virtual addr_type IpAddress::get_type  )  const [inline, virtual]
 

Return the type of the address.

See also:
Address::addr_type
Returns:
Always Address:type_ip

Implements Address.

Reimplemented in UdpAddress.

Definition at line 414 of file address.h.

virtual int IpAddress::map_to_ipv6  )  [virtual]
 

Map a IPv4 address to a IPv6 address.

Returns:
- TRUE if no error occured.

Reimplemented in UdpAddress.

void IpAddress::mask const IpAddress ipaddr  ) 
 

Logically AND the address with the param.

Parameters:
ipaddr - address to use as mask

virtual IpAddress::operator const char *  )  const [inline, virtual]
 

Overloaded operator for streaming output.

Returns:
String containing the numerical address

Implements Address.

Reimplemented in UdpAddress.

Definition at line 393 of file address.h.

IpAddress& IpAddress::operator= const char *  inaddr  ) 
 

Overloaded assignment operator for strings.

Reimplemented in UdpAddress.

IpAddress& IpAddress::operator= const IpAddress ipaddress  ) 
 

Overloaded assignment operator for other IP addresses.

Reimplemented in UdpAddress.

SnmpSyntax& IpAddress::operator= const SnmpSyntax val  )  [virtual]
 

Map other SnmpSyntax objects to IpAddress.

Implements Address.

Reimplemented in UdpAddress.

virtual bool IpAddress::parse_address const char *  inaddr  )  [protected, virtual]
 

Implements Address.

Reimplemented in UdpAddress.

int IpAddress::parse_coloned_ipstring const char *  inaddr  )  [protected]
 

int IpAddress::parse_dotted_ipstring const char *  inaddr  )  [protected]
 


Member Data Documentation

version_type IpAddress::ip_version [protected]
 

Definition at line 474 of file address.h.

char IpAddress::iv_friendly_name[MAX_FRIENDLY_NAME] [protected]
 

Definition at line 452 of file address.h.

int IpAddress::iv_friendly_name_status [protected]
 

Definition at line 453 of file address.h.

char IpAddress::output_buffer[OUTBUFF] [protected]
 

Reimplemented in UdpAddress.

Definition at line 449 of file address.h.


The documentation for this class was generated from the following file:
Generated on Tue Jan 4 22:42:18 2005 for SNMP++ by doxygen 1.3.2