sP2P c++ STL *nix API  1.2
NAT traversal and peer-to-peer networking API providing all utilities needed to build peer-to-peer application straigth out of box
 All Classes Functions Variables Typedefs Enumerations Enumerator
sp2plib::IP4Address Class Reference

Public Member Functions

 IP4Address ()
 Initialises new instance of IP4Address object
 
 IP4Address (sp2plib::UInt32 i4Adr)
 Initialises new instance of IP4Address object with given address value (machine byte order int32)
 
 IP4Address (const char *s4Address)
 Initialises new instance of IP4Address object with given human readable text address value
 
 ~IP4Address ()
 Clears all resources taken by IP4Address object
 
sp2plib::UInt32 Get ()
 Gets address as Int32 value in machiine byte order
 
void Set (sp2plib::UInt32 value)
 Sets address value using Int32 value in machine byte order
 
void Set (in_addr value)
 Sets address value using in_addr [CPP:<netinet/in.h>/ W:<winsock2.h>] structure value
 
void Parse (char *str_address)
 Parses addess value from human readable string example "12.13.14.15"
 
void ParseFromBytes (unsigned char *byte_array, int startIndex=0)
 Parses addess value from byte array in machine order
 
::std::string ToString ()
 Gets human readable presentation of address in format: d.d.d.d
 
void ToByteArray (unsigned char *buffer, int startIndex=0)
 Writes 4 address bytes to existing byte array starting from startIndex
 
void As_sockaddr_in (sockaddr_in &adr, sp2plib::UInt16 Port)
 Injects data from this object into sockaddr_in structure, also port value is passed as aux argument
 
IP4Addressoperator= (const IP4Address &rhs)
 Assignment operator.
 
IP4Addressoperator= (const sp2plib::UInt32 &rhs)
 Assignment operator.
 
bool operator== (const IP4Address &other) const
 Equality operator.
 
bool operator!= (const IP4Address &other) const
 Inequality operator.
 

Static Public Member Functions

static IP4Addressnew_Parse (char *str_address)
 Creates IP4Address object from human readable string example : IP4Address *adr = IP4Address::new_Parse("12.13.14.15");
 
static IP4Addressnew_ParseFromBytes (unsigned char *byte_array, int startIndex=0)
 Creates IP4Address object from byte array
 
static IP4AddressANY ()
 Gets IP address ANY coresponding to int32 value of 0 (ANY)
 
static bool IsIP4AddressFormat (const char *s_adr)
 Checks it given string is IP 4 address in humar readable text format
 

Constructor & Destructor Documentation

sp2plib::IP4Address::IP4Address ( )

Initialises new instance of IP4Address object

sp2plib::IP4Address::IP4Address ( sp2plib::UInt32  i4Adr)

Initialises new instance of IP4Address object with given address value (machine byte order int32)

Parameters
i4AdrMachine byte order addrress value
sp2plib::IP4Address::IP4Address ( const char *  s4Address)

Initialises new instance of IP4Address object with given human readable text address value

Parameters
s4AddressAddess in human readable format 000.000.000.000
sp2plib::IP4Address::~IP4Address ( )

Clears all resources taken by IP4Address object

Member Function Documentation

static IP4Address& sp2plib::IP4Address::ANY ( )
static

Gets IP address ANY coresponding to int32 value of 0 (ANY)

Returns
.
void sp2plib::IP4Address::As_sockaddr_in ( sockaddr_in &  adr,
sp2plib::UInt16  Port 
)

Injects data from this object into sockaddr_in structure, also port value is passed as aux argument

Parameters
adrsockaddr_in address object
PortPort
sp2plib::UInt32 sp2plib::IP4Address::Get ( )

Gets address as Int32 value in machiine byte order

Returns
Machine byte order addrress value
static bool sp2plib::IP4Address::IsIP4AddressFormat ( const char *  s_adr)
static

Checks it given string is IP 4 address in humar readable text format

Parameters
s_adrHuman readable address string to check
Returns
true if IP 4 address format, false if not.
static IP4Address* sp2plib::IP4Address::new_Parse ( char *  str_address)
static

Creates IP4Address object from human readable string example : IP4Address *adr = IP4Address::new_Parse("12.13.14.15");

Parameters
str_addressAddess in human readable format 000.000.000.000
Returns
null if it fails, else new IP4address object
static IP4Address* sp2plib::IP4Address::new_ParseFromBytes ( unsigned char *  byte_array,
int  startIndex = 0 
)
static

Creates IP4Address object from byte array

char b_adr[4] = {0x0C,0x0D,0x0E,0x0F}; IP4Address *adr = IP4Address::new_ParseFromBytes(b_adr);

Parameters
byte_arrayByte array holding address bytes
startIndex(optional) the start index from whict to start parsing
Returns
null if it fails, else new IP4Adddress object
bool sp2plib::IP4Address::operator!= ( const IP4Address other) const

Inequality operator.

Parameters
otherThe other.
Returns
true if the parameters are not considered equivalent.
IP4Address& sp2plib::IP4Address::operator= ( const IP4Address rhs)

Assignment operator.

Parameters
rhsThe right hand side.
Returns
A shallow copy of this object.
IP4Address& sp2plib::IP4Address::operator= ( const sp2plib::UInt32 &  rhs)

Assignment operator.

Parameters
rhsThe right hand side.
Returns
A shallow copy of this object.
bool sp2plib::IP4Address::operator== ( const IP4Address other) const

Equality operator.

Parameters
otherThe other.
Returns
true if the parameters are considered equivalent.
void sp2plib::IP4Address::Parse ( char *  str_address)

Parses addess value from human readable string example "12.13.14.15"

Parameters
str_addressAddess in human readable format 000.000.000.000.
void sp2plib::IP4Address::ParseFromBytes ( unsigned char *  byte_array,
int  startIndex = 0 
)

Parses addess value from byte array in machine order

Parameters
byte_arrayByte array holding address bytes.
startIndex(optional) the start index from whict to start parsing.
void sp2plib::IP4Address::Set ( sp2plib::UInt32  value)

Sets address value using Int32 value in machine byte order

Parameters
valueMachine byte order addrress value
void sp2plib::IP4Address::Set ( in_addr  value)

Sets address value using in_addr [CPP:<netinet/in.h>/ W:<winsock2.h>] structure value

Parameters
valueSets value from in_addr object
void sp2plib::IP4Address::ToByteArray ( unsigned char *  buffer,
int  startIndex = 0 
)

Writes 4 address bytes to existing byte array starting from startIndex

Parameters
bufferByte array to store address bytes to
startIndex(optional) the start index from whict to start writing
::std::string sp2plib::IP4Address::ToString ( )

Gets human readable presentation of address in format: d.d.d.d


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