X-Git-Url: http://www.project-moonshot.org/gitweb/?p=libradsec.git;a=blobdiff_plain;f=debug.c;h=903c7931c492578be00411d846571481ce5c57b3;hp=f507f50cd54c9fb6e75f71708b9f6fba8a164d89;hb=HEAD;hpb=ba96d1cc28b9f1a54720bc997b38a9fabf896cdd diff --git a/debug.c b/debug.c index f507f50..903c793 100644 --- a/debug.c +++ b/debug.c @@ -1,35 +1,46 @@ -/* - * Copyright (C) 2007 Stig Venaas - * - * 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 +/* Copyright 2011 NORDUnet A/S. All rights reserved. + See LICENSE for licensing information. */ + +#if defined HAVE_CONFIG_H +#include +#endif + +#include #include -#include -#include -#include +#include +#include +#include +#include #include "debug.h" -static uint8_t debug_level = 0; - -void debug(uint8_t level, char *format, ...) { - extern int errno; - - if (level >= debug_level) { - va_list ap; - va_start(ap, format); - vfprintf(stderr, format, ap); - va_end(ap); - if (errno) { - fprintf(stderr, ": "); - perror(NULL); - fprintf(stderr, "errno=%d\n", errno); - } else - fprintf(stderr, "\n"); - } - if (level >= DBG_ERR) - exit(1); +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