![]() |
Contiki-NG
|
DTLS (Mbed TLS implementation) support for CoAP. More...
#include <MBEDTLS_CONFIG_FILE>#include "mbedtls/ssl.h"#include "mbedtls/entropy.h"#include "mbedtls/ctr_drbg.h"#include "mbedtls/timing.h"#include "dtls-support-config.h"#include "coap-endpoint.h"#include "coap-keystore.h"Go to the source code of this file.
Functions | |
| void | coap_dtls_init (void) |
| Initializes CoAP-MbedTLS global info. | |
| void | coap_dtls_event_handler (void) |
| Handler for timer, and process-poll events. | |
| void | coap_dtls_conn_init (struct uip_udp_conn *udp_conn, struct process *host_process) |
| Registers, 1. | |
| int | coap_ep_dtls_write (const coap_endpoint_t *ep, const unsigned char *message, int len) |
| Encrypt app. | |
| int | coap_ep_dtls_handle_message (const coap_endpoint_t *ep) |
| Handler for new DTLS messages. | |
| void | coap_ep_dtls_disconnect (const coap_endpoint_t *ep) |
| Disconnect a peer. | |
| coap_dtls_session_info_t * | coap_ep_get_dtls_session_info (const coap_endpoint_t *ep) |
| Get session struct associated with CoAP endpoint. | |
| bool | coap_ep_is_dtls_peer (const coap_endpoint_t *ep) |
| Check if a CoAP endpoint is a peer in the list of DTLS sessions. | |
| bool | coap_ep_is_dtls_connected (const coap_endpoint_t *ep) |
| Check if a peer has completed the handshake successfully. | |
| int | coap_ep_get_dtls_state (const coap_endpoint_t *ep) |
| Check in what DTLS state the peer is in. | |
DTLS (Mbed TLS implementation) support for CoAP.
Definition in file mbedtls-support.h.
| void coap_dtls_conn_init | ( | struct uip_udp_conn * | udp_conn, |
| struct process * | host_process ) |
Registers, 1.
UDP port info. 2. Host process (Coap Engine).
| udp_conn | Pointer to UDP port information. This will be used when CoAP-MbedTLS needs to send messages via UDP. |
| host_process | Pointer to the host process. This process will recieve a poll event when a DTLS message needs to be sent. |
Definition at line 187 of file mbedtls-support.c.
| void coap_dtls_event_handler | ( | void | ) |
Handler for timer, and process-poll events.
Must be called by the host process (CoAP Engine).
Definition at line 314 of file mbedtls-support.c.
References CLOCK_SECOND, coap_ep_get_dtls_session_info(), etimer_expiration_time(), etimer_expired(), etimer_set(), heapmem_free(), list_head(), list_pop(), PROCESS_CURRENT, and process_poll().
| void coap_dtls_init | ( | void | ) |
Initializes CoAP-MbedTLS global info.
Must be the first thing that is called before using CoAP-MbedTLS.
Definition at line 159 of file mbedtls-support.c.
References LIST_STRUCT_INIT.
Referenced by coap_transport_init().
| void coap_ep_dtls_disconnect | ( | const coap_endpoint_t * | ep | ) |
Disconnect a peer.
Sends a close notification message to peer. Followed by cleanup of session struct, free memory.
| ep | Pointer of peer CoAP endpoint. |
Definition at line 830 of file mbedtls-support.c.
References coap_ep_get_dtls_session_info(), etimer_stop(), list_remove(), and memb_free().
Referenced by coap_endpoint_disconnect(), and coap_ep_dtls_handle_message().
| int coap_ep_dtls_handle_message | ( | const coap_endpoint_t * | ep | ) |
Handler for new DTLS messages.
Handles both handshake and decryption of record layer messages.
| ep | Pointer of source CoAP endpoint. |
Definition at line 772 of file mbedtls-support.c.
References coap_ep_dtls_disconnect(), coap_ep_get_dtls_session_info(), uip_appdata, and uip_datalen.
| int coap_ep_dtls_write | ( | const coap_endpoint_t * | ep, |
| const unsigned char * | message, | ||
| int | len ) |
Encrypt app.
data and send via UDP.
| ep | Pointer to destination CoAP endpoint. |
| message | Pointer to the buffer holding app. data. |
| len | Length of message to be sent. |
Definition at line 734 of file mbedtls-support.c.
References coap_ep_get_dtls_session_info().
Referenced by coap_sendto().
| coap_dtls_session_info_t * coap_ep_get_dtls_session_info | ( | const coap_endpoint_t * | ep | ) |
Get session struct associated with CoAP endpoint.
| ep | Pointer of peer CoAP endpoint. |
Definition at line 224 of file mbedtls-support.c.
References coap_endpoint_cmp(), and list_head().
Referenced by coap_dtls_event_handler(), coap_ep_dtls_disconnect(), coap_ep_dtls_handle_message(), coap_ep_dtls_write(), coap_ep_get_dtls_state(), and coap_ep_is_dtls_connected().
| int coap_ep_get_dtls_state | ( | const coap_endpoint_t * | ep | ) |
Check in what DTLS state the peer is in.
| ep | Pointer of peer CoAP endpoint. |
Definition at line 244 of file mbedtls-support.c.
References coap_ep_get_dtls_session_info().
| bool coap_ep_is_dtls_connected | ( | const coap_endpoint_t * | ep | ) |
Check if a peer has completed the handshake successfully.
| ep | Pointer of peer CoAP endpoint. |
Definition at line 237 of file mbedtls-support.c.
References coap_ep_get_dtls_session_info().
Referenced by coap_endpoint_is_connected().
| bool coap_ep_is_dtls_peer | ( | const coap_endpoint_t * | ep | ) |
Check if a CoAP endpoint is a peer in the list of DTLS sessions.
| ep | Pointer of peer CoAP endpoint. |
Definition at line 195 of file mbedtls-support.c.
References coap_endpoint_cmp(), and list_head().
Referenced by coap_endpoint_is_connected().