14#include "uri_parser.h"
20#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT) || defined(DOXYGEN)
26#if IS_USED(MODULE_UNICOAP_DRIVER_DTLS) || defined(DOXYGEN)
30#if IS_USED(MODULE_UNICOAP_DRIVER_SLIPMUX) || defined(DOXYGEN)
67#define UNICOAP_SCHEME "coap"
72#define UNICOAP_SCHEME_UDP "coap"
77#define UNICOAP_SCHEME_DTLS "coaps"
82#define UNICOAP_SCHEME_TCP "coap+tcp"
87#define UNICOAP_SCHEME_TLS "coaps+tcp"
92#define UNICOAP_SCHEME_WEBSOCKET "coap+ws"
97#define UNICOAP_SCHEME_WEBSOCKET_TLS "coaps+ws"
102#define UNICOAP_SCHEME_BLE_GATT "coap"
107#define UNICOAP_SCHEME_SLIPMUX "coap+uart"
115#define UNICOAP_DOMAIN_BLE ".ble.arpa"
130#define UNICOAP_PROTO_UNSPECIFIED (0)
135#define UNICOAP_PROTO_FLAG_RELIABLE_TRANSPORT (1)
211#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT) || defined(DOXYGEN)
223#if IS_USED(MODULE_UNICOAP_DRIVER_SLIPMUX) || defined(DOXYGEN)
243#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT)
263#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT)
283# if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT)
298#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT)
302 return (
ipv6_addr_t*)_unicoap_endpoint_get_tl(endpoint)->addr.ipv6;
321#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT)
325 return (
ipv4_addr_t*)_unicoap_endpoint_get_tl(endpoint)->addr.ipv4;
344#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT)
346 return &_unicoap_endpoint_get_tl(endpoint)->family;
364#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT)
366 return &_unicoap_endpoint_get_tl(endpoint)->port;
384#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT)
386 return &_unicoap_endpoint_get_tl(endpoint)->netif;
468# define _UNICOAP_DESTINATION_STRING_LENGTH_MAX ((1 << 10) - 1)
488 assert(length < _UNICOAP_DESTINATION_STRING_LENGTH_MAX);
491 ._string_length = (uint16_t)length };
509 ._string_length = strlen(
host) };
529 assert(length < _UNICOAP_DESTINATION_STRING_LENGTH_MAX);
532 ._string_length = (uint16_t)length };
550 ._string_length = strlen(
uri) };
574 const char* host,
size_t length);
587 const char* scheme,
const char* host)
634#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT) || defined(DOXYGEN)
662#if IS_USED(MODULE_UNICOAP_DRIVER_UDP) || defined(DOXYGEN)
672#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT) || defined(DOXYGEN)
688# if IS_USED(MODULE_UNICOAP_DRIVER_UDP) || defined(DOXYGEN)
708# if IS_USED(MODULE_UNICOAP_DRIVER_UDP) || defined(DOXYGEN)
732#if IS_USED(MODULE_UNICOAP_DRIVER_DTLS) || defined(DOXYGEN)
742#if IS_USED(MODULE_UNICOAP_SOCK_SUPPORT) || defined(DOXYGEN)
762# if IS_USED(MODULE_UNICOAP_DRIVER_DTLS) || defined(DOXYGEN)
787# if IS_USED(MODULE_UNICOAP_DRIVER_DTLS) || defined(DOXYGEN)
#define AF_INET
internetwork address family: UDP, TCP, etc.
#define AF_INET6
internetwork address family with IPv6: UDP, TCP, etc.
#define AF_UNSPEC
unspecified address family (as macro)
#define assert(cond)
abort the program if assertion is false
struct sock_udp sock_udp_t
forward declare for async
struct sock_dtls sock_dtls_t
forward declare for async
struct _sock_tl_ep sock_udp_ep_t
An end point for a UDP sock object.
int unicoap_uri_populate(uri_parser_result_t *parsed, unicoap_endpoint_t *endpoint, unicoap_options_t *options)
Populates endpoint and CoAP options with URI parser result.
sock_dtls_t * unicoap_transport_dtls_get_socket(void)
Returns the internal DTLS socket.
int unicoap_transport_dtls_add_socket(sock_dtls_t *socket, sock_udp_t *base_socket, sock_udp_ep_t *local)
Adds DTLS socket for client and server functionality.
sock_udp_t * unicoap_transport_udp_get_socket(void)
Returns the internal UDP socket.
int unicoap_transport_dtls_remove_socket(sock_dtls_t *socket)
Removes DTLS socket previously added manually.
int unicoap_transport_udp_add_socket(sock_udp_t *socket, sock_udp_ep_t *local)
Adds UDP socket for client and server functionality.
int unicoap_transport_udp_remove_socket(sock_udp_t *socket)
Removes UDP socket previously added manually.
unicoap_proto_t
Transport protocol CoAP is used over.
#define UNICOAP_PROTO_FLAG_RELIABLE_TRANSPORT
Protocol number flag indicating the transport is considered reliable on its own.
static unicoap_destination_t unicoap_destination_host(const char *host, size_t length)
Creates destination identifier from hostname string.
void unicoap_print_endpoint(const unicoap_endpoint_t *endpoint)
Prints the given CoAP endpoint.
static unicoap_destination_t unicoap_destination_uri(const char *uri, size_t length)
Creates destination identifier from URI string.
const char * unicoap_scheme_from_proto(unicoap_proto_t proto)
Returns scheme from protocol number.
unicoap_destination_type_t
Resource identifier type.
const char * unicoap_string_from_proto(unicoap_proto_t proto)
Returns scheme from protocol number.
static unicoap_destination_t unicoap_destination_uri_string(const char *uri)
Creates destination identifier from URI string.
static unicoap_destination_t unicoap_destination_host_string(const char *host)
Creates destination identifier from null-terminated hostname string.
static uint16_t * unicoap_endpoint_get_port(unicoap_endpoint_t *endpoint)
Retrieves port from endpoint, if present and supported by endpoint type.
static int unicoap_transport_proto_from_scheme_and_host_string(const char *scheme, const char *host)
Converts a given null-terminated scheme string like coap+tcp to the corresponding protocol identifier...
static sock_udp_ep_t * unicoap_endpoint_get_udp(unicoap_endpoint_t *endpoint)
Retrieves UDP endpoint from CoAP endpoint.
static ipv6_addr_t * unicoap_endpoint_get_ipv6_addr(unicoap_endpoint_t *endpoint)
Retrieves IPv6 address from endpoint, if present and supported by endpoint type.
void unicoap_print_sock_tl_ep(const struct _sock_tl_ep *ep)
Prints the given transport layer endpoint.
static bool unicoap_transport_is_reliable(unicoap_proto_t proto)
Determines whether the given transport protocol is reliable.
static ipv4_addr_t * unicoap_endpoint_get_ipv4_addr(unicoap_endpoint_t *endpoint)
Retrieves IPv4 address from endpoint, if present and supported by endpoint type.
static uint16_t * unicoap_endpoint_get_netif_id(unicoap_endpoint_t *endpoint)
Retrieves network interface ID from endpoint, if present and supported by endpoint type.
int unicoap_proto_from_scheme_and_host(const char *scheme, size_t scheme_length, const char *host, size_t length)
Converts a given scheme string like coap+tcp to the corresponding protocol identifier.
bool unicoap_endpoint_is_equal(const unicoap_endpoint_t *source, const unicoap_endpoint_t *destination)
Compares two endpoints.
static bool unicoap_transport_uses_sock_tl_ep(unicoap_proto_t proto)
Determines whether the given transport driver uses a transport layer socket in RIOT.
static int * unicoap_endpoint_get_address_family(unicoap_endpoint_t *endpoint)
Retrieves address family from endpoint, if present and supported by endpoint type.
bool unicoap_endpoint_is_multicast(const unicoap_endpoint_t *endpoint)
Determines whether the given endpoint is a multicast endpoint.
static unicoap_destination_t unicoap_destination_endpoint(unicoap_endpoint_t *endpoint)
Creates destination identifier from endpoint.
static sock_udp_ep_t * unicoap_endpoint_get_dtls(unicoap_endpoint_t *endpoint)
Retrieves DTLS endpoint from CoAP endpoint.
@ UNICOAP_PROTO_UDP
CoAP over UDP endpoint.
@ UNICOAP_PROTO_SLIPMUX
CoAP over Slipmux endpoint.
@ UNICOAP_PROTO_DTLS
CoAP over DTLS over UDP endpoint.
@ UNICOAP_DESTINATION_ENDPOINT
Endpoint.
@ UNICOAP_DESTINATION_HOST
Hostname.
@ UNICOAP_DESTINATION_URI
URI (Uniform Resource Identifier)
int socket(int domain, int type, int protocol)
Create an endpoint for communication.
iolist scatter / gather IO
Common macros and compiler attributes/pragmas configuration.
Asynchronous sock using Event Queue definitions.
Common sock API definitions.
Common IP-based transport layer end point.
int family
family of sock_ip_ep_t::addr
Device descriptor for slipdev.
Auxiliary exchange information.
const unicoap_message_properties_t * properties
Message properties.
const unicoap_endpoint_t * local
The local CoAP endpoint in this exchange.
const unicoap_endpoint_t * remote
The remote CoAP endpoint in this exchange.
A type abstracting over CoAP resource identifiers.
const char * uri
URI string, if identified by UNICOAP_DESTINATION_URI.
const char * host
Hostname, if identified by UNICOAP_DESTINATION_HOST.
unicoap_endpoint_t * endpoint
Endpoint itself, if identified by UNICOAP_DESTINATION_ENDPOINT.
unicoap_destination_type_t type
The type of this identifier.
uint16_t _string_length
Number of ASCII code units (bytes)
sock_udp_ep_t dtls_ep
RIOT sock DTLS endpoint.
struct _sock_tl_ep _tl_ep
Transport layer endpoint.
unicoap_proto_t proto
Protocol number.
sock_udp_ep_t udp_ep
RIOT sock UDP endpoint.
Properties of a CoAP message.
container that holds all results
Utility library for comparing and computing timestamps.
Data type to represent an IPv4 address.
Data type to represent an IPv6 address.
sock utility function definitions