more alarms
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@1051 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
737597eba6
commit
d32f7f67a3
|
@ -1447,6 +1447,66 @@ zap_status_t zap_channel_from_event(zap_sigmsg_t *sigmsg, switch_core_session_t
|
|||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
static ZIO_SIGNAL_CB_FUNCTION(on_common_signal)
|
||||
{
|
||||
switch_event_t *event = NULL;
|
||||
|
||||
switch (sigmsg->event_id) {
|
||||
|
||||
case ZAP_SIGEVENT_ALARM_CLEAR:
|
||||
case ZAP_SIGEVENT_ALARM_TRAP:
|
||||
{
|
||||
if (zap_channel_get_alarms(sigmsg->channel) != ZAP_SUCCESS) {
|
||||
zap_log(ZAP_LOG_ERROR, "failed to retrieve alarms\n");
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
if (switch_event_create(&event, SWITCH_EVENT_TRAP) != SWITCH_STATUS_SUCCESS) {
|
||||
zap_log(ZAP_LOG_ERROR, "failed to create alarms events\n");
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
if (sigmsg->event_id == ZAP_SIGEVENT_ALARM_CLEAR) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "zap-alarm-clear");
|
||||
} else {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "zap-alarm-trap");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return ZAP_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_RECOVER)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "recover");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_LOOPBACK)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "loopback");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_YELLOW)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "yellow");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_RED)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "red");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_BLUE)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "blue");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_NOTOPEN)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "notopen");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_AIS)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "ais");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_RAI)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "rai");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_GENERAL)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "general");
|
||||
}
|
||||
switch_event_fire(&event);
|
||||
|
||||
return ZAP_BREAK;
|
||||
}
|
||||
|
||||
static ZIO_SIGNAL_CB_FUNCTION(on_fxo_signal)
|
||||
{
|
||||
|
@ -1729,6 +1789,10 @@ static ZIO_SIGNAL_CB_FUNCTION(on_r2_signal)
|
|||
|
||||
zap_log(ZAP_LOG_DEBUG, "Got R2 channel sig [%s] in channel %d\n", zap_signal_event2str(sigmsg->event_id), sigmsg->channel->physical_chan_id);
|
||||
|
||||
if (on_common_signal(sigmsg) == ZAP_BREAK) {
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
switch(sigmsg->event_id) {
|
||||
/* on_call_disconnect from the R2 side */
|
||||
case ZAP_SIGEVENT_STOP:
|
||||
|
@ -1824,49 +1888,6 @@ static ZIO_SIGNAL_CB_FUNCTION(on_r2_signal)
|
|||
return status;
|
||||
}
|
||||
|
||||
static ZIO_SIGNAL_CB_FUNCTION(on_common_signal)
|
||||
{
|
||||
switch_event_t *event = NULL;
|
||||
|
||||
switch (sigmsg->event_id) {
|
||||
|
||||
case ZAP_SIGEVENT_ALARM_CLEAR:
|
||||
case ZAP_SIGEVENT_ALARM_TRAP:
|
||||
{
|
||||
if (zap_channel_get_alarms(sigmsg->channel) != ZAP_SUCCESS) {
|
||||
zap_log(ZAP_LOG_ERROR, "failed to retrieve alarms\n");
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
if (switch_event_create(&event, SWITCH_EVENT_TRAP) != SWITCH_STATUS_SUCCESS) {
|
||||
zap_log(ZAP_LOG_ERROR, "failed to create alarms events\n");
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
if (sigmsg->event_id == ZAP_SIGEVENT_ALARM_CLEAR) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "zap-alarm-clear");
|
||||
} else {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "zap-alarm-trap");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return ZAP_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_RED)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "red");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_YELLOW)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "yellow");
|
||||
}
|
||||
if (zap_test_alarm_flag(sigmsg->channel, ZAP_ALARM_BLUE)) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "blue");
|
||||
}
|
||||
switch_event_fire(&event);
|
||||
|
||||
return ZAP_BREAK;
|
||||
}
|
||||
|
||||
static ZIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
|
@ -1966,6 +1987,10 @@ static ZIO_SIGNAL_CB_FUNCTION(on_analog_signal)
|
|||
{
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (on_common_signal(sigmsg) == ZAP_BREAK) {
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
switch (sigmsg->channel->type) {
|
||||
case ZAP_CHAN_TYPE_FXO:
|
||||
case ZAP_CHAN_TYPE_EM:
|
||||
|
|
|
@ -897,11 +897,38 @@ static ZIO_GET_ALARMS_FUNCTION(wanpipe_get_alarms)
|
|||
}
|
||||
alarms = tdm_api.wp_tdm_cmd.fe_alarms;
|
||||
#endif
|
||||
zchan->alarm_flags = ZAP_ALARM_NONE;
|
||||
|
||||
|
||||
zchan->alarm_flags = alarms ? ZAP_ALARM_RED : ZAP_ALARM_NONE;
|
||||
if (alarms & WAN_TE_BIT_ALARM_RED) {
|
||||
zchan->alarm_flags |= ZAP_ALARM_RED;
|
||||
alarms &= ~WAN_TE_BIT_ALARM_RED;
|
||||
}
|
||||
|
||||
return ZAP_SUCCESS;
|
||||
if (alarms & WAN_TE_BIT_ALARM_AIS) {
|
||||
zchan->alarm_flags |= ZAP_ALARM_AIS;
|
||||
zchan->alarm_flags |= ZAP_ALARM_BLUE;
|
||||
alarms &= ~WAN_TE_BIT_ALARM_AIS;
|
||||
}
|
||||
|
||||
if (alarms & WAN_TE_BIT_ALARM_RAI) {
|
||||
zchan->alarm_flags |= ZAP_ALARM_RAI;
|
||||
zchan->alarm_flags |= ZAP_ALARM_YELLOW;
|
||||
alarms &= ~WAN_TE_BIT_ALARM_RAI;
|
||||
}
|
||||
|
||||
/* still missing to map:
|
||||
* ZAP_ALARM_RECOVER
|
||||
* ZAP_ALARM_LOOPBACK
|
||||
* ZAP_ALARM_NOTOPEN
|
||||
* */
|
||||
|
||||
/* if we still have alarms that we did not map, set the general alarm */
|
||||
if (alarms) {
|
||||
zap_log(ZAP_LOG_DEBUG, "Unmapped wanpipe alarms: %d\n", alarms);
|
||||
zchan->alarm_flags |= ZAP_ALARM_GENERAL;
|
||||
}
|
||||
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1055,7 +1082,15 @@ ZIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
|||
}
|
||||
break;
|
||||
case WP_TDMAPI_EVENT_ALARM:
|
||||
event_id = ZAP_OOB_NOOP;
|
||||
zap_log(ZAP_LOG_DEBUG, "Got wanpipe alarms %d\n", tdm_api.wp_tdm_cmd.event.wp_api_event_alarm);
|
||||
zap_sigmsg_t sigmsg;
|
||||
memset(&sigmsg, 0, sizeof(sigmsg));
|
||||
event_id = ZAP_OOB_ALARM_TRAP;
|
||||
sigmsg.chan_id = zchan->chan_id;
|
||||
sigmsg.span_id = zchan->span_id;
|
||||
sigmsg.channel = zchan;
|
||||
sigmsg.event_id = (event_id == ZAP_OOB_ALARM_CLEAR) ? ZAP_SIGEVENT_ALARM_CLEAR : ZAP_SIGEVENT_ALARM_TRAP;
|
||||
zap_span_send_signal(zchan->span, &sigmsg);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue