Commit 5c9981ee authored by Pekka Pessi's avatar Pekka Pessi

Added NUTAG_REFER_EXPIRES() with default value of 300.

Handling expiration of implicit subscriptions created by REFER.

darcs-hash:20051130121836-65a35-eede264f963d51980490ff5cad2ea8aeb5ef2863.gz
parent 17e10d99
......@@ -282,6 +282,8 @@ int ua_init(su_root_t *root, nua_t *nua)
DNHP_SET(dnhp, service_route_enable, 1);
DNHP_SET(dnhp, path_enable, 1);
DNHP_SET(dnhp, refer_expires, 300);
DNHP_SET(dnhp, substate, nua_substate_active);
DNHP_SET(dnhp, allow, sip_allow_make(dnh->nh_home, nua_allow_str));
......@@ -6077,13 +6079,82 @@ ua_notify(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags)
SIP_METHOD_NOTIFY,
NUTAG_ADD_CONTACT(1),
TAG_NEXT(tags));
sip = sip_object(msg);
if (sip) {
du = dialog_usage_get(nh->nh_ds, nua_notifier_usage, sip->sip_event);
if (du && du->du_event && !sip->sip_event)
sip_add_dup(msg, sip, (sip_header_t *)du->du_event);
if (!du)
;
else if (sip->sip_subscription_state) {
char const *ss_substate = sip->sip_subscription_state->ss_substate;
if (strcasecmp(ss_substate, "terminated") == 0)
du->du_notifier->de_substate = nua_substate_terminated;
else if (strcasecmp(ss_substate, "pending") == 0)
du->du_subscriber->de_substate = nua_substate_pending;
else /* if (strcasecmp(subs->ss_substate, "active") == 0) */
du->du_subscriber->de_substate = nua_substate_active;
if (sip->sip_subscription_state->ss_expires) {
unsigned long expires;
expires = strtoul(sip->sip_subscription_state->ss_expires, NULL, 10);
if (expires > 3600)
expires = 3600;
du->du_common->cu_refresh = sip_now() + expires;
}
}
else {
sip_subscription_state_t *ss;
char const *substate;
sip_time_t now = sip_now();
unsigned long expires = 3600;
if (du->du_notifier->de_substate == nua_substate_embryonic)
du->du_notifier->de_substate = nua_substate_pending;
switch (du->du_notifier->de_substate) {
case nua_substate_embryonic:
du->du_notifier->de_substate = nua_substate_pending;
/*FALLTHROUGH*/
case nua_substate_pending:
substate = "pending";
break;
case nua_substate_active:
default:
substate = "active";
break;
case nua_substate_terminated:
substate = "terminated";
break;
}
if (du->du_common->cu_refresh <= now)
du->du_notifier->de_substate = nua_substate_terminated;
if (du->du_notifier->de_substate != nua_substate_terminated) {
if (du->du_common->cu_refresh)
expires = du->du_common->cu_refresh - now;
else
du->du_common->cu_refresh = now + expires;
ss = sip_subscription_state_format(msg_home(msg), "%s;expires=%lu",
substate, expires);
}
else {
du->du_common->cu_refresh = now;
ss = sip_subscription_state_make(msg_home(msg), "terminated; "
"reason=noresource");
}
msg_header_insert(msg, (void *)sip, (void *)ss);
}
if (du && du->du_notifier->de_substate == nua_substate_terminated)
du->du_terminating = 1;
}
if (du)
cr->cr_orq = nta_outgoing_mcreate(nua->nua_nta,
process_response_to_notify, nh, NULL,
......@@ -6355,6 +6426,7 @@ static int process_response_to_refer(nua_handle_t *nh,
}
/*--------------------------------------------------*/
int process_refer(nua_t *nua,
nua_handle_t *nh,
nta_incoming_t *irq,
......@@ -6386,6 +6458,7 @@ int process_refer(nua_t *nua,
}
du->du_ready = 1;
dialog_uas_route(nh, sip, 1); /* Set route and tags */
if (!sip->sip_referred_by) {
......@@ -6406,11 +6479,12 @@ int process_refer(nua_t *nua,
nta_incoming_mreply(irq, response);
du->du_common->cu_refresh = sip_now() + NH_PGET(nh, refer_expires);
/* Immediate notify */
stack_signal(nh,
nua_r_notify,
SIPTAG_EVENT(event),
SIPTAG_SUBSCRIPTION_STATE_STR("pending"),
SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
SIPTAG_PAYLOAD_STR("SIP/2.0 100 Trying\r\n"),
TAG_END());
......
......@@ -326,6 +326,9 @@ typedef struct nua_handle_preferences
unsigned:0;
/* Default lifetime for implicit subscriptions created by REFER */
unsigned nhp_refer_expires;
/* Subscriber state, i.e. nua_substate_pending */
unsigned nhp_substate;
......@@ -358,6 +361,7 @@ typedef struct nua_handle_preferences
unsigned nhp_media_features:1;
unsigned nhp_service_route_enable:1;
unsigned nhp_path_enable:1;
unsigned nhp_refer_expires:1;
unsigned nhp_substate:1;
unsigned nhp_allow:1;
unsigned nhp_supported:1;
......
......@@ -69,6 +69,7 @@ tag_typedef_t nutag_session_timer = INTTAG_TYPEDEF(session_timer);
tag_typedef_t nutag_min_se = INTTAG_TYPEDEF(min_se);
tag_typedef_t nutag_session_refresher = INTTAG_TYPEDEF(session_refresher);
tag_typedef_t nutag_update_refresh = BOOLTAG_TYPEDEF(update_refresh);
tag_typedef_t nutag_refer_expires = UINTTAG_TYPEDEF(refer_expires);
tag_typedef_t nutag_autoAlert = BOOLTAG_TYPEDEF(autoAlert);
tag_typedef_t nutag_autoAnswer = BOOLTAG_TYPEDEF(autoAnswer);
tag_typedef_t nutag_autoACK = BOOLTAG_TYPEDEF(autoACK);
......@@ -76,6 +77,7 @@ tag_typedef_t nutag_enableInvite = BOOLTAG_TYPEDEF(enableInvite);
tag_typedef_t nutag_enableMessage = BOOLTAG_TYPEDEF(enableMessage);
tag_typedef_t nutag_enableMessenger = BOOLTAG_TYPEDEF(enableMessenger);
/* Start NRC Boston */
tag_typedef_t nutag_smime_enable = BOOLTAG_TYPEDEF(smime_enable);
tag_typedef_t nutag_smime_opt = INTTAG_TYPEDEF(smime_opt);
......
......@@ -1100,6 +1100,32 @@ enum nua_substate {
nua_substate_terminated = nea_terminated
};
/**Default lifetime for implicit subscriptions created by REFER.
*
* Default expiration time in seconds for implicit subscriptions created by
* REFER.
*
* @par Used with
* nua_set_params() \n
* nua_get_params() \n
* nua_set_hparams() \n
* nua_get_hparams() \n
*
* @par Parameter type
* unsigned int
*
* @par Values
* @c 0 disable \n
* @c >0 interval in seconds
*
* Corresponding tag taking reference parameter is NUTAG_REFER_EXPIRES()
*/
#define NUTAG_REFER_EXPIRES(x) nutag_refer_expires, tag_uint_v((x))
extern tag_typedef_t nutag_refer_expires;
#define NUTAG_REFER_EXPIRES_REF(x) nutag_refer_expires_ref, tag_uint_vr((&(x)))
extern tag_typedef_t nutag_refer_expires_ref;
/** Add media tags from our offer to Accept-Contact headers.
*
* Automatically generate Accept-Contact headers for caller
......
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