Commit ca7420c5 authored by Pekka Pessi's avatar Pekka Pessi

nua: added NUTAG_INCLUDE_EXTRA_SDP().

darcs-hash:20061009135504-65a35-394295ee81354366f1132cff4549279f7cc0137e.gz
parent 7dcf518e
......@@ -1610,9 +1610,14 @@ void respond_to_invite(nua_t *nua, nua_handle_t *nh,
}
else if (status >= 200 || ss->ss_100rel ||
(sr->sr_offer_recv && sr->sr_answer_sent <= 1 && early_answer)) {
if ((sr->sr_offer_recv && sr->sr_answer_sent > 1) ||
(sr->sr_offer_sent && !sr->sr_answer_recv))
/* Nothing to do */;
int extra = 0;
if (sr->sr_offer_sent && !sr->sr_answer_recv)
/* Wait for answer */;
else if (sr->sr_offer_recv && sr->sr_answer_sent > 1) {
tagi_t const *t = tl_find_last(tags, nutag_include_extra_sdp);
extra = t && t->t_value;
}
else if (sr->sr_offer_recv && !sr->sr_answer_sent) {
if (soa_generate_answer(nh->nh_soa, NULL) < 0) {
int wcode;
......@@ -1643,7 +1648,7 @@ void respond_to_invite(nua_t *nua, nua_handle_t *nh,
offer = 1;
}
if (offer || answer) {
if (offer || answer || extra) {
if (session_include_description(nh->nh_soa, msg, sip) < 0)
SET_STATUS1(SIP_500_INTERNAL_SERVER_ERROR);
}
......
......@@ -52,6 +52,7 @@ tag_typedef_t nutag_callee_caps = BOOLTAG_TYPEDEF(callee_caps);
tag_typedef_t nutag_early_media = BOOLTAG_TYPEDEF(early_media);
tag_typedef_t nutag_only183_100rel = BOOLTAG_TYPEDEF(only183_100rel);
tag_typedef_t nutag_early_answer = BOOLTAG_TYPEDEF(early_answer);
tag_typedef_t nutag_include_extra_sdp = BOOLTAG_TYPEDEF(include_extra_sdp);
tag_typedef_t nutag_media_enable = BOOLTAG_TYPEDEF(media_enable);
tag_typedef_t nutag_soa_session = PTRTAG_TYPEDEF(soa_session);
......
......@@ -343,6 +343,42 @@ SOFIAPUBVAR tag_typedef_t nutag_early_answer;
#define NUTAG_EARLY_ANSWER_REF(x) nutag_early_answer_ref, tag_bool_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_early_answer_ref;
/**Include an extra copy of SDP answer in the response.
*
* When NUTAG_INCLUDE_EXTRA_SDP(1) is included in nua_respond() tags, stack
* will include in the response a copy of the SDP offer/answer that was last
* sent to the client. This tag should be used only when you know that the
* remote end requires the extra SDP, for example, some versions of Cisco
* SIPGateway need a copy of answer in 200 OK even when they indicate
* support for 100rel.
*
* @par Used with
* nua_respond()
*
* @par Parameter type
* int (boolean)
*
* @par Values
* @c 0 False \n
* @c !=0 True
*
* Corresponding tag taking reference parameter is
* NUTAG_INCLUDE_EXTRA_SDP_REF().
*
* @note Requires that @soa is enabled with NUTAG_MEDIA_ENABLE(1).
*
* @sa NUTAG_EARLY_ANSWER(), NUTAG_EARLY_MEDIA(), NUTAG_AUTOALERT(),
* NUTAG_MEDIA_ENABLE(), @RFC3264, @RFC3264
*
* @since New in @VERSION_1_12_4.
*/
#define NUTAG_INCLUDE_EXTRA_SDP(x) nutag_include_extra_sdp, tag_bool_v(x)
SOFIAPUBVAR tag_typedef_t nutag_include_extra_sdp;
#define NUTAG_INCLUDE_EXTRA_SDP_REF(x) \
nutag_include_extra_sdp_ref, tag_bool_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_include_extra_sdp_ref;
/** Timer for outstanding INVITE in seconds.
*
* INVITE will be canceled if no answer is received before timer expires.
......
......@@ -94,6 +94,41 @@ int accept_pracked(CONDITION_PARAMS)
}
}
int accept_pracked2(CONDITION_PARAMS)
{
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
return 0;
save_event_in_list(ctx, event, ep, call);
switch (event) {
case nua_i_prack:
if (200 <= status && status < 300) {
RESPOND(ep, call, nh, SIP_200_OK,
NUTAG_INCLUDE_EXTRA_SDP(1),
TAG_END());
ep->next_condition = until_ready;
}
default:
break;
}
switch (callstate(tags)) {
case nua_callstate_received:
RESPOND(ep, call, nh, SIP_180_RINGING,
TAG_IF(call->sdp, SOATAG_USER_SDP_STR(call->sdp)),
TAG_END());
return 0;
case nua_callstate_terminated:
if (call)
nua_handle_destroy(call->nh), call->nh = NULL;
return 1;
default:
return 0;
}
}
int test_180rel(struct context *ctx)
{
BEGIN();
......@@ -101,6 +136,7 @@ int test_180rel(struct context *ctx)
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
sip_t *sip;
if (print_headings)
printf("TEST NUA-10.1.1: Call with 100rel and 180\n");
......@@ -144,7 +180,7 @@ int test_180rel(struct context *ctx)
SOATAG_USER_SDP_STR(a_call->sdp),
TAG_END());
run_ab_until(ctx, -1, until_ready, -1, accept_pracked);
run_ab_until(ctx, -1, until_ready, -1, accept_pracked2);
/* Client transitions:
INIT -(C1)-> CALLING: nua_invite(), nua_i_state
......@@ -168,6 +204,10 @@ int test_180rel(struct context *ctx)
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_content_type);
TEST_S(sip->sip_content_type->c_type, "application/sdp");
TEST_1(sip->sip_payload);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_ready); /* READY */
......
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