Skip to content

Commit

Permalink
Fix validation of the send_sock in t_uac().
Browse files Browse the repository at this point in the history
If a send_sock is already provided, no need to do socket discovery again. We need just the protocol (from mk_proxy) in order to validate (or not) the already given send_sock. Do socket discovery only if there no send_sock given or the protocol does not match.

(cherry picked from commit c95ddd8)
  • Loading branch information
bogdan-iancu committed Oct 9, 2014
1 parent 50e6668 commit c7066fe
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions modules/tm/uac.c
Expand Up @@ -179,7 +179,7 @@ int t_uac(str* method, str* headers, str* body, dlg_t* dialog,
int backup_route_type;
int sip_msg_len;
unsigned int hi;
struct socket_info *send_sock, *new_send_sock;
struct socket_info *new_send_sock;
str h_to, h_from, h_cseq, h_callid;
struct proxy_l *proxy, *new_proxy;
unsigned short dst_changed;
Expand Down Expand Up @@ -207,18 +207,23 @@ int t_uac(str* method, str* headers, str* body, dlg_t* dialog,
/* use the first address */
hostent2su( &to_su,
&proxy->host, proxy->addr_idx, proxy->port ? proxy->port:SIP_PORT);
/* get the send socket */
send_sock = get_send_socket( NULL/*msg*/, &to_su, proxy->proto);
if (!send_sock) {
LM_ERR("no corresponding socket for af %d\n", to_su.s.sa_family);
ser_error = E_NO_SOCKET;
goto error2;
}

/* if a send socket defined verify if the same protocol */
if (dialog->send_sock==NULL ||
send_sock->proto != dialog->send_sock->proto)
dialog->send_sock = send_sock;
/* check/discover the send socket */
if (dialog->send_sock) {
/* if already set, the protocol of send sock must have the
the same type as the proto required by destination URI */
if (proxy->proto != dialog->send_sock->proto)
dialog->send_sock = NULL;
}
if (dialog->send_sock==NULL) {
/* get the send socket */
dialog->send_sock = get_send_socket( NULL/*msg*/, &to_su, proxy->proto);
if (!dialog->send_sock) {
LM_ERR("no corresponding socket for af %d\n", to_su.s.sa_family);
ser_error = E_NO_SOCKET;
goto error2;
}
}
LM_DBG("sending socket is %.*s \n",
dialog->send_sock->name.len,dialog->send_sock->name.s);

Expand Down Expand Up @@ -352,12 +357,12 @@ int t_uac(str* method, str* headers, str* body, dlg_t* dialog,
req->add_to_branch_len = req->via1->branch->value.len;

/* update also info about new destination and send sock */
dialog->send_sock = send_sock = new_send_sock;
dialog->send_sock = new_send_sock;
free_proxy( proxy );
pkg_free( proxy );
proxy = new_proxy;
request->dst.send_sock = send_sock;
request->dst.proto = send_sock->proto;
request->dst.send_sock = new_send_sock;
request->dst.proto = new_send_sock->proto;
request->dst.proto_reserved1 = 0;

/* build the shm buffer now */
Expand Down

0 comments on commit c7066fe

Please sign in to comment.