[sofia-sip] Add urn: scheme support to sofia. (#445)

As an effort to support NENA i3 specs for NG 9-1-1, this adds support
for INVITE URI appearing as urn:service:sos to request for emergency services.

Reference for URN support in RFC 6061 https://tools.ietf.org/html/rfc6061
This commit is contained in:
CAUCA 9-1-1 2020-05-12 14:58:33 -04:00 committed by GitHub
parent 8f8edfbd01
commit 770ed14f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 17 additions and 5 deletions

View File

@ -1 +1 @@
Sat May 09 16:04:04 UTC 2020 Tue May 12 18:04:14 UTC 2020

View File

@ -389,6 +389,7 @@ int response_to_subscribe(nea_t *nea,
for (m = sip->sip_contact; m; m = m->m_next) { for (m = sip->sip_contact; m; m = m->m_next) {
if (m->m_url->url_type == url_sip || if (m->m_url->url_type == url_sip ||
m->m_url->url_type == url_urn ||
m->m_url->url_type == url_sips) m->m_url->url_type == url_sips)
break; break;
} }

View File

@ -1581,7 +1581,7 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
url_sanitize(dp); url_sanitize(dp);
if (dp == NULL || dp->url_type == url_sip || dp->url_type == url_sips) { if (dp == NULL || dp->url_type == url_sip || dp->url_type == url_sips || dp->url_type == url_urn) {
if (agent->sa_default_proxy) if (agent->sa_default_proxy)
su_free(home, agent->sa_default_proxy); su_free(home, agent->sa_default_proxy);
agent->sa_default_proxy = dp; agent->sa_default_proxy = dp;
@ -2160,7 +2160,7 @@ int nta_agent_add_tport(nta_agent_t *self,
} }
if (!(url = url_hdup(self->sa_home, uri->us_url)) || if (!(url = url_hdup(self->sa_home, uri->us_url)) ||
(url->url_type != url_sip && url->url_type != url_sips)) { (url->url_type != url_sip && url->url_type != url_sips && url->url_type != url_urn)) {
if (url_string_p(uri)) if (url_string_p(uri))
SU_DEBUG_1(("nta: %s: invalid bind URL\n", uri->us_str)); SU_DEBUG_1(("nta: %s: invalid bind URL\n", uri->us_str));
else else
@ -2173,7 +2173,7 @@ int nta_agent_add_tport(nta_agent_t *self,
tpn->tpn_host = url->url_host; tpn->tpn_host = url->url_host;
tpn->tpn_port = url_port(url); tpn->tpn_port = url_port(url);
if (url->url_type == url_sip) { if (url->url_type == url_sip || url->url_type == url_urn) {
tpn->tpn_proto = "*"; tpn->tpn_proto = "*";
tports = tports_sip; tports = tports_sip;
if (!tpn->tpn_port || !tpn->tpn_port[0]) if (!tpn->tpn_port || !tpn->tpn_port[0])
@ -2660,6 +2660,7 @@ nta_tpn_by_url(su_home_t *home,
} }
if (url->url_type != url_sip && if (url->url_type != url_sip &&
url->url_type != url_urn &&
url->url_type != url_sips && url->url_type != url_sips &&
url->url_type != url_im && url->url_type != url_im &&
url->url_type != url_pres) { url->url_type != url_pres) {

View File

@ -1280,6 +1280,7 @@ int can_redirect(sip_contact_t const *m, sip_method_t method)
enum url_type_e type = (enum url_type_e)m->m_url->url_type; enum url_type_e type = (enum url_type_e)m->m_url->url_type;
return return
type == url_sip || type == url_sip ||
type == url_urn ||
type == url_sips || type == url_sips ||
(type == url_tel && (type == url_tel &&
(method == sip_method_invite || method == sip_method_message)) || (method == sip_method_invite || method == sip_method_message)) ||

View File

@ -887,6 +887,7 @@ static int nua_register_client_response(nua_client_request_t *cr,
for (m = sip->sip_contact; m; m = m->m_next) { for (m = sip->sip_contact; m; m = m->m_next) {
if (m->m_url->url_type != url_sip && if (m->m_url->url_type != url_sip &&
m->m_url->url_type != url_urn &&
m->m_url->url_type != url_sips) m->m_url->url_type != url_sips)
continue; continue;

View File

@ -122,6 +122,7 @@ int nua_stack_process_request(nua_handle_t *nh,
switch (sip->sip_request->rq_url->url_type) { switch (sip->sip_request->rq_url->url_type) {
case url_sip: case url_sip:
case url_urn:
case url_sips: case url_sips:
case url_im: case url_im:
case url_pres: case url_pres:

View File

@ -278,7 +278,7 @@ sres_sip_new(sres_resolver_t *sres,
srs->srs_url = u = url_hdup(srs->srs_home, (url_t *)uri); srs->srs_url = u = url_hdup(srs->srs_home, (url_t *)uri);
if (u == NULL) if (u == NULL)
return sres_sip_fatal(srs, SRES_SIP_ERR_BAD_URI); return sres_sip_fatal(srs, SRES_SIP_ERR_BAD_URI);
if (u->url_type != url_sip && u->url_type != url_sips) if (u->url_type != url_sip && u->url_type != url_urn && u->url_type != url_sips)
return sres_sip_fatal(srs, SRES_SIP_ERR_BAD_URI); return sres_sip_fatal(srs, SRES_SIP_ERR_BAD_URI);
/* RFC 3263: /* RFC 3263:

View File

@ -44,6 +44,7 @@ enum url_type_e {
url_any = 0, /**< "*" */ url_any = 0, /**< "*" */
url_sip, /**< "sip:". @sa @RFC3261 */ url_sip, /**< "sip:". @sa @RFC3261 */
url_sips, /**< "sips:". @sa @RFC3261 */ url_sips, /**< "sips:". @sa @RFC3261 */
url_urn, /**< "urn:". @sa @RFC6061 */
url_tel, /**< "tel:" @sa RFC3966 */ url_tel, /**< "tel:" @sa RFC3966 */
url_fax, /**< "fax:". @note Obsolete. @sa @RFC2806 */ url_fax, /**< "fax:". @note Obsolete. @sa @RFC2806 */
url_modem, /**< "modem:". @note Obsolete. @sa @RFC2806 */ url_modem, /**< "modem:". @note Obsolete. @sa @RFC2806 */

View File

@ -257,6 +257,7 @@ int test_sip(void)
BEGIN(); BEGIN();
TEST_S(url_scheme(url_sip), "sip"); TEST_S(url_scheme(url_sip), "sip");
TEST_S(url_scheme(url_urn), "urn");
TEST_S(url_scheme(url_sips), "sips"); TEST_S(url_scheme(url_sips), "sips");
memset(url, 255, sizeof url); memset(url, 255, sizeof url);

View File

@ -477,6 +477,7 @@ char const* url_scheme(enum url_type_e url_type)
case url_cid: return "cid"; case url_cid: return "cid";
case url_msrp: return "msrp"; case url_msrp: return "msrp";
case url_msrps: return "msrps"; case url_msrps: return "msrps";
case url_urn: return "urn";
case url_wv: return "wv"; case url_wv: return "wv";
default: default:
assert(url_type == url_unknown); assert(url_type == url_unknown);
@ -535,6 +536,8 @@ enum url_type_e url_get_type(char const *scheme, size_t len)
test_scheme(sip); test_scheme(sips); break; test_scheme(sip); test_scheme(sips); break;
case 't': case 'T': case 't': case 'T':
test_scheme(tel); break; test_scheme(tel); break;
case 'u': case 'U':
test_scheme(urn); break;
case 'w': case 'W': case 'w': case 'W':
test_scheme(wv); break; test_scheme(wv); break;
@ -1796,6 +1799,7 @@ char const *url_port_default(enum url_type_e url_type)
return "9999"; /* XXXX */ return "9999"; /* XXXX */
case url_tel: case url_tel:
case url_urn:
case url_fax: case url_fax:
case url_modem: case url_modem:
case url_im: case url_im:
@ -1841,6 +1845,7 @@ char const *url_tport_default(enum url_type_e url_type)
case url_im: case url_im:
case url_pres: case url_pres:
case url_cid: case url_cid:
case url_urn:
case url_wv: case url_wv:
default: /* Unknown scheme */ default: /* Unknown scheme */