Skip to content

Commit d2a60b9

Browse files
committed
Add rtpp_bind_local support for the offer/answer/engage.
When this AVP is set, its value would be provided to the rtpproxy with "l" modifier, allowing proper address to be selected for the session.
1 parent b7e02bb commit d2a60b9

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

modules/rtpproxy/README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ if (is_method("INVITE") && has_totag()) {
604604
returns the resulted body in it. If not used, the message's
605605
body is used, and the outgoing body is changed.
606606

607+
If $avp(rtpp_bind_local) is set to a string, its value is
608+
appended as l<value> to the RTPProxy U/L command (for example,
609+
"[1:2:3]" for IPv6). This applies to both rtpproxy_offer() and
610+
rtpproxy_answer().
611+
607612
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
608613
FAILURE_ROUTE, BRANCH_ROUTE.
609614

modules/rtpproxy/doc/rtpproxy_admin.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,13 @@ if (is_method("INVITE") &amp;&amp; has_totag()) {
740740
and returns the resulted body in it. If not used, the message's
741741
body is used, and the outgoing body is changed.
742742
</para>
743+
<para>
744+
If <emphasis>$avp(rtpp_bind_local)</emphasis> is set to a string,
745+
its value is appended as <emphasis>l&lt;value&gt;</emphasis> to
746+
the RTPProxy U/L command (for example, "[1:2:3]" for IPv6).
747+
This applies to both <function>rtpproxy_offer()</function> and
748+
<function>rtpproxy_answer()</function>.
749+
</para>
743750
<para>
744751
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
745752
FAILURE_ROUTE, BRANCH_ROUTE.
@@ -1264,4 +1271,3 @@ $ opensips-cli -x mi rtpproxy_reload
12641271
</section>
12651272

12661273
</chapter>
1267-

modules/rtpproxy/rtpproxy.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ static str param3_name = str_init("rtpproxy_3");
228228
str param3_bavp_name = str_init("$bavp(5589967)");
229229
pv_spec_t param3_spec;
230230
static str late_name = str_init("late_negotiation");
231+
static str rtpp_bind_local_avp_name = str_init("$avp(rtpp_bind_local)");
232+
static pv_spec_t rtpp_bind_local_spec;
233+
static int rtpp_bind_local_avp_ok = 0;
231234

232235
/* parameters name for event signaling */
233236
static str event_name = str_init("E_RTPPROXY_STATUS");
@@ -1304,6 +1307,14 @@ mod_init(void)
13041307
parse_bavp(&param3_bavp_name, &param3_spec) < 0)
13051308
LM_DBG("cannot parse bavps\n");
13061309

1310+
if (pv_parse_spec(&rtpp_bind_local_avp_name, &rtpp_bind_local_spec) != NULL &&
1311+
rtpp_bind_local_spec.type == PVT_AVP) {
1312+
rtpp_bind_local_avp_ok = 1;
1313+
} else {
1314+
LM_ERR("malformed rtpp_bind_local AVP definition\n");
1315+
rtpp_bind_local_avp_ok = 0;
1316+
}
1317+
13071318
if(rtpp_notify_socket.s) {
13081319
if (strncmp("tcp:", rtpp_notify_socket.s, 4) == 0) {
13091320
rtpp_notify_socket_un = 0;
@@ -3583,12 +3594,13 @@ static int rtpproxy_offer_answer(struct sip_msg *msg, struct rtpp_args *args,
35833594
char medianum_buf[20];
35843595
char buf[32], dbuf[128];
35853596
int medianum, media_multi;
3586-
str medianum_str, tmpstr1;
3597+
str medianum_str, tmpstr1, bind_local_val;
35873598
int c1p_altered;
35883599
int enable_dtmf_catch = 0;
35893600
int node_has_notification, node_has_dtmf_catch = 0;
35903601
int vcnt;
35913602
pv_value_t val;
3603+
pv_value_t bind_val;
35923604
char *adv_address = NULL;
35933605
struct dlg_cell * dlg;
35943606
str dtmf_tag = {0, 0}, timeout_tag = {0, 0};
@@ -3817,6 +3829,22 @@ static int rtpproxy_offer_answer(struct sip_msg *msg, struct rtpp_args *args,
38173829
medianum = 0;
38183830

38193831
opts.s.s[0] = (create == 0) ? 'L' : 'U';
3832+
3833+
bind_local_val.len = 0;
3834+
if (msg && rtpp_bind_local_avp_ok) {
3835+
if (pv_get_spec_value(msg, &rtpp_bind_local_spec, &bind_val) < 0) {
3836+
LM_ERR("cannot get rtpp_bind_local avp value\n");
3837+
} else if (!(bind_val.flags & PV_VAL_NULL)) {
3838+
if (bind_val.flags & PV_VAL_STR) {
3839+
bind_local_val = bind_val.rs;
3840+
} else if (bind_val.flags & PV_VAL_INT) {
3841+
bind_local_val.s = int2str(bind_val.ri, &bind_local_val.len);
3842+
} else {
3843+
bind_local_val.len = 0;
3844+
}
3845+
}
3846+
}
3847+
38203848
STR2IOVEC(args->callid, vup.vu[5]);
38213849
STR2IOVEC(args->from_tag, vup.vu[11]);
38223850
STR2IOVEC(args->to_tag, vup.vu[15]);
@@ -3994,6 +4022,13 @@ static int rtpproxy_offer_answer(struct sip_msg *msg, struct rtpp_args *args,
39944022
goto error;
39954023
}
39964024
}
4025+
if (bind_local_val.len > 0) {
4026+
if (append_opts(&m_opts, 'l') == -1 ||
4027+
append_opts_str(&m_opts, &bind_local_val) == -1) {
4028+
LM_ERR("out of pkg memory\n");
4029+
goto error;
4030+
}
4031+
}
39974032
STR2IOVEC(newip, vup.vu[7]);
39984033
STR2IOVEC(oldport, vup.vu[9]);
39994034
if (1 || media_multi) /* XXX netch: can't choose now*/

0 commit comments

Comments
 (0)