SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SLNet::SystemAddress Struct Reference

Network address for a system. More...

`#include <slikenet/types.h>`

## Public Member Functions

| SystemAddress ()
| Constructors.
| SystemAddress (const char *str)
| SystemAddress (const char *str, unsigned short port)
unsigned char | GetIPVersion (void) const
unsigned int | GetIPPROTO (void) const
void | SetToLoopback (void)
| Call SetToLoopback(), with whatever IP version is currently held. Defaults to IPV4.
void | SetToLoopback (unsigned char ipVersion)
bool | IsLoopback (void) const
const char * | ToString (bool writePort=true, char portDelineator='|') const
void | ToString (bool writePort, char *dest, char portDelineator= '|') const
void | ToString (bool writePort, char *dest, size_t destLength, char portDelineator='|') const
bool | FromString (const char *str, char portDelineator='|', int ipVersion=0)
bool | FromStringExplicitPort (const char *str, unsigned short port, int ipVersion=0)
| Same as FromString(), but you explicitly set a port at the same time.
void | CopyPort (const SystemAddress &right)
| Copy the port from another SystemAddress structure.
bool | EqualsExcludingPort (const SystemAddress &right) const
| Returns if two system addresses have the same IP (port is not checked)
unsigned short | GetPort (void) const
| Returns the port in host order (this is what you normally use)
unsigned short | GetPortNetworkOrder (void) const
void | SetPortHostOrder (unsigned short s)
void | SetPortNetworkOrder (unsigned short s)
bool | SetBinaryAddress (const char *str, char portDelineator=':')
| Old version, for crap platforms that don't support newer socket functions.
void | ToString_Old (bool writePort, char *dest, char portDelineator= ':') const
| Old version, for crap platforms that don't support newer socket functions.
void | ToString_Old (bool writePort, char *dest, size_t destLength, char portDelineator= ':') const
void | FixForIPVersion (const SystemAddress &boundAddressToSocket)
bool | IsLANAddress (void)
SystemAddress & | operator= (const SystemAddress &input)
bool | operator== (const SystemAddress &right) const
bool | operator!= (const SystemAddress &right) const
bool | operator> (const SystemAddress &right) const
bool | operator< (const SystemAddress &right) const

## Static Public Member Functions

static int | size (void)
static unsigned long | ToInteger (const SystemAddress &sa)
| Hash the system address.

## Public Attributes

| union
| SystemAddress, with RAKNET_SUPPORT_IPV6 defined, holds both an sockaddr_in6 and a sockaddr_in.
| address
unsigned short | debugPort
| This is not used internally, but holds a copy of the port held in the address union, so for debugging it's easier to check what port is being held.
SystemIndex | systemIndex

## Detailed Description

Network address for a system.

Corresponds to a network address
This is not necessarily a unique identifier. For example, if a system has both LAN and internet connections, the system may be identified by either one, depending on who is communicating
Therefore, you should not transmit the SystemAddress over the network and expect it to identify a system, or use it to connect to that system, except in the case where that system is not behind a NAT (such as with a dedciated server) Use RakNetGUID for a unique per-instance of RakPeer to identify systems

Definition at line 195 of file types.h.

## Constructor & Destructor Documentation

SystemAddress::SystemAddress | ( |  | ) |

Constructors.

Definition at line 436 of file RakNetTypes.cpp.

References address, debugPort, and systemIndex.

SystemAddress::SystemAddress | ( | const char * | str | ) |

Definition at line 444 of file RakNetTypes.cpp.

References address, FromString(), SetPortHostOrder(), and systemIndex.

SystemAddress::SystemAddress | ( | const char * | str,
|  | unsigned short | port
| ) |  |

Definition at line 451 of file RakNetTypes.cpp.

References address, FromStringExplicitPort(), and systemIndex.

## Member Function Documentation

void SystemAddress::CopyPort | ( | const SystemAddress & | right | ) |

Copy the port from another SystemAddress structure.

