Debug improvements (bug #1329)

git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@86 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
Mark Spencer 2004-04-11 01:27:11 +00:00
parent 4743ebd26f
commit 8da0a1e5a7
3 changed files with 23 additions and 7 deletions

View File

@ -148,7 +148,7 @@ typedef enum q921_state {
} q921_state;
/* Dumps a *known good* Q.921 packet */
extern void q921_dump(q921_h *h, int len, int showraw, int txrx);
extern void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx);
/* Bring up the D-channel */
extern void q921_start(struct pri *pri, int now);

23
q921.c
View File

@ -78,7 +78,7 @@ static int q921_transmit(struct pri *pri, q921_h *h, int len)
#endif
/* Just send it raw */
if (pri->debug & PRI_DEBUG_Q921_DUMP)
q921_dump(h, len, pri->debug & PRI_DEBUG_Q921_RAW, 1);
q921_dump(pri, h, len, pri->debug & PRI_DEBUG_Q921_RAW, 1);
/* Write an extra two bytes for the FCS */
res = write(pri->fd, h, len + 2);
if (res != (len + 2)) {
@ -486,13 +486,27 @@ static pri_event *q921_handle_iframe(struct pri *pri, q921_i *i, int len)
return NULL;
}
void q921_dump(q921_h *h, int len, int showraw, int txrx)
void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx)
{
int x;
char *type;
char direction_tag;
char *cmd_rsp;
direction_tag = txrx ? '>' : '<';
/* If we are PRI_CPE: Use "Command" if we are transmitting and C/R bit is 0.
* Use "Response" if we are transmitting and C/R bit is 1.
* Use "Command" if we are receiving and C/R bit is 1.
* Use "Response" if we are receiving and C/R bit is 0.
*
* If we are PRI_NETWORK: Use "Command" if we are transmitting and C/R bit is 1.
* Use "Response" if we are transmitting and C/R bit is 0.
* Use "Command" if we are receiving and C/R bit is 0.
* Use "Response" if we are receiving and C/R bit is 1.
*/
cmd_rsp = (((pri->localtype == PRI_CPE)?0:1) ^ txrx ^ h->h.c_r) ? "Command" : "Response";
if (showraw) {
char *buf = malloc(len * 3 + 1);
int buflen = 0;
@ -518,12 +532,13 @@ void q921_dump(q921_h *h, int len, int showraw, int txrx)
}
pri_message(
"%c SAPI: %02d C/R: %d EA: %d\n"
"%c SAPI: %02d C/R: %d EA: %d [%s]\n"
"%c TEI: %03d EA: %d\n",
direction_tag,
h->h.sapi,
h->h.c_r,
h->h.ea1,
cmd_rsp,
direction_tag,
h->h.tei,
h->h.ea2);
@ -686,7 +701,7 @@ static pri_event *__q921_receive(struct pri *pri, q921_h *h, int len)
len -= 2;
if (pri->debug & PRI_DEBUG_Q921_DUMP)
q921_dump(h, len, pri->debug & PRI_DEBUG_Q921_RAW, 0);
q921_dump(pri, h, len, pri->debug & PRI_DEBUG_Q921_RAW, 0);
/* Check some reject conditions -- Start by rejecting improper ea's */
if (h->h.ea1 || !(h->h.ea2))

5
q931.c
View File

@ -1149,7 +1149,7 @@ static int transmit_cause(struct pri *pri, q931_call *call, int msgtype, q931_ie
static void dump_sending_complete(q931_ie *ie, int len, char prefix)
{
pri_message("%c Sending Complete (len=%2d)\n", prefix, ie->len);
pri_message("%c Sending Complete.\n", prefix);
}
static int receive_sending_complete(struct pri *pri, q931_call *call, int msgtype, q931_ie *ie, int len)
@ -1410,7 +1410,8 @@ void q931_dump(q931_h *h, int len, int txrx)
int x=0, r;
c = txrx ? '>' : '<';
pri_message("%c Protocol Discriminator: %s (%d) len=%d\n", c, disc2str(h->pd), h->pd, len);
pri_message("%c Call Ref: len=%2d (reference %d/0x%X) (%s)\n", c, h->crlen, q931_cr(h), q931_cr(h), (h->crv[0] & 0x80) ? "Terminator" : "Originator");
pri_message("%c Call Ref: len=%2d (reference %d/0x%X) (%s)\n",
c, h->crlen, q931_cr(h) & 0x7fff, q931_cr(h) & 0x7fff, (q931_cr(h) & 0x8000) ? "Terminator" : "Originator");
/* Message header begins at the end of the call reference number */
mh = (q931_mh *)(h->contents + h->crlen);
pri_message("%c Message type: %s (%d)\n", c, msg2str(mh->msg), mh->msg);