Contiki-NG
Modules | Functions

The CoAP transport API defines a common interface for sending/receiving CoAP messages. More...

Modules

 CoAP transport implementation for uIP
 This is an implementation of CoAP transport and CoAP endpoint over uIP with DTLS support.
 

Functions

void coap_endpoint_copy (coap_endpoint_t *dest, const coap_endpoint_t *src)
 Copy a CoAP endpoint from one memory area to another. More...
 
int coap_endpoint_cmp (const coap_endpoint_t *e1, const coap_endpoint_t *e2)
 Compare two CoAP endpoints. More...
 
void coap_endpoint_log (const coap_endpoint_t *ep)
 Print a CoAP endpoint via the logging module. More...
 
void coap_endpoint_print (const coap_endpoint_t *ep)
 Print a CoAP endpoint. More...
 
int coap_endpoint_snprint (char *str, size_t size, const coap_endpoint_t *ep)
 Print a CoAP endpoint to a string. More...
 
int coap_endpoint_parse (const char *text, size_t size, coap_endpoint_t *ep)
 Parse a CoAP endpoint. More...
 
int coap_endpoint_is_secure (const coap_endpoint_t *ep)
 Check if a CoAP endpoint is secure (encrypted). More...
 
int coap_endpoint_is_connected (const coap_endpoint_t *ep)
 Check if a CoAP endpoint is connected. More...
 
int coap_endpoint_connect (coap_endpoint_t *ep)
 Request a connection to a CoAP endpoint. More...
 
void coap_endpoint_disconnect (coap_endpoint_t *ep)
 Request that any connection to a CoAP endpoint is discontinued. More...
 
uint8_t * coap_databuf (void)
 Returns a common data buffer that can be used when generating CoAP messages for transmission. More...
 
int coap_sendto (const coap_endpoint_t *ep, const uint8_t *data, uint16_t len)
 Send a message to the specified CoAP endpoint. More...
 
void coap_transport_init (void)
 Initialize the CoAP transport. More...
 

Detailed Description

The CoAP transport API defines a common interface for sending/receiving CoAP messages.

Function Documentation

◆ coap_databuf()

uint8_t* coap_databuf ( void  )

Returns a common data buffer that can be used when generating CoAP messages for transmission.

The buffer size is at least COAP_MAX_PACKET_SIZE bytes.

In Contiki-NG, this corresponds to the uIP buffer.

Returns
A pointer to a data buffer where a CoAP message can be stored.

Definition at line 330 of file coap-uip.c.

References uip_appdata.

◆ coap_endpoint_cmp()

int coap_endpoint_cmp ( const coap_endpoint_t *  e1,
const coap_endpoint_t *  e2 
)

Compare two CoAP endpoints.

Parameters
e1A pointer to the first CoAP endpoint.
e2A pointer to the second CoAP endpoint.
Returns
Non-zero if the endpoints are identical and zero otherwise.

Definition at line 171 of file coap-uip.c.

◆ coap_endpoint_connect()

int coap_endpoint_connect ( coap_endpoint_t *  ep)

Request a connection to a CoAP endpoint.

Parameters
epA pointer to a CoAP endpoint.
Returns
Returns zero if an error occured and non-zero otherwise.

Definition at line 295 of file coap-uip.c.

◆ coap_endpoint_copy()

void coap_endpoint_copy ( coap_endpoint_t *  dest,
const coap_endpoint_t *  src 
)

Copy a CoAP endpoint from one memory area to another.

Parameters
destA pointer to a CoAP endpoint to copy to.
srcA pointer to a CoAP endpoint to copy from.

Definition at line 162 of file coap-uip.c.

References uip_ipaddr_copy.

◆ coap_endpoint_disconnect()

void coap_endpoint_disconnect ( coap_endpoint_t *  ep)

Request that any connection to a CoAP endpoint is discontinued.

Parameters
epA pointer to a CoAP endpoint.

Definition at line 320 of file coap-uip.c.

◆ coap_endpoint_is_connected()

int coap_endpoint_is_connected ( const coap_endpoint_t *  ep)

Check if a CoAP endpoint is connected.

Parameters
epA pointer to a CoAP endpoint.
Returns
Returns non-zero if the endpoint is connected and zero otherwise.

Definition at line 258 of file coap-uip.c.

References uip_is_addr_linklocal.

◆ coap_endpoint_is_secure()

int coap_endpoint_is_secure ( const coap_endpoint_t *  ep)

Check if a CoAP endpoint is secure (encrypted).

Parameters
epA pointer to a CoAP endpoint.
Returns
Returns non-zero if the endpoint is secure and zero otherwise.

Definition at line 252 of file coap-uip.c.

◆ coap_endpoint_log()

void coap_endpoint_log ( const coap_endpoint_t *  ep)

Print a CoAP endpoint via the logging module.

Parameters
epA pointer to the CoAP endpoint to log.

Definition at line 102 of file coap-uip.c.

◆ coap_endpoint_parse()

int coap_endpoint_parse ( const char *  text,
size_t  size,
coap_endpoint_t *  ep 
)

Parse a CoAP endpoint.

Parameters
textThe string to parse.
sizeThe max number of characters in the string.
epA pointer to the CoAP endpoint to write to.
Returns
Returns non-zero if the endpoint was successfully parsed and zero otherwise.

Definition at line 209 of file coap-uip.c.

References start().

◆ coap_endpoint_print()

void coap_endpoint_print ( const coap_endpoint_t *  ep)

Print a CoAP endpoint.

Parameters
epA pointer to the CoAP endpoint to print.

Definition at line 118 of file coap-uip.c.

◆ coap_endpoint_snprint()

int coap_endpoint_snprint ( char *  str,
size_t  size,
const coap_endpoint_t *  ep 
)

Print a CoAP endpoint to a string.

The output is always null-terminated unless size is zero.

Parameters
strThe string to write to.
sizeThe max number of characters to write.
epA pointer to the CoAP endpoint to print.
Returns
Returns the number of characters needed for the output excluding the ending null-terminator or negative if an error occurred.

Definition at line 134 of file coap-uip.c.

◆ coap_sendto()

int coap_sendto ( const coap_endpoint_t *  ep,
const uint8_t *  data,
uint16_t  len 
)

Send a message to the specified CoAP endpoint.

Parameters
epA pointer to a CoAP endpoint
dataA pointer to data to send
lenThe size of the data to send
Returns
The number of bytes sent or negative if an error occurred.

Definition at line 377 of file coap-uip.c.

◆ coap_transport_init()

void coap_transport_init ( void  )

Initialize the CoAP transport.

This function initializes the CoAP transport implementation and should only be called by the CoAP engine.

Definition at line 336 of file coap-uip.c.

References process_start().