Definition at line 739 of file RakNetTypes.cpp.

References address, and debugPort.

Referenced by SLNet::RakPeer::AssignSystemAddressToRemoteSystemList().

bool SystemAddress::EqualsExcludingPort | ( | const SystemAddress & | right | ) | const

Returns if two system addresses have the same IP (port is not checked)

Definition at line 139 of file RakNetTypes.cpp.

References address.

Referenced by SLNet::RakPeer::AssignSystemAddressToRemoteSystemList(), SLNet::RakPeer::IsLoopbackAddress(), and operator==().

void SystemAddress::FixForIPVersion | ( | const SystemAddress & | boundAddressToSocket | ) |

Definition at line 495 of file RakNetTypes.cpp.

References FromString(), GetIPVersion(), IPV4_LOOPBACK, IPV6_LOOPBACK, and ToString().

Referenced by SLNet::RakPeer::CloseConnectionInternal(), SLNet::RakPeer::Ping(), SLNet::RakPeer::RunUpdateCycle(), SLNet::RakPeer::SendOutOfBand(), and SLNet::RakPeer::SendTTL().

bool SystemAddress::FromString | ( | const char * | str,
|  | char | portDelineator = `'|'`,
|  | int | ipVersion = `0`
| ) |  |

Set the system address from a printable IP string, for example "192.0.2.1" or "2001:db8:63b3:1::3490" You can write the port as well, using the portDelineator, for example "192.0.2.1|1234"

Parameters

  [in] | str | A printable IP string, for example "192.0.2.1" or "2001:db8:63b3:1::3490". Pass 0 for str to set to UNASSIGNED_SYSTEM_ADDRESS
  [in] | portDelineator | if str contains a port, delineate the port with this character. portDelineator should not be '.', ':', '', '-', '/', a number, or a-f
  [in] | ipVersion | Only used if str is a pre-defined address in the wrong format, such as 127.0.0.1 but you want ip version 6, so you can pass 6 here to do the conversion

Note
  The current port is unchanged if a port is not specified in str

Returns
  True on success, false on ipVersion does not match type of passed string

Definition at line 605 of file RakNetTypes.cpp.

References WSAStartupSingleton::AddRef(), address, debugPort, WSAStartupSingleton::Deref(), IPV4_LOOPBACK, IPV6_LOOPBACK, RakAssert, and SetBinaryAddress().

Referenced by FixForIPVersion(), FromStringExplicitPort(), SLNet::SocketLayer::GetSystemAddress(), SetToLoopback(), and SystemAddress().

bool SystemAddress::FromStringExplicitPort | ( | const char * | str,
|  | unsigned short | port,
|  | int | ipVersion = `0`
| ) |  |

Same as FromString(), but you explicitly set a port at the same time.

Definition at line 727 of file RakNetTypes.cpp.

References address, debugPort, FromString(), and SLNet::UNASSIGNED_SYSTEM_ADDRESS.

Referenced by SLNet::RakPeer::Ping(), SLNet::RakPeer::SendConnectionRequest(), SLNet::RakPeer::SendOutOfBand(), SLNet::RakPeer::SendTTL(), and SystemAddress().

unsigned int SystemAddress::GetIPPROTO | ( | void |  | ) | const

Definition at line 230 of file RakNetTypes.cpp.

References address.

unsigned char SystemAddress::GetIPVersion | ( | void |  | ) | const

Return the IP version, either IPV4 or IPV6

Returns
  Either 4 or 6

Definition at line 224 of file RakNetTypes.cpp.

References address.

Referenced by FixForIPVersion(), IsLoopback(), SetToLoopback(), and SLNet::BitStream::Write().

unsigned short SystemAddress::GetPort | ( | void |  | ) | const

Returns the port in host order (this is what you normally use)

Definition at line 147 of file RakNetTypes.cpp.

References address.

Referenced by SLNet::SocketLayer::GetLocalPort(), SLNet::ProcessNetworkPacket(), SLNet::RNS2_Berkley::RecvFromLoopInt(), SLNet::CommandParserInterface::ReturnResult(), and ToString_Old().

