Add pri_dump_info and q921/q931 counters to libpri

git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@78 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
James Golovich 2004-03-15 05:53:25 +00:00
parent 09645488d6
commit d00abddee3
6 changed files with 66 additions and 2 deletions

View File

@ -24,12 +24,15 @@
# Uncomment if you want libpri not send PROGRESS_INDICATOR w/ALERTING
#ALERTING=-DALERTING_NO_PROGRESS
# Uncomment if you want libpri to count number of Q921/Q931 sent/received
#LIBPRI_COUNTERS=-DLIBPRI_COUNTERS
TOBJS=testpri.o
STATIC_LIBRARY=libpri.a
DYNAMIC_LIBRARY=libpri.so.1.0
STATIC_OBJS=pri.o q921.o prisched.o q931.o
DYNAMIC_OBJS=pri.lo q921.lo prisched.lo q931.lo
CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g $(ALERTING)
CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g $(ALERTING) $(LIBPRI_COUNTERS)
INSTALL_PREFIX=
all: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)

View File

@ -386,4 +386,8 @@ extern void pri_set_error(void (*__pri_error)(char *));
/* Set overlap mode */
#define PRI_SET_OVERLAPDIAL
extern void pri_set_overlapdial(struct pri *pri,int state);
#define PRI_DUMP_INFO
extern void pri_dump_info(struct pri *pri);
#endif

38
pri.c
View File

@ -66,6 +66,12 @@ struct pri *pri_new(int fd, int node, int switchtype)
p->localtype = node;
p->switchtype = switchtype;
p->cref = 1;
#ifdef LIBPRI_COUNTERS
p->q921_rxcount = 0;
p->q921_txcount = 0;
p->q931_rxcount = 0;
p->q931_txcount = 0;
#endif
/* Start Q.921 layer */
q921_start(p, 1);
}
@ -332,3 +338,35 @@ void pri_set_overlapdial(struct pri *pri,int state)
pri->overlapdial = state;
}
void pri_dump_info(struct pri *pri)
{
#ifdef LIBPRI_COUNTERS
struct q921_frame *f;
int q921outstanding = 0;
#endif
if (!pri)
return;
/* Might be nice to format these a little better */
pri_message("Switchtype: %s\n", pri_switch2str(pri->switchtype));
pri_message("Type: %s\n", pri_node2str(pri->localtype));
#ifdef LIBPRI_COUNTERS
/* Remember that Q921 Counters include Q931 packets (and any retransmissions) */
pri_message("Q931 RX: %d\n", pri->q931_rxcount);
pri_message("Q931 TX: %d\n", pri->q931_txcount);
pri_message("Q921 RX: %d\n", pri->q921_rxcount);
pri_message("Q921 TX: %d\n", pri->q921_txcount);
f = pri->txqueue;
while (f) {
q921outstanding++;
f = f->next;
}
pri_message("Q921 Outstanding: %d\n", q921outstanding);
#endif
pri_message("Sentrej: %d\n", pri->sentrej);
pri_message("SolicitFbit: %d\n", pri->solicitfbit);
pri_message("Retrans: %d\n", pri->retrans);
pri_message("Busy: %d\n", pri->busy);
pri_message("Overlap Dial: %d\n", pri->overlapdial);
}

View File

@ -82,6 +82,14 @@ struct pri {
/* do we do overlap dialing */
int overlapdial;
#ifdef LIBPRI_COUNTERS
/* q921/q931 packet counters */
unsigned int q921_txcount;
unsigned int q921_rxcount;
unsigned int q931_txcount;
unsigned int q931_rxcount;
#endif
};
extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);

7
q921.c
View File

@ -73,7 +73,9 @@ static int q921_transmit(struct pri *pri, q921_h *h, int len)
return 0;
}
#endif
#ifdef LIBPRI_COUNTERS
pri->q921_txcount++;
#endif
/* Just send it raw */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
q921_dump(h, len, pri->debug & PRI_DEBUG_Q921_RAW, 1);
@ -858,6 +860,9 @@ pri_event *q921_receive(struct pri *pri, q921_h *h, int len)
pri_event *e;
e = __q921_receive(pri, h, len);
reschedule_t203(pri);
#ifdef LIBPRI_COUNTERS
pri->q921_rxcount++;
#endif
return e;
}

6
q931.c
View File

@ -1476,6 +1476,9 @@ static int q931_xmit(struct pri *pri, q931_h *h, int len, int cr)
right order in the log */
if (pri->debug & PRI_DEBUG_Q931_DUMP)
q931_dump(h, len, 1);
#ifdef LIBPRI_COUNTERS
pri->q931_txcount++;
#endif
return 0;
}
@ -1935,6 +1938,9 @@ int q931_receive(struct pri *pri, q931_h *h, int len)
int missingmand;
if (pri->debug & PRI_DEBUG_Q931_DUMP)
q931_dump(h, len, 0);
#ifdef LIBPRI_COUNTERS
pri->q931_rxcount++;
#endif
mh = (q931_mh *)(h->contents + h->crlen);
if (h->pd == 0x3) {
/* This is the weird maintenance stuff. We majorly