Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions modules/rtpproxy/README
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<value> 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][,
Expand Down Expand Up @@ -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<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.

Expand Down
30 changes: 29 additions & 1 deletion modules/rtpproxy/doc/rtpproxy_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,27 @@ modparam("rtpproxy", "generated_sdp_port_max", 30000)
<programlisting format="linespecific">
...
modparam("rtpproxy", "generated_sdp_media_ip", "10.0.0.1")
...
</programlisting>
</example>
</section>

<section id="param_rtpp_bind_local_avp" xreflabel="rtpp_bind_local_avp">
<title><varname>rtpp_bind_local_avp</varname> (string)</title>
<para>
The pseudo-variable used to read the local bind value which is
appended as <emphasis>l&lt;value&gt;</emphasis> to the RTPProxy U/L
command when set.
</para>

<para>
<emphasis>Default value is <quote>$avp(rtpp_bind_local)</quote>.</emphasis>
</para>
<example>
<title>Set <varname>rtpp_bind_local_avp</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("rtpproxy", "rtpp_bind_local_avp", "$socket_out(ip)")
...
</programlisting>
</example>
Expand Down Expand Up @@ -740,6 +761,14 @@ if (is_method("INVITE") &amp;&amp; has_totag()) {
and returns the resulted body in it. If not used, the message's
body is used, and the outgoing body is changed.
</para>
<para>
If the pseudo-variable set by <varname>rtpp_bind_local_avp</varname>
is set to a string, its value is appended as
<emphasis>l&lt;value&gt;</emphasis> to the RTPProxy U/L command
(for example, "[1:2:3]" for IPv6). This applies to both
<function>rtpproxy_offer()</function> and
<function>rtpproxy_answer()</function>.
</para>
<para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
Expand Down Expand Up @@ -1264,4 +1293,3 @@ $ opensips-cli -x mi rtpproxy_reload
</section>

</chapter>

44 changes: 43 additions & 1 deletion modules/rtpproxy/rtpproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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}
};

Expand Down Expand Up @@ -1304,6 +1308,18 @@ mod_init(void)
parse_bavp(&param3_bavp_name, &param3_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;
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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*/
Expand Down