unsigned short SystemAddress::GetPortNetworkOrder | ( | void |  | ) | const

Definition at line 151 of file RakNetTypes.cpp.

References address.

Referenced by SLNet::BitStream::Write().

bool SystemAddress::IsLANAddress | ( | void |  | ) |

Definition at line 523 of file RakNetTypes.cpp.

References address.

bool SystemAddress::IsLoopback | ( | void |  | ) | const

Returns
  If was set to 127.0.0.1 or ::1

Definition at line 255 of file RakNetTypes.cpp.

References address, and GetIPVersion().

bool SystemAddress::operator!= | ( | const SystemAddress & | right | ) | const

Definition at line 170 of file RakNetTypes.cpp.

bool SystemAddress::operator< | ( | const SystemAddress & | right | ) | const

Definition at line 190 of file RakNetTypes.cpp.

References address.

SystemAddress & SystemAddress::operator= | ( | const SystemAddress & | input | ) |

Definition at line 132 of file RakNetTypes.cpp.

References address, debugPort, and systemIndex.

bool SystemAddress::operator== | ( | const SystemAddress & | right | ) | const

Definition at line 165 of file RakNetTypes.cpp.

References address, and EqualsExcludingPort().

bool SystemAddress::operator> | ( | const SystemAddress & | right | ) | const

Definition at line 175 of file RakNetTypes.cpp.

References address.

bool SystemAddress::SetBinaryAddress | ( | const char * | str,
|  | char | portDelineator = `':'`
| ) |  |

Old version, for crap platforms that don't support newer socket functions.

Definition at line 532 of file RakNetTypes.cpp.

References _FILE_AND_LINE_, address, debugPort, SLNet::RakNetSocket2::DomainNameToIP(), SLNet::NonNumericHostString(), SLNet::OP_DELETE_ARRAY(), and SLNet::UNASSIGNED_SYSTEM_ADDRESS.

Referenced by FromString().

void SystemAddress::SetPortHostOrder | ( | unsigned short | s | ) |

Sets the port. The port value should be in host order (this is what you normally use) Renamed from SetPort because of winspool.h http://edn.embarcadero.com/article/21494

Definition at line 155 of file RakNetTypes.cpp.

References address, and debugPort.

Referenced by SLNet::RakPeer::Startup(), and SystemAddress().

void SystemAddress::SetPortNetworkOrder | ( | unsigned short | s | ) |

Definition at line 160 of file RakNetTypes.cpp.

References address, and debugPort.

Referenced by SLNet::SocketLayer::GetSystemAddress_Old().

void SystemAddress::SetToLoopback | ( | void |  | ) |

Call SetToLoopback(), with whatever IP version is currently held. Defaults to IPV4.

Definition at line 240 of file RakNetTypes.cpp.

References GetIPVersion().

Referenced by SLNet::SocketLayer::GetSystemAddress().

void SystemAddress::SetToLoopback | ( | unsigned char | ipVersion | ) |

Call SetToLoopback() with a specific IP version

Parameters

  [in] | ipVersion | Either 4 for IPV4 or 6 for IPV6

Definition at line 244 of file RakNetTypes.cpp.

References FromString(), IPV4_LOOPBACK, and IPV6_LOOPBACK.

int SystemAddress::size | ( | void |  | ) |

static

Definition at line 204 of file RakNetTypes.cpp.

unsigned long SystemAddress::ToInteger | ( | const SystemAddress & | sa | ) |

static

Hash the system address.

Definition at line 212 of file RakNetTypes.cpp.

References address, and SuperFastHashIncremental().

Referenced by SLNet::RakPeer::RemoteSystemLookupHashIndex(), and SLNet::AddressOrGUID::ToInteger().

const char * SystemAddress::ToString | ( | bool | writePort = `true`,
|  | char | portDelineator = `'|'`
| ) |  | const

