Merge remote-tracking branch 'fsorig/master'

This commit is contained in:
Moises Silva 2011-07-29 17:06:00 -04:00
commit dcbfa9a876
17 changed files with 160 additions and 79 deletions

View File

@ -11,7 +11,6 @@
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/jquery-ui.min.js" ></script>
<script language="javascript" type="text/javascript" src="jquery.query-2.1.7.js"></script>
<script language="javascript" type="text/javascript" src="jquery.tmpl.js"></script>
<script language="javascript" type="text/javascript" src="http://js-hotkeys.googlecode.com/files/jquery.hotkeys-0.7.9.min.js"></script>
<script language="javascript" content-type="text/javascript">
var flashvars = {
@ -407,20 +406,6 @@
$("a", "#controls").button({ disabled: true });
$("a", "#call_container").button();
$("a", "#guest_account").button();
/*
$(document).bind('keydown', '1', function() { sendDTMF('1', 2000); return false; });
$(document).bind('keydown', '2', function() { sendDTMF('2', 2000); return false; });
$(document).bind('keydown', '3', function() { sendDTMF('3', 2000); return false; });
$(document).bind('keydown', '4', function() { sendDTMF('4', 2000); return false; });
$(document).bind('keydown', '5', function() { sendDTMF('5', 2000); return false; });
$(document).bind('keydown', '6', function() { sendDTMF('6', 2000); return false; });
$(document).bind('keydown', '7', function() { sendDTMF('7', 2000); return false; });
$(document).bind('keydown', '8', function() { sendDTMF('8', 2000); return false; });
$(document).bind('keydown', '9', function() { sendDTMF('9', 2000); return false; });
$(document).bind('keydown', '0', function() { sendDTMF('0', 2000); return false; });
$(document).bind('keydown', '#', function() { sendDTMF('#', 2000); return false; });
$(document).bind('keydown', '*', function() { sendDTMF('*', 2000); return false; });
*/
});
function testevent() {

View File

@ -4498,35 +4498,41 @@ static ftdm_status_t ftdm_set_channels_gains(ftdm_span_t *span, int currindex, f
return FTDM_SUCCESS;
}
static ftdm_status_t ftdm_set_channels_alarms(ftdm_span_t *span, int currindex) {
unsigned chan_index = 0;
static ftdm_status_t ftdm_report_initial_channels_alarms(ftdm_span_t *span)
{
ftdm_channel_t *fchan = NULL;
ftdm_iterator_t *curr = NULL;
ftdm_status_t status = FTDM_SUCCESS;
ftdm_alarm_flag_t alarmbits;
ftdm_event_t fake_event;
ftdm_iterator_t *citer = ftdm_span_get_chan_iterator(span, NULL);
if (!span->chan_count) {
ftdm_log(FTDM_LOG_ERROR, "%d:Failed to set alarms because span has no channels\n");
return FTDM_FAIL;
if (!citer) {
status = FTDM_ENOMEM;
goto done;
}
if (!span->fio->get_alarms) {
ftdm_log(FTDM_LOG_WARNING, "%d: Span does not support alarms\n", span->span_id);
return FTDM_SUCCESS;
}
memset(&fake_event, 0, sizeof(fake_event));
fake_event.e_type = FTDM_EVENT_OOB;
for (chan_index = currindex+1; chan_index <= span->chan_count; chan_index++) {
/* fio->get_alarms will update ftdm_chan->alarm_flags */
if (span->fio->get_alarms(span->channels[chan_index]) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "%d:%d: Failed to get alarms\n", span->channels[chan_index]->physical_span_id, span->channels[chan_index]->physical_chan_id);
return FTDM_FAIL;
}
if (span->channels[chan_index]->alarm_flags) {
ftdm_set_flag_locked(span->channels[chan_index], FTDM_CHANNEL_IN_ALARM);
} else {
ftdm_clear_flag_locked(span->channels[chan_index], FTDM_CHANNEL_IN_ALARM);
for (curr = citer; curr; curr = ftdm_iterator_next(curr)) {
fchan = ftdm_iterator_current(curr);
status = ftdm_channel_get_alarms(fchan, &alarmbits);
if (status != FTDM_SUCCESS) {
ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Failed to initialize alarms\n");
continue;
}
fake_event.channel = fchan;
fake_event.enum_id = fchan->alarm_flags ? FTDM_OOB_ALARM_TRAP : FTDM_OOB_ALARM_CLEAR;
ftdm_event_handle_oob(&fake_event);
}
return FTDM_SUCCESS;
done:
ftdm_iterator_free(citer);
return status;
}
FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const char* str, ftdm_channel_config_t *chan_config, unsigned *configured)
{
int currindex;
@ -4558,12 +4564,6 @@ FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const
return FTDM_FAIL;
}
if (ftdm_set_channels_alarms(span, currindex) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "%d:Failed to set channel alarms\n", span->span_id);
return FTDM_FAIL;
}
if (chan_config->debugdtmf) {
for (chan_index = currindex+1; chan_index <= span->chan_count; chan_index++) {
if (!FTDM_IS_VOICE_CHANNEL(span->channels[chan_index])) {
@ -5084,6 +5084,7 @@ static ftdm_status_t post_configure_span_channels(ftdm_span_t *span)
ftdm_status_t status = FTDM_SUCCESS;
ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN;
for (i = 1; i <= span->chan_count; i++) {
sigstatus = FTDM_SIG_STATE_DOWN;
ftdm_channel_get_sig_status(span->channels[i], &sigstatus);
if (sigstatus == FTDM_SIG_STATE_UP) {
ftdm_set_flag(span->channels[i], FTDM_CHANNEL_SIG_UP);
@ -5189,13 +5190,8 @@ FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span)
goto done;
}
/* check the alarms again before starting the signaling module
this works-around some I/O modules (netborder I/O module) that cannot
check the alarm status before during configuration because the spans are
not really started yet at the I/O level */
if (ftdm_set_channels_alarms(span, 0) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Failed to set channel alarms in span %s\n", span->name);
status = FTDM_FAIL;
status = ftdm_report_initial_channels_alarms(span);
if (status != FTDM_SUCCESS) {
goto done;
}

View File

@ -777,7 +777,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan)
}
assert(sr);
pri_sr_set_channel(sr, ftdm_channel_get_id(chan), 0, 0);
pri_sr_set_channel(sr, ftdm_channel_get_id(chan), 1, 0);
pri_sr_set_bearer(sr, PRI_TRANS_CAP_SPEECH, isdn_data->layer1);
pri_sr_set_called(sr, caller_data->dnis.digits, ton, 1);

View File

@ -366,11 +366,10 @@ static void *ftdm_sangoma_isdn_io_run(ftdm_thread_t *me, void *obj)
waitms = 1000;
memset(poll_events, 0, sizeof(short)*span->chan_count);
poll_events[i] |= FTDM_EVENTS;
for (i = 0, citer = ftdm_span_get_chan_iterator(span, chaniter); citer; citer = ftdm_iterator_next(citer), i++) {
ftdmchan = ftdm_iterator_current(citer);
poll_events[i] |= FTDM_EVENTS;
if (FTDM_IS_VOICE_CHANNEL(ftdmchan)) {
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_RX_DISABLED)) {
poll_events[i] |= FTDM_READ;

View File

@ -1047,12 +1047,11 @@ void sngisdn_restart_timeout(void *p_signal_data)
{
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t *)p_signal_data;
ftdm_span_t *span = signal_data->ftdm_span;
ftdm_log(FTDM_LOG_DEBUG, "s%d:Did not receive a RESTART from remote switch in %d ms - restarting\n", span->name, signal_data->restart_timeout);
ftdm_iterator_t *chaniter = NULL;
ftdm_iterator_t *curr = NULL;
ftdm_log(FTDM_LOG_DEBUG, "s%d:Did not receive a RESTART from remote switch in %d ms - restarting\n", span->name, signal_data->restart_timeout);
chaniter = ftdm_span_get_chan_iterator(span, NULL);
for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) {
ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr);

View File

@ -100,7 +100,7 @@ int stun_parse_message(stun_msg_t *msg)
msg->stun_attr = NULL;
while (len > 0) {
i = stun_parse_attribute(msg, p);
if (i <= 0) {
if (i <= 0 || i > len) {
SU_DEBUG_3(("%s: Error parsing attribute.\n", __func__));
return -1;
}

View File

@ -41,6 +41,9 @@
#define SWITCH_APR_H
SWITCH_BEGIN_EXTERN_C
SWITCH_DECLARE(int) switch_status_is_timeup(int status);
#ifdef WIN32
typedef DWORD switch_thread_id_t;
#else

View File

@ -4042,6 +4042,11 @@ SWITCH_STANDARD_API(show_function)
if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2];
}
} else if (!strcasecmp(command, "detailed_calls")) {
sprintf(sql, "select * from detailed_calls where hostname='%s' order by created_epoch", hostname);
if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2];
}
} else if (!strcasecmp(command, "aliases")) {
sprintf(sql, "select * from aliases where hostname='%s' order by alias", hostname);
} else if (!strcasecmp(command, "complete")) {

View File

@ -1,3 +1,4 @@
fix small interoperability issues if remote endpoint send progress twice
make sure dtmfinband gets initialized
make gk-identifier and gk-interface settings optional (documentation sayed that about gk-identifier already)
fix race condition on destroying signaling thread in h323 library

View File

@ -1138,8 +1138,7 @@ bool FSH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PStrin
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnAlerting user = %s [%p]\n",(const char *)user,this);
unsigned pi;
switch_status_t status = switch_channel_mark_ring_ready(m_fsChannel);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----------->OnAlerting return = %d\n",status);
switch_channel_mark_ring_ready(m_fsChannel);
if (!alertingPDU.GetQ931().GetProgressIndicator(pi))
pi = 0;
@ -1151,7 +1150,7 @@ bool FSH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PStrin
m_ChannelProgress = true;
}
}
return ( status == SWITCH_STATUS_SUCCESS);
return H323Connection::OnAlerting(alertingPDU,user);
}
void FSH323Connection::AnsweringCall(AnswerCallResponse response)

