Skip to content

Commit

Permalink
Fixed autobridging in combination with TopoHiding.
Browse files Browse the repository at this point in the history
Get information about the next hop from the Transaction layer (when Topo Hiding is used), as we have no second VIA present in the SIP replies.
Based on an original fix from Nick Altmann, related to push request #238.

(cherry picked from commit 20d1fe6)

Conflicts:
	modules/rtpproxy/rtpproxy.c
  • Loading branch information
bogdan-iancu committed Jun 4, 2014
1 parent 58a2c7a commit ff5cdfa
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions modules/rtpproxy/rtpproxy.c
Expand Up @@ -972,7 +972,8 @@ mod_init(void)
float timeout;

if (rtpproxy_autobridge != 0) {
LM_WARN("Auto bridging does not properly function when doing serial/parallel forking\n");
LM_WARN("Auto bridging does not properly function when doing "
"serial/parallel forking\n");
}

if (nortpproxy_str.s==NULL || nortpproxy_str.s[0]==0) {
Expand Down Expand Up @@ -1103,27 +1104,27 @@ mod_init(void)
LM_DBG("dialog module not loaded.\n");
memset(&tm_api, 0, sizeof(struct tm_binds));
if (load_tm_api(&tm_api)!=0)
LM_DBG("can't load TM API - check if tm module was loaded\n");
LM_DBG("TM modules was not found\n");

if (parse_bavp(&param1_bavp_name, &param1_spec) < 0 ||
parse_bavp(&param2_bavp_name, &param2_spec) < 0)
LM_DBG("cannot parse bavp's\n");

if(rtpp_notify_socket.s) {
if(rtpp_notify_socket.s) {
if (strncmp("tcp:", rtpp_notify_socket.s, 4) == 0) {
rtpp_notify_socket.s += 4;
} else {
if (strncmp("unix:", rtpp_notify_socket.s, 5) == 0)
rtpp_notify_socket.s += 5;
rtpp_notify_socket_un = 1;
}
/* check if the notify socket parameter is set */
rtpp_notify_socket.len = strlen(rtpp_notify_socket.s);
if(dlg_api.get_dlg == 0) {
LM_ERR("You need to load dialog module if you want to use the"
" timeout notification feature\n");
return -1;
}
/* check if the notify socket parameter is set */
rtpp_notify_socket.len = strlen(rtpp_notify_socket.s);
if(dlg_api.get_dlg == 0) {
LM_ERR("You need to load dialog module if you want to use the"
" timeout notification feature\n");
return -1;
}

rtpp_notify_h = (struct rtpp_notify_head *)
shm_malloc(sizeof(struct rtpp_notify_head));
Expand All @@ -1147,11 +1148,9 @@ mod_init(void)
LM_ERR("cannot find any valid rtpproxy to use\n");
return -1;
}
}
else
{
exports.procs = 0;
}
} else {
exports.procs = 0;
}

if (rtpp_sock_pvar_pvname.s && (rtpp_sock_pvar_pvname.len=strlen(rtpp_sock_pvar_pvname.s))>0 ) {
if(pv_parse_spec(&rtpp_sock_pvar_pvname, &rtpp_sock_pvar_pv)==NULL
Expand Down Expand Up @@ -2919,7 +2918,8 @@ force_rtp_proxy(struct sip_msg* msg, char* str1, char* str2, int offer)
struct force_rtpp_args *ap;
union sockaddr_union to;
struct ip_addr ip;

struct cell *trans;

memset(&args, '\0', sizeof(args));
m = get_all_bodies(msg);

Expand Down Expand Up @@ -2990,16 +2990,24 @@ force_rtp_proxy(struct sip_msg* msg, char* str1, char* str2, int offer)
msg_callback_add(msg, REQ_PRE_FORWARD, rtpproxy_pre_fwd, ap);
msg_callback_add(msg, MSG_DESTROY, rtpproxy_pre_fwd_free, ap);
continue;
}
if (rtpproxy_autobridge && args.node->abr_supported && msg->first_line.type == SIP_REPLY) {
if (parse_headers(msg, HDR_VIA2_F, 0) != -1 &&
(msg->via2 != NULL) && (msg->via2->error == PARSE_OK) &&
update_sock_struct_from_via(&to, msg, msg->via2) != -1) {
} else {
/* first try to get the destination of this reply from the
* transaction (as the source of the request) */
if (tm_api.t_gett && (trans=tm_api.t_gett())!=0 &&
trans!=T_UNDEFINED && trans->uas.request ) {
/* we have the request from the transaction this
* reply belongs to */
args.raddr.s = ip_addr2a(&trans->uas.request->rcv.src_ip);
args.raddr.len = strlen(args.raddr.s);
} else if (parse_headers(msg, HDR_VIA2_F, 0) != -1 &&
(msg->via2 != NULL) && (msg->via2->error == PARSE_OK) &&
update_sock_struct_from_via(&to, msg, msg->via2)!=-1) {
su2ip_addr(&ip, &to);
args.raddr.s = ip_addr2a(&ip);
args.raddr.len = strlen(args.raddr.s);
} else {
LM_ERR("can't extract 2nd via found reply\n");
LM_ERR("can't extract reply destination from "
"transaction/reply_via2\n");
}
}

Expand Down

0 comments on commit ff5cdfa

Please sign in to comment.