mirror of
https://github.com/obgm/libcoap.git
synced 2026-12-01 02:27:09 +03:00
tls_layer: Separate out (D)TLS layer functionality
Add in new file src/coap_dtls.c. Add in coap_(d)tls_establish() functions which are called when netif accept / connect take place. Add in coap_session_establish() function which is called when (D)TLS has established as well as at the session layer if there is no (D)TLS in preparation for properly supporting protocol layers. Add in coap_(d)tls_close() functions which are called prior to coap_netif_close().
This commit is contained in:
1 parent
7d76228b86
commit
ecf07b53b5
17 files changed
+253
-126
No files matched your search
@@ -265,6 +265,27 @@ int coap_dtls_hello(coap_session_t *coap_session,
|
||||
size_t data_len);
|
||||
#endif /* COAP_SERVER_SUPPORT */
|
||||
|
||||
/**
|
||||
* Layer function interface for layer below DTLS connect being
|
||||
* established.
|
||||
*
|
||||
* If this layer is properly established on invocation, then the next layer
|
||||
* must get called by calling
|
||||
* coap_session_establish(session)
|
||||
* (or done at any point when DTLS is established).
|
||||
*
|
||||
* @param session Session that the lower layer connect was done on.
|
||||
*
|
||||
*/
|
||||
void coap_dtls_establish(coap_session_t *session);
|
||||
|
||||
/**
|
||||
* Layer function interface for DTLS close for a session.
|
||||
*
|
||||
* @param session Session to do the DTLS close on.
|
||||
*/
|
||||
void coap_dtls_close(coap_session_t *session);
|
||||
|
||||
/**
|
||||
* Get DTLS overhead over cleartext PDUs.
|
||||
*
|
||||
@@ -340,6 +361,27 @@ ssize_t coap_tls_read(coap_session_t *coap_session,
|
||||
size_t data_len
|
||||
);
|
||||
|
||||
/**
|
||||
* Layer function interface for layer below TLS accept/connect being
|
||||
* established. This function initiates an accept/connect at the TLS layer.
|
||||
*
|
||||
* If this layer is properly established on invocation, then the next layer
|
||||
* must get called by calling
|
||||
* coap_session_establish(session)
|
||||
* (or done at any point when TLS is established).
|
||||
*
|
||||
* @param session Session that the lower layer accept/connect was done on.
|
||||
*
|
||||
*/
|
||||
void coap_tls_establish(coap_session_t *session);
|
||||
|
||||
/**
|
||||
* Layer function interface for TLS close for a session.
|
||||
*
|
||||
* @param session Session to do the TLS close on.
|
||||
*/
|
||||
void coap_tls_close(coap_session_t *session);
|
||||
|
||||
/**
|
||||
* Get the current client's PSK key.
|
||||
*
|
||||
|
||||
@@ -72,7 +72,9 @@ typedef enum {
|
||||
COAP_NACK_RST,
|
||||
COAP_NACK_TLS_FAILED,
|
||||
COAP_NACK_ICMP_ISSUE,
|
||||
COAP_NACK_BAD_RESPONSE
|
||||
COAP_NACK_BAD_RESPONSE,
|
||||
COAP_NACK_TLS_LAYER_FAILED,
|
||||
COAP_NACK_SESSION_LAYER_FAILED,
|
||||
} coap_nack_reason_t;
|
||||
|
||||
#endif /* COAP_IO_H_ */
|
||||
@@ -67,7 +67,7 @@ typedef enum coap_ext_token_check_t {
|
||||
struct coap_session_t {
|
||||
coap_proto_t proto; /**< protocol used */
|
||||
coap_session_type_t type; /**< client or server side socket */
|
||||
coap_session_state_t state; /**< current state of relationaship with
|
||||
coap_session_state_t state; /**< current state of relationship with
|
||||
peer */
|
||||
unsigned ref; /**< reference count from queues */
|
||||
size_t tls_overhead; /**< overhead of TLS layer */
|
||||
@@ -274,6 +274,16 @@ coap_session_t *coap_new_server_session(
|
||||
);
|
||||
#endif /* COAP_SERVER_SUPPORT */
|
||||
|
||||
/**
|
||||
* Layer function interface for layer below session accept/connect being
|
||||
* established. This function initiates a CSM request for reliable protocols,
|
||||
* or coap_session_connect() for un-reliable protocols.
|
||||
*
|
||||
* @param session Session that the lower layer accept/connect was done on.
|
||||
*
|
||||
*/
|
||||
void coap_session_establish(coap_session_t *session);
|
||||
|
||||
/**
|
||||
* Send a pdu according to the session's protocol. This function returns
|
||||
* the number of bytes that have been transmitted, or a value less than zero
|
||||
|
||||
Reference in new issue
Block a user