Improve protocol robustness and invoke user callbacks.
[radsecproxy.git] / lib / debug.c
1 /* See the file COPYING for licensing information.  */
2
3 #if defined HAVE_CONFIG_H
4 #include <config.h>
5 #endif
6
7 #include <stdio.h>
8 #include <assert.h>
9 #include <freeradius/libradius.h>
10 #include <radsec/radsec.h>
11 #include <radsec/radsec-impl.h>
12 #include "debug.h"
13
14 void
15 rs_dump_packet (const struct rs_packet *pkt)
16 {
17   const RADIUS_PACKET *p = NULL;
18
19   if (!pkt || !pkt->rpkt)
20     return;
21   p = pkt->rpkt;
22
23   fprintf (stderr, "\tCode: %u, Identifier: %u, Lenght: %u\n",
24            p->code,
25            p->id,
26            p->data_len);
27   fflush (stderr);
28 }
29
30 void
31 rs_dump_attr (const struct rs_attr *attr)
32 {
33   vp_printlist (stderr, attr->vp);
34 }
35
36 #if defined DEBUG
37 int
38 _rs_debug (const char *fmt, ...)
39 {
40   int n;
41   va_list args;
42
43   va_start (args, fmt);
44   n = vfprintf (stderr, fmt, args);
45   va_end (args);
46   fflush (stderr);
47
48   return n;
49 }
50 #endif