freetdm: ISDN - Fix for some API commands printing ERR - no return
This commit is contained in:
parent
d655fa600f
commit
2246f3ca75
|
@ -1199,9 +1199,17 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_isdn_unload)
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
#define SANGOMA_ISDN_API_USAGE_TRACE "ftdm sangoma_isdn trace <q921|q931> <span name>\n"
|
||||
#define SANGOMA_ISDN_API_USAGE_SHOW_L1_STATS "ftdm sangoma_isdn l1_stats <span name>\n"
|
||||
#define SANGOMA_ISDN_API_USAGE_SHOW_SPANS "ftdm sangoma_isdn show_spans [<span name>]\n"
|
||||
|
||||
#define SANGOMA_ISDN_API_USAGE "\t"SANGOMA_ISDN_API_USAGE_TRACE \
|
||||
"\t"SANGOMA_ISDN_API_USAGE_SHOW_L1_STATS \
|
||||
"\t"SANGOMA_ISDN_API_USAGE_SHOW_SPANS
|
||||
|
||||
static FIO_API_FUNCTION(ftdm_sangoma_isdn_api)
|
||||
{
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
ftdm_status_t status = FTDM_EINVAL;
|
||||
char *mycmd = NULL, *argv[10] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
|
@ -1223,7 +1231,7 @@ static FIO_API_FUNCTION(ftdm_sangoma_isdn_api)
|
|||
ftdm_span_t *span;
|
||||
|
||||
if (argc < 3) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Usage: ftdm sangoma_isdn trace <q921|q931> <span name>\n");
|
||||
ftdm_log(FTDM_LOG_ERROR, "Usage: %s\n", SANGOMA_ISDN_API_USAGE_TRACE);
|
||||
status = FTDM_FAIL;
|
||||
goto done;
|
||||
}
|
||||
|
@ -1232,34 +1240,40 @@ static FIO_API_FUNCTION(ftdm_sangoma_isdn_api)
|
|||
status = ftdm_span_find_by_name(argv[2], &span);
|
||||
if (FTDM_SUCCESS != status) {
|
||||
stream->write_function(stream, "-ERR failed to find span by name %s\n", argv[2]);
|
||||
|
||||
status = FTDM_FAIL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!strcasecmp(trace_opt, "q921")) {
|
||||
sngisdn_activate_trace(span, SNGISDN_TRACE_Q921);
|
||||
status = sngisdn_activate_trace(span, SNGISDN_TRACE_Q921);
|
||||
} else if (!strcasecmp(trace_opt, "q931")) {
|
||||
sngisdn_activate_trace(span, SNGISDN_TRACE_Q931);
|
||||
status = sngisdn_activate_trace(span, SNGISDN_TRACE_Q931);
|
||||
} else if (!strcasecmp(trace_opt, "disable")) {
|
||||
sngisdn_activate_trace(span, SNGISDN_TRACE_DISABLE);
|
||||
status = sngisdn_activate_trace(span, SNGISDN_TRACE_DISABLE);
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR invalid trace option <q921|q931> <span name>\n");
|
||||
status = FTDM_FAIL;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[0], "l1_stats")) {
|
||||
ftdm_span_t *span;
|
||||
if (argc < 2) {
|
||||
stream->write_function(stream, "Usage: ftdm sangoma_isdn l1_stats <span name>\n");
|
||||
stream->write_function(stream, "Usage: %s\n", SANGOMA_ISDN_API_USAGE_SHOW_L1_STATS);
|
||||
status = FTDM_FAIL;
|
||||
goto done;
|
||||
}
|
||||
status = ftdm_span_find_by_name(argv[1], &span);
|
||||
if (FTDM_SUCCESS != status) {
|
||||
stream->write_function(stream, "-ERR failed to find span with name %s\n", argv[1]);
|
||||
/* Return SUCCESS because we do not want to print the general FTDM usage list */
|
||||
status = FTDM_SUCCESS;
|
||||
|
||||
status = FTDM_FAIL;
|
||||
goto done;
|
||||
}
|
||||
sngisdn_print_phy_stats(stream, span);
|
||||
status = sngisdn_show_l1_stats(stream, span);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[0], "show_spans")) {
|
||||
|
@ -1268,20 +1282,39 @@ static FIO_API_FUNCTION(ftdm_sangoma_isdn_api)
|
|||
status = ftdm_span_find_by_name(argv[1], &span);
|
||||
if (FTDM_SUCCESS != status) {
|
||||
stream->write_function(stream, "-ERR failed to find span with name %s\n", argv[1]);
|
||||
/* Return SUCCESS because we do not want to print the general FTDM usage list */
|
||||
status = FTDM_SUCCESS;
|
||||
|
||||
stream->write_function(stream, "Usage: %s\n", SANGOMA_ISDN_API_USAGE_SHOW_SPANS);
|
||||
status = FTDM_FAIL;
|
||||
goto done;
|
||||
}
|
||||
sngisdn_print_span(stream, span);
|
||||
status = FTDM_SUCCESS;
|
||||
status = sngisdn_show_span(stream, span);
|
||||
goto done;
|
||||
}
|
||||
sngisdn_print_spans(stream);
|
||||
status = sngisdn_show_spans(stream);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[0], "check_ids")) {
|
||||
sngisdn_check_free_ids();
|
||||
status = sngisdn_check_free_ids();
|
||||
goto done;
|
||||
}
|
||||
done:
|
||||
switch (status) {
|
||||
case FTDM_SUCCESS:
|
||||
stream->write_function(stream, "Command executed OK\n");
|
||||
break;
|
||||
case FTDM_EINVAL:
|
||||
stream->write_function(stream, "Invalid arguments [%s]\n", mycmd);
|
||||
stream->write_function(stream, "Usage:\n%s\n", SANGOMA_ISDN_API_USAGE);
|
||||
break;
|
||||
default:
|
||||
/* FTDM_FAIL - Do nothing since we already printed the cause of the error */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Return SUCCESS because we do not want to print the general FTDM usage list */
|
||||
status = FTDM_SUCCESS;
|
||||
|
||||
ftdm_safe_free(mycmd);
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -471,9 +471,9 @@ ftdm_status_t sngisdn_stack_start(ftdm_span_t *span);
|
|||
ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span);
|
||||
ftdm_status_t sngisdn_wake_up_phy(ftdm_span_t *span);
|
||||
|
||||
void sngisdn_print_phy_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span);
|
||||
void sngisdn_print_spans(ftdm_stream_handle_t *stream);
|
||||
void sngisdn_print_span(ftdm_stream_handle_t *stream, ftdm_span_t *span);
|
||||
ftdm_status_t sngisdn_show_l1_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span);
|
||||
ftdm_status_t sngisdn_show_spans(ftdm_stream_handle_t *stream);
|
||||
ftdm_status_t sngisdn_show_span(ftdm_stream_handle_t *stream, ftdm_span_t *span);
|
||||
|
||||
#endif /* __FTMOD_SNG_ISDN_H__ */
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@ SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_descr, ftdm_sngisdn_progind_descr
|
|||
SNGISDN_ENUM_NAMES(SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_STRINGS)
|
||||
SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str, ftdm_sngisdn_progind_loc_t, SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_INVALID)
|
||||
|
||||
ftdm_status_t sngisdn_check_free_ids(void);
|
||||
|
||||
extern ftdm_sngisdn_data_t g_sngisdn_data;
|
||||
void get_memory_info(void);
|
||||
|
||||
|
@ -1131,7 +1129,7 @@ ftdm_user_layer1_prot_t sngisdn_get_usrInfoLyr1Prot_from_stack(uint8_t layer1_pr
|
|||
return FTDM_USER_LAYER1_PROT_ULAW;
|
||||
}
|
||||
|
||||
void sngisdn_print_phy_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span)
|
||||
ftdm_status_t sngisdn_show_l1_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span)
|
||||
{
|
||||
L1Mngmt sts;
|
||||
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data;
|
||||
|
@ -1169,11 +1167,11 @@ void sngisdn_print_phy_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span)
|
|||
stream->write_function(stream, " TX Errors Details");
|
||||
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
|
||||
stream->write_function(stream, "Aborted:\t%u\tFifo:\t\t%u\tCarrier:\t%u\n", sts.t.sts.tx_aborted_errors, sts.t.sts.tx_fifo_errors, sts.t.sts.tx_carrier_errors);
|
||||
return;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void sngisdn_print_span(ftdm_stream_handle_t *stream, ftdm_span_t *span)
|
||||
ftdm_status_t sngisdn_show_span(ftdm_stream_handle_t *stream, ftdm_span_t *span)
|
||||
{
|
||||
ftdm_signaling_status_t sigstatus;
|
||||
ftdm_alarm_flag_t alarmbits;
|
||||
|
@ -1188,18 +1186,18 @@ void sngisdn_print_span(ftdm_stream_handle_t *stream, ftdm_span_t *span)
|
|||
stream->write_function(stream, "span:%s physical:%s signalling:%s\n",
|
||||
span->name, alarmbits ? "ALARMED" : "OK",
|
||||
ftdm_signaling_status2str(sigstatus));
|
||||
return;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
void sngisdn_print_spans(ftdm_stream_handle_t *stream)
|
||||
ftdm_status_t sngisdn_show_spans(ftdm_stream_handle_t *stream)
|
||||
{
|
||||
int i;
|
||||
for(i=1;i<=MAX_L1_LINKS;i++) {
|
||||
if (g_sngisdn_data.spans[i]) {
|
||||
sngisdn_print_span(stream, g_sngisdn_data.spans[i]->ftdm_span);
|
||||
sngisdn_show_span(stream, g_sngisdn_data.spans[i]->ftdm_span);
|
||||
}
|
||||
}
|
||||
return;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_status_t sngisdn_add_var(sngisdn_chan_data_t *sngisdn_info, const char* var, const char* val)
|
||||
|
|
Loading…
Reference in New Issue