SCOPE_EXIT_RTN();
}
+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;
+ char *domain = ast_alloca(size);
+
+ ast_copy_pj_str(domain, &sip_ruri->host, size);
+
+ pbx_builtin_setvar_helper(session->channel, "SIPDOMAIN", domain);
+ return;
+}
+
/*! \brief Function called when a request is received on the session */
static int chan_pjsip_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
SCOPE_EXIT_LOG_RTN_VALUE(-1, LOG_ERROR, "%s: Failed to allocate new PJSIP channel on incoming SIP INVITE\n",
ast_sip_session_get_name(session));
}
+
+ set_sipdomain_variable(session);
+
/* channel gets created on incoming request, but we wait to call start
so other supplements have a chance to run */
SCOPE_EXIT_RTN_VALUE(0, "%s\n", ast_sip_session_get_name(session));
*/
AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(session->exten);
- pickup_cfg = ast_get_chan_features_pickup_config(session->channel);
+ pickup_cfg = ast_get_chan_features_pickup_config(NULL); /* session->channel doesn't exist yet, using NULL */
if (!pickup_cfg) {
ast_log(LOG_ERROR, "%s: Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n",
ast_sip_session_get_name(session));
if (!strcmp(session->exten, pickupexten) ||
ast_exists_extension(NULL, session->endpoint->context, session->exten, 1, NULL)) {
- size_t size = pj_strlen(&sip_ruri->host) + 1;
- char *domain = ast_alloca(size);
-
- ast_copy_pj_str(domain, &sip_ruri->host, size);
- pbx_builtin_setvar_helper(session->channel, "SIPDOMAIN", domain);
-
/*
* Save off the INVITE Request-URI in case it is
* needed: CHANNEL(pjsip,request_uri)