internet_address Class Reference

#include <address.h>

Inheritance diagram for internet_address:

Inheritance graph
[legend]
Collaboration diagram for internet_address:

Collaboration graph
[legend]
List of all members.

Public Types

enum  internet_address_constraints { ADDRESS_SIZE = 4, MAXIMUM_HOSTNAME_LENGTH = 128 }
typedef byte address_array [ADDRESS_SIZE]

Public Member Functions

 internet_address ()
 internet_address (const byte_array &ip_address, const istring &host, int port)
 IMPLEMENT_CLASS_NAME ("internet_address")
machine_uid convert () const
void fill (const byte_array &ip_address, const istring &host, int port)
bool same_host (const address_base &to_compare) const
bool same_port (const address_base &to_compare) const
bool shareable (const address_base &to_compare) const
bool operator== (const internet_address &to_compare) const
istring text_form () const
 Provides a text view of all the important info owned by this object.
istring tokenize () const
bool detokenize (const istring &info)
istring normalize_host () const
bool is_nil_address () const
bool is_localhost () const
address_basecreate_copy () const
void pack (byte_array &packed_form) const
 Creates a packed form of the packable object in "packed_form".
bool unpack (byte_array &packed_form)
 Restores the packable from the "packed_form".
virtual int packed_size () const
 Estimates the space needed for the packed structure.

Static Public Member Functions

static const byte_arraynil_address ()
static bool is_nil_address (const address_array &ip_address)
static bool valid_address (const istring &to_check)
static bool is_valid_internet_address (const istring &to_check, byte_array &ip_form, bool &all_zeros)
static bool ip_appropriate_number (const istring &to_check, int indy, istring &accum)
 returns true if "to_check" has a number at "indy" that works in ipv4.
static bool has_ip_address (const istring &to_check, istring &ip_found)
 returns true if "to_check" has an IP address in it somewhere.
static istring ip_address_text_form (const byte_array &ip_address)
static const byte_arraylocalhost ()

Public Attributes

address_array ip_address
int port
char hostname [MAXIMUM_HOSTNAME_LENGTH]

Detailed Description

Definition at line 38 of file address.h.


Member Typedef Documentation

typedef byte internet_address::address_array[ADDRESS_SIZE]

Definition at line 46 of file address.h.


Member Enumeration Documentation

enum internet_address::internet_address_constraints

Enumerator:
ADDRESS_SIZE 
MAXIMUM_HOSTNAME_LENGTH 

Definition at line 41 of file address.h.


Constructor & Destructor Documentation

internet_address::internet_address (  ) 

Definition at line 370 of file address.cpp.

References fill().

Referenced by create_copy().

internet_address::internet_address ( const byte_array ip_address,
const istring host,
int  port 
)

Definition at line 372 of file address.cpp.

References fill().


Member Function Documentation

internet_address::IMPLEMENT_CLASS_NAME ( "internet_address"   ) 

machine_uid internet_address::convert (  )  const [virtual]

Implements address_base.

Definition at line 380 of file address.cpp.

References ADDRESS_SIZE, hostname, and ip_address.

Referenced by cromp_common::chew_hostname(), tcpip_stack::enumerate_adapters(), and ip_appropriate_number().

void internet_address::fill ( const byte_array ip_address,
const istring host,
int  port 
)

Definition at line 510 of file address.cpp.

References ADDRESS_SIZE, hostname, ip_address, array< contents >::length(), MAXIMUM_HOSTNAME_LENGTH, minimum(), port, and istring::stuff().

Referenced by tcpip_stack::convert(), detokenize(), tcpip_stack::fill_and_resolve(), and internet_address().

bool internet_address::same_host ( const address_base to_compare  )  const [virtual]

Implements address_base.

Definition at line 562 of file address.cpp.

References ADDRESS_SIZE, CAST_UP, hostname, ip_address, and is_nil_address().

bool internet_address::same_port ( const address_base to_compare  )  const [virtual]

Implements address_base.

Definition at line 596 of file address.cpp.

References CAST_UP, and port.

bool internet_address::shareable ( const address_base to_compare  )  const [virtual]

Implements address_base.

Definition at line 602 of file address.cpp.

bool internet_address::operator== ( const internet_address to_compare  )  const [inline]

Definition at line 69 of file address.h.

References address_base::same_host(), and address_base::same_port().

istring internet_address::text_form (  )  const [virtual]

Provides a text view of all the important info owned by this object.

It is understood that there could be a large amount of information and that this function might take a relatively long time to complete. The information can be provided in multiple lines if desired (it is good to use log_base::platform_ending() for the line breaks to help to ensure that the text is formatted appropriately). the default is quite lame and should be overridden.

Implements address_base.

Definition at line 527 of file address.cpp.

References ADDRESS_SIZE, hostname, ip_address, and port.

Referenced by spocket::accept(), cromp_common::chew_hostname(), spocket::connect(), detokenize(), cromp_server::enable_servers(), cromp_common::open_common(), and spocket::text_form().

istring internet_address::tokenize (  )  const [virtual]

Implements address_base.

Definition at line 645 of file address.cpp.

References ADD, ADDRESS_SIZE, DUMP_EXIT, FUNCDEF, hostname, ip_address, LOG, port, and STORER_ENTRY.

bool internet_address::detokenize ( const istring info  )  [virtual]

Implements address_base.

Definition at line 605 of file address.cpp.

References ADDRESS_SIZE, fill(), FIND, FUNCDEF, GRAB, LOADER_ENTRY, LOADER_EXIT, LOG, port, and text_form().

