undo svn r 7762

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7809 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2008-03-07 17:34:46 +00:00
parent af26fa721b
commit 96b5099a80
17 changed files with 600 additions and 389 deletions

View File

@ -51,9 +51,10 @@ libtestnua_la_SOURCES = test_nua.h test_ops.c \
test_call_reject.c test_cancel_bye.c \ test_call_reject.c test_cancel_bye.c \
test_call_hold.c test_session_timer.c \ test_call_hold.c test_session_timer.c \
test_refer.c test_100rel.c \ test_refer.c test_100rel.c \
test_simple.c test_sip_events.c \ test_sip_events.c test_simple.c \
test_extension.c test_extension.c
libtestproxy_la_SOURCES = test_proxy.h test_proxy.c libtestproxy_la_SOURCES = test_proxy.h test_proxy.c
libtestnat_la_SOURCES = test_nat.h test_nat.c test_nat_tags.c libtestnat_la_SOURCES = test_nat.h test_nat.c test_nat_tags.c

View File

@ -373,8 +373,12 @@ void nua_dialog_usage_remove_at(nua_owner_t *own,
/* Destroy saved client request */ /* Destroy saved client request */
if (nua_client_is_bound(du->du_cr)) { if (nua_client_is_bound(du->du_cr)) {
nua_client_bind(cr = du->du_cr, NULL); nua_client_bind(cr = du->du_cr, NULL);
if (!nua_client_is_queued(cr) &&
!nua_client_is_reporting(cr)) if (nua_client_is_queued(cr))
nua_client_request_complete(cr);
else if (nua_client_is_reporting(cr))
;
else
nua_client_request_destroy(cr); nua_client_request_destroy(cr);
} }

View File

@ -253,11 +253,11 @@ typedef struct {
nta_outgoing_t *orq, nta_outgoing_t *orq,
tagi_t const *tags); tagi_t const *tags);
/** @a crm_deinit is called when a client-side request is destroyed. /** @a crm_complete is called when a client-side request is destroyed.
* *
* @return The return value should be 0. It is currently ignored. * @return The return value should be 0. It is currently ignored.
*/ */
int (*crm_deinit)(nua_client_request_t *); int (*crm_complete)(nua_client_request_t *);
} nua_client_methods_t; } nua_client_methods_t;
@ -516,6 +516,8 @@ void *nua_private_client_request(nua_client_request_t const *cr)
return (void *)(cr + 1); return (void *)(cr + 1);
} }
void nua_client_request_complete(nua_client_request_t *);
void nua_client_request_destroy(nua_client_request_t *); void nua_client_request_destroy(nua_client_request_t *);
int nua_client_request_queue(nua_client_request_t *cr); int nua_client_request_queue(nua_client_request_t *cr);

View File

@ -74,18 +74,21 @@
*/ */
static nua_client_methods_t const nua_method_client_methods = { static nua_client_methods_t const nua_method_client_methods = {
SIP_METHOD_UNKNOWN, SIP_METHOD_UNKNOWN, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 0, /* create_dialog */ 0,
/* in_dialog */ 0, /* in_dialog */ 0,
/* target_refresh */ 1, /* target_refresh */ 1,
}, },
/* nua_method_client_template */ NULL, NULL, /* crm_template */
/* nua_method_client_init */ NULL, NULL, /* crm_init */
/* nua_method_client_request */ NULL, NULL, /* crm_send */
/* nua_method_client_check_restart */ NULL, NULL, /* crm_check_restart */
/* nua_method_client_response */ NULL NULL, /* crm_recv */
NULL, /* crm_preliminary */
NULL, /* crm_report */
NULL, /* crm_complete */
}; };
int int

View File

@ -77,18 +77,22 @@ static int nua_message_client_init(nua_client_request_t *cr,
tagi_t const *tags); tagi_t const *tags);
static nua_client_methods_t const nua_message_client_methods = { static nua_client_methods_t const nua_message_client_methods = {
SIP_METHOD_MESSAGE, SIP_METHOD_MESSAGE, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 0, /* create_dialog */ 0,
/* in_dialog */ 0, /* in_dialog */ 0,
/* target refresh */ 0 /* target refresh */ 0
}, },
/* nua_message_client_template */ NULL, NULL, /* crm_template */
nua_message_client_init, nua_message_client_init, /* crm_init */
/*nua_message_client_request*/ NULL, NULL, /* crm_send */
/* nua_message_client_check_restart */ NULL, NULL, /* crm_check_restart */
/*nua_message_client_response*/ NULL NULL, /* crm_recv */
NULL, /* crm_preliminary */
NULL, /* crm_report */
NULL, /* crm_complete */
}; };
int int

View File

@ -237,7 +237,8 @@ int nua_subscribe_server_preprocess(nua_server_request_t *sr)
sip_event_t *o = sip->sip_event; sip_event_t *o = sip->sip_event;
char const *event = o ? o->o_type : NULL; char const *event = o ? o->o_type : NULL;
/* Maximum expiration time */ /* Maximum expiration time */
unsigned long expires = 3600; unsigned long expires = sip->sip_expires ? sip->sip_expires->ex_delta : 3600;
sip_time_t now = sip_now();
assert(nh && nh->nh_nua->nua_dhandle != nh); assert(nh && nh->nh_nua->nua_dhandle != nh);
@ -259,9 +260,10 @@ int nua_subscribe_server_preprocess(nua_server_request_t *sr)
nu = nua_dialog_usage_private(du); nu = nua_dialog_usage_private(du);
if (sip->sip_expires && sip->sip_expires->ex_delta < expires) if (now + expires >= now)
expires = sip->sip_expires->ex_delta; nu->nu_requested = now + expires;
nu->nu_requested = sip_now() + expires; else
nu->nu_requested = SIP_TIME_MAX - 1;
#if SU_HAVE_EXPERIMENTAL #if SU_HAVE_EXPERIMENTAL
nu->nu_etags = nu->nu_etags =
@ -295,9 +297,23 @@ int nua_subscribe_server_respond(nua_server_request_t *sr, tagi_t const *tags)
sip_time_t now = sip_now(); sip_time_t now = sip_now();
if (nu->nu_requested) { if (nu->nu_requested) {
if (nu->nu_requested > nu->nu_expires) if (sip->sip_expires) {
/* Expires in response can only shorten the expiration time */
if (nu->nu_requested > now + sip->sip_expires->ex_delta)
nu->nu_requested = now + sip->sip_expires->ex_delta;
}
else {
unsigned sub_expires = NH_PGET(sr->sr_owner, sub_expires);
if (nu->nu_requested > now + sub_expires)
nu->nu_requested = now + sub_expires;
}
if (nu->nu_requested >= now)
nu->nu_expires = nu->nu_requested; nu->nu_expires = nu->nu_requested;
else if (nu->nu_expires <= now || nu->nu_requested <= now) else
nu->nu_expires = now;
if (nu->nu_expires <= now)
nu->nu_substate = nua_substate_terminated; nu->nu_substate = nua_substate_terminated;
} }
@ -305,7 +321,7 @@ int nua_subscribe_server_respond(nua_server_request_t *sr, tagi_t const *tags)
ex->ex_delta = nu->nu_expires - now; ex->ex_delta = nu->nu_expires - now;
} }
else { else {
/* Add header Expires: 0 */ /* Always add header Expires: 0 */
} }
if (!sip->sip_expires || sip->sip_expires->ex_delta > ex->ex_delta) if (!sip->sip_expires || sip->sip_expires->ex_delta > ex->ex_delta)
@ -420,20 +436,21 @@ static int nua_notify_client_report(nua_client_request_t *cr,
tagi_t const *tags); tagi_t const *tags);
static nua_client_methods_t const nua_notify_client_methods = { static nua_client_methods_t const nua_notify_client_methods = {
SIP_METHOD_NOTIFY, SIP_METHOD_NOTIFY, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 1, /* create_dialog */ 1,
/* in_dialog */ 1, /* in_dialog */ 1,
/* target refresh */ 1 /* target refresh */ 1
}, },
/* nua_notify_client_template */ NULL, NULL, /* crm_template */
nua_notify_client_init, nua_notify_client_init, /* crm_init */
nua_notify_client_request, nua_notify_client_request, /* crm_send */
/* nua_notify_client_check_restart */ NULL, NULL, /* crm_check_restart */
/* nua_notify_client_response */ NULL, NULL, /* crm_recv */
/* nua_notify_client_preliminary */ NULL, NULL, /* crm_preliminary */
nua_notify_client_report nua_notify_client_report, /* crm_report */
NULL, /* crm_complete */
}; };
/**@internal Send NOTIFY. */ /**@internal Send NOTIFY. */

View File

