mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 05:02:10 +00:00
Merge remote branch 'fsorig/master'
Conflicts: libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c
This commit is contained in:
@@ -250,6 +250,11 @@ char *generate_pai_str(private_object_t *tech_pvt)
|
||||
const char *callee_name = NULL, *callee_number = NULL;
|
||||
const char *var, *header, *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent");
|
||||
char *pai = NULL;
|
||||
const char *host = switch_channel_get_variable(tech_pvt->channel, "sip_to_host");
|
||||
|
||||
if (zstr(host)) {
|
||||
host = tech_pvt->profile->sipip;
|
||||
}
|
||||
|
||||
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_CALLEE_ID) || !sofia_test_pflag(tech_pvt->profile, PFLAG_CID_IN_1XX) ||
|
||||
((var = switch_channel_get_variable(tech_pvt->channel, "sip_cid_in_1xx")) && switch_false(var))) {
|
||||
@@ -276,7 +281,7 @@ char *generate_pai_str(private_object_t *tech_pvt)
|
||||
callee_name = switch_sanitize_number(switch_core_session_strdup(session, callee_name));
|
||||
|
||||
if (!zstr(callee_number) && (zstr(ua) || !switch_stristr("polycom", ua))) {
|
||||
callee_number = switch_core_session_sprintf(session, "sip:%s@%s", callee_number, tech_pvt->profile->sipip);
|
||||
callee_number = switch_core_session_sprintf(session, "sip:%s@%s", callee_number, host);
|
||||
}
|
||||
|
||||
header = (tech_pvt->cid_type == CID_TYPE_RPID && !switch_stristr("aastra", ua)) ? "Remote-Party-ID" : "P-Asserted-Identity";
|
||||
@@ -321,8 +326,11 @@ static int hangup_cause_to_sip(switch_call_cause_t cause)
|
||||
case SWITCH_CAUSE_REDIRECTION_TO_NEW_DESTINATION:
|
||||
return 410;
|
||||
case SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER:
|
||||
case SWITCH_CAUSE_INVALID_PROFILE:
|
||||
return 502;
|
||||
case SWITCH_CAUSE_INVALID_NUMBER_FORMAT:
|
||||
case SWITCH_CAUSE_INVALID_URL:
|
||||
case SWITCH_CAUSE_INVALID_GATEWAY:
|
||||
return 484;
|
||||
case SWITCH_CAUSE_FACILITY_REJECTED:
|
||||
return 501;
|
||||
@@ -333,6 +341,7 @@ static int hangup_cause_to_sip(switch_call_cause_t cause)
|
||||
case SWITCH_CAUSE_NETWORK_OUT_OF_ORDER:
|
||||
case SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE:
|
||||
case SWITCH_CAUSE_SWITCH_CONGESTION:
|
||||
case SWITCH_CAUSE_GATEWAY_DOWN:
|
||||
return 503;
|
||||
case SWITCH_CAUSE_OUTGOING_CALL_BARRED:
|
||||
case SWITCH_CAUSE_INCOMING_CALL_BARRED:
|
||||
@@ -484,11 +493,12 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
||||
const char *val = NULL;
|
||||
|
||||
val = switch_channel_get_variable(tech_pvt->channel, "disable_q850_reason");
|
||||
if (!val || switch_true(val)) {
|
||||
if (cause > 0 && 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 || cause == SWITCH_CAUSE_LOSE_RACE) {
|
||||
|
||||
if (switch_false(val)) {
|
||||
if (switch_channel_test_flag(channel, CF_INTERCEPT) || cause == SWITCH_CAUSE_PICKED_OFF || cause == SWITCH_CAUSE_LOSE_RACE) {
|
||||
switch_snprintf(reason, sizeof(reason), "SIP;cause=200;text=\"Call completed elsewhere\"");
|
||||
} else if (cause > 0 && cause < 128) {
|
||||
switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
|
||||
} else {
|
||||
switch_snprintf(reason, sizeof(reason), "%s;cause=%d;text=\"%s\"", tech_pvt->profile->username, cause, switch_channel_cause2str(cause));
|
||||
}
|
||||
@@ -952,7 +962,6 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
||||
|
||||
while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session) && !switch_channel_test_flag(channel, CF_REQ_MEDIA))) {
|
||||
switch_ivr_parse_all_messages(tech_pvt->session);
|
||||
|
||||
if (--sanity && switch_channel_up(channel)) {
|
||||
switch_yield(10000);
|
||||
} else {
|
||||
@@ -1009,39 +1018,66 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
||||
switch_event_t *event;
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_RECV_RTCP_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
char buf[30];
|
||||
char value[30];
|
||||
char header[50];
|
||||
int i;
|
||||
|
||||
char *uuid = switch_core_session_get_uuid(session);
|
||||
if (uuid) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%.8x", rtcp_frame.ssrc);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "SSRC", buf);
|
||||
snprintf(value, sizeof(value), "%.8x", rtcp_frame.ssrc);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "SSRC", value);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", rtcp_frame.ntp_msw);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "NTP-Most-Significant-Word", buf);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.ntp_msw);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "NTP-Most-Significant-Word", value);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", rtcp_frame.ntp_lsw);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "NTP-Least-Significant-Word", buf);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.ntp_lsw);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "NTP-Least-Significant-Word", value);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", rtcp_frame.timestamp);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "RTP-Timestamp", buf);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.timestamp);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "RTP-Timestamp", value);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", rtcp_frame.packet_count);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Sender-Packet-Count", buf);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.packet_count);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Sender-Packet-Count", value);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", rtcp_frame.octect_count);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Octect-Packet-Count", buf);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.octect_count);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Octect-Packet-Count", value);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%" SWITCH_SIZE_T_FMT, tech_pvt->read_frame.timestamp);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Last-RTP-Timestamp", buf);
|
||||
snprintf(value, sizeof(value), "%" SWITCH_SIZE_T_FMT, tech_pvt->read_frame.timestamp);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Last-RTP-Timestamp", value);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u", tech_pvt->read_frame.rate);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "RTP-Rate", buf);
|
||||
snprintf(value, sizeof(value), "%u", tech_pvt->read_frame.rate);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "RTP-Rate", value);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%" SWITCH_TIME_T_FMT, switch_time_now());
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Capture-Time", buf);
|
||||
snprintf(value, sizeof(value), "%" SWITCH_TIME_T_FMT, switch_time_now());
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Capture-Time", value);
|
||||
|
||||
// Add sources info
|
||||
for (i = 0; i < rtcp_frame.report_count; i++) {
|
||||
snprintf(header, sizeof(header), "Source%u-SSRC", i);
|
||||
snprintf(value, sizeof(value), "%.8x", rtcp_frame.reports[i].ssrc);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header, value);
|
||||
snprintf(header, sizeof(header), "Source%u-Fraction", i);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.reports[i].fraction);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header, value);
|
||||
snprintf(header, sizeof(header), "Source%u-Lost", i);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.reports[i].lost);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header, value);
|
||||
snprintf(header, sizeof(header), "Source%u-Highest-Sequence-Number-Received", i);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.reports[i].highest_sequence_number_received);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header, value);
|
||||
snprintf(header, sizeof(header), "Source%u-Jitter", i);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.reports[i].jitter);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header, value);
|
||||
snprintf(header, sizeof(header), "Source%u-LSR", i);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.reports[i].lsr);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header, value);
|
||||
snprintf(header, sizeof(header), "Source%u-DLSR", i);
|
||||
snprintf(value, sizeof(value), "%u", rtcp_frame.reports[i].dlsr);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header, value);
|
||||
}
|
||||
|
||||
switch_event_fire(&event);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "Dispatched RTCP event\n");
|
||||
@@ -1504,6 +1540,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames) (%d max drift)\n",
|
||||
len, qlen, maxqlen, max_drift);
|
||||
switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER);
|
||||
if (!switch_false(switch_channel_get_variable(tech_pvt->channel, "sip_jitter_buffer_plc"))) {
|
||||
switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER_PLC);
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
|
||||
SWITCH_LOG_WARNING, "Error Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
|
||||
@@ -1782,6 +1821,28 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
break;
|
||||
|
||||
case SWITCH_MESSAGE_INDICATE_AUDIO_DATA:
|
||||
{
|
||||
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||
if (msg->numeric_arg) {
|
||||
if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) {
|
||||
switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_TRUE);
|
||||
sofia_set_flag(tech_pvt, TFLAG_JB_PAUSED);
|
||||
}
|
||||
|
||||
rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_UNSTICK);
|
||||
|
||||
} else {
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_JB_PAUSED)) {
|
||||
sofia_clear_flag(tech_pvt, TFLAG_JB_PAUSED);
|
||||
if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) {
|
||||
switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Sending media re-direct:\n%s\n",
|
||||
@@ -1793,7 +1854,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
|
||||
switch_channel_set_flag(channel, CF_REQ_MEDIA);
|
||||
|
||||
if (!switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||
switch_channel_set_flag(channel, CF_REQ_MEDIA);
|
||||
}
|
||||
sofia_glue_do_invite(session);
|
||||
}
|
||||
break;
|
||||
@@ -1854,7 +1918,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
|
||||
sofia_glue_set_image_sdp(tech_pvt, t38_options, msg->numeric_arg);
|
||||
|
||||
switch_channel_set_flag(channel, CF_REQ_MEDIA);
|
||||
if (!switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||
switch_channel_set_flag(channel, CF_REQ_MEDIA);
|
||||
}
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
|
||||
sofia_glue_do_invite(session);
|
||||
}
|
||||
@@ -1892,7 +1958,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
|
||||
|
||||
if (send_invite) {
|
||||
switch_channel_set_flag(channel, CF_REQ_MEDIA);
|
||||
if (!switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||
switch_channel_set_flag(channel, CF_REQ_MEDIA);
|
||||
}
|
||||
sofia_glue_do_invite(session);
|
||||
} else {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
@@ -1918,6 +1986,43 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
} else {
|
||||
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), NUTAG_SUBSTATE(nua_substate_active), SIPTAG_EVENT_STR(event), TAG_END());
|
||||
}
|
||||
|
||||
}
|
||||
case SWITCH_MESSAGE_INDICATE_INFO:
|
||||
{
|
||||
char *ct = "freeswitch/data";
|
||||
int ok = 0;
|
||||
|
||||
if (!zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) {
|
||||
ct = switch_core_session_sprintf(session, "%s/%s", msg->string_array_arg[0], msg->string_array_arg[1]);
|
||||
ok = 1;
|
||||
}
|
||||
|
||||
if (switch_stristr("send_info", tech_pvt->x_freeswitch_support_remote)) {
|
||||
ok = 1;
|
||||
}
|
||||
|
||||
if (switch_true(switch_channel_get_variable(channel, "fs_send_unspported_info"))) {
|
||||
ok = 1;
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
char *headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_INFO_HEADER_PREFIX);
|
||||
const char *pl = NULL;
|
||||
|
||||
if (!zstr(msg->string_array_arg[2])) {
|
||||
pl = msg->string_array_arg[2];
|
||||
}
|
||||
|
||||
nua_info(tech_pvt->nh,
|
||||
SIPTAG_CONTENT_TYPE_STR(ct),
|
||||
TAG_IF(!zstr(headers), SIPTAG_HEADER_STR(headers)),
|
||||
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
|
||||
TAG_IF(pl, SIPTAG_PAYLOAD_STR(pl)),
|
||||
TAG_END());
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send_info is not supported.\n", switch_channel_get_name(channel));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_SIMPLIFY:
|
||||
@@ -1989,6 +2094,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent");
|
||||
switch_event_t *event;
|
||||
|
||||
check_decode(name, tech_pvt->session);
|
||||
|
||||
|
||||
if (zstr(number)) {
|
||||
number = tech_pvt->caller_profile->destination_number;
|
||||
}
|
||||
@@ -2306,7 +2414,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||
sofia_glue_tech_patch_sdp(tech_pvt);
|
||||
sofia_glue_tech_proxy_remote_addr(tech_pvt);
|
||||
sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL);
|
||||
}
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
@@ -2569,7 +2677,7 @@ static switch_status_t sofia_receive_event(switch_core_session_t *session, switc
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
msg_nh = nua_handle(tech_pvt->profile->nua, NULL,
|
||||
SIPTAG_FROM_STR(tech_pvt->chat_from),
|
||||
NUTAG_URL(tech_pvt->chat_to), SIPTAG_TO_STR(tech_pvt->chat_to), SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END());
|
||||
NUTAG_URL(tech_pvt->chat_to), SIPTAG_TO_STR(tech_pvt->chat_to), TAG_END());
|
||||
nua_handle_bind(msg_nh, &mod_sofia_globals.destroy_private);
|
||||
nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
@@ -2867,7 +2975,6 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
stream->write_function(stream, "CALLS-OUT \t%u\n", profile->ob_calls);
|
||||
stream->write_function(stream, "FAILED-CALLS-OUT \t%u\n", profile->ob_failed_calls);
|
||||
}
|
||||
stream->write_function(stream, "\nRegistrations:\n%s\n", line);
|
||||
|
||||
cb.profile = profile;
|
||||
cb.stream = stream;
|
||||
@@ -2884,6 +2991,12 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
"network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
|
||||
" from sip_registrations where profile_name='%q' and contact like '%%%q%%'", profile->name, argv[3]);
|
||||
}
|
||||
if (!sql && argv[2] && !strcasecmp(argv[2], "reg")) {
|
||||
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
|
||||
"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
|
||||
"network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
|
||||
" from sip_registrations where profile_name='%q'", profile->name);
|
||||
}
|
||||
if (!sql && argv[2] && !strcasecmp(argv[2], "user") && argv[3]) {
|
||||
char *dup = strdup(argv[3]);
|
||||
char *host = NULL, *user = NULL;
|
||||
@@ -2914,20 +3027,18 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
switch_safe_free(sqlextra);
|
||||
}
|
||||
|
||||
if (!sql) {
|
||||
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
|
||||
"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
|
||||
"network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
|
||||
" from sip_registrations where profile_name='%q'", profile->name);
|
||||
if (sql) {
|
||||
stream->write_function(stream, "\nRegistrations:\n%s\n", line);
|
||||
|
||||
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, show_reg_callback, &cb);
|
||||
switch_safe_free(sql);
|
||||
|
||||
stream->write_function(stream, "Total items returned: %d\n", cb.row_process);
|
||||
stream->write_function(stream, "%s\n", line);
|
||||
}
|
||||
|
||||
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, show_reg_callback, &cb);
|
||||
switch_safe_free(sql);
|
||||
|
||||
stream->write_function(stream, "Total items returned: %d\n", cb.row_process);
|
||||
stream->write_function(stream, "%s\n", line);
|
||||
|
||||
sofia_glue_release_profile(profile);
|
||||
|
||||
} else {
|
||||
stream->write_function(stream, "Invalid Profile!\n");
|
||||
}
|
||||
@@ -3973,7 +4084,7 @@ SWITCH_STANDARD_API(sofia_function)
|
||||
" siptrace <on|off>\n"
|
||||
" capture <on|off>\n"
|
||||
" watchdog <on|off>\n\n"
|
||||
"sofia <status|xmlstatus> profile <name> [reg <contact str>] | [pres <pres str>] | [user <user@domain>]\n"
|
||||
"sofia <status|xmlstatus> profile <name> [reg [<contact str>]] | [pres <pres str>] | [user <user@domain>]\n"
|
||||
"sofia <status|xmlstatus> gateway <name>\n\n"
|
||||
"sofia loglevel <all|default|tport|iptsec|nea|nta|nth_client|nth_server|nua|soa|sresolv|stun> [0-9]\n"
|
||||
"sofia tracelevel <console|alert|crit|err|warning|notice|info|debug>\n\n"
|
||||
@@ -4033,6 +4144,7 @@ SWITCH_STANDARD_API(sofia_function)
|
||||
int ston = -1;
|
||||
int cton = -1;
|
||||
int wdon = -1;
|
||||
int stbyon = -1;
|
||||
|
||||
if (argc > 1) {
|
||||
if (!strcasecmp(argv[1], "debug")) {
|
||||
@@ -4068,6 +4180,12 @@ SWITCH_STANDARD_API(sofia_function)
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[1], "standby")) {
|
||||
if (argc > 2) {
|
||||
stbyon = switch_true(argv[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[1], "capture")) {
|
||||
if (argc > 2) {
|
||||
cton = switch_true(argv[2]);
|
||||
@@ -4085,11 +4203,14 @@ SWITCH_STANDARD_API(sofia_function)
|
||||
sofia_glue_global_siptrace(ston);
|
||||
stream->write_function(stream, "+OK Global siptrace %s", ston ? "on" : "off");
|
||||
} else if (cton != -1) {
|
||||
sofia_glue_global_capture(cton);
|
||||
stream->write_function(stream, "+OK Global capture %s", cton ? "on" : "off");
|
||||
sofia_glue_global_capture(cton);
|
||||
stream->write_function(stream, "+OK Global capture %s", cton ? "on" : "off");
|
||||
} else if (wdon != -1) {
|
||||
sofia_glue_global_watchdog(wdon);
|
||||
stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off");
|
||||
} else if (stbyon != -1) {
|
||||
sofia_glue_global_standby(stbyon);
|
||||
stream->write_function(stream, "+OK Global standby %s", stbyon ? "on" : "off");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|capture <on|off>|watchdog <on|off>|debug <sla|presence|none");
|
||||
}
|
||||
@@ -4102,10 +4223,23 @@ SWITCH_STANDARD_API(sofia_function)
|
||||
stream->write_function(stream, "Flushing recovery database.\n");
|
||||
} else {
|
||||
int x = sofia_glue_recover(SWITCH_FALSE);
|
||||
switch_event_t *event = NULL;
|
||||
|
||||
if (x) {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM,
|
||||
MY_EVENT_RECOVERY_RECOVERED) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "recovered_calls", "%d", x);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
stream->write_function(stream, "Recovered %d call(s)\n", x);
|
||||
} else {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM,
|
||||
MY_EVENT_RECOVERY_RECOVERED) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "recovered_calls", "0");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
stream->write_function(stream, "No calls to recover.\n");
|
||||
}
|
||||
}
|
||||
@@ -4178,7 +4312,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
*new_session = NULL;
|
||||
|
||||
if (!outbound_profile || zstr(outbound_profile->destination_number)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid Destination\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid Empty Destination\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -4215,30 +4349,30 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
char *gw, *params;
|
||||
|
||||
if (!(gw = strchr(profile_name, '/'))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid URL\n");
|
||||
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid URL \'%s\'\n", profile_name);
|
||||
cause = SWITCH_CAUSE_INVALID_URL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
*gw++ = '\0';
|
||||
|
||||
if (!(dest = strchr(gw, '/'))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid URL\n");
|
||||
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid URL \'%s\'\n", gw);
|
||||
cause = SWITCH_CAUSE_INVALID_URL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
*dest++ = '\0';
|
||||
|
||||
if (!(gateway_ptr = sofia_reg_find_gateway(gw))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Gateway\n");
|
||||
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Gateway \'%s\'\n", gw);
|
||||
cause = SWITCH_CAUSE_INVALID_GATEWAY;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (gateway_ptr->status != SOFIA_GATEWAY_UP) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Gateway is down!\n");
|
||||
cause = SWITCH_CAUSE_NETWORK_OUT_OF_ORDER;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Gateway \'%s\' is down!\n", gw);
|
||||
cause = SWITCH_CAUSE_GATEWAY_DOWN;
|
||||
gateway_ptr->ob_failed_calls++;
|
||||
goto error;
|
||||
}
|
||||
@@ -4278,6 +4412,13 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
}
|
||||
|
||||
profile = gateway_ptr->profile;
|
||||
|
||||
if (profile && sofia_test_pflag(profile, PFLAG_STANDBY)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "System Paused\n");
|
||||
cause = SWITCH_CAUSE_SYSTEM_SHUTDOWN;
|
||||
goto error;
|
||||
}
|
||||
|
||||
tech_pvt->gateway_name = switch_core_session_strdup(nsession, gateway_ptr->name);
|
||||
switch_channel_set_variable(nchannel, "sip_gateway_name", gateway_ptr->name);
|
||||
|
||||
@@ -4345,14 +4486,20 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
} else {
|
||||
if (!(dest = strchr(profile_name, '/'))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid URL\n");
|
||||
cause = SWITCH_CAUSE_INVALID_NUMBER_FORMAT;
|
||||
cause = SWITCH_CAUSE_INVALID_URL;
|
||||
goto error;
|
||||
}
|
||||
*dest++ = '\0';
|
||||
|
||||
if (!(profile = sofia_glue_find_profile(profile_name))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Profile\n");
|
||||
cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||
cause = SWITCH_CAUSE_INVALID_PROFILE;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (profile && sofia_test_pflag(profile, PFLAG_STANDBY)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "System Paused\n");
|
||||
cause = SWITCH_CAUSE_SYSTEM_SHUTDOWN;
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -4465,6 +4612,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
|
||||
if (profile->pres_type) {
|
||||
char *sql;
|
||||
time_t now;
|
||||
|
||||
const char *presence_id = switch_channel_get_variable(nchannel, "presence_id");
|
||||
const char *presence_data = switch_channel_get_variable(nchannel, "presence_data");
|
||||
|
||||
@@ -4476,9 +4625,10 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
presence_data = switch_event_get_header(var_event, "presence_data");
|
||||
}
|
||||
|
||||
sql = switch_mprintf("insert into sip_dialogs (uuid,presence_id,presence_data,profile_name,hostname) "
|
||||
"values ('%q', '%q', '%q', '%q', '%q')", switch_core_session_get_uuid(nsession),
|
||||
switch_str_nil(presence_id), switch_str_nil(presence_data), profile->name, mod_sofia_globals.hostname);
|
||||
now = switch_epoch_time_now(NULL);
|
||||
sql = switch_mprintf("insert into sip_dialogs (uuid,presence_id,presence_data,profile_name,hostname,rcd) "
|
||||
"values ('%q', '%q', '%q', '%q', '%q', %ld)", switch_core_session_get_uuid(nsession),
|
||||
switch_str_nil(presence_id), switch_str_nil(presence_data), profile->name, mod_sofia_globals.hostname, (long) now);
|
||||
sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
@@ -5284,6 +5434,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
|
||||
switch_console_set_complete("add sofia tracelevel ::[console:alert:crit:err:warning:notice:info:debug");
|
||||
|
||||
switch_console_set_complete("add sofia global siptrace ::[on:off");
|
||||
switch_console_set_complete("add sofia global standby ::[on:off");
|
||||
switch_console_set_complete("add sofia global capture ::[on:off");
|
||||
switch_console_set_complete("add sofia global watchdog ::[on:off");
|
||||
|
||||
@@ -5398,3 +5549,4 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown)
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user