]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Add TEL URI support for basic calls.
authorBen Ford <bford@digium.com>
Tue, 2 Aug 2022 17:15:36 +0000 (12:15 -0500)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Tue, 13 Sep 2022 09:51:46 +0000 (04:51 -0500)
This change allows TEL URI requests to come through for basic calls. The
allowed requests are INVITE, ACK, BYE, and CANCEL. The From and To
headers will now allow TEL URIs, as well as the request URI.

Support is only for TEL URIs present in traffic from a remote party.
Asterisk does not generate any TEL URIs on its own.

ASTERISK-26894

Change-Id: If5729e6cd583be7acf666373bf9f1b9d653ec29a

18 files changed:
channels/chan_pjsip.c
configs/samples/pjsip.conf.sample
include/asterisk/res_pjsip.h
res/res_pjsip.c
res/res_pjsip/pjsip_distributor.c
res/res_pjsip/pjsip_message_filter.c
res/res_pjsip/pjsip_options.c
res/res_pjsip_caller_id.c
res/res_pjsip_dialog_info_body_generator.c
res/res_pjsip_diversion.c
res/res_pjsip_endpoint_identifier_anonymous.c
res/res_pjsip_endpoint_identifier_user.c
res/res_pjsip_messaging.c
res/res_pjsip_nat.c
res/res_pjsip_outbound_registration.c
res/res_pjsip_path.c
res/res_pjsip_pubsub.c
res/res_pjsip_session.c

