21
21
#include <stddef.h>
22
22
#include <inttypes.h>
23
23
#include <stdbool.h>
24
- #include "mbedtls/platform.h"
24
+
25
+ #ifdef NS_USE_EXTERNAL_MBED_TLS
25
26
#include "mbedtls/ssl.h"
26
- #include "mbedtls/sha256.h"
27
- #include "mbedtls/entropy.h"
28
- #include "mbedtls/ctr_drbg.h"
27
+ #ifdef MBEDTLS_SSL_TLS_C
28
+ #define COAP_SECURITY_AVAILABLE
29
+ #endif
30
+ #endif
29
31
30
32
#define COOKIE_SIMPLE_LEN 8
31
33
typedef struct simple_cookie {
@@ -68,6 +70,8 @@ typedef struct {
68
70
69
71
typedef struct coap_security_s coap_security_t ;
70
72
73
+ #ifdef COAP_SECURITY_AVAILABLE
74
+
71
75
coap_security_t * coap_security_create (int8_t socket_id , int8_t timer_id , void * handle ,
72
76
SecureConnectionMode mode ,
73
77
send_cb * send_cb ,
@@ -93,4 +97,26 @@ bool coap_security_handler_is_started(const coap_security_t *sec);
93
97
94
98
const void * coap_security_handler_keyblock (const coap_security_t * sec );
95
99
100
+ #else
101
+
102
+ /* Dummy definitions, including needed error codes */
103
+ #define MBEDTLS_ERR_SSL_TIMEOUT (-1)
104
+ #define MBEDTLS_ERR_SSL_WANT_READ (-2)
105
+ #define MBEDTLS_ERR_SSL_WANT_WRITE (-3)
106
+ #define MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE (-4)
107
+
108
+ #define coap_security_create (socket_id , timer_id , handle , \
109
+ mode , send_cb , receive_cb , start_timer_cb , timer_status_cb ) ((coap_security_t *) 0)
110
+ #define coap_security_destroy (sec ) ((void) 0)
111
+ #define coap_security_handler_connect (sec , is_server , sock_mode , keys ) (-1)
112
+ #define coap_security_handler_connect_non_blocking (sec , is_server , sock_mode , keys , timeout_min , timeout_max ) (-1)
113
+ #define coap_security_handler_continue_connecting (sec ) (-1)
114
+ #define coap_security_handler_send_message (sec , message , len ) (-1)
115
+ #define coap_security_send_close_alert (sec ) (-1)
116
+ #define coap_security_handler_read (sec , buffer , len ) (-1)
117
+ #define coap_security_handler_is_started (sec ) false
118
+ #define coap_security_handler_keyblock (sec ) ((void *) 0)
119
+
120
+ #endif /* COAP_SECURITY_AVAILABLE */
121
+
96
122
#endif
0 commit comments