Commit b3929541 authored by Pekka Pessi's avatar Pekka Pessi

nua: added handle/nua parameters for Allow-Events header.

Added tag NUTAG_ALLOW_EVENTS().

Modified sofia-sip/nua_tag.h, nua_params.h, nua_params.c, test_nua_params.c.

darcs-hash:20061017154708-65a35-af0546c66c85aa7e1d075670100d2df77f4c13a6.gz
parent 78c72b5a
......@@ -271,6 +271,7 @@ int nua_stack_init_instance(nua_handle_t *nh, tagi_t const *tags)
*
* @par Related tags:
* NUTAG_ALLOW() \n
* NUTAG_ALLOW_EVENTS() \n
* NUTAG_AUTOACK() \n
* NUTAG_AUTOALERT() \n
* NUTAG_AUTOANSWER() \n
......@@ -317,6 +318,8 @@ int nua_stack_init_instance(nua_handle_t *nh, tagi_t const *tags)
* NUTAG_USER_AGENT() \n
* SIPTAG_ALLOW() \n
* SIPTAG_ALLOW_STR() \n
* SIPTAG_ALLOW_EVENTS() \n
* SIPTAG_ALLOW_EVENTS_STR() \n
* SIPTAG_FROM() \n
* SIPTAG_FROM_STR() \n
* SIPTAG_ORGANIZATION() \n
......@@ -395,6 +398,7 @@ int nua_stack_init_instance(nua_handle_t *nh, tagi_t const *tags)
*
* @par Tags Used to Set Handle-Specific Parameters:
* NUTAG_ALLOW() \n
* NUTAG_ALLOW_EVENTS() \n
* NUTAG_AUTOACK() \n
* NUTAG_AUTOALERT() \n
* NUTAG_AUTOANSWER() \n
......@@ -433,6 +437,8 @@ int nua_stack_init_instance(nua_handle_t *nh, tagi_t const *tags)
* NUTAG_USER_AGENT() \n
* SIPTAG_ALLOW() \n
* SIPTAG_ALLOW_STR() \n
* SIPTAG_ALLOW_EVENTS() \n
* SIPTAG_ALLOW_EVENTS_STR() \n
* SIPTAG_ORGANIZATION() \n
* SIPTAG_ORGANIZATION_STR() \n
* SIPTAG_SUPPORTED() \n
......@@ -465,6 +471,7 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
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;
enter;
......@@ -477,6 +484,8 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
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;
error = 0;
global = nh == dnh; /* save also stack-specific params */
......@@ -492,6 +501,8 @@ int nua_stack_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
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;
/* Move parameters from tmp to nhp (or allocate new nhp) */
if (nh != dnh && nhp == dnh->nh_prefs)
......@@ -738,9 +749,9 @@ static int nhp_set_tags(su_home_t *home,
NHP_SET(nhp, win_messenger_enable, value != 0);
}
#if 0
/* NUTAG_MESSAGE_AUTOANSWER(message_auto_respond) */
else if (tag == nutag_message_autoanwer) {
NHP_SET(nhp, message_auto_respond, value);
/* NUTAG_AUTORESPOND(autorespond) */
else if (tag == nutag_autorespond) {
NHP_SET(nhp, autorespond, value);
}
#endif
/* NUTAG_CALLEE_CAPS(callee_caps) */
......@@ -820,6 +831,27 @@ static int nhp_set_tags(su_home_t *home,
else if (ok)
NHP_SET(nhp, allow, allow);
}
/* NUTAG_ALLOW_EVENTS(allow_events) */
/* SIPTAG_ALLOW_EVENTS_STR(allow_events) */
/* SIPTAG_ALLOW_EVENTS(allow_events) */
else if (tag == nutag_allow_events ||
tag == siptag_allow_events_str ||
tag == siptag_allow_events) {
int ok;
sip_allow_events_t *allow_events = NULL;
ok = nhp_merge_lists(home,
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 */
tag == nutag_allow_events, /* merge with old value */
t->t_value);
if (ok < 0)
return -1;
else if (ok)
NHP_SET(nhp, allow_events, allow_events);
}
/* SIPTAG_USER_AGENT(user_agent) */
else if (tag == siptag_user_agent) {
NHP_SET_STR_BY_HEADER(nhp, user_agent, value);
......@@ -1290,7 +1322,6 @@ int nua_stack_set_smime_params(nua_t *nua, tagi_t const *tags)
* @param hmagic NULL
* @param sip NULL
* @param tags
* NUTAG_ALLOW() \n
* NUTAG_AUTOACK() \n
* NUTAG_AUTOALERT() \n
* NUTAG_AUTOANSWER() \n
......@@ -1332,11 +1363,12 @@ int nua_stack_set_smime_params(nua_t *nua, tagi_t const *tags)
* NUTAG_SMIME_SIGNATURE() \n
* NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n
* NUTAG_SUPPORTED() \n
* NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT() \n
* SIPTAG_ALLOW() \n
* SIPTAG_ALLOW_STR() \n
* SIPTAG_ALLOW_EVENTS() \n
* SIPTAG_ALLOW_EVENTS_STR() \n
* SIPTAG_FROM() \n
* SIPTAG_FROM_STR() \n
* SIPTAG_ORGANIZATION() \n
......@@ -1462,7 +1494,7 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
TIF(NUTAG_ENABLEMESSAGE, message_enable),
TIF(NUTAG_ENABLEMESSENGER, win_messenger_enable),
/* TIF(NUTAG_MESSAGE_AUTOANSWER, message_auto_respond), */
/* TIF(NUTAG_AUTORESPOND, autorespond), */
TIF(NUTAG_CALLEE_CAPS, callee_caps),
TIF(NUTAG_MEDIA_FEATURES, media_features),
......@@ -1477,6 +1509,8 @@ int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
TIF_STR(SIPTAG_SUPPORTED_STR, supported),
TIF(SIPTAG_ALLOW, allow),
TIF_STR(SIPTAG_ALLOW_STR, allow),
TIF(SIPTAG_ALLOW_EVENTS, allow_events),
TIF_STR(SIPTAG_ALLOW_EVENTS_STR, allow_events),
TIF_SIP(SIPTAG_USER_AGENT, user_agent),
TIF(SIPTAG_USER_AGENT_STR, user_agent),
TIF(NUTAG_USER_AGENT, user_agent),
......
......@@ -112,6 +112,7 @@ typedef struct nua_handle_preferences
sip_allow_t *nhp_allow;
sip_supported_t *nhp_supported;
sip_allow_events_t *nhp_allow_events;
char const *nhp_user_agent;
char const *nhp_organization;
......@@ -163,8 +164,9 @@ typedef struct nua_handle_preferences
unsigned nhb_allow:1;
unsigned nhb_supported:1;
unsigned nhb_user_agent:1;
unsigned nhb_allow_events:1;
unsigned :0; /* at most 32 bits ... */
unsigned nhb_user_agent:1;
unsigned nhb_organization:1;
unsigned nhb_m_display:1;
......
......@@ -136,6 +136,7 @@ tag_typedef_t nutag_refer_event = SIPHDRTAG_NAMED_TYPEDEF(refer_event, event);
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_supported = STRTAG_TYPEDEF(supported);
tag_typedef_t nutag_path_enable = BOOLTAG_TYPEDEF(path_enable);
tag_typedef_t nutag_service_route_enable =
......
......@@ -1591,6 +1591,41 @@ SOFIAPUBVAR tag_typedef_t nutag_supported;
#define NUTAG_SUPPORTED_REF(x) nutag_supported_ref, tag_str_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_supported_ref;
/** Allow an event or events.
*
* This tag is used to add a new event to the already existing set of
* allowed events. If you want to ignore the existing set of allowed events,
* set the allowed event set with SIPTAG_ALLOW_EVENTS_STR() or
* SIPTAG_ALLOW_EVENTS().
*
* The set of allowed methods is added to the @AllowEvents header in the
* response to the SUBSCRIBE or PUBLISH requests. For incoming SUBSCRIBE or
* PUBLISH request, an error response <i>489 Bad Event</i> is automatically
* returned if the incoming method is not included in the set.
*
* @par Used with
* nua_set_params() \n
* nua_set_hparams() \n
* any handle-specific nua call
*
* @par Parameter type
* char const *
*
* @par Values
* Valid event name, or comma-separated list of them.
*
* @sa @AllowEvents, @RFC3265, @RFC3903, #nua_i_subscribe, #nua_i_publish,
* nua_subscribe(), nua_publish(), SIPTAG_ALLOW_EVENTS(),
* SIPTAG_ALLOW_EVENTS_STR()
*
* Corresponding tag taking reference parameter is NUTAG_ALLOW_EVENTS_REF()
*/
#define NUTAG_ALLOW_EVENTS(x) nutag_allow_events, tag_str_v(x)
SOFIAPUBVAR tag_typedef_t nutag_allow_events;
#define NUTAG_ALLOW_EVENTS_REF(x) nutag_allow_events_ref, tag_str_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_allow_events_ref;
/** Call state
*
* @par Used with
......
......@@ -148,6 +148,7 @@ int test_nua_params(struct context *ctx)
SIPTAG_SUPPORTED_STR("test"),
SIPTAG_ALLOW_STR("DWIM, OPTIONS, INFO"),
SIPTAG_ALLOW_EVENTS_STR("reg"),
SIPTAG_USER_AGENT_STR("test_nua/1.0"),
SIPTAG_ORGANIZATION_STR("Open Laboratory"),
......@@ -205,9 +206,15 @@ int test_nua_params(struct context *ctx)
SIPTAG_SUPPORTED(sip_supported_make(tmphome, "foo")),
NUTAG_SUPPORTED("foo, bar"),
SIPTAG_SUPPORTED_STR(",baz,"),
SIPTAG_ALLOW_STR("OPTIONS"),
SIPTAG_ALLOW(sip_allow_make(tmphome, "INFO")),
NUTAG_ALLOW("ACK, INFO"),
SIPTAG_ALLOW_EVENTS_STR("reg"),
SIPTAG_ALLOW_EVENTS(sip_allow_make(tmphome, "presence")),
NUTAG_ALLOW_EVENTS("presence.winfo"),
SIPTAG_USER_AGENT(sip_user_agent_make(tmphome, "test_nua")),
SIPTAG_ORGANIZATION(sip_organization_make(tmphome, "Pussy Galore's Flying Circus")),
......@@ -261,6 +268,8 @@ int test_nua_params(struct context *ctx)
sip_allow_t const *allow = NONE;
char const *allow_str = "NONE";
sip_allow_events_t const *allow_events = NONE;
char const *allow_events_str = "NONE";
sip_supported_t const *supported = NONE;
char const *supported_str = "NONE";
sip_user_agent_t const *user_agent = NONE;
......@@ -323,6 +332,8 @@ int test_nua_params(struct context *ctx)
SIPTAG_SUPPORTED_STR_REF(supported_str),
SIPTAG_ALLOW_REF(allow),
SIPTAG_ALLOW_STR_REF(allow_str),
SIPTAG_ALLOW_EVENTS_REF(allow_events),
SIPTAG_ALLOW_EVENTS_STR_REF(allow_events_str),
SIPTAG_USER_AGENT_REF(user_agent),
SIPTAG_USER_AGENT_STR_REF(user_agent_str),
NUTAG_USER_AGENT_REF(ua_name),
......@@ -342,7 +353,7 @@ int test_nua_params(struct context *ctx)
NUTAG_INSTANCE_REF(instance),
TAG_END());
TEST(n, 44);
TEST(n, 46);
TEST_S(sip_header_as_string(tmphome, (void *)from), Alice);
TEST_S(from_str, Alice);
......@@ -378,6 +389,9 @@ int test_nua_params(struct context *ctx)
TEST_S(sip_header_as_string(tmphome, (void *)allow), "OPTIONS, INFO, ACK");
TEST_S(allow_str, "OPTIONS, INFO, ACK");
TEST_S(sip_header_as_string(tmphome, (void *)allow_events),
"reg, presence, presence.winfo");
TEST_S(allow_events_str, "reg, presence, presence.winfo");
TEST_S(sip_header_as_string(tmphome, (void *)supported),
"foo, bar, baz");
TEST_S(supported_str, "foo, bar, baz");
......
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