libcoap  4.2.0
coap_notls.c
Go to the documentation of this file.
1 /*
2 * coap_notls.c -- Stub Datagram Transport Layer Support for libcoap
3 *
4 * Copyright (C) 2016 Olaf Bergmann <bergmann@tzi.org>
5 *
6 * This file is part of the CoAP library libcoap. Please see README for terms
7 * of use.
8 */
9 
10 #include "coap_config.h"
11 
12 #if !defined(HAVE_LIBTINYDTLS) && !defined(HAVE_OPENSSL) && !defined(HAVE_LIBGNUTLS)
13 
14 #include "net.h"
15 
16 #ifdef __GNUC__
17 #define UNUSED __attribute__((unused))
18 #else /* __GNUC__ */
19 #define UNUSED
20 #endif /* __GNUC__ */
21 
22 int
24  return 0;
25 }
26 
27 int
29  return 0;
30 }
31 
34  static coap_tls_version_t version;
35  version.version = 0;
36  version.type = COAP_TLS_LIBRARY_NOTLS;
37  return &version;
38 }
39 
40 int
42  coap_dtls_pki_t* setup_data UNUSED,
43  coap_dtls_role_t role UNUSED
44 ) {
45  return 0;
46 }
47 
48 int
50  const char *ca_file UNUSED,
51  const char *ca_path UNUSED
52 ) {
53  return 0;
54 }
55 
56 int
58  const char *hint UNUSED,
59  coap_dtls_role_t role UNUSED
60 ) {
61  return 0;
62 }
63 
64 int
66 {
67  return 0;
68 }
69 
70 static int dtls_log_level = 0;
71 
72 void coap_dtls_startup(void) {
73 }
74 
75 void
77  dtls_log_level = level;
78 }
79 
80 int
82  return dtls_log_level;
83 }
84 
85 void *
87  return NULL;
88 }
89 
90 void
92 }
93 
95  return NULL;
96 }
97 
99  return NULL;
100 }
101 
103 }
104 
106 }
107 
108 int
110  const uint8_t *data UNUSED,
111  size_t data_len UNUSED
112 ) {
113  return -1;
114 }
115 
117  return 1;
118 }
119 
121  return 0;
122 }
123 
125  return 0;
126 }
127 
129 }
130 
131 int
133  const uint8_t *data UNUSED,
134  size_t data_len UNUSED
135 ) {
136  return -1;
137 }
138 
139 int
141  const uint8_t *data UNUSED,
142  size_t data_len UNUSED
143 ) {
144  return 0;
145 }
146 
148  return 0;
149 }
150 
151 void *coap_tls_new_client_session(coap_session_t *session UNUSED, int *connected UNUSED) {
152  return NULL;
153 }
154 
155 void *coap_tls_new_server_session(coap_session_t *session UNUSED, int *connected UNUSED) {
156  return NULL;
157 }
158 
160 }
161 
163  const uint8_t *data UNUSED,
164  size_t data_len UNUSED
165 ) {
166  return -1;
167 }
168 
170  uint8_t *data UNUSED,
171  size_t data_len UNUSED
172 ) {
173  return -1;
174 }
175 
176 #undef UNUSED
177 
178 #else /* !HAVE_LIBTINYDTLS && !HAVE_OPENSSL && !HAVE_LIBGNUTLS */
179 
180 #ifdef __clang__
181 /* Make compilers happy that do not like empty modules. As this function is
182  * never used, we ignore -Wunused-function at the end of compiling this file
183  */
184 #pragma GCC diagnostic ignored "-Wunused-function"
185 #endif
186 static inline void dummy(void) {
187 }
188 
189 #endif /* !HAVE_LIBTINYDTLS && !HAVE_OPENSSL && !HAVE_LIBGNUTLS */
void coap_dtls_set_log_level(int level)
Sets the (D)TLS logging level to the specified level.
Definition: coap_notls.c:76
int coap_dtls_hello(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:140
void coap_tls_free_session(coap_session_t *coap_session UNUSED)
Definition: coap_notls.c:159
int coap_dtls_receive(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:132
int coap_dtls_context_check_keys_enabled(coap_context_t *ctx UNUSED)
Definition: coap_notls.c:65
ssize_t coap_tls_read(coap_session_t *session UNUSED, uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:169
int coap_dtls_get_log_level(void)
Get the current (D)TLS logging.
Definition: coap_notls.c:81
void * coap_dtls_new_client_session(coap_session_t *session UNUSED)
Definition: coap_notls.c:98
int coap_dtls_is_supported(void)
Check whether DTLS is available.
Definition: coap_notls.c:23
void coap_dtls_free_context(void *handle UNUSED)
Definition: coap_notls.c:91
int coap_dtls_context_set_pki(coap_context_t *ctx UNUSED, coap_dtls_pki_t *setup_data UNUSED, coap_dtls_role_t role UNUSED)
Definition: coap_notls.c:41
void * coap_tls_new_server_session(coap_session_t *session UNUSED, int *connected UNUSED)
Definition: coap_notls.c:155
ssize_t coap_tls_write(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:162
uint64_t version
(D)TLS runtime Library Version
Definition: coap_dtls.h:48
void * coap_tls_new_client_session(coap_session_t *session UNUSED, int *connected UNUSED)
Definition: coap_notls.c:151
int coap_tls_is_supported(void)
Check whether TLS is available.
Definition: coap_notls.c:28
coap_tls_version_t * coap_get_tls_library_version(void)
Determine the type and version of the underlying (D)TLS library.
Definition: coap_notls.c:33
int type
Library type.
Definition: coap_dtls.h:49
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
Definition: coap_time.h:85
COAP_STATIC_INLINE void dummy(void)
Definition: coap_time.c:132
unsigned int coap_dtls_get_overhead(coap_session_t *session UNUSED)
Definition: coap_notls.c:147
static int dtls_log_level
Definition: coap_notls.c:70
The structure used for returning the underlying (D)TLS library information.
Definition: coap_dtls.h:47
int coap_dtls_context_set_psk(coap_context_t *ctx UNUSED, const char *hint UNUSED, coap_dtls_role_t role UNUSED)
Definition: coap_notls.c:57
coap_dtls_role_t
Definition: coap_dtls.h:264
void coap_dtls_free_session(coap_session_t *coap_session UNUSED)
Definition: coap_notls.c:102
void * coap_dtls_new_server_session(coap_session_t *session UNUSED)
Definition: coap_notls.c:94
The structure used for defining the PKI setup data to be used.
Definition: coap_dtls.h:191
int coap_dtls_context_set_pki_root_cas(struct coap_context_t *ctx UNUSED, const char *ca_file UNUSED, const char *ca_path UNUSED)
Definition: coap_notls.c:49
int coap_dtls_send(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:109
coap_tick_t coap_dtls_get_timeout(coap_session_t *session UNUSED)
Definition: coap_notls.c:124
#define COAP_TLS_LIBRARY_NOTLS
No DTLS library.
Definition: coap_dtls.h:38
void coap_dtls_handle_timeout(coap_session_t *session UNUSED)
Definition: coap_notls.c:128
void coap_dtls_startup(void)
Initialize the underlying (D)TLS Library layer.
Definition: coap_notls.c:72
unsigned char uint8_t
Definition: uthash.h:79
#define UNUSED
Definition: coap_notls.c:19
coap_tick_t coap_dtls_get_context_timeout(void *dtls_context UNUSED)
Definition: coap_notls.c:120
void coap_dtls_session_update_mtu(coap_session_t *session UNUSED)
Definition: coap_notls.c:105
void * coap_dtls_new_context(struct coap_context_t *coap_context UNUSED)
Definition: coap_notls.c:86
The CoAP stack&#39;s global state is stored in a coap_context_t object.
Definition: net.h:148
int coap_dtls_is_context_timeout(void)
Check if timeout is handled per CoAP session or per CoAP context.
Definition: coap_notls.c:116