• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_internal.h"
11 #include "coap_dtls.h"
12 
13 #if !defined(HAVE_LIBTINYDTLS) && !defined(HAVE_OPENSSL) && !defined(HAVE_LIBGNUTLS)
14 
15 #ifdef __GNUC__
16 #define UNUSED __attribute__((unused))
17 #else /* __GNUC__ */
18 #define UNUSED
19 #endif /* __GNUC__ */
20 
21 int
coap_dtls_is_supported(void)22 coap_dtls_is_supported(void) {
23   return 0;
24 }
25 
26 int
coap_tls_is_supported(void)27 coap_tls_is_supported(void) {
28   return 0;
29 }
30 
31 coap_tls_version_t *
coap_get_tls_library_version(void)32 coap_get_tls_library_version(void) {
33   static coap_tls_version_t version;
34   version.version = 0;
35   version.type = COAP_TLS_LIBRARY_NOTLS;
36   return &version;
37 }
38 
39 int
coap_dtls_context_set_pki(coap_context_t * ctx UNUSED,coap_dtls_pki_t * setup_data UNUSED,coap_dtls_role_t role UNUSED)40 coap_dtls_context_set_pki(coap_context_t *ctx UNUSED,
41                           coap_dtls_pki_t* setup_data UNUSED,
42                           coap_dtls_role_t role UNUSED
43 ) {
44   return 0;
45 }
46 
47 int
coap_dtls_context_set_pki_root_cas(struct coap_context_t * ctx UNUSED,const char * ca_file UNUSED,const char * ca_path UNUSED)48 coap_dtls_context_set_pki_root_cas(struct coap_context_t *ctx UNUSED,
49                                    const char *ca_file UNUSED,
50                                    const char *ca_path UNUSED
51 ) {
52   return 0;
53 }
54 
55 int
coap_dtls_context_set_psk(coap_context_t * ctx UNUSED,const char * hint UNUSED,coap_dtls_role_t role UNUSED)56 coap_dtls_context_set_psk(coap_context_t *ctx UNUSED,
57                           const char *hint UNUSED,
58                           coap_dtls_role_t role UNUSED
59 ) {
60   return 0;
61 }
62 
63 int
coap_dtls_context_check_keys_enabled(coap_context_t * ctx UNUSED)64 coap_dtls_context_check_keys_enabled(coap_context_t *ctx UNUSED)
65 {
66   return 0;
67 }
68 
69 static int dtls_log_level = 0;
70 
coap_dtls_startup(void)71 void coap_dtls_startup(void) {
72 }
73 
74 void
coap_dtls_set_log_level(int level)75 coap_dtls_set_log_level(int level) {
76   dtls_log_level = level;
77 }
78 
79 int
coap_dtls_get_log_level(void)80 coap_dtls_get_log_level(void) {
81   return dtls_log_level;
82 }
83 
84 void *
coap_dtls_new_context(struct coap_context_t * coap_context UNUSED)85 coap_dtls_new_context(struct coap_context_t *coap_context UNUSED) {
86   return NULL;
87 }
88 
89 void
coap_dtls_free_context(void * handle UNUSED)90 coap_dtls_free_context(void *handle UNUSED) {
91 }
92 
coap_dtls_new_server_session(coap_session_t * session UNUSED)93 void *coap_dtls_new_server_session(coap_session_t *session UNUSED) {
94   return NULL;
95 }
96 
coap_dtls_new_client_session(coap_session_t * session UNUSED)97 void *coap_dtls_new_client_session(coap_session_t *session UNUSED) {
98   return NULL;
99 }
100 
coap_dtls_free_session(coap_session_t * coap_session UNUSED)101 void coap_dtls_free_session(coap_session_t *coap_session UNUSED) {
102 }
103 
coap_dtls_session_update_mtu(coap_session_t * session UNUSED)104 void coap_dtls_session_update_mtu(coap_session_t *session UNUSED) {
105 }
106 
107 int
coap_dtls_send(coap_session_t * session UNUSED,const uint8_t * data UNUSED,size_t data_len UNUSED)108 coap_dtls_send(coap_session_t *session UNUSED,
109   const uint8_t *data UNUSED,
110   size_t data_len UNUSED
111 ) {
112   return -1;
113 }
114 
coap_dtls_is_context_timeout(void)115 int coap_dtls_is_context_timeout(void) {
116   return 1;
117 }
118 
coap_dtls_get_context_timeout(void * dtls_context UNUSED)119 coap_tick_t coap_dtls_get_context_timeout(void *dtls_context UNUSED) {
120   return 0;
121 }
122 
123 coap_tick_t
coap_dtls_get_timeout(coap_session_t * session UNUSED,coap_tick_t now UNUSED)124 coap_dtls_get_timeout(coap_session_t *session UNUSED, coap_tick_t now UNUSED) {
125   return 0;
126 }
127 
coap_dtls_handle_timeout(coap_session_t * session UNUSED)128 void coap_dtls_handle_timeout(coap_session_t *session UNUSED) {
129 }
130 
131 int
coap_dtls_receive(coap_session_t * session UNUSED,const uint8_t * data UNUSED,size_t data_len UNUSED)132 coap_dtls_receive(coap_session_t *session UNUSED,
133   const uint8_t *data UNUSED,
134   size_t data_len UNUSED
135 ) {
136   return -1;
137 }
138 
139 int
coap_dtls_hello(coap_session_t * session UNUSED,const uint8_t * data UNUSED,size_t data_len UNUSED)140 coap_dtls_hello(coap_session_t *session UNUSED,
141   const uint8_t *data UNUSED,
142   size_t data_len UNUSED
143 ) {
144   return 0;
145 }
146 
coap_dtls_get_overhead(coap_session_t * session UNUSED)147 unsigned int coap_dtls_get_overhead(coap_session_t *session UNUSED) {
148   return 0;
149 }
150 
coap_tls_new_client_session(coap_session_t * session UNUSED,int * connected UNUSED)151 void *coap_tls_new_client_session(coap_session_t *session UNUSED, int *connected UNUSED) {
152   return NULL;
153 }
154 
coap_tls_new_server_session(coap_session_t * session UNUSED,int * connected UNUSED)155 void *coap_tls_new_server_session(coap_session_t *session UNUSED, int *connected UNUSED) {
156   return NULL;
157 }
158 
coap_tls_free_session(coap_session_t * coap_session UNUSED)159 void coap_tls_free_session(coap_session_t *coap_session UNUSED) {
160 }
161 
coap_tls_write(coap_session_t * session UNUSED,const uint8_t * data UNUSED,size_t data_len UNUSED)162 ssize_t coap_tls_write(coap_session_t *session UNUSED,
163                        const uint8_t *data UNUSED,
164                        size_t data_len UNUSED
165 ) {
166   return -1;
167 }
168 
coap_tls_read(coap_session_t * session UNUSED,uint8_t * data UNUSED,size_t data_len UNUSED)169 ssize_t coap_tls_read(coap_session_t *session UNUSED,
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
dummy(void)186 static inline void dummy(void) {
187 }
188 
189 #endif /* !HAVE_LIBTINYDTLS && !HAVE_OPENSSL && !HAVE_LIBGNUTLS */
190