istring internet_address::normalize_host (  )  const

Definition at line 471 of file address.cpp.

References ADDRESS_SIZE, hostname, ip_address, ip_address_text_form(), and istring::t().

Referenced by cromp_common::chew_hostname(), and network_address::unified_hostname().

static const byte_array& internet_address::nil_address (  )  [static]

Referenced by tcpip_stack::fill_and_resolve(), and tcpip_stack::full_resolve().

bool internet_address::is_nil_address (  )  const

Referenced by spocket::connect(), and same_host().

bool internet_address::is_nil_address ( const address_array ip_address  )  [static]

Definition at line 549 of file address.cpp.

References ADDRESS_SIZE.

bool internet_address::valid_address ( const istring to_check  )  [static]

Definition at line 705 of file address.cpp.

References is_valid_internet_address().

Referenced by main().

bool internet_address::is_valid_internet_address ( const istring to_check,
byte_array ip_form,
bool &  all_zeros 
) [static]

Definition at line 672 of file address.cpp.

References ADDRESS_SIZE, array< contents >::length(), NIL, array< contents >::reset(), and istring::s().

Referenced by tcpip_stack::fill_and_resolve(), and valid_address().

bool internet_address::ip_appropriate_number ( const istring to_check,
int  indy,
istring accum 
) [static]

returns true if "to_check" has a number at "indy" that works in ipv4.

this reports if the string at the position specified could be part of a valid internet address. the characters starting at the "indy" must be numeric. up to three numbers will be checked, and when we get three or less of the numbers together, we will check that they make an integer less than 255. the "accum" string will be filled with the number we found. note that this doesn't care what the characters are after our 1-3 numbers; it merely checks whether the portion of the string at "indy" *could* work in an IP address.

Definition at line 383 of file address.cpp.

References istring::convert(), convert(), FUNCDEF, parser_bits::is_numeric(), istring::length(), and istring::reset().

Referenced by has_ip_address().

bool internet_address::has_ip_address ( const istring to_check,
istring ip_found 
) [static]

returns true if "to_check" has an IP address in it somewhere.

this looks across the whole string and returns the first IP address it finds in "ip_found", if possible.

Definition at line 405 of file address.cpp.

References istring::find(), FUNCDEF, ip_appropriate_number(), parser_bits::is_numeric(), istring::length(), negative(), istring::reset(), and istring::substring().

istring internet_address::ip_address_text_form ( const byte_array ip_address  )  [static]

Definition at line 712 of file address.cpp.

References ip_address.

Referenced by normalize_host().

static const byte_array& internet_address::localhost (  )  [static]

Referenced by cromp_common::cromp_common(), tcpip_stack::fill_and_resolve(), and tcpip_stack::full_resolve().

bool internet_address::is_localhost (  )  const

address_base * internet_address::create_copy (  )  const [virtual]

Implements address_base.

Definition at line 521 of file address.cpp.

References ADDRESS_SIZE, hostname, internet_address(), ip_address, and port.

void internet_address::pack ( byte_array packed_form  )  const [virtual]

Creates a packed form of the packable object in "packed_form".

This must append to the data in "packed_form" rather than clearing prior contents.

Implements packable.

Definition at line 489 of file address.cpp.

References ADDRESS_SIZE, basis::attach(), hostname, ip_address, MAXIMUM_HOSTNAME_LENGTH, and port.

bool internet_address::unpack ( byte_array packed_form  )  [virtual]

Restores the packable from the "packed_form".

This object becomes the unpacked form, and therefore must lose any of its prior contents that depend on the data in "packed_form". This is up to the derived unpack function to figure out. The "packed_form" is modified by extracting all of the pieces that are used for this object; the remainder stays in "packed_form". true is returned if the unpacking was successful.

Implements packable.

Definition at line 496 of file address.cpp.

References ADDRESS_SIZE, basis::detach(), hostname, ip_address, array< contents >::length(), MAXIMUM_HOSTNAME_LENGTH, port, array< contents >::stuff(), and array< contents >::zap().

int internet_address::packed_size (  )  const [virtual]

Estimates the space needed for the packed structure.

Implements address_base.

Definition at line 482 of file address.cpp.

References ADDRESS_SIZE, MAXIMUM_HOSTNAME_LENGTH, and port.


Member Data Documentation

address_array internet_address::ip_address

Definition at line 47 of file address.h.

Referenced by spocket::connect(), tcpip_stack::convert(), convert(), create_copy(), fill(), ip_address_text_form(), normalize_host(), pack(), tcpip_stack::resolve_any(), same_host(), text_form(), tokenize(), and unpack().

int internet_address::port

Definition at line 48 of file address.h.

Referenced by cromp_common::chew_hostname(), tcpip_stack::convert(), create_copy(), detokenize(), fill(), pack(), packed_size(), same_port(), text_form(), tokenize(), and unpack().

char internet_address::hostname[MAXIMUM_HOSTNAME_LENGTH]

Definition at line 50 of file address.h.

Referenced by cromp_common::chew_hostname(), spocket::connect(), convert(), create_copy(), tcpip_stack::enumerate_adapters(), fill(), normalize_host(), pack(), tcpip_stack::resolve_any(), same_host(), text_form(), tokenize(), and unpack().


The documentation for this class was generated from the following files:
Generated on Fri Aug 29 04:30:33 2008 for HOOPLE Libraries by  doxygen 1.5.1