add NUTAG_WS_URL and NUTAG_WSS_URL tags

This commit is contained in:
Anthony Minessale 2013-01-25 17:23:29 -06:00
parent e31c74b638
commit 99559a3cd3
5 changed files with 101 additions and 2 deletions

View File

@ -2053,8 +2053,8 @@ const sipdns_tports[SIPDNS_TRANSPORTS] = {
{ "tcp", "5060", "_sip._tcp.", "SIP+D2T" },
{ "sctp", "5060", "_sip._sctp.", "SIP+D2S" },
{ "tls", "5061", "_sips._tcp.", "SIPS+D2T" },
{ "ws", "5066", "_sips._ws.", "SIP+D2W" },
{ "wss", "5067", "_sips._wss.", "SIPS+D2W" },
{ "ws", "5080", "_sips._ws.", "SIP+D2W" },
{ "wss", "5081", "_sips._wss.", "SIPS+D2W" },
};
static char const * const tports_sip[] =

View File

@ -1248,6 +1248,14 @@ int nua_handle_save_tags(nua_handle_t *nh, tagi_t *tags)
else if (t->t_tag == nutag_sips_url) {
url = (url_string_t *)t->t_value;
}
/* NUTAG_WS_URL_REF(url) */
else if (t->t_tag == nutag_ws_url) {
url = (url_string_t *)t->t_value;
}
/* NUTAG_WSS_URL_REF(url) */
else if (t->t_tag == nutag_wss_url) {
url = (url_string_t *)t->t_value;
}
}
su_home_auto(tmphome, sizeof tmphome);
@ -1314,6 +1322,8 @@ static int nua_handle_param_filter(tagi_t const *f, tagi_t const *t)
if (t->t_tag == nutag_url ||
t->t_tag == nutag_sips_url ||
t->t_tag == nutag_ws_url ||
t->t_tag == nutag_wss_url ||
t->t_tag == nutag_identity)
return 0;

View File

@ -1149,12 +1149,16 @@ int
nua_stack_init_transport(nua_t *nua, tagi_t const *tags)
{
url_string_t const *contact1 = NULL, *contact2 = NULL;
url_string_t const *contact3 = NULL, *contact4 = NULL;
char const *name1 = "sip", *name2 = "sip";
char const *name3 = "sip", *name4 = "sip";
char const *certificate_dir = NULL;
tl_gets(tags,
NUTAG_URL_REF(contact1),
NUTAG_SIPS_URL_REF(contact2),
NUTAG_WS_URL_REF(contact3),
NUTAG_WSS_URL_REF(contact4),
NUTAG_CERTIFICATE_DIR_REF(certificate_dir),
TAG_END());
@ -1173,6 +1177,18 @@ nua_stack_init_transport(nua_t *nua, tagi_t const *tags)
: contact2->us_url->url_type == url_sips))
name2 = "sips";
if (contact3 &&
(url_is_string(contact3)
? su_casenmatch(contact3->us_str, "sips:", 5)
: contact3->us_url->url_type == url_sips))
name3 = "sips";
if (contact4 &&
(url_is_string(contact4)
? su_casenmatch(contact4->us_str, "sips:", 5)
: contact4->us_url->url_type == url_sips))
name4 = "sips";
if (!contact1 /* && !contact2 */) {
if (nta_agent_add_tport(nua->nua_nta, NULL,
TPTAG_IDENT("sip"),
@ -1207,6 +1223,20 @@ nua_stack_init_transport(nua_t *nua, tagi_t const *tags)
TPTAG_CERTIFICATE(certificate_dir),
TAG_NEXT(nua->nua_args)) < 0)
return -1;
if (contact3 &&
nta_agent_add_tport(nua->nua_nta, contact3,
TPTAG_IDENT(name3),
TPTAG_CERTIFICATE(certificate_dir),
TAG_NEXT(nua->nua_args)) < 0)
return -1;
if (contact4 &&
nta_agent_add_tport(nua->nua_nta, contact4,
TPTAG_IDENT(name4),
TPTAG_CERTIFICATE(certificate_dir),
TAG_NEXT(nua->nua_args)) < 0)
return -1;
}

View File

@ -1621,6 +1621,55 @@ tag_typedef_t nutag_sips_url = URLTAG_TYPEDEF(sips_url);
* Reference tag for NUTAG_SIPS_URL().
*/
/**@def NUTAG_WS_URL(x)
*
* Local WS url.
*
* The application can specify an alternative local address for
* NUA user agent engine. Usually the alternative address is a
* SIP URI (WS) used with websocket transport.
*
* @par Used with
* nua_create()
*
* @par Parameter type
* char const *
*
* @par Values
*
* Corresponding tag taking reference parameter is NUTAG_WS_URL_REF().
*/
tag_typedef_t nutag_ws_url = URLTAG_TYPEDEF(ws_url);
/**@def NUTAG_WS_URL_REF(x)
* Reference tag for NUTAG_WS_URL().
*/
/**@def NUTAG_WSS_URL(x)
*
* Local WSS url.
*
* The application can specify an alternative local address for
* NUA user agent engine. Usually the alternative address is a
* secure SIP URI (WSS) used with secure websocket transport.
*
* @par Used with
* nua_create()
*
* @par Parameter type
* char const *
*
* @par Values
*
* Corresponding tag taking reference parameter is NUTAG_WSS_URL_REF().
*/
tag_typedef_t nutag_wss_url = URLTAG_TYPEDEF(wss_url);
/**@def NUTAG_WSS_URL_REF(x)
* Reference tag for NUTAG_WSS_URL().
*/
/**@def NUTAG_CERTIFICATE_DIR(x)
*

View File

@ -286,6 +286,16 @@ SOFIAPUBVAR tag_typedef_t nutag_sips_url;
#define NUTAG_SIPS_URL_REF(x) nutag_sips_url_ref, urltag_url_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_sips_url_ref;
#define NUTAG_WS_URL(x) nutag_ws_url, urltag_url_v(x)
SOFIAPUBVAR tag_typedef_t nutag_ws_url;
#define NUTAG_WS_URL_REF(x) nutag_ws_url_ref, urltag_url_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_ws_url_ref;
#define NUTAG_WSS_URL(x) nutag_wss_url, urltag_url_v(x)
SOFIAPUBVAR tag_typedef_t nutag_wss_url;
#define NUTAG_WSS_URL_REF(x) nutag_wss_url_ref, urltag_url_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_wss_url_ref;
#define NUTAG_PROXY(x) NTATAG_DEFAULT_PROXY(x)
#define NUTAG_PROXY_REF(x) NTATAG_DEFAULT_PROXY_REF(x)
#define nutag_proxy ntatag_default_proxy