View File

@ -1311,10 +1311,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)
memset(&globals, 0, sizeof(globals));
if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
return status;
}
switch_core_hash_init(&globals.call_hash, module_pool);
switch_core_hash_init(&globals.sh_streams, module_pool);
switch_core_hash_init(&globals.endpoints, module_pool);
@ -1336,6 +1332,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)
globals.dual_streams = 0;
#endif
if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
return status;
}
if (dump_info(0)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't find any audio devices!\n");
return SWITCH_STATUS_TERM;

View File

@ -142,7 +142,7 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req)
if (!listener_is_ready(listener)) {
break;
}
if ((status != 70007 /* APR_TIMEUP */) && !SWITCH_STATUS_IS_BREAK(status) && (status != SWITCH_STATUS_SUCCESS)) {
if (!switch_status_is_timeup(status) && !SWITCH_STATUS_IS_BREAK(status) && (status != SWITCH_STATUS_SUCCESS)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Socket break with status=%d.\n", status);
return SWITCH_STATUS_FALSE;
}

View File

@ -4833,9 +4833,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
}
}
/* SNARK: message to respond to reinvite wasn't being delivered in 3pcc+bypass media case. */
//switch_core_session_queue_message(other_session, msg);
switch_core_session_receive_message(other_session, msg);
switch_core_session_queue_message(other_session, msg);
switch_core_session_rwunlock(other_session);
}

