Shadowrun: Awakened 29 September 2011 - Build 871
Public Types | Public Member Functions | Static Public Attributes | Private Attributes
cat::NetAddr Class Reference

#include <Sockets.hpp>

List of all members.

Public Types

typedef sockaddr_in6 SockAddr

Public Member Functions

CAT_INLINE bool Convert (bool To6)
bool DemoteTo4 ()
bool EqualsIPOnly (const NetAddr &addr) const
CAT_INLINE const u32 GetIP4 () const
CAT_INLINE const u64GetIP6 () const
CAT_INLINE Port GetPort () const
CAT_INLINE void Invalidate ()
std::string IPToString () const
CAT_INLINE bool Is6 () const
bool IsInternetRoutable ()
bool IsRoutable ()
 NetAddr (int a, int b, int c, int d, Port port=0)
 NetAddr (const char *ip_str, Port port=0)
 NetAddr (const sockaddr_in &addr)
 NetAddr (const sockaddr *addr)
 NetAddr (const sockaddr_in6 &addr)
CAT_INLINE NetAddr ()
 NetAddr (const NetAddr &addr)
bool operator!= (const NetAddr &addr) const
NetAddroperator= (const NetAddr &addr)
bool operator== (const NetAddr &addr) const
bool PromoteTo6 ()
bool SetFromDotDecimals (int a, int b, int c, int d, Port port=0)
bool SetFromRawIP (const u8 *ip_binary, int bytes)
bool SetFromString (const char *ip_str, Port port=0)
CAT_INLINE void SetPort (Port port)
bool Unwrap (SockAddr &addr, int &addr_len, bool PromoteToIP6=false) const
CAT_INLINE bool Valid () const
bool Wrap (const sockaddr_in &addr)
bool Wrap (const sockaddr_in6 &addr)
bool Wrap (const sockaddr *addr)

Static Public Attributes

static const int IP4_BYTES = 4
static const int IP6_BYTES = 16

Private Attributes

union {
   struct {
      u16   _family
      Port   _port
   } 
   u32   _valid
}; 
union {
   struct {
      u32   v4
      u32   v4_padding [3]
   } 
   u64   v6 [2]
   u8   v6_bytes [16]
   u16   v6_words [8]
_ip

Detailed Description

Definition at line 65 of file Sockets.hpp.


Member Typedef Documentation

typedef sockaddr_in6 cat::NetAddr::SockAddr

Definition at line 91 of file Sockets.hpp.


Constructor & Destructor Documentation

CAT_INLINE cat::NetAddr::NetAddr ( ) [inline]

Definition at line 94 of file Sockets.hpp.

{}
cat::NetAddr::NetAddr ( const char *  ip_str,
Port  port = 0 
)
cat::NetAddr::NetAddr ( const sockaddr_in6 &  addr)
cat::NetAddr::NetAddr ( const sockaddr_in &  addr)
cat::NetAddr::NetAddr ( const sockaddr *  addr)
cat::NetAddr::NetAddr ( int  a,
int  b,
int  c,
int  d,
Port  port = 0 
)
cat::NetAddr::NetAddr ( const NetAddr addr)

Member Function Documentation

CAT_INLINE bool cat::NetAddr::Convert ( bool  To6) [inline]

Definition at line 118 of file Sockets.hpp.

References DemoteTo4(), and PromoteTo6().

{ if (To6) return PromoteTo6(); else return DemoteTo4(); }
bool cat::NetAddr::DemoteTo4 ( )

Referenced by Convert().

bool cat::NetAddr::EqualsIPOnly ( const NetAddr addr) const
CAT_INLINE const u32 cat::NetAddr::GetIP4 ( ) const [inline]

Definition at line 124 of file Sockets.hpp.

References _ip.

{ return _ip.v4; }
CAT_INLINE const u64* cat::NetAddr::GetIP6 ( ) const [inline]

Definition at line 125 of file Sockets.hpp.

References _ip.

{ return _ip.v6; }
CAT_INLINE Port cat::NetAddr::GetPort ( ) const [inline]

Definition at line 127 of file Sockets.hpp.

References _port.

{ return _port; }
CAT_INLINE void cat::NetAddr::Invalidate ( ) [inline]

Definition at line 131 of file Sockets.hpp.

References _valid.

Referenced by cat::DNSClient::CAT_SINGLETON().

{ _valid = 0; }
std::string cat::NetAddr::IPToString ( ) const
CAT_INLINE bool cat::NetAddr::Is6 ( ) const [inline]

Definition at line 122 of file Sockets.hpp.

References _family.

{ return _family == AF_INET6; }
bool cat::NetAddr::IsInternetRoutable ( )
bool cat::NetAddr::IsRoutable ( )
bool cat::NetAddr::operator!= ( const NetAddr addr) const
NetAddr& cat::NetAddr::operator= ( const NetAddr addr)
bool cat::NetAddr::operator== ( const NetAddr addr) const
bool cat::NetAddr::PromoteTo6 ( )

Referenced by Convert().

bool cat::NetAddr::SetFromDotDecimals ( int  a,
int  b,
int  c,
int  d,
Port  port = 0 
)
bool cat::NetAddr::SetFromRawIP ( const u8 ip_binary,
int  bytes 
)
bool cat::NetAddr::SetFromString ( const char *  ip_str,
Port  port = 0 
)
CAT_INLINE void cat::NetAddr::SetPort ( Port  port) [inline]

Definition at line 128 of file Sockets.hpp.

References _port.

{ _port = port; }
bool cat::NetAddr::Unwrap ( SockAddr addr,
int &  addr_len,
bool  PromoteToIP6 = false 
) const
CAT_INLINE bool cat::NetAddr::Valid ( ) const [inline]

Definition at line 121 of file Sockets.hpp.

References _valid.

{ return _valid != 0; }
bool cat::NetAddr::Wrap ( const sockaddr *  addr)
bool cat::NetAddr::Wrap ( const sockaddr_in &  addr)
bool cat::NetAddr::Wrap ( const sockaddr_in6 &  addr)

Member Data Documentation

union { ... } [private]

Definition at line 83 of file Sockets.hpp.

Referenced by Is6().

union { ... } cat::NetAddr::_ip [private]

Referenced by GetIP4(), and GetIP6().

Definition at line 82 of file Sockets.hpp.

Referenced by GetPort(), and SetPort().

Definition at line 80 of file Sockets.hpp.

Referenced by Invalidate(), and Valid().

const int cat::NetAddr::IP4_BYTES = 4 [static]

Definition at line 88 of file Sockets.hpp.

const int cat::NetAddr::IP6_BYTES = 16 [static]

Definition at line 89 of file Sockets.hpp.

Definition at line 73 of file Sockets.hpp.

Definition at line 74 of file Sockets.hpp.

Definition at line 71 of file Sockets.hpp.

Definition at line 69 of file Sockets.hpp.

Definition at line 70 of file Sockets.hpp.


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

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net