add sip_bye_h prefix to add headers to bye
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9129 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
fbaec0d507
commit
952f2b7198
|
@ -284,6 +284,28 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
|||
|
||||
if (tech_pvt->nh && !switch_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
char reason[128] = "";
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
switch_event_header_t *hi;
|
||||
char *bye_headers = NULL;
|
||||
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
if ((hi = switch_channel_variable_first(channel))) {
|
||||
for (; hi; hi = hi->next) {
|
||||
const char *name = (char *) hi->name;
|
||||
char *value = (char *) hi->value;
|
||||
|
||||
if (!strncasecmp(name, SOFIA_SIP_BYE_HEADER_PREFIX, strlen(SOFIA_SIP_BYE_HEADER_PREFIX))) {
|
||||
const char *hname = name + strlen(SOFIA_SIP_BYE_HEADER_PREFIX);
|
||||
stream.write_function(&stream, "%s: %s\r\n", hname, value);
|
||||
}
|
||||
}
|
||||
switch_channel_variable_last(channel);
|
||||
}
|
||||
|
||||
if (stream.data) {
|
||||
bye_headers = stream.data;
|
||||
}
|
||||
|
||||
if (cause > 1 && cause < 128) {
|
||||
switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
|
||||
} else if (cause == SWITCH_CAUSE_PICKED_OFF) {
|
||||
|
@ -294,17 +316,28 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
|||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel));
|
||||
nua_bye(tech_pvt->nh, SIPTAG_REASON_STR(reason), TAG_END());
|
||||
nua_bye(tech_pvt->nh,
|
||||
SIPTAG_REASON_STR(reason),
|
||||
TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
|
||||
TAG_END());
|
||||
} else {
|
||||
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel));
|
||||
nua_cancel(tech_pvt->nh, SIPTAG_REASON_STR(reason), TAG_END());
|
||||
nua_cancel(tech_pvt->nh,
|
||||
SIPTAG_REASON_STR(reason),
|
||||
TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
|
||||
TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
|
||||
TAG_END());
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause);
|
||||
nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), SIPTAG_REASON_STR(reason), TAG_END());
|
||||
nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause),
|
||||
SIPTAG_REASON_STR(reason),
|
||||
TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
|
||||
TAG_END());
|
||||
}
|
||||
}
|
||||
switch_set_flag(tech_pvt, TFLAG_BYE);
|
||||
switch_safe_free(stream.data);
|
||||
}
|
||||
|
||||
switch_clear_flag(tech_pvt, TFLAG_IO);
|
||||
|
|
|
@ -78,6 +78,7 @@ typedef struct private_object private_object_t;
|
|||
#define SOFIA_USER_AGENT "FreeSWITCH-mod_sofia/" SWITCH_VERSION_MAJOR "." SWITCH_VERSION_MINOR "." SWITCH_VERSION_MICRO "-" SWITCH_VERSION_REVISION
|
||||
#define SOFIA_CHAT_PROTO "sip"
|
||||
#define SOFIA_SIP_HEADER_PREFIX "sip_h_"
|
||||
#define SOFIA_SIP_BYE_HEADER_PREFIX "sip_bye_h_"
|
||||
#define SOFIA_SIP_HEADER_PREFIX_T "~sip_h_"
|
||||
#define SOFIA_DEFAULT_PORT "5060"
|
||||
#define SOFIA_DEFAULT_TLS_PORT "5061"
|
||||
|
|
Loading…
Reference in New Issue