Add support to return the library version number and string via the API.
diff --git a/include/srtp.h b/include/srtp.h
index 27bd934..a9e5256 100644
--- a/include/srtp.h
+++ b/include/srtp.h
@@ -1239,6 +1239,18 @@
srtp_install_event_handler(srtp_event_handler_func_t func);
/**
+ * @brief Returns the version string of the library.
+ *
+ */
+char *srtp_get_version_string(void);
+
+/**
+ * @brief Returns the numeric representation of the library version.
+ *
+ */
+unsigned int srtp_get_version(void);
+
+/**
* @}
*/
/* in host order, so outside the #if */
diff --git a/include/srtp_priv.h b/include/srtp_priv.h
index e041829..170df5b 100644
--- a/include/srtp_priv.h
+++ b/include/srtp_priv.h
@@ -57,6 +57,9 @@
#include "key.h"
#include "crypto_kernel.h"
+#define SRTP_VER_STRING PACKAGE_STRING
+#define SRTP_VERSION PACKAGE_VERSION
+
/*
* an srtp_hdr_t represents the srtp header
*
diff --git a/srtp/srtp.c b/srtp/srtp.c
index 45432f4..4c2583d 100644
--- a/srtp/srtp.c
+++ b/srtp/srtp.c
@@ -72,6 +72,35 @@
#define octets_in_rtcp_header 8
#define uint32s_in_rtcp_header 2
+char *srtp_get_version_string ()
+{
+ /*
+ * Simply return the autotools generated string
+ */
+ return SRTP_VER_STRING;
+}
+
+unsigned int srtp_get_version ()
+{
+ unsigned int major = 0, minor = 0, micro = 0;
+ unsigned int rv = 0;
+
+ /*
+ * Parse the autotools generated version
+ */
+ sscanf(SRTP_VERSION, "%u.%u.%u", &major, &minor, µ);
+
+ /*
+ * We allow 8 bits for the major and minor, while
+ * allowing 16 bits for the micro. 16 bits for the micro
+ * may be beneficial for a continuous delivery model
+ * in the future.
+ */
+ rv |= (major & 0xFF) << 24;
+ rv |= (minor & 0xFF) << 16;
+ rv |= micro & 0xFF;
+ return rv;
+}
err_status_t
srtp_stream_alloc(srtp_stream_ctx_t **str_ptr,
diff --git a/test/rtpw.c b/test/rtpw.c
index e90fa6c..48c6649 100644
--- a/test/rtpw.c
+++ b/test/rtpw.c
@@ -181,6 +181,8 @@
}
#endif
+ printf("Using %s [0x%x]\n", srtp_get_version_string(), srtp_get_version());
+
if (setup_signal_handler(argv[0]) != 0) {
exit(1);
}