Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cNetHost4 Class Reference

#include <cNetHost.h>

Public Member Functions

 cNetHost4 () noexcept
 
 cNetHost4 (UINT uIP4) noexcept
 
 cNetHost4 (const in_addr &ip) noexcept
 
 cNetHost4 (const char *pszIP)
 
bool isHostValid () const noexcept
 
bool isHostLoopback () const noexcept
 
bool isHostBroadcast () const noexcept
 
bool isHostPrivate () const
 
bool isHostLocalTo (const cNetHost4 &ip, UINT32 dwMask=0xFFFFFF00) const noexcept
 
bool operator== (cNetHost4 ip) const noexcept
 
void SetEmptyHostAddr () noexcept
 
 operator in_addr () const noexcept
 
BYTE GetByte (int i=0) const
 
in_addr get_HostIp4 () const noexcept
 
UINT32 get_HostIp4_H () const noexcept
 
void put_HostIp4 (in_addr addr4) noexcept
 
void put_HostIp4_H (UINT32 uIP4) noexcept
 
void put_HostLoopback () noexcept
 
HASHCODE32_t get_HashCode () const noexcept
 
cStringA get_HostStr () const
 
HRESULT put_HostStr (const char *pszIP)
 
 UNITTEST_FRIEND (cNetHost)
 

Static Public Member Functions

static StrLen_t GRAYCALL GetIP4Format (const char *pszIP, bool bTerm=true)
 

Static Public Attributes

static const UINT32 k_LOOPBACK_N = 0x7F000001
 INADDR_LOOPBACK in network order bytes. INADDR_LOOPBACK. More...
 
static const UINT32 k_BROADCAST = 0xFFFFFFFF
 INADDR_BROADCAST. More...
 
static const in_addr k_AddrNull
 invalid address. INADDR_ANY (NOT INADDR_NONE) More...
 
static const in_addr k_AddrBroadcast
 Broadcast. INADDR_BROADCAST. More...
 

Protected Attributes

in_addr m_ipa4
 (network order bytes) (4 bytes) More...
 

Detailed Description

AF_INET The machine/host IPv4 32 bit address. (network order bytes) Not the port and does NOT handle IPv6 of course. ASSERT sizeof(cNetHost4) = 4 = sizeof(in_addr) = sizeof(IN_ADDR)

INADDR_ANY (u_long)0x00000000 INADDR_LOOPBACK 0x7f000001 = host order bytes INADDR_BROADCAST (u_long)0xffffffff INADDR_NONE 0xffffffff

Constructor & Destructor Documentation

◆ cNetHost4() [1/4]

GrayLib::cNetHost4::cNetHost4 ( )
inlinenoexcept

◆ cNetHost4() [2/4]

GrayLib::cNetHost4::cNetHost4 ( UINT  uIP4)
inlineexplicitnoexcept

init via Host order 32 bit IP address.

◆ cNetHost4() [3/4]

GrayLib::cNetHost4::cNetHost4 ( const in_addr &  ip)
inlinenoexcept

◆ cNetHost4() [4/4]

GrayLib::cNetHost4::cNetHost4 ( const char *  pszIP)
inline

Set IP as "1.2.3.4" format. Any port info (or host name) is ignored/lost.

Member Function Documentation

◆ get_HashCode()

HASHCODE32_t GrayLib::cNetHost4::get_HashCode ( ) const
inlinenoexcept

get a hash code for the IP address alone. not including port number. for sorting by the IP. ASSUME sort host order.

◆ get_HostIp4()

in_addr GrayLib::cNetHost4::get_HostIp4 ( ) const
inlinenoexcept

just get the address as a 32 bit struct. Net Order

◆ get_HostIp4_H()

UINT32 GrayLib::cNetHost4::get_HostIp4_H ( ) const
inlinenoexcept

just get the address as a 32 bit number. Host Order. Now i can compare against INADDR_LOOPBACK.

◆ get_HostStr()

cStringA GrayLib::cNetHost4::get_HostStr ( ) const

