[asterisk-commits] file: branch 12 r400520 - /branches/12/res/res_pjsip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Oct 4 10:48:36 CDT 2013
Author: file
Date: Fri Oct 4 10:48:34 2013
New Revision: 400520
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=400520
Log:
Enclose the To URI and update its user portion if a request user has been specified.
Modified:
branches/12/res/res_pjsip.c
Modified: branches/12/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip.c?view=diff&rev=400520&r1=400519&r2=400520
==============================================================================
--- branches/12/res/res_pjsip.c (original)
+++ branches/12/res/res_pjsip.c Fri Oct 4 10:48:34 2013
@@ -1342,15 +1342,19 @@
pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *uri, const char *request_user)
{
- pj_str_t local_uri = { "sip:temp at temp", 13 }, remote_uri;
+ char enclosed_uri[PJSIP_MAX_URL_SIZE];
+ pj_str_t local_uri = { "sip:temp at temp", 13 }, remote_uri, target_uri;
pjsip_dialog *dlg = NULL;
const char *outbound_proxy = endpoint->outbound_proxy;
pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
static const pj_str_t HCONTACT = { "Contact", 7 };
- pj_cstr(&remote_uri, uri);
-
- if (pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, NULL, &dlg) != PJ_SUCCESS) {
+ snprintf(enclosed_uri, sizeof(enclosed_uri), "<%s>", uri);
+ pj_cstr(&remote_uri, enclosed_uri);
+
+ pj_cstr(&target_uri, uri);
+
+ if (pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, &target_uri, &dlg) != PJ_SUCCESS) {
return NULL;
}
@@ -1370,9 +1374,17 @@
dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen, NULL);
/* If a request user has been specified and we are permitted to change it, do so */
- if (!ast_strlen_zero(request_user) && (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target))) {
- pjsip_sip_uri *target = pjsip_uri_get_uri(dlg->target);
- pj_strdup2(dlg->pool, &target->user, request_user);
+ if (!ast_strlen_zero(request_user)) {
+ pjsip_sip_uri *sip_uri;
+
+ if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) {
+ sip_uri = pjsip_uri_get_uri(dlg->target);
+ pj_strdup2(dlg->pool, &sip_uri->user, request_user);
+ }
+ if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) {
+ sip_uri = pjsip_uri_get_uri(dlg->remote.info->uri);
+ pj_strdup2(dlg->pool, &sip_uri->user, request_user);
+ }
}
/* We have to temporarily bump up the sess_count here so the dialog is not prematurely destroyed */
More information about the asterisk-commits
mailing list