PTLib  Version 2.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PILSSession::MSIPAddress Class Reference

Special IP address class. More...

#include <pils.h>

Inheritance diagram for PILSSession::MSIPAddress:
PIPSocket::Address PObject

Public Member Functions

 MSIPAddress (DWORD a=0)
 MSIPAddress (const PIPSocket::Address &a)
 MSIPAddress (const PString &dotNotation)
 MSIPAddress (PINDEX len, const BYTE *bytes)
MSIPAddressoperator= (DWORD a)
 Copy an address from a four byte value in network order.
MSIPAddressoperator= (const PIPSocket::Address &a)
MSIPAddressoperator= (const PString &dotNotation)
 Copy an address from a string.
- Public Member Functions inherited from PIPSocket::Address
Comparison Compare (const PObject &obj) const
 Compare two adresses for absolute (in)equality.
bool operator== (const Address &addr) const
bool operator!= (const Address &addr) const
bool operator== (in_addr &addr) const
bool operator!= (in_addr &addr) const
bool operator== (DWORD dw) const
bool operator!= (DWORD dw) const
bool operator== (int i) const
bool operator!= (int i) const
bool operator*= (const Address &addr) const
 Compare two addresses for equivalence.
PString AsString (bool bracketIPv6=false) const
 Format an address as a string.
PBoolean FromString (const PString &str)
 Convert string to IP address. Returns true if was a valid address.
 operator PString () const
 Format an address as a string.
 operator in_addr () const
 Return IPv4 address in network order.
 operator DWORD () const
 Return IPv4 address in network order.
BYTE Byte1 () const
 Return first byte of IPv4 address.
BYTE Byte2 () const
 Return second byte of IPv4 address.
BYTE Byte3 () const
 Return third byte of IPv4 address.
BYTE Byte4 () const
 Return fourth byte of IPv4 address.
BYTE operator[] (PINDEX idx) const
 Return specified byte of IPv4 or IPv6 address.
PINDEX GetSize () const
 Get the address length (will be either 4 or 16).
const char * GetPointer () const
 Get the pointer to IP address data.
unsigned GetVersion () const
 Get the version of the IP address being used.
PBoolean IsValid () const
 Check address 0.0.0.0 or ::.
PBoolean IsAny () const
PBoolean IsLoopback () const
 Check address 127.0.0.1 or ::1.
PBoolean IsBroadcast () const
 Check for Broadcast address 255.255.255.255.
PBoolean IsMulticast () const
 Check if address is multicast group.
PBoolean IsRFC1918 () const
 Check if the remote address is a private address.
 Address ()
 Create an IPv4 address with the default address: 127.0.0.1 (loopback).
 Address (const PString &dotNotation)
 Create an IP address from string notation, eg dot notation x.x.x.x.
 Address (PINDEX len, const BYTE *bytes)
 Create an IPv4 or IPv6 address from 4 or 16 byte values.
 Address (BYTE b1, BYTE b2, BYTE b3, BYTE b4)
 Create an IP address from four byte values.
 Address (DWORD dw)
 Create an IPv4 address from a four byte value in network byte order.
 Address (const in_addr &addr)
 Create an IPv4 address from an in_addr structure.
 Address (const int ai_family, const int ai_addrlen, struct sockaddr *ai_addr)
 Create an IP (v4 or v6) address from a sockaddr (sockaddr_in, sockaddr_in6 or sockaddr_in6_old) structure.
Addressoperator= (const in_addr &addr)
 Copy an address from another IP v4 address.
- Public Member Functions inherited from PObject
virtual ~PObject ()
virtual PObjectClone () const
 Create a copy of the class on the heap.
virtual PINDEX HashFunction () const
 This function yields a hash value required by the PDictionary class.
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
 Determine the byte wise comparison of two objects.
bool operator== (const PObject &obj) const
 Compare the two objects.
bool operator!= (const PObject &obj) const
 Compare the two objects.
bool operator< (const PObject &obj) const
 Compare the two objects.
bool operator> (const PObject &obj) const
 Compare the two objects.
bool operator<= (const PObject &obj) const
 Compare the two objects.
bool operator>= (const PObject &obj) const
 Compare the two objects.
virtual const char * GetClass (unsigned ancestor=0) const
 Get the current dynamic type of the object instance.
PBoolean IsClass (const char *cls) const
virtual PBoolean InternalIsDescendant (const char *clsName) const
 Determine if the dynamic type of the current instance is a descendent of the specified class.
virtual void PrintOn (ostream &strm) const
 Output the contents of the object to the stream.
virtual void ReadFrom (istream &strm)
 Input the contents of the object from the stream.

Friends

istream & operator>> (istream &s, MSIPAddress &a)
ostream & operator<< (ostream &s, MSIPAddress &a)

Additional Inherited Members

- Public Types inherited from PObject
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
 Result of the comparison operation performed by the Compare() function. More...
- Static Public Member Functions inherited from PIPSocket::Address
static const AddressGetLoopback (int version=4)
static const AddressGetAny (int version=4)
static const Address GetBroadcast (int version=4)
- Protected Member Functions inherited from PObject
 PObject ()
 Constructor for PObject, made protected so cannot ever create one on its own.
- Protected Attributes inherited from PIPSocket::Address
union {
   in_addr   four
v
 Runtime test of IP addresse type.
unsigned version

Detailed Description

Special IP address class.

Microsoft in their infinite wisdom save the IP address as an little endian integer in the LDAP fild, but this was generated from a 32 bit integer that was in network byte order (big endian) which causes immense confusion. Reading directly into a PIPSocket::Address does not work as it assumes that any integer forms would be in host order. So we need to override the standard read function so the marchalling into the RTPerson structure works. All very sad.

Constructor & Destructor Documentation

PILSSession::MSIPAddress::MSIPAddress ( DWORD  a = 0)
inline
PILSSession::MSIPAddress::MSIPAddress ( const PIPSocket::Address a)
inline
PILSSession::MSIPAddress::MSIPAddress ( const PString dotNotation)
inline
PILSSession::MSIPAddress::MSIPAddress ( PINDEX  len,
const BYTE *  bytes 
)
inline

Member Function Documentation

MSIPAddress& PILSSession::MSIPAddress::operator= ( DWORD  dw)
inline

Copy an address from a four byte value in network order.

Reimplemented from PIPSocket::Address.

Referenced by operator=().

MSIPAddress& PILSSession::MSIPAddress::operator= ( const PIPSocket::Address a)
inline

References operator=().

MSIPAddress& PILSSession::MSIPAddress::operator= ( const PString dotNotation)
inline

Copy an address from a string.

Reimplemented from PIPSocket::Address.

References operator=().

Friends And Related Function Documentation

ostream& operator<< ( ostream &  s,
MSIPAddress a 
)
friend
istream& operator>> ( istream &  s,
MSIPAddress a 
)
friend

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