Commit 99ed3308 authored by Pekka Pessi's avatar Pekka Pessi

nua: fixed problem of using user-supplied Contact with nua_register()

The user-supplied Contact was not stored with the registration.

darcs-hash:20061128212526-65a35-b48f64011a8f0038c1503f422ff6b11020ef7492.gz
parent d9a09da8
......@@ -120,6 +120,8 @@ struct nua_client_request
unsigned cr_offer_recv:1; /**< Recv offer in a response */
unsigned cr_answer_sent:1; /**< Sent answer in (PR)ACK */
unsigned cr_has_contact:1; /**< Request has application contact */
};
......
......@@ -583,17 +583,12 @@ nua_stack_register(nua_t *nua, nua_handle_t *nh, nua_event_t e,
goto error;
}
if (du->du_msg == NULL)
du->du_msg = msg_ref_create(cr->cr_msg); /* Save original message */
if (terminating)
/* Add Expires: 0 and remove the expire parameters from contacts */
unregister_expires_contacts(msg, sip);
if (nua_tagis_have_contact_tag(tags) ||
nua_tagis_have_contact_tag(nh->nh_tags)) {
if (!sip->sip_contact)
terminating = 1;
if (!sip->sip_contact && cr->cr_has_contact) {
terminating = 1;
}
else if (nua_registration_set_contact(nh, nr, sip->sip_contact, terminating)
< 0)
......@@ -601,6 +596,9 @@ nua_stack_register(nua_t *nua, nua_handle_t *nh, nua_event_t e,
du->du_terminating = terminating;
if (du->du_msg == NULL && !terminating)
du->du_msg = msg_ref_create(cr->cr_msg); /* Save original message */
ob = nr->nr_ob;
if (!ob && (NH_PGET(nh, outbound) || NH_PGET(nh, instance))) {
......@@ -1362,7 +1360,7 @@ nua_registration_t *nua_registration_by_aor(nua_registration_t const *list,
alt_aor = memcpy(_alt_aor, aor, sizeof _alt_aor);
for (nr = list; nr; nr = nr->nr_next) {
if (!nr->nr_ready)
if (!nr->nr_ready || !nr->nr_contact)
continue;
if (nr->nr_aor) {
if (aor && url_cmp(nr->nr_aor->a_url, aor->a_url) == 0)
......@@ -1414,6 +1412,7 @@ nua_registration_for_response(nua_registration_t const *list,
sip_record_route_t const *record_route,
sip_contact_t const *remote_contact)
{
nua_registration_t *nr;
sip_to_t const *aor = NULL;
url_t const *uri = NULL;
......@@ -1429,7 +1428,9 @@ nua_registration_for_response(nua_registration_t const *list,
else if (sip && sip->sip_from)
uri = sip->sip_from->a_url;
return nua_registration_by_aor(list, aor, uri, 0);
nr = nua_registration_by_aor(list, aor, uri, 0);
return nr;
}
......@@ -1479,7 +1480,8 @@ int nua_registration_add_contact_to_request(nua_handle_t *nh,
nr = nua_registration_for_request(nh->nh_nua->nua_registrations, sip);
return nua_registration_add_contact_and_route(nr, msg, sip,
add_contact, add_service_route);
add_contact,
add_service_route);
}
/** Add a Contact header to response.
......@@ -1634,6 +1636,7 @@ int nua_registration_set_contact(nua_handle_t *nh,
/** Mark registration as ready */
void nua_registration_set_ready(nua_registration_t *nr, int ready)
{
assert(!ready || nr->nr_contact);
nr->nr_ready = ready;
}
......
......@@ -1084,6 +1084,9 @@ msg_t *nua_creq_msg(nua_t *nua,
add_contact = t->t_value != 0;
}
if (!restart)
cr->cr_has_contact = has_contact;
if (has_contact) add_contact = 0;
if (method == sip_method_register && url == NULL)
......
......@@ -221,22 +221,6 @@ int test_basic_call_1(struct context *ctx)
run_ab_until(ctx, -1, until_ready, -1, accept_call_with_early_sdp);
TEST_1(repa = nua_handle_make_replaces(a_call->nh, nua_handle_home(a_call->nh), 0));
TEST_1(repb = nua_handle_make_replaces(b_call->nh, nua_handle_home(b_call->nh), 0));
TEST_S(repa->rp_call_id, repb->rp_call_id);
TEST_1(!nua_handle_by_replaces(a->nua, repa));
TEST_1(!nua_handle_by_replaces(b->nua, repb));
TEST_1(nh = nua_handle_by_replaces(a->nua, repb));
TEST_P(nh, a_call->nh);
nua_handle_unref(nh);
TEST_1(nh = nua_handle_by_replaces(b->nua, repa));
TEST_P(nh, b_call->nh);
nua_handle_unref(nh);
/* Client transitions:
INIT -(C1)-> CALLING: nua_invite(), nua_i_state
CALLING -(C2)-> PROCEEDING: nua_r_invite, nua_i_state
......@@ -298,6 +282,22 @@ int test_basic_call_1(struct context *ctx)
TEST_1(nua_handle_has_active_call(b_call->nh));
TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
TEST_1(repa = nua_handle_make_replaces(a_call->nh, nua_handle_home(a_call->nh), 0));
TEST_1(repb = nua_handle_make_replaces(b_call->nh, nua_handle_home(b_call->nh), 0));
TEST_S(repa->rp_call_id, repb->rp_call_id);
TEST_1(!nua_handle_by_replaces(a->nua, repa));
TEST_1(!nua_handle_by_replaces(b->nua, repb));
TEST_1(nh = nua_handle_by_replaces(a->nua, repb));
TEST_P(nh, a_call->nh);
nua_handle_unref(nh);
TEST_1(nh = nua_handle_by_replaces(b->nua, repa));
TEST_P(nh, b_call->nh);
nua_handle_unref(nh);
BYE(b, b_call, b_call->nh, TAG_END());
run_ab_until(ctx, -1, until_terminated, -1, until_terminated);
......
......@@ -174,10 +174,18 @@ int test_register_to_proxy(struct context *ctx)
TEST_1(b_reg->nh = nua_handle(b->nua, b_reg, TAG_END()));
REGISTER(b, b_reg, b_reg->nh, SIPTAG_TO(b->to),
NUTAG_M_DISPLAY("B"),
NUTAG_M_USERNAME("b"),
TAG_END());
/* Test application-supplied contact */
{
sip_contact_t m[1];
sip_contact_init(m)->m_url[0] = b->contact->m_url[0];
m->m_display = "B";
m->m_url->url_user = "b";
REGISTER(b, b_reg, b_reg->nh, SIPTAG_TO(b->to),
SIPTAG_CONTACT(m),
TAG_END());
}
run_ab_until(ctx, -1, save_events, -1, save_until_final_response);
TEST_1(e = b->events->head);
......
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