Definition at line 330 of file RakNetTypes.cpp.

Referenced by SLNet::RakPeer::AssignSystemAddressToRemoteSystemList(), FixForIPVersion(), SLNet::SocketLayer::GetFirstBindableIP(), SLNet::RakPeer::GetLocalIP(), SLNet::ProcessOfflineNetworkPacket(), SLNet::CommandParserInterface::ReturnResult(), SLNet::RakPeer::RunUpdateCycle(), and SLNet::AddressOrGUID::ToString().

void SystemAddress::ToString | ( | bool | writePort,
|  | char * | dest,
|  | char | portDelineator = `'|'`
| ) |  | const

Definition at line 419 of file RakNetTypes.cpp.

References ToString_Old().

void SystemAddress::ToString | ( | bool | writePort,
|  | char * | dest,
|  | size_t | destLength,
|  | char | portDelineator = `'|'`
| ) |  | const

Definition at line 427 of file RakNetTypes.cpp.

References ToString_Old().

void SystemAddress::ToString_Old | ( | bool | writePort,
|  | char * | dest,
|  | char | portDelineator = `':'`
| ) |  | const

Old version, for crap platforms that don't support newer socket functions.

Definition at line 275 of file RakNetTypes.cpp.

References address, GetPort(), Itoa(), and SLNet::UNASSIGNED_SYSTEM_ADDRESS.

Referenced by ToString().

void SystemAddress::ToString_Old | ( | bool | writePort,
|  | char * | dest,
|  | size_t | destLength,
|  | char | portDelineator = `':'`
| ) |  | const

Definition at line 308 of file RakNetTypes.cpp.

References address, GetPort(), Itoa(), and SLNet::UNASSIGNED_SYSTEM_ADDRESS.

## Member Data Documentation

SLNet::SystemAddress::address

Definition at line 220 of file types.h.

Referenced by CopyPort(), EqualsExcludingPort(), FromString(), FromStringExplicitPort(), GetIPPROTO(), GetIPVersion(), GetPort(), GetPortNetworkOrder(), SLNet::SocketLayer::GetSystemAddress(), SLNet::SocketLayer::GetSystemAddress_Old(), IsLANAddress(), IsLoopback(), operator<(), operator=(), operator==(), operator>(), SLNet::ProcessOfflineNetworkPacket(), SLNet::BitStream::Read(), SLNet::RakPeer::RunUpdateCycle(), SetBinaryAddress(), SetPortHostOrder(), SetPortNetworkOrder(), SystemAddress(), ToInteger(), ToString_Old(), and SLNet::BitStream::Write().

unsigned short SLNet::SystemAddress::debugPort

This is not used internally, but holds a copy of the port held in the address union, so for debugging it's easier to check what port is being held.

Definition at line 223 of file types.h.

Referenced by CopyPort(), FromString(), FromStringExplicitPort(), SLNet::SocketLayer::GetSystemAddress(), operator=(), SLNet::BitStream::Read(), SLNet::RakPeer::RunUpdateCycle(), SetBinaryAddress(), SetPortHostOrder(), SetPortNetworkOrder(), and SystemAddress().

SystemIndex SLNet::SystemAddress::systemIndex

Definition at line 311 of file types.h.

Referenced by SLNet::RakPeer::CloseConnection(), SLNet::RakPeer::GetClientPublicKeyFromSystemAddress(), SLNet::RakPeer::GetGuidFromSystemAddress(), SLNet::RakPeer::GetIndexFromSystemAddress(), operator=(), SLNet::ProcessOfflineNetworkPacket(), SLNet::RakPeer::RunUpdateCycle(), and SystemAddress().

SLNet::SystemAddress::union

Initial value:
{
sockaddr_in addr4

SystemAddress, with RAKNET_SUPPORT_IPV6 defined, holds both an sockaddr_in6 and a sockaddr_in.

Definition at line 213 of file types.h.

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

- Source/include/slikenet/types.h
- Source/src/RakNetTypes.cpp