Enable tls psk
[radsecproxy.git] / debug.c
diff --git a/debug.c b/debug.c
index 3959987..903c793 100644 (file)
--- a/debug.c
+++ b/debug.c
@@ -1,31 +1,46 @@
-/*
- * Copyright (C) 2007 Stig Venaas <venaas@uninett.no>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
-
-#include <stdint.h>
+/* 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 <stdlib.h>
-#include <stdarg.h>
+#include <assert.h>
+#include <radius/client.h>
+#include <radsec/radsec.h>
+#include <radsec/radsec-impl.h>
 #include "debug.h"
 
-static uint8_t debug_level = DBG_WARN;
+void
+rs_dump_packet (const struct rs_packet *pkt)
+{
+  const RADIUS_PACKET *p = NULL;
+
+  if (!pkt || !pkt->rpkt)
+    return;
+  p = pkt->rpkt;
 
-void debug_set_level(uint8_t level) {
-    debug_level = level;
+  fprintf (stderr, "\tCode: %u, Identifier: %u, Lenght: %zu\n",
+          p->code,
+          p->id,
+          p->sizeof_data);
+  fflush (stderr);
 }
 
-void debug(uint8_t level, char *format, ...) {
-    if (level >= debug_level) {
-       va_list ap;
-       va_start(ap, format);
-       vfprintf(stderr, format, ap);
-       va_end(ap);
-       fprintf(stderr, "\n");
-    }
-    if (level >= DBG_ERR)
-       exit(1);
+#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