diff --git a/configure.ac b/configure.ac index 7ad323be2..a5d6088bd 100644 --- a/configure.ac +++ b/configure.ac @@ -177,9 +177,21 @@ fi AC_CHECK_HEADER(srtp2/srtp.h, found_libsrtp2=yes) if test "$found_libsrtp2" = yes then - AC_CHECK_LIB(srtp2, srtp_init, + AC_CHECK_LIB(srtp2, srtp_init,[ LIBS_SRTP="-lsrtp2" - AC_DEFINE([ENABLE_SRTP2], 1, [Define if you have libsrtp2 library installed])) + # Test program to check if the srtp_protect function accepts size_t* argument + AC_MSG_CHECKING(['srtp_protect()' last argument type]) + original_cflags="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ + #include + #include ], + [srtp_t ctx; void* rtp_hdr; size_t len; return srtp_protect(ctx, rtp_hdr, &len);])], + [srtp_protect_lastarg=size_t], [srtp_protect_lastarg=int]) + CFLAGS="$original_cflags" + AC_MSG_RESULT([$srtp_protect_lastarg]) + AC_DEFINE_UNQUOTED([SRTP_PROTECT_LASTARG], [${srtp_protect_lastarg}], [Type of the last argument of the srtp_protect() API]) + AC_DEFINE([ENABLE_SRTP2], 1, [Define if you have libsrtp2 library installed])]) else # libsrtp AC_CHECK_HEADER(srtp/srtp.h, found_libsrtp=yes) diff --git a/extractaudio/eaud_crypto.c b/extractaudio/eaud_crypto.c index 195f9085a..97b102edb 100644 --- a/extractaudio/eaud_crypto.c +++ b/extractaudio/eaud_crypto.c @@ -169,7 +169,12 @@ static int srtp_inited; int eaud_crypto_decrypt(struct eaud_crypto *crypto, uint8_t *pkt_raw, int pkt_len) { - int status, octets_recvd; + int status; +#if defined(SRTP_PROTECT_LASTARG) + SRTP_PROTECT_LASTARG octets_recvd; +#else + size_t octets_recvd; +#endif rtp_hdr_t *rpkt; if (srtp_inited == 0) { diff --git a/modules/dtls_gw/rtpp_dtls_conn.c b/modules/dtls_gw/rtpp_dtls_conn.c index e5519ba5c..c03e9673c 100644 --- a/modules/dtls_gw/rtpp_dtls_conn.c +++ b/modules/dtls_gw/rtpp_dtls_conn.c @@ -454,7 +454,12 @@ rtpp_dtls_conn_dtls_recv(struct rtpp_dtls_conn *self, static int rtpp_dtls_conn_rtp_send(struct rtpp_dtls_conn *self, struct pkt_proc_ctx *pktxp) { - int status, len; + int status; +#if defined(SRTP_PROTECT_LASTARG) + SRTP_PROTECT_LASTARG len; +#else + size_t len; +#endif struct rtpp_dtls_conn_priv *pvt; PUB2PVT(self, pvt); @@ -477,7 +482,12 @@ rtpp_dtls_conn_rtp_send(struct rtpp_dtls_conn *self, struct pkt_proc_ctx *pktxp) static int rtpp_dtls_conn_srtp_recv(struct rtpp_dtls_conn *self, struct pkt_proc_ctx *pktxp) { - int status, len; + int status; +#if defined(SRTP_PROTECT_LASTARG) + SRTP_PROTECT_LASTARG len; +#else + size_t len; +#endif struct rtpp_dtls_conn_priv *pvt; PUB2PVT(self, pvt); diff --git a/src/config.h.in b/src/config.h.in index ea7f70a0b..3d1cfff7e 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -211,6 +211,9 @@ /* The number of bytes in type time_t */ #undef SIZEOF_TIME_T +/* Type of the last argument of the srtp_protect() API */ +#undef SRTP_PROTECT_LASTARG + /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime.