adding termination service states(in-service/out-of-service) flags and
reject incoming megaco request if requested termination is not in service
This commit is contained in:
parent
5d3718fdb8
commit
0c87442dd7
|
@ -128,6 +128,8 @@ static void ctdm_report_alarms(ftdm_channel_t *channel)
|
|||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "general");
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Reporting [%s] alarms for %s:%d\n",
|
||||
(alarmflag?"ftdm-alarm-clear":"ftdm-alarm-trap"), ftdm_channel_get_span_name(channel), ftdm_channel_get_id(channel));
|
||||
|
||||
switch_event_fire(&event);
|
||||
return;
|
||||
|
@ -184,6 +186,9 @@ static void ctdm_event_handler(switch_event_t *event)
|
|||
return;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Requesting alarm status for %s:%d\n",
|
||||
ftdm_channel_get_span_name(channel), ftdm_channel_get_id(channel));
|
||||
|
||||
ctdm_report_alarms(channel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -578,8 +578,9 @@ switch_status_t megaco_profile_start(const char *profilename)
|
|||
switch_core_new_memory_pool(&pool);
|
||||
profile = switch_core_alloc(pool, sizeof(*profile));
|
||||
profile->pool = pool;
|
||||
profile->physical_terminations = NULL;
|
||||
profile->name = switch_core_strdup(pool, profilename);
|
||||
profile->next_context_id++;
|
||||
profile->next_context_id++;
|
||||
profile->inact_tmr = 0x00;
|
||||
profile->inact_tmr_task_id = 0x00;
|
||||
|
||||
|
|
|
@ -2306,18 +2306,22 @@ switch_status_t mg_send_term_service_change(char *span_name, char *chan_number,
|
|||
{
|
||||
case MG_TERM_SERVICE_STATE_IN_SERVICE:
|
||||
{
|
||||
/* set INS flag...clear oos flag */
|
||||
switch_clear_flag(term, MG_OUT_OF_SERVICE);
|
||||
switch_set_flag(term, MG_IN_SERVICE);
|
||||
ret = mg_send_ins_service_change(term->profile, term->name, 0x00 );
|
||||
if(switch_test_flag(term, MG_OUT_OF_SERVICE)){
|
||||
/* set INS flag...clear oos flag */
|
||||
switch_clear_flag(term, MG_OUT_OF_SERVICE);
|
||||
switch_set_flag(term, MG_IN_SERVICE);
|
||||
ret = mg_send_ins_service_change(term->profile, term->name, 0x00 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MG_TERM_SERVICE_STATE_OUT_OF_SERVICE:
|
||||
{
|
||||
/* set OOS flag...clear ins flag */
|
||||
switch_clear_flag(term, MG_IN_SERVICE);
|
||||
switch_set_flag(term, MG_OUT_OF_SERVICE);
|
||||
ret = mg_send_oos_service_change(term->profile, term->name, 0x00 );
|
||||
if(switch_test_flag(term, MG_IN_SERVICE)){
|
||||
/* set OOS flag...clear ins flag */
|
||||
switch_clear_flag(term, MG_IN_SERVICE);
|
||||
switch_set_flag(term, MG_OUT_OF_SERVICE);
|
||||
ret = mg_send_oos_service_change(term->profile, term->name, 0x00 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -213,6 +213,7 @@ void mg_create_tdm_term(megaco_profile_t *profile, const char *tech, const char
|
|||
term->name = switch_core_sprintf(pool, "%s%d", prefix, chan_num);
|
||||
term->u.tdm.channel = chan_num;
|
||||
term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix);
|
||||
switch_set_flag(term, MG_OUT_OF_SERVICE);
|
||||
|
||||
switch_core_hash_insert_wrlock(profile->terminations, term->name, term, profile->terminations_rwlock);
|
||||
term->next = profile->physical_terminations;
|
||||
|
@ -222,7 +223,6 @@ void mg_create_tdm_term(megaco_profile_t *profile, const char *tech, const char
|
|||
"Mapped termination [%s] to freetdm span: %s chan: %d\n",
|
||||
term->name, term->u.tdm.span_name, term->u.tdm.channel);
|
||||
megaco_prepare_tdm_termination(term);
|
||||
|
||||
}
|
||||
/****************************************************************************************************************************/
|
||||
switch_status_t mg_config_cleanup(megaco_profile_t* profile)
|
||||
|
|
|
@ -549,6 +549,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
|||
if ((CH_CMD_TYPE_IND == cmd->cmdType.val) &&
|
||||
(MGT_TERMID_OTHER == termId->type.val)){
|
||||
if(SWITCH_STATUS_FALSE == mg_stack_termination_is_in_service(mg_profile, (char*)termId->name.lcl.val, termId->name.lcl.len)){
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Termination[%s] not in service \n", (char*)termId->name.lcl.val);
|
||||
mg_util_set_term_string(&errTxt, termId);
|
||||
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID;
|
||||
goto error;
|
||||
|
|
Loading…
Reference in New Issue