Commit 78f30f9d authored by Pekka Pessi's avatar Pekka Pessi

nua_register.c: sf.net bug #1816647: Outbound contact does not make it to dialogs

Now use Contact from first registration instead of Contact generated from
transport.

darcs-hash:20071116173400-65a35-c4e0d3465c56c2ca33a7bdcaf8cf558f51dccdf6.gz
parent 4905c892
......@@ -1426,6 +1426,7 @@ nua_registration_t *nua_registration_by_aor(nua_registration_t const *list,
int sips_uri = remote_uri && remote_uri->url_type == url_sips;
nua_registration_t const *nr, *public = NULL, *any = NULL;
nua_registration_t const *registered = NULL;
nua_registration_t const *namewise = NULL, *sipswise = NULL;
int ip4 = remote_uri && host_is_ip4_address(remote_uri->url_host);
......@@ -1444,11 +1445,15 @@ nua_registration_t *nua_registration_by_aor(nua_registration_t const *list,
continue;
if (sips_uri ? nr->nr_secure : !nr->nr_secure)
return (nua_registration_t *)nr;
if (!registered && nr->nr_aor)
registered = nr;
if (!public && nr->nr_public)
public = nr;
if (!any)
any = nr;
}
if (registered)
return (nua_registration_t *)registered;
if (public)
return (nua_registration_t *)public;
if (any)
......@@ -1456,8 +1461,11 @@ nua_registration_t *nua_registration_by_aor(nua_registration_t const *list,
return NULL;
}
if (!sips_aor && aor)
if (!sips_aor && aor) {
alt_aor = memcpy(_alt_aor, aor, sizeof _alt_aor);
alt_aor->a_url->url_type = url_sips;
alt_aor->a_url->url_scheme = "sips";
}
for (nr = list; nr; nr = nr->nr_next) {
if (!nr->nr_ready || !nr->nr_contact)
......@@ -1468,11 +1476,12 @@ nua_registration_t *nua_registration_by_aor(nua_registration_t const *list,
if (!namewise && alt_aor && url_cmp(nr->nr_aor->a_url, aor->a_url) == 0)
namewise = nr;
}
else {
if (!sipswise && ((sips_aor || sips_uri) ?
nr->nr_secure : !nr->nr_secure))
sipswise = nr;
}
if (!sipswise && ((sips_aor || sips_uri) ?
nr->nr_secure : !nr->nr_secure))
sipswise = nr;
if (!registered)
registered = nr;
if (!public && nr->nr_public)
public = nr;
if (!any)
......@@ -1483,7 +1492,9 @@ nua_registration_t *nua_registration_by_aor(nua_registration_t const *list,
return (nua_registration_t *)namewise;
if (sipswise)
return (nua_registration_t *)sipswise;
if (registered)
return (nua_registration_t *)registered;
/* XXX -
should we do some policing whether sips_aor or sips_uri can be used
with sip contact?
......@@ -1594,7 +1605,7 @@ int nua_registration_add_contact_to_request(nua_handle_t *nh,
*
* @param nh
* @param msg response message
* @param sip response headers
* @param sip headers in response message
* @param record_route record-route from request
* @param remote_contact Contact from request
*/
......
......@@ -457,8 +457,14 @@ int test_basic_call_2(struct context *ctx)
TEST_S(sip->sip_content_type->c_type, "application/sdp");
TEST_1(sip->sip_payload); /* there is sdp in 200 OK */
TEST_1(sip->sip_contact);
#if nomore
/* Test that B does not use application-specific contact */
TEST_1(!sip->sip_contact->m_url->url_user);
#else
/* sf.net bug #1816647: Outbound contact does not make it to dialogs */
/* Now we use first registered contact if aor does not match */
TEST_S(sip->sip_contact->m_url->url_user, "b");
#endif
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
TEST_1(!is_answer_recv(e->data->e_tags)); /* but it is ignored */
......@@ -989,6 +995,9 @@ int change_uri_in_ack(CONDITION_PARAMS)
}
/* Test changing from/to within dialog */
/* Test that a proper Contact gets selected in response
* regardless of the To URI.
*/
int test_basic_call_5(struct context *ctx)
{
BEGIN();
......@@ -1004,13 +1013,15 @@ int test_basic_call_5(struct context *ctx)
a_call->sdp = "m=audio 5008 RTP/AVP 8";
b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
TEST_1(a_call->nh = nua_handle(a->nua, a_call,
SIPTAG_TO_STR("<sips:b@x.org>"),
TAG_END()));
TEST_1(!nua_handle_has_active_call(a_call->nh));
TEST_1(!nua_handle_has_call_on_hold(a_call->nh));
INVITE(a, a_call, a_call->nh,
TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
NUTAG_URL(b->contact->m_url),
SOATAG_USER_SDP_STR(a_call->sdp),
NUTAG_AUTOACK(0),
TAG_END());
......@@ -1032,6 +1043,7 @@ int test_basic_call_5(struct context *ctx)
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_contact);
TEST_S(sip->sip_contact->m_url->url_user, "b");
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_completing); /* COMPLETING */
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment