From: Joshua Colp Date: Fri, 4 Oct 2013 15:48:34 +0000 (+0000) Subject: Enclose the To URI and update its user portion if a request user has been specified. X-Git-Tag: 12.0.0-alpha2~24^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1e76f6ccbfe8dac86c5fdc5e8e50c18697d46f3;p=thirdparty%2Fasterisk.git Enclose the To URI and update its user portion if a request user has been specified. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@400520 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/res/res_pjsip.c b/res/res_pjsip.c index c102803a2e..d522ad581a 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -1342,15 +1342,19 @@ static int sip_get_tpselector_from_uri(const char *uri, pjsip_tpselector *select 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@temp", 13 }, remote_uri; + char enclosed_uri[PJSIP_MAX_URL_SIZE]; + pj_str_t local_uri = { "sip:temp@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); + snprintf(enclosed_uri, sizeof(enclosed_uri), "<%s>", uri); + pj_cstr(&remote_uri, enclosed_uri); - if (pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, NULL, &dlg) != PJ_SUCCESS) { + 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 @@ pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, 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 */