index 07b908801f75cbeb4e5e8822aca85ba4f78bc8f9..3e8abd2f32165dc84b1b84dfb32b681753075dff 100644 (file)
@@ -3009,11 +3009,11 @@ static void chan_pjsip_session_end(struct ast_sip_session *session)
 
 static void set_sipdomain_variable(struct ast_sip_session *session)
 {
-       pjsip_sip_uri *sip_ruri = pjsip_uri_get_uri(session->request_uri);
-       size_t size = pj_strlen(&sip_ruri->host) + 1;
+       const pj_str_t *host = ast_sip_pjsip_uri_get_hostname(session->request_uri);
+       size_t size = pj_strlen(host) + 1;
        char *domain = ast_alloca(size);
 
-       ast_copy_pj_str(domain, &sip_ruri->host, size);
+       ast_copy_pj_str(domain, host, size);
 
        pbx_builtin_setvar_helper(session->channel, "SIPDOMAIN", domain);
        return;
index bf9f78cba50ede064c19728d2f1a4c99d3ab1a31..6fbdb8b934b8d000e63fcf5f204eb6e4cd8ffba1 100644 (file)
 
 ;mailbox_state_filter=     ; Optional regular expression used to filter what
                            ; mailboxes we accept events for.
+
+
+;================================TEL URIs=====================================
+;
+; Asterisk has TEL URI support, but with limited scope. Support is only for
+; TEL URIs present in traffic from a remote party. Asterisk does not generate
+; any TEL URIs of its own.
+;
+; Currently, the allowed request types are INVITE, ACK, BYE, and CANCEL. Any
+; other request type that contains a TEL URI will behave as it did before.
+; TEL URIs are allowed in the request, From, and To headers.
+;
+; You can match a TEL URI From header by IP, header, or auth_username.
index e688494cbf38fefb5e7336d5832a84d56b8bb948..dcdf2b392009c5185dc2fa4c44b08709df53b957 100644 (file)
@@ -105,6 +105,8 @@ struct pjsip_tpselector;
 
 AST_VECTOR(ast_sip_service_route_vector, char *);
 
+static const pj_str_t AST_PJ_STR_EMPTY = { "", 0 };
+
 /*!
  * \brief Structure for SIP transport information
  */
@@ -3692,4 +3694,65 @@ void ast_sip_transport_state_register(struct ast_sip_tpmgr_state_callback *eleme
  */
 void ast_sip_transport_state_unregister(struct ast_sip_tpmgr_state_callback *element);
 
+/*!
+ * \brief Check whether a pjsip_uri is SIP/SIPS or not
+ * \since 16.28.0
+ *
+ * \param uri The pjsip_uri to check
+ *
+ * \retval 1 if true
+ * \retval 0 if false
+ */
+int ast_sip_is_uri_sip_sips(pjsip_uri *uri);
+
+/*!
+ * \brief Check whether a pjsip_uri is allowed or not
+ * \since 16.28.0
+ *
+ * \param uri The pjsip_uri to check
+ *
+ * \retva; 1 if allowed
+ * \retval 0 if not allowed
+ */
+int ast_sip_is_allowed_uri(pjsip_uri *uri);
+
+/*!
+ * \brief Get the user portion of the pjsip_uri
+ * \since 16.28.0
+ *
+ * \param uri The pjsip_uri to get the user from
+ *
+ * \note This function will check what kind of URI it receives and return
+ * the user based off of that
+ *
+ * \return User string or empty string if not present
+ */
+const pj_str_t *ast_sip_pjsip_uri_get_username(pjsip_uri *uri);
+
+/*!
+ * \brief Get the host portion of the pjsip_uri
+ * \since 16.28.0
+ *
+ * \param uri The pjsip_uri to get the host from
+ *
+ * \note This function will check what kind of URI it receives and return
+ * the host based off of that
+ *
+ * \return Host string or empty string if not present
+ */
+const pj_str_t *ast_sip_pjsip_uri_get_hostname(pjsip_uri *uri);
+
+/*!
+ * \brief Get the other_param portion of the pjsip_uri
+ * \since 16.28.0
+ *
+ * \param uri The pjsip_uri to get hte other_param from
+ *
+ * \note This function will check what kind of URI it receives and return
+ * the other_param based off of that
+ *
+ * \return other_param or NULL if not present
+ */
+struct pjsip_param *ast_sip_pjsip_uri_get_other_param(pjsip_uri *uri, const pj_str_t *param_str);
+
 #endif /* _RES_PJSIP_H */
index 2febf3de875aee2270c89218035891ab2cd5a8b9..c6d9a8970724bbe2dc86dba56ac798948d623586 100644 (file)
@@ -2472,6 +2472,69 @@ struct ast_threadpool *ast_sip_threadpool(void)
        return sip_threadpool;
 }
 
+int ast_sip_is_uri_sip_sips(pjsip_uri *uri)
+{
+       return (PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri));
+}
+
+int ast_sip_is_allowed_uri(pjsip_uri *uri)
+{
+       return (ast_sip_is_uri_sip_sips(uri) || PJSIP_URI_SCHEME_IS_TEL(uri));
+}
+
+const pj_str_t *ast_sip_pjsip_uri_get_username(pjsip_uri *uri)
+{
+       if (ast_sip_is_uri_sip_sips(uri)) {
+               pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
+               if (!sip_uri) {
+                       return &AST_PJ_STR_EMPTY;
+               }
+               return &sip_uri->user;
+       } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
+               pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
+               if (!tel_uri) {
+                       return &AST_PJ_STR_EMPTY;
+               }
+               return &tel_uri->number;
+       }
+
+       return &AST_PJ_STR_EMPTY;
+}
+
+const pj_str_t *ast_sip_pjsip_uri_get_hostname(pjsip_uri *uri)
+{
+       if (ast_sip_is_uri_sip_sips(uri)) {
+               pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
+               if (!sip_uri) {
+                       return &AST_PJ_STR_EMPTY;
+               }
+               return &sip_uri->host;
+       } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
+               return &AST_PJ_STR_EMPTY;
+       }
+
+       return &AST_PJ_STR_EMPTY;
+}
+
+struct pjsip_param *ast_sip_pjsip_uri_get_other_param(pjsip_uri *uri, const pj_str_t *param_str)
+{
+       if (ast_sip_is_uri_sip_sips(uri)) {
+               pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
+               if (!sip_uri) {
+                       return NULL;
+               }
+               return pjsip_param_find(&sip_uri->other_param, param_str);
+       } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
+               pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
+               if (!tel_uri) {
+                       return NULL;
+               }
+               return pjsip_param_find(&tel_uri->other_param, param_str);
+       }
+
+       return NULL;
+}
+
 #ifdef TEST_FRAMEWORK
 AST_TEST_DEFINE(xml_sanitization_end_null)
 {
index ea8fb021244b038f18a73354ac86c745787e861f..092e012a773b102bf4945f6ba2b6e6964e11b8fc 100644 (file)
@@ -763,9 +763,8 @@ static pj_bool_t endpoint_lookup(pjsip_rx_data *rdata)
                char name[AST_UUID_STR_LEN] = "";
                pjsip_uri *from = rdata->msg_info.from->uri;
 
-               if (PJSIP_URI_SCHEME_IS_SIP(from) || PJSIP_URI_SCHEME_IS_SIPS(from)) {
-                       pjsip_sip_uri *sip_from = pjsip_uri_get_uri(from);
-                       ast_copy_pj_str(name, &sip_from->user, sizeof(name));
+               if (ast_sip_is_allowed_uri(from)) {
+                       ast_copy_pj_str(name, ast_sip_pjsip_uri_get_username(from), sizeof(name));
                }
 
                unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY);
@@ -833,6 +832,7 @@ static int extract_contact_addr(pjsip_contact_hdr *contact, struct ast_sockaddr
                *addrs = NULL;
                return 0;
        }
+
        if (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri)) {
                *addrs = NULL;
                return 0;
index edac55fca38324da2e3093d29b98bfd9bc802800..7f1b7d736c1972bb25205a489c58f390e5a25791 100644 (file)
@@ -190,7 +190,7 @@ static void FUNC_ATTRS sanitize_tdata(pjsip_tx_data *tdata)
        pjsip_hdr *hdr;
 
        if (tdata->msg->type == PJSIP_REQUEST_MSG) {
-               if (is_sip_uri(tdata->msg->line.req.uri)) {
+               if (ast_sip_is_uri_sip_sips(tdata->msg->line.req.uri)) {
                        uri = pjsip_uri_get_uri(tdata->msg->line.req.uri);
                        print_sanitize_debug("Sanitizing Request", PJSIP_URI_IN_REQ_URI, uri);
                        while ((x_transport = pjsip_param_find(&uri->other_param, &x_name))) {
@@ -201,7 +201,7 @@ static void FUNC_ATTRS sanitize_tdata(pjsip_tx_data *tdata)
 
        for (hdr = tdata->msg->hdr.next; hdr != &tdata->msg->hdr; hdr = hdr->next) {
                if (hdr->type == PJSIP_H_TO || hdr->type == PJSIP_H_FROM) {
-                       if (is_sip_uri(((pjsip_fromto_hdr *) hdr)->uri)) {
+                       if (ast_sip_is_uri_sip_sips(((pjsip_fromto_hdr *) hdr)->uri)) {
                                uri = pjsip_uri_get_uri(((pjsip_fromto_hdr *) hdr)->uri);
                                print_sanitize_debug("Sanitizing From/To header", PJSIP_URI_IN_FROMTO_HDR, uri);
                                while ((x_transport = pjsip_param_find(&uri->other_param, &x_name))) {
@@ -209,7 +209,7 @@ static void FUNC_ATTRS sanitize_tdata(pjsip_tx_data *tdata)
                                }
                        }
                } else if (hdr->type == PJSIP_H_CONTACT) {
-                       if (!((pjsip_contact_hdr *) hdr)->star && is_sip_uri(((pjsip_contact_hdr *) hdr)->uri)) {
+                       if (!((pjsip_contact_hdr *) hdr)->star && ast_sip_is_uri_sip_sips(((pjsip_contact_hdr *) hdr)->uri)) {
                                uri = pjsip_uri_get_uri(((pjsip_contact_hdr *) hdr)->uri);
                                print_sanitize_debug("Sanitizing Contact header", PJSIP_URI_IN_CONTACT_HDR, uri);
                                while ((x_transport = pjsip_param_find(&uri->other_param, &x_name))) {
@@ -288,7 +288,7 @@ static pj_status_t filter_on_tx_message(pjsip_tx_data *tdata)
        if (tdata->msg->type == PJSIP_REQUEST_MSG || !(cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL)) ||
                pj_strcmp2(&cseq->method.name, "REGISTER")) {
                pjsip_contact_hdr *contact = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL);
-               if (contact && (PJSIP_URI_SCHEME_IS_SIP(contact->uri) || PJSIP_URI_SCHEME_IS_SIPS(contact->uri))
+               if (contact && ast_sip_is_uri_sip_sips(contact->uri)
                        && !(tdata->msg->type == PJSIP_RESPONSE_MSG && tdata->msg->line.status.code / 100 == 3)) {
                        pjsip_sip_uri *uri = pjsip_uri_get_uri(contact->uri);
 
@@ -440,6 +440,10 @@ static void remove_x_ast_params(pjsip_uri *header_uri){
                return;
        }
 
+       if (PJSIP_URI_SCHEME_IS_TEL(header_uri)) {
+               return;
+       }
+
        uri = pjsip_uri_get_uri(header_uri);
        if (!uri) {
                return;
@@ -458,6 +462,25 @@ static void remove_x_ast_params(pjsip_uri *header_uri){
        }
 }
 
+/* An allow list helper function for tel URI requests */
+static int is_allowed_tel_uri_request(pjsip_rx_data *rdata)
+{
+       struct pjsip_request_line req = rdata->msg_info.msg->line.req;
+       const pjsip_method method = (const pjsip_method)req.method;
+
+       if (pjsip_method_cmp(&method, pjsip_get_invite_method())) {
+               return 1;
+       } else if (pjsip_method_cmp(&method, pjsip_get_ack_method())) {
+               return 1;
+       } else if (pjsip_method_cmp(&method, pjsip_get_bye_method())) {
+               return 1;
+       } else if (pjsip_method_cmp(&method, pjsip_get_cancel_method())) {
+               return 1;
+       }
+
+       return 0;
+}
+
 static pj_bool_t on_rx_process_uris(pjsip_rx_data *rdata)
 {
        pjsip_contact_hdr *contact = NULL;
@@ -466,7 +489,8 @@ static pj_bool_t on_rx_process_uris(pjsip_rx_data *rdata)
                return PJ_FALSE;
        }
 
-       if (!is_sip_uri(rdata->msg_info.msg->line.req.uri)) {
+       if (PJSIP_URI_SCHEME_IS_TEL(rdata->msg_info.msg->line.req.uri)
+               && !is_allowed_tel_uri_request(rdata)) {
                print_uri_debug(URI_TYPE_REQUEST, rdata, NULL);
                pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata,
                        PJSIP_SC_UNSUPPORTED_URI_SCHEME, NULL, NULL, NULL);
@@ -474,7 +498,7 @@ static pj_bool_t on_rx_process_uris(pjsip_rx_data *rdata)
        }
        remove_x_ast_params(rdata->msg_info.msg->line.req.uri);
 
-       if (!is_sip_uri(rdata->msg_info.from->uri)) {
+       if (!ast_sip_is_allowed_uri(rdata->msg_info.from->uri)) {
                print_uri_debug(URI_TYPE_FROM, rdata, (pjsip_hdr *)rdata->msg_info.from);
                pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata,
                        PJSIP_SC_UNSUPPORTED_URI_SCHEME, NULL, NULL, NULL);
@@ -482,7 +506,7 @@ static pj_bool_t on_rx_process_uris(pjsip_rx_data *rdata)
        }
        remove_x_ast_params(rdata->msg_info.from->uri);
 
-       if (!is_sip_uri(rdata->msg_info.to->uri)) {
+       if (!ast_sip_is_allowed_uri(rdata->msg_info.to->uri)) {
                print_uri_debug(URI_TYPE_TO, rdata, (pjsip_hdr *)rdata->msg_info.to);
                pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata,
                        PJSIP_SC_UNSUPPORTED_URI_SCHEME, NULL, NULL, NULL);
index 4f4825778908df6db23136bba0619f4e9d86e2d8..7632deadd7a74c373dda2f04f251309cb73bf49c 100644 (file)
@@ -269,7 +269,6 @@ static pj_bool_t options_on_rx_request(pjsip_rx_data *rdata)
 {
        RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
        pjsip_uri *ruri;
-       pjsip_sip_uri *sip_ruri;
        char exten[AST_MAX_EXTENSION];
 
        if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, &pjsip_options_method)) {
@@ -281,13 +280,12 @@ static pj_bool_t options_on_rx_request(pjsip_rx_data *rdata)
        }
 
        ruri = rdata->msg_info.msg->line.req.uri;
-       if (!PJSIP_URI_SCHEME_IS_SIP(ruri) && !PJSIP_URI_SCHEME_IS_SIPS(ruri)) {
+       if (!ast_sip_is_allowed_uri(ruri)) {
                send_options_response(rdata, 416);
                return PJ_TRUE;
        }
 
-       sip_ruri = pjsip_uri_get_uri(ruri);
-       ast_copy_pj_str(exten, &sip_ruri->user, sizeof(exten));
+       ast_copy_pj_str(exten, ast_sip_pjsip_uri_get_username(ruri), sizeof(exten));
 
        /*
         * We may want to match in the dialplan without any user
index 96e2cf96e40d6cef1d1fbf5fee2db7201e98c2f3..64fd8c7777bf1b8634ca8e64c695801cc9be5116 100644 (file)
@@ -45,13 +45,11 @@ static void set_id_from_hdr(pjsip_fromto_hdr *hdr, struct ast_party_id *id)
 {
        char cid_name[AST_CHANNEL_NAME];
        char cid_num[AST_CHANNEL_NAME];
-       pjsip_sip_uri *uri;
        pjsip_name_addr *id_name_addr = (pjsip_name_addr *) hdr->uri;
        char *semi;
 
-       uri = pjsip_uri_get_uri(id_name_addr);
        ast_copy_pj_str(cid_name, &id_name_addr->display, sizeof(cid_name));
-       ast_copy_pj_str(cid_num, &uri->user, sizeof(cid_num));
+       ast_copy_pj_str(cid_num, ast_sip_pjsip_uri_get_username(hdr->uri), sizeof(cid_num));
 
        /* Always truncate caller-id number at a semicolon. */
        semi = strchr(cid_num, ';');
index 972b90874936fa94fcedf0c545340e3a823a0c0b..9efb15492b2c7d75f37987a6a40872c96eafff75 100644 (file)
@@ -183,7 +183,6 @@ static int dialog_info_generate_body_content(void *body, void *data)
                        int remote_connected_num_restricted;
                        char *local_caller_num;
                        pjsip_dialog *dlg = ast_sip_subscription_get_dialog(state_data->sub);
-                       pjsip_sip_uri *dlg_remote_fromhdr = pjsip_uri_get_uri(dlg->local.info->uri);
                        char remote_target[PJSIP_MAX_URL_SIZE + 32];
                        char dlg_remote_uri[PJSIP_MAX_URL_SIZE];
                        char *from_domain_stripped;
@@ -191,7 +190,7 @@ static int dialog_info_generate_body_content(void *body, void *data)
                        pj_xml_node *remote_node, *remote_identity_node, *remote_target_node;
 
                        /* We use the local dialog URI to determine the domain to use in the XML itself */
-                       ast_copy_pj_str(dlg_remote_uri, &dlg_remote_fromhdr->host, sizeof(dlg_remote_uri));
+                       ast_copy_pj_str(dlg_remote_uri, ast_sip_pjsip_uri_get_hostname(dlg->local.info->uri), sizeof(dlg_remote_uri));
                        from_domain_stripped = ast_strip_quoted(dlg_remote_uri, "<", ">");
                        ast_sip_sanitize_xml(from_domain_stripped, from_domain_sanitized, sizeof(from_domain_sanitized));
 
index 1cc6e0827f1331519d3e48dccbcca7fdf213260d..b5191a98f27b5001be884cc7a3667b735e273d14 100644 (file)
@@ -327,15 +327,15 @@ static void set_redirecting_reason_by_cause(pjsip_name_addr *name_addr,
                                   struct ast_party_redirecting_reason *data)
 {
        static const pj_str_t cause_name = { "cause", 5 };
-       pjsip_sip_uri *uri = pjsip_uri_get_uri(name_addr);
+       pjsip_uri *uri = name_addr->uri;
        pjsip_param *cause = NULL;
        unsigned long cause_value = 0;
 
-       if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri)) {
+       if (!ast_sip_is_allowed_uri(uri)) {
                return;
        }
 
-       cause = pjsip_param_find(&uri->other_param, &cause_name);
+       cause = ast_sip_pjsip_uri_get_other_param(uri, &cause_name);
 
        if (!cause) {
                return;
@@ -507,7 +507,6 @@ static void add_diversion_header(pjsip_tx_data *tdata, struct ast_party_redirect
 
        pjsip_fromto_hdr *hdr;
        pjsip_name_addr *name_addr;
-       pjsip_sip_uri *uri;
        pjsip_param *param;
        pjsip_fromto_hdr *old_hdr;
        const char *reason_str;
@@ -534,10 +533,9 @@ static void add_diversion_header(pjsip_tx_data *tdata, struct ast_party_redirect
        hdr->sname = hdr->name = diversion_name;
 
        name_addr = pjsip_uri_clone(tdata->pool, base);
-       uri = pjsip_uri_get_uri(name_addr->uri);
 
        pj_strdup2(tdata->pool, &name_addr->display, id->name.str);
-       pj_strdup2(tdata->pool, &uri->user, id->number.str);
+       pj_strdup2(tdata->pool, (pj_str_t *)ast_sip_pjsip_uri_get_username(name_addr->uri), id->number.str);
 
        param = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
        param->name = reason_name;
index 63fc405620f1c809aa62ab3cd2a2d0b03928f8b8..cc4cd4bee13e41dc80d8fbc438f1144ffd94a8bb 100644 (file)
 static int get_endpoint_details(pjsip_rx_data *rdata, char *domain, size_t domain_size)
 {
        pjsip_uri *from = rdata->msg_info.from->uri;
-       pjsip_sip_uri *sip_from;
-       if (!PJSIP_URI_SCHEME_IS_SIP(from) && !PJSIP_URI_SCHEME_IS_SIPS(from)) {
+       if (!ast_sip_is_uri_sip_sips(from)) {
                return -1;
        }
-       sip_from = (pjsip_sip_uri *) pjsip_uri_get_uri(from);
-       ast_copy_pj_str(domain, &sip_from->host, domain_size);
+       ast_copy_pj_str(domain, ast_sip_pjsip_uri_get_hostname(from), domain_size);
        return 0;
 }
 
index 46e82db174c8ac8619c63ed3feb80e02990cf527..481cd3b3fcfb80327413123193cc2bee1ce1d0fb 100644 (file)
 static int get_from_header(pjsip_rx_data *rdata, char *username, size_t username_size, char *domain, size_t domain_size)
 {
        pjsip_uri *from = rdata->msg_info.from->uri;
-       pjsip_sip_uri *sip_from;
 
-       if (!PJSIP_URI_SCHEME_IS_SIP(from) && !PJSIP_URI_SCHEME_IS_SIPS(from)) {
+       if (!ast_sip_is_uri_sip_sips(from)) {
                return -1;
        }
-       sip_from = (pjsip_sip_uri *) pjsip_uri_get_uri(from);
-       ast_copy_pj_str(username, &sip_from->user, username_size);
-       ast_copy_pj_str(domain, &sip_from->host, domain_size);
+
+       ast_copy_pj_str(username, ast_sip_pjsip_uri_get_username(from), username_size);
+       ast_copy_pj_str(domain, ast_sip_pjsip_uri_get_hostname(from), domain_size);
+
        return 0;
 }
 
index f0db27cec652d5d2ee38e2656e57fabca83b1bb5..336d392cd40cc19bb438ca61f601f6fa99568954 100644 (file)
@@ -1055,7 +1055,6 @@ static enum pjsip_status_code rx_data_to_ast_msg(pjsip_rx_data *rdata, struct as
 {
        RAII_VAR(struct ast_sip_endpoint *, endpt, NULL, ao2_cleanup);
        pjsip_uri *ruri = rdata->msg_info.msg->line.req.uri;
-       pjsip_sip_uri *sip_ruri;
        pjsip_name_addr *name_addr;
        char buf[MAX_BODY_SIZE];
        const char *field;
@@ -1064,12 +1063,11 @@ static enum pjsip_status_code rx_data_to_ast_msg(pjsip_rx_data *rdata, struct as
        int res = 0;
        int size;
 
-       if (!PJSIP_URI_SCHEME_IS_SIP(ruri) && !PJSIP_URI_SCHEME_IS_SIPS(ruri)) {
+       if (!ast_sip_is_allowed_uri(ruri)) {
                return PJSIP_SC_UNSUPPORTED_URI_SCHEME;
        }
 
-       sip_ruri = pjsip_uri_get_uri(ruri);
-       ast_copy_pj_str(exten, &sip_ruri->user, AST_MAX_EXTENSION);
+       ast_copy_pj_str(exten, ast_sip_pjsip_uri_get_username(ruri), AST_MAX_EXTENSION);
 
        /*
         * We may want to match in the dialplan without any user
index 2d5e6a7583ede5e17917830fae6adb4634980e95..59223f7bbf08f11db80611440757097409448332 100644 (file)
@@ -112,7 +112,6 @@ static void rewrite_uri(pjsip_rx_data *rdata, pjsip_sip_uri *uri, pj_pool_t *poo
  * for the subsequent requests and responses & then be able to properly update
  * the dialog object for all required events.
  */
-
 static int rewrite_route_set(pjsip_rx_data *rdata, pjsip_dialog *dlg)
 {
        pjsip_rr_hdr *rr = NULL;
index 20a4761b3f39912b15a61ae698a8f34f5b3399d5..0c9b1ee227da48eeb5a950b6a75ee54c5d087e81 100644 (file)
@@ -511,14 +511,9 @@ static int line_identify_relationship(void *obj, void *arg, int flags)
 
 static struct pjsip_param *get_uri_option_line(const void *uri)
 {
-       pjsip_sip_uri *pjuri;
        static const pj_str_t LINE_STR = { "line", 4 };
 
-       if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri)) {
-               return NULL;
-       }
-       pjuri = pjsip_uri_get_uri(uri);
-       return pjsip_param_find(&pjuri->other_param, &LINE_STR);
+       return ast_sip_pjsip_uri_get_other_param((pjsip_uri *)uri, &LINE_STR);
 }
 
 /*! \brief Endpoint identifier which uses the 'line' parameter to establish a relationship to an outgoing registration */
index 5eb3d49e05944931b48054583f2f16a2c997e872..5272a5c4242fa96b9acf308001cf8928c098c85b 100644 (file)
@@ -39,7 +39,8 @@ static pj_str_t PATH_SUPPORTED_NAME = { "path", 4 };
 static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri *uri)
 {
        char *configured_aors, *aor_name;
-       pjsip_sip_uri *sip_uri;
+       const pj_str_t *uri_username;
+       const pj_str_t *uri_hostname;
        char *domain_name;
        char *username;
        struct ast_str *id = NULL;
@@ -48,11 +49,13 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri
                return NULL;
        }
 
-       sip_uri = pjsip_uri_get_uri(uri);
-       domain_name = ast_alloca(sip_uri->host.slen + 1);
-       ast_copy_pj_str(domain_name, &sip_uri->host, sip_uri->host.slen + 1);
-       username = ast_alloca(sip_uri->user.slen + 1);
-       ast_copy_pj_str(username, &sip_uri->user, sip_uri->user.slen + 1);
+       uri_hostname = ast_sip_pjsip_uri_get_hostname(uri);
+       domain_name = ast_alloca(uri_hostname->slen + 1);
+       ast_copy_pj_str(domain_name, uri_hostname, uri_hostname->slen + 1);
+
+       uri_username = ast_sip_pjsip_uri_get_username(uri);
+       username = ast_alloca(uri_username->slen + 1);
+       ast_copy_pj_str(username, uri_username, uri_username->slen + 1);
 
        /*
         * We may want to match without any user options getting
@@ -74,7 +77,7 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri
                        break;
                }
 
-               if (!id && !(id = ast_str_create(strlen(username) + sip_uri->host.slen + 2))) {
+               if (!id && !(id = ast_str_create(strlen(username) + uri_hostname->slen + 2))) {
                        aor_name = NULL;
                        break;
                }
index 4086445353b79f434cf9e5ba69437020dcc6e086..d76726965630946d686551a7da3d71b48702fcbe 100644 (file)
@@ -1596,17 +1596,17 @@ static int sub_persistence_recreate(void *obj)
        struct ast_sip_pubsub_body_generator *generator;
        struct ast_sip_subscription_handler *handler;
        char *resource;
-       pjsip_sip_uri *request_uri;
        size_t resource_size;
        int resp;
        struct resource_tree tree;
        pjsip_expires_hdr *expires_header;
        int64_t expires;
+       const pj_str_t *user;
 
-       request_uri = pjsip_uri_get_uri(rdata->msg_info.msg->line.req.uri);
-       resource_size = pj_strlen(&request_uri->user) + 1;
+       user = ast_sip_pjsip_uri_get_username(rdata->msg_info.msg->line.req.uri);
+       resource_size = pj_strlen(user) + 1;
        resource = ast_alloca(resource_size);
-       ast_copy_pj_str(resource, &request_uri->user, resource_size);
+       ast_copy_pj_str(resource, user, resource_size);
 
        /*
         * We may want to match without any user options getting
@@ -3015,11 +3015,11 @@ static pj_bool_t pubsub_on_rx_subscribe_request(pjsip_rx_data *rdata)
        struct ast_sip_pubsub_body_generator *generator;
        char *resource;
        pjsip_uri *request_uri;
-       pjsip_sip_uri *request_uri_sip;
        size_t resource_size;
        int resp;
        struct resource_tree tree;
        pj_status_t dlg_status;
+       const pj_str_t *user;
 
        endpoint = ast_pjsip_rdata_get_endpoint(rdata);
        ast_assert(endpoint != NULL);
@@ -3032,7 +3032,7 @@ static pj_bool_t pubsub_on_rx_subscribe_request(pjsip_rx_data *rdata)
 
        request_uri = rdata->msg_info.msg->line.req.uri;
 
-       if (!PJSIP_URI_SCHEME_IS_SIP(request_uri) && !PJSIP_URI_SCHEME_IS_SIPS(request_uri)) {
+       if (!ast_sip_is_uri_sip_sips(request_uri)) {
                char uri_str[PJSIP_MAX_URL_SIZE];
 
                pjsip_uri_print(PJSIP_URI_IN_REQ_URI, request_uri, uri_str, sizeof(uri_str));
@@ -3041,10 +3041,10 @@ static pj_bool_t pubsub_on_rx_subscribe_request(pjsip_rx_data *rdata)
                return PJ_TRUE;
        }
 
-       request_uri_sip = pjsip_uri_get_uri(request_uri);
-       resource_size = pj_strlen(&request_uri_sip->user) + 1;
+       user = ast_sip_pjsip_uri_get_username(request_uri);
+       resource_size = pj_strlen(user) + 1;
        resource = ast_alloca(resource_size);
-       ast_copy_pj_str(resource, &request_uri_sip->user, resource_size);
+       ast_copy_pj_str(resource, user, resource_size);
 
        /*
         * We may want to match without any user options getting
@@ -3260,12 +3260,12 @@ static struct ast_sip_publication *publish_request_initial(struct ast_sip_endpoi
        RAII_VAR(struct ast_sip_publication_resource *, resource, NULL, ao2_cleanup);
        struct ast_variable *event_configuration_name = NULL;
        pjsip_uri *request_uri;
-       pjsip_sip_uri *request_uri_sip;
        int resp;
+       const pj_str_t *user;
 
        request_uri = rdata->msg_info.msg->line.req.uri;
 
-       if (!PJSIP_URI_SCHEME_IS_SIP(request_uri) && !PJSIP_URI_SCHEME_IS_SIPS(request_uri)) {
+       if (!ast_sip_is_uri_sip_sips(request_uri)) {
                char uri_str[PJSIP_MAX_URL_SIZE];
 
                pjsip_uri_print(PJSIP_URI_IN_REQ_URI, request_uri, uri_str, sizeof(uri_str));
@@ -3274,10 +3274,10 @@ static struct ast_sip_publication *publish_request_initial(struct ast_sip_endpoi
                return NULL;
        }
 
-       request_uri_sip = pjsip_uri_get_uri(request_uri);
-       resource_size = pj_strlen(&request_uri_sip->user) + 1;
+       user = ast_sip_pjsip_uri_get_username(request_uri);
+       resource_size = pj_strlen(user) + 1;
        resource_name = ast_alloca(resource_size);
-       ast_copy_pj_str(resource_name, &request_uri_sip->user, resource_size);
+       ast_copy_pj_str(resource_name, user, resource_size);
 
        /*
         * We may want to match without any user options getting
index d4a857f63c5c2f65557966319f17bde5998a260e..858faf365aab509cd16f916aeaa6d938dbca2db0 100644 (file)
@@ -3665,16 +3665,14 @@ enum sip_get_destination_result {
 static enum sip_get_destination_result get_destination(struct ast_sip_session *session, pjsip_rx_data *rdata)
 {
        pjsip_uri *ruri = rdata->msg_info.msg->line.req.uri;
-       pjsip_sip_uri *sip_ruri;
        struct ast_features_pickup_config *pickup_cfg;
        const char *pickupexten;
 
-       if (!PJSIP_URI_SCHEME_IS_SIP(ruri) && !PJSIP_URI_SCHEME_IS_SIPS(ruri)) {
+       if (!ast_sip_is_allowed_uri(ruri)) {
                return SIP_GET_DEST_UNSUPPORTED_URI;
        }
 
-       sip_ruri = pjsip_uri_get_uri(ruri);
-       ast_copy_pj_str(session->exten, &sip_ruri->user, sizeof(session->exten));
+       ast_copy_pj_str(session->exten, ast_sip_pjsip_uri_get_username(ruri), sizeof(session->exten));
 
        /*
         * We may want to match in the dialplan without any user