From 770ed14f447aa6f2b37017b97fe924d6cc1d8ba3 Mon Sep 17 00:00:00 2001 From: CAUCA 9-1-1 <60942644+cauca-signalwire@users.noreply.github.com> Date: Tue, 12 May 2020 14:58:33 -0400 Subject: [PATCH] [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 --- libs/sofia-sip/.update | 2 +- libs/sofia-sip/libsofia-sip-ua/nea/nea.c | 1 + libs/sofia-sip/libsofia-sip-ua/nta/nta.c | 7 ++++--- libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c | 1 + libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c | 1 + libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c | 1 + libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c | 2 +- libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h | 1 + libs/sofia-sip/libsofia-sip-ua/url/torture_url.c | 1 + libs/sofia-sip/libsofia-sip-ua/url/url.c | 5 +++++ 10 files changed, 17 insertions(+), 5 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index e6af7a2165..f2ecef0016 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Sat May 09 16:04:04 UTC 2020 +Tue May 12 18:04:14 UTC 2020 diff --git a/libs/sofia-sip/libsofia-sip-ua/nea/nea.c b/libs/sofia-sip/libsofia-sip-ua/nea/nea.c index 1f58a18e10..29afcd71c4 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nea/nea.c +++ b/libs/sofia-sip/libsofia-sip-ua/nea/nea.c @@ -389,6 +389,7 @@ int response_to_subscribe(nea_t *nea, for (m = sip->sip_contact; m; m = m->m_next) { if (m->m_url->url_type == url_sip || + m->m_url->url_type == url_urn || m->m_url->url_type == url_sips) break; } diff --git a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c index 07bab4f6eb..d4ed20ed78 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c +++ b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c @@ -1581,7 +1581,7 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags) 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) su_free(home, agent->sa_default_proxy); 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)) || - (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)) SU_DEBUG_1(("nta: %s: invalid bind URL\n", uri->us_str)); else @@ -2173,7 +2173,7 @@ int nta_agent_add_tport(nta_agent_t *self, tpn->tpn_host = url->url_host; 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 = "*"; tports = tports_sip; 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 && + url->url_type != url_urn && url->url_type != url_sips && url->url_type != url_im && url->url_type != url_pres) { diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c index 969fff6e93..a3e692dea7 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c @@ -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; return type == url_sip || + type == url_urn || type == url_sips || (type == url_tel && (method == sip_method_invite || method == sip_method_message)) || diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c index df375b54b7..5c2fa1a33b 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c @@ -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) { if (m->m_url->url_type != url_sip && + m->m_url->url_type != url_urn && m->m_url->url_type != url_sips) continue; diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c index cf8e23577d..0acfba5a87 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c @@ -122,6 +122,7 @@ int nua_stack_process_request(nua_handle_t *nh, switch (sip->sip_request->rq_url->url_type) { case url_sip: + case url_urn: case url_sips: case url_im: case url_pres: diff --git a/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c b/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c index 9dd0e3f347..296cad5fb6 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c +++ b/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_sip.c @@ -278,7 +278,7 @@ sres_sip_new(sres_resolver_t *sres, srs->srs_url = u = url_hdup(srs->srs_home, (url_t *)uri); if (u == NULL) 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); /* RFC 3263: diff --git a/libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h b/libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h index caeb2133b0..4ea520825a 100644 --- a/libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h +++ b/libs/sofia-sip/libsofia-sip-ua/url/sofia-sip/url.h @@ -44,6 +44,7 @@ enum url_type_e { url_any = 0, /**< "*" */ url_sip, /**< "sip:". @sa @RFC3261 */ url_sips, /**< "sips:". @sa @RFC3261 */ + url_urn, /**< "urn:". @sa @RFC6061 */ url_tel, /**< "tel:" @sa RFC3966 */ url_fax, /**< "fax:". @note Obsolete. @sa @RFC2806 */ url_modem, /**< "modem:". @note Obsolete. @sa @RFC2806 */ diff --git a/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c b/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c index 4af13fb4f0..f74b7f5355 100644 --- a/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c +++ b/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c @@ -257,6 +257,7 @@ int test_sip(void) BEGIN(); TEST_S(url_scheme(url_sip), "sip"); + TEST_S(url_scheme(url_urn), "urn"); TEST_S(url_scheme(url_sips), "sips"); memset(url, 255, sizeof url); diff --git a/libs/sofia-sip/libsofia-sip-ua/url/url.c b/libs/sofia-sip/libsofia-sip-ua/url/url.c index 71544735e1..81de531ddc 100644 --- a/libs/sofia-sip/libsofia-sip-ua/url/url.c +++ b/libs/sofia-sip/libsofia-sip-ua/url/url.c @@ -477,6 +477,7 @@ char const* url_scheme(enum url_type_e url_type) case url_cid: return "cid"; case url_msrp: return "msrp"; case url_msrps: return "msrps"; + case url_urn: return "urn"; case url_wv: return "wv"; default: 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; case 't': case 'T': test_scheme(tel); break; + case 'u': case 'U': + test_scheme(urn); break; case 'w': case 'W': test_scheme(wv); break; @@ -1796,6 +1799,7 @@ char const *url_port_default(enum url_type_e url_type) return "9999"; /* XXXX */ case url_tel: + case url_urn: case url_fax: case url_modem: case url_im: @@ -1841,6 +1845,7 @@ char const *url_tport_default(enum url_type_e url_type) case url_im: case url_pres: case url_cid: + case url_urn: case url_wv: default: /* Unknown scheme */