summaryrefslogtreecommitdiff
path: root/debug.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2014-02-05 11:10:02 +0100
committerLinus Nordberg <linus@nordberg.se>2014-02-05 11:10:02 +0100
commit3d954bfd2f658ac05a0f20a1241738ed3e3fdd28 (patch)
treed95b364fbab298c9b94c9c729afc98904c7c5bb0 /debug.c
parent67bdfa83f1879312fef0fbac769f6fb45df12d1a (diff)
Move lib to the root.
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/debug.c b/debug.c
new file mode 100644
index 0000000..903c793
--- /dev/null
+++ b/debug.c
@@ -0,0 +1,46 @@
+/* Copyright 2011 NORDUnet A/S. All rights reserved.
+ See LICENSE for licensing information. */
+
+#if defined HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <assert.h>
+#include <radius/client.h>
+#include <radsec/radsec.h>
+#include <radsec/radsec-impl.h>
+#include "debug.h"
+
+void
+rs_dump_packet (const struct rs_packet *pkt)
+{
+ const RADIUS_PACKET *p = NULL;
+
+ if (!pkt || !pkt->rpkt)
+ return;
+ p = pkt->rpkt;
+
+ fprintf (stderr, "\tCode: %u, Identifier: %u, Lenght: %zu\n",
+ p->code,
+ p->id,
+ p->sizeof_data);
+ fflush (stderr);
+}
+
+#if defined DEBUG
+int
+_rs_debug (const char *fmt, ...)
+{
+ int n;
+ va_list args;
+
+ va_start (args, fmt);
+ n = vfprintf (stderr, fmt, args);
+ va_end (args);
+ fflush (stderr);
+
+ return n;
+}
+#endif