Commit f96079e5 authored by Pekka Pessi's avatar Pekka Pessi

nua: using NUTAG_M_DISPLAY(), NUTAG_M_USERNAME(), and NUTAG_M_PARAMS() in...

nua: using NUTAG_M_DISPLAY(), NUTAG_M_USERNAME(), and NUTAG_M_PARAMS() in Contacts added to ordinary requests or responses

darcs-hash:20070202005910-65a35-ec99d6775b4b2e3075c6e2e7d5fcae74b6efdf48.gz
parent b2381780
......@@ -970,7 +970,8 @@ static int nua_register_usage_shutdown(nua_handle_t *nh,
#endif
static void nua_stack_tport_update(nua_t *nua, nta_agent_t *nta);
static int nua_registration_add_contact_and_route(nua_registration_t *nr,
static int nua_registration_add_contact_and_route(nua_handle_t *nh,
nua_registration_t *nr,
msg_t *msg,
sip_t *sip,
int add_contact,
......@@ -1466,7 +1467,7 @@ int nua_registration_add_contact_to_request(nua_handle_t *nh,
if (nr == NULL)
nr = nua_registration_for_request(nh->nh_nua->nua_registrations, sip);
return nua_registration_add_contact_and_route(nr, msg, sip,
return nua_registration_add_contact_and_route(nh, nr, msg, sip,
add_contact,
add_service_route);
}
......@@ -1497,12 +1498,15 @@ int nua_registration_add_contact_to_response(nua_handle_t *nh,
nr = nua_registration_for_response(nh->nh_nua->nua_registrations, sip,
record_route, remote_contact);
return nua_registration_add_contact_and_route(nr, msg, sip, 1, 0);
return nua_registration_add_contact_and_route(nh, nr, msg, sip,
1,
0);
}
/** Add a Contact (and Route) header to request */
static
int nua_registration_add_contact_and_route(nua_registration_t *nr,
int nua_registration_add_contact_and_route(nua_handle_t *nh,
nua_registration_t *nr,
msg_t *msg,
sip_t *sip,
int add_contact,
......@@ -1513,7 +1517,34 @@ int nua_registration_add_contact_and_route(nua_registration_t *nr,
if (add_contact) {
sip_contact_t const *m = nua_registration_contact(nr);
if (!m || msg_header_add_dup(msg, (msg_pub_t *)sip, (void const *)m) < 0)
char const *m_display = NH_PGET(nh, m_display);
char const *m_username = NH_PGET(nh, m_username);
char const *m_params = NH_PGET(nh, m_params);
url_t const *u = m->m_url;
if (!m)
return -1;
if (str0cmp(m_params, u->url_params) == 0)
m_params = NULL;
m = sip_contact_format(msg_home(msg),
"%s<%s:%s%s%s%s%s%s%s%s%s>",
m_display ? m_display :
m->m_display ? m->m_display : "",
u->url_scheme,
m_username ? m_username : "",
m_username ? "@" : "",
u->url_host,
u->url_port ? ":" : "",
u->url_port ? u->url_port : "",
u->url_params ? ";" : "",
u->url_params ? u->url_params : "",
m_params ? ";" : "",
m_params ? m_params : "");
if (msg_header_insert(msg, (msg_pub_t *)sip, (void *)m) < 0)
return -1;
}
......
......@@ -1327,6 +1327,7 @@ SOFIAPUBVAR tag_typedef_t nutag_authtime_ref;
*
* @par Used with
* nua_register(), nua_set_hparams(), nua_set_params().
* nua_invite(), nua_respond(), nua_subscribe(), nua_notify()
*
* @par Parameter type
* string (char *)
......@@ -1358,6 +1359,7 @@ SOFIAPUBVAR tag_typedef_t nutag_m_display_ref;
*
* @par Used with
* nua_register(), nua_set_hparams(), nua_set_params().
* nua_invite(), nua_respond(), nua_subscribe(), nua_notify()
*
* @par Parameter type
* string (char *)
......@@ -1388,7 +1390,8 @@ SOFIAPUBVAR tag_typedef_t nutag_m_username_ref;
* user-agent.
*
* @par Used with
* nua_register(), nua_set_hparams(), nua_set_params().
* nua_register(), nua_set_hparams(), nua_set_params(),
* nua_invite(), nua_respond(), nua_subscribe(), nua_notify()
*
* @par Parameter type
* string (char *)
......
......@@ -117,6 +117,8 @@ int accept_call_with_early_sdp(CONDITION_PARAMS)
case nua_callstate_received:
RESPOND(ep, call, nh, SIP_180_RINGING,
TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
NUTAG_M_DISPLAY("Bob"),
NUTAG_M_USERNAME("b+b"),
TAG_END());
return 0;
case nua_callstate_early:
......@@ -217,6 +219,8 @@ int test_basic_call_1(struct context *ctx)
INVITE(a, a_call, a_call->nh,
TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
SOATAG_USER_SDP_STR(a_call->sdp),
NUTAG_M_USERNAME("a+a"),
NUTAG_M_DISPLAY("Alice"),
TAG_END());
run_ab_until(ctx, -1, until_ready, -1, accept_call_with_early_sdp);
......@@ -263,8 +267,11 @@ int test_basic_call_1(struct context *ctx)
TEST_1(is_answer_recv(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 200);
TEST_1(sip->sip_payload);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_payload);
TEST_1(sip->sip_contact);
TEST_S(sip->sip_contact->m_display, "Bob");
TEST_S(sip->sip_contact->m_url->url_user, "b+b");
/* Test that B uses application-specific contact */
if (ctx->proxy_tests)
TEST_1(sip->sip_contact->m_url->url_user);
......@@ -282,6 +289,10 @@ int test_basic_call_1(struct context *ctx)
*/
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
TEST(e->data->e_status, 100);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_contact);
TEST_S(sip->sip_contact->m_display, "Alice");
TEST_S(sip->sip_contact->m_url->url_user, "a+a");
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
TEST_1(is_offer_recv(e->data->e_tags));
......
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