View File

@ -69,6 +69,11 @@
/* apr stubs */
SWITCH_DECLARE(int) switch_status_is_timeup(int status)
{
return APR_STATUS_IS_TIMEUP(status);
}
/* Memory Pools */
SWITCH_DECLARE(switch_thread_id_t) switch_thread_self(void)
@ -701,7 +706,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const
need = req - wrote;
status = apr_socket_send(sock, buf + wrote, &need);
if (status == SWITCH_STATUS_BREAK || status == 730035 || status == 35) {
if (++to_count > 10000000) {
if (++to_count > 60000) {
status = SWITCH_STATUS_FALSE;
break;
}

View File

@ -1419,7 +1419,8 @@ static void core_event_handler(switch_event_t *event)
{
const char *callee_cid_name, *callee_cid_num, *direction;
char *func_name;
char *aleg_uuid, *bleg_uuid;
direction = switch_event_get_header(event, "other-leg-direction");
if (direction && !strcasecmp(direction, "outbound")) {
@ -1442,6 +1443,15 @@ static void core_event_handler(switch_event_t *event)
func_name = "call_function";
}
aleg_uuid = switch_event_get_header_nil(event, "caller-unique-id");
bleg_uuid = switch_event_get_header_nil(event, "Other-Leg-unique-id");
new_sql() = switch_mprintf("update channels set originatee='%s' where uuid='%s'", bleg_uuid, aleg_uuid);
new_sql() = switch_mprintf("update channels set originator='%s' where uuid='%s'", aleg_uuid, bleg_uuid);
new_sql() = switch_mprintf("insert into calls (call_uuid,call_created,call_created_epoch,%s,caller_cid_name,"
"caller_cid_num,caller_dest_num,caller_chan_name,caller_uuid,callee_cid_name,"
"callee_cid_num,callee_dest_num,callee_chan_name,callee_uuid,hostname) "
@ -1455,12 +1465,13 @@ static void core_event_handler(switch_event_t *event)
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "caller-destination-number"),
switch_event_get_header_nil(event, "caller-channel-name"),
switch_event_get_header_nil(event, "caller-unique-id"),
aleg_uuid,
callee_cid_name,
callee_cid_num,
switch_event_get_header_nil(event, "Other-Leg-destination-number"),
switch_event_get_header_nil(event, "Other-Leg-channel-name"),
switch_event_get_header_nil(event, "Other-Leg-unique-id"), switch_core_get_switchname()
bleg_uuid,
switch_core_get_switchname()
);
}
break;
@ -1470,6 +1481,10 @@ static void core_event_handler(switch_event_t *event)
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q') and hostname='%q'",
uuid, uuid, switch_core_get_switchname());
new_sql() = switch_mprintf("update channels set originator=null,originatee=null where uuid='%s' or originator='%s' or originatee='%s'",
uuid, uuid, uuid);
break;
}
case SWITCH_EVENT_SHUTDOWN:
@ -1617,10 +1632,15 @@ static char create_channels_sql[] =
" callee_name VARCHAR(1024),\n"
" callee_num VARCHAR(256),\n"
" callee_direction VARCHAR(5),\n"
" call_uuid VARCHAR(256)\n"
" call_uuid VARCHAR(256),\n"
" originator VARCHAR(256),\n"
" originatee VARCHAR(256)\n"
");\n"
"create index uuindex on channels (uuid,hostname);\n"
"create index uuindex2 on channels (call_uuid,hostname);\n";
"create index ch_hn_index on channels (hostname);\n"
"create index uuindex on channels (uuid);\n"
"create index uuindex2 on channels (call_uuid);\n"
"create index uuindex3 on channels (originator);\n"
"create index uuindex4 on channels (originatee);\n";
static char create_calls_sql[] =
"CREATE TABLE calls (\n"
@ -1640,9 +1660,10 @@ static char create_calls_sql[] =
" callee_uuid VARCHAR(256),\n"
" hostname VARCHAR(256)\n"
");\n"
"create index eruuindex on calls (caller_uuid,hostname);\n"
"create index eeuuindex on calls (callee_uuid,hostname);\n"
"create index eeuuindex2 on calls (call_uuid,hostname);\n";
"create index ca_hn_index on calls (hostname);\n"
"create index eruuindex on calls (caller_uuid);\n"
"create index eeuuindex on calls (callee_uuid);\n"
"create index eeuuindex2 on calls (call_uuid);\n";
static char create_interfaces_sql[] =
"CREATE TABLE interfaces (\n"
@ -1688,6 +1709,69 @@ static char create_registrations_sql[] =
"create index regindex1 on registrations (reg_user,realm,hostname);\n";
static char view_sql[] =
"create view detailed_calls as select "
"a.uuid uuid,\n"
"a.direction direction,\n"
"a.created created,\n"
"a.created_epoch created_epoch,\n"
"a.name name,\n"
"a.state state,\n"
"a.cid_name cid_name,\n"
"a.cid_num cid_num,\n"
"a.ip_addr ip_addr,\n"
"a.dest dest,\n"
"a.application application,\n"
"a.application_data application_data,\n"
"a.dialplan dialplan,\n"
"a.context context,\n"
"a.read_codec read_codec,\n"
"a.read_rate read_rate,\n"
"a.read_bit_rate read_bit_rate,\n"
"a.write_codec write_codec,\n"
"a.write_rate write_rate,\n"
"a.write_bit_rate write_bit_rate,\n"
"a.secure secure,\n"
"a.hostname hostname,\n"
"a.presence_id presence_id,\n"
"a.presence_data presence_data,\n"
"a.callstate callstate,\n"
"a.callee_name callee_name,\n"
"a.callee_num callee_num,\n"
"a.callee_direction callee_direction,\n"
"a.call_uuid call_uuid,\n"
"b.uuid b_uuid,\n"
"b.direction b_direction,\n"
"b.created b_created,\n"
"b.created_epoch b_created_epoch,\n"
"b.name b_name,\n"
"b.state b_state,\n"
"b.cid_name b_cid_name,\n"
"b.cid_num b_cid_num,\n"
"b.ip_addr b_ip_addr,\n"
"b.dest b_dest,\n"
"b.application b_application,\n"
"b.application_data b_application_data,\n"
"b.dialplan b_dialplan,\n"
"b.context b_context,\n"
"b.read_codec b_read_codec,\n"
"b.read_rate b_read_rate,\n"
"b.read_bit_rate b_read_bit_rate,\n"
"b.write_codec b_write_codec,\n"
"b.write_rate b_write_rate,\n"
"b.write_bit_rate b_write_bit_rate,\n"
"b.secure b_secure,\n"
"b.hostname b_hostname,\n"
"b.presence_id b_presence_id,\n"
"b.presence_data b_presence_data,\n"
"b.callstate b_callstate,\n"
"b.callee_name b_callee_name,\n"
"b.callee_num b_callee_num,\n"
"b.callee_direction b_callee_direction,\n"
"b.call_uuid b_call_uuid\n"
"from channels a left join channels b on a.originatee = b.uuid where a.originator is null";
SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
const char *network_ip, const char *network_port, const char *network_proto)
{
@ -1827,6 +1911,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
case SCDB_TYPE_CORE_DB:
{
switch_cache_db_execute_sql(dbh, "drop table channels", NULL);
switch_cache_db_execute_sql(dbh, "drop view detailed_calls", NULL);
switch_cache_db_execute_sql(dbh, "drop table calls", NULL);
switch_cache_db_execute_sql(dbh, "drop table interfaces", NULL);
switch_cache_db_execute_sql(dbh, "drop table tasks", NULL);
@ -1852,6 +1937,8 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
{
char *err;
switch_cache_db_test_reactive(dbh, "select call_uuid, read_bit_rate from channels", "DROP TABLE channels", create_channels_sql);
switch_cache_db_test_reactive(dbh, "select * from detailed_calls", NULL, view_sql);
if (runtime.odbc_dbtype == DBTYPE_DEFAULT) {
switch_cache_db_test_reactive(dbh, "select call_uuid from calls", "DROP TABLE calls", create_calls_sql);
} else {
@ -1884,6 +1971,8 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
case SCDB_TYPE_CORE_DB:
{
switch_cache_db_execute_sql(dbh, create_channels_sql, NULL);
switch_cache_db_execute_sql(dbh, view_sql, NULL);
switch_cache_db_execute_sql(dbh, create_calls_sql, NULL);
switch_cache_db_execute_sql(dbh, create_interfaces_sql, NULL);
switch_cache_db_execute_sql(dbh, create_tasks_sql, NULL);

View File

@ -1286,7 +1286,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
switch_snprintf(cid_buf, sizeof(cid_buf), "%s|%s", cp->caller_id_number, cp->caller_id_name);
msg.string_arg = cid_buf;
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
switch_core_session_receive_message(tsession, &msg);
switch_core_session_receive_message(session, &msg);
while (switch_channel_up(tchannel) && switch_channel_ready(channel)) {
uint32_t len = sizeof(buf);

View File

@ -1869,7 +1869,9 @@ static char *cleanup_separated_string(char *str, char delim)
}
if (!esc) {
if (*ptr == '\'') {
inside_quotes = (1 - inside_quotes);
if ((inside_quotes = (1 - inside_quotes))) {
end = dest;
}
} else {
*dest++ = *ptr;
if (*ptr != ' ' || inside_quotes) {