diff --git a/modules/rtpproxy/README b/modules/rtpproxy/README index d1e0f661c29..d7f5086041c 100644 --- a/modules/rtpproxy/README +++ b/modules/rtpproxy/README @@ -30,6 +30,7 @@ rtpproxy Module 1.5.13. generated_sdp_port_min (integer) 1.5.14. generated_sdp_port_max (integer) 1.5.15. generated_sdp_media_ip (string) + 1.5.16. rtpp_bind_local_avp (string) 1.6. Exported Functions @@ -470,6 +471,15 @@ modparam("rtpproxy", "generated_sdp_port_max", 30000) modparam("rtpproxy", "generated_sdp_media_ip", "10.0.0.1") ... +1.5.16. rtpp_bind_local_avp (string) + + The pseudo-variable used to read the local bind value which is + appended as l to the RTPProxy U/L command when set. For + example, use "$socket_out(ip)" to bind based on the outbound + socket. + + Default value is “$avp(rtpp_bind_local)”. + 1.6. Exported Functions 1.6.1. rtpproxy_engage([[flags][, [ip_address][, [set_id][, @@ -604,6 +614,11 @@ if (is_method("INVITE") && has_totag()) { returns the resulted body in it. If not used, the message's body is used, and the outgoing body is changed. + If the pseudo-variable set by rtpp_bind_local_avp is set to a string, its + value is appended as l to the RTPProxy U/L command (for + example, "[1:2:3]" for IPv6). This applies to both + rtpproxy_offer() and rtpproxy_answer(). + This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE. diff --git a/modules/rtpproxy/doc/rtpproxy_admin.xml b/modules/rtpproxy/doc/rtpproxy_admin.xml index 2ae4c9b2b04..7664e8aa499 100644 --- a/modules/rtpproxy/doc/rtpproxy_admin.xml +++ b/modules/rtpproxy/doc/rtpproxy_admin.xml @@ -547,6 +547,27 @@ modparam("rtpproxy", "generated_sdp_port_max", 30000) ... modparam("rtpproxy", "generated_sdp_media_ip", "10.0.0.1") +... + + + + +
+ <varname>rtpp_bind_local_avp</varname> (string) + + The pseudo-variable used to read the local bind value which is + appended as l<value> to the RTPProxy U/L + command when set. + + + + Default value is $avp(rtpp_bind_local). + + + Set <varname>rtpp_bind_local_avp</varname> parameter + +... +modparam("rtpproxy", "rtpp_bind_local_avp", "$socket_out(ip)") ... @@ -740,6 +761,14 @@ if (is_method("INVITE") && has_totag()) { and returns the resulted body in it. If not used, the message's body is used, and the outgoing body is changed. + + If the pseudo-variable set by rtpp_bind_local_avp + is set to a string, its value is appended as + l<value> to the RTPProxy U/L command + (for example, "[1:2:3]" for IPv6). This applies to both + rtpproxy_offer() and + rtpproxy_answer(). + This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE. @@ -1264,4 +1293,3 @@ $ opensips-cli -x mi rtpproxy_reload
- diff --git a/modules/rtpproxy/rtpproxy.c b/modules/rtpproxy/rtpproxy.c index 8f1682207f5..656bca9bd00 100644 --- a/modules/rtpproxy/rtpproxy.c +++ b/modules/rtpproxy/rtpproxy.c @@ -228,6 +228,9 @@ static str param3_name = str_init("rtpproxy_3"); str param3_bavp_name = str_init("$bavp(5589967)"); pv_spec_t param3_spec; static str late_name = str_init("late_negotiation"); +static str rtpp_bind_local_avp_name = str_init("$avp(rtpp_bind_local)"); +static pv_spec_t rtpp_bind_local_spec; +static int rtpp_bind_local_avp_ok = 0; /* parameters name for event signaling */ static str event_name = str_init("E_RTPPROXY_STATUS"); @@ -525,6 +528,7 @@ static const param_export_t params[] = { {"generated_sdp_port_min",INT_PARAM, &rtpproxy_port_min }, {"generated_sdp_port_max",INT_PARAM, &rtpproxy_port_max }, {"generated_sdp_media_ip",STR_PARAM, &rtpproxy_media_ip.s }, + {"rtpp_bind_local_avp", STR_PARAM, &rtpp_bind_local_avp_name.s }, {0, 0, 0} }; @@ -1304,6 +1308,18 @@ mod_init(void) parse_bavp(¶m3_bavp_name, ¶m3_spec) < 0) LM_DBG("cannot parse bavps\n"); + if (rtpp_bind_local_avp_name.s && rtpp_bind_local_avp_name.s[0] != '\0') { + rtpp_bind_local_avp_name.len = strlen(rtpp_bind_local_avp_name.s); + if (pv_parse_spec(&rtpp_bind_local_avp_name, &rtpp_bind_local_spec) != NULL) { + rtpp_bind_local_avp_ok = 1; + } else { + LM_ERR("malformed rtpp_bind_local pvar definition\n"); + return -1; + } + } else { + rtpp_bind_local_avp_ok = 0; + } + if(rtpp_notify_socket.s) { if (strncmp("tcp:", rtpp_notify_socket.s, 4) == 0) { rtpp_notify_socket_un = 0; @@ -3583,12 +3599,13 @@ static int rtpproxy_offer_answer(struct sip_msg *msg, struct rtpp_args *args, char medianum_buf[20]; char buf[32], dbuf[128]; int medianum, media_multi; - str medianum_str, tmpstr1; + str medianum_str, tmpstr1, bind_local_val; int c1p_altered; int enable_dtmf_catch = 0; int node_has_notification, node_has_dtmf_catch = 0; int vcnt; pv_value_t val; + pv_value_t bind_val; char *adv_address = NULL; struct dlg_cell * dlg; str dtmf_tag = {0, 0}, timeout_tag = {0, 0}; @@ -3817,6 +3834,24 @@ static int rtpproxy_offer_answer(struct sip_msg *msg, struct rtpp_args *args, medianum = 0; opts.s.s[0] = (create == 0) ? 'L' : 'U'; + + bind_local_val.len = 0; + if (msg && rtpp_bind_local_avp_ok) { + if (pv_get_spec_value(msg, &rtpp_bind_local_spec, &bind_val) < 0) { + LM_ERR("cannot get rtpp_bind_local avp value\n"); + goto exit; + } else if (!(bind_val.flags & PV_VAL_NULL)) { + if (bind_val.flags & PV_VAL_STR) { + bind_local_val = bind_val.rs; + } else if (bind_val.flags & PV_VAL_INT) { + bind_local_val.s = int2str(bind_val.ri, &bind_local_val.len); + } else { + LM_ERR("rtpp_bind_local avp has unsupported value type\n"); + goto exit; + } + } + } + STR2IOVEC(args->callid, vup.vu[5]); STR2IOVEC(args->from_tag, vup.vu[11]); STR2IOVEC(args->to_tag, vup.vu[15]); @@ -3994,6 +4029,13 @@ static int rtpproxy_offer_answer(struct sip_msg *msg, struct rtpp_args *args, goto error; } } + if (bind_local_val.len > 0) { + if (append_opts(&m_opts, 'l') == -1 || + append_opts_str(&m_opts, &bind_local_val) == -1) { + LM_ERR("out of pkg memory\n"); + goto error; + } + } STR2IOVEC(newip, vup.vu[7]); STR2IOVEC(oldport, vup.vu[9]); if (1 || media_multi) /* XXX netch: can't choose now*/