sock utility function More...
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.  More... | |
| const char * | sock_urlpath (const char *url) | 
Returns a pointer to the path component in url.  More... | |
| int | sock_tl_ep_fmt (const struct _sock_tl_ep *endpoint, char *addr_str, uint16_t *port) | 
| Format common IP-based transport layer endpoint to string and port.  More... | |
| static int | sock_tcp_ep_fmt (const sock_tcp_ep_t *endpoint, char *addr_str, uint16_t *port) | 
| Format TCP endpoint to string and port.  More... | |
| static 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_tl_str2ep (struct _sock_tl_ep *ep_out, const char *str) | 
| Convert string to common IP-based transport layer endpoint.  More... | |
| int | sock_tl_name2ep (struct _sock_tl_ep *ep_out, const char *str) | 
Convert string to common IP-based transport layer endpoint If the sock_dns module is used, this will do a DNS lookup if str is not an IP address.  More... | |
| static int | sock_tcp_str2ep (sock_tcp_ep_t *ep_out, const char *str) | 
| Convert string to TCP endpoint.  More... | |
| static int | sock_tcp_name2ep (sock_tcp_ep_t *ep_out, const char *str) | 
Convert string to TCP endpoint If the sock_dns module is used, this will do a DNS lookup if str is not an IP address.  More... | |
| static int | sock_udp_str2ep (sock_udp_ep_t *ep_out, const char *str) | 
| Convert string to UDP endpoint.  More... | |
| static int | sock_udp_name2ep (sock_udp_ep_t *ep_out, const char *str) | 
Convert string to UDP endpoint If the sock_dns module is used, this will do a DNS lookup if str is not an IP address.  More... | |
| bool | sock_tl_ep_equal (const struct _sock_tl_ep *a, const struct _sock_tl_ep *b) | 
| Compare the two given common IP-based transport layer endpoints.  More... | |
| static bool | sock_tcp_ep_equal (const sock_tcp_ep_t *a, const sock_tcp_ep_t *b) | 
| Compare the two given TCP endpoints.  More... | |
| static bool | sock_udp_ep_equal (const sock_udp_ep_t *a, const sock_udp_ep_t *b) | 
| Compare the two given UDP endpoints.  More... | |
| 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.  More... | |
| 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.
| [out] | sock_udp | Struct to store the underlying UDP socket | 
| [out] | sock_dtls | Struct for the actual DTLS socket | 
| [out] | session | Struct to store DTLS session information | 
| [in] | tag | Credential tag to use | 
| [in] | local | Local endpoint, must not be NULL | 
| [in] | remote | Server endpoint to connect to | 
| [in] | work_buf | Buffer used to negotiate connection | 
| [in] | work_buf_len | Size of work buf. Should be at least 160 bytes for AES_128_CCM_8 with PSK | 
      
  | 
  inlinestatic | 
Compare the two given TCP endpoints.
The given endpoint identifiers are compared by checking their address family, their addresses, and their port value.
| [in] | a | Endpoint A | 
| [in] | b | Endpoint B | 
      
  | 
  inlinestatic | 
      
  | 
  inlinestatic | 
Convert string to TCP endpoint If the sock_dns module is used, this will do a DNS lookup if str is not an IP address. 
Takes eg., "exampl.com:80" or "[2001:db8::1]:1234" and converts it into the corresponding UDP endpoint structure.
| [out] | ep_out | endpoint structure to fill | 
| [in] | str | string to read from | 
      
  | 
  inlinestatic | 
| bool sock_tl_ep_equal | ( | const struct _sock_tl_ep * | a, | 
| const struct _sock_tl_ep * | b | ||
| ) | 
Compare the two given common IP-based transport layer endpoints.
The given endpoint identifiers are compared by checking their address family, their addresses, and their port value.
| [in] | a | Endpoint A | 
| [in] | b | Endpoint B | 
| int sock_tl_ep_fmt | ( | const struct _sock_tl_ep * | endpoint, | 
| char * | addr_str, | ||
| uint16_t * | port | ||
| ) | 
Format common IP-based transport layer endpoint to string and port.
| [in] | endpoint | endpoint to format | 
| [out] | addr_str | where to write address as string | 
| [out] | port | where to write port number as uint16_t | 
addr_str on success | int sock_tl_name2ep | ( | struct _sock_tl_ep * | ep_out, | 
| const char * | str | ||
| ) | 
Convert string to common IP-based transport layer endpoint If the sock_dns module is used, this will do a DNS lookup if str is not an IP address. 
Takes eg., "riot-os.org:1234" and converts it into the corresponding endpoint structure.
| [out] | ep_out | endpoint structure to fill | 
| [in] | str | string to read from | 
| int sock_tl_str2ep | ( | struct _sock_tl_ep * | ep_out, | 
| const char * | str | ||
| ) | 
Convert string to common IP-based transport layer endpoint.
Takes eg., "[2001:db8::1]:1234" and converts it into the corresponding UDP endpoint structure.
| [out] | ep_out | endpoint structure to fill | 
| [in] | str | string to read from | 
      
  | 
  inlinestatic | 
Compare the two given UDP endpoints.
The given endpoint identifiers are compared by checking their address family, their addresses, and their port value.
| [in] | a | Endpoint A | 
| [in] | b | Endpoint B | 
      
  | 
  inlinestatic | 
      
  | 
  inlinestatic | 
Convert string to UDP endpoint If the sock_dns module is used, this will do a DNS lookup if str is not an IP address. 
Takes eg., "exampl.com:80" or "[2001:db8::1]:1234" and converts it into the corresponding UDP endpoint structure.
| [out] | ep_out | endpoint structure to fill | 
| [in] | str | string to read from | 
      
  | 
  inlinestatic | 
| const char* sock_urlpath | ( | const char * | url | ) | 
Returns a pointer to the path component in url. 
| [in] | url | URL to examine. Must not be NULL. | 
url url is invalid | 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".
url != NULL| [in] | url | URL to split. Must not be NULL. | 
| [out] | hostport | where to write host:port. Can be NULL. | 
| [out] | urlpath | where to write url path. Can be NULL. |