sock utility functions

sock utility function More...

Detailed Description

sock utility function


 SOCK utility functions compile configurations


file  util.h
 sock utility function definitions


int sock_udp_ep_fmt (const sock_udp_ep_t *endpoint, char *addr_str, uint16_t *port)
 Format UDP endpoint to string and port. More...
int sock_urlsplit (const char *url, char *hostport, char *urlpath)
 Split url to host:port and url path. More...
int sock_udp_str2ep (sock_udp_ep_t *ep_out, const char *str)
 Convert string to UDP endpoint. More...
bool sock_udp_ep_equal (const sock_udp_ep_t *a, const sock_udp_ep_t *b)
 Compare the two given UDP endpoints. More...

Function Documentation

◆ sock_udp_ep_equal()

bool sock_udp_ep_equal ( const sock_udp_ep_t a,
const sock_udp_ep_t b 

Compare the two given UDP endpoints.

The given endpoint identifiers are compared by checking their address family, their addresses, and their port value.

[in]aEndpoint A
[in]bEndpoint B
true if given endpoint identifiers point to the same destination
false if given endpoint identifiers do not point to the same destination, or if the address family is unknown

◆ sock_udp_ep_fmt()

int sock_udp_ep_fmt ( const sock_udp_ep_t endpoint,
char *  addr_str,
uint16_t *  port 

Format UDP endpoint to string and port.

[in]endpointendpoint to format
[out]addr_strwhere to write address as string
[out]portwhere to write prt number as uint16_t
number of bytes written to addr_str on success
<0 otherwise

◆ sock_udp_str2ep()

int sock_udp_str2ep ( sock_udp_ep_t ep_out,
const char *  str 

Convert string to UDP endpoint.

Takes eg., "[2001:db8::1]:1234" and converts it into the corresponding UDP endpoint structure.

[out]ep_outendpoint structure to fill
[in]strstring to read from
0 on success
<0 otherwise

◆ sock_urlsplit()

int sock_urlsplit ( const char *  url,
char *  hostport,
char *  urlpath 

Split url to host:port and url path.

Will split e.g., "" into "" and "/url/path".

Caller has to make sure hostport and urlpath can hold the results! Make sure to provide space for CONFIG_SOCK_HOSTPORT_MAXLEN respectively CONFIG_SOCK_URLPATH_MAXLEN bytes, if pointers are not NULL. Scheme part of the URL is limited to CONFIG_SOCK_SCHEME_MAXLEN length.
url != NULL
[in]urlURL to split. Must not be NULL.
[out]hostportwhere to write host:port. Can be NULL.
[out]urlpathwhere to write url path. Can be NULL.
0 on success
<0 otherwise