feisty meow concerns codebase  2.140
sockets::internet_address Class Reference

this type of address describes a destination out on the internet. More...

#include <internet_address.h>

Inheritance diagram for sockets::internet_address:
Collaboration diagram for sockets::internet_address:

Public Types

enum  internet_address_constraints { ADDRESS_SIZE = 4 , MAXIMUM_HOSTNAME_LENGTH = 128 }
 
typedef basis::abyte address_array[ADDRESS_SIZE]
 

Public Member Functions

 internet_address ()
 
 internet_address (const basis::byte_array &ip_address, const basis::astring &host, int port)
 
 DEFINE_CLASS_NAME ("internet_address")
 
machine_uid convert () const
 
void fill (const basis::byte_array &ip_address, const basis::astring &host, int port)
 
bool same_host (const base_address &to_compare) const
 
bool same_port (const base_address &to_compare) const
 
bool shareable (const base_address &to_compare) const
 
bool operator== (const internet_address &to_compare) const
 
basis::astring text_form () const
 
basis::astring tokenize () const
 
bool detokenize (const basis::astring &info)
 
basis::astring normalize_host () const
 
bool is_nil_address () const
 
bool is_localhost () const
 
base_addresscreate_copy () const
 
void pack (basis::byte_array &packed_form) const
 Creates a packed form of the packable object in "packed_form". More...
 
bool unpack (basis::byte_array &packed_form)
 Restores the packable from the "packed_form". More...
 
virtual int packed_size () const
 Estimates the space needed for the packed structure. More...
 
- Public Member Functions inherited from basis::nameable
virtual const char * class_name () const =0
 Returns the bare name of this class as a constant character pointer. More...
 

Static Public Member Functions

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

Public Attributes

address_array ip_address
 
int port
 
char hostname [MAXIMUM_HOSTNAME_LENGTH]
 

Detailed Description

this type of address describes a destination out on the internet.

Definition at line 30 of file internet_address.h.

Member Typedef Documentation

◆ address_array

typedef basis::abyte sockets::internet_address::address_array[ADDRESS_SIZE]

Definition at line 38 of file internet_address.h.

Member Enumeration Documentation

◆ internet_address_constraints

Enumerator
ADDRESS_SIZE 
MAXIMUM_HOSTNAME_LENGTH 

Definition at line 33 of file internet_address.h.

Constructor & Destructor Documentation

◆ internet_address() [1/2]

sockets::internet_address::internet_address ( )

Definition at line 92 of file internet_address.cpp.

◆ internet_address() [2/2]

sockets::internet_address::internet_address ( const basis::byte_array ip_address,
const basis::astring host,
int  port 
)

Definition at line 94 of file internet_address.cpp.

Member Function Documentation

◆ appropriate_for_ip()

bool sockets::internet_address::appropriate_for_ip ( const basis::astring to_check)
static

Definition at line 397 of file internet_address.cpp.

References basis::astring::length().

◆ convert()

◆ create_copy()

base_address * sockets::internet_address::create_copy ( ) const
virtual

Implements sockets::base_address.

Definition at line 243 of file internet_address.cpp.

◆ DEFINE_CLASS_NAME()

sockets::internet_address::DEFINE_CLASS_NAME ( "internet_address"  )

◆ detokenize()

bool sockets::internet_address::detokenize ( const basis::astring info)
virtual

Implements sockets::base_address.

◆ fill()

void sockets::internet_address::fill ( const basis::byte_array ip_address,
const basis::astring host,
int  port 
)

◆ has_ip_address()

bool sockets::internet_address::has_ip_address ( const basis::astring to_check,
basis::astring 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 127 of file internet_address.cpp.

References basis::astring::find(), FUNCDEF, basis::astring::length(), basis::negative(), basis::astring::reset(), and basis::astring::substring().

◆ ip_address_text_form()

astring sockets::internet_address::ip_address_text_form ( const basis::byte_array ip_address)
static

Definition at line 462 of file internet_address.cpp.

◆ ip_appropriate_number()

bool sockets::internet_address::ip_appropriate_number ( const basis::astring to_check,
int  indy,
basis::astring 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 105 of file internet_address.cpp.

References basis::astring::convert(), timely::convert(), FUNCDEF, basis::astring::length(), and basis::astring::reset().

◆ is_localhost()

bool sockets::internet_address::is_localhost ( ) const

◆ is_nil_address() [1/2]

bool sockets::internet_address::is_nil_address ( ) const

◆ is_nil_address() [2/2]

bool sockets::internet_address::is_nil_address ( const address_array ip_address)
static

Definition at line 271 of file internet_address.cpp.

◆ is_valid_internet_address()

bool sockets::internet_address::is_valid_internet_address ( const basis::astring to_check,
basis::byte_array ip_form,
bool &  all_zeros 
)
static

◆ localhost()

static const basis::byte_array& sockets::internet_address::localhost ( )
static

◆ nil_address()

static const basis::byte_array& sockets::internet_address::nil_address ( )
static

◆ normalize_host()

basis::astring sockets::internet_address::normalize_host ( ) const

◆ operator==()

bool sockets::internet_address::operator== ( const internet_address to_compare) const
inline

Definition at line 61 of file internet_address.h.

References same_host(), and same_port().

◆ pack()

void sockets::internet_address::pack ( basis::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 basis::packable.

◆ packed_size()

virtual int sockets::internet_address::packed_size ( ) const
virtual

Estimates the space needed for the packed structure.

Implements basis::packable.

◆ same_host()

bool sockets::internet_address::same_host ( const base_address to_compare) const
virtual

Implements sockets::base_address.

Referenced by operator==().

◆ same_port()

bool sockets::internet_address::same_port ( const base_address to_compare) const
virtual

Implements sockets::base_address.

Referenced by operator==().

◆ shareable()

bool sockets::internet_address::shareable ( const base_address to_compare) const
virtual

Implements sockets::base_address.

◆ text_form()

astring sockets::internet_address::text_form ( ) const
virtual

◆ tokenize()

astring sockets::internet_address::tokenize ( ) const
virtual

◆ unpack()

bool sockets::internet_address::unpack ( basis::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 basis::packable.

◆ valid_address()

bool sockets::internet_address::valid_address ( const basis::astring to_check)
static

Definition at line 455 of file internet_address.cpp.

Member Data Documentation

◆ hostname

◆ ip_address

address_array sockets::internet_address::ip_address

◆ port

int sockets::internet_address::port

The documentation for this class was generated from the following files: