diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-12-27 16:34:12 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-01-15 00:02:54 +0100 |
commit | 7173f63eed051a8b1e533682633e9c23859238ed (patch) | |
tree | cf1a54c8d29077b849fc18278f3ee1b2e2a7df9e | |
parent | 0977e0c4b875ae5f499ebe504d6f0c1d0c192c4b (diff) |
bsc: Fix "show lchan" for partially provided information
show lchan should be capable of showing all allocated lchans,
all of a given bts, a given trx, a given ts. This feature was
broken when I added the ability to show a more simple summary.
Restore the initial behavior by splitting out the for loops
for the bts/trx/ts and check if we have parsed all parameters
and then call and return the subroutine.
-rw-r--r-- | openbsc/src/libbsc/bsc_vty.c | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index ed74397ec..0c02552b0 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -903,6 +903,47 @@ static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan) VTY_NEWLINE); } + +static int dump_lchan_trx_ts(struct gsm_bts_trx_ts *ts, struct vty *vty, + void (*dump_cb)(struct vty *, struct gsm_lchan *)) +{ + int lchan_nr; + for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN; lchan_nr++) { + struct gsm_lchan *lchan = &ts->lchan[lchan_nr]; + if ((lchan->type == GSM_LCHAN_NONE) && (lchan->state == LCHAN_S_NONE)) + continue; + dump_cb(vty, lchan); + } + + return CMD_SUCCESS; +} + +static int dump_lchan_trx(struct gsm_bts_trx *trx, struct vty *vty, + void (*dump_cb)(struct vty *, struct gsm_lchan *)) +{ + int ts_nr; + + for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) { + struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr]; + dump_lchan_trx_ts(ts, vty, dump_cb); + } + + return CMD_SUCCESS; +} + +static int dump_lchan_bts(struct gsm_bts *bts, struct vty *vty, + void (*dump_cb)(struct vty *, struct gsm_lchan *)) +{ + int trx_nr; + + for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { + struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_nr); + dump_lchan_trx(trx, vty, dump_cb); + } + + return CMD_SUCCESS; +} + static int lchan_summary(struct vty *vty, int argc, const char **argv, void (*dump_cb)(struct vty *, struct gsm_lchan *)) { @@ -922,6 +963,9 @@ static int lchan_summary(struct vty *vty, int argc, const char **argv, return CMD_WARNING; } bts = gsm_bts_num(net, bts_nr); + + if (argc == 1) + return dump_lchan_bts(bts, vty, dump_cb); } if (argc >= 2) { trx_nr = atoi(argv[1]); @@ -931,6 +975,9 @@ static int lchan_summary(struct vty *vty, int argc, const char **argv, return CMD_WARNING; } trx = gsm_bts_trx_num(bts, trx_nr); + + if (argc == 2) + return dump_lchan_trx(trx, vty, dump_cb); } if (argc >= 3) { ts_nr = atoi(argv[2]); @@ -940,6 +987,9 @@ static int lchan_summary(struct vty *vty, int argc, const char **argv, return CMD_WARNING; } ts = &trx->ts[ts_nr]; + + if (argc == 3) + return dump_lchan_trx_ts(ts, vty, dump_cb); } if (argc >= 4) { lchan_nr = atoi(argv[3]); @@ -952,21 +1002,11 @@ static int lchan_summary(struct vty *vty, int argc, const char **argv, dump_cb(vty, lchan); return CMD_SUCCESS; } + + for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { bts = gsm_bts_num(net, bts_nr); - for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { - trx = gsm_bts_trx_num(bts, trx_nr); - for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) { - ts = &trx->ts[ts_nr]; - for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN; - lchan_nr++) { - lchan = &ts->lchan[lchan_nr]; - if ((lchan->type == GSM_LCHAN_NONE) && (lchan->state == LCHAN_S_NONE)) - continue; - dump_cb(vty, lchan); - } - } - } + dump_lchan_bts(bts, vty, dump_cb); } return CMD_SUCCESS; |