summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsip/sip_errno.h5
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h18
-rw-r--r--pjsip/src/pjsip/sip_errno.c1
-rw-r--r--pjsip/src/pjsip/sip_util.c5
-rw-r--r--pjsip/src/pjsua-lib/pjsua_acc.c35
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c29
6 files changed, 71 insertions, 22 deletions
diff --git a/pjsip/include/pjsip/sip_errno.h b/pjsip/include/pjsip/sip_errno.h
index 15f842a9..8e075f28 100644
--- a/pjsip/include/pjsip/sip_errno.h
+++ b/pjsip/include/pjsip/sip_errno.h
@@ -96,6 +96,11 @@ PJ_BEGIN_DECL
* SIP object is not initialized.
*/
#define PJSIP_ENOTINITIALIZED (PJSIP_ERRNO_START_PJSIP + 4) /* 171004 */
+/**
+ * @hideinitializer
+ * Missing route set (for tel: URI)
+ */
+#define PJSIP_ENOROUTESET (PJSIP_ERRNO_START_PJSIP + 5) /* 171005 */
/************************************************************
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 3aa03b93..10e1b0fe 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -1540,16 +1540,32 @@ PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
/**
* This is a utility function to verify that valid SIP url is given. If the
- * URL is valid, PJ_SUCCESS will be returned.
+ * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
*
* @param url The URL, as NULL terminated string.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
+ *
+ * @see pjsua_verify_url()
*/
PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
/**
+ * This is a utility function to verify that valid URI is given. Unlike
+ * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI
+ * is given.
+ *
+ * @param url The URL, as NULL terminated string.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ *
+ * @see pjsua_verify_sip_url()
+ */
+PJ_DECL(pj_status_t) pjsua_verify_url(const char *url);
+
+
+/**
* Schedule a timer entry. Note that the timer callback may be executed
* by different thread, depending on whether worker thread is enabled or
* not.
diff --git a/pjsip/src/pjsip/sip_errno.c b/pjsip/src/pjsip/sip_errno.c
index 0c15206a..afef2a19 100644
--- a/pjsip/src/pjsip/sip_errno.c
+++ b/pjsip/src/pjsip/sip_errno.c
@@ -39,6 +39,7 @@ static const struct
PJ_BUILD_ERR( PJSIP_ETYPEEXISTS , "Object with the same type exists" ),
PJ_BUILD_ERR( PJSIP_ESHUTDOWN, "SIP stack shutting down" ),
PJ_BUILD_ERR( PJSIP_ENOTINITIALIZED,"SIP object is not initialized." ),
+ PJ_BUILD_ERR( PJSIP_ENOROUTESET, "Missing route set (for tel: URI)" ),
/* Messaging errors */
PJ_BUILD_ERR( PJSIP_EINVALIDMSG, "Invalid message/syntax error" ),
diff --git a/pjsip/src/pjsip/sip_util.c b/pjsip/src/pjsip/sip_util.c
index 2b0933a3..b57c9485 100644
--- a/pjsip/src/pjsip/sip_util.c
+++ b/pjsip/src/pjsip/sip_util.c
@@ -835,9 +835,12 @@ static pj_status_t get_dest_info(const pjsip_uri *target_uri,
dest_info->flag =
pjsip_transport_get_flag_from_type(dest_info->type);
} else {
+ /* Should have never reached here; app should have configured route
+ * set when sending to tel: URI
pj_assert(!"Unsupported URI scheme!");
+ */
PJ_TODO(SUPPORT_REQUEST_ADDR_RESOLUTION_FOR_TEL_URI);
- return PJSIP_EINVALIDSCHEME;
+ return PJSIP_ENOROUTESET;
}
/* Handle IPv6 (http://trac.pjsip.org/repos/ticket/861) */
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c
index abb61b15..fdd37a51 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -119,7 +119,7 @@ static pj_status_t initialize_acc(unsigned acc_id)
pjsua_acc_config *acc_cfg = &pjsua_var.acc[acc_id].cfg;
pjsua_acc *acc = &pjsua_var.acc[acc_id];
pjsip_name_addr *name_addr;
- pjsip_sip_uri *sip_uri, *sip_reg_uri;
+ pjsip_sip_uri *sip_reg_uri;
pj_status_t status;
unsigned i;
@@ -136,18 +136,27 @@ static pj_status_t initialize_acc(unsigned acc_id)
}
/* Local URI MUST be a SIP or SIPS: */
-
if (!PJSIP_URI_SCHEME_IS_SIP(name_addr) &&
!PJSIP_URI_SCHEME_IS_SIPS(name_addr))
{
- pjsua_perror(THIS_FILE, "Invalid local URI",
- PJSIP_EINVALIDSCHEME);
- return PJSIP_EINVALIDSCHEME;
- }
+ acc->display = name_addr->display;
+ acc->user_part = name_addr->display;
+ acc->srv_domain = pj_str("");
+ acc->srv_port = 0;
+ } else {
+ pjsip_sip_uri *sip_uri;
+ /* Get the SIP URI object: */
+ sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(name_addr);
- /* Get the SIP URI object: */
- sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(name_addr);
+ /* Save the user and domain part. These will be used when finding an
+ * account for incoming requests.
+ */
+ acc->display = name_addr->display;
+ acc->user_part = sip_uri->user;
+ acc->srv_domain = sip_uri->host;
+ acc->srv_port = 0;
+ }
/* Parse registrar URI, if any */
@@ -177,14 +186,6 @@ static pj_status_t initialize_acc(unsigned acc_id)
sip_reg_uri = NULL;
}
- /* Save the user and domain part. These will be used when finding an
- * account for incoming requests.
- */
- acc->display = name_addr->display;
- acc->user_part = sip_uri->user;
- acc->srv_domain = sip_uri->host;
- acc->srv_port = 0;
-
if (sip_reg_uri) {
acc->srv_port = sip_reg_uri->port;
}
@@ -2160,7 +2161,7 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
/* For non-SIP scheme, route set should be configured */
if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))
- return PJSIP_EINVALIDREQURI;
+ return PJSIP_ENOROUTESET;
sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(uri);
}
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 9fb0a5d0..0dcd0f2a 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -2404,6 +2404,29 @@ PJ_DEF(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type)
return pjsua_var.nat_status;
}
+/*
+ * Verify that valid url is given.
+ */
+PJ_DEF(pj_status_t) pjsua_verify_url(const char *c_url)
+{
+ pjsip_uri *p;
+ pj_pool_t *pool;
+ char *url;
+ int len = (c_url ? pj_ansi_strlen(c_url) : 0);
+
+ if (!len) return PJSIP_EINVALIDURI;
+
+ pool = pj_pool_create(&pjsua_var.cp.factory, "check%p", 1024, 0, NULL);
+ if (!pool) return PJ_ENOMEM;
+
+ url = (char*) pj_pool_alloc(pool, len+1);
+ pj_ansi_strcpy(url, c_url);
+
+ p = pjsip_parse_uri(pool, url, len, 0);
+
+ pj_pool_release(pool);
+ return p ? 0 : PJSIP_EINVALIDURI;
+}
/*
* Verify that valid SIP url is given.
@@ -2415,10 +2438,10 @@ PJ_DEF(pj_status_t) pjsua_verify_sip_url(const char *c_url)
char *url;
int len = (c_url ? pj_ansi_strlen(c_url) : 0);
- if (!len) return -1;
+ if (!len) return PJSIP_EINVALIDURI;
pool = pj_pool_create(&pjsua_var.cp.factory, "check%p", 1024, 0, NULL);
- if (!pool) return -1;
+ if (!pool) return PJ_ENOMEM;
url = (char*) pj_pool_alloc(pool, len+1);
pj_ansi_strcpy(url, c_url);
@@ -2431,7 +2454,7 @@ PJ_DEF(pj_status_t) pjsua_verify_sip_url(const char *c_url)
}
pj_pool_release(pool);
- return p ? 0 : -1;
+ return p ? 0 : PJSIP_EINVALIDURI;
}
/*