--- res/res_pjsip_session.c (Asterisk 13.13.1) +++ res/res_pjsip_session.c (working copy) @@ -1998,2 +1998,11 @@ ast_exists_extension(NULL, session->endpoint->context, session->exten, 1, NULL)) { + size_t size = pj_strlen(&sip_ruri->host) + 1; + char *domain = ast_malloc(size); + + if (domain) { + ast_copy_pj_str(domain, &sip_ruri->host, size); + pbx_builtin_setvar_helper(session->channel, "SIPDOMAIN", domain); + ast_free(domain); + } + return SIP_GET_DEST_EXTEN_FOUND;