diff options
author | Linus Nordberg <linus@nordu.net> | 2011-02-02 10:54:11 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2011-02-02 10:54:11 +0100 |
commit | 81a1e7ed51a23f8e5d891684deb3b96b5419a63b (patch) | |
tree | c7f432b9439b2a4e85fe792b0190cbd6fc84178c /lib/debug.c | |
parent | 65723ca456c63cd972d2a86fa7cbbcc1a39a8ea6 (diff) |
Replace some code for debug printouts.
Diffstat (limited to 'lib/debug.c')
-rw-r--r-- | lib/debug.c | 71 |
1 files changed, 8 insertions, 63 deletions
diff --git a/lib/debug.c b/lib/debug.c index 604ab23..801f2fb 100644 --- a/lib/debug.c +++ b/lib/debug.c @@ -5,77 +5,22 @@ #endif #include <stdio.h> +#include <assert.h> #include <freeradius/libradius.h> #include <radsec/radsec.h> #include <radsec/radsec-impl.h> #include "debug.h" -/* From freeradius-server/src/lib/radius.c */ -static void print_hex(RADIUS_PACKET *packet) -{ - int i; - - if (!packet->data) return; - - printf(" Code:\t\t%u\n", packet->data[0]); - printf(" Id:\t\t%u\n", packet->data[1]); - printf(" Length:\t%u\n", ((packet->data[2] << 8) | - (packet->data[3]))); - printf(" Vector:\t"); - for (i = 4; i < 20; i++) { - printf("%02x", packet->data[i]); - } - printf("\n"); - - if (packet->data_len > 20) { - int total; - const uint8_t *ptr; - printf(" Data:"); - - total = packet->data_len - 20; - ptr = packet->data + 20; - - while (total > 0) { - int attrlen; - - printf("\t\t"); - if (total < 2) { /* too short */ - printf("%02x\n", *ptr); - break; - } - - if (ptr[1] > total) { /* too long */ - for (i = 0; i < total; i++) { - printf("%02x ", ptr[i]); - } - break; - } - - printf("%02x %02x ", ptr[0], ptr[1]); - attrlen = ptr[1] - 2; - ptr += 2; - total -= 2; - - for (i = 0; i < attrlen; i++) { - if ((i > 0) && ((i & 0x0f) == 0x00)) - printf("\t\t\t"); - printf("%02x ", ptr[i]); - if ((i & 0x0f) == 0x0f) printf("\n"); - } - - if ((attrlen & 0x0f) != 0x00) printf("\n"); - - ptr += attrlen; - total -= attrlen; - } - } - fflush(stdout); -} - void rs_dump_packet (const struct rs_packet *pkt) { - print_hex (pkt->rpkt); + const RADIUS_PACKET *p = pkt->rpkt; + assert(p); + + fprintf (stderr, "\tCode: %u, Identifier: %u, Lenght: %u\n", + p->code, + p->id, + p->data_len); } void |