process alarms in the core
git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@1055 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
66bc2e43c8
commit
617020ea0c
|
@ -1,3 +1,3 @@
|
|||
OPENZAP (WORK IN PROGRESS)
|
||||
FREETDM (WORK IN PROGRESS)
|
||||
|
||||
*shrug*
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
== Interface inconsistency ==
|
||||
- enum_id member of ftdm_event_t is inconsistent. Most of the time is just for OOB events, the only other
|
||||
type of event as of now is FTDM_EVENT_DTMF and is not using the enum_id member. I think we can get rid
|
||||
of the FTDM_EVENT_DTMF and create ftdm_dtmf_event_t type instead of reusing ftdm_event_t
|
||||
then ftdm_event_t would be renamed to ftdm_oob_event_t and the enum_id renamed to type, then ftdm_span_next_event()
|
||||
will only return OOB events
|
||||
|
|
@ -1429,8 +1429,10 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal)
|
|||
return FTDM_FAIL;
|
||||
}
|
||||
if (sigmsg->event_id == FTDM_SIGEVENT_ALARM_CLEAR) {
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Alarm cleared on channel %d:%d [%s]\n", sigmsg->channel->span_id, sigmsg->channel->chan_id);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-clear");
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Alarm raised on channel %d:%d [%s]\n", sigmsg->channel->span_id, sigmsg->channel->chan_id);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-trap");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -823,15 +823,46 @@ FT_DECLARE(ftdm_status_t) ftdm_span_poll_event(ftdm_span_t *span, uint32_t ms)
|
|||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_next_event(ftdm_span_t *span, ftdm_event_t **event)
|
||||
{
|
||||
assert(span->fio != NULL);
|
||||
ftdm_status_t status = FTDM_FAIL;
|
||||
ftdm_sigmsg_t sigmsg;
|
||||
ftdm_assert_return(span->fio != NULL, FTDM_FAIL, "No I/O module attached to this span!\n");
|
||||
|
||||
if (span->fio->next_event) {
|
||||
return span->fio->next_event(span, event);
|
||||
} else {
|
||||
if (!span->fio->next_event) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "next_event method not implemented in module %s!", span->fio->name);
|
||||
return FTDM_NOTIMPL;
|
||||
}
|
||||
|
||||
return FTDM_NOTIMPL;
|
||||
|
||||
status = span->fio->next_event(span, event);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* before returning the event to the user we do some core operations with certain OOB events */
|
||||
memset(&sigmsg, 0, sizeof(sigmsg));
|
||||
sigmsg.span_id = span->span_id;
|
||||
sigmsg.chan_id = (*event)->channel->chan_id;
|
||||
sigmsg.channel = (*event)->channel;
|
||||
switch ((*event)->enum_id) {
|
||||
case FTDM_OOB_ALARM_CLEAR:
|
||||
{
|
||||
sigmsg.event_id = FTDM_SIGEVENT_ALARM_CLEAR;
|
||||
ftdm_clear_flag_locked((*event)->channel, FTDM_CHANNEL_IN_ALARM);
|
||||
ftdm_span_send_signal(span, &sigmsg);
|
||||
}
|
||||
break;
|
||||
case FTDM_OOB_ALARM_TRAP:
|
||||
{
|
||||
sigmsg.event_id = FTDM_SIGEVENT_ALARM_TRAP;
|
||||
ftdm_set_flag_locked((*event)->channel, FTDM_CHANNEL_IN_ALARM);
|
||||
ftdm_span_send_signal(span, &sigmsg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* NOOP */
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static ftdm_status_t ftdmchan_fsk_write_sample(int16_t *buf, ftdm_size_t buflen, void *user_data)
|
||||
|
@ -1209,6 +1240,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_dir
|
|||
if (ftdm_test_flag(check, FTDM_CHANNEL_READY) &&
|
||||
!ftdm_test_flag(check, FTDM_CHANNEL_INUSE) &&
|
||||
!ftdm_test_flag(check, FTDM_CHANNEL_SUSPENDED) &&
|
||||
!ftdm_test_flag(check, FTDM_CHANNEL_IN_ALARM) &&
|
||||
check->state == FTDM_CHANNEL_STATE_DOWN &&
|
||||
FTDM_IS_VOICE_CHANNEL(check)
|
||||
) {
|
||||
|
@ -1327,6 +1359,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direc
|
|||
if (ftdm_test_flag(check, FTDM_CHANNEL_READY) &&
|
||||
!ftdm_test_flag(check, FTDM_CHANNEL_INUSE) &&
|
||||
!ftdm_test_flag(check, FTDM_CHANNEL_SUSPENDED) &&
|
||||
!ftdm_test_flag(check, FTDM_CHANNEL_IN_ALARM) &&
|
||||
check->state == FTDM_CHANNEL_STATE_DOWN &&
|
||||
FTDM_IS_VOICE_CHANNEL(check)
|
||||
) {
|
||||
|
@ -1417,7 +1450,12 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_chan(ftdm_channel_t *ftdmchan)
|
|||
assert(ftdmchan != NULL);
|
||||
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED)) {
|
||||
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", "Channel is suspended");
|
||||
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", "Channel is suspended\n");
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) {
|
||||
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", "Channel is alarmed\n");
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
|
@ -1468,7 +1506,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open(uint32_t span_id, uint32_t chan_id,
|
|||
goto done;
|
||||
}
|
||||
|
||||
if (ftdm_test_flag(check, FTDM_CHANNEL_SUSPENDED) ||
|
||||
if (ftdm_test_flag(check, FTDM_CHANNEL_SUSPENDED) || ftdm_test_flag(check, FTDM_CHANNEL_IN_ALARM) ||
|
||||
!ftdm_test_flag(check, FTDM_CHANNEL_READY) || (status = ftdm_mutex_trylock(check->mutex)) != FTDM_SUCCESS) {
|
||||
*ftdmchan = NULL;
|
||||
goto done;
|
||||
|
@ -2371,8 +2409,8 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data
|
|||
ftdm_size_t max = *datalen;
|
||||
unsigned i = 0;
|
||||
|
||||
assert(ftdmchan != NULL);
|
||||
assert(ftdmchan->fio != NULL);
|
||||
ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "ftdmchan is null\n");
|
||||
ftdm_assert_return(ftdmchan->fio != NULL, FTDM_FAIL, "No I/O module attached to ftdmchan\n");
|
||||
|
||||
if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) {
|
||||
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "channel not open");
|
||||
|
|
|
@ -872,14 +872,6 @@ static __inline__ ftdm_status_t process_event(ftdm_span_t *span, ftdm_event_t *e
|
|||
ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_DOWN);
|
||||
}
|
||||
}
|
||||
case FTDM_OOB_ALARM_TRAP:
|
||||
{
|
||||
ftdm_set_flag_locked(event->channel, FTDM_CHANNEL_SUSPENDED);
|
||||
}
|
||||
case FTDM_OOB_ALARM_CLEAR:
|
||||
{
|
||||
ftdm_clear_flag_locked(event->channel, FTDM_CHANNEL_SUSPENDED);
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
|
|
@ -1501,11 +1501,8 @@ static __inline__ void check_state(ftdm_span_t *span)
|
|||
static __inline__ ftdm_status_t check_events(ftdm_span_t *span, int ms_timeout)
|
||||
{
|
||||
ftdm_status_t status;
|
||||
ftdm_sigmsg_t sigmsg;
|
||||
ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
|
||||
|
||||
memset(&sigmsg, 0, sizeof(sigmsg));
|
||||
|
||||
status = ftdm_span_poll_event(span, ms_timeout);
|
||||
|
||||
switch(status) {
|
||||
|
@ -1513,25 +1510,16 @@ static __inline__ ftdm_status_t check_events(ftdm_span_t *span, int ms_timeout)
|
|||
{
|
||||
ftdm_event_t *event;
|
||||
while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) {
|
||||
sigmsg.span_id = event->channel->span_id;
|
||||
sigmsg.chan_id = event->channel->chan_id;
|
||||
sigmsg.channel = event->channel;
|
||||
switch (event->enum_id) {
|
||||
case FTDM_OOB_ALARM_TRAP:
|
||||
sigmsg.event_id = FTDM_SIGEVENT_HWSTATUS_CHANGED;
|
||||
sigmsg.raw_data = (void *)FTDM_HW_LINK_DISCONNECTED;
|
||||
if (sangoma_boost_data->sigmod) {
|
||||
sangoma_boost_data->sigmod->on_hw_link_status_change(event->channel, FTDM_HW_LINK_DISCONNECTED);
|
||||
}
|
||||
ftdm_span_send_signal(span, &sigmsg);
|
||||
break;
|
||||
case FTDM_OOB_ALARM_CLEAR:
|
||||
sigmsg.event_id = FTDM_SIGEVENT_HWSTATUS_CHANGED;
|
||||
sigmsg.raw_data = (void *)FTDM_HW_LINK_CONNECTED;
|
||||
if (sangoma_boost_data->sigmod) {
|
||||
sangoma_boost_data->sigmod->on_hw_link_status_change(event->channel, FTDM_HW_LINK_CONNECTED);
|
||||
}
|
||||
ftdm_span_send_signal(span, &sigmsg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1032,12 +1032,11 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
|||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
ftdm_log(FTDM_LOG_DEBUG, "read wanpipe event %d\n", tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type);
|
||||
switch(tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type) {
|
||||
|
||||
case WP_TDMAPI_EVENT_LINK_STATUS:
|
||||
{
|
||||
ftdm_sigmsg_t sigmsg;
|
||||
memset(&sigmsg, 0, sizeof(sigmsg));
|
||||
switch(tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_link_status) {
|
||||
case WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED:
|
||||
event_id = FTDM_OOB_ALARM_CLEAR;
|
||||
|
@ -1046,11 +1045,6 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
|||
event_id = FTDM_OOB_ALARM_TRAP;
|
||||
break;
|
||||
};
|
||||
sigmsg.chan_id = ftdmchan->chan_id;
|
||||
sigmsg.span_id = ftdmchan->span_id;
|
||||
sigmsg.channel = ftdmchan;
|
||||
sigmsg.event_id = (event_id == FTDM_OOB_ALARM_CLEAR) ? FTDM_SIGEVENT_ALARM_CLEAR : FTDM_SIGEVENT_ALARM_TRAP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigmsg);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1121,6 +1115,7 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
|||
if (tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_dtmf_type == WAN_EC_TONE_STOP) {
|
||||
ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_MUTE);
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) {
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Queuing wanpipe DTMF: %c\n", tmp_dtmf[0]);
|
||||
ftdm_channel_queue_dtmf(ftdmchan, tmp_dtmf);
|
||||
}
|
||||
}
|
||||
|
@ -1129,20 +1124,12 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
|||
case WP_TDMAPI_EVENT_ALARM:
|
||||
{
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Got wanpipe alarms %d\n", tdm_api.wp_tdm_cmd.event.wp_api_event_alarm);
|
||||
ftdm_sigmsg_t sigmsg;
|
||||
memset(&sigmsg, 0, sizeof(sigmsg));
|
||||
/* FIXME: is this always alarm trap? what about clearing? */
|
||||
event_id = FTDM_OOB_ALARM_TRAP;
|
||||
sigmsg.chan_id = ftdmchan->chan_id;
|
||||
sigmsg.span_id = ftdmchan->span_id;
|
||||
sigmsg.channel = ftdmchan;
|
||||
sigmsg.event_id = (event_id == FTDM_OOB_ALARM_CLEAR) ? FTDM_SIGEVENT_ALARM_CLEAR : FTDM_SIGEVENT_ALARM_TRAP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigmsg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
ftdm_log(FTDM_LOG_WARNING, "Unhandled event %d\n", tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type);
|
||||
ftdm_log(FTDM_LOG_WARNING, "Unhandled wanpipe event %d\n", tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type);
|
||||
event_id = FTDM_OOB_INVALID;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1027,28 +1027,12 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
|
|||
break;
|
||||
case ZT_EVENT_ALARM:
|
||||
{
|
||||
ftdm_sigmsg_t sigmsg;
|
||||
ftdm_channel_t *ftdmchan = span->channels[i];
|
||||
event_id = FTDM_OOB_ALARM_TRAP;
|
||||
memset(&sigmsg, 0, sizeof(sigmsg));
|
||||
sigmsg.chan_id = ftdmchan->chan_id;
|
||||
sigmsg.span_id = ftdmchan->span_id;
|
||||
sigmsg.channel = ftdmchan;
|
||||
sigmsg.event_id = FTDM_SIGEVENT_ALARM_TRAP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigmsg);
|
||||
}
|
||||
break;
|
||||
case ZT_EVENT_NOALARM:
|
||||
{
|
||||
ftdm_sigmsg_t sigmsg;
|
||||
ftdm_channel_t *ftdmchan = span->channels[i];
|
||||
event_id = FTDM_OOB_ALARM_CLEAR;
|
||||
memset(&sigmsg, 0, sizeof(sigmsg));
|
||||
sigmsg.chan_id = ftdmchan->chan_id;
|
||||
sigmsg.span_id = ftdmchan->span_id;
|
||||
sigmsg.channel = ftdmchan;
|
||||
sigmsg.event_id = FTDM_SIGEVENT_ALARM_CLEAR;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigmsg);
|
||||
}
|
||||
break;
|
||||
case ZT_EVENT_BITSCHANGED:
|
||||
|
|
|
@ -220,10 +220,8 @@ typedef enum {
|
|||
FTDM_SIGEVENT_COLLECTED_DIGIT,
|
||||
FTDM_SIGEVENT_ADD_CALL,
|
||||
FTDM_SIGEVENT_RESTART,
|
||||
/* Signaling link status changed (D-chan up, down, R2 blocked etc) */
|
||||
/* Signaling status changed (D-chan up, down, R2 blocked etc) */
|
||||
FTDM_SIGEVENT_SIGSTATUS_CHANGED,
|
||||
/* Hardware link status changed (Line connected, disconnected) */
|
||||
FTDM_SIGEVENT_HWSTATUS_CHANGED,
|
||||
FTDM_SIGEVENT_INVALID
|
||||
} ftdm_signal_event_t;
|
||||
#define SIGNAL_STRINGS "START", "STOP", "TRANSFER", "ANSWER", "UP", "FLASH", "PROGRESS", \
|
||||
|
@ -412,6 +410,7 @@ typedef enum {
|
|||
FTDM_CHANNEL_MUTE = (1 << 24),
|
||||
FTDM_CHANNEL_USE_RX_GAIN = (1 << 25),
|
||||
FTDM_CHANNEL_USE_TX_GAIN = (1 << 26),
|
||||
FTDM_CHANNEL_IN_ALARM = (1 << 27),
|
||||
} ftdm_channel_flag_t;
|
||||
#if defined(__cplusplus) && defined(WIN32)
|
||||
// fix C2676
|
||||
|
|
Loading…
Reference in New Issue