Commit c37b0bb1 authored by Pekka Pessi's avatar Pekka Pessi

Added NUTAG_ALLOW() and NUTAG_ALLOW_REF() to nua.

darcs-hash:20051028162218-65a35-4f535ff019c2397da647527ab13d1d5d7282e745.gz
parent fe532eb6
......@@ -108,6 +108,15 @@ typedef struct sdp_session_s sdp_session_t;
typedef unsigned longlong ull;
#define SET_STATUS(_status, _phrase) status = _status, phrase = _phrase
/* This is interesting macro:
* x expands to "num, str", num is assigned to status, str to phrase.
* Macro expands to two comma-separated expressions
* usable as function arguments
*/
#define SET_STATUS1(x) ((status = x), status), (phrase = ((void)x))
/* ========================================================================
*
* Protocol stack side
......@@ -875,6 +884,8 @@ void ua_shutdown(nua_t *nua)
* Parameters
*/
#include <msg_parser.h>
int ua_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
tagi_t const *tags)
{
......@@ -910,6 +921,7 @@ int ua_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
sip_allow_t const *allow = NONE;
char const *allow_str = NONE;
char const *allowing = NULL;
sip_supported_t const *supported = NONE;
char const *supported_str = NONE;
sip_user_agent_t const *user_agent = NONE;
......@@ -970,8 +982,11 @@ int ua_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
SIPTAG_SUPPORTED_REF(supported),
SIPTAG_SUPPORTED_STR_REF(supported_str),
SIPTAG_ALLOW_REF(allow),
SIPTAG_ALLOW_STR_REF(allow_str),
NUTAG_ALLOW_REF(allowing),
SIPTAG_USER_AGENT_REF(user_agent),
SIPTAG_USER_AGENT_STR_REF(user_agent_str),
NUTAG_USER_AGENT_REF(ua_name),
......@@ -1081,8 +1096,26 @@ int ua_set_params(nua_t *nua, nua_handle_t *nh, nua_event_t e,
} \
}
/* Add contents of NUTAG_ALLOW() to list of currently allowed methods */
if (allow == NONE && allow_str == NONE && allowing != NULL) {
sip_allow_t *methods = sip_allow_make(tmphome, allowing);
if (methods)
allow = sip_allow_dup(tmphome, NHP_GET(ohp, dnhp, allow));
if (allow == NULL)
allow = NONE;
if (allow != NONE)
if (msg_params_join(tmphome,
(msg_param_t **)&allow->k_items, methods->k_items,
1 /* prune */, 0 /* don't dup */) < 0)
allow = NONE;
}
NHP_SET_HEADER(nhp, supported, supported, supported_str);
NHP_SET_HEADER(nhp, allow, allow, allow_str);
/* Add contents of NUTAG_USER_AGENT() to our distribution name */
if (ua_name != NONE && user_agent_str == NONE && user_agent == NONE)
user_agent_str = ua_name
? su_sprintf(tmphome, "%s %s", ua_name, PACKAGE_NAME "/" PACKAGE_VERSION)
......
......@@ -444,8 +444,6 @@ extern char const nua_500_error[];
#define NUA_500_ERROR 500, nua_500_error
#define SET_STATUS(_status, _phrase) status = _status, phrase = _phrase
struct nua_s {
su_home_t nua_home[1];
......
......@@ -116,6 +116,7 @@ tag_typedef_t nutag_notify_refer = PTRTAG_TYPEDEF(notify_refer);
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_path_enable = BOOLTAG_TYPEDEF(path_enable);
tag_typedef_t nutag_service_route_enable =
BOOLTAG_TYPEDEF(service_route_enable);
......
......@@ -1016,6 +1016,27 @@ extern tag_typedef_t nutag_user_agent;
#define NUTAG_USER_AGENT_REF(x) nutag_user_agent_ref, tag_str_vr(&(x))
extern tag_typedef_t nutag_user_agent_ref;
/** Allow a method (or methods).
*
* @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_ALLOW_REF()
*/
#define NUTAG_ALLOW(x) nutag_allow, tag_str_v(x)
extern tag_typedef_t nutag_allow;
#define NUTAG_ALLOW_REF(x) nutag_allow_ref, tag_str_vr(&(x))
extern tag_typedef_t nutag_allow_ref;
/** Call state
*
* @par Used with
......
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