diff --git a/configure b/configure index 26ead08ba..167faf0a2 100755 --- a/configure +++ b/configure @@ -683,6 +683,8 @@ BUILD_UDP_CONTENTION_FALSE BUILD_UDP_CONTENTION_TRUE BUILD_LOG_STAND_FALSE BUILD_LOG_STAND_TRUE +HAVE_LIBCRYPTO_FALSE +HAVE_LIBCRYPTO_TRUE BUILD_CRYPTO_FALSE BUILD_CRYPTO_TRUE BUILD_ELPERIODIC_FALSE @@ -15426,6 +15428,56 @@ fi fi fi +# libcrypto (OpenSSL), for --record_callid_hash sha256 +ac_fn_c_check_header_compile "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default" +if test "x$ac_cv_header_openssl_evp_h" = xyes +then : + found_libcrypto=yes +fi + +if test "$found_libcrypto" = yes +then + save_LIBS="${LIBS}" + LIBS="${LIBS} ${LIB_CRYPTO}" + { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for EVP_Digest in libcrypto" >&5 +printf %s "checking for EVP_Digest in libcrypto... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + +int +main (void) +{ + + return EVP_Digest("", 0, NULL, NULL, EVP_sha256(), NULL); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + + { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf '%s\n' "yes" >&6; } + found_evp_digest=yes + +printf '%s\n' "#define HAVE_LIBCRYPTO 1" >>confdefs.h + + +else case e in #( + e) + { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf '%s\n' "no" >&6; } + ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LIBS="${save_LIBS}" +fi + # libelperiodic ac_fn_c_check_header_compile "$LINENO" "elperiodic.h" "ac_cv_header_elperiodic_h" "$ac_includes_default" if test "x$ac_cv_header_elperiodic_h" = xyes @@ -16949,6 +17001,14 @@ else BUILD_CRYPTO_FALSE= fi + if test "x${found_evp_digest}" = xyes; then + HAVE_LIBCRYPTO_TRUE= + HAVE_LIBCRYPTO_FALSE='#' +else + HAVE_LIBCRYPTO_TRUE='#' + HAVE_LIBCRYPTO_FALSE= +fi + if test "${LIBS_SIPLOG}" = ""; then BUILD_LOG_STAND_TRUE= BUILD_LOG_STAND_FALSE='#' @@ -17230,6 +17290,10 @@ if test -z "${BUILD_CRYPTO_TRUE}" && test -z "${BUILD_CRYPTO_FALSE}"; then as_fn_error $? "conditional \"BUILD_CRYPTO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_LIBCRYPTO_TRUE}" && test -z "${HAVE_LIBCRYPTO_FALSE}"; then + as_fn_error $? "conditional \"HAVE_LIBCRYPTO\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${BUILD_LOG_STAND_TRUE}" && test -z "${BUILD_LOG_STAND_FALSE}"; then as_fn_error $? "conditional \"BUILD_LOG_STAND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 52d4d6749..56bf3b08f 100644 --- a/configure.ac +++ b/configure.ac @@ -299,6 +299,27 @@ else fi fi +# libcrypto (OpenSSL), for --record_callid_hash sha256 +AC_CHECK_HEADER(openssl/evp.h, found_libcrypto=yes) +if test "$found_libcrypto" = yes +then + save_LIBS="${LIBS}" + LIBS="${LIBS} ${LIB_CRYPTO}" + AC_MSG_CHECKING([for EVP_Digest in libcrypto]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + #include + ], [ + return EVP_Digest("", 0, NULL, NULL, EVP_sha256(), NULL); + ])], [ + AC_MSG_RESULT([yes]) + found_evp_digest=yes + AC_DEFINE([HAVE_LIBCRYPTO], 1, [Define if you have libcrypto (OpenSSL) installed]) + ], [ + AC_MSG_RESULT([no]) + ]) + LIBS="${save_LIBS}" +fi + # libelperiodic AC_CHECK_HEADER(elperiodic.h, found_libelperiodic=yes) if test "$found_libelperiodic" = yes @@ -494,6 +515,7 @@ AM_CONDITIONAL(BUILD_MODULES, [test "${ENABLE_MODULE_IF}" = 1]) AM_CONDITIONAL(ENABLE_MODULE_IF, [test "${ENABLE_MODULE_IF}" = 1]) AM_CONDITIONAL(BUILD_ELPERIODIC, [test "${EXTERNAL_ELPERIODIC}" != 1]) AM_CONDITIONAL(BUILD_CRYPTO, [test "${LIBS_SRTP}" != ""]) +AM_CONDITIONAL(HAVE_LIBCRYPTO, [test "x${found_evp_digest}" = xyes]) AM_CONDITIONAL(BUILD_LOG_STAND, [test "${LIBS_SIPLOG}" = ""]) AM_CONDITIONAL(BUILD_UDP_CONTENTION, [test "${ENABLE_UDP_CONTENTION}" = 1]) AM_CONDITIONAL(BUILD_OBJCK, [test "${ENABLE_OBJCK}" = 1]) diff --git a/doc/manpage.xml b/doc/manpage.xml index 8ac63170c..3346c484e 100644 --- a/doc/manpage.xml +++ b/doc/manpage.xml @@ -186,6 +186,7 @@ + method @@ -819,6 +820,62 @@ names. + + + + method + + + Selects how the Call-ID is put into the recording file name + when the name is built from the Call-ID and from-tag (the + R and Rs commands and the + option). File names given explicitly with the + C command are not affected. The from-tag is + always used as is. method is one + of: + + + + raw + + + Use the Call-ID as is (the default). Calls whose + Call-ID contains / are not recorded. + + + + + sha256 + + + Use the SHA-256 digest of the Call-ID, written as 64 + lowercase hex characters. This is the recommended method + for its security properties. A recording can be found from + a known Call-ID by computing the same digest, for example + with printf '%s' "$CALLID" | sha256sum. + Available only if rtpproxy has been + built with OpenSSL. + + + + + b64url + + + Use the Call-ID encoded with the URL-safe base64 + alphabet (RFC 4648, section 5) without padding. Use it when + the Call-ID has to be recovered from the file name, for + example to index existing recordings. The resulting file + names are case-sensitive. + + + + + If method is unknown or is not + available in this build, rtpproxy reports an + error and exits. + + diff --git a/rtpproxy.8 b/rtpproxy.8 index 695805388..f316096bf 100644 --- a/rtpproxy.8 +++ b/rtpproxy.8 @@ -31,7 +31,7 @@ rtpproxy \- RTP (Real\-time Transport Protocol) Proxy Server .SH "SYNOPSIS" .HP \w'\fBrtpproxy\fR\ 'u -\fBrtpproxy\fR [\fB\-?\fR] [\fB\-2\fR] [\fB\-f\fR] [\fB\-v\fR] [\fB\-V\fR] [\fB\-R\fR] [\fB\-l\fR\ \fIaddr1\fR\fI[/addr2]\fR...] [\fB\-l\fR\ \fI[label@]\fR\fIaddress\fR\fI[=advertized_address]\fR...] [\fB\-6\fR\ \fIaddr1\fR\fI[/addr2]\fR...] [\fB\-6\fR\ \fI[label@]\fR\fIaddress\fR\fI[=advertized_address]\fR...] [\fB\-s\fR\ \fIctrl_socket\fR] [\fB\-t\fR\ \fItos\fR] [\fB\-p\fR\ \fIpidfile\fR] [\fB\-T\fR\ \fImax_ttl\fR] [\fB\-\-maxpps\fR\ \fIpps\fR\fI[,rtcp_pps]\fR] [\fB\-\-maxpsize\fR\ \fIsize\fR\fI[,rtcp_size]\fR] [\fB\-r\fR\ \fIrdir\fR\ [\fB\-S\fR\ \fIsdir\fR]] [\fB\-L\fR\ \fInofile_limit\fR] [\fB\-A\fR\ \fIadvaddr1\fR\fI[/advaddr2]\fR] [\fB\-m\fR\ \fImin_port\fR] [\fB\-M\fR\ \fImax_port\fR] [\fB\-u\fR\ \fIuname\fR\fI[:gname]\fR] [\fB\-w\fR\ \fIsock_mode\fR] [\fB\-F\fR] [\fB\-i\fR] [\fB\-n\fR\ \fItimeout_socket\fR] [\fB\-P\fR] [\fB\-a\fR] [\fB\-d\fR\ \fIlog_level\fR\fI[:log_facility]\fR] [\fB\-W\fR\ \fIsetup_ttl\fR] [\fB\-\-force_asymmetric\fR] [\fB\-b\fR] [\fB\-c\fR\ \fIfifo|rr\fR] [\fB\-\-nice\fR\ \fIlevel\fR] [\fB\-D\fR] [\fB\-\-no_redirect\fR] [\fB\-\-config\fR\ \fIconfig_file\fR] [\fB\-\-dso\fR\ \fImodule\fR...] [\fB\-\-bridge_symmetric\fR] [\fB\-\-no_resolve\fR] +\fBrtpproxy\fR [\fB\-?\fR] [\fB\-2\fR] [\fB\-f\fR] [\fB\-v\fR] [\fB\-V\fR] [\fB\-R\fR] [\fB\-l\fR\ \fIaddr1\fR\fI[/addr2]\fR...] [\fB\-l\fR\ \fI[label@]\fR\fIaddress\fR\fI[=advertized_address]\fR...] [\fB\-6\fR\ \fIaddr1\fR\fI[/addr2]\fR...] [\fB\-6\fR\ \fI[label@]\fR\fIaddress\fR\fI[=advertized_address]\fR...] [\fB\-s\fR\ \fIctrl_socket\fR] [\fB\-t\fR\ \fItos\fR] [\fB\-p\fR\ \fIpidfile\fR] [\fB\-T\fR\ \fImax_ttl\fR] [\fB\-\-maxpps\fR\ \fIpps\fR\fI[,rtcp_pps]\fR] [\fB\-\-maxpsize\fR\ \fIsize\fR\fI[,rtcp_size]\fR] [\fB\-r\fR\ \fIrdir\fR\ [\fB\-S\fR\ \fIsdir\fR]] [\fB\-L\fR\ \fInofile_limit\fR] [\fB\-A\fR\ \fIadvaddr1\fR\fI[/advaddr2]\fR] [\fB\-m\fR\ \fImin_port\fR] [\fB\-M\fR\ \fImax_port\fR] [\fB\-u\fR\ \fIuname\fR\fI[:gname]\fR] [\fB\-w\fR\ \fIsock_mode\fR] [\fB\-F\fR] [\fB\-i\fR] [\fB\-n\fR\ \fItimeout_socket\fR] [\fB\-P\fR] [\fB\-a\fR] [\fB\-d\fR\ \fIlog_level\fR\fI[:log_facility]\fR] [\fB\-W\fR\ \fIsetup_ttl\fR] [\fB\-\-force_asymmetric\fR] [\fB\-b\fR] [\fB\-c\fR\ \fIfifo|rr\fR] [\fB\-\-nice\fR\ \fIlevel\fR] [\fB\-D\fR] [\fB\-\-no_redirect\fR] [\fB\-\-config\fR\ \fIconfig_file\fR] [\fB\-\-dso\fR\ \fImodule\fR...] [\fB\-\-bridge_symmetric\fR] [\fB\-\-no_resolve\fR] [\fB\-\-record_callid_hash\fR\ \fImethod\fR] .HP \w'\fBrtpproxy\fR\ 'u \fBrtpproxy\fR \fB\-C\fR .SH "DESCRIPTION" @@ -502,6 +502,45 @@ In the bridging mode, do not treat all sessions as asymmetric, which is the defa .RS 4 Only accept numeric IP addresses, in the command line arguments and in the control commands, instead of resolving host names\&. .RE +.PP +\fB\-\-record_callid_hash\fR \fImethod\fR +.RS 4 +Selects how the Call\-ID is put into the recording file name when the name is built from the Call\-ID and from\-tag (the +\fBR\fR +and +\fBRs\fR +commands and the +\fB\-a\fR +option)\&. File names given explicitly with the +\fBC\fR +command are not affected\&. The from\-tag is always used as is\&. +\fImethod\fR +is one of: +.PP +raw +.RS 4 +Use the Call\-ID as is (the default)\&. Calls whose Call\-ID contains "/" are not recorded\&. +.RE +.PP +sha256 +.RS 4 +Use the SHA\-256 digest of the Call\-ID, written as 64 lowercase hex characters\&. This is the recommended method for its security properties\&. A recording can be found from a known Call\-ID by computing the same digest, for example with +\fBprintf \*(Aq%s\*(Aq "$CALLID" | sha256sum\fR\&. Available only if +\fBrtpproxy\fR +has been built with OpenSSL\&. +.RE +.PP +b64url +.RS 4 +Use the Call\-ID encoded with the URL\-safe base64 alphabet (RFC 4648, section 5) without padding\&. Use it when the Call\-ID has to be recovered from the file name, for example to index existing recordings\&. The resulting file names are case\-sensitive\&. +.RE +.sp +If +\fImethod\fR +is unknown or is not available in this build, +\fBrtpproxy\fR +reports an error and exits\&. +.RE .SH "PRINCIPLES OF OPERATION" .PP When the SIP controller receives an INVITE request, it extracts the Call\-ID and from_tag from INVITE\&. The call controller communicates it with the rtpproxy via Unix domain socket or a UDP socket\&. rtpproxy looks for an existing session with the given Call\-ID and from_tag\&. diff --git a/src/Makefile.am b/src/Makefile.am index 01c5db0de..046de3a6f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -75,6 +75,7 @@ BASE_SOURCES=main.c rtp.h rtpp_server.c \ rtpp_network_io.c rtpp_network_io.h rtpp_wi_pkt.c rtpp_wi_pkt.h \ rtpp_timeout_data.c rtpp_timeout_data.h rtpp_locking.h \ rtpp_nofile.c rtpp_nofile.h rtpp_record_adhoc.h \ + rtpp_record_util.c rtpp_record_util.h \ $(CMDSRCDIR)/rpcpv1_norecord.c $(CMDSRCDIR)/rpcpv1_norecord.h \ $(CMDSRCDIR)/rpcpv1_ul_subc.c $(CMDSRCDIR)/rpcpv1_ul_subc.h \ $(RTPP_AUTOSRC_SOURCES) rtpp_epoll.c rtpp_str.c rtpp_str.h \ @@ -222,6 +223,10 @@ endif endif librtpproxy_la_LDFLAGS = -static librtpproxy_la_LIBADD += @LIBS_ELPERIODIC@ +if HAVE_LIBCRYPTO +rtpproxy_debug_LDADD += $(LIB_CRYPTO) +librtpproxy_la_LIBADD += $(LIB_CRYPTO) +endif update_autosrc: @echo "# Auto-generated by $(srcdir)/Makefile - DO NOT EDIT!" > $(RTPP_AUTOSRC_DIR)/Makefile.ami diff --git a/src/Makefile.in b/src/Makefile.in index b02e980a7..dd98e5c75 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -118,6 +118,8 @@ bin_PROGRAMS = rtpproxy$(EXEEXT) $(am__EXEEXT_1) @BUILD_CRYPTO_TRUE@@BUILD_MODULES_TRUE@am__append_15 = $(MOD_DIR)/dtls_gw/librtpp_dtls_gw.la \ @BUILD_CRYPTO_TRUE@@BUILD_MODULES_TRUE@ $(MOD_DIR)/ice_lite/librtpp_ice_lite.la +@HAVE_LIBCRYPTO_TRUE@am__append_16 = $(LIB_CRYPTO) +@HAVE_LIBCRYPTO_TRUE@am__append_17 = $(LIB_CRYPTO) subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ @@ -167,9 +169,11 @@ am__uninstall_files_from_dir = { \ $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \ } LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) +am__DEPENDENCIES_1 = +@HAVE_LIBCRYPTO_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) librtpproxy_la_DEPENDENCIES = $(top_srcdir)/libucl/libucl.la \ $(XXH_DIR)/libxxHash.la $(RTQ_DIR)/libRTQueue.la \ - $(am__append_14) $(am__append_15) + $(am__append_14) $(am__append_15) $(am__DEPENDENCIES_2) am__librtpproxy_la_SOURCES_DIST = main.c rtp.h rtpp_server.c \ rtpp_defines.h rtpp_log.h rtpp_record.c rtpp_session.h \ rtpp_util.c rtpp_util.h rtp.c rtp_resizer.c rtp_resizer.h \ @@ -212,6 +216,7 @@ am__librtpproxy_la_SOURCES_DIST = main.c rtp.h rtpp_server.c \ rtpp_network_io.c rtpp_network_io.h rtpp_wi_pkt.c \ rtpp_wi_pkt.h rtpp_timeout_data.c rtpp_timeout_data.h \ rtpp_locking.h rtpp_nofile.c rtpp_nofile.h rtpp_record_adhoc.h \ + rtpp_record_util.c rtpp_record_util.h \ $(CMDSRCDIR)/rpcpv1_norecord.c $(CMDSRCDIR)/rpcpv1_norecord.h \ $(CMDSRCDIR)/rpcpv1_ul_subc.c $(CMDSRCDIR)/rpcpv1_ul_subc.h \ rtpp_command_rcache.h rtpp_log_obj.h rtpp_port_table.h \ @@ -301,6 +306,7 @@ am__objects_6 = librtpproxy_la-main.lo librtpproxy_la-rtpp_server.lo \ librtpproxy_la-rtpp_wi_pkt.lo \ librtpproxy_la-rtpp_timeout_data.lo \ librtpproxy_la-rtpp_nofile.lo \ + librtpproxy_la-rtpp_record_util.lo \ $(CMDSRCDIR)/librtpproxy_la-rpcpv1_norecord.lo \ $(CMDSRCDIR)/librtpproxy_la-rpcpv1_ul_subc.lo $(am__objects_2) \ librtpproxy_la-rtpp_epoll.lo librtpproxy_la-rtpp_str.lo \ @@ -358,8 +364,8 @@ am_pproc_manager_test_OBJECTS = \ $(am__objects_15) \ $(RTPP_AUTOSRC_DIR)/pproc_manager_test-rtpp_refcnt_fin.$(OBJEXT) pproc_manager_test_OBJECTS = $(am_pproc_manager_test_OBJECTS) -am__DEPENDENCIES_1 = $(top_srcdir)/libexecinfo/libexecinfo.la -pproc_manager_test_DEPENDENCIES = $(am__DEPENDENCIES_1) +am__DEPENDENCIES_3 = $(top_srcdir)/libexecinfo/libexecinfo.la +pproc_manager_test_DEPENDENCIES = $(am__DEPENDENCIES_3) pproc_manager_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(pproc_manager_test_CFLAGS) $(CFLAGS) \ @@ -445,7 +451,7 @@ am__objects_52 = $(am__objects_25) $(am__objects_26) $(am__objects_27) \ am_rtpp_fintest_OBJECTS = rtpp_fintest-rtpp_fintest.$(OBJEXT) \ $(am__objects_17) $(am__objects_24) $(am__objects_52) rtpp_fintest_OBJECTS = $(am_rtpp_fintest_OBJECTS) -rtpp_fintest_DEPENDENCIES = $(am__DEPENDENCIES_1) +rtpp_fintest_DEPENDENCIES = $(am__DEPENDENCIES_3) rtpp_fintest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(rtpp_fintest_CFLAGS) \ $(CFLAGS) $(rtpp_fintest_LDFLAGS) $(LDFLAGS) -o $@ @@ -548,8 +554,7 @@ am__objects_90 = $(am__objects_63) $(am__objects_64) $(am__objects_65) \ am_rtpp_objck_OBJECTS = $(am__objects_60) $(am__objects_62) \ $(am__objects_90) rtpp_objck_OBJECTS = $(am_rtpp_objck_OBJECTS) -am__DEPENDENCIES_2 = -rtpp_objck_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +rtpp_objck_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3) rtpp_objck_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(rtpp_objck_CFLAGS) \ $(CFLAGS) $(rtpp_objck_LDFLAGS) $(LDFLAGS) -o $@ @@ -651,7 +656,7 @@ am_rtpp_rzmalloc_perf_debug_OBJECTS = \ $(am__objects_100) $(am__objects_128) rtpp_rzmalloc_perf_debug_OBJECTS = \ $(am_rtpp_rzmalloc_perf_debug_OBJECTS) -rtpp_rzmalloc_perf_debug_DEPENDENCIES = $(am__DEPENDENCIES_2) \ +rtpp_rzmalloc_perf_debug_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_srcdir)/libexecinfo/libexecinfo.la rtpp_rzmalloc_perf_debug_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ @@ -724,7 +729,7 @@ am_rtpp_wref_test_OBJECTS = rtpp_wref_test-rtpp_wref_test.$(OBJEXT) \ rtpp_wref_test-rtpp_wref.$(OBJEXT) $(am__objects_130) \ $(am__objects_158) rtpp_wref_test_OBJECTS = $(am_rtpp_wref_test_OBJECTS) -rtpp_wref_test_DEPENDENCIES = $(am__DEPENDENCIES_1) +rtpp_wref_test_DEPENDENCIES = $(am__DEPENDENCIES_3) rtpp_wref_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(rtpp_wref_test_CFLAGS) $(CFLAGS) $(rtpp_wref_test_LDFLAGS) \ @@ -735,8 +740,8 @@ am__rtpproxy_SOURCES_DIST = main.c librtpproxy.la rtpp_module_if.c \ @ENABLE_MODULE_IF_TRUE@ rtpproxy-rtpp_module_if.$(OBJEXT) am_rtpproxy_OBJECTS = rtpproxy-main.$(OBJEXT) $(am__objects_159) rtpproxy_OBJECTS = $(am_rtpproxy_OBJECTS) -rtpproxy_DEPENDENCIES = librtpproxy.la $(am__DEPENDENCIES_2) \ - $(am__DEPENDENCIES_2) +rtpproxy_DEPENDENCIES = librtpproxy.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) rtpproxy_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(rtpproxy_CFLAGS) \ $(CFLAGS) $(rtpproxy_LDFLAGS) $(LDFLAGS) -o $@ @@ -782,6 +787,7 @@ am__rtpproxy_debug_SOURCES_DIST = main.c rtp.h rtpp_server.c \ rtpp_network_io.c rtpp_network_io.h rtpp_wi_pkt.c \ rtpp_wi_pkt.h rtpp_timeout_data.c rtpp_timeout_data.h \ rtpp_locking.h rtpp_nofile.c rtpp_nofile.h rtpp_record_adhoc.h \ + rtpp_record_util.c rtpp_record_util.h \ $(CMDSRCDIR)/rpcpv1_norecord.c $(CMDSRCDIR)/rpcpv1_norecord.h \ $(CMDSRCDIR)/rpcpv1_ul_subc.c $(CMDSRCDIR)/rpcpv1_ul_subc.h \ rtpp_command_rcache.h rtpp_log_obj.h rtpp_port_table.h \ @@ -948,6 +954,7 @@ am__objects_163 = rtpproxy_debug-main.$(OBJEXT) \ rtpproxy_debug-rtpp_wi_pkt.$(OBJEXT) \ rtpproxy_debug-rtpp_timeout_data.$(OBJEXT) \ rtpproxy_debug-rtpp_nofile.$(OBJEXT) \ + rtpproxy_debug-rtpp_record_util.$(OBJEXT) \ $(CMDSRCDIR)/rtpproxy_debug-rpcpv1_norecord.$(OBJEXT) \ $(CMDSRCDIR)/rtpproxy_debug-rpcpv1_ul_subc.$(OBJEXT) \ $(am__objects_2) rtpproxy_debug-rtpp_epoll.$(OBJEXT) \ @@ -1043,7 +1050,8 @@ am_rtpproxy_debug_OBJECTS = $(am__objects_163) $(am__objects_170) \ rtpproxy_debug_OBJECTS = $(am_rtpproxy_debug_OBJECTS) rtpproxy_debug_DEPENDENCIES = $(top_srcdir)/libucl/libucl_debug.la \ $(XXH_DIR)/libxxHash_debug.la $(RTQ_DIR)/libRTQueue_debug.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) + $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) rtpproxy_debug_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(rtpproxy_debug_CFLAGS) $(CFLAGS) $(rtpproxy_debug_LDFLAGS) \ @@ -1354,6 +1362,7 @@ am__depfiles_remade = \ ./$(DEPDIR)/librtpproxy_la-rtpp_proc_wakeup.Plo \ ./$(DEPDIR)/librtpproxy_la-rtpp_queue.Plo \ ./$(DEPDIR)/librtpproxy_la-rtpp_record.Plo \ + ./$(DEPDIR)/librtpproxy_la-rtpp_record_util.Plo \ ./$(DEPDIR)/librtpproxy_la-rtpp_refcnt.Plo \ ./$(DEPDIR)/librtpproxy_la-rtpp_refproxy.Plo \ ./$(DEPDIR)/librtpproxy_la-rtpp_ringbuf.Plo \ @@ -1478,6 +1487,7 @@ am__depfiles_remade = \ ./$(DEPDIR)/rtpproxy_debug-rtpp_proc_wakeup.Po \ ./$(DEPDIR)/rtpproxy_debug-rtpp_queue.Po \ ./$(DEPDIR)/rtpproxy_debug-rtpp_record.Po \ + ./$(DEPDIR)/rtpproxy_debug-rtpp_record_util.Po \ ./$(DEPDIR)/rtpproxy_debug-rtpp_refproxy.Po \ ./$(DEPDIR)/rtpproxy_debug-rtpp_ringbuf.Po \ ./$(DEPDIR)/rtpproxy_debug-rtpp_rw_lock.Po \ @@ -1847,6 +1857,7 @@ BASE_SOURCES = main.c rtp.h rtpp_server.c rtpp_defines.h rtpp_log.h \ rtpp_network_io.c rtpp_network_io.h rtpp_wi_pkt.c \ rtpp_wi_pkt.h rtpp_timeout_data.c rtpp_timeout_data.h \ rtpp_locking.h rtpp_nofile.c rtpp_nofile.h rtpp_record_adhoc.h \ + rtpp_record_util.c rtpp_record_util.h \ $(CMDSRCDIR)/rpcpv1_norecord.c $(CMDSRCDIR)/rpcpv1_norecord.h \ $(CMDSRCDIR)/rpcpv1_ul_subc.c $(CMDSRCDIR)/rpcpv1_ul_subc.h \ $(RTPP_AUTOSRC_SOURCES) rtpp_epoll.c rtpp_str.c rtpp_str.h \ @@ -1864,7 +1875,7 @@ rtpproxy_LDADD = librtpproxy.la -lm -lpthread $(am__append_6) \ rtpproxy_debug_LDADD = -lm -lpthread @LIBS_ELPERIODIC@ \ $(top_srcdir)/libucl/libucl_debug.la \ $(XXH_DIR)/libxxHash_debug.la $(RTQ_DIR)/libRTQueue_debug.la \ - $(RTPP_MEMDEB_LD_ADD) $(am__append_11) + $(RTPP_MEMDEB_LD_ADD) $(am__append_11) $(am__append_16) rtpproxy_debug_LDFLAGS = -Wl,--export-dynamic $(LTO_FLAG) rtpproxy_LDFLAGS = $(LTO_FLAG) $(am__append_7) SRCS_MEMDEB_CORE = $(RTPP_MEMDEB_CORESRCS) rtpp_memdeb_stats.h rtpp_memdeb_test.c @@ -1965,7 +1976,8 @@ librtpproxy_la_CFLAGS = $(rtpproxy_CFLAGS) -fPIC librtpproxy_la_CPPFLAGS = $(rtpproxy_CPPFLAGS) -DLIBRTPPROXY librtpproxy_la_LIBADD = $(top_srcdir)/libucl/libucl.la \ $(XXH_DIR)/libxxHash.la $(RTQ_DIR)/libRTQueue.la \ - $(am__append_14) $(am__append_15) @LIBS_ELPERIODIC@ + $(am__append_14) $(am__append_15) @LIBS_ELPERIODIC@ \ + $(am__append_17) librtpproxy_la_LDFLAGS = -static IPLDIR = $(top_srcdir)/src/ipol all: config.h @@ -3196,6 +3208,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtpproxy_la-rtpp_proc_wakeup.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtpproxy_la-rtpp_queue.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtpproxy_la-rtpp_record.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtpproxy_la-rtpp_record_util.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtpproxy_la-rtpp_refcnt.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtpproxy_la-rtpp_refproxy.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/librtpproxy_la-rtpp_ringbuf.Plo@am__quote@ # am--include-marker @@ -3320,6 +3333,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtpproxy_debug-rtpp_proc_wakeup.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtpproxy_debug-rtpp_queue.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtpproxy_debug-rtpp_record.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtpproxy_debug-rtpp_record_util.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtpproxy_debug-rtpp_refproxy.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtpproxy_debug-rtpp_ringbuf.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtpproxy_debug-rtpp_rw_lock.Po@am__quote@ # am--include-marker @@ -3859,6 +3873,13 @@ librtpproxy_la-rtpp_nofile.lo: rtpp_nofile.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(librtpproxy_la_CPPFLAGS) $(CPPFLAGS) $(librtpproxy_la_CFLAGS) $(CFLAGS) -c -o librtpproxy_la-rtpp_nofile.lo `test -f 'rtpp_nofile.c' || echo '$(srcdir)/'`rtpp_nofile.c +librtpproxy_la-rtpp_record_util.lo: rtpp_record_util.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(librtpproxy_la_CPPFLAGS) $(CPPFLAGS) $(librtpproxy_la_CFLAGS) $(CFLAGS) -MT librtpproxy_la-rtpp_record_util.lo -MD -MP -MF $(DEPDIR)/librtpproxy_la-rtpp_record_util.Tpo -c -o librtpproxy_la-rtpp_record_util.lo `test -f 'rtpp_record_util.c' || echo '$(srcdir)/'`rtpp_record_util.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/librtpproxy_la-rtpp_record_util.Tpo $(DEPDIR)/librtpproxy_la-rtpp_record_util.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rtpp_record_util.c' object='librtpproxy_la-rtpp_record_util.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(librtpproxy_la_CPPFLAGS) $(CPPFLAGS) $(librtpproxy_la_CFLAGS) $(CFLAGS) -c -o librtpproxy_la-rtpp_record_util.lo `test -f 'rtpp_record_util.c' || echo '$(srcdir)/'`rtpp_record_util.c + $(CMDSRCDIR)/librtpproxy_la-rpcpv1_norecord.lo: $(CMDSRCDIR)/rpcpv1_norecord.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(librtpproxy_la_CPPFLAGS) $(CPPFLAGS) $(librtpproxy_la_CFLAGS) $(CFLAGS) -MT $(CMDSRCDIR)/librtpproxy_la-rpcpv1_norecord.lo -MD -MP -MF $(CMDSRCDIR)/$(DEPDIR)/librtpproxy_la-rpcpv1_norecord.Tpo -c -o $(CMDSRCDIR)/librtpproxy_la-rpcpv1_norecord.lo `test -f '$(CMDSRCDIR)/rpcpv1_norecord.c' || echo '$(srcdir)/'`$(CMDSRCDIR)/rpcpv1_norecord.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(CMDSRCDIR)/$(DEPDIR)/librtpproxy_la-rpcpv1_norecord.Tpo $(CMDSRCDIR)/$(DEPDIR)/librtpproxy_la-rpcpv1_norecord.Plo @@ -8038,6 +8059,20 @@ rtpproxy_debug-rtpp_nofile.obj: rtpp_nofile.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rtpproxy_debug_CPPFLAGS) $(CPPFLAGS) $(rtpproxy_debug_CFLAGS) $(CFLAGS) -c -o rtpproxy_debug-rtpp_nofile.obj `if test -f 'rtpp_nofile.c'; then $(CYGPATH_W) 'rtpp_nofile.c'; else $(CYGPATH_W) '$(srcdir)/rtpp_nofile.c'; fi` +rtpproxy_debug-rtpp_record_util.o: rtpp_record_util.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rtpproxy_debug_CPPFLAGS) $(CPPFLAGS) $(rtpproxy_debug_CFLAGS) $(CFLAGS) -MT rtpproxy_debug-rtpp_record_util.o -MD -MP -MF $(DEPDIR)/rtpproxy_debug-rtpp_record_util.Tpo -c -o rtpproxy_debug-rtpp_record_util.o `test -f 'rtpp_record_util.c' || echo '$(srcdir)/'`rtpp_record_util.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/rtpproxy_debug-rtpp_record_util.Tpo $(DEPDIR)/rtpproxy_debug-rtpp_record_util.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rtpp_record_util.c' object='rtpproxy_debug-rtpp_record_util.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rtpproxy_debug_CPPFLAGS) $(CPPFLAGS) $(rtpproxy_debug_CFLAGS) $(CFLAGS) -c -o rtpproxy_debug-rtpp_record_util.o `test -f 'rtpp_record_util.c' || echo '$(srcdir)/'`rtpp_record_util.c + +rtpproxy_debug-rtpp_record_util.obj: rtpp_record_util.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rtpproxy_debug_CPPFLAGS) $(CPPFLAGS) $(rtpproxy_debug_CFLAGS) $(CFLAGS) -MT rtpproxy_debug-rtpp_record_util.obj -MD -MP -MF $(DEPDIR)/rtpproxy_debug-rtpp_record_util.Tpo -c -o rtpproxy_debug-rtpp_record_util.obj `if test -f 'rtpp_record_util.c'; then $(CYGPATH_W) 'rtpp_record_util.c'; else $(CYGPATH_W) '$(srcdir)/rtpp_record_util.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/rtpproxy_debug-rtpp_record_util.Tpo $(DEPDIR)/rtpproxy_debug-rtpp_record_util.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rtpp_record_util.c' object='rtpproxy_debug-rtpp_record_util.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rtpproxy_debug_CPPFLAGS) $(CPPFLAGS) $(rtpproxy_debug_CFLAGS) $(CFLAGS) -c -o rtpproxy_debug-rtpp_record_util.obj `if test -f 'rtpp_record_util.c'; then $(CYGPATH_W) 'rtpp_record_util.c'; else $(CYGPATH_W) '$(srcdir)/rtpp_record_util.c'; fi` + $(CMDSRCDIR)/rtpproxy_debug-rpcpv1_norecord.o: $(CMDSRCDIR)/rpcpv1_norecord.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rtpproxy_debug_CPPFLAGS) $(CPPFLAGS) $(rtpproxy_debug_CFLAGS) $(CFLAGS) -MT $(CMDSRCDIR)/rtpproxy_debug-rpcpv1_norecord.o -MD -MP -MF $(CMDSRCDIR)/$(DEPDIR)/rtpproxy_debug-rpcpv1_norecord.Tpo -c -o $(CMDSRCDIR)/rtpproxy_debug-rpcpv1_norecord.o `test -f '$(CMDSRCDIR)/rpcpv1_norecord.c' || echo '$(srcdir)/'`$(CMDSRCDIR)/rpcpv1_norecord.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(CMDSRCDIR)/$(DEPDIR)/rtpproxy_debug-rpcpv1_norecord.Tpo $(CMDSRCDIR)/$(DEPDIR)/rtpproxy_debug-rpcpv1_norecord.Po @@ -9304,6 +9339,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_proc_wakeup.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_queue.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_record.Plo + -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_record_util.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_refcnt.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_refproxy.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_ringbuf.Plo @@ -9428,6 +9464,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_proc_wakeup.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_queue.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_record.Po + -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_record_util.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_refproxy.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_ringbuf.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_rw_lock.Po @@ -9789,6 +9826,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_proc_wakeup.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_queue.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_record.Plo + -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_record_util.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_refcnt.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_refproxy.Plo -rm -f ./$(DEPDIR)/librtpproxy_la-rtpp_ringbuf.Plo @@ -9913,6 +9951,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_proc_wakeup.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_queue.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_record.Po + -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_record_util.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_refproxy.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_ringbuf.Po -rm -f ./$(DEPDIR)/rtpproxy_debug-rtpp_rw_lock.Po diff --git a/src/config.h.in b/src/config.h.in index 5950636ce..be661765a 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -91,6 +91,9 @@ /* Have kqueue(2) interface. */ #undef HAVE_KQUEUE +/* Define if you have libcrypto (OpenSSL) installed */ +#undef HAVE_LIBCRYPTO + /* Define to 1 if you have the header file. */ #undef HAVE_LIBGEN_H diff --git a/src/main.c b/src/main.c index fc1bce691..5d95f0f77 100644 --- a/src/main.c +++ b/src/main.c @@ -115,6 +115,7 @@ #include "rtpp_debug.h" #include "rtpp_locking.h" #include "rtpp_nofile.h" +#include "rtpp_record_util.h" #include "advanced/pproc_manager.h" #include "ucl.h" #include "rtpp_ucl.h" @@ -152,7 +153,8 @@ usage(void) "[-n timeout_socket]\n\t [-d log_level[:log_facility]] [-p pid_file]\n" "\t [-c fifo|rr] [-A addr1[/addr2] [-W setup_ttl]\n" "\t [--maxpps pps[,rtcp_pps]] [--maxpsize size[,rtcp_size]]\n" - "\trtpproxy -V\n"); + "\t [--record_callid_hash %s]\n" + "\trtpproxy -V\n", rtpp_record_callid_hash_usage); } static struct rtpp_cfg *_sig_cf; @@ -266,6 +268,7 @@ ehandler(void) #define LOPT_NO_REDIR 263 #define LOPT_MAXPPS 264 #define LOPT_MAXPSIZE 265 +#define LOPT_RCID_HASH 266 const static struct option longopts[] = { { "dso", required_argument, NULL, LOPT_DSO }, @@ -278,6 +281,7 @@ const static struct option longopts[] = { { "no_redirect", no_argument, NULL, LOPT_NO_REDIR }, { "maxpps", required_argument, NULL, LOPT_MAXPPS }, { "maxpsize", required_argument, NULL, LOPT_MAXPSIZE }, + { "record_callid_hash", required_argument, NULL, LOPT_RCID_HASH }, { NULL, 0, NULL, 0 } }; @@ -519,6 +523,12 @@ init_config(struct rtpp_cfg *cfsp, int argc, const char * const *argv) } break; + case LOPT_RCID_HASH: + if (rtpp_record_callid_hash_parse(optarg, + &cfsp->record_callid_hash, &errmsg) != 0) + IC_ERRX(1, "%s: %s", optarg, errmsg); + break; + case 'c': if (strcmp(optarg, "fifo") == 0) { cfsp->sched_policy = SCHED_FIFO; diff --git a/src/rtpp_cfg.h b/src/rtpp_cfg.h index 9ea183660..24c10d14f 100644 --- a/src/rtpp_cfg.h +++ b/src/rtpp_cfg.h @@ -108,6 +108,9 @@ struct rtpp_cfg { const char *sdir; int record_pcap; /* Record in the PCAP format? */ int record_all; /* Record everything */ + int record_callid_hash; /* How the Call-ID goes into recording + file names, RTPP_RCID_*, see + rtpp_record_util.h */ int rrtcp; /* Whether or not to relay RTCP? */ struct rtpp_log *glog; diff --git a/src/rtpp_record.c b/src/rtpp_record.c index 30c216e7b..af7ed13f5 100644 --- a/src/rtpp_record.c +++ b/src/rtpp_record.c @@ -52,6 +52,7 @@ #include "config.h" + #include "rtpp_types.h" #include "rtp.h" #include "rtpp_time.h" @@ -67,6 +68,7 @@ #include "rtpp_mallocs.h" #include "rtpp_network.h" #include "rtpp_record.h" +#include "rtpp_record_util.h" #include "rtpp_record_fin.h" #include "rtpp_record_adhoc.h" #include "rtpp_record_private.h" @@ -173,6 +175,8 @@ rtpp_record_ctor(const struct rtpp_cfg *cfsp, const struct remote_copy_args *rap int rval, remote; size_t len; pcap_hdr_t pcap_hdr; + char fname[PATH_MAX + 1]; + const char *emsg; remote = (rname != NULL && strncmp("udp:", rname, 4) == 0) ? 1 : 0; @@ -211,10 +215,10 @@ rtpp_record_ctor(const struct rtpp_cfg *cfsp, const struct remote_copy_args *rap goto e2; } - if (rname == NULL && (memchr(sp->call_id->s, '/', sp->call_id->len) != NULL || - memchr(sp->from_tag_nmn->s, '/', sp->from_tag_nmn->len) != NULL)) { - RTPP_LOG(sp->log, RTPP_LOG_ERR, "call-id or from-tag contains '/', " - "refusing to use it in the recording file name"); + if (rname == NULL && rtpp_record_callid_fname(fname, sizeof(fname), + sp->call_id->s, sp->call_id->len, sp->from_tag_nmn->s, + sp->from_tag_nmn->len, cfsp->record_callid_hash, &emsg) < 0) { + RTPP_LOG(sp->log, RTPP_LOG_ERR, "%s", emsg); goto e2; } @@ -240,9 +244,8 @@ rtpp_record_ctor(const struct rtpp_cfg *cfsp, const struct remote_copy_args *rap sdir = cfsp->sdir; rrc->needspool = 1; if (rname == NULL) { - len = snprintf(rrc->rpath, sizeof(rrc->rpath), "%s/%.*s=%.*s%s%s", - cfsp->rdir, (int)sp->call_id->len, sp->call_id->s, - (int)sp->from_tag_nmn->len, sp->from_tag_nmn->s, suffix1, suffix2); + len = snprintf(rrc->rpath, sizeof(rrc->rpath), "%s/%s%s%s", + cfsp->rdir, fname, suffix1, suffix2); } else { len = snprintf(rrc->rpath, sizeof(rrc->rpath), "%s/%s%s", cfsp->rdir, rname, suffix2); @@ -253,9 +256,8 @@ rtpp_record_ctor(const struct rtpp_cfg *cfsp, const struct remote_copy_args *rap } } if (rname == NULL) { - len = snprintf(rrc->spath, sizeof(rrc->spath), "%s/%.*s=%.*s%s%s", - sdir, (int)sp->call_id->len, sp->call_id->s, - (int)sp->from_tag_nmn->len, sp->from_tag_nmn->s, suffix1, suffix2); + len = snprintf(rrc->spath, sizeof(rrc->spath), "%s/%s%s%s", + sdir, fname, suffix1, suffix2); } else { len = snprintf(rrc->spath, sizeof(rrc->spath), "%s/%s%s", sdir, rname, suffix2); diff --git a/src/rtpp_record_util.c b/src/rtpp_record_util.c new file mode 100644 index 000000000..7f39822ef --- /dev/null +++ b/src/rtpp_record_util.c @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2026 Sippy Software, Inc., http://www.sippysoft.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include +#include +#include + +#include "config.h" + +#if defined(HAVE_LIBCRYPTO) +#include +#endif + +#include "rtpp_record_util.h" + +#if defined(HAVE_LIBCRYPTO) +#define RCID_SHA256_AVAIL 1 +#define RCID_METHODS "raw, b64url, sha256" +#else +#define RCID_SHA256_AVAIL 0 +#define RCID_METHODS "raw, b64url" +#endif + +static const struct { + const char *name; + int method; + int avail; +} rcid_methods[] = { + {"raw", RTPP_RCID_RAW, 1}, + {"b64url", RTPP_RCID_B64URL, 1}, + {"sha256", RTPP_RCID_SHA256, RCID_SHA256_AVAIL}, +}; + +#if defined(HAVE_LIBCRYPTO) +const char rtpp_record_callid_hash_usage[] = "raw|b64url|sha256"; +#else +const char rtpp_record_callid_hash_usage[] = "raw|b64url"; +#endif + +/* + * Parse the argument of the --record_callid_hash option into one of the + * RTPP_RCID_* values. Returns 0 on success, or -1 with *emsgp pointing to + * the reason if the method is unknown or not available in this build. + */ +int +rtpp_record_callid_hash_parse(const char *arg, int *methodp, + const char **emsgp) +{ + size_t i; + + for (i = 0; i < sizeof(rcid_methods) / sizeof(rcid_methods[0]); i++) { + if (strcmp(arg, rcid_methods[i].name) != 0) + continue; + if (!rcid_methods[i].avail) { + *emsgp = "--record_callid_hash method is not available, " + "rtpproxy has been built without OpenSSL"; + return (-1); + } + *methodp = rcid_methods[i].method; + return (0); + } + *emsgp = "unknown --record_callid_hash method, supported: " RCID_METHODS; + return (-1); +} + +/* + * Encode the Call-ID (src, slen, not NUL-terminated) into dst as selected + * by method. Returns the length of the result, or -1 if it does not fit + * into dlen bytes or cannot be built. + */ +static int +rcid_encode(char *dst, size_t dlen, const char *src, size_t slen, int method) +{ + static const char b64url[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz0123456789-_"; + size_t i, j; + uint32_t v; + + switch (method) { + case RTPP_RCID_RAW: + if (slen >= dlen) + return (-1); + memcpy(dst, src, slen); + dst[slen] = '\0'; + return ((int)slen); + + case RTPP_RCID_B64URL: + if (slen > (dlen - 1) / 4 * 3) + return (-1); + for (i = j = 0; i < slen; i += 3) { + v = (uint32_t)(unsigned char)src[i] << 16; + if (i + 1 < slen) + v |= (uint32_t)(unsigned char)src[i + 1] << 8; + if (i + 2 < slen) + v |= (uint32_t)(unsigned char)src[i + 2]; + dst[j++] = b64url[(v >> 18) & 0x3f]; + dst[j++] = b64url[(v >> 12) & 0x3f]; + if (i + 1 < slen) + dst[j++] = b64url[(v >> 6) & 0x3f]; + if (i + 2 < slen) + dst[j++] = b64url[v & 0x3f]; + } + dst[j] = '\0'; + return ((int)j); + +#if defined(HAVE_LIBCRYPTO) + case RTPP_RCID_SHA256: { + static const char hex[] = "0123456789abcdef"; + unsigned char md[EVP_MAX_MD_SIZE]; + unsigned int mdlen; + + if (EVP_Digest(src, slen, md, &mdlen, EVP_sha256(), NULL) != 1) + return (-1); + if ((size_t)mdlen * 2 >= dlen) + return (-1); + for (i = 0; i < mdlen; i++) { + dst[i * 2] = hex[md[i] >> 4]; + dst[i * 2 + 1] = hex[md[i] & 0xf]; + } + dst[i * 2] = '\0'; + return ((int)(i * 2)); + } +#endif + + default: + return (-1); + } +} + +/* + * Build the "=" part of a recording file name into dst + * (dlen bytes, NUL-terminated). The Call-ID and the from-tag are not + * NUL-terminated. The from-tag is used as is, the Call-ID as selected by + * method (RTPP_RCID_*): RTPP_RCID_RAW uses it as is, RTPP_RCID_B64URL + * encodes it with the URL-safe base64 alphabet (RFC 4648 sec. 5) without + * padding, so it can be recovered from the file name, and RTPP_RCID_SHA256 + * replaces it with its SHA-256 digest in lowercase hex. Neither of the + * latter two can produce '/', and a raw Call-ID or a from-tag containing + * '/' is refused, so the result never contains '/'. + * + * Returns the length of the result, or -1 with *emsgp pointing to the + * reason. + */ +int +rtpp_record_callid_fname(char *dst, size_t dlen, const char *cid, + size_t cidlen, const char *tag, size_t taglen, int method, + const char **emsgp) +{ + int len; + + if (method == RTPP_RCID_RAW && memchr(cid, '/', cidlen) != NULL) { + *emsgp = "call-id contains '/', refusing to use it in the recording " + "file name (see --record_callid_hash)"; + return (-1); + } + if (memchr(tag, '/', taglen) != NULL) { + *emsgp = "from-tag contains '/', refusing to use it in the recording " + "file name"; + return (-1); + } + len = rcid_encode(dst, dlen, cid, cidlen, method); + if (len < 0 || dlen - (size_t)len < taglen + 2) { + *emsgp = "recording file name is too long"; + return (-1); + } + dst[len++] = '='; + memcpy(dst + len, tag, taglen); + len += (int)taglen; + dst[len] = '\0'; + return (len); +} diff --git a/src/rtpp_record_util.h b/src/rtpp_record_util.h new file mode 100644 index 000000000..8074332b5 --- /dev/null +++ b/src/rtpp_record_util.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2026 Sippy Software, Inc., http://www.sippysoft.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +/* Values of the rtpp_cfg.record_callid_hash */ +#define RTPP_RCID_RAW 0 /* Call-ID as is, '/' is refused */ +#define RTPP_RCID_B64URL 1 /* URL-safe base64 (RFC 4648 sec. 5) */ +#define RTPP_RCID_SHA256 2 /* SHA-256, lowercase hex */ + +/* Methods available in this build, as "raw|b64url[|sha256]" */ +extern const char rtpp_record_callid_hash_usage[]; + +int rtpp_record_callid_hash_parse(const char *, int *, const char **); +int rtpp_record_callid_fname(char *, size_t, const char *, size_t, + const char *, size_t, int, const char **); diff --git a/tests/Makefile.am b/tests/Makefile.am index 47a0fbccc..ac05391fc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -38,6 +38,9 @@ TESTS_ENVIRONMENT = \ BASEDIR=${abs_srcdir} ; export BASEDIR ; \ BUILDDIR=${abs_builddir} ; export BUILDDIR ; \ TOP_BUILDDIR=${abs_top_builddir} ; export TOP_BUILDDIR ; +if HAVE_LIBCRYPTO +TESTS_ENVIRONMENT += HAVE_LIBCRYPTO=1 ; export HAVE_LIBCRYPTO ; +endif CLEANFILES += *.core test-suite.log # Keep live output and serial execution, and repeat failures at the end. diff --git a/tests/Makefile.in b/tests/Makefile.in index 8f60a8e77..15451b03d 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -101,7 +101,7 @@ host_triplet = @host@ @ENABLE_BASIC_TESTS_TRUE@ unittests/pproc_manager_test \ @ENABLE_BASIC_TESTS_TRUE@ unittests/rptl_pyspawn \ @ENABLE_BASIC_TESTS_TRUE@ unittests/rptl_process_io \ -@ENABLE_BASIC_TESTS_TRUE@ libucl/libucl1 \ +@ENABLE_BASIC_TESTS_TRUE@ libucl/libucl1 config_types/confval1 \ @ENABLE_BASIC_TESTS_TRUE@ libexecinfo/libexecinfo1 \ @ENABLE_BASIC_TESTS_TRUE@ acct_rtcp_hep/confval1 \ @ENABLE_BASIC_TESTS_TRUE@ acct_rtcp_hep/basic acct_csv/basic \ @@ -148,6 +148,7 @@ host_triplet = @host@ @ENABLE_BASIC_TESTS_TRUE@ ${makeann_EXTRA_DIST} \ @ENABLE_BASIC_TESTS_TRUE@ ${unittests_EXTRA_DIST} \ @ENABLE_BASIC_TESTS_TRUE@ ${libucl_EXTRA_DIST} \ +@ENABLE_BASIC_TESTS_TRUE@ ${config_types_EXTRA_DIST} \ @ENABLE_BASIC_TESTS_TRUE@ ${libexecinfo_EXTRA_DIST} \ @ENABLE_BASIC_TESTS_TRUE@ ${acct_rtcp_hep_EXTRA_DIST} \ @ENABLE_BASIC_TESTS_TRUE@ ${acct_csv_EXTRA_DIST} \ @@ -174,6 +175,7 @@ host_triplet = @host@ @BUILD_CRYPTO_TRUE@@ENABLE_BASIC_TESTS_TRUE@am__append_10 = dtls_gw/basic dtls_gw/fingerprint @BUILD_CRYPTO_TRUE@am__append_11 = ${dtls_gw_CLEANFILES} @BUILD_CRYPTO_TRUE@am__append_12 = ${dtls_gw_EXTRA_DIST} +@HAVE_LIBCRYPTO_TRUE@am__append_13 = HAVE_LIBCRYPTO=1 ; export HAVE_LIBCRYPTO ; subdir = tests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \ @@ -239,6 +241,7 @@ am__DIST_COMMON = $(srcdir)/Makefile.in \ $(srcdir)/basic_versions/Makefile.ami \ $(srcdir)/catch_dtmf/Makefile.ami \ $(srcdir)/command_parser/Makefile.ami \ + $(srcdir)/config_types/Makefile.ami \ $(srcdir)/dtls_gw/Makefile.ami \ $(srcdir)/extractaudio/Makefile.ami \ $(srcdir)/forwarding/Makefile.ami \ @@ -416,6 +419,7 @@ EXTRA_DIST = $(am__append_3) $(am__append_5) $(am__append_9) \ @ENABLE_BASIC_TESTS_TRUE@rtcp2json_CLEANFILES = rtcp1.output @ENABLE_BASIC_TESTS_TRUE@libucl_EXTRA_DIST = libucl @ENABLE_BASIC_TESTS_TRUE@libucl_CLEANFILES = libucl_test.output +@ENABLE_BASIC_TESTS_TRUE@config_types_EXTRA_DIST = config_types @ENABLE_BASIC_TESTS_TRUE@libexecinfo_EXTRA_DIST = libexecinfo @ENABLE_BASIC_TESTS_TRUE@libexecinfo_CLEANFILES = @ENABLE_BASIC_TESTS_TRUE@acct_rtcp_hep_EXTRA_DIST = acct_rtcp_hep @@ -473,15 +477,14 @@ EXTRA_DIST = $(am__append_3) $(am__append_5) $(am__append_9) \ @BUILD_CRYPTO_TRUE@dtls_gw_EXTRA_DIST = dtls_gw @BUILD_CRYPTO_TRUE@dtls_gw_CLEANFILES = dtls_gw.* dtls_fingerprint.* # NB: AM_TESTS_ENVIRONMENT not available until automake 1.12 -TESTS_ENVIRONMENT = \ - BASEDIR=${abs_srcdir} ; export BASEDIR ; \ - BUILDDIR=${abs_builddir} ; export BUILDDIR ; \ - TOP_BUILDDIR=${abs_top_builddir} ; export TOP_BUILDDIR ; - +TESTS_ENVIRONMENT = BASEDIR=${abs_srcdir} ; export BASEDIR ; \ + BUILDDIR=${abs_builddir} ; export BUILDDIR ; \ + TOP_BUILDDIR=${abs_top_builddir} ; export TOP_BUILDDIR ; \ + $(am__append_13) all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/autosrc/Makefile.ami $(srcdir)/recording/Makefile.ami $(srcdir)/makeann/Makefile.ami $(srcdir)/unittests/Makefile.ami $(srcdir)/libucl/Makefile.ami $(srcdir)/libexecinfo/Makefile.ami $(srcdir)/acct_rtcp_hep/Makefile.ami $(srcdir)/acct_csv/Makefile.ami $(srcdir)/catch_dtmf/Makefile.ami $(srcdir)/rtp_analyze/Makefile.ami $(srcdir)/extractaudio/Makefile.ami $(srcdir)/startstop/Makefile.ami $(srcdir)/basic_versions/Makefile.ami $(srcdir)/command_parser/Makefile.ami $(srcdir)/forwarding/Makefile.ami $(srcdir)/session_timeouts/Makefile.ami $(srcdir)/playback/Makefile.ami $(srcdir)/makeann/Makefile.ami $(srcdir)/memdeb/Makefile.ami $(srcdir)/dtls_gw/Makefile.ami $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/autosrc/Makefile.ami $(srcdir)/recording/Makefile.ami $(srcdir)/makeann/Makefile.ami $(srcdir)/unittests/Makefile.ami $(srcdir)/libucl/Makefile.ami $(srcdir)/config_types/Makefile.ami $(srcdir)/libexecinfo/Makefile.ami $(srcdir)/acct_rtcp_hep/Makefile.ami $(srcdir)/acct_csv/Makefile.ami $(srcdir)/catch_dtmf/Makefile.ami $(srcdir)/rtp_analyze/Makefile.ami $(srcdir)/extractaudio/Makefile.ami $(srcdir)/startstop/Makefile.ami $(srcdir)/basic_versions/Makefile.ami $(srcdir)/command_parser/Makefile.ami $(srcdir)/forwarding/Makefile.ami $(srcdir)/session_timeouts/Makefile.ami $(srcdir)/playback/Makefile.ami $(srcdir)/makeann/Makefile.ami $(srcdir)/memdeb/Makefile.ami $(srcdir)/dtls_gw/Makefile.ami $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -501,7 +504,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; -$(srcdir)/autosrc/Makefile.ami $(srcdir)/recording/Makefile.ami $(srcdir)/makeann/Makefile.ami $(srcdir)/unittests/Makefile.ami $(srcdir)/libucl/Makefile.ami $(srcdir)/libexecinfo/Makefile.ami $(srcdir)/acct_rtcp_hep/Makefile.ami $(srcdir)/acct_csv/Makefile.ami $(srcdir)/catch_dtmf/Makefile.ami $(srcdir)/rtp_analyze/Makefile.ami $(srcdir)/extractaudio/Makefile.ami $(srcdir)/startstop/Makefile.ami $(srcdir)/basic_versions/Makefile.ami $(srcdir)/command_parser/Makefile.ami $(srcdir)/forwarding/Makefile.ami $(srcdir)/session_timeouts/Makefile.ami $(srcdir)/playback/Makefile.ami $(srcdir)/makeann/Makefile.ami $(srcdir)/memdeb/Makefile.ami $(srcdir)/dtls_gw/Makefile.ami $(am__empty): +$(srcdir)/autosrc/Makefile.ami $(srcdir)/recording/Makefile.ami $(srcdir)/makeann/Makefile.ami $(srcdir)/unittests/Makefile.ami $(srcdir)/libucl/Makefile.ami $(srcdir)/config_types/Makefile.ami $(srcdir)/libexecinfo/Makefile.ami $(srcdir)/acct_rtcp_hep/Makefile.ami $(srcdir)/acct_csv/Makefile.ami $(srcdir)/catch_dtmf/Makefile.ami $(srcdir)/rtp_analyze/Makefile.ami $(srcdir)/extractaudio/Makefile.ami $(srcdir)/startstop/Makefile.ami $(srcdir)/basic_versions/Makefile.ami $(srcdir)/command_parser/Makefile.ami $(srcdir)/forwarding/Makefile.ami $(srcdir)/session_timeouts/Makefile.ami $(srcdir)/playback/Makefile.ami $(srcdir)/makeann/Makefile.ami $(srcdir)/memdeb/Makefile.ami $(srcdir)/dtls_gw/Makefile.ami $(am__empty): $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh diff --git a/tests/recording/basic b/tests/recording/basic index 2426e7763..6c93b7881 100755 --- a/tests/recording/basic +++ b/tests/recording/basic @@ -37,7 +37,19 @@ run_recording() { report_rc ${RPTL_RC} "running basic.${stest}.rptl RPTL script" } -SUB_TESTS="${SUB_TESTS:-"files singlefile singlefile_c stopall files_stophalf singlefile_stophalf remote remote_p badpath"}" +# The sha256 method of --record_callid_hash is only available if rtpproxy +# has been built with OpenSSL (HAVE_LIBCRYPTO is set by the test harness). +# Without it, the method must be refused with an explicit error. +if [ "${HAVE_LIBCRYPTO}" = 1 ] +then + SUB_TESTS_SHA256="badpath_sha256" +else + RTPP_GLITCH_ACT="" ${RTPPROXY} --record_callid_hash sha256 -V 2>&1 | \ + grep -q 'rtpproxy has been built without OpenSSL' + report "--record_callid_hash sha256 is refused in a build without OpenSSL" +fi + +SUB_TESTS="${SUB_TESTS:-"files singlefile singlefile_c stopall files_stophalf singlefile_stophalf remote remote_p badpath badpath_b64 ${SUB_TESTS_SHA256}"}" for stest in ${SUB_TESTS} do diff --git a/tests/recording/basic.badpath.rptl b/tests/recording/basic.badpath.rptl index c7d694bc5..ba71a707c 100644 --- a/tests/recording/basic.badpath.rptl +++ b/tests/recording/basic.badpath.rptl @@ -31,6 +31,12 @@ rtpp: L %%CALLID%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(PORT_O) rtpp: R %%CALLID%% to_tag_1 from_tag_1 -> str_compare(RES_E50) rtpp: Rs %%CALLID%% to_tag_1 from_tag_1 -> str_compare(RES_E50) +# '/' in the from-tag is refused as well. +rtpp: U %%CALLID_SHORT%%.tag 127.0.0.1 12345 ../from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_SHORT%%.tag 127.0.0.1 54321 ../from_tag_1 to_tag_1 -> validate_port(_) +rtpp: R %%CALLID_SHORT%%.tag to_tag_1 ../from_tag_1 -> str_compare(RES_E50) +rtpp: Rs %%CALLID_SHORT%%.tag to_tag_1 ../from_tag_1 -> str_compare(RES_E50) + rtpp: U %%CALLID_LONG%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) rtpp: L %%CALLID_LONG%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) rtpp: R %%CALLID_LONG%% to_tag_1 from_tag_1 -> str_compare(RES_E50) diff --git a/tests/recording/basic.badpath_b64.rptl b/tests/recording/basic.badpath_b64.rptl new file mode 100644 index 000000000..4708d0920 --- /dev/null +++ b/tests/recording/basic.badpath_b64.rptl @@ -0,0 +1,103 @@ +# Same Call-IDs as in basic.badpath, with --record_callid_hash b64url: the +# Call-ID is put into the recording file name encoded with the URL-safe +# base64 alphabet (RFC 4648 sec. 5) without padding, so the recording (R, Rs) +# is created inside of the recording directory under the encoded name +# instead of being refused. Names that do not fit into PATH_MAX are still +# refused, and so is '/' in the from-tag, which is always used as is. + +.eval: 0 -> RES_OK +.eval: E50 -> RES_E50 +.eval: recording.%%SUBTEST%% -> WORK_BASE +.eval: ../%%WORK_BASE%%.rec. -> CALLID +.eval: ../%%WORK_BASE%%.recs. -> CALLID_S +.eval: %%WORK_BASE%%.tag -> CALLID_T +.eval: %%RECORD_SPL_DIR%%/%%CALLID%%=from_tag_1 -> REC_BASE +.eval: %%RECORD_SPL_DIR%%/%%CALLID_S%%=from_tag_1 -> REC_BASE_S + +.eval: import sys, base64; print(base64.urlsafe_b64encode(sys.argv[1].encode()).decode().rstrip("=")) -> ENC +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID%%' -> CALLID_ENC +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID_S%%' -> CALLID_S_ENC +.eval: %%RECORD_SPL_DIR%%/%%CALLID_ENC%%=from_tag_1 -> ENC_BASE +.eval: %%RECORD_SPL_DIR%%/%%CALLID_S_ENC%%=from_tag_1 -> ENC_BASE_S + +# Unknown methods are rejected at startup. +.exec: %%RTPPROXY_BIN%% --record_callid_hash foo -V 2>&1 | grep -q 'unknown --record_callid_hash method' +.exec: %%RTPPROXY_BIN%% --record_callid_hash raw -V > /dev/null + +.exec: mkdir -p %%RECORD_SPL_DIR%% +.exec: rm -f %%REC_BASE%%.* %%REC_BASE_S%%* %%ENC_BASE%%.* %%ENC_BASE_S%%* + +# Longer than PATH_MAX once encoded on any supported platform, yet short +# enough for the commands carrying it to fit into the RTPP_CMD_BUFLEN. +.exec: printf '%4200s' '' | tr ' ' x -> LONG_NAME +.eval: %%WORK_BASE%%.long.%%LONG_NAME%% -> CALLID_LONG + +.eval: -d dbug -T60 -W60 -P -r %%RECORD_SPL_DIR%% --record_callid_hash b64url -> RTPPROXY_ARGS +socket rtpp: stdio: %%RTPPROXY_ARGS%% -> %%WORK_BASE%%.rout + +rtpp: U %%CALLID%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: R %%CALLID%% to_tag_1 from_tag_1 -> str_compare(RES_OK) + +rtpp: U %%CALLID_S%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_S%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: Rs %%CALLID_S%% to_tag_1 from_tag_1 -> str_compare(RES_OK) + +rtpp: U %%CALLID_T%% 127.0.0.1 12345 ../from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_T%% 127.0.0.1 54321 ../from_tag_1 to_tag_1 -> validate_port(_) +rtpp: R %%CALLID_T%% to_tag_1 ../from_tag_1 -> str_compare(RES_E50) + +rtpp: U %%CALLID_LONG%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_LONG%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: R %%CALLID_LONG%% to_tag_1 from_tag_1 -> str_compare(RES_E50) +rtpp: Rs %%CALLID_LONG%% to_tag_1 from_tag_1 -> str_compare(RES_E50) + +.close: rtpp +.exec: for f in %%REC_BASE%%.* %%REC_BASE_S%%*; do test ! -e "$f" || exit 1; done +.exec: ls %%ENC_BASE%%.* %%ENC_BASE_S%%* > /dev/null +.exec: rm -f %%ENC_BASE%%.* %%ENC_BASE_S%%* + +# With a spool directory (-S) the files are created there and moved into +# the recording directory when closed, both under the encoded name. +.eval: ../%%WORK_BASE%%.spool.r. -> CALLID_SR +.eval: ../%%WORK_BASE%%.spool.rs.x -> CALLID_SRS +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID_SR%%' -> CALLID_SR_ENC +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID_SRS%%' -> CALLID_SRS_ENC +.exec: rm -f %%RECORD_DIR%%/%%CALLID_SR_ENC%%=* %%RECORD_DIR%%/%%CALLID_SRS_ENC%%=* %%RECORD_SPL_DIR%%/%%CALLID_SR_ENC%%=* %%RECORD_SPL_DIR%%/%%CALLID_SRS_ENC%%=* + +.eval: -d dbug -T60 -W60 -P -r %%RECORD_DIR%% -S %%RECORD_SPL_DIR%% --record_callid_hash b64url -> RTPPROXY_ARGS +socket rtpp: stdio: %%RTPPROXY_ARGS%% -> %%WORK_BASE%%.S.rout + +rtpp: U %%CALLID_SR%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_SR%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: R %%CALLID_SR%% to_tag_1 from_tag_1 -> str_compare(RES_OK) + +rtpp: U %%CALLID_SRS%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_SRS%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: Rs %%CALLID_SRS%% to_tag_1 from_tag_1 -> str_compare(RES_OK) + +rtpp: U %%CALLID_T%%.S 127.0.0.1 12345 ../from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_T%%.S 127.0.0.1 54321 ../from_tag_1 to_tag_1 -> validate_port(_) +rtpp: Rs %%CALLID_T%%.S to_tag_1 ../from_tag_1 -> str_compare(RES_E50) + +.close: rtpp +.exec: ls %%RECORD_DIR%%/%%CALLID_SR_ENC%%=from_tag_1.* %%RECORD_DIR%%/%%CALLID_SRS_ENC%%=from_tag_1* > /dev/null +.exec: for f in %%RECORD_SPL_DIR%%/%%CALLID_SR_ENC%%=* %%RECORD_SPL_DIR%%/%%CALLID_SRS_ENC%%=*; do test ! -e "$f" || exit 1; done +.exec: rm -f %%RECORD_DIR%%/%%CALLID_SR_ENC%%=* %%RECORD_DIR%%/%%CALLID_SRS_ENC%%=* + +# Record-all mode (-a) builds the names the same way. A session whose +# from-tag contains '/' is still set up, just not recorded. +.eval: ../%%WORK_BASE%%.all -> CALLID_A +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID_A%%' -> CALLID_A_ENC +.exec: rm -f %%RECORD_SPL_DIR%%/%%CALLID_A_ENC%%=* + +.eval: -d dbug -T60 -W60 -P -a -r %%RECORD_SPL_DIR%% --record_callid_hash b64url -> RTPPROXY_ARGS +socket rtpp: stdio: %%RTPPROXY_ARGS%% -> %%WORK_BASE%%.a.rout + +rtpp: U %%CALLID_A%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_A%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: U %%CALLID_A%%.tag 127.0.0.1 12345 ../from_tag_1 -> validate_port(_) + +.close: rtpp +.exec: ls %%RECORD_SPL_DIR%%/%%CALLID_A_ENC%%=from_tag_1* > /dev/null +.exec: rm -f %%RECORD_SPL_DIR%%/%%CALLID_A_ENC%%=* diff --git a/tests/recording/basic.badpath_sha256.rptl b/tests/recording/basic.badpath_sha256.rptl new file mode 100644 index 000000000..a93c64c85 --- /dev/null +++ b/tests/recording/basic.badpath_sha256.rptl @@ -0,0 +1,101 @@ +# Same Call-IDs as in basic.badpath, with --record_callid_hash sha256: the +# Call-ID is replaced in the recording file name with its SHA-256 digest +# in lowercase hex, so the recording (R, Rs) is created inside of the +# recording directory under a fixed-length name instead of being refused, +# even for Call-IDs too long to be used as is. '/' in the from-tag, which +# is always used as is, is still refused. Only run if rtpproxy has been +# built with OpenSSL. + +.eval: 0 -> RES_OK +.eval: E50 -> RES_E50 +.eval: recording.%%SUBTEST%% -> WORK_BASE +.eval: ../%%WORK_BASE%%.rec. -> CALLID +.eval: ../%%WORK_BASE%%.recs. -> CALLID_S +.eval: %%WORK_BASE%%.tag -> CALLID_T +.eval: %%RECORD_SPL_DIR%%/%%CALLID%%=from_tag_1 -> REC_BASE +.eval: %%RECORD_SPL_DIR%%/%%CALLID_S%%=from_tag_1 -> REC_BASE_S + +# Longer than PATH_MAX on any supported platform, yet short enough for +# the commands carrying it to fit into the RTPP_CMD_BUFLEN. +.exec: printf '%4200s' '' | tr ' ' x -> LONG_NAME +.eval: %%WORK_BASE%%.long.%%LONG_NAME%% -> CALLID_LONG + +.eval: import sys, hashlib; print(hashlib.sha256(sys.argv[1].encode()).hexdigest()) -> ENC +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID%%' -> CALLID_ENC +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID_S%%' -> CALLID_S_ENC +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID_LONG%%' -> CALLID_LONG_ENC +.eval: %%RECORD_SPL_DIR%%/%%CALLID_ENC%%=from_tag_1 -> ENC_BASE +.eval: %%RECORD_SPL_DIR%%/%%CALLID_S_ENC%%=from_tag_1 -> ENC_BASE_S +.eval: %%RECORD_SPL_DIR%%/%%CALLID_LONG_ENC%%=from_tag_1 -> ENC_BASE_L + +.exec: mkdir -p %%RECORD_SPL_DIR%% +.exec: rm -f %%REC_BASE%%.* %%REC_BASE_S%%* %%ENC_BASE%%.* %%ENC_BASE_S%%* %%ENC_BASE_L%%* + +.eval: -d dbug -T60 -W60 -P -r %%RECORD_SPL_DIR%% --record_callid_hash sha256 -> RTPPROXY_ARGS +socket rtpp: stdio: %%RTPPROXY_ARGS%% -> %%WORK_BASE%%.rout + +rtpp: U %%CALLID%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: R %%CALLID%% to_tag_1 from_tag_1 -> str_compare(RES_OK) + +rtpp: U %%CALLID_S%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_S%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: Rs %%CALLID_S%% to_tag_1 from_tag_1 -> str_compare(RES_OK) + +rtpp: U %%CALLID_T%% 127.0.0.1 12345 ../from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_T%% 127.0.0.1 54321 ../from_tag_1 to_tag_1 -> validate_port(_) +rtpp: R %%CALLID_T%% to_tag_1 ../from_tag_1 -> str_compare(RES_E50) + +rtpp: U %%CALLID_LONG%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_LONG%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: Rs %%CALLID_LONG%% to_tag_1 from_tag_1 -> str_compare(RES_OK) + +.close: rtpp +.exec: for f in %%REC_BASE%%.* %%REC_BASE_S%%*; do test ! -e "$f" || exit 1; done +.exec: ls %%ENC_BASE%%.* %%ENC_BASE_S%%* %%ENC_BASE_L%%* > /dev/null +.exec: rm -f %%ENC_BASE%%.* %%ENC_BASE_S%%* %%ENC_BASE_L%%* + +# With a spool directory (-S) the files are created there and moved into +# the recording directory when closed, both under the encoded name. +.eval: ../%%WORK_BASE%%.spool.r. -> CALLID_SR +.eval: ../%%WORK_BASE%%.spool.rs.x -> CALLID_SRS +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID_SR%%' -> CALLID_SR_ENC +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID_SRS%%' -> CALLID_SRS_ENC +.exec: rm -f %%RECORD_DIR%%/%%CALLID_SR_ENC%%=* %%RECORD_DIR%%/%%CALLID_SRS_ENC%%=* %%RECORD_SPL_DIR%%/%%CALLID_SR_ENC%%=* %%RECORD_SPL_DIR%%/%%CALLID_SRS_ENC%%=* + +.eval: -d dbug -T60 -W60 -P -r %%RECORD_DIR%% -S %%RECORD_SPL_DIR%% --record_callid_hash sha256 -> RTPPROXY_ARGS +socket rtpp: stdio: %%RTPPROXY_ARGS%% -> %%WORK_BASE%%.S.rout + +rtpp: U %%CALLID_SR%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_SR%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: R %%CALLID_SR%% to_tag_1 from_tag_1 -> str_compare(RES_OK) + +rtpp: U %%CALLID_SRS%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_SRS%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: Rs %%CALLID_SRS%% to_tag_1 from_tag_1 -> str_compare(RES_OK) + +rtpp: U %%CALLID_T%%.S 127.0.0.1 12345 ../from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_T%%.S 127.0.0.1 54321 ../from_tag_1 to_tag_1 -> validate_port(_) +rtpp: Rs %%CALLID_T%%.S to_tag_1 ../from_tag_1 -> str_compare(RES_E50) + +.close: rtpp +.exec: ls %%RECORD_DIR%%/%%CALLID_SR_ENC%%=from_tag_1.* %%RECORD_DIR%%/%%CALLID_SRS_ENC%%=from_tag_1* > /dev/null +.exec: for f in %%RECORD_SPL_DIR%%/%%CALLID_SR_ENC%%=* %%RECORD_SPL_DIR%%/%%CALLID_SRS_ENC%%=*; do test ! -e "$f" || exit 1; done +.exec: rm -f %%RECORD_DIR%%/%%CALLID_SR_ENC%%=* %%RECORD_DIR%%/%%CALLID_SRS_ENC%%=* + +# Record-all mode (-a) builds the names the same way. A session whose +# from-tag contains '/' is still set up, just not recorded. +.eval: ../%%WORK_BASE%%.all -> CALLID_A +.exec: %%PYINT%% -c '%%ENC%%' '%%CALLID_A%%' -> CALLID_A_ENC +.exec: rm -f %%RECORD_SPL_DIR%%/%%CALLID_A_ENC%%=* + +.eval: -d dbug -T60 -W60 -P -a -r %%RECORD_SPL_DIR%% --record_callid_hash sha256 -> RTPPROXY_ARGS +socket rtpp: stdio: %%RTPPROXY_ARGS%% -> %%WORK_BASE%%.a.rout + +rtpp: U %%CALLID_A%% 127.0.0.1 12345 from_tag_1 -> validate_port(_) +rtpp: L %%CALLID_A%% 127.0.0.1 54321 from_tag_1 to_tag_1 -> validate_port(_) +rtpp: U %%CALLID_A%%.tag 127.0.0.1 12345 ../from_tag_1 -> validate_port(_) + +.close: rtpp +.exec: ls %%RECORD_SPL_DIR%%/%%CALLID_A_ENC%%=from_tag_1* > /dev/null +.exec: rm -f %%RECORD_SPL_DIR%%/%%CALLID_A_ENC%%=*