Hi,
I've reworked nua_stack_init_transport (from nua_register.c) to look for
multiple instances of NUTAG_URL and NUTAG_SIPS_URL in the tag list. The
old nua_stack_init_transport ignored all but the last instance of
NUTAG_URL and/or NUTAG_SIPS_URL.
This change makes the behaviour of nua_create consistent with the
documentation for NUTAG_URL and NUTAG_SIPS_URL.
Following is my implementation. I've tested it with NUTAG_URL, but I
haven't tested it with NUTAG_SIPS_URL. Could someone please have a look
over it?
Cheers,
--JT
int
nua_stack_init_transport(nua_t *nua, tagi_t const *tags)
{
char const *certificate_dir = NULL;
int bind_count = 0;
tagi_t const *t;
/* Fetch the certificate directory path from the tag list (if provided)
*/
tl_gets(tags,
NUTAG_CERTIFICATE_DIR_REF(certificate_dir),
TAG_END());
/* Scan the tag list for instances of NUTAG_URL or NUTAG_SIPS_URL and
bind to each specified contact URL */
for (t = tags; t; t = tl_next(t)) {
tag_type_t tt = t->t_tag;
if ((nutag_url == tt) || (nutag_sips_url == tt)) {
char const *name;
url_string_t const *contact = (url_string_t const *)t->t_value;
if (url_is_string(contact)
? strncasecmp(contact->us_str, "sips:", 5) == 0
: contact->us_url->url_type == url_sips) {
name = "sips";
} else {
name = "sip";
}
if (nta_agent_add_tport(nua->nua_nta, contact,
TPTAG_IDENT(name),
TPTAG_CERTIFICATE(certificate_dir),
TAG_NEXT(nua->nua_args)) < 0)
return -1;
bind_count++;
}
}
/* If no URLs were specified, bind to ALL (use wildcards). */
if (bind_count == 0) {
if (nta_agent_add_tport(nua->nua_nta, NULL,
TPTAG_IDENT("sip"),
TPTAG_CERTIFICATE(certificate_dir),
TAG_NEXT(nua->nua_args)) < 0 &&
nta_agent_add_tport(nua->nua_nta, URL_STRING_MAKE("sip:*:*"),
TPTAG_IDENT("sip"),
TPTAG_CERTIFICATE(certificate_dir),
TAG_NEXT(nua->nua_args)) < 0)
return -1;
#if HAVE_SOFIA_STUN
if (stun_is_requested(TAG_NEXT(nua->nua_args)) &&
nta_agent_add_tport(nua->nua_nta,
URL_STRING_MAKE("sip:0.0.0.0:*"),
TPTAG_IDENT("stun"),
TPTAG_PUBLIC(tport_type_stun), /* use stun */
TPTAG_CERTIFICATE(certificate_dir),
TAG_NEXT(nua->nua_args)) < 0) {
SU_DEBUG_0(("nua: error initializing STUN transport\n"));
}
#endif
}
/* Assuming all the binds succeeded (because we would have returned
already if
any of the binds had failed), initialize the registrations. */
if (nua_stack_init_registrations(nua) < 0)
return -1;
return 0;
}
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Sofia-sip-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel