Commit b77f7e74 authored by Pekka Pessi's avatar Pekka Pessi

nua: added tag NUTAG_APPL_METHOD().

Changes in files nua_tag.h, nua_tag.c, nua_params.h, nua_params.c.

darcs-hash:20061213143218-65a35-fac78cb7f1bdfbf004f1f5aec3029c0010758951.gz
parent 0d8a78c4
......@@ -177,6 +177,9 @@ int nua_stack_set_defaults(nua_handle_t *nh,
NHP_SET(nhp, keepalive, 120000);
NHP_SET(nhp, appl_method,
sip_allow_make(home, "INVITE, REGISTER, PUBLISH, SUBSCRIBE"));
if (!nhp->nhp_allow ||
!nhp->nhp_supported ||
!nhp->nhp_user_agent ||
......@@ -474,6 +477,7 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
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;
......@@ -481,13 +485,16 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
*tmp = *nhp; NHP_UNSET_ALL(tmp);
/* Supported features and allowed methods can be merged with previous ones */
/* Supported features, allowed methods and events are merged
with previous ones */
if (!NHP_ISSET(nhp, supported))
supported = tmp->nhp_supported = dnhp->nhp_supported;
if (!NHP_ISSET(nhp, allow))
allow = tmp->nhp_allow = dnhp->nhp_allow;
if (!NHP_ISSET(nhp, allow_events))
allow_events = tmp->nhp_allow_events = dnhp->nhp_allow_events;
if (!NHP_ISSET(nhp, appl_method))
appl_method = tmp->nhp_appl_method = dnhp->nhp_appl_method;
error = 0;
global = nh == dnh; /* save also stack-specific params */
......@@ -501,11 +508,16 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
if (NHP_IS_ANY_SET(tmp)) {
if (tmp->nhp_supported == supported)
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;
......@@ -820,11 +832,11 @@ static int nhp_set_tags(su_home_t *home,
tag == siptag_allow_str ||
tag == siptag_allow) {
int ok;
sip_allow_t *allow = NULL;
msg_list_t *allow = NULL;
ok = nhp_merge_lists(home,
sip_allow_class,
(msg_list_t **)&allow,
&allow,
(msg_list_t const *)nhp->nhp_allow,
NHP_ISSET(nhp, allow), /* already set by tags */
tag == siptag_allow, /* dup it, don't make */
......@@ -833,7 +845,7 @@ static int nhp_set_tags(su_home_t *home,
if (ok < 0)
return -1;
else if (ok)
NHP_SET(nhp, allow, allow);
NHP_SET(nhp, allow, (sip_allow_t *)allow);
}
/* NUTAG_ALLOW_EVENTS(allow_events) */
/* SIPTAG_ALLOW_EVENTS_STR(allow_events) */
......@@ -845,7 +857,8 @@ static int nhp_set_tags(su_home_t *home,
sip_allow_events_t *allow_events = NULL;
ok = nhp_merge_lists(home,
sip_allow_events_class, &allow_events,
sip_allow_events_class,
&allow_events,
nhp->nhp_allow_events,
NHP_ISSET(nhp, allow_events), /* already set */
tag == siptag_allow_events, /* dup it, don't make */
......@@ -856,6 +869,29 @@ static int nhp_set_tags(su_home_t *home,
else if (ok)
NHP_SET(nhp, allow_events, allow_events);
}
/* NUTAG_APPL_METHOD(appl_method) */
else if (tag == nutag_appl_method) {
if (t->t_value == 0) {
NHP_SET(nhp, appl_method, NULL);
}
else {
int ok;
msg_list_t *appl_method = NULL;
ok = nhp_merge_lists(home,
sip_allow_class,
&appl_method,
(msg_list_t const *)nhp->nhp_appl_method,
NHP_ISSET(nhp, allow), /* already set by tags */
0, /* dup it, don't make */
1, /* merge with old value */
t->t_value);
if (ok < 0)
return -1;
else if (ok)
NHP_SET(nhp, appl_method, (sip_allow_t *)appl_method);
}
}
/* SIPTAG_USER_AGENT(user_agent) */
else if (tag == siptag_user_agent) {
NHP_SET_STR_BY_HEADER(nhp, user_agent, value);
......
......@@ -127,6 +127,8 @@ typedef struct nua_handle_preferences
/**< Network detection: NONE, INFORMAL, TRY_FULL */
int nhp_detect_network_updates;
sip_allow_t *nhp_appl_method;
union { struct {
/* A bit for each feature set by application */
......@@ -176,6 +178,7 @@ typedef struct nua_handle_preferences
unsigned nhb_instance:1;
unsigned nhb_outbound:1;
unsigned nhb_detect_network_updates:1;
unsigned nhb_appl_method:1;
unsigned :0;
} set_bits;
unsigned set_unsigned[2];
......
......@@ -2032,17 +2032,19 @@ int nua_default_respond(nua_server_request_t *sr,
* NUTAG_WITH_SAVED()). Otherwise, NUTAG_WITH() will contain an indication
* of the request being responded.
*
* In order to simplify the application, most requests are responded
* In order to simplify the simple applications, most requests are responded
* automatically. The set of requests always responded by the stack include
* BYE, CANCEL and NOTIFY. The application can add methods that it likes to
* handle by itself with NUTAG_APPL_METHOD(). The default set of
* NUTAG_APPL_METHOD() include INVITE, PUBLISH, REGISTER and SUBSCRIBE. Note
* that unless the method is also added to the set of allowed methods with
* NUTAG_ALLOW(), the stack will respond to the incoming methods with <i>405
* Not Allowed</i>.
* NUTAG_APPL_METHOD() includes INVITE, PUBLISH, REGISTER and SUBSCRIBE.
* Note that unless the method is also included in the set of allowed
* methods with NUTAG_ALLOW(), the stack will respond to the incoming
* methods with <i>405 Not Allowed</i>.
*
* Note that certain methods are rejected outside a SIP session (created
* with INVITE transaction). They include BYE, UPDATE, PRACK and INFO.
* with INVITE transaction). They include BYE, UPDATE, PRACK and INFO. Also
* the auxiliary methods ACK and CANCEL are rejected by stack if there is no
* ongoing INVITE transaction corresponding to them.
*
* @param nh Pointer to operation handle
* @param status SIP response status (see RFCs of SIP)
......
......@@ -138,6 +138,7 @@ tag_typedef_t nutag_refer_pause = BOOLTAG_TYPEDEF(refer_pause);
tag_typedef_t nutag_user_agent = STRTAG_TYPEDEF(user_agent);
tag_typedef_t nutag_allow = STRTAG_TYPEDEF(allow);
tag_typedef_t nutag_allow_events = STRTAG_TYPEDEF(allow_events);
tag_typedef_t nutag_appl_method = STRTAG_TYPEDEF(appl_method);
tag_typedef_t nutag_supported = STRTAG_TYPEDEF(supported);
tag_typedef_t nutag_path_enable = BOOLTAG_TYPEDEF(path_enable);
tag_typedef_t nutag_service_route_enable =
......
......@@ -1705,6 +1705,45 @@ SOFIAPUBVAR tag_typedef_t nutag_allow;
SOFIAPUBVAR tag_typedef_t nutag_allow_ref;
/** Indicate that a method (or methods) are handled by application.
*
* This tag is used to add a new method to the already existing set of
* methods handled by application, or clear the set. If you want to
* determine the set explicitly, include NUTAG_APPL_METHOD() twice,
* first with NULL and then with your supported set.
*
* The default set of application methods now include INVITE, REGISTER,
* PUBLISH and SUBSCRIBE.
*
* If the request method is in the set of methods handled by application,
* the nua stack does not automatically respond to the incoming request nor
* it will automatically send such a request. Note if the application adds
* the PRACK and UPDATE requests to the set of application methods it must
* also take care for sending the PRACK and UPDATE requests during the call
* setup when necessary.
*
* @par Used with
* nua_set_params() \n
* nua_set_hparams() \n
* any handle-specific nua call
*
* @par Parameter type
* char const *
*
* @par Values
* Valid method name, or comma-separated list of them.
*
* Corresponding tag taking reference parameter is NUTAG_APPL_METHOD_REF()
*
* @since Working since @VERSION_1_12_5.
*/
#define NUTAG_APPL_METHOD(x) nutag_appl_method, tag_str_v(x)
SOFIAPUBVAR tag_typedef_t nutag_appl_method;
#define NUTAG_APPL_METHOD_REF(x) nutag_appl_method_ref, tag_str_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_appl_method_ref;
/** Support a feature.
*
* This tag is used to add a new feature to the existing set of supported
......
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