Loading...
Searching...
No Matches

CoAP transport protocol abstraction layer. More...

Detailed Description

CoAP transport protocol abstraction layer.

Author
Carl Seifert carl..nosp@m.seif.nosp@m.ert@t.nosp@m.u-dr.nosp@m.esden.nosp@m..de

Definition in file transport.h.

#include <stdbool.h>
#include <stdint.h>
#include "iolist.h"
#include "timex.h"
#include "uri_parser.h"
#include "modules.h"
#include "net/sock.h"
#include "net/sock/udp.h"
#include "net/sock/async/event.h"
#include "net/sock/util.h"
#include "net/sock/tcp.h"
#include "net/sock/dtls.h"
#include "slipdev.h"
#include "net/unicoap/message.h"
#include "net/unicoap/options.h"
+ Include dependency graph for transport.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  unicoap_endpoint_t
 A CoAP endpoint. More...
 
struct  unicoap_destination_t
 A type abstracting over CoAP resource identifiers. More...
 
struct  unicoap_aux_t
 Auxiliary exchange information. More...
 

CoAP URI schemes

The goal for CoAP is to have coap as the only scheme, with the underlying transport being inferred using CoAP Transport Indication.

#define UNICOAP_SCHEME   "coap"
 Default CoAP URI scheme.
 
#define UNICOAP_SCHEME_UDP   "coap"
 URI scheme for CoAP over UDP.
 
#define UNICOAP_SCHEME_DTLS   "coaps"
 URI scheme for CoAP over DTLS.
 
#define UNICOAP_SCHEME_TCP   "coap+tcp"
 URI scheme for CoAP over TCP.
 
#define UNICOAP_SCHEME_TLS   "coaps+tcp"
 URI scheme for CoAP over TLS.
 
#define UNICOAP_SCHEME_WEBSOCKET   "coap+ws"
 URI scheme for CoAP over WebSockets.
 
#define UNICOAP_SCHEME_WEBSOCKET_TLS   "coaps+ws"
 URI scheme for CoAP over secure WebSockets (over TLS)
 
#define UNICOAP_SCHEME_BLE_GATT   "coap"
 URI scheme for CoAP over GATT over Bluetooth Low Energy (BLE)
 
#define UNICOAP_SCHEME_SLIPMUX   "coap+uart"
 URI scheme for CoAP over Slipmux.
 
#define UNICOAP_DOMAIN_BLE   ".ble.arpa"
 Domain for for CoAP over GATT over Bluetooth Low Energy (BLE)
 

Endpoints

#define UNICOAP_PROTO_UNSPECIFIED   (0)
 Unspecified protocol number.
 
#define UNICOAP_PROTO_FLAG_RELIABLE_TRANSPORT   (1)
 Protocol number flag indicating the transport is considered reliable on its own.
 
enum  unicoap_proto_t { UNICOAP_PROTO_UDP = 1 << 1 , UNICOAP_PROTO_DTLS = 2 << 1 , UNICOAP_PROTO_SLIPMUX = 3 << 1 }
 Transport protocol CoAP is used over. More...
 
static bool unicoap_transport_is_reliable (unicoap_proto_t proto)
 Determines whether the given transport protocol is reliable.
 
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 ipv6_addr_t * unicoap_endpoint_get_ipv6_addr (unicoap_endpoint_t *endpoint)
 Retrieves IPv6 address from endpoint, if present and supported by endpoint type.
 
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 int * unicoap_endpoint_get_address_family (unicoap_endpoint_t *endpoint)
 Retrieves address family from endpoint, if present and supported by endpoint type.
 
static uint16_t * unicoap_endpoint_get_port (unicoap_endpoint_t *endpoint)
 Retrieves port 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.
 

Request destinations

enum  unicoap_destination_type_t { UNICOAP_DESTINATION_ENDPOINT = 0 , UNICOAP_DESTINATION_HOST = 1 , UNICOAP_DESTINATION_URI = 2 }
 Resource identifier type. More...
 

Conversions and Tools

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.
 
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.
 
const char * unicoap_scheme_from_proto (unicoap_proto_t proto)
 Returns scheme from protocol number.
 
const char * unicoap_string_from_proto (unicoap_proto_t proto)
 Returns scheme from protocol number.
 
bool unicoap_endpoint_is_equal (const unicoap_endpoint_t *source, const unicoap_endpoint_t *destination)
 Compares two endpoints.
 
bool unicoap_endpoint_is_multicast (const unicoap_endpoint_t *endpoint)
 Determines whether the given endpoint is a multicast endpoint.
 
void unicoap_print_sock_tl_ep (const struct _sock_tl_ep *ep)
 Prints the given transport layer endpoint.
 
void unicoap_print_endpoint (const unicoap_endpoint_t *endpoint)
 Prints the given CoAP endpoint.
 

Sockets

sock_udp_t * unicoap_transport_udp_get_socket (void)
 Returns the internal UDP socket.
 
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.
 
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.
 
int unicoap_transport_dtls_remove_socket (sock_dtls_t *socket)
 Removes DTLS socket previously added manually.
 

Manually parsing a CoAP URI

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.