Return the numeric "1.1.1.1" string like deprecated "::inet_ntoa()"

Note
This can also be done with getnameinfo(NI_NUMERICHOST)

◆ GetByte()

BYTE GrayLib::cNetHost4::GetByte ( int  i = 0) const
inline

get s_net,s_host,s_lh,s_impno,

◆ GetIP4Format()

StrLen_t GRAYCALL GrayLib::cNetHost4::GetIP4Format ( const char *  pszIP,
bool  bTerm = true 
)
static

is pszIP in format of "1.1.1.1"?

  • bTerm = true = must be '\0' terminated
    Returns
    length

◆ isHostBroadcast()

bool GrayLib::cNetHost4::isHostBroadcast ( ) const
inlinenoexcept

broadcast on my LAN?

◆ isHostLocalTo()

bool GrayLib::cNetHost4::isHostLocalTo ( const cNetHost4 ip,
UINT32  dwMask = 0xFFFFFF00 
) const
inlinenoexcept

is this IP on the same local sub net ? dwMask = host order. Private address ranges are local by definition? cause we can either reach them or we can't? dwMask = 0xFFFFFF00 = 255.255.255.0 - host order.

◆ isHostLoopback()

bool GrayLib::cNetHost4::isHostLoopback ( ) const
inlinenoexcept

my local loop back address?

◆ isHostPrivate()

bool GrayLib::cNetHost4::isHostPrivate ( ) const
inline

private LAN address ranges. Not for the general Internet.

◆ isHostValid()

bool GrayLib::cNetHost4::isHostValid ( ) const
inlinenoexcept

is NOT 0, but 0xffffffff=INADDR_NONE = broadcast is OK.

◆ operator in_addr()

GrayLib::cNetHost4::operator in_addr ( ) const
inlinenoexcept

Get network order structure.

◆ operator==()

bool GrayLib::cNetHost4::operator== ( cNetHost4  ip) const
inlinenoexcept

◆ put_HostIp4()

void GrayLib::cNetHost4::put_HostIp4 ( in_addr  addr4)
inlinenoexcept

in_addr = network order.

◆ put_HostIp4_H()

void GrayLib::cNetHost4::put_HostIp4_H ( UINT32  uIP4)
inlinenoexcept

uIP4 = host order. m_ipa4 = network order.

◆ put_HostLoopback()

void GrayLib::cNetHost4::put_HostLoopback ( )
inlinenoexcept

in_addr = network order.

◆ put_HostStr()

HRESULT GrayLib::cNetHost4::put_HostStr ( const char *  pszIP)
Note
decode an ip4 address in "1.2.3.4" format. ASSUME no port. like deprecated "::inet_addr" https://msdn.microsoft.com/en-us/library/windows/desktop/ms738563%28v=vs.85%29.aspx

◆ SetEmptyHostAddr()

void GrayLib::cNetHost4::SetEmptyHostAddr ( )
inlinenoexcept

DO NOT reflect up to set the m_sAddrName

◆ UNITTEST_FRIEND()

GrayLib::cNetHost4::UNITTEST_FRIEND ( cNetHost  )

Member Data Documentation

◆ k_AddrBroadcast

const in_addr GrayLib::cNetHost4::k_AddrBroadcast
static

Broadcast. INADDR_BROADCAST.

◆ k_AddrNull

const in_addr GrayLib::cNetHost4::k_AddrNull
static

invalid address. INADDR_ANY (NOT INADDR_NONE)

◆ k_BROADCAST

const UINT32 GrayLib::cNetHost4::k_BROADCAST = 0xFFFFFFFF
static

INADDR_BROADCAST.

◆ k_LOOPBACK_N

const UINT32 GrayLib::cNetHost4::k_LOOPBACK_N = 0x7F000001
static

INADDR_LOOPBACK in network order bytes. INADDR_LOOPBACK.

◆ m_ipa4

in_addr GrayLib::cNetHost4::m_ipa4
protected

(network order bytes) (4 bytes)


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