res_pjsip / res_pjsip_multihomed: Use the correct transport and addressing information on UAS sessions.

The first thing this patch fixes is UAS dialogs. Previously if a transport was
configured on an endpoint and an inbound session was created there was no guarantee
that requests sent on the dialog would use the correct transport and address
information. This has now been fixed so an explicitly configured transport
is taken into account.

The second thing this patch fixes is res_pjsip_multihomed. The res_pjsip_multihomed
module attempts to determine what transport a message should go out on and what
addressing information should go into the message itself. In a scenario where
multiple transports exist bound to the same IP address but a different port the
code would incorrectly alter the transport and change the message to the wrong
transport. This change makes the res_pjsip_multihomed module smarter so it will
only change the transport and address information in the message when it is
possible and makes sense.

ASTERISK-24615 #close
Reported by: David Justl

Review: https://reviewboard.asterisk.org/r/4331/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@430755 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2015-01-19 13:18:32 +00:00
parent 34c220203f
commit 643b81d98e
2 changed files with 45 additions and 28 deletions

View File

@@ -2270,17 +2270,29 @@ pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint,
pjsip_dialog *dlg;
pj_str_t contact;
pjsip_transport_type_e type = rdata->tp_info.transport->key.type;
pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
pjsip_transport *transport;
ast_assert(status != NULL);
if (sip_get_tpselector_from_endpoint(endpoint, &selector)) {
return NULL;
}
transport = rdata->tp_info.transport;
if (selector.type == PJSIP_TPSELECTOR_TRANSPORT) {
transport = selector.u.transport;
}
type = transport->key.type;
contact.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE);
contact.slen = pj_ansi_snprintf(contact.ptr, PJSIP_MAX_URL_SIZE,
"<sip:%s%.*s%s:%d%s%s>",
(type & PJSIP_TRANSPORT_IPV6) ? "[" : "",
(int)rdata->tp_info.transport->local_name.host.slen,
rdata->tp_info.transport->local_name.host.ptr,
(int)transport->local_name.host.slen,
transport->local_name.host.ptr,
(type & PJSIP_TRANSPORT_IPV6) ? "]" : "",
rdata->tp_info.transport->local_name.port,
transport->local_name.port,
(type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
(type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
@@ -2294,6 +2306,10 @@ pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint,
return NULL;
}
dlg->sess_count++;
pjsip_dlg_set_transport(dlg, &selector);
dlg->sess_count--;
return dlg;
}