Add CLI "pri show channels" command.

List the current mapping of DAHDI B channels to Asterisk channel names and
which calls are on hold or call-waiting.  Calls on hold or call-waiting
are not associated with any B channel.

JIRA LIBPRI-27
JIRA SWP-2547


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@307964 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2011-02-15 21:42:55 +00:00
parent b1db966684
commit 4a48600231
3 changed files with 108 additions and 6 deletions

View File

@@ -109,6 +109,25 @@ static int pri_gendigittimeout = 8000;
static int pri_active_dchan_index(struct sig_pri_span *pri);
static const char *sig_pri_call_level2str(enum sig_pri_call_level level)
{
switch (level) {
case SIG_PRI_CALL_LEVEL_IDLE:
return "Idle";
case SIG_PRI_CALL_LEVEL_SETUP:
return "Setup";
case SIG_PRI_CALL_LEVEL_OVERLAP:
return "Overlap";
case SIG_PRI_CALL_LEVEL_PROCEEDING:
return "Proceeding";
case SIG_PRI_CALL_LEVEL_ALERTING:
return "Alerting";
case SIG_PRI_CALL_LEVEL_CONNECT:
return "Connect";
}
return "Unknown";
}
static inline void pri_rel(struct sig_pri_span *pri)
{
ast_mutex_unlock(&pri->lock);
@@ -7880,8 +7899,9 @@ int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char
}
if (pvt->call_level < SIG_PRI_CALL_LEVEL_CONNECT) {
ast_log(LOG_WARNING,
"Span %d: Digit '%c' may be ignored by peer. (Call level:%d)\n",
pvt->pri->span, digit, pvt->call_level);
"Span %d: Digit '%c' may be ignored by peer. (Call level:%d(%s))\n",
pvt->pri->span, digit, pvt->call_level,
sig_pri_call_level2str(pvt->call_level));
}
}
return 1;
@@ -8300,6 +8320,54 @@ void sig_pri_chan_delete(struct sig_pri_chan *doomed)
ast_free(doomed);
}
#define SIG_PRI_SC_HEADER "%-4s %4s %-4s %-10s %-4s %s\n"
#define SIG_PRI_SC_LINE "%4d %4d %-4s %-10s %-4s %s"
void sig_pri_cli_show_channels_header(int fd)
{
ast_cli(fd, SIG_PRI_SC_HEADER, "PRI", "", "B", "Call", "PRI", "Channel");
ast_cli(fd, SIG_PRI_SC_HEADER, "Span", "Chan", "Chan", "Level", "Call", "Name");
}
void sig_pri_cli_show_channels(int fd, struct sig_pri_span *pri)
{
char line[256];
int idx;
struct sig_pri_chan *pvt;
ast_mutex_lock(&pri->lock);
for (idx = 0; idx < pri->numchans; ++idx) {
if (!pri->pvts[idx]) {
continue;
}
pvt = pri->pvts[idx];
sig_pri_lock_private(pvt);
sig_pri_lock_owner(pri, idx);
if (pvt->no_b_channel && !pvt->call && !pvt->owner) {
/* Don't show held/call-waiting channels if they are not in use. */
sig_pri_unlock_private(pvt);
continue;
}
snprintf(line, sizeof(line), SIG_PRI_SC_LINE,
pri->span,
pvt->channel,
pvt->no_b_channel ? "No" : "Yes",/* Has media */
sig_pri_call_level2str(pvt->call_level),
pvt->call ? "Yes" : "No",
pvt->owner ? pvt->owner->name : "");
if (pvt->owner) {
ast_channel_unlock(pvt->owner);
}
sig_pri_unlock_private(pvt);
ast_mutex_unlock(&pri->lock);
ast_cli(fd, "%s\n", line);
ast_mutex_lock(&pri->lock);
}
ast_mutex_unlock(&pri->lock);
}
static void build_status(char *s, size_t len, int status, int active)
{
if (!s || len < 1) {