@ -88,18 +88,21 @@
*/ */
static nua_client_methods_t const nua_options_client_methods = { static nua_client_methods_t const nua_options_client_methods = {
SIP_METHOD_OPTIONS, SIP_METHOD_OPTIONS, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 0, /* create_dialog */ 0,
/* in_dialog */ 0, /* in_dialog */ 0,
/* target refresh */ 0 /* target refresh */ 0
}, },
/*nua_options_client_template*/ NULL, NULL, /* crm_template */
/*nua_options_client_init*/ NULL, NULL, /* crm_init */
/*nua_options_client_request*/ NULL, NULL, /* crm_send */
/* nua_options_client_check_restart */ NULL, NULL, /* crm_check_restart */
/*nua_options_client_response*/ NULL NULL, /* crm_recv */
NULL, /* crm_preliminary */
NULL, /* crm_report */
NULL, /* crm_complete */
}; };
int nua_stack_options(nua_t *nua, int nua_stack_options(nua_t *nua,

View File

@ -77,19 +77,27 @@ su_inline int nhp_is_any_set(nua_handle_preferences_t const *nhp)
su_inline void nhp_or_set(nua_handle_preferences_t *a, su_inline void nhp_or_set(nua_handle_preferences_t *a,
nua_handle_preferences_t const *b) nua_handle_preferences_t const *b)
{ {
unsigned *ap = a->nhp_set_.set_unsigned;
unsigned const *bp = b->nhp_set_.set_unsigned;
size_t i;
memcpy(a, b, offsetof(nua_handle_preferences_t, nhp_set)); memcpy(a, b, offsetof(nua_handle_preferences_t, nhp_set));
/* Bitwise or of bitfields, casted to unsigned */
a->nhp_set_.set_unsigned[0] |= b->nhp_set_.set_unsigned[0];
a->nhp_set_.set_unsigned[1] |= b->nhp_set_.set_unsigned[1];
/*
unsigned *ap, const *bp;
size_t i;
ap = a->nhp_set_.set_unsigned;
bp = b->nhp_set_.set_unsigned;
for (i = 0; i < (sizeof a->nhp_set); i += (sizeof *ap)) for (i = 0; i < (sizeof a->nhp_set); i += (sizeof *ap))
*ap++ |= *bp++; *ap++ |= *bp++;
*/
} }
static int nhp_set_tags(su_home_t *home, static int nhp_set_tags(su_home_t *home,
nua_handle_preferences_t *nhp, nua_handle_preferences_t *nhp,
int global, nua_global_preferences_t *ngp,
tagi_t const *tags); tagi_t const *tags);
static int nhp_merge_lists(su_home_t *home, static int nhp_merge_lists(su_home_t *home,
@ -101,11 +109,11 @@ static int nhp_merge_lists(su_home_t *home,
int always_merge, int always_merge,
tag_value_t value); tag_value_t value);
static static int nhp_save_params(nua_handle_t *nh,
nua_handle_preferences_t *nhp_move_params(su_home_t *home,
nua_handle_preferences_t *dst,
su_home_t *tmphome, su_home_t *tmphome,
nua_handle_preferences_t const *src); nua_global_preferences_t *gsrc,
nua_handle_preferences_t *src);
/* ====================================================================== */ /* ====================================================================== */
/* Magical NUTAG_USER_AGENT() - add NHP_USER_AGENT there if it is not there */ /* Magical NUTAG_USER_AGENT() - add NHP_USER_AGENT there if it is not there */
@ -169,6 +177,7 @@ int nua_stack_set_defaults(nua_handle_t *nh,
NHP_SET(nhp, refer_with_id, 1); NHP_SET(nhp, refer_with_id, 1);
NHP_SET(nhp, substate, nua_substate_active); NHP_SET(nhp, substate, nua_substate_active);
NHP_SET(nhp, sub_expires, 3600);
NHP_SET(nhp, allow, sip_allow_make(home, nua_allow_str)); NHP_SET(nhp, allow, sip_allow_make(home, nua_allow_str));
NHP_SET(nhp, supported, sip_supported_make(home, "timer, 100rel")); NHP_SET(nhp, supported, sip_supported_make(home, "timer, 100rel"));
@ -198,20 +207,12 @@ int nua_stack_set_from(nua_t *nua, int initial, tagi_t const *tags)
sip_from_t *f = NULL, f0[1]; sip_from_t *f = NULL, f0[1];
int set; int set;
char const *uicc_name = "default";
tl_gets(tags, tl_gets(tags,
/* By nua_stack_set_from() */ /* By nua_stack_set_from() */
SIPTAG_FROM_REF(from), SIPTAG_FROM_REF(from),
SIPTAG_FROM_STR_REF(str), SIPTAG_FROM_STR_REF(str),
NUTAG_UICC_REF(uicc_name),
TAG_END()); TAG_END());
#if HAVE_UICC_H
if (initial && uicc_name)
nua->nua_uicc = uicc_create(root, uicc_name);
#endif
if (!initial && from == NONE && str == NONE) if (!initial && from == NONE && str == NONE)
return 0; return 0;
@ -325,6 +326,7 @@ int nua_stack_init_instance(nua_handle_t *nh, tagi_t const *tags)
* NUTAG_SMIME_SIGNATURE() \n * NUTAG_SMIME_SIGNATURE() \n
* NUTAG_SOA_NAME() \n * NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n * NUTAG_SUBSTATE() \n
* NUTAG_SUB_EXPIRES() \n
* NUTAG_SUPPORTED(), SIPTAG_SUPPORTED(), and SIPTAG_SUPPORTED_STR() \n * NUTAG_SUPPORTED(), SIPTAG_SUPPORTED(), and SIPTAG_SUPPORTED_STR() \n
* NUTAG_UPDATE_REFRESH() \n * NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT(), SIPTAG_USER_AGENT() and SIPTAG_USER_AGENT_STR() \n * NUTAG_USER_AGENT(), SIPTAG_USER_AGENT() and SIPTAG_USER_AGENT_STR() \n
@ -437,6 +439,7 @@ int nua_stack_init_instance(nua_handle_t *nh, tagi_t const *tags)
* NUTAG_SESSION_TIMER() \n * NUTAG_SESSION_TIMER() \n
* NUTAG_SOA_NAME() \n * NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n * NUTAG_SUBSTATE() \n
* NUTAG_SUB_EXPIRES() \n
* NUTAG_SUPPORTED(), SIPTAG_SUPPORTED(), and SIPTAG_SUPPORTED_STR() \n * NUTAG_SUPPORTED(), SIPTAG_SUPPORTED(), and SIPTAG_SUPPORTED_STR() \n
* NUTAG_UPDATE_REFRESH() \n * NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT(), SIPTAG_USER_AGENT() and SIPTAG_USER_AGENT_STR() \n * NUTAG_USER_AGENT(), SIPTAG_USER_AGENT() and SIPTAG_USER_AGENT_STR() \n
@ -475,81 +478,62 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
tagi_t const *tags) tagi_t const *tags)
{ {
nua_handle_t *dnh = nua->nua_dhandle; nua_handle_t *dnh = nua->nua_dhandle;
nua_handle_preferences_t tmp[1], *nhp = nh->nh_prefs;
nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
su_home_t tmphome[1] = { SU_HOME_INIT(tmphome) }; int status;
char const *phrase;
tagi_t const *ptags;
int error, global;
int status = 900;
char const *phrase = "Error storing parameters";
sip_supported_t const *supported = NULL;
sip_allow_t const *allow = NULL;
sip_allow_events_t const *allow_events = NULL;
sip_allow_t const *appl_method = NULL;
enter; enter;
ptags = !nh->nh_used_ptags ? nh->nh_ptags : NULL; {
su_home_t tmphome[1] = { SU_HOME_INIT(tmphome) };
nua_handle_preferences_t *nhp = nh->nh_prefs;
nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
nua_handle_preferences_t tmp[1];
nua_global_preferences_t gtmp[1], *ngp = NULL;
*tmp = *nhp; NHP_UNSET_ALL(tmp); *tmp = *nhp; NHP_UNSET_ALL(tmp);
/* Supported features, allowed methods and events are merged /*
with previous ones */ * Supported features, allowed methods and events are merged
* with previous or default settings.
*
* Here we just copy pointers from default settings. However when saving
* settings we have to be extra careful so that we
* 1) zero the pointers if the setting has not been modified
* 2) do not free pointer if the setting has been modified
* See NHP_ZAP_OVERRIDEN() below for gorier details.
*/
if (!NHP_ISSET(nhp, supported)) if (!NHP_ISSET(nhp, supported))
supported = tmp->nhp_supported = dnhp->nhp_supported; tmp->nhp_supported = dnhp->nhp_supported;
if (!NHP_ISSET(nhp, allow)) if (!NHP_ISSET(nhp, allow))
allow = tmp->nhp_allow = dnhp->nhp_allow; tmp->nhp_allow = dnhp->nhp_allow;
if (!NHP_ISSET(nhp, allow_events)) if (!NHP_ISSET(nhp, allow_events))
allow_events = tmp->nhp_allow_events = dnhp->nhp_allow_events; tmp->nhp_allow_events = dnhp->nhp_allow_events;
if (!NHP_ISSET(nhp, appl_method)) if (!NHP_ISSET(nhp, appl_method))
appl_method = tmp->nhp_appl_method = dnhp->nhp_appl_method; tmp->nhp_appl_method = dnhp->nhp_appl_method;
error = 0; if (nh == dnh) /* nua_set_params() call, save stack-wide params, too */
global = nh == dnh; /* save also stack-specific params */ ngp = gtmp, *gtmp = *nua->nua_prefs;
/* Set and save parameters to tmp */ /* Set and save parameters to tmp */
if (nhp_set_tags(tmphome, tmp, global, ptags) < 0) if (!nh->nh_used_ptags &&
error = 1, phrase = "Error storing default handle parameters"; nhp_set_tags(tmphome, tmp, NULL, nh->nh_ptags) < 0)
else if (nhp_set_tags(tmphome, tmp, global, tags) < 0) status = 900, phrase = "Error storing default handle parameters";
error = 1, phrase = "Error storing parameters"; else if (nhp_set_tags(tmphome, tmp, ngp, tags) < 0)
else { status = 900, phrase = "Error storing parameters";
if (NHP_IS_ANY_SET(tmp)) { else if (nhp_save_params(nh, tmphome, ngp, tmp) < 0)
if (tmp->nhp_supported == supported) status = 900, phrase = su_strerror(ENOMEM);
tmp->nhp_supported = NULL;
if (tmp->nhp_allow == allow)
tmp->nhp_allow = NULL;
if (tmp->nhp_allow_events == allow_events)
tmp->nhp_allow_events = NULL;
if (tmp->nhp_appl_method == appl_method)
tmp->nhp_appl_method = NULL;
/* Move parameters from tmp to nhp (or allocate new nhp) */
if (nh != dnh && nhp == dnh->nh_prefs)
nhp = NULL;
nhp = nhp_move_params(nh->nh_home, nhp, tmphome, tmp);
if (nhp)
nh->nh_prefs = nhp;
else else
/* Fail miserably with ENOMEM */ status = 200, phrase = "OK", nh->nh_used_ptags = 1;
error = 1, status = 900, phrase = su_strerror(ENOMEM);
}
if (!error)
nh->nh_used_ptags = 1;
}
su_home_deinit(tmphome); su_home_deinit(tmphome);
}
if (error) if (status == 200) {
; nua_handle_preferences_t const *nhp = nh->nh_prefs;
else if (!nh->nh_soa && NHP_GET(nhp, dnhp, media_enable)) { nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
if (!nh->nh_soa && NHP_GET(nhp, dnhp, media_enable)) {
/* Create soa when needed */ /* Create soa when needed */
char const *soa_name = NHP_GET(nhp, dnhp, soa_name); char const *soa_name = NHP_GET(nhp, dnhp, soa_name);
@ -558,63 +542,60 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
else else
nh->nh_soa = soa_create(soa_name, nua->nua_root, nh); nh->nh_soa = soa_create(soa_name, nua->nua_root, nh);
ptags = nh->nh_ptags;
if (!nh->nh_soa) if (!nh->nh_soa)
error = 1, status = 900, phrase = "Error Creating SOA Object"; status = 900, phrase = "Error Creating SOA Object";
else if (soa_set_params(nh->nh_soa, TAG_NEXT(nh->nh_ptags)) < 0)
status = 900, phrase = "Error Setting SOA Parameters";
} }
else if (nh->nh_soa && !NHP_GET(nhp, dnhp, media_enable)) { else if (nh->nh_soa && !NHP_GET(nhp, dnhp, media_enable)) {
/* ... destroy soa when not needed */ /* ... destroy soa when not needed */
soa_destroy(nh->nh_soa), nh->nh_soa = NULL; soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
} }
if (!error && nh->nh_soa) { if (status == 200 && tags && nh->nh_soa &&
if ((ptags && soa_set_params(nh->nh_soa, TAG_NEXT(ptags)) < 0) || soa_set_params(nh->nh_soa, TAG_NEXT(tags)) < 0)
(tags && soa_set_params(nh->nh_soa, TAG_NEXT(tags)) < 0)) status = 900, phrase = "Error Setting SOA Parameters";
error = 1, status = 900, phrase = "Error Setting SOA Parameters";
} }
if (error || nh != dnh) { if (status == 200 && nh == dnh) {
;
}
else if (nua_stack_set_smime_params(nua, tags) < 0) {
error = 1, status = 900, phrase = "Error setting S/MIME parameters";
}
else if (!nua->nua_nta) {
}
/* Set stack-specific things below */ /* Set stack-specific things below */
else if (nta_agent_set_params(nua->nua_nta, TAG_NEXT(tags)) < 0) { if (nua_stack_set_smime_params(nua, tags) < 0) {
status = 900, phrase = "Error setting S/MIME parameters";
}
else if (nua->nua_nta && nta_agent_set_params(nua->nua_nta, TAG_NEXT(tags)) < 0) {
status = 900, phrase = "Error setting NTA parameters"; status = 900, phrase = "Error setting NTA parameters";
error = 1;
} }
else { else {
nua_stack_set_from(nua, 0, tags); nua_stack_set_from(nua, 0, tags);
if (NHP_ISSET(nhp, detect_network_updates))
if (nua->nua_prefs->ngp_detect_network_updates)
nua_stack_launch_network_change_detector(nua); nua_stack_launch_network_change_detector(nua);
} }
}
if (error) { if (status != 200) {
if (e == nua_i_none) if (e == nua_i_none)
SU_DEBUG_1(("nua_set_params(): failed: %s\n", phrase)); SU_DEBUG_1(("nua_set_params(): failed: %s\n", phrase));
return UA_EVENT2(e, status, phrase), -1; return UA_EVENT2(e, status, phrase), -1;
} }
else {
if (e == nua_r_set_params) if (e == nua_r_set_params)
UA_EVENT2(e, 200, "OK"); UA_EVENT2(e, status, phrase);
return 0; return 0;
}
} }
/** Parse parameters from tags to @a nhp.
/** Parse parameters from tags to @a nhp or @a ngp.
* *
* @param home allocate new values from @a home * @param home allocate new values from @a home
* @param nhp structure to store handle preferences * @param nhp structure to store handle preferences
* @param global if true, save also global parameters * @param ngp structure to store global preferences
* @param tags list of tags to parse * @param tags list of tags to parse
*/ */
static int nhp_set_tags(su_home_t *home, static int nhp_set_tags(su_home_t *home,
nua_handle_preferences_t *nhp, nua_handle_preferences_t *nhp,
int global, nua_global_preferences_t *ngp,
tagi_t const *tags) tagi_t const *tags)
{ {
@ -826,6 +807,10 @@ static int nhp_set_tags(su_home_t *home,
else if (tag == nutag_substate) { else if (tag == nutag_substate) {
NHP_SET(nhp, substate, (int)value); NHP_SET(nhp, substate, (int)value);
} }
/* NUTAG_SUB_EXPIRES(sub_expires) */
else if (tag == nutag_sub_expires) {
NHP_SET(nhp, sub_expires, value);
}
/* NUTAG_KEEPALIVE(keepalive) */ /* NUTAG_KEEPALIVE(keepalive) */
else if (tag == nutag_keepalive) { else if (tag == nutag_keepalive) {
NHP_SET(nhp, keepalive, (unsigned)value); NHP_SET(nhp, keepalive, (unsigned)value);
@ -997,7 +982,7 @@ static int nhp_set_tags(su_home_t *home,
NHP_SET_STR(nhp, outbound, value); NHP_SET_STR(nhp, outbound, value);
} }
/* NUTAG_DETECT_NETWORK_UPDATES(detect_network_updates) */ /* NUTAG_DETECT_NETWORK_UPDATES(detect_network_updates) */
else if (global && tag == nutag_detect_network_updates) { else if (ngp && tag == nutag_detect_network_updates) {
int detector = (int)value; int detector = (int)value;
if (detector < NUA_NW_DETECT_NOTHING) if (detector < NUA_NW_DETECT_NOTHING)
@ -1005,7 +990,13 @@ static int nhp_set_tags(su_home_t *home,
else if (detector > NUA_NW_DETECT_TRY_FULL) else if (detector > NUA_NW_DETECT_TRY_FULL)
detector = NUA_NW_DETECT_TRY_FULL; detector = NUA_NW_DETECT_TRY_FULL;
NHP_SET(nhp, detect_network_updates, detector); ngp->ngp_detect_network_updates = detector;
ngp->ngp_set.ngp_detect_network_updates = 1;
}
/* NUTAG_SHUTDOWN_EVENTS() */
else if (ngp && tag == nutag_shutdown_events) {
ngp->ngp_shutdown_events = value != 0;
ngp->ngp_set.ngp_shutdown_events = 1;
} }
} }
@ -1078,54 +1069,70 @@ static int nhp_merge_lists(su_home_t *home,
return 1; return 1;
} }
/** Save parameters in @a gtmp and @a tmp.
*/
static static
nua_handle_preferences_t *nhp_move_params(su_home_t *home, int nhp_save_params(nua_handle_t *nh,
nua_handle_preferences_t *dst,
su_home_t *tmphome, su_home_t *tmphome,
nua_handle_preferences_t const *src) nua_global_preferences_t *gsrc,
nua_handle_preferences_t *src)
{ {
/* Update prefs structure */ su_home_t *home = nh->nh_home;
nua_handle_preferences_t tbf[1]; nua_t *nua = nh->nh_nua;
nua_handle_t *dnh = nua->nua_dhandle;
nua_handle_preferences_t *dst = nh->nh_prefs, old[1];
if (dst == NULL) if (gsrc) {
dst = su_zalloc(home, sizeof *dst); *nua->nua_prefs = *gsrc; /* No pointers this far */
if (dst == NULL) }
return NULL;
if (su_home_move(home, tmphome) < 0)
return NULL;
*tbf = *dst; if (!NHP_IS_ANY_SET(src))
return 0;
if (nh == dnh || nh->nh_prefs != dnh->nh_prefs) {
dst = nh->nh_prefs, *old = *dst;
assert(dst);
}
else {
dst = su_zalloc(home, sizeof *dst), memset(old, 0, sizeof *old);
if (!dst)
return -1;
}
/* Move allocations from tmphome to home */
su_home_move(nh->nh_home, tmphome);
/* Copy parameters that are set from src to dst */
nhp_or_set(dst, src); nhp_or_set(dst, src);
/* Handle pointer items. Free changed ones and zap unset ones. */ /* Handle pointer items. Free changed ones and zap unset ones. */
#define NHP_ZAP_OVERRIDEN(tbf, nhp, pref) \ /* Note that pointer items where !NHP_ISSET(old, pref) are not freed
(((tbf)->nhp_set.nhb_##pref \ (because they were just on loan from the default preference set) */
&& (tbf)->nhp_##pref != (nhp)->nhp_##pref \ #define NHP_ZAP_OVERRIDEN(old, dst, free, pref) \
? su_free(home, (void *)(tbf)->nhp_##pref) : (void)0), \ (((NHP_ISSET(old, pref) && \
(void)(!(nhp)->nhp_set.nhb_##pref ? (nhp)->nhp_##pref = NULL : NULL)) (old)->nhp_##pref && (old)->nhp_##pref != (dst)->nhp_##pref) \
? (free)(home, (void *)(old)->nhp_##pref) : (void)0), \
(void)(!(dst)->nhp_set.nhb_##pref ? (dst)->nhp_##pref = NULL : NULL))
NHP_ZAP_OVERRIDEN(tbf, dst, soa_name); NHP_ZAP_OVERRIDEN(old, dst, su_free, soa_name);
NHP_ZAP_OVERRIDEN(tbf, dst, registrar); NHP_ZAP_OVERRIDEN(old, dst, su_free, registrar);
NHP_ZAP_OVERRIDEN(tbf, dst, supported); NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, allow);
NHP_ZAP_OVERRIDEN(tbf, dst, allow); NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, supported);
NHP_ZAP_OVERRIDEN(tbf, dst, user_agent); NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, allow_events);
NHP_ZAP_OVERRIDEN(tbf, dst, organization); NHP_ZAP_OVERRIDEN(old, dst, su_free, user_agent);
NHP_ZAP_OVERRIDEN(tbf, dst, instance); NHP_ZAP_OVERRIDEN(old, dst, su_free, organization);
NHP_ZAP_OVERRIDEN(tbf, dst, m_display); NHP_ZAP_OVERRIDEN(old, dst, su_free, m_display);
NHP_ZAP_OVERRIDEN(tbf, dst, m_username); NHP_ZAP_OVERRIDEN(old, dst, su_free, m_username);
NHP_ZAP_OVERRIDEN(tbf, dst, m_params); NHP_ZAP_OVERRIDEN(old, dst, su_free, m_params);
NHP_ZAP_OVERRIDEN(tbf, dst, m_features); NHP_ZAP_OVERRIDEN(old, dst, su_free, m_features);
NHP_ZAP_OVERRIDEN(tbf, dst, outbound); NHP_ZAP_OVERRIDEN(old, dst, su_free, instance);
NHP_ZAP_OVERRIDEN(old, dst, su_free, outbound);
NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, appl_method);
NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, initial_route);
#define NHP_ZAP_OVERRIDEN_HDR(tbf, nhp, pref) \ nh->nh_prefs = dst;
(((tbf)->nhp_set.nhb_##pref \
&& (tbf)->nhp_##pref != (nhp)->nhp_##pref \
? msg_header_free(home, (void *)(tbf)->nhp_##pref) : (void)0), \
(void)(!(nhp)->nhp_set.nhb_##pref ? (nhp)->nhp_##pref = NULL : NULL))
NHP_ZAP_OVERRIDEN_HDR(tbf, dst, initial_route); return 0;
return dst;
} }
static int nua_handle_tags_filter(tagi_t const *f, tagi_t const *t); static int nua_handle_tags_filter(tagi_t const *f, tagi_t const *t);
@ -1475,6 +1482,7 @@ int nua_stack_set_smime_params(nua_t *nua, tagi_t const *tags)
* NUTAG_SMIME_SIGNATURE() \n * NUTAG_SMIME_SIGNATURE() \n
* NUTAG_SOA_NAME() \n * NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n * NUTAG_SUBSTATE() \n
* NUTAG_SUB_EXPIRES() \n
* NUTAG_UPDATE_REFRESH() \n * NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT() \n * NUTAG_USER_AGENT() \n
* SIPTAG_ALLOW() \n * SIPTAG_ALLOW() \n
@ -1515,6 +1523,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
tagi_t const *tags) tagi_t const *tags)
{ {
nua_handle_t *dnh = nua->nua_dhandle; nua_handle_t *dnh = nua->nua_dhandle;
nua_global_preferences_t const *ngp = nua->nua_prefs;
nua_handle_preferences_t const *nhp = nh->nh_prefs; nua_handle_preferences_t const *nhp = nh->nh_prefs;
tagi_t *lst; tagi_t *lst;
@ -1540,8 +1549,6 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
enter; enter;
su_home_auto(tmphome, sizeof(tmphome));
nta_agent_get_params(nua->nua_nta, nta_agent_get_params(nua->nua_nta,
NTATAG_UDP_MTU_REF(udp_mtu), NTATAG_UDP_MTU_REF(udp_mtu),
NTATAG_MAX_PROCEEDING_REF(max_proceeding), NTATAG_MAX_PROCEEDING_REF(max_proceeding),
@ -1590,6 +1597,8 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
? sip_##pref##_make(tmphome, (char *)nhp->nhp_##pref) \ ? sip_##pref##_make(tmphome, (char *)nhp->nhp_##pref) \
: NULL)) : NULL))
su_home_auto(tmphome, sizeof(tmphome));
lst = tl_filtered_tlist lst = tl_filtered_tlist
(tmphome, tags, (tmphome, tags,
TAG_IF(has_from, SIPTAG_FROM(from)), TAG_IF(has_from, SIPTAG_FROM(from)),
@ -1630,6 +1639,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
TIF(NUTAG_REFER_WITH_ID, refer_with_id), TIF(NUTAG_REFER_WITH_ID, refer_with_id),
TIF(NUTAG_SUBSTATE, substate), TIF(NUTAG_SUBSTATE, substate),
TIF(NUTAG_SUB_EXPIRES, sub_expires),
TIF(SIPTAG_SUPPORTED, supported), TIF(SIPTAG_SUPPORTED, supported),
TIF_STR(SIPTAG_SUPPORTED_STR, supported), TIF_STR(SIPTAG_SUPPORTED_STR, supported),
@ -1658,11 +1668,18 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
TIF(NUTAG_M_PARAMS, m_params), TIF(NUTAG_M_PARAMS, m_params),
TIF(NUTAG_M_FEATURES, m_features), TIF(NUTAG_M_FEATURES, m_features),
TIF(NUTAG_OUTBOUND, outbound), TIF(NUTAG_OUTBOUND, outbound),
TIF(NUTAG_DETECT_NETWORK_UPDATES, detect_network_updates),
/* Skip user-agent-level parameters if parameters are for handle only */ /* Skip user-agent-level parameters if parameters are for handle only */
TAG_IF(nh != dnh, TAG_NEXT(media_params)), TAG_IF(nh != dnh, TAG_NEXT(media_params)),
/* Include tag in the list returned to user
* if it has been earlier set (by user) */
#define GIF(TAG, pref) \
TAG_IF(ngp->ngp_set.ngp_##pref, TAG(ngp->ngp_##pref))
GIF(NUTAG_DETECT_NETWORK_UPDATES, detect_network_updates),
GIF(NUTAG_SHUTDOWN_EVENTS, shutdown_events),
NTATAG_CONTACT(m), NTATAG_CONTACT(m),
#if HAVE_SOFIA_SMIME #if HAVE_SOFIA_SMIME

View File

@ -107,6 +107,7 @@ typedef struct nua_handle_preferences
/* Subscriber state, i.e. nua_substate_pending */ /* Subscriber state, i.e. nua_substate_pending */
unsigned nhp_substate; unsigned nhp_substate;
unsigned nhp_sub_expires;
/* REGISTER keepalive intervals */ /* REGISTER keepalive intervals */
unsigned nhp_keepalive, nhp_keepalive_stream; unsigned nhp_keepalive, nhp_keepalive_stream;
@ -127,9 +128,6 @@ typedef struct nua_handle_preferences
/** Outbound OPTIONS */ /** Outbound OPTIONS */
char const *nhp_outbound; char const *nhp_outbound;
/** Network detection: NONE, INFORMAL, TRY_FULL */
int nhp_detect_network_updates;
sip_allow_t *nhp_appl_method; sip_allow_t *nhp_appl_method;
/** Initial route set */ /** Initial route set */
@ -137,6 +135,12 @@ typedef struct nua_handle_preferences
union { struct { union { struct {
/* A bit for each feature set by application */ /* A bit for each feature set by application */
/* NOTE:
Some compilers behave weird if there are bitfields
together with width > 32
So there should be a padding field (unsigned:0;)
every 32 bits.
*/
unsigned nhb_retry_count:1; unsigned nhb_retry_count:1;
unsigned nhb_max_subscriptions:1; unsigned nhb_max_subscriptions:1;
@ -166,13 +170,15 @@ typedef struct nua_handle_preferences
unsigned nhb_refer_with_id:1; unsigned nhb_refer_with_id:1;
unsigned nhb_refer_expires:1; unsigned nhb_refer_expires:1;
unsigned nhb_substate:1; unsigned nhb_substate:1;
unsigned nhb_sub_expires:1;
unsigned nhb_keepalive:1; unsigned nhb_keepalive:1;
unsigned nhb_keepalive_stream:1; unsigned nhb_keepalive_stream:1;
unsigned nhb_registrar:1; unsigned nhb_registrar:1;
unsigned nhb_allow:1; unsigned nhb_allow:1;
unsigned :0; /* at most 32 bits before this point */
unsigned nhb_supported:1; unsigned nhb_supported:1;
unsigned :0; /* at most 32 bits ... */
unsigned nhb_allow_events:1; unsigned nhb_allow_events:1;
unsigned nhb_user_agent:1; unsigned nhb_user_agent:1;
unsigned nhb_organization:1; unsigned nhb_organization:1;
@ -183,7 +189,6 @@ typedef struct nua_handle_preferences
unsigned nhb_m_features:1; unsigned nhb_m_features:1;
unsigned nhb_instance:1; unsigned nhb_instance:1;
unsigned nhb_outbound:1; unsigned nhb_outbound:1;
unsigned nhb_detect_network_updates:1;
unsigned nhb_appl_method:1; unsigned nhb_appl_method:1;
unsigned nhb_initial_route:1; unsigned nhb_initial_route:1;
unsigned :0; unsigned :0;
@ -194,6 +199,26 @@ typedef struct nua_handle_preferences
#define nhp_set nhp_set_.set_bits #define nhp_set nhp_set_.set_bits
/** Global preferences for nua. */
typedef struct {
/** Network detection: NONE, INFORMAL, TRY_FULL */
signed int ngp_detect_network_updates:3;
/** Pass events during shutdown, too */
int ngp_shutdown_events:1;
unsigned :0; /* pad */
union { struct {
/* A bit for each feature set by application */
unsigned ngp_detect_network_updates:1;
unsigned ngp_shutdown_events:1;
unsigned :0;
} set_bits;
unsigned set_unsigned[2];
} ngp_set_;
} nua_global_preferences_t;
#define ngp_set ngp_set_.set_bits
#define DNHP_GET(dnhp, pref) ((dnhp)->nhp_##pref) #define DNHP_GET(dnhp, pref) ((dnhp)->nhp_##pref)
#define NHP_GET(nhp, dnhp, pref) \ #define NHP_GET(nhp, dnhp, pref) \

View File

@ -244,19 +244,21 @@ static int nua_publish_client_response(nua_client_request_t *cr,
sip_t const *sip); sip_t const *sip);
static nua_client_methods_t const nua_publish_client_methods = { static nua_client_methods_t const nua_publish_client_methods = {
SIP_METHOD_PUBLISH, SIP_METHOD_PUBLISH, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 0, /* create_dialog */ 0,
/* in_dialog */ 0, /* in_dialog */ 0,
/* target refresh */ 0 /* target refresh */ 0
}, },
nua_publish_client_template, nua_publish_client_template, /* crm_template */
nua_publish_client_init, nua_publish_client_init, /* crm_init */
nua_publish_client_request, nua_publish_client_request, /* crm_send */
nua_publish_client_check_restart, nua_publish_client_check_restart, /* crm_check_restart */
nua_publish_client_response, nua_publish_client_response, /* crm_recv */
/* nua_publish_client_preliminary */ NULL NULL, /* crm_preliminary */
NULL, /* crm_report */
NULL, /* crm_complete */
}; };
/**@internal Send PUBLISH. */ /**@internal Send PUBLISH. */

View File

@ -570,18 +570,21 @@ static int nua_register_client_response(nua_client_request_t *cr,
sip_t const *sip); sip_t const *sip);
static nua_client_methods_t const nua_register_client_methods = { static nua_client_methods_t const nua_register_client_methods = {
SIP_METHOD_REGISTER, SIP_METHOD_REGISTER, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 1, /* create_dialog */ 1,
/* in_dialog */ 0, /* in_dialog */ 0,
/* target refresh */ 0 /* target refresh */ 0
}, },
nua_register_client_template, nua_register_client_template, /* crm_template */
nua_register_client_init, nua_register_client_init, /* crm_init */
nua_register_client_request, nua_register_client_request, /* crm_send */
nua_register_client_check_restart, nua_register_client_check_restart, /* crm_check_restart */
nua_register_client_response nua_register_client_response, /* crm_recv */
NULL, /* crm_preliminary */
NULL, /* crm_report */
NULL, /* crm_complete */
}; };
/**@internal Send REGISTER. */ /**@internal Send REGISTER. */

View File

@ -191,7 +191,7 @@ static int nua_session_usage_shutdown(nua_owner_t *,
nua_dialog_usage_t *); nua_dialog_usage_t *);
static int nua_invite_client_ack(nua_client_request_t *cr, tagi_t const *tags); static int nua_invite_client_ack(nua_client_request_t *cr, tagi_t const *tags);
static int nua_invite_client_deinit(nua_client_request_t *cr); static int nua_invite_client_complete(nua_client_request_t *cr);
static nua_usage_class const nua_session_usage[1] = { static nua_usage_class const nua_session_usage[1] = {
{ {
@ -238,7 +238,8 @@ void nua_session_usage_remove(nua_handle_t *nh,
cr = du->du_cr; cr = du->du_cr;
if (cr && cr->cr_orq && cr->cr_status >= 200) { if (cr && cr->cr_orq && cr->cr_status >= 200 &&
cr->cr_method == sip_method_invite) {
ss->ss_reporting = 1; ss->ss_reporting = 1;
nua_invite_client_ack(cr, NULL); nua_invite_client_ack(cr, NULL);
ss->ss_reporting = 0; ss->ss_reporting = 0;
@ -250,14 +251,17 @@ void nua_session_usage_remove(nua_handle_t *nh,
if (cr->cr_method != sip_method_invite) if (cr->cr_method != sip_method_invite)
continue; continue;
if (cr == du->du_cr) if (cr == du->du_cr)
continue; continue;
if (cr->cr_status < 200) {
nua_stack_event(nh->nh_nua, nh, nua_stack_event(nh->nh_nua, nh,
NULL, NULL,
cr->cr_event, cr->cr_event,
SIP_481_NO_TRANSACTION, SIP_481_NO_TRANSACTION,
NULL); NULL);
}
nua_client_request_destroy(cr); nua_client_request_destroy(cr);
@ -542,21 +546,21 @@ static int nua_invite_client_report(nua_client_request_t *cr,
tagi_t const *tags); tagi_t const *tags);
nua_client_methods_t const nua_invite_client_methods = { nua_client_methods_t const nua_invite_client_methods = {
SIP_METHOD_INVITE, SIP_METHOD_INVITE, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 1, /* create_dialog */ 1,
/* in_dialog */ 1, /* in_dialog */ 1,
/* target refresh */ 1 /* target refresh */ 1
}, },
NULL, NULL, /* crm_template */
nua_invite_client_init, nua_invite_client_init, /* crm_init */
nua_invite_client_request, nua_invite_client_request, /* crm_send */
session_timer_check_restart, session_timer_check_restart, /* crm_check_restart */
nua_invite_client_response, nua_invite_client_response, /* crm_recv */
nua_invite_client_preliminary, nua_invite_client_preliminary, /* crm_preliminary */
nua_invite_client_report, nua_invite_client_report, /* crm_report */
nua_invite_client_deinit nua_invite_client_complete, /* crm_complete */
}; };
extern nua_client_methods_t const nua_bye_client_methods; extern nua_client_methods_t const nua_bye_client_methods;
@ -604,10 +608,15 @@ static int nua_invite_client_init(nua_client_request_t *cr,
if (!du) if (!du)
return -1; return -1;
ss = nua_dialog_usage_private(du);
if (ss->ss_state >= nua_callstate_terminating)
return nua_client_return(cr, 900, "Session is terminating", msg);
if (nua_client_bind(cr, du) < 0) if (nua_client_bind(cr, du) < 0)
return nua_client_return(cr, 900, "INVITE already in progress", msg); return nua_client_return(cr, 900, "INVITE already in progress", msg);
ss = nua_dialog_usage_private(du); cr->cr_neutral = 0;
session_timer_preferences(ss->ss_timer, session_timer_preferences(ss->ss_timer,
sip, sip,
@ -617,8 +626,6 @@ static int nua_invite_client_init(nua_client_request_t *cr,
NH_PGET(nh, refresher), NH_PGET(nh, refresher),
NH_PGET(nh, min_se)); NH_PGET(nh, min_se));
cr->cr_neutral = 0;
return 0; return 0;
} }
@ -635,6 +642,9 @@ static int nua_invite_client_request(nua_client_request_t *cr,
if (du == NULL) /* Call terminated */ if (du == NULL) /* Call terminated */
return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg); return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
if (ss->ss_state >= nua_callstate_terminating)
return nua_client_return(cr, 900, "Session is terminating", msg);
assert(ss); assert(ss);
invite_timeout = NH_PGET(nh, invite_timeout); invite_timeout = NH_PGET(nh, invite_timeout);
@ -1047,7 +1057,7 @@ int nua_stack_ack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
if (error < 0) { if (error < 0) {
if (ss->ss_reason == NULL) if (ss->ss_reason == NULL)
ss->ss_reason = "SIP;cause=500;text=\"Internal Error\""; ss->ss_reason = "SIP;cause=500;text=\"Internal Error\"";
ss->ss_reporting = 1; /* We report state here if BYE fails */ ss->ss_reporting = 1; /* We report terminated state here if BYE fails */
error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL); error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
ss->ss_reporting = 0; ss->ss_reporting = 0;
signal_call_state_change(nh, ss, 500, "Internal Error", signal_call_state_change(nh, ss, 500, "Internal Error",
@ -1090,6 +1100,7 @@ int nua_invite_client_ack(nua_client_request_t *cr, tagi_t const *tags)
char const *invite_branch; char const *invite_branch;
assert(cr->cr_orq); assert(cr->cr_orq);
assert(cr->cr_method == sip_method_invite);
if (!ds->ds_leg) { if (!ds->ds_leg) {
@ -1226,8 +1237,8 @@ int nua_invite_client_ack(nua_client_request_t *cr, tagi_t const *tags)
return error; return error;
} }
/** Deinitialize client request */ /** Complete client request */
static int nua_invite_client_deinit(nua_client_request_t *cr) static int nua_invite_client_complete(nua_client_request_t *cr)
{ {
if (cr->cr_orq == NULL) if (cr->cr_orq == NULL)
/* Xyzzy */; /* Xyzzy */;
@ -1263,18 +1274,21 @@ static int nua_cancel_client_request(nua_client_request_t *cr,
tagi_t const *tags); tagi_t const *tags);
nua_client_methods_t const nua_cancel_client_methods = { nua_client_methods_t const nua_cancel_client_methods = {
SIP_METHOD_CANCEL, SIP_METHOD_CANCEL, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 0, /* create_dialog */ 0,
/* in_dialog */ 1, /* in_dialog */ 1,
/* target refresh */ 0 /* target refresh */ 0
}, },
NULL, NULL, /* crm_template */
NULL, NULL, /* crm_init */
nua_cancel_client_request, nua_cancel_client_request, /* crm_send */
/* nua_cancel_client_check_restart */ NULL, NULL, /* crm_check_restart */
/* nua_cancel_client_response */ NULL NULL, /* crm_recv */
NULL, /* crm_preliminary */
NULL, /* crm_report */
NULL, /* crm_complete */
}; };
int nua_stack_cancel(nua_t *nua, nua_handle_t *nh, nua_event_t e, int nua_stack_cancel(nua_t *nua, nua_handle_t *nh, nua_event_t e,
@ -1493,20 +1507,21 @@ static int nua_prack_client_report(nua_client_request_t *cr,
tagi_t const *tags); tagi_t const *tags);
nua_client_methods_t const nua_prack_client_methods = { nua_client_methods_t const nua_prack_client_methods = {
SIP_METHOD_PRACK, SIP_METHOD_PRACK, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 0, /* create_dialog */ 0,
/* in_dialog */ 1, /* in_dialog */ 1,
/* target refresh */ 0 /* target refresh */ 0
}, },
NULL, NULL, /* crm_template */
nua_prack_client_init, nua_prack_client_init, /* crm_init */
nua_prack_client_request, nua_prack_client_request, /* crm_send */
/* nua_prack_client_check_restart */ NULL, NULL, /* crm_check_restart */
nua_prack_client_response, nua_prack_client_response, /* crm_recv */
NULL, NULL, /* crm_preliminary */
nua_prack_client_report nua_prack_client_report, /* crm_report */
NULL, /* crm_complete */
}; };
int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e, int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
@ -1542,6 +1557,8 @@ static int nua_prack_client_request(nua_client_request_t *cr,
if (du == NULL) /* Call terminated */ if (du == NULL) /* Call terminated */
return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg); return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
assert(ss); assert(ss);
if (ss->ss_state >= nua_callstate_terminating)
return nua_client_return(cr, 900, "Session is terminating", msg);
cri = du->du_cr; cri = du->du_cr;
@ -1820,6 +1837,7 @@ nua_invite_server_init(nua_server_request_t *sr)
{ {
nua_handle_t *nh = sr->sr_owner; nua_handle_t *nh = sr->sr_owner;
nua_t *nua = nh->nh_nua; nua_t *nua = nh->nh_nua;
nua_session_usage_t *ss;
sr->sr_neutral = 1; sr->sr_neutral = 1;
@ -1836,9 +1854,8 @@ nua_invite_server_init(nua_server_request_t *sr)
nua_client_request_t const *cr; nua_client_request_t const *cr;
for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next) { for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next) {
/* Final response have not been sent to previous INVITE */ /* Previous INVITE has not been ACKed */
if (sr0->sr_method == sip_method_invite && if (sr0->sr_method == sip_method_invite)
nua_server_request_is_pending(sr0))
break; break;
/* Or we have sent offer but have not received an answer */ /* Or we have sent offer but have not received an answer */
if (sr->sr_sdp && sr0->sr_offer_sent && !sr0->sr_answer_recv) if (sr->sr_sdp && sr0->sr_offer_sent && !sr0->sr_answer_recv)
@ -1858,6 +1875,13 @@ nua_invite_server_init(nua_server_request_t *sr)
/* Glare - RFC 3261 14.2 and RFC 3311 section 5.2 */ /* Glare - RFC 3261 14.2 and RFC 3311 section 5.2 */
return SR_STATUS1(sr, SIP_491_REQUEST_PENDING); return SR_STATUS1(sr, SIP_491_REQUEST_PENDING);
} }
ss = nua_dialog_usage_private(sr->sr_usage);
if (ss->ss_state < nua_callstate_ready &&
ss->ss_state != nua_callstate_init) {
return nua_server_retry_after(sr, 500, "Overlapping Requests 2", 0, 10);
}
} }
sr->sr_neutral = 0; sr->sr_neutral = 0;
@ -1887,6 +1911,11 @@ nua_session_server_init(nua_server_request_t *sr)
/* UPDATE/PRACK sent within an existing dialog? */ /* UPDATE/PRACK sent within an existing dialog? */
return SR_STATUS(sr, 481, "Call Does Not Exist"); return SR_STATUS(sr, 481, "Call Does Not Exist");
} }
else if (sr->sr_usage) {
nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
if (ss->ss_state >= nua_callstate_terminating)
return SR_STATUS(sr, 481, "Call is being terminated");
}
if (nh->nh_soa) { if (nh->nh_soa) {
sip_accept_t *a = nua->nua_invite_accept; sip_accept_t *a = nua->nua_invite_accept;
@ -1972,8 +2001,10 @@ int nua_invite_server_preprocess(nua_server_request_t *sr)
session_timer_store(ss->ss_timer, request); session_timer_store(ss->ss_timer, request);
if (!(ss->ss_state >= nua_callstate_ready || ss->ss_state == nua_callstate_init)) #if 0 /* The glare and overlap tests should take care of this. */
return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR); assert(ss->ss_state >= nua_callstate_completed ||
ss->ss_state == nua_callstate_init);
#endif
if (NH_PGET(nh, auto_answer) || if (NH_PGET(nh, auto_answer) ||
/* Auto-answer to re-INVITE unless auto_answer is set to 0 on handle */ /* Auto-answer to re-INVITE unless auto_answer is set to 0 on handle */
@ -2319,7 +2350,7 @@ int process_ack(nua_server_request_t *sr,
nua_stack_event(nh->nh_nua, nh, NULL, nua_stack_event(nh->nh_nua, nh, NULL,
nua_i_media_error, status, phrase, NULL); nua_i_media_error, status, phrase, NULL);
ss->ss_reporting = 1; /* We report state here if BYE fails */ ss->ss_reporting = 1; /* We report terminated state here if BYE fails */
error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL); error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
ss->ss_reporting = 0; ss->ss_reporting = 0;
@ -2416,7 +2447,7 @@ int process_timeout(nua_server_request_t *sr,
/* send BYE, too, if 200 OK (or 183 to re-INVITE) timeouts */ /* send BYE, too, if 200 OK (or 183 to re-INVITE) timeouts */
ss->ss_reason = reason; ss->ss_reason = reason;
ss->ss_reporting = 1; /* We report state here if BYE fails */ ss->ss_reporting = 1; /* We report terminated state here if BYE fails */
error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL); error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
ss->ss_reporting = 0; ss->ss_reporting = 0;
@ -2787,18 +2818,21 @@ static int nua_info_client_request(nua_client_request_t *cr,
tagi_t const *tags); tagi_t const *tags);
nua_client_methods_t const nua_info_client_methods = { nua_client_methods_t const nua_info_client_methods = {
SIP_METHOD_INFO, SIP_METHOD_INFO, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 0, /* create_dialog */ 0,
/* in_dialog */ 1, /* in_dialog */ 1,
/* target refresh */ 0 /* target refresh */ 0
}, },
/*nua_info_client_template*/ NULL, NULL, /* crm_template */
nua_info_client_init, nua_info_client_init, /* crm_init */
nua_info_client_request, nua_info_client_request, /* crm_send */
/*nua_info_client_check_restart*/ NULL, NULL, /* crm_check_restart */
/*nua_info_client_response*/ NULL NULL, /* crm_recv */
NULL, /* crm_preliminary */
NULL, /* crm_report */
NULL, /* crm_complete */
}; };
int int
@ -2934,20 +2968,21 @@ static int nua_update_client_report(nua_client_request_t *cr,
tagi_t const *tags); tagi_t const *tags);
nua_client_methods_t const nua_update_client_methods = { nua_client_methods_t const nua_update_client_methods = {
SIP_METHOD_UPDATE, SIP_METHOD_UPDATE, /* crm_method, crm_method_name */
0, /* size of private data */ 0, /* crm_extrasize of private data */
{ { /* crm_flags */
/* create_dialog */ 0, /* create_dialog */ 0,
/* in_dialog */ 1, /* in_dialog */ 1,
/* target refresh */ 1 /* target refresh */ 1
}, },
NULL, NULL, /* crm_template */
nua_update_client_init, nua_update_client_init, /* crm_init */
nua_update_client_request, nua_update_client_request, /* crm_send */
session_timer_check_restart, session_timer_check_restart, /* crm_check_restart */
nua_update_client_response, nua_update_client_response, /* crm_recv */
NULL, NULL, /* crm_preliminary */
nua_update_client_report nua_update_client_report, /* crm_report */
NULL, /* crm_complete */
}; };
int nua_stack_update(nua_t *nua, nua_handle_t *nh, nua_event_t e, int nua_stack_update(nua_t *nua, nua_handle_t *nh, nua_event_t e,
@ -2982,6 +3017,8 @@ static int nua_update_client_request(nua_client_request_t *cr,
if (du == NULL) /* Call terminated */ if (du == NULL) /* Call terminated */
return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg); return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
assert(ss); assert(ss);
if (ss->ss_state >= nua_callstate_terminating)
return nua_client_return(cr, 900, "Session is terminating", msg);
cri = du->du_cr; cri = du->du_cr;
@ -3397,20 +3434,21 @@ static int nua_bye_client_report(nua_client_request_t *cr,
tagi_t const *tags); tagi_t const *tags);
nua_client_methods_t const nua_bye_client_methods = { nua_client_methods_t const nua_bye_client_methods = {
SIP_METHOD_BYE, SIP_METHOD_BYE, /* crm_method, crm_method_name */
0, 0, /* crm_extrasize */
{ { /* crm_flags */
/* create_dialog */ 0, /* create_dialog */ 0,
/* in_dialog */ 1, /* in_dialog */ 1,
/* target refresh */ 0 /* target refresh */ 0
}, },
NULL, NULL, /* crm_template */
nua_bye_client_init, nua_bye_client_init, /* crm_init */
nua_bye_client_request, nua_bye_client_request, /* crm_send */
/*nua_bye_client_check_restart*/ NULL, NULL, /* crm_check_restart */
/*nua_bye_client_response*/ NULL, NULL, /* crm_recv */
/*nua_bye_client_preliminary*/ NULL, NULL, /* crm_preliminary */
nua_bye_client_report nua_bye_client_report, /* crm_report */
NULL, /* crm_complete */
}; };
int int
@ -3443,7 +3481,9 @@ static int nua_bye_client_init(nua_client_request_t *cr,
if (nh->nh_soa) if (nh->nh_soa)
soa_terminate(nh->nh_soa, 0); soa_terminate(nh->nh_soa, 0);
cr->cr_usage = du;
du->du_cr = NULL;
nua_client_bind(cr, du);
return 0; return 0;
} }
@ -3515,19 +3555,25 @@ static int nua_bye_client_report(nua_client_request_t *cr,
else { else {
nua_session_usage_t *ss = nua_dialog_usage_private(du); nua_session_usage_t *ss = nua_dialog_usage_private(du);
if (ss->ss_reporting) {
return 1; /* Somebody else's problem */
}
else if (cr->cr_waiting) {
return 1; /* Application problem */
}
signal_call_state_change(nh, ss, status, "to BYE", signal_call_state_change(nh, ss, status, "to BYE",
nua_callstate_terminated); nua_callstate_terminated);
if (ss && !ss->ss_reporting) { if (du &&
if (du->du_cr == NULL || (du->du_cr == NULL ||
!nua_client_is_queued(du->du_cr) || !nua_client_is_queued(du->du_cr) ||
du->du_cr->cr_status >= 200) { du->du_cr->cr_status >= 200)) {
/* INVITE is completed, we can zap the session... */; /* INVITE is completed, we can zap the session... */;
cr->cr_usage = NULL; cr->cr_usage = NULL;
nua_session_usage_destroy(nh, ss); nua_session_usage_destroy(nh, ss);
} }
} }
}
return 1; return 1;
} }

View File

@ -209,7 +209,7 @@ int nua_stack_init(su_root_t *root, nua_t *nua)
if (nua_stack_set_from(nua, 1, nua->nua_args) < 0) if (nua_stack_set_from(nua, 1, nua->nua_args) < 0)
return -1; return -1;
if (NHP_ISSET(dnh->nh_prefs, detect_network_updates)) if (nua->nua_prefs->ngp_detect_network_updates)
nua_stack_launch_network_change_detector(nua); nua_stack_launch_network_change_detector(nua);
nua_stack_timer(nua, nua->nua_timer, NULL); nua_stack_timer(nua, nua->nua_timer, NULL);
@ -293,7 +293,8 @@ int nua_stack_event(nua_t *nua, nua_handle_t *nh, msg_t *msg,
if ((event > nua_r_authenticate && event <= nua_r_ack) if ((event > nua_r_authenticate && event <= nua_r_ack)
|| event < nua_i_error || event < nua_i_error
|| (nh && !nh->nh_valid) || (nh && !nh->nh_valid)
) { || (nua->nua_shutdown && event != nua_r_shutdown &&
!nua->nua_prefs->ngp_shutdown_events)) {
if (msg) if (msg)
msg_destroy(msg); msg_destroy(msg);
return event; return event;
@ -2075,6 +2076,13 @@ nua_client_request_t *nua_client_request_remove(nua_client_request_t *cr)
return cr; return cr;
} }
void nua_client_request_complete(nua_client_request_t *cr)
{
nua_client_request_remove(cr);
if (cr && cr->cr_methods->crm_complete)
cr->cr_methods->crm_complete(cr);
}
void nua_client_request_destroy(nua_client_request_t *cr) void nua_client_request_destroy(nua_client_request_t *cr)
{ {
nua_handle_t *nh; nua_handle_t *nh;
@ -2082,14 +2090,12 @@ void nua_client_request_destroy(nua_client_request_t *cr)
if (cr == NULL) if (cr == NULL)
return; return;
if (cr->cr_methods->crm_deinit) nua_client_request_complete(cr);
cr->cr_methods->crm_deinit(cr);
nh = cr->cr_owner; nh = cr->cr_owner;
nua_destroy_signal(cr->cr_signal); nua_destroy_signal(cr->cr_signal);
nua_client_request_remove(cr);
nua_client_bind(cr, NULL); nua_client_bind(cr, NULL);
if (cr->cr_msg) if (cr->cr_msg)
@ -2098,7 +2104,6 @@ void nua_client_request_destroy(nua_client_request_t *cr)
if (cr->cr_orq) if (cr->cr_orq)
nta_outgoing_destroy(cr->cr_orq); nta_outgoing_destroy(cr->cr_orq);
cr->cr_orq = NULL; cr->cr_orq = NULL;
if (cr->cr_timer) if (cr->cr_timer)

View File

@ -217,28 +217,31 @@ struct nua_s {
su_clone_r nua_clone; su_clone_r nua_clone;
su_task_r nua_client; su_task_r nua_client;
su_network_changed_t *nua_nw_changed;
nua_callback_f nua_callback; nua_callback_f nua_callback;
nua_magic_t *nua_magic; nua_magic_t *nua_magic;
nua_event_frame_t *nua_current; nua_event_frame_t *nua_current;
nua_saved_event_t nua_signal[1]; nua_saved_event_t nua_signal[1];
/**< Used by stop-and-wait args calls */
tagi_t const *nua_args;
/* Engine state flags */ /* Engine state flags */
sip_time_t nua_shutdown;
unsigned nua_shutdown_started:1; /**< Shutdown initiated */ unsigned nua_shutdown_started:1; /**< Shutdown initiated */
unsigned nua_shutdown_final:1; /**< Shutdown is complete */ unsigned nua_shutdown_final:1; /**< Shutdown is complete */
unsigned nua_from_is_set; unsigned nua_from_is_set;
unsigned :0; unsigned :0;
/**< Used by stop-and-wait args calls */
tagi_t const *nua_args;
/**< Local SIP address. Contents are kept around for ever. */ /**< Local SIP address. Contents are kept around for ever. */
sip_from_t nua_from[1]; sip_from_t nua_from[1];
/* ---------------------------------------------------------------------- */
/* Protocol (server) side */ /* Protocol (server) side */
su_network_changed_t *nua_nw_changed;
nua_registration_t *nua_registrations; /**< Active registrations */ nua_registration_t *nua_registrations; /**< Active registrations */
@ -250,21 +253,8 @@ struct nua_s {
nta_agent_t *nua_nta; nta_agent_t *nua_nta;
su_timer_t *nua_timer; su_timer_t *nua_timer;
void *nua_sip_parser;
sip_time_t nua_shutdown;
/* Route */
sip_service_route_t *nua_service_route;
/* User-agent parameters */ /* User-agent parameters */
unsigned nua_media_enable:1; nua_global_preferences_t nua_prefs[1];
unsigned :0;
#if HAVE_SMIME /* Start NRC Boston */
sm_object_t *sm;
#endif /* End NRC Boston */
nua_handle_t *nua_handles; nua_handle_t *nua_handles;
nua_handle_t **nua_handles_tail; nua_handle_t **nua_handles_tail;

View File

@ -183,18 +183,21 @@ static int nua_subscribe_client_response(nua_client_request_t *cr,
sip_t const *sip); sip_t const *sip);
static nua_client_methods_t const nua_subscribe_client_methods = { static nua_client_methods_t const nua_subscribe_client_methods = {
SIP_METHOD_SUBSCRIBE, SIP_METHOD_SUBSCRIBE, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 1, /* create_dialog */ 1,
/* in_dialog */ 1, /* in_dialog */ 1,
/* target refresh */ 1 /* target refresh */ 1
}, },
NULL, NULL, /* crm_template */
nua_subscribe_client_init, nua_subscribe_client_init, /* crm_init */
nua_subscribe_client_request, nua_subscribe_client_request, /* crm_send */
/* nua_subscribe_client_check_restart */ NULL, NULL, /* crm_check_restart */
nua_subscribe_client_response nua_subscribe_client_response, /* crm_recv */
NULL, /* crm_preliminary */
NULL, /* crm_report */
NULL, /* crm_complete */
}; };
int int
@ -368,6 +371,9 @@ static int nua_subscribe_client_response(nua_client_request_t *cr,
else else
delta = 0; delta = 0;
if (delta > eu->eu_expires)
delta = eu->eu_expires;
if (win_messenger_enable && !nua_dialog_is_established(nh->nh_ds)) { if (win_messenger_enable && !nua_dialog_is_established(nh->nh_ds)) {
/* Notify from messanger does not match with dialog tag */ /* Notify from messanger does not match with dialog tag */
nh->nh_ds->ds_remote_tag = su_strdup(nh->nh_home, ""); nh->nh_ds->ds_remote_tag = su_strdup(nh->nh_home, "");
@ -647,8 +653,6 @@ int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags)
if (substate == nua_substate_active || substate == nua_substate_pending) { if (substate == nua_substate_active || substate == nua_substate_pending) {
if (subs && subs->ss_expires) if (subs && subs->ss_expires)
delta = strtoul(subs->ss_expires, NULL, 10); delta = strtoul(subs->ss_expires, NULL, 10);
else
delta = eu->eu_expires;
} }
else if (substate == nua_substate_embryonic) { else if (substate == nua_substate_embryonic) {
if (subs && subs->ss_reason) { if (subs && subs->ss_reason) {
@ -686,6 +690,7 @@ int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags)
nua_dialog_usage_set_refresh_range(du, retry, retry + 5); nua_dialog_usage_set_refresh_range(du, retry, retry + 5);
} }
else { else {
if (delta < SIP_TIME_MAX)
nua_dialog_usage_set_refresh(du, delta); nua_dialog_usage_set_refresh(du, delta);
} }
@ -777,20 +782,21 @@ static int nua_refer_client_response(nua_client_request_t *cr,
sip_t const *sip); sip_t const *sip);
static nua_client_methods_t const nua_refer_client_methods = { static nua_client_methods_t const nua_refer_client_methods = {
SIP_METHOD_REFER, SIP_METHOD_REFER, /* crm_method, crm_method_name */
0, 0, /* crm_extra */
{ { /* crm_flags */
/* create_dialog */ 1, /* create_dialog */ 1,
/* in_dialog */ 1, /* in_dialog */ 1,
/* target refresh */ 1 /* target refresh */ 1
}, },
/*nua_refer_client_template*/ NULL, NULL, /* crm_template */
nua_refer_client_init, nua_refer_client_init, /* crm_init */
nua_refer_client_request, nua_refer_client_request, /* crm_send */
/* nua_refer_client_check_restart */ NULL, NULL, /* crm_check_restart */
nua_refer_client_response, nua_refer_client_response, /* crm_recv */
nua_refer_client_response, /* Preliminary */ nua_refer_client_response, /* crm_preliminary */
NULL NULL, /* crm_report */
NULL, /* crm_complete */
}; };
int int

View File

@ -227,21 +227,22 @@
* - NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and * - NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and
* SIPTAG_ALLOW_EVENTS_STR() * SIPTAG_ALLOW_EVENTS_STR()
* - NUTAG_MAX_SUBSCRIPTIONS() * - NUTAG_MAX_SUBSCRIPTIONS()
* - NUTAG_SUBSTATE() * - NUTAG_SUBSTATE(), NUTAG_SUB_EXPIRES()
* @par Specifications * @par Specifications
* - @RFC3265 * - @RFC3265
* *
* @par SIP Event Subscriber * @par SIP Event Subscriber
* - nua_subscribe(), #nua_r_subscribe, #nua_i_notify, NUTAG_SUBSTATE(), * - nua_subscribe(), #nua_r_subscribe, #nua_i_notify, NUTAG_SUBSTATE(),
* SIPTAG_EVENT(), SIPTAG_EXPIRES(), * SIPTAG_EVENT(), SIPTAG_EXPIRES()
* - nua_unsubscribe(), #nua_r_unsubscribe() * - nua_unsubscribe(), #nua_r_unsubscribe()
* @par Specifications * @par Specifications
* - @RFC3265 * - @RFC3265
* *
* @par SIP Event Notifier * @par SIP Event Notifier
* - #nua_i_subscribe(), nua_notify(), #nua_r_notify, * - #nua_i_subscribe(), nua_notify(), #nua_r_notify,
* NUTAG_SUBSTATE(), SIPTAG_EVENT() * NUTAG_SUBSTATE(), NUTAG_SUB_EXPIRES(), SIPTAG_EVENT()
* Settings: * Settings:
* - NUTAG_SUB_EXPIRES()
* - NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and * - NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and
* SIPTAG_ALLOW_EVENTS_STR() * SIPTAG_ALLOW_EVENTS_STR()
* - NUTAG_ALLOW("SUBSCRIBE"), NUTAG_APPL_METHOD("SUBSCRIBE") * - NUTAG_ALLOW("SUBSCRIBE"), NUTAG_APPL_METHOD("SUBSCRIBE")
@ -267,6 +268,8 @@
* Settings: * Settings:
* - NUTAG_ALLOW(x), NUTAG_APPL_METHOD(x) * - NUTAG_ALLOW(x), NUTAG_APPL_METHOD(x)
* *
* @par Server Shutdown
* - nua_shutdown(), NUTAG_SHUTDOWN_EVENTS(), nua_destroy().
*/ */
/* @par S/MIME /* @par S/MIME
@ -769,7 +772,7 @@ tag_typedef_t nutag_answer_sent = BOOLTAG_TYPEDEF(answer_sent);
* - with nua_create(), nua_set_params(), nua_get_params(), * - with nua_create(), nua_set_params(), nua_get_params(),
* nua_handle(), nua_set_hparams(), nua_get_hparams(), and * nua_handle(), nua_set_hparams(), nua_get_hparams(), and
* nua_notifier() to change the default subscription state returned by * nua_notifier() to change the default subscription state returned by
* the intenal event server * the internal event server
* - with nua_notify() and nua_respond() to SUBSCRIBE to determine the * - with nua_notify() and nua_respond() to SUBSCRIBE to determine the
* subscription state (if application include @SubscriptionState * subscription state (if application include @SubscriptionState
* header in the tag list, the NUTAG_SUBSTATE() value is ignored) * header in the tag list, the NUTAG_SUBSTATE() value is ignored)
@ -806,6 +809,39 @@ tag_typedef_t nutag_substate = INTTAG_TYPEDEF(substate);
*/ */
/**@def NUTAG_SUB_EXPIRES()
*
* Default expiration time of subscriptions.
*
* @par Used with
* - with nua_create(), nua_set_params(), nua_get_params(), nua_handle(),
* nua_set_hparams(), nua_get_hparams(), nua_respond(), nua_notify(), and
* nua_notifier() to change the default expiration time of subscriptions
*
* @par Parameter type
* unsigned int
*
* @par Values
* - default expiration time in seconds
*
* Note that the expires parameter in @SubscriptionState or @Expires header
* in the nua_response() to the SUBSCRIBE overrides the default subscription
* expiration specified by NUTAG_SUB_EXPIRES().
*
* @sa @RFC3265, NUTAG_REFER_EXPIRES(), @Expires, SIPTAG_EXPIRES(),
* SIPTAG_EXPIRES_STR(), @SubscriptionState, nua_respond(), nua_notifier(),
* #nua_r_subscribe, #nua_i_subscribe, #nua_r_refer, #nua_r_notify,
* #nua_i_notify.
*
* Corresponding tag taking reference parameter is NUTAG_SUB_EXPIRES_REF().
*/
tag_typedef_t nutag_sub_expires = UINTTAG_TYPEDEF(substate);
/**@def NUTAG_SUB_EXPIRES_REF(x)
* Reference tag for NUTAG_SUB_EXPIRES().
*/
/**@def NUTAG_NEWSUB() /**@def NUTAG_NEWSUB()
* *
* Send unsolicited NOTIFY request. * Send unsolicited NOTIFY request.
@ -1075,17 +1111,17 @@ tag_typedef_t nutag_update_refresh = BOOLTAG_TYPEDEF(update_refresh);
* REFER. * REFER.
* *
* @par Used with * @par Used with
* nua_set_params() \n * nua_handle(), nua_respond() \n
* nua_get_params() \n * nua_set_params() or nua_set_hparams() \n
* nua_set_hparams() \n * nua_get_params() or nua_get_hparams()
* nua_get_hparams() \n
* *
* @par Parameter type * @par Parameter type
* unsigned int * unsigned int
* *
* @par Values * @par Values
* @c 0 disable \n * - default interval in seconds
* @c >0 interval in seconds *
* @sa NUTAG_SUB_EXPIRES()
* *
* Corresponding tag taking reference parameter is NUTAG_REFER_EXPIRES_REF(). * Corresponding tag taking reference parameter is NUTAG_REFER_EXPIRES_REF().
*/ */
@ -1570,6 +1606,9 @@ extern msg_hclass_t sip_route_class[];
* NUTAG_INITIAL_ROUTE_STR() tags, the route set is constructed from them * NUTAG_INITIAL_ROUTE_STR() tags, the route set is constructed from them
* all. * all.
* *
* The initial route is inserted into request message before the route
* entries set with SIPTAG_ROUTE() or SIPTAG_ROUTE_STR().
*
* @par Used with * @par Used with
* nua_set_params() \n * nua_set_params() \n
* nua_set_hparams() \n * nua_set_hparams() \n
@ -2736,6 +2775,39 @@ tag_typedef_t nutag_dialog = UINTTAG_TYPEDEF(dialog);
* Reference tag for NUTAG_SIP_PARSER(). * Reference tag for NUTAG_SIP_PARSER().
*/ */
/**@def NUTAG_SHUTDOWN_EVENTS(x)
*
* Allow passing of normal events when stack is being shut down.
*
* By default, only #nua_r_shutdown events are passed to application after
* calling nua_shutdown(). If application is interested in nua events during
* shutdown, it should give NUTAG_SHUTDOWN_EVENTS(1) to nua_create() or
* nua_set_params() called before nua_shutdown().
*
* @par Used with
* nua_create(), nua_set_params().
*
* @par Parameter type
* int (boolean)
*
* @par Values
* @c 0 False \n
* @c !=0 True
*
* Corresponding tag taking reference parameter is NUTAG_SHUTDOWN_EVENTS_REF().
*
* @sa nua_shutdown(), nua_destroy().
*
* @NEW_1_12_9.
*/
tag_typedef_t nutag_shutdown_events = BOOLTAG_TYPEDEF(shutdown_events);
/**@def NUTAG_SHUTDOWN_EVENTS_REF(x)
* Reference tag for NUTAG_SHUTDOWN_EVENTS().
*/
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
tag_typedef_t nutag_soa_session = PTRTAG_TYPEDEF(soa_session); tag_typedef_t nutag_soa_session = PTRTAG_TYPEDEF(soa_session);

View File

@ -497,12 +497,16 @@ SOFIAPUBFUN char const *nua_substate_name(enum nua_substate substate);
/** Convert string to enum nua_substate. @NEW_1_12_5. */ /** Convert string to enum nua_substate. @NEW_1_12_5. */
SOFIAPUBFUN enum nua_substate nua_substate_make(char const *sip_substate); SOFIAPUBFUN enum nua_substate nua_substate_make(char const *sip_substate);
#define NUTAG_SUB_EXPIRES(x) nutag_sub_expires, tag_uint_v(x)
SOFIAPUBVAR tag_typedef_t nutag_sub_expires;
#define NUTAG_SUB_EXPIRES_REF(x) nutag_sub_expires_ref, tag_uint_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_sub_expires_ref;
#define NUTAG_NEWSUB(x) nutag_newsub, tag_bool_v(x) #define NUTAG_NEWSUB(x) nutag_newsub, tag_bool_v(x)
SOFIAPUBVAR tag_typedef_t nutag_newsub; SOFIAPUBVAR tag_typedef_t nutag_newsub;
#define NUTAG_NEWSUB_REF(x) nutag_newsub_ref, tag_bool_vr(&(x)) #define NUTAG_NEWSUB_REF(x) nutag_newsub_ref, tag_bool_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_newsub_ref; SOFIAPUBVAR tag_typedef_t nutag_newsub_ref;
#define NUTAG_REFER_EXPIRES(x) nutag_refer_expires, tag_uint_v((x)) #define NUTAG_REFER_EXPIRES(x) nutag_refer_expires, tag_uint_v((x))
SOFIAPUBVAR tag_typedef_t nutag_refer_expires; SOFIAPUBVAR tag_typedef_t nutag_refer_expires;
#define NUTAG_REFER_EXPIRES_REF(x) nutag_refer_expires_ref, tag_uint_vr((&(x))) #define NUTAG_REFER_EXPIRES_REF(x) nutag_refer_expires_ref, tag_uint_vr((&(x)))
@ -569,6 +573,13 @@ SOFIAPUBVAR tag_typedef_t nutag_detect_network_updates;
nutag_detect_network_updates_ref, tag_int_vr(&(x)) nutag_detect_network_updates_ref, tag_int_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_detect_network_updates_ref; SOFIAPUBVAR tag_typedef_t nutag_detect_network_updates_ref;
#define NUTAG_SHUTDOWN_EVENTS(x) \
nutag_shutdown_events, tag_bool_v(x)
SOFIAPUBVAR tag_typedef_t nutag_shutdown_events;
#define NUTAG_SHUTDOWN_EVENTS_REF(x) \
nutag_shutdown_events_ref, tag_bool_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_shutdown_events_ref;
/* Pass nua handle as tagged argument */ /* Pass nua handle as tagged argument */
#if SU_INLINE_TAG_CAST #if SU_INLINE_TAG_CAST
su_inline tag_value_t nutag_handle_v(nua_handle_t *v) { return (tag_value_t)v; } su_inline tag_value_t nutag_handle_v(nua_handle_t *v) { return (tag_value_t)v; }