@@ -228,6 +228,9 @@ static str param3_name = str_init("rtpproxy_3");
228228str param3_bavp_name = str_init ("$bavp(5589967)" );
229229pv_spec_t param3_spec ;
230230static 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 */
233236static str event_name = str_init ("E_RTPPROXY_STATUS" );
@@ -525,6 +528,7 @@ static const param_export_t params[] = {
525528 {"generated_sdp_port_min" ,INT_PARAM , & rtpproxy_port_min },
526529 {"generated_sdp_port_max" ,INT_PARAM , & rtpproxy_port_max },
527530 {"generated_sdp_media_ip" ,STR_PARAM , & rtpproxy_media_ip .s },
531+ {"rtpp_bind_local_avp" , STR_PARAM , & rtpp_bind_local_avp_name .s },
528532 {0 , 0 , 0 }
529533};
530534
@@ -1304,6 +1308,18 @@ mod_init(void)
13041308 parse_bavp (& param3_bavp_name , & param3_spec ) < 0 )
13051309 LM_DBG ("cannot parse bavps\n" );
13061310
1311+ if (rtpp_bind_local_avp_name .s && rtpp_bind_local_avp_name .s [0 ] != '\0' ) {
1312+ rtpp_bind_local_avp_name .len = strlen (rtpp_bind_local_avp_name .s );
1313+ if (pv_parse_spec (& rtpp_bind_local_avp_name , & rtpp_bind_local_spec ) != NULL ) {
1314+ rtpp_bind_local_avp_ok = 1 ;
1315+ } else {
1316+ LM_ERR ("malformed rtpp_bind_local pvar definition\n" );
1317+ return -1 ;
1318+ }
1319+ } else {
1320+ rtpp_bind_local_avp_ok = 0 ;
1321+ }
1322+
13071323 if (rtpp_notify_socket .s ) {
13081324 if (strncmp ("tcp:" , rtpp_notify_socket .s , 4 ) == 0 ) {
13091325 rtpp_notify_socket_un = 0 ;
@@ -3583,12 +3599,13 @@ static int rtpproxy_offer_answer(struct sip_msg *msg, struct rtpp_args *args,
35833599 char medianum_buf [20 ];
35843600 char buf [32 ], dbuf [128 ];
35853601 int medianum , media_multi ;
3586- str medianum_str , tmpstr1 ;
3602+ str medianum_str , tmpstr1 , bind_local_val ;
35873603 int c1p_altered ;
35883604 int enable_dtmf_catch = 0 ;
35893605 int node_has_notification , node_has_dtmf_catch = 0 ;
35903606 int vcnt ;
35913607 pv_value_t val ;
3608+ pv_value_t bind_val ;
35923609 char * adv_address = NULL ;
35933610 struct dlg_cell * dlg ;
35943611 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,
38173834 medianum = 0 ;
38183835
38193836 opts .s .s [0 ] = (create == 0 ) ? 'L' : 'U' ;
3837+
3838+ bind_local_val .len = 0 ;
3839+ if (msg && rtpp_bind_local_avp_ok ) {
3840+ if (pv_get_spec_value (msg , & rtpp_bind_local_spec , & bind_val ) < 0 ) {
3841+ LM_ERR ("cannot get rtpp_bind_local avp value\n" );
3842+ goto exit ;
3843+ } else if (!(bind_val .flags & PV_VAL_NULL )) {
3844+ if (bind_val .flags & PV_VAL_STR ) {
3845+ bind_local_val = bind_val .rs ;
3846+ } else if (bind_val .flags & PV_VAL_INT ) {
3847+ bind_local_val .s = int2str (bind_val .ri , & bind_local_val .len );
3848+ } else {
3849+ LM_ERR ("rtpp_bind_local avp has unsupported value type\n" );
3850+ goto exit ;
3851+ }
3852+ }
3853+ }
3854+
38203855 STR2IOVEC (args -> callid , vup .vu [5 ]);
38213856 STR2IOVEC (args -> from_tag , vup .vu [11 ]);
38223857 STR2IOVEC (args -> to_tag , vup .vu [15 ]);
@@ -3994,6 +4029,13 @@ static int rtpproxy_offer_answer(struct sip_msg *msg, struct rtpp_args *args,
39944029 goto error ;
39954030 }
39964031 }
4032+ if (bind_local_val .len > 0 ) {
4033+ if (append_opts (& m_opts , 'l' ) == -1 ||
4034+ append_opts_str (& m_opts , & bind_local_val ) == -1 ) {
4035+ LM_ERR ("out of pkg memory\n" );
4036+ goto error ;
4037+ }
4038+ }
39974039 STR2IOVEC (newip , vup .vu [7 ]);
39984040 STR2IOVEC (oldport , vup .vu [9 ]);
39994041 if (1 || media_multi ) /* XXX netch: can't choose now*/
0 commit comments