char *transferee;
/*! \brief Non-zero if the 100 notify has been sent */
int sent_100;
+ /*! \brief Whether to notifies all the progress details on blind transfer */
+ unsigned int refer_blind_progress;
};
/*! \brief REFER Progress notification structure */
ast_debug(3, "Created progress monitor '%p' for transfer occurring from channel '%s' and endpoint '%s'\n",
progress, ast_channel_name(session->channel), ast_sorcery_object_get_id(session->endpoint));
+ (*progress)->refer_blind_progress = session->endpoint->refer_blind_progress;
+
(*progress)->framehook = -1;
/* To prevent a potential deadlock we need the dialog so we can lock/unlock */
}
}
+ ast_sip_session_end_if_deferred(attended->transferer);
if (response != 200) {
if (!ast_sip_push_task(attended->transferer->serializer,
defer_termination_cancel, attended->transferer)) {
pjsip_replaces_hdr *replaces;
/*! \brief Optional Refer-To header */
pjsip_sip_uri *refer_to;
+ /*! \brief Attended transfer flag */
+ unsigned int attended:1;
};
/*! \brief Blind transfer callback function */
pbx_builtin_setvar_helper(chan, "SIPTRANSFER", "yes");
- /* If progress monitoring is being done attach a frame hook so we can monitor it */
- if (refer->progress) {
+ if (refer->progress && !refer->attended && !refer->progress->refer_blind_progress) {
+ /* If blind transfer and endpoint doesn't want to receive all the progress details */
+ struct refer_progress_notification *notification = refer_progress_notification_alloc(refer->progress, 200,
+ PJSIP_EVSUB_STATE_TERMINATED);
+
+ if (notification) {
+ refer_progress_notify(notification);
+ }
+ } else if (refer->progress) {
+ /* If attended transfer and progress monitoring is being done attach a frame hook so we can monitor it */
struct ast_framehook_interface hook = {
.version = AST_FRAMEHOOK_INTERFACE_VERSION,
.event_cb = refer_progress_framehook,
/* Push it to the other session, which will have both channels with minimal locking */
if (ast_sip_push_task(other_session->serializer, refer_attended_task, attended)) {
+ ast_sip_session_end_if_deferred(session);
ast_sip_session_defer_termination_cancel(session);
ao2_cleanup(attended);
return 500;
refer.rdata = rdata;
refer.replaces = replaces;
refer.refer_to = target_uri;
+ refer.attended = 1;
if (ast_sip_session_defer_termination(session)) {
ast_log(LOG_ERROR, "Received REFER for remote session on channel '%s' from endpoint '%s' but could not defer termination, rejecting\n",
response = xfer_response_code2sip(ast_bridge_transfer_blind(1, session->channel,
"external_replaces", context, refer_blind_callback, &refer));
+
+ ast_sip_session_end_if_deferred(session);
if (response != 200) {
ast_sip_session_defer_termination_cancel(session);
}
+
return response;
}
}
*/
AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(exten);
+ /* Uri without exten */
+ if (ast_strlen_zero(exten)) {
+ ast_copy_string(exten, "s", sizeof(exten));
+ ast_debug(3, "Channel '%s' from endpoint '%s' attempted blind transfer to a target without extension. Target was set to 's@%s'\n",
+ ast_channel_name(session->channel), ast_sorcery_object_get_id(session->endpoint), context);
+ }
+
if (!ast_exists_extension(NULL, context, exten, 1, NULL)) {
ast_log(LOG_ERROR, "Channel '%s' from endpoint '%s' attempted blind transfer to '%s@%s' but target does not exist\n",
ast_channel_name(session->channel), ast_sorcery_object_get_id(session->endpoint), exten, context);
refer.progress = progress;
refer.rdata = rdata;
refer.refer_to = target;
+ refer.attended = 0;
if (ast_sip_session_defer_termination(session)) {
ast_log(LOG_ERROR, "Channel '%s' from endpoint '%s' attempted blind transfer but could not defer termination, rejecting\n",
response = xfer_response_code2sip(ast_bridge_transfer_blind(1, session->channel,
exten, context, refer_blind_callback, &refer));
+
+ ast_sip_session_end_if_deferred(session);
if (response != 200) {
ast_sip_session_defer_termination_cancel(session);
}
+
return response;
}
int response;
static const pj_str_t str_refer_to = { "Refer-To", 8 };
+ static const pj_str_t str_refer_to_s = { "r", 1 };
static const pj_str_t str_replaces = { "Replaces", 8 };
if (!session->channel) {
}
/* A Refer-To header is required */
- refer_to = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_to, NULL);
+ refer_to = pjsip_msg_find_hdr_by_names(rdata->msg_info.msg, &str_refer_to, &str_refer_to_s, NULL);
if (!refer_to) {
pjsip_dlg_respond(session->inv_session->dlg, rdata, 400, NULL, NULL, NULL);
ast_debug(3, "Received a REFER without Refer-To on channel '%s' from endpoint '%s'\n",
ast_sip_register_service(&refer_progress_module);
ast_sip_session_register_supplement(&refer_supplement);
+ ast_module_shutdown_ref(ast_module_info->self);
+
return AST_MODULE_LOAD_SUCCESS;
}