Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::NetworkManager Class Reference
Collaboration diagram for Burger::NetworkManager:

Public Member Functions

 NetworkManager () noexcept
 Default constructor.
 
 ~NetworkManager ()
 Default destructor.
 
eError Init (void) noexcept
 Initialize network code.
 
void Shutdown (void) noexcept
 Shut down network code.
 
const char * GetHostName (void) const noexcept
 Get the hostname.
 
uint_t GetLocalAddressCount (void) const noexcept
 Get the number of local addresses.
 
const NetAddr_tGetLocalAddresses (void) const noexcept
 Get the base pointer of the array of local addresses.
 
uint_t HasAddrType (NetAddr_t::eAddressType uType) const noexcept
 Test if a specific protocol is present.
 
eError ResolveIPv4Address (NetAddr_t *pOutput, const char *pDNSName) noexcept
 Resolve a DNS address to IPv4.
 
eError ResolveIPv6Address (NetAddr_t *pOutput, const char *pDNSName) noexcept
 Resolve a DNS address to IPv6.
 
eError GetIPv4Address (NetAddr_t *pOutput) noexcept
 Return the IPv4 address of the current machine.
 
eError GetIPv6Address (NetAddr_t *pOutput) noexcept
 Return the IPv6 address of the current machine.
 
eError SendPacket (const NetAddr_t *pDestination, const void *pBuffer, uintptr_t uSize) noexcept
 Send a data packet to another network address.
 
eError SendStream (const NetAddr_t *pDestination, const void *pBuffer, uintptr_t uSize) noexcept
 Send a data packet to another network address using guaranteed protocol.
 
eError EnumerateLocalAddresses (void) noexcept
 Enumerate all local network addresses.
 

Static Public Member Functions

static NetworkManagerNew (void) noexcept
 Allocate a NetworkManager using the global memory manager.
 

Protected Attributes

String m_HostName
 gethostname() of the current machineSi
 
uint_t m_uStarted
 Number of times this was started up.
 
uint_t m_uLocalAddressCount
 Number of local addresses found.
 
NetAddr_tm_pLocalAddresses
 Array of all local addresses for this machine.
 
uint_t m_uProtocolsFound
 Which protocols were found.
 
uint_t m_bWSAStarted
 TRUE if WSAStartup() called
 
uint_t m_bOpenTransportStarted
 TRUE if Open Transport started
 
void * m_pEventHandler
 (OTNotifyUPP) Open Transport callback
 

Private Member Functions

 NetworkManager (const NetworkManager &)=delete
 
NetworkManageroperator= (const NetworkManager &)=delete
 
 NetworkManager (NetworkManager &&)=delete
 
NetworkManageroperator= (NetworkManager &&)=delete
 

Constructor & Destructor Documentation

◆ NetworkManager() [1/3]

Burger::NetworkManager::NetworkManager ( const NetworkManager & )
privatedelete

◆ NetworkManager() [2/3]

Burger::NetworkManager::NetworkManager ( NetworkManager && )
privatedelete

◆ NetworkManager() [3/3]

Burger::NetworkManager::NetworkManager ( )
noexcept

Default constructor.


Initialize the variables for a NetworkManager instance.

◆ ~NetworkManager()

Burger::NetworkManager::~NetworkManager ( )

Default destructor.


Release the variables for a NetworkManager instance.

Member Function Documentation

◆ EnumerateLocalAddresses()

Burger::eError BURGER_API Burger::NetworkManager::EnumerateLocalAddresses ( void )
noexcept

Enumerate all local network addresses.


Scan all the network adapters and collect all of the local addresses for this machine. Only addresses that are "DNS eligible" will be enumerated, so things like the loopback or other special purpose addresses are not placed in the list.

Returns
Zero if no error, non zero if an error had occurred

◆ GetHostName()

const char * Burger::NetworkManager::GetHostName ( void ) const
inlinenoexcept

Get the hostname.


On machines with TCP/IP support, return the string that is returned by a call to gethostname().

Returns
Pointer to an empty string or the result of a successful call to gethostname()

◆ GetIPv4Address()

Burger::eError BURGER_API Burger::NetworkManager::GetIPv4Address ( NetAddr_t * pOutput)
noexcept

Return the IPv4 address of the current machine.


Iterate over the IPv4 addresses associated with the host computer and return the most likely IP address that is active.

Parameters
pOutputPointer to the NetAddr_t structure that will contain the resolved address
Returns
Zero if no error, non zero if an IPv4 address isn't associated with this machine.
See also
GetIPv6Address(NetAddr_t *)

◆ GetIPv6Address()

Burger::eError BURGER_API Burger::NetworkManager::GetIPv6Address ( NetAddr_t * pOutput)
noexcept

Return the IPv6 address of the current machine.


Return the IPv6 address associated with the host computer.

Parameters
pOutputPointer to the NetAddr_t structure that will contain the resolved address
Returns
Zero if no error, non zero if an IPv6 address isn't associated with this machine.
See also
GetIPv6Address(NetAddr_t *)

◆ GetLocalAddressCount()

uint_t Burger::NetworkManager::GetLocalAddressCount ( void ) const
inlinenoexcept

Get the number of local addresses.


On start up of this class, all local IP addresses were enumerated and the number of addresses found will be returned with this call. Call GetLocalAddresses() const to get the base address of the array of NetAddr_t structures that have the addresses.

Returns
Number of valid local addresses, can be zero.
See also
GetLocalAddresses(void) const

