DDNet documentation
Loading...
Searching...
No Matches
Addresses

Classes

struct  NETADDR

Typedefs

typedef struct NETADDR NETADDR

Functions

int net_addr_comp (const NETADDR *a, const NETADDR *b)
int net_addr_comp_noport (const NETADDR *a, const NETADDR *b)
void net_addr_str (const NETADDR *addr, char *string, int max_length, bool add_port)
int net_addr_from_url (NETADDR *addr, const char *string, char *host_buf, size_t host_buf_size)
bool net_addr_is_local (const NETADDR *addr)
int net_addr_from_str (NETADDR *addr, const char *string)
int net_host_lookup (const char *hostname, NETADDR *addr, int types)

Variables

const NETADDR NETADDR_ZEROED
constexpr auto NETADDR_MAXSTRSIZE = 1 + (8 * 4 + 7) + 1 + 1 + 5 + 1

Detailed Description

Typedef Documentation

◆ NETADDR

typedef struct NETADDR NETADDR

Function Documentation

◆ net_addr_comp()

int net_addr_comp ( const NETADDR * a,
const NETADDR * b )

Compares two network addresses.

Parameters
aAddress to compare.
bAddress to compare to.
Returns
< 0 if address a is less than address b.
0 if address a is equal to address b.
> 0 if address a is greater than address b.

◆ net_addr_comp_noport()

int net_addr_comp_noport ( const NETADDR * a,
const NETADDR * b )

Compares two network addresses ignoring port.

Parameters
aAddress to compare.
bAddress to compare to.
Returns
< 0 if address a is less than address b.
0 if address a is equal to address b.
> 0 if address a is greater than address b.

◆ net_addr_from_str()

int net_addr_from_str ( NETADDR * addr,
const char * string )

Turns string into a network address.

Parameters
addrAddress to fill in.
stringString to parse.
Returns
0 on success.

◆ net_addr_from_url()

int net_addr_from_url ( NETADDR * addr,
const char * string,
char * host_buf,
size_t host_buf_size )

Turns url string into a network address struct. The url format is tw-0.6+udp://{ipaddr}[:{port}] ipaddr: can be ipv4 or ipv6 port: is a optional internet protocol port

This format is used for parsing the master server, be careful before changing it.

Examples: tw-0.6+udp://127.0.0.1 tw-0.6+udp://127.0.0.1:8303

Parameters
addrAddress to fill in.
stringString to parse.
host_bufPointer to a buffer to write the host to. It will include the port if one is included in the URL. It can also be set to nullptr then it will be ignored.
host_buf_sizeSize of the host buffer or 0 if no host_buf pointer is given.
Returns
0 on success.
> 0 if the input wasn't a valid DDNet URL,
< 0 if the input is a valid DDNet URL but the host part was not a valid IPv4/IPv6 address

◆ net_addr_is_local()

bool net_addr_is_local ( const NETADDR * addr)

Checks if an address is local.

Parameters
addrAddress to check.
Returns
true if the address is local, false otherwise.

◆ net_addr_str()

void net_addr_str ( const NETADDR * addr,
char * string,
int max_length,
bool add_port )

Turns a network address into a representative string.

Parameters
addrAddress to turn into a string.
stringBuffer to fill with the string.
max_lengthMaximum size of the string.
add_portWhether to add the port to the string.
Remarks
The string will always be null-terminated.

◆ net_host_lookup()

int net_host_lookup ( const char * hostname,
NETADDR * addr,
int types )

Looks up the IP of a hostname.

Parameters
hostnameHost name to look up.
addrThe output address to write to.
typesThe type of IP that should be returned.
Returns
0 on success.

Variable Documentation

◆ NETADDR_MAXSTRSIZE

auto NETADDR_MAXSTRSIZE = 1 + (8 * 4 + 7) + 1 + 1 + 5 + 1
inlineconstexpr

◆ NETADDR_ZEROED

const NETADDR NETADDR_ZEROED
extern