Loading...
Searching...
No Matches
sock utility functions

sock utility function More...

Detailed Description

sock utility function

Files

file  util.h
 sock utility function definitions
 

Macros

#define SOCK_HAS_UDP   1
 UDP support is enabled.
 
#define SOCK_HAS_TCP   1
 TCP support is enabled.
 
#define HAVE_SOCK_TL_EP   1
 Indicates presence of struct _sock_tl_ep
 

Functions

int sock_urlsplit (const char *url, char *hostport, char *urlpath)
 Split url to host:port and url path.
 
const char * sock_urlpath (const char *url)
 Returns a pointer to the path component in url.
 
int sock_dtls_establish_session (sock_udp_t *sock_udp, sock_dtls_t *sock_dtls, sock_dtls_session_t *session, credman_tag_t tag, sock_udp_ep_t *local, const sock_udp_ep_t *remote, void *work_buf, size_t work_buf_len)
 Helper function to establish a DTLS connection.
 

Macro Definition Documentation

◆ HAVE_SOCK_TL_EP

#define HAVE_SOCK_TL_EP   1

Indicates presence of struct _sock_tl_ep

Definition at line 46 of file util.h.

◆ SOCK_HAS_TCP

#define SOCK_HAS_TCP   1

TCP support is enabled.

Definition at line 38 of file util.h.

◆ SOCK_HAS_UDP

#define SOCK_HAS_UDP   1

UDP support is enabled.

Definition at line 34 of file util.h.

Function Documentation

◆ sock_dtls_establish_session()

int sock_dtls_establish_session ( sock_udp_t * sock_udp,
sock_dtls_t * sock_dtls,
sock_dtls_session_t * session,
credman_tag_t tag,
sock_udp_ep_t * local,
const sock_udp_ep_t * remote,
void * work_buf,
size_t work_buf_len )

Helper function to establish a DTLS connection.

Parameters
[out]sock_udpStruct to store the underlying UDP socket
[out]sock_dtlsStruct for the actual DTLS socket
[out]sessionStruct to store DTLS session information
[in]tagCredential tag to use
[in]localLocal endpoint, must not be NULL
[in]remoteServer endpoint to connect to
[in]work_bufBuffer used to negotiate connection
[in]work_buf_lenSize of work buf. Should be at least 160 bytes for AES_128_CCM_8 with PSK
Returns
0 on success
negative error otherwise (see sock_dtls_recv_aux)

◆ sock_urlpath()

const char * sock_urlpath ( const char * url)

Returns a pointer to the path component in url.

Parameters
[in]urlURL to examine. Must not be NULL.
Returns
pointer to the start of the path component in url
NULL if url is invalid

◆ sock_urlsplit()

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

Split url to host:port and url path.

Will split e.g., "https://host.name:1234/url/path" into "host.name:1234" and "/url/path".

Note
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.
Precondition
url != NULL
Parameters
[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.
Returns
0 on success
<0 otherwise