Commit 72424b26 authored by Pekka Pessi's avatar Pekka Pessi

nua: using global preferences. Added NUTAG_SHUTDOWN_EVENTS().

darcs-hash:20080206170546-65a35-d9826f24242e4916ec27516dd840a7abf389247d.gz
parent 4f7a2ef0
This diff is collapsed.
......@@ -127,9 +127,6 @@ typedef struct nua_handle_preferences
/** Outbound OPTIONS */
char const *nhp_outbound;
/** Network detection: NONE, INFORMAL, TRY_FULL */
int nhp_detect_network_updates;
sip_allow_t *nhp_appl_method;
/** Initial route set */
......@@ -137,6 +134,12 @@ typedef struct nua_handle_preferences
union { struct {
/* 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_max_subscriptions:1;
......@@ -172,7 +175,8 @@ typedef struct nua_handle_preferences
unsigned nhb_allow:1;
unsigned nhb_supported:1;
unsigned :0; /* at most 32 bits ... */
unsigned :0; /* at most 32 bits before this point */
unsigned nhb_allow_events:1;
unsigned nhb_user_agent:1;
unsigned nhb_organization:1;
......@@ -183,7 +187,6 @@ typedef struct nua_handle_preferences
unsigned nhb_m_features:1;
unsigned nhb_instance:1;
unsigned nhb_outbound:1;
unsigned nhb_detect_network_updates:1;
unsigned nhb_appl_method:1;
unsigned nhb_initial_route:1;
unsigned :0;
......@@ -194,6 +197,26 @@ typedef struct nua_handle_preferences
#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 NHP_GET(nhp, dnhp, pref) \
......
......@@ -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)
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_timer(nua, nua->nua_timer, NULL);
......
......@@ -217,28 +217,31 @@ struct nua_s {
su_clone_r nua_clone;
su_task_r nua_client;
su_network_changed_t *nua_nw_changed;
nua_callback_f nua_callback;
nua_magic_t *nua_magic;
nua_event_frame_t *nua_current;
nua_saved_event_t nua_signal[1];
/**< Used by stop-and-wait args calls */
tagi_t const *nua_args;
/* Engine state flags */
sip_time_t nua_shutdown;
unsigned nua_shutdown_started:1; /**< Shutdown initiated */
unsigned nua_shutdown_final:1; /**< Shutdown is complete */
unsigned nua_from_is_set;
unsigned :0;
/**< Used by stop-and-wait args calls */
tagi_t const *nua_args;
/**< Local SIP address. Contents are kept around for ever. */
sip_from_t nua_from[1];
sip_from_t nua_from[1];
/* ---------------------------------------------------------------------- */
/* Protocol (server) side */
su_network_changed_t *nua_nw_changed;
nua_registration_t *nua_registrations; /**< Active registrations */
......@@ -250,21 +253,8 @@ struct nua_s {
nta_agent_t *nua_nta;
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 */
unsigned nua_media_enable:1;
unsigned :0;
#if HAVE_SMIME /* Start NRC Boston */
sm_object_t *sm;
#endif /* End NRC Boston */
nua_global_preferences_t nua_prefs[1];
nua_handle_t *nua_handles;
nua_handle_t **nua_handles_tail;
......
......@@ -267,6 +267,8 @@
* Settings:
* - NUTAG_ALLOW(x), NUTAG_APPL_METHOD(x)
*
* @par Server Shutdown
* - nua_shutdown(), NUTAG_SHUTDOWN_EVENTS(), nua_destroy().
*/
/* @par S/MIME
......@@ -1570,6 +1572,9 @@ extern msg_hclass_t sip_route_class[];
* NUTAG_INITIAL_ROUTE_STR() tags, the route set is constructed from them
* all.
*
* The initial route is inserted into request message before the route
* entries set with SIPTAG_ROUTE() or SIPTAG_ROUTE_STR().
*
* @par Used with
* nua_set_params() \n
* nua_set_hparams() \n
......@@ -2736,6 +2741,39 @@ tag_typedef_t nutag_dialog = UINTTAG_TYPEDEF(dialog);
* 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);
......
......@@ -569,6 +569,13 @@ SOFIAPUBVAR tag_typedef_t nutag_detect_network_updates;
nutag_detect_network_updates_ref, tag_int_vr(&(x))
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 */
#if SU_INLINE_TAG_CAST
su_inline tag_value_t nutag_handle_v(nua_handle_t *v) { return (tag_value_t)v; }
......
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