Commit 0a51fd08 authored by Pekka Pessi's avatar Pekka Pessi

test_proxy.[hc], test_100rel.c: fixed session timer negotiation by proxy (add...

test_proxy.[hc], test_100rel.c: fixed session timer negotiation by proxy (add "Require: timer" when needed)

darcs-hash:20070410201140-65a35-d24ea772ce850dc265d6ade7ec4f3af96d798767.gz
parent 8bbc5838
......@@ -1197,14 +1197,14 @@ int test_preconditions2(struct context *ctx)
nua_set_params(ctx->a.nua,
NUTAG_EARLY_MEDIA(1),
SIPTAG_SUPPORTED_STR("100rel, precondition"),
SIPTAG_SUPPORTED_STR("100rel, precondition, timer"),
TAG_END());
run_a_until(ctx, nua_r_set_params, until_final_response);
nua_set_params(ctx->b.nua,
NUTAG_EARLY_MEDIA(1),
NUTAG_ONLY183_100REL(1),
SIPTAG_SUPPORTED_STR("100rel, precondition"),
SIPTAG_SUPPORTED_STR("100rel, precondition, timer"),
TAG_END());
run_b_until(ctx, nua_r_set_params, until_final_response);
......
......@@ -375,6 +375,27 @@ void test_proxy_get_expiration(struct proxy *p,
}
}
void test_proxy_set_session_timer(struct proxy *p,
sip_time_t session_expires,
sip_time_t min_se)
{
if (p) {
p->prefs.session_expires = session_expires;
p->prefs.min_se = min_se;
}
}
void test_proxy_get_session_timer(struct proxy *p,
sip_time_t *return_session_expires,
sip_time_t *return_min_se)
{
if (p) {
if (return_session_expires)
*return_session_expires = p->prefs.session_expires;
if (return_min_se) *return_min_se = p->prefs.min_se;
}
}
/* ---------------------------------------------------------------------- */
static sip_contact_t *create_transport_contacts(struct proxy *p)
......@@ -427,6 +448,7 @@ int proxy_request(struct proxy *proxy,
sip_session_expires_t *x = NULL, x0[1];
sip_min_se_t *min_se = NULL, min_se0[1];
char const *require = NULL;
mf = sip->sip_max_forwards;
......@@ -447,24 +469,33 @@ int proxy_request(struct proxy *proxy,
}
if (method == sip_method_invite) {
if (!sip->sip_min_se ||
sip->sip_min_se->min_delta < proxy->prefs.min_se) {
min_se = sip_min_se_init(min_se0);
min_se->min_delta = proxy->prefs.min_se;
}
if (proxy->prefs.min_se) {
if (!sip->sip_min_se ||
sip->sip_min_se->min_delta < proxy->prefs.min_se) {
min_se = sip_min_se_init(min_se0);
min_se->min_delta = proxy->prefs.min_se;
}
if (!sip->sip_session_expires) {
x = sip_session_expires_init(x0);
x->x_delta = proxy->prefs.session_expires;
if (sip->sip_session_expires
&& sip->sip_session_expires->x_delta < proxy->prefs.min_se
&& sip_has_supported(sip->sip_supported, "timer")) {
if (min_se == NULL)
min_se = sip->sip_min_se; assert(min_se);
nta_incoming_treply(irq, SIP_422_SESSION_TIMER_TOO_SMALL,
SIPTAG_MIN_SE(min_se),
TAG_END());
return 422;
}
}
else if (sip->sip_session_expires->x_delta < proxy->prefs.min_se
&& sip_has_supported(sip->sip_supported, "timer")) {
if (min_se == NULL)
min_se = sip->sip_min_se; assert(min_se);
nta_incoming_treply(irq, SIP_422_SESSION_TIMER_TOO_SMALL,
SIPTAG_MIN_SE(min_se),
TAG_END());
return 422;
if (proxy->prefs.session_expires) {
if (!sip->sip_session_expires ||
sip->sip_session_expires->x_delta > proxy->prefs.session_expires) {
x = sip_session_expires_init(x0);
x->x_delta = proxy->prefs.session_expires;
if (!sip_has_supported(sip->sip_supported, "timer"))
require = "timer";
}
}
}
......@@ -528,6 +559,7 @@ int proxy_request(struct proxy *proxy,
SIPTAG_REQUEST(rq),
SIPTAG_SESSION_EXPIRES(x),
SIPTAG_MIN_SE(min_se),
SIPTAG_REQUIRE_STR(require),
TAG_END());
if (t->client == NULL) {
proxy_transaction_destroy(t);
......
......@@ -48,6 +48,14 @@ void test_proxy_get_expiration(struct proxy *,
sip_time_t *return_expires,
sip_time_t *return_max_expires);
void test_proxy_set_session_timer(struct proxy *p,
sip_time_t session_expires,
sip_time_t min_se);
void test_proxy_get_session_timer(struct proxy *p,
sip_time_t *return_session_expires,
sip_time_t *return_min_se);
SOFIA_END_DECLS
#endif
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