coap_notls.c
Go to the documentation of this file.
/*
* coap_notls.c -- Stub Datagram Transport Layer Support for libcoap
*
* Copyright (C) 2016 Olaf Bergmann <bergmann@tzi.org>
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#include "coap_internal.h"
#if !defined(HAVE_LIBTINYDTLS) && !defined(HAVE_OPENSSL) && !defined(HAVE_LIBGNUTLS)
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else /* __GNUC__ */
#define UNUSED
#endif /* __GNUC__ */
int
coap_dtls_is_supported(void) {
return 0;
}
int
coap_tls_is_supported(void) {
return 0;
}
coap_tls_version_t *
coap_get_tls_library_version(void) {
static coap_tls_version_t version;
version.version = 0;
version.type = COAP_TLS_LIBRARY_NOTLS;
return &version;
}
int
coap_dtls_context_set_pki(coap_context_t *ctx UNUSED,
coap_dtls_pki_t* setup_data UNUSED,
coap_dtls_role_t role UNUSED
) {
return 0;
}
int
coap_dtls_context_set_pki_root_cas(struct coap_context_t *ctx UNUSED,
const char *ca_file UNUSED,
const char *ca_path UNUSED
) {
return 0;
}
int
coap_dtls_context_set_psk(coap_context_t *ctx UNUSED,
const char *hint UNUSED,
coap_dtls_role_t role UNUSED
) {
return 0;
}
int
coap_dtls_context_check_keys_enabled(coap_context_t *ctx UNUSED)
{
return 0;
}
static int dtls_log_level = 0;
void coap_dtls_startup(void) {
}
void
coap_dtls_set_log_level(int level) {
dtls_log_level = level;
}
int
coap_dtls_get_log_level(void) {
return dtls_log_level;
}
void *
coap_dtls_new_context(struct coap_context_t *coap_context UNUSED) {
return NULL;
}
void
coap_dtls_free_context(void *handle UNUSED) {
}
void *coap_dtls_new_server_session(coap_session_t *session UNUSED) {
return NULL;
}
void *coap_dtls_new_client_session(coap_session_t *session UNUSED) {
return NULL;
}
void coap_dtls_free_session(coap_session_t *coap_session UNUSED) {
}
void coap_dtls_session_update_mtu(coap_session_t *session UNUSED) {
}
int
coap_dtls_send(coap_session_t *session UNUSED,
const uint8_t *data UNUSED,
size_t data_len UNUSED
) {
return -1;
}
int coap_dtls_is_context_timeout(void) {
return 1;
}
coap_tick_t coap_dtls_get_context_timeout(void *dtls_context UNUSED) {
return 0;
}
coap_tick_t
coap_dtls_get_timeout(coap_session_t *session UNUSED, coap_tick_t now UNUSED) {
return 0;
}
void coap_dtls_handle_timeout(coap_session_t *session UNUSED) {
}
int
coap_dtls_receive(coap_session_t *session UNUSED,
const uint8_t *data UNUSED,
size_t data_len UNUSED
) {
return -1;
}
int
coap_dtls_hello(coap_session_t *session UNUSED,
const uint8_t *data UNUSED,
size_t data_len UNUSED
) {
return 0;
}
unsigned int coap_dtls_get_overhead(coap_session_t *session UNUSED) {
return 0;
}
void *coap_tls_new_client_session(coap_session_t *session UNUSED, int *connected UNUSED) {
return NULL;
}
void *coap_tls_new_server_session(coap_session_t *session UNUSED, int *connected UNUSED) {
return NULL;
}
void coap_tls_free_session(coap_session_t *coap_session UNUSED) {
}
ssize_t coap_tls_write(coap_session_t *session UNUSED,
const uint8_t *data UNUSED,
size_t data_len UNUSED
) {
return -1;
}
ssize_t coap_tls_read(coap_session_t *session UNUSED,
uint8_t *data UNUSED,
size_t data_len UNUSED
) {
return -1;
}
#undef UNUSED
#else /* !HAVE_LIBTINYDTLS && !HAVE_OPENSSL && !HAVE_LIBGNUTLS */
#ifdef __clang__
/* Make compilers happy that do not like empty modules. As this function is
* never used, we ignore -Wunused-function at the end of compiling this file
*/
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
static inline void dummy(void) {
}
#endif /* !HAVE_LIBTINYDTLS && !HAVE_OPENSSL && !HAVE_LIBGNUTLS */
coap_internal.h
Pulls together all the internal only header files.
coap_dtls_context_set_pki_root_cas
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:47
coap_dtls_new_client_session
void * coap_dtls_new_client_session(coap_session_t *session UNUSED)
Definition: coap_notls.c:96
coap_dtls_context_set_psk
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:55
coap_dtls_get_context_timeout
coap_tick_t coap_dtls_get_context_timeout(void *dtls_context UNUSED)
Definition: coap_notls.c:118
coap_tls_new_client_session
void * coap_tls_new_client_session(coap_session_t *session UNUSED, int *connected UNUSED)
Definition: coap_notls.c:150
coap_dtls_receive
int coap_dtls_receive(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:131
coap_dtls_new_context
void * coap_dtls_new_context(struct coap_context_t *coap_context UNUSED)
Definition: coap_notls.c:84
coap_dtls_hello
int coap_dtls_hello(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:139
coap_tls_new_server_session
void * coap_tls_new_server_session(coap_session_t *session UNUSED, int *connected UNUSED)
Definition: coap_notls.c:154
coap_dtls_new_server_session
void * coap_dtls_new_server_session(coap_session_t *session UNUSED)
Definition: coap_notls.c:92
coap_tls_read
ssize_t coap_tls_read(coap_session_t *session UNUSED, uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:168
coap_dtls_get_timeout
coap_tick_t coap_dtls_get_timeout(coap_session_t *session UNUSED, coap_tick_t now UNUSED)
Definition: coap_notls.c:123
coap_dtls_context_check_keys_enabled
int coap_dtls_context_check_keys_enabled(coap_context_t *ctx UNUSED)
Definition: coap_notls.c:63
dtls_log_level
static int dtls_log_level
Definition: coap_notls.c:68
coap_tls_free_session
void coap_tls_free_session(coap_session_t *coap_session UNUSED)
Definition: coap_notls.c:158
coap_dtls_session_update_mtu
void coap_dtls_session_update_mtu(coap_session_t *session UNUSED)
Definition: coap_notls.c:103
coap_dtls_handle_timeout
void coap_dtls_handle_timeout(coap_session_t *session UNUSED)
Definition: coap_notls.c:127
coap_dtls_send
int coap_dtls_send(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:107
coap_dtls_free_session
void coap_dtls_free_session(coap_session_t *coap_session UNUSED)
Definition: coap_notls.c:100
coap_dtls_free_context
void coap_dtls_free_context(void *handle UNUSED)
Definition: coap_notls.c:89
coap_dtls_context_set_pki
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:39
coap_dtls_get_overhead
unsigned int coap_dtls_get_overhead(coap_session_t *session UNUSED)
Definition: coap_notls.c:146
coap_tls_write
ssize_t coap_tls_write(coap_session_t *session UNUSED, const uint8_t *data UNUSED, size_t data_len UNUSED)
Definition: coap_notls.c:161
UNUSED
#define UNUSED
Definition: coap_notls.c:17
dummy
COAP_STATIC_INLINE void dummy(void)
Definition: coap_time.c:129
coap_tick_t
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
Definition: coap_time.h:93
coap_dtls_startup
void coap_dtls_startup(void)
Initialize the underlying (D)TLS Library layer.
Definition: coap_notls.c:70
coap_dtls_role_t
coap_dtls_role_t
Definition: coap_dtls.h:266
coap_dtls_is_context_timeout
int coap_dtls_is_context_timeout(void)
Check if timeout is handled per CoAP session or per CoAP context.
Definition: coap_notls.c:114
coap_tls_is_supported
int coap_tls_is_supported(void)
Check whether TLS is available.
Definition: coap_notls.c:26
coap_get_tls_library_version
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:31
coap_dtls_is_supported
int coap_dtls_is_supported(void)
Check whether DTLS is available.
Definition: coap_notls.c:21
COAP_TLS_LIBRARY_NOTLS
@ COAP_TLS_LIBRARY_NOTLS
No DTLS library.
Definition: coap_dtls.h:41
coap_dtls_set_log_level
void coap_dtls_set_log_level(int level)
Sets the (D)TLS logging level to the specified level.
Definition: coap_notls.c:74
coap_dtls_get_log_level
int coap_dtls_get_log_level(void)
Get the current (D)TLS logging.
Definition: coap_notls.c:79
coap_context_t
The CoAP stack's global state is stored in a coap_context_t object.
Definition: net.h:147
coap_dtls_pki_t
The structure used for defining the PKI setup data to be used.
Definition: coap_dtls.h:193
coap_session_t
Definition: coap_session.h:59
coap_tls_version_t
The structure used for returning the underlying (D)TLS library information.
Definition: coap_dtls.h:51
coap_tls_version_t::type
coap_tls_library_t type
Library type.
Definition: coap_dtls.h:53
coap_tls_version_t::version
uint64_t version
(D)TLS runtime Library Version
Definition: coap_dtls.h:52
uint8_t
unsigned char uint8_t
Definition: uthash.h:79