Make PRI_DEBUG_Q921_RAW work independantly of PRI_DEBUG_Q921_DUMP

Ensure that the DUMP and RAW flags work independently in q921_dump().

(closes issue PRI-119)
Patch-by: wimpy


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2282 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
Kinsey Moore 2012-02-03 23:12:57 +00:00
parent 2c159d4685
commit 17649b363b
3 changed files with 123 additions and 119 deletions

View File

@ -273,7 +273,7 @@ static inline int Q921_ADD(int a, int b)
} }
/* Dumps a *known good* Q.921 packet */ /* Dumps a *known good* Q.921 packet */
extern void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx); extern void q921_dump(struct pri *pri, q921_h *h, int len, int debugflags, int txrx);
/* Bring up the D-channel */ /* Bring up the D-channel */
void q921_start(struct q921_link *link); void q921_start(struct q921_link *link);

View File

@ -71,7 +71,7 @@ static int pri_open(char *dev)
static void dump_packet(struct pri *pri, char *buf, int len, int txrx) static void dump_packet(struct pri *pri, char *buf, int len, int txrx)
{ {
q921_h *h = (q921_h *)buf; q921_h *h = (q921_h *)buf;
q921_dump(pri, h, len, 1, txrx); q921_dump(pri, h, len, PRI_DEBUG_ALL, txrx);
if (!((h->h.data[0] & Q921_FRAMETYPE_MASK) & 0x3)) { if (!((h->h.data[0] & Q921_FRAMETYPE_MASK) & 0x3)) {
q931_dump(pri, h->h.tei, (q931_h *)(h->i.data), len - 4 - 2 /* FCS */, txrx); q931_dump(pri, h->h.tei, (q931_h *)(h->i.data), len - 4 - 2 /* FCS */, txrx);
} }

12
q921.c
View File

@ -186,7 +186,7 @@ static int q921_transmit(struct pri *ctrl, q921_h *h, int len)
ctrl->q921_txcount++; ctrl->q921_txcount++;
/* Just send it raw */ /* Just send it raw */
if (ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW)) if (ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW))
q921_dump(ctrl, h, len, ctrl->debug & PRI_DEBUG_Q921_RAW, 1); q921_dump(ctrl, h, len, ctrl->debug, 1);
/* Write an extra two bytes for the FCS */ /* Write an extra two bytes for the FCS */
res = ctrl->write_func ? ctrl->write_func(ctrl, h, len + 2) : 0; res = ctrl->write_func ? ctrl->write_func(ctrl, h, len + 2) : 0;
if (res != (len + 2)) { if (res != (len + 2)) {
@ -1187,7 +1187,7 @@ static void q921_dump_iqueue_info(struct q921_link *link)
static void q921_dump_pri_by_h(struct pri *ctrl, char direction_tag, q921_h *h); static void q921_dump_pri_by_h(struct pri *ctrl, char direction_tag, q921_h *h);
void q921_dump(struct pri *ctrl, q921_h *h, int len, int showraw, int txrx) void q921_dump(struct pri *ctrl, q921_h *h, int len, int debugflags, int txrx)
{ {
int x; int x;
const char *type; const char *type;
@ -1196,9 +1196,11 @@ void q921_dump(struct pri *ctrl, q921_h *h, int len, int showraw, int txrx)
direction_tag = txrx ? '>' : '<'; direction_tag = txrx ? '>' : '<';
pri_message(ctrl, "\n"); pri_message(ctrl, "\n");
if (debugflags & PRI_DEBUG_Q921_DUMP) {
q921_dump_pri_by_h(ctrl, direction_tag, h); q921_dump_pri_by_h(ctrl, direction_tag, h);
}
if (showraw) { if (debugflags & PRI_DEBUG_Q921_RAW) {
char *buf = malloc(len * 3 + 1); char *buf = malloc(len * 3 + 1);
int buflen = 0; int buflen = 0;
if (buf) { if (buf) {
@ -1209,6 +1211,7 @@ void q921_dump(struct pri *ctrl, q921_h *h, int len, int showraw, int txrx)
} }
} }
if (debugflags & PRI_DEBUG_Q921_DUMP) {
switch (h->h.data[0] & Q921_FRAMETYPE_MASK) { switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
case 0: case 0:
case 2: case 2:
@ -1338,6 +1341,7 @@ void q921_dump(struct pri *ctrl, q921_h *h, int len, int showraw, int txrx)
} }
} }
} }
}
static void q921_dump_pri(struct q921_link *link, char direction_tag) static void q921_dump_pri(struct q921_link *link, char direction_tag)
{ {
@ -3006,7 +3010,7 @@ static pri_event *__q921_receive(struct pri *ctrl, q921_h *h, int len)
len -= 2; len -= 2;
if (ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW)) { if (ctrl->debug & (PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW)) {
q921_dump(ctrl, h, len, ctrl->debug & PRI_DEBUG_Q921_RAW, 0); q921_dump(ctrl, h, len, ctrl->debug, 0);
} }
/* Check some reject conditions -- Start by rejecting improper ea's */ /* Check some reject conditions -- Start by rejecting improper ea's */