◆ GetLocalAddresses()

const NetAddr_t * Burger::NetworkManager::GetLocalAddresses ( void ) const
inlinenoexcept

Get the base pointer of the array of local addresses.


On start up of this class, all local IP addresses were enumerated and the base pointer to the array of addresses found will be returned with this call. Call GetLocalAddressCount() const to get the size of this array.

Returns
Base pointer to the valid local addresses, can be NULL if there are none.
See also
GetLocalAddressCount(void) const

◆ HasAddrType()

uint_t Burger::NetworkManager::HasAddrType ( NetAddr_t::eAddressType uType) const
inlinenoexcept

Test if a specific protocol is present.


On start up of this class, all available protocols are tested and flags are set which can be queried with this call.

Parameters
uTypeType to test for.
Returns
Zero if the requested protocol is not available, non-zero if it is.

◆ Init()

Burger::eError BURGER_API Burger::NetworkManager::Init ( void )
noexcept

Initialize network code.


Start up the operating system's network layer and return any error code if it failed.

Returns
Zero on success, non-zero if an error had occurred

◆ New()

Burger::NetworkManager *BURGER_API Burger::NetworkManager::New ( void )
staticnoexcept

Allocate a NetworkManager using the global memory manager.


Using the GlobalMemoryManager, allocate an instance of this class and return the pointer.

Returns
A pointer to a new instance of the NetworkManager class or NULL on failure

◆ operator=() [1/2]

NetworkManager & Burger::NetworkManager::operator= ( const NetworkManager & )
privatedelete

◆ operator=() [2/2]

NetworkManager & Burger::NetworkManager::operator= ( NetworkManager && )
privatedelete

◆ ResolveIPv4Address()

Burger::eError BURGER_API Burger::NetworkManager::ResolveIPv4Address ( NetAddr_t * pOutput,
const char * pDNSName )
noexcept

Resolve a DNS address to IPv4.


Given a DNS string with an optional port number, contact the connected DNS server to resolve the address.

Note
If the DNS address is a port literal, it will be decoded without contacting any server.
Parameters
pOutputPointer to the NetAddr_t structure that will contain the resolved address
pDNSNamePointer to a "C" string in UTF-8 encoding to pass to the DNS server
Returns
Zero if no error, non zero if the string couldn't be resolved.

◆ ResolveIPv6Address()

Burger::eError BURGER_API Burger::NetworkManager::ResolveIPv6Address ( NetAddr_t * pOutput,
const char * pDNSName )
noexcept

Resolve a DNS address to IPv6.


Given a DNS string with an optional port number, contact the connected DNS server to resolve the address.

Note
If the DNS address is a port literal, it will be decoded without contacting any server.
Parameters
pOutputPointer to the NetAddr_t structure that will contain the resolved address
pDNSNamePointer to a "C" string in UTF-8 encoding to pass to the DNS server
Returns
Zero if no error, non zero if the string couldn't be resolved.

◆ SendPacket()

Burger::eError BURGER_API Burger::NetworkManager::SendPacket ( const NetAddr_t * pDestination,
const void * pBuffer,
uintptr_t uBufferSize )
noexcept

Send a data packet to another network address.


Send data to another machine using UDP or other non-guaranteed transport method.

Parameters
pDestinationPointer to the NetAddr_t that has the destination address
pBufferPointer to the data to transmit
uBufferSizeNumber of bytes to transmit
Returns
Zero if no error, non zero if an error had occurred
See also
SendStream(const NetAddr_t *,void *,uintptr_t)

◆ SendStream()

Burger::eError BURGER_API Burger::NetworkManager::SendStream ( const NetAddr_t * pDestination,
const void * pBuffer,
uintptr_t uBufferSize )
noexcept

Send a data packet to another network address using guaranteed protocol.


Send data to another machine using TCP or other guaranteed transport method.

Parameters
pDestinationPointer to the NetAddr_t that has the destination address
pBufferPointer to the data to transmit
uBufferSizeNumber of bytes to transmit
Returns
Zero if no error, non zero if an error had occurred
See also
SendPacket(const NetAddr_t *,void *,uintptr_t)

◆ Shutdown()

void BURGER_API Burger::NetworkManager::Shutdown ( void )
noexcept

Shut down network code.


Shut down the operating system's network layer and release all allocated resources

Member Data Documentation

◆ m_bOpenTransportStarted

uint_t Burger::NetworkManager::m_bOpenTransportStarted
protected

TRUE if Open Transport started

◆ m_bWSAStarted

uint_t Burger::NetworkManager::m_bWSAStarted
protected

TRUE if WSAStartup() called

◆ m_HostName

String Burger::NetworkManager::m_HostName
protected

gethostname() of the current machineSi

◆ m_pEventHandler

void* Burger::NetworkManager::m_pEventHandler
protected

(OTNotifyUPP) Open Transport callback

◆ m_pLocalAddresses

NetAddr_t* Burger::NetworkManager::m_pLocalAddresses
protected

Array of all local addresses for this machine.

◆ m_uLocalAddressCount

uint_t Burger::NetworkManager::m_uLocalAddressCount
protected

Number of local addresses found.

◆ m_uProtocolsFound

uint_t Burger::NetworkManager::m_uProtocolsFound
protected

Which protocols were found.

◆ m_uStarted

uint_t Burger::NetworkManager::m_uStarted
protected

Number of times this was started up.