mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-14 04:09:43 +03:00
Extend coap_tls_version_t to include both built and runtime TLS versions
This allows an application to determine what the built version is as well as what the runtime version of a TLS library is. include/coap2/coap_dtls.h Add built_version to coap_tls_version_t src/coap_openssl.c src/coap_tinydtls.c Additionally populate coap_tls_version_t with build_version when coap_get_tls_library_version() is called. src/coap_tinydtls.c Correct the version returned as actual TinyDTLS version instead the binary value of a DTLS packet type.
This commit is contained in:
1 parent
ea29a48fd7
commit
4a543d1198
3 files changed
+20
-2
No files matched your search
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+17
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user