diff --git a/include/coap2/coap_dtls.h b/include/coap2/coap_dtls.h index 1c1a10ed..2f61e032 100644 --- a/include/coap2/coap_dtls.h +++ b/include/coap2/coap_dtls.h @@ -45,8 +45,9 @@ int coap_tls_is_supported(void); * information. */ typedef struct coap_tls_version_t { - uint64_t version; /**< (D)TLS Library Version */ + uint64_t version; /**< (D)TLS runtime Library Version */ int type; /**< Library type. One of COAP_TLS_LIBRARY_* */ + uint64_t built_version; /**< (D)TLS Built against Library Version */ } coap_tls_version_t; /** diff --git a/src/coap_openssl.c b/src/coap_openssl.c index cf301281..0547a233 100644 --- a/src/coap_openssl.c +++ b/src/coap_openssl.c @@ -142,6 +142,7 @@ coap_tls_version_t * coap_get_tls_library_version(void) { static coap_tls_version_t version; version.version = SSLeay(); + version.built_version = OPENSSL_VERSION_NUMBER; version.type = COAP_TLS_LIBRARY_OPENSSL; return &version; } diff --git a/src/coap_tinydtls.c b/src/coap_tinydtls.c index 55947e8d..2ec5351a 100644 --- a/src/coap_tinydtls.c +++ b/src/coap_tinydtls.c @@ -453,7 +453,23 @@ int coap_tls_is_supported(void) { coap_tls_version_t * coap_get_tls_library_version(void) { static coap_tls_version_t version; - version.version = DTLS_VERSION; + const char *vers = dtls_package_version(); + + version.version = 0; + if (vers) { + long int p1, p2 = 0, p3 = 0; + char* endptr; + + p1 = strtol(vers, &endptr, 10); + if (*endptr == '.') { + p2 = strtol(endptr+1, &endptr, 10); + if (*endptr == '.') { + p3 = strtol(endptr+1, &endptr, 10); + } + } + version.version = (p1 << 16) | (p2 << 8) | p3; + } + version.built_version = version.version; version.type = COAP_TLS_LIBRARY_TINYDTLS; return &version; }