mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-14 04:09:43 +03:00
Merge branch 'tls-supported' of https://github.com/mrdeep1/libcoap into mrdeep1-tls-supported
This commit is contained in:
commit
16685d7736
6 files changed
+49
No files matched your search
@@ -27,6 +27,21 @@ int coap_dtls_is_supported(void);
|
||||
/** Returns 1 if support for TLS is enabled, or 0 otherwise. */
|
||||
int coap_tls_is_supported( void );
|
||||
|
||||
#define COAP_TLS_LIBRARY_NOTLS 0
|
||||
#define COAP_TLS_LIBRARY_TINYDTLS 1
|
||||
#define COAP_TLS_LIBRARY_OPENSSL 2
|
||||
#define COAP_TLS_LIBRARY_GNUTLS 3
|
||||
|
||||
typedef struct coap_tls_version_t {
|
||||
uint64_t version; /* Library Version */
|
||||
int type; /* One of COAP_TLS_LIBRARY_* */
|
||||
} coap_tls_version_t;
|
||||
|
||||
/**
|
||||
* Returns the version and type of library libcoap was compiled against
|
||||
*/
|
||||
coap_tls_version_t *coap_get_tls_library_version(void);
|
||||
|
||||
/** Sets the log level to the specified value. */
|
||||
void coap_dtls_set_log_level(int level);
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ global:
|
||||
coap_get_log_level;
|
||||
coap_get_query;
|
||||
coap_get_resource_from_key;
|
||||
coap_get_tls_library_version;
|
||||
coap_handle_dgram;
|
||||
coap_handle_event;
|
||||
coap_handle_failed_notify;
|
||||
|
||||
@@ -71,6 +71,7 @@ coap_get_data
|
||||
coap_get_log_level
|
||||
coap_get_query
|
||||
coap_get_resource_from_key
|
||||
coap_get_tls_library_version
|
||||
coap_handle_dgram
|
||||
coap_handle_event
|
||||
coap_handle_failed_notify
|
||||
|
||||
@@ -29,6 +29,14 @@ 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;
|
||||
}
|
||||
|
||||
static int dtls_log_level = 0;
|
||||
|
||||
void coap_dtls_startup(void) {
|
||||
|
||||
@@ -40,13 +40,29 @@ typedef struct coap_openssl_context_t {
|
||||
} coap_openssl_context_t;
|
||||
|
||||
int coap_dtls_is_supported(void) {
|
||||
if (SSLeay() < 0x10100000L) {
|
||||
coap_log(LOG_WARNING, "OpenSSL version 1.1.0 or later is required\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int coap_tls_is_supported(void) {
|
||||
if (SSLeay() < 0x10100000L) {
|
||||
coap_log(LOG_WARNING, "OpenSSL version 1.1.0 or later is required\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
coap_tls_version_t *
|
||||
coap_get_tls_library_version(void) {
|
||||
static coap_tls_version_t version;
|
||||
version.version = SSLeay();
|
||||
version.type = COAP_TLS_LIBRARY_OPENSSL;
|
||||
return &version;
|
||||
}
|
||||
|
||||
void coap_dtls_startup(void) {
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
|
||||
@@ -444,6 +444,14 @@ 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 = DTLS_VERSION;
|
||||
version.type = COAP_TLS_LIBRARY_TINYDTLS;
|
||||
return &version;
|
||||
}
|
||||
|
||||
void *coap_tls_new_client_session(coap_session_t *session UNUSED, int *connected UNUSED) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user