From fdb1d7c1fdf66f9cf1c97ac9e83ac1162b221675 Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Tue, 10 Oct 2023 11:21:31 -0700 Subject: [PATCH 1/2] Make timeout notification feature useable. Add an new "timeout_tag_pv" option to set notify tag along with the notification socket path. Both are required by the RTPProxy. Reported by: James Lipski --- src/modules/rtpproxy/rtpproxy.c | 53 +++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/src/modules/rtpproxy/rtpproxy.c b/src/modules/rtpproxy/rtpproxy.c index bc252982e1c..74da691e705 100644 --- a/src/modules/rtpproxy/rtpproxy.c +++ b/src/modules/rtpproxy/rtpproxy.c @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2003-2008 Sippy Software, Inc., http://www.sippysoft.com + * Copyright (C) 2003-2023 Sippy Software, Inc., http://www.sippysoft.com * * This file is part of Kamailio, a free SIP server. * @@ -187,6 +187,8 @@ static struct tm_binds tmb; unsigned int *natping_state = 0; static str timeout_socket_str = {0, 0}; +static str timeout_tag_pv_str = {0, 0}; +static pv_elem_t *timeout_tag_pv = NULL; static pv_elem_t *extra_id_pv = NULL; static cmd_export_t cmds[] = { @@ -243,6 +245,7 @@ static param_export_t params[] = { {"rtpproxy_retr", INT_PARAM, &rtpproxy_retr}, {"rtpproxy_tout", INT_PARAM, &rtpproxy_tout}, {"timeout_socket", PARAM_STR, &timeout_socket_str}, + {"timeout_tag_pv", PARAM_STR, &timeout_tag_pv_str}, {"ice_candidate_priority_avp", PARAM_STRING, &ice_candidate_priority_avp_param}, {"extra_id_pv", PARAM_STR, &extra_id_pv_param}, @@ -735,6 +738,20 @@ static int mod_init(void) } else { extra_id_pv = NULL; } + if(timeout_socket_str.s != NULL && timeout_tag_pv_str.s == NULL) { + LM_ERR("The timeout_tag_pv has to be set along with timeout_socket\n"); + return -1; + } + if(timeout_tag_pv_str.s != NULL) { + if(timeout_tag_pv_str.len == 0) { + LM_ERR("Empty timeout_tag_pv is not allowed\n"); + return -1; + } + if(pv_parse_format(&timeout_tag_pv_str, &timeout_tag_pv) < 0) { + LM_ERR("malformed PV string: %s\n", timeout_tag_pv_str.s); + return -1; + } + } if(rtpp_strings) pkg_free(rtpp_strings); @@ -1488,6 +1505,21 @@ static int get_extra_id(struct sip_msg *msg, str *id_str) } +static int get_timeout_tag(struct sip_msg *msg, str *ntag_str) +{ + if(msg == NULL || timeout_tag_pv == NULL || ntag_str == NULL) { + LM_ERR("bad parameters\n"); + return 0; + } + if(pv_printf_s(msg, timeout_tag_pv, ntag_str) < 0) { + LM_ERR("cannot print the notify tag\n"); + return 0; + } + + return 1; +} + + static int unforce_rtp_proxy1_f(struct sip_msg *msg, char *str1, char *str2) { str flags; @@ -1969,6 +2001,8 @@ static int force_rtp_proxy( {NULL, 0}, /* medianum */ {" ", 1}, /* separator */ {NULL, 0}, /* Timeout-Socket */ + {" ", 1}, /* separator */ + {NULL, 0}, /* Timeout-Tag */ }; int iovec_param_count; int autobridge_ipv4v6; @@ -2410,14 +2444,21 @@ static int force_rtp_proxy( } if(to_tag.len > 0) { iovec_param_count = 20; - if(opts.s.s[0] == 'U' && timeout_socket_str.len > 0) { - iovec_param_count = 22; - STR2IOVEC(timeout_socket_str, v[21]); - } } else { iovec_param_count = 16; } - + if(opts.s.s[0] == 'U' && timeout_socket_str.len > 0) { + str ntag = {0, 0}; + if(get_timeout_tag(msg, &ntag) == 0 || ntag.s == NULL + || ntag.len == 0) { + LM_ERR("can't get timeout notification tag\n"); + FORCE_RTP_PROXY_RET(-1); + } + STR2IOVEC(timeout_socket_str, v[iovec_param_count + 1]); + iovec_param_count += 2; + STR2IOVEC(ntag, v[iovec_param_count + 1]); + iovec_param_count += 2; + } cp = send_rtpp_command(node, v, iovec_param_count); } while(cp == NULL); LM_DBG("proxy reply: %s\n", cp); From b54bca5e2874df4c00c5d09793085291c539b653 Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Tue, 10 Oct 2023 11:23:49 -0700 Subject: [PATCH 2/2] Update rtpproxy module documentation. o Correct description of the timeout_socket; o Document timeout_tag_pv; o Update (c); o Remove reference to the ngcp-mediaproxy-ng which does not exist anymore. --- src/modules/rtpproxy/doc/rtpproxy.xml | 2 +- src/modules/rtpproxy/doc/rtpproxy_admin.xml | 38 +++++++++++++++++---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/modules/rtpproxy/doc/rtpproxy.xml b/src/modules/rtpproxy/doc/rtpproxy.xml index 94886eaf404..ee1fdad9fc8 100644 --- a/src/modules/rtpproxy/doc/rtpproxy.xml +++ b/src/modules/rtpproxy/doc/rtpproxy.xml @@ -67,7 +67,7 @@ - 2003-2008 + 2003-2023 Sippy Software, Inc. diff --git a/src/modules/rtpproxy/doc/rtpproxy_admin.xml b/src/modules/rtpproxy/doc/rtpproxy_admin.xml index 79a85edad70..b04baa5e3dc 100644 --- a/src/modules/rtpproxy/doc/rtpproxy_admin.xml +++ b/src/modules/rtpproxy/doc/rtpproxy_admin.xml @@ -18,11 +18,7 @@ Overview This is a module that enables media streams to be proxied - via an rtpproxy. Rtpproxies know to work with this module - are Sippy RTPproxy - and ngcp-rtpproxy-ng - . - Some features of the rtpproxy module apply only to one of the two rtpproxies. + via the Sippy RTPproxy . @@ -235,7 +231,37 @@ modparam("rtpproxy", "nortpproxy_str", "a=sdpmangled:yes\r\n") Set <varname>timeout_socket</varname> parameter ... -modparam("rtpproxy", "timeout_socket", "xmlrpc:http://127.0.0.1:8000/RPC2") +modparam("rtpproxy", "timeout_socket", "tcp:127.0.0.1:8000") +... + + + +
+ <varname>timeout_tag_pv</varname> (string) + + The parameter devines the AVP of the string to be provided to the + RTP-Proxy. + + + The content of the AVP must be a valid URL-encoded string with + no spaces. + It will be decoded and send by the RTP proxy to the timeout socket if the + media timeout has happened. + + + This parameter is required in order for the timeout notification + mechanism to work properly. + + + + Default value is (nothing). + + + + Set <varname>timeout_tag_pv</varname> parameter + +... +modparam("rtpproxy", "timeout_tag_pv", "$avp(rtpp_ntag)") ...