added openzap CLI tracing

This commit is contained in:
Moises Silva 2010-04-13 12:23:31 -04:00
parent 2ffef4c358
commit 53874730cd
3 changed files with 76 additions and 0 deletions

View File

@ -3122,6 +3122,69 @@ SWITCH_STANDARD_API(oz_function)
}
}
stream->write_function(stream, "+OK gains set to Rx %f and Tx %f\n", rxgain, txgain);
} else if (!strcasecmp(argv[0], "trace")) {
char tracepath[255];
int i = 0;
uint32_t chan_id = 0;
zap_span_t *span = NULL;
if (argc < 3) {
stream->write_function(stream, "-ERR Usage: oz trace <path> <span_id> [<chan_id>]\n");
goto end;
}
zap_span_find_by_name(argv[2], &span);
if (!span) {
stream->write_function(stream, "-ERR invalid span\n");
goto end;
}
if (argc > 3) {
chan_id = atoi(argv[3]);
if (chan_id > span->chan_count) {
stream->write_function(stream, "-ERR invalid chan\n");
goto end;
}
}
if (chan_id) {
snprintf(tracepath, sizeof(tracepath), "%s-in-c%d", argv[1], chan_id);
zap_channel_command(span->channels[chan_id], ZAP_COMMAND_TRACE_INPUT, tracepath);
snprintf(tracepath, sizeof(tracepath), "%s-out-c%d", argv[1], chan_id);
zap_channel_command(span->channels[chan_id], ZAP_COMMAND_TRACE_OUTPUT, tracepath);
} else {
for (i = 1; i < (int)span->chan_count; i++) {
snprintf(tracepath, sizeof(tracepath), "%s-in-c%d", argv[1], i);
zap_channel_command(span->channels[i], ZAP_COMMAND_TRACE_INPUT, tracepath);
snprintf(tracepath, sizeof(tracepath), "%s-out-c%d", argv[1], i);
zap_channel_command(span->channels[i], ZAP_COMMAND_TRACE_OUTPUT, tracepath);
}
}
stream->write_function(stream, "+OK trace enabled with prefix path %s\n", argv[1]);
} else if (!strcasecmp(argv[0], "notrace")) {
uint32_t i = 0;
uint32_t chan_id = 0;
zap_span_t *span = NULL;
if (argc < 2) {
stream->write_function(stream, "-ERR Usage: oz notrace <span_id> [<chan_id>]\n");
goto end;
}
zap_span_find_by_name(argv[1], &span);
if (!span) {
stream->write_function(stream, "-ERR invalid span\n");
goto end;
}
if (argc > 2) {
chan_id = atoi(argv[2]);
if (chan_id > span->chan_count) {
stream->write_function(stream, "-ERR invalid chan\n");
goto end;
}
}
if (chan_id) {
zap_channel_command(span->channels[chan_id], ZAP_COMMAND_TRACE_END_ALL, NULL);
} else {
for (i = 1; i < (int)span->chan_count; i++) {
zap_channel_command(span->channels[i], ZAP_COMMAND_TRACE_END_ALL, NULL);
}
}
stream->write_function(stream, "+OK trace disabled\n");
} else {
char *rply = zap_api_execute(cmd, NULL);

View File

@ -277,6 +277,7 @@ typedef enum {
ZAP_COMMAND_DISABLE_PROGRESS_DETECT,
ZAP_COMMAND_TRACE_INPUT,
ZAP_COMMAND_TRACE_OUTPUT,
ZAP_COMMAND_TRACE_END_ALL,
ZAP_COMMAND_ENABLE_CALLERID_DETECT,
ZAP_COMMAND_DISABLE_CALLERID_DETECT,
ZAP_COMMAND_ENABLE_ECHOCANCEL,

View File

@ -1519,6 +1519,18 @@ OZ_DECLARE(zap_status_t) zap_channel_command(zap_channel_t *zchan, zap_command_t
GOTO_STATUS(done, ZAP_FAIL);
}
break;
case ZAP_COMMAND_TRACE_END_ALL:
{
if (zchan->fds[0] > 0) {
close(zchan->fds[0]);
zchan->fds[0] = -1;
}
if (zchan->fds[1] > 0) {
close(zchan->fds[1]);
zchan->fds[1] = -1;
}
GOTO_STATUS(done, ZAP_SUCCESS);
}
case ZAP_COMMAND_SET_INTERVAL:
{
if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_INTERVAL)) {