From a425aedc1ee2c0bba4ba20904943afb21bd6e2e5 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 5 Apr 2009 12:52:24 +0200 Subject: [PATCH] Added display of current active TEI values (L2) at lcradmin. modified: README modified: lcradmin.c modified: lcrsocket.h modified: mISDN.cpp modified: mISDN.h modified: socket_server.c --- README | 1 + lcradmin.c | 27 ++++++++++++++++++++++----- lcrsocket.h | 1 + mISDN.cpp | 6 +++++- mISDN.h | 1 + socket_server.c | 1 + 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/README b/README index fc19664..6027472 100644 --- a/README +++ b/README @@ -482,4 +482,5 @@ Changes after Version 1.4 release - chan_lcr: Fixed compile problem with newer versions. - chan_lcr: Open b-channel if asterisk indicates "PROGRESS". -> Also if tones are available, asterisk gets "PROGRESS" indication. +- lcradmin displays TEI values in NT-mode PTMP diff --git a/lcradmin.c b/lcradmin.c index 306a0da..b8b9ac3 100644 --- a/lcradmin.c +++ b/lcradmin.c @@ -670,7 +670,7 @@ const char *admin_state(int sock, char *argv[]) if (m[i].u.i.block >= 2) { if (m[i].u.i.portnum < 0) - SPRINT(buffer, "%s (port ?: %s)%s", m[i].u.i.interface_name, m[i].u.i.portname, (m[i].u.i.extension)?" extension":""); + SPRINT(buffer, "%s (port ?: %s)%s", m[i].u.i.interface_name, m[i].u.i.portname, (m[i].u.i.extension)?" exten":""); else SPRINT(buffer, "%s (port %d: %s)%s", m[i].u.i.interface_name, m[i].u.i.portnum, m[i].u.i.portname, (m[i].u.i.extension)?" extension":""); addstr(buffer); @@ -684,7 +684,7 @@ const char *admin_state(int sock, char *argv[]) SPRINT(buffer, "(port %d: %s)", m[i].u.i.portnum, m[i].u.i.portname); addstr(buffer); color(cyan); - SPRINT(buffer, " %s %s%s%s%s", (m[i].u.i.ntmode)?"NT-mode":"TE-mode", (m[i].u.i.ptp)?"ptp":"ptmp", (m[i].u.i.l1hold)?" l1hold":"", (m[i].u.i.l2hold)?" l2hold":"", (m[i].u.i.extension)?" extension":""); + SPRINT(buffer, " %s %s%s%s%s", (m[i].u.i.ntmode)?"NT":"TE", (m[i].u.i.ptp)?"ptp":"ptmp", (m[i].u.i.l1hold)?" l1hold":"", (m[i].u.i.l2hold)?" l2hold":"", (m[i].u.i.extension)?" extension":""); addstr(buffer); if (m[i].u.i.use) color(green); @@ -696,15 +696,32 @@ const char *admin_state(int sock, char *argv[]) { color((m[i].u.i.l2link > 0)?green:red); if (m[i].u.i.l2link < 0) - addstr(" L2 unknown"); + addstr(" L2 unkn"); else addstr((m[i].u.i.l2link)?" L2 UP":" L2 down"); + } else + { + k = 0; + color(green); + j = 0; + while(j < 128) + { + if (m[i].u.i.l2mask[j>>3] & (1 << (j&7))) + { + SPRINT(buffer, "%s%d", k?",":" TEI(", j); + addstr(buffer); + k = 1; + } + j++; + } + if (k) + addstr(")"); } color((m[i].u.i.l1link > 0)?green:blue); if (m[i].u.i.l1link < 0) - addstr(" L1 unknown"); + addstr(" L1 unkn"); else - addstr((m[i].u.i.l1link)?" L1 ACTIVE":" L1 inactive"); + addstr((m[i].u.i.l1link)?" L1 UP":" L1 down"); if (m[i].u.i.los) { color(red); diff --git a/lcrsocket.h b/lcrsocket.h index 69b8c7d..edb882b 100644 --- a/lcrsocket.h +++ b/lcrsocket.h @@ -76,6 +76,7 @@ struct admin_response_interface { int use; /* number of ports that use this interface */ int l1link; /* down(0) or up(1) */ int l2link; /* down(0) or up(1) */ + unsigned char l2mask[16]; /* one bit for each tei */ int los, ais, rdi, slip_tx, slip_rx; int channels; char busy[256]; /* if port is idle(0) busy(1) */ diff --git a/mISDN.cpp b/mISDN.cpp index 1bb9362..2cbd39f 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -71,7 +71,7 @@ int mISDN_initialize(void) if (options.deb & DEBUG_STACK) { SPRINT(filename, "%s/debug_mISDN.log", LOG_DIR); - mISDN_debug_init(0xffffffff, filename, filename, filename); + mISDN_debug_init(0xfffffeff, filename, filename, filename); } else mISDN_debug_init(0, NULL, NULL, NULL); @@ -2006,6 +2006,8 @@ int mISDN_handler(void) add_trace("tei", NULL, "%d", l3m->pid); end_trace(); mISDNport->l2link = 1; + if (l3m->pid < 128) + mISDNport->l2mask[l3m->pid >> 3] |= (1 << (l3m->pid & 7)); if ((!mISDNport->ntmode || mISDNport->ptp) && l3m->pid < 127) { if (mISDNport->l2establish) @@ -2017,6 +2019,8 @@ int mISDN_handler(void) break; case MT_L2RELEASE: + if (l3m->pid < 128) + mISDNport->l2mask[l3m->pid >> 3] &= ~(1 << (l3m->pid & 7)); if (!mISDNport->l2establish) { l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN); diff --git a/mISDN.h b/mISDN.h index 9907b9a..90f686b 100644 --- a/mISDN.h +++ b/mISDN.h @@ -39,6 +39,7 @@ struct mISDNport { int ptp; /* if ptp is set, we keep track of l2link */ int l1link; /* if l1 is available (only works with nt-mode) */ int l2link; /* if l2 is available (at PTP we take this serious) */ + unsigned char l2mask[16]; /* 128 bits for each tei */ int l1hold; /* set, if layer 1 should be holt */ int l2hold; /* set, if layer 2 must be hold/checked */ time_t l2establish; /* time until establishing after link failure */ diff --git a/socket_server.c b/socket_server.c index a527114..9abb5b2 100644 --- a/socket_server.c +++ b/socket_server.c @@ -914,6 +914,7 @@ int admin_state(struct admin_queue **responsep) response->am[num].u.i.l1link = mISDNport->l1link; /* l2link */ response->am[num].u.i.l2link = mISDNport->l2link; + memcpy(response->am[num].u.i.l2mask, mISDNport->l2mask, 16); /* los */ response->am[num].u.i.los = mISDNport->los; /* ais */ -- 2.13.6