From e0f4da27734d6451f231683417b259b2c773f1e0 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Wed, 8 Sep 2010 21:43:14 +0000 Subject: [PATCH] Added more parameter checks to pri_set_timer() and pri_get_timer(). Made pri_dump_info_str() output a line for each Q.921 TEI Tx queue when LIBPRI_COUNTERS is defined. git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@1965 2fbb986a-6c06-0410-b554-c9c1f0a7f128 --- pri.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/pri.c b/pri.c index e453b90..a5c025f 100644 --- a/pri.c +++ b/pri.c @@ -220,20 +220,23 @@ static void pri_default_timers(struct pri *ctrl, int switchtype) } } -int pri_set_timer(struct pri *pri, int timer, int value) +int pri_set_timer(struct pri *ctrl, int timer, int value) { - if (timer < 0 || timer > PRI_MAX_TIMERS || value < 0) + if (!ctrl || timer < 0 || PRI_MAX_TIMERS <= timer || value < 0) { return -1; - - pri->timers[timer] = value; + } + ctrl = PRI_MASTER(ctrl); + ctrl->timers[timer] = value; return 0; } -int pri_get_timer(struct pri *pri, int timer) +int pri_get_timer(struct pri *ctrl, int timer) { - if (timer < 0 || timer > PRI_MAX_TIMERS) + if (!ctrl || timer < 0 || PRI_MAX_TIMERS <= timer) { return -1; - return pri->timers[timer]; + } + ctrl = PRI_MASTER(ctrl); + return ctrl->timers[timer]; } int pri_set_service_message_support(struct pri *pri, int supportflag) @@ -1419,6 +1422,7 @@ char *pri_dump_info_str(struct pri *ctrl) size_t used; #ifdef LIBPRI_COUNTERS struct q921_frame *f; + struct pri *link; unsigned q921outstanding; #endif unsigned idx; @@ -1434,6 +1438,8 @@ char *pri_dump_info_str(struct pri *ctrl) return NULL; } + ctrl = PRI_MASTER(ctrl); + /* Might be nice to format these a little better */ used = 0; used = pri_snprintf(buf, used, buf_size, "Switchtype: %s\n", @@ -1445,13 +1451,14 @@ char *pri_dump_info_str(struct pri *ctrl) used = pri_snprintf(buf, used, buf_size, "Q931 TX: %d\n", ctrl->q931_txcount); used = pri_snprintf(buf, used, buf_size, "Q921 RX: %d\n", ctrl->q921_rxcount); used = pri_snprintf(buf, used, buf_size, "Q921 TX: %d\n", ctrl->q921_txcount); - q921outstanding = 0; - f = ctrl->txqueue; - while (f) { - q921outstanding++; - f = f->next; + for (link = ctrl; link; link = link->subchannel) { + q921outstanding = 0; + for (f = link->txqueue; f; f = f->next) { + ++q921outstanding; + } + used = pri_snprintf(buf, used, buf_size, "Q921 Outstanding: %u (TEI=%d)\n", + q921outstanding, link->tei); } - used = pri_snprintf(buf, used, buf_size, "Q921 Outstanding: %u\n", q921outstanding); #endif #if 0 used = pri_snprintf(buf, used, buf_size, "Window Length: %d/%d\n",