@@ -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" );
@@ -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