Commit a8fc1060 authored by Pekka Pessi's avatar Pekka Pessi

nua: fixed registration without Contact.

darcs-hash:20061005072624-65a35-d00897de6544687eb1b4d22391e2211481b9aacc.gz
parent 2da61556
......@@ -551,8 +551,6 @@ nua_stack_register(nua_t *nua, nua_handle_t *nh, nua_event_t e,
goto error;
}
du->du_terminating = terminating;
if (du->du_msg == NULL)
du->du_msg = msg_ref_create(cr->cr_msg); /* Save original message */
......@@ -560,9 +558,17 @@ nua_stack_register(nua_t *nua, nua_handle_t *nh, nua_event_t e,
/* Add Expires: 0 and remove the expire parameters from contacts */
unregister_expires_contacts(msg, sip);
if (nua_registration_set_contact(nh, nr, sip->sip_contact, terminating) < 0)
if (nua_tagis_have_contact_tag(tags) ||
nua_tagis_have_contact_tag(nh->nh_tags)) {
if (!sip->sip_contact)
terminating = 1;
}
else if (nua_registration_set_contact(nh, nr, sip->sip_contact, terminating)
< 0)
goto error;
du->du_terminating = terminating;
ob = nr->nr_ob;
if (!ob && (NH_PGET(nh, outbound) || NH_PGET(nh, instance))) {
......
......@@ -909,6 +909,18 @@ int nh_challenge(nua_handle_t *nh, sip_t const *sip)
return server + proxy;
}
#include <sofia-sip/su_tag_inline.h>
/** Check if tag list has contact */
int nua_tagis_have_contact_tag(tagi_t const *t)
{
for (; t && t->t_tag; t = t_next(t))
if (t->t_tag == siptag_contact ||
t->t_tag == siptag_contact_str)
return 1;
return 0;
}
/**@internal
* Create a request message.
*
......@@ -933,7 +945,7 @@ msg_t *nua_creq_msg(nua_t *nua,
ta_list ta;
url_string_t const *url = NULL;
long seq = -1;
int copy = 1, use_dialog = 0, add_contact = 0, add_service_route;
int copy = 1;
/* If restarting, use existing message */
if (restart) {
......@@ -1025,11 +1037,22 @@ msg_t *nua_creq_msg(nua_t *nua,
}
{
tl_gets(ta_args(ta),
NUTAG_URL_REF(url),
NUTAG_USE_DIALOG_REF(use_dialog),
NUTAG_ADD_CONTACT_REF(add_contact),
TAG_END());
int add_contact = 0, use_dialog = 0, add_service_route, has_contact = 0;
tagi_t const *t;
for (t = ta_args(ta); t; t = t_next(t)) {
if (t->t_tag == siptag_contact ||
t->t_tag == siptag_contact_str)
has_contact = 1;
else if (t->t_tag == nutag_url)
url = (url_string_t const *)t->t_value;
else if (t->t_tag == nutag_use_dialog)
use_dialog = t->t_value != 0;
else if (t->t_tag == _nutag_add_contact)
add_contact = t->t_value != 0;
}
if (has_contact) add_contact = 0;
if (method == sip_method_register && url == NULL)
url = (url_string_t const *)NH_PGET(nh, registrar);
......@@ -1129,10 +1152,8 @@ msg_t *nua_creq_msg(nua_t *nua,
*/
if (!add_contact ||
sip->sip_contact ||
tl_find(nh->nh_tags, siptag_contact) ||
tl_find(nh->nh_tags, siptag_contact_str) ||
tl_find(ta_args(ta), siptag_contact) ||
tl_find(ta_args(ta), siptag_contact_str))
nua_tagis_have_contact_tag(nh->nh_tags) ||
nua_tagis_have_contact_tag(ta_args(ta)))
add_contact = 0;
/**For the initial requests, @ServiceRoute set received from the registrar
......
......@@ -457,6 +457,8 @@ msg_t *nua_creq_msg(nua_t *nua, nua_handle_t *nh,
sip_method_t method, char const *name,
tag_type_t tag, tag_value_t value, ...);
int nua_tagis_have_contact_tag(tagi_t const *t);
int nua_creq_check_restart(nua_handle_t *nh,
struct nua_client_request *cr,
nta_outgoing_t *orq,
......
......@@ -370,6 +370,12 @@ int test_register_to_c(struct context *ctx)
free_events_in_list(ctx, b->events);
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
TEST_1(e = c->events->head);
TEST_E(e->data->e_event, nua_i_register);
TEST(e->data->e_status, 100);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(!sip->sip_contact);
free_events_in_list(ctx, c->events);
nua_handle_destroy(c_call->nh), c_call->nh = NULL;
......
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