[Asterisk-code-review] res_pjsip: Add TEL URI support for basic calls. (asterisk[16])
Benjamin Keith Ford
asteriskteam at digium.com
Mon Aug 8 08:35:51 CDT 2022
Benjamin Keith Ford has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18892 )
Change subject: res_pjsip: Add TEL URI support for basic calls.
......................................................................
res_pjsip: Add TEL URI support for basic calls.
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.
Support is only for incoming calls.
ASTERISK-26894
Change-Id: If5729e6cd583be7acf666373bf9f1b9d653ec29a
---
M channels/chan_pjsip.c
M include/asterisk/res_pjsip.h
M res/res_pjsip.c
M res/res_pjsip/pjsip_distributor.c
M res/res_pjsip/pjsip_message_filter.c
M res/res_pjsip/pjsip_options.c
M res/res_pjsip_caller_id.c
M res/res_pjsip_dialog_info_body_generator.c
M res/res_pjsip_diversion.c
M res/res_pjsip_endpoint_identifier_anonymous.c
M res/res_pjsip_endpoint_identifier_user.c
M res/res_pjsip_messaging.c
M res/res_pjsip_nat.c
M res/res_pjsip_outbound_registration.c
M res/res_pjsip_path.c
M res/res_pjsip_pubsub.c
M res/res_pjsip_session.c
17 files changed, 206 insertions(+), 71 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/92/18892/1
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index c800cfc..adc71f5 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -2950,11 +2950,11 @@
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;
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index a4d0607..9b1cd7c 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -94,6 +94,8 @@
/*! Maximum number of challenges before assuming that we are in a loop */
#define MAX_RX_CHALLENGES 10
+static const pj_str_t AST_PJ_STR_EMPTY = { "", 0 };
+
/*!
* \brief Structure for SIP transport information
*/
@@ -3465,4 +3467,65 @@
*/
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 */
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 1e41360..79ebbd1 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -2359,6 +2359,69 @@
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)
{
diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index ea8fb02..092e012 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -763,9 +763,8 @@
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 @@
*addrs = NULL;
return 0;
}
+
if (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri)) {
*addrs = NULL;
return 0;
diff --git a/res/res_pjsip/pjsip_message_filter.c b/res/res_pjsip/pjsip_message_filter.c
index ceb8913..2409c9d 100644
--- a/res/res_pjsip/pjsip_message_filter.c
+++ b/res/res_pjsip/pjsip_message_filter.c
@@ -189,7 +189,7 @@
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))) {
@@ -200,7 +200,7 @@
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))) {
@@ -208,7 +208,7 @@
}
}
} 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))) {
@@ -287,7 +287,7 @@
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);
@@ -439,6 +439,10 @@
return;
}
+ if (PJSIP_URI_SCHEME_IS_TEL(header_uri)) {
+ return;
+ }
+
uri = pjsip_uri_get_uri(header_uri);
if (!uri) {
return;
@@ -457,6 +461,25 @@
}
}
+/* 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 char *request = pj_strbuf(&req.method.name);
+
+ if (!strcmp(request, "INVITE")) {
+ return 1;
+ } else if (!strcmp(request, "ACK")) {
+ return 1;
+ } else if (!strcmp(request, "BYE")) {
+ return 1;
+ } else if (!strcmp(request, "CANCEL")) {
+ return 1;
+ }
+
+ return 0;
+}
+
static pj_bool_t on_rx_process_uris(pjsip_rx_data *rdata)
{
pjsip_contact_hdr *contact = NULL;
@@ -465,7 +488,9 @@
return PJ_FALSE;
}
- if (!is_sip_uri(rdata->msg_info.msg->line.req.uri)) {
+ if (!ast_sip_is_uri_sip_sips(rdata->msg_info.msg->line.req.uri)
+ && (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);
@@ -473,7 +498,7 @@
}
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);
@@ -481,7 +506,7 @@
}
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);
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 14013ad..5118e07 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -269,7 +269,6 @@
{
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 @@
}
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
diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index e9c24a6..a58cca3 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -45,13 +45,11 @@
{
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, ';');
diff --git a/res/res_pjsip_dialog_info_body_generator.c b/res/res_pjsip_dialog_info_body_generator.c
index 88aa6c2..abcc759 100644
--- a/res/res_pjsip_dialog_info_body_generator.c
+++ b/res/res_pjsip_dialog_info_body_generator.c
@@ -183,7 +183,6 @@
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 @@
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));
diff --git a/res/res_pjsip_diversion.c b/res/res_pjsip_diversion.c
index 1cc6e08..b5191a9 100644
--- a/res/res_pjsip_diversion.c
+++ b/res/res_pjsip_diversion.c
@@ -327,15 +327,15 @@
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 @@
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 @@
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;
diff --git a/res/res_pjsip_endpoint_identifier_anonymous.c b/res/res_pjsip_endpoint_identifier_anonymous.c
index 63fc405..32e48f3 100644
--- a/res/res_pjsip_endpoint_identifier_anonymous.c
+++ b/res/res_pjsip_endpoint_identifier_anonymous.c
@@ -33,12 +33,10 @@
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_allowed_uri(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;
}
diff --git a/res/res_pjsip_endpoint_identifier_user.c b/res/res_pjsip_endpoint_identifier_user.c
index 46e82db..b21db2b 100644
--- a/res/res_pjsip_endpoint_identifier_user.c
+++ b/res/res_pjsip_endpoint_identifier_user.c
@@ -32,14 +32,14 @@
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_allowed_uri(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;
}
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index f0db27c..336d392 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -1055,7 +1055,6 @@
{
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 @@
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
diff --git a/res/res_pjsip_nat.c b/res/res_pjsip_nat.c
index 2d5e6a7..59223f7 100644
--- a/res/res_pjsip_nat.c
+++ b/res/res_pjsip_nat.c
@@ -112,7 +112,6 @@
* 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;
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 2cf5713..16786ef 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -480,14 +480,9 @@
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 */
diff --git a/res/res_pjsip_path.c b/res/res_pjsip_path.c
index 5eb3d49..5272a5c 100644
--- a/res/res_pjsip_path.c
+++ b/res/res_pjsip_path.c
@@ -39,7 +39,8 @@
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 @@
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 @@
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;
}
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index 5cccdcc..9e2fe48 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -1596,17 +1596,17 @@
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
@@ -3013,11 +3013,11 @@
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);
@@ -3039,10 +3039,10 @@
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
@@ -3258,8 +3258,8 @@
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;
@@ -3272,10 +3272,10 @@
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
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 3c55af7..2fecdea 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -3671,16 +3671,14 @@
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
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18892
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: If5729e6cd583be7acf666373bf9f1b9d653ec29a
Gerrit-Change-Number: 18892
Gerrit-PatchSet: 1
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220808/e541e57b/attachment-0001.html>
More information about the asterisk-code-review
mailing list