2006-10-31 12:27:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Martin Willi
|
2018-05-23 14:04:50 +00:00
|
|
|
* HSR Hochschule fuer Technik Rapperswil
|
2006-10-31 12:27:59 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
2008-03-13 14:14:44 +00:00
|
|
|
*/
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-03-13 14:14:44 +00:00
|
|
|
/**
|
|
|
|
* @defgroup debug debug
|
2012-10-16 14:03:21 +00:00
|
|
|
* @{ @ingroup utils
|
2006-10-31 12:27:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DEBUG_H_
|
|
|
|
#define DEBUG_H_
|
|
|
|
|
2010-03-31 15:17:02 +00:00
|
|
|
typedef enum debug_t debug_t;
|
|
|
|
typedef enum level_t level_t;
|
|
|
|
|
2017-10-13 12:33:43 +00:00
|
|
|
#include <utils/printf_hook/printf_hook.h>
|
2014-05-16 09:55:53 +00:00
|
|
|
#include <utils/utils.h>
|
2017-10-13 12:33:43 +00:00
|
|
|
#include <stdio.h>
|
2010-03-31 15:17:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Debug message group.
|
|
|
|
*/
|
|
|
|
enum debug_t {
|
|
|
|
/** daemon specific */
|
|
|
|
DBG_DMN,
|
|
|
|
/** IKE_SA_MANAGER */
|
|
|
|
DBG_MGR,
|
|
|
|
/** IKE_SA */
|
|
|
|
DBG_IKE,
|
|
|
|
/** CHILD_SA */
|
|
|
|
DBG_CHD,
|
|
|
|
/** job processing */
|
|
|
|
DBG_JOB,
|
|
|
|
/** configuration backends */
|
|
|
|
DBG_CFG,
|
|
|
|
/** kernel interface */
|
|
|
|
DBG_KNL,
|
|
|
|
/** networking/sockets */
|
|
|
|
DBG_NET,
|
2011-12-16 15:27:28 +00:00
|
|
|
/** low-level encoding/decoding (ASN.1, X.509 etc.) */
|
|
|
|
DBG_ASN,
|
2010-03-31 15:17:02 +00:00
|
|
|
/** message encoding/decoding */
|
|
|
|
DBG_ENC,
|
2010-10-09 14:01:19 +00:00
|
|
|
/** trusted network connect */
|
|
|
|
DBG_TNC,
|
2011-05-29 08:25:13 +00:00
|
|
|
/** integrity measurement client */
|
|
|
|
DBG_IMC,
|
|
|
|
/** integrity measurement verifier */
|
|
|
|
DBG_IMV,
|
2011-09-10 22:11:04 +00:00
|
|
|
/** platform trust service */
|
|
|
|
DBG_PTS,
|
2010-08-20 13:57:47 +00:00
|
|
|
/** libtls */
|
|
|
|
DBG_TLS,
|
2012-05-04 13:22:43 +00:00
|
|
|
/** applications other than daemons */
|
|
|
|
DBG_APP,
|
2012-03-28 13:41:31 +00:00
|
|
|
/** libipsec */
|
|
|
|
DBG_ESP,
|
2010-03-31 15:17:02 +00:00
|
|
|
/** libstrongswan */
|
|
|
|
DBG_LIB,
|
|
|
|
/** number of groups */
|
|
|
|
DBG_MAX,
|
|
|
|
/** pseudo group with all groups */
|
|
|
|
DBG_ANY = DBG_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* short names of debug message group.
|
|
|
|
*/
|
|
|
|
extern enum_name_t *debug_names;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* short names of debug message group, lower case.
|
|
|
|
*/
|
|
|
|
extern enum_name_t *debug_lower_names;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Debug levels used to control output verbosity.
|
|
|
|
*/
|
|
|
|
enum level_t {
|
|
|
|
/** absolutely silent */
|
2010-04-12 09:25:46 +00:00
|
|
|
LEVEL_SILENT = -1,
|
2010-03-31 15:17:02 +00:00
|
|
|
/** most important auditing logs */
|
|
|
|
LEVEL_AUDIT = 0,
|
|
|
|
/** control flow */
|
|
|
|
LEVEL_CTRL = 1,
|
|
|
|
/** diagnose problems */
|
|
|
|
LEVEL_DIAG = 2,
|
|
|
|
/** raw binary blobs */
|
|
|
|
LEVEL_RAW = 3,
|
|
|
|
/** including sensitive data (private keys) */
|
|
|
|
LEVEL_PRIVATE = 4,
|
|
|
|
};
|
|
|
|
|
2006-10-31 12:27:59 +00:00
|
|
|
#ifndef DEBUG_LEVEL
|
|
|
|
# define DEBUG_LEVEL 4
|
|
|
|
#endif /* DEBUG_LEVEL */
|
|
|
|
|
|
|
|
/** debug macros, they call the dbg function hook */
|
2010-03-31 15:26:39 +00:00
|
|
|
#if DEBUG_LEVEL >= 0
|
|
|
|
# define DBG0(group, fmt, ...) dbg(group, 0, fmt, ##__VA_ARGS__)
|
|
|
|
#endif /* DEBUG_LEVEL */
|
2006-10-31 12:27:59 +00:00
|
|
|
#if DEBUG_LEVEL >= 1
|
2010-03-31 15:26:39 +00:00
|
|
|
# define DBG1(group, fmt, ...) dbg(group, 1, fmt, ##__VA_ARGS__)
|
2006-10-31 12:27:59 +00:00
|
|
|
#endif /* DEBUG_LEVEL */
|
|
|
|
#if DEBUG_LEVEL >= 2
|
2010-03-31 15:26:39 +00:00
|
|
|
# define DBG2(group, fmt, ...) dbg(group, 2, fmt, ##__VA_ARGS__)
|
2006-10-31 12:27:59 +00:00
|
|
|
#endif /* DEBUG_LEVEL */
|
|
|
|
#if DEBUG_LEVEL >= 3
|
2010-03-31 15:26:39 +00:00
|
|
|
# define DBG3(group, fmt, ...) dbg(group, 3, fmt, ##__VA_ARGS__)
|
2006-10-31 12:27:59 +00:00
|
|
|
#endif /* DEBUG_LEVEL */
|
|
|
|
#if DEBUG_LEVEL >= 4
|
2010-03-31 15:26:39 +00:00
|
|
|
# define DBG4(group, fmt, ...) dbg(group, 4, fmt, ##__VA_ARGS__)
|
2006-10-31 12:27:59 +00:00
|
|
|
#endif /* DEBUG_LEVEL */
|
|
|
|
|
2010-03-31 15:17:02 +00:00
|
|
|
#ifndef DBG0
|
|
|
|
# define DBG0(...) {}
|
|
|
|
#endif
|
2006-10-31 12:27:59 +00:00
|
|
|
#ifndef DBG1
|
|
|
|
# define DBG1(...) {}
|
|
|
|
#endif
|
|
|
|
#ifndef DBG2
|
|
|
|
# define DBG2(...) {}
|
|
|
|
#endif
|
|
|
|
#ifndef DBG3
|
|
|
|
# define DBG3(...) {}
|
|
|
|
#endif
|
|
|
|
#ifndef DBG4
|
|
|
|
# define DBG4(...) {}
|
|
|
|
#endif
|
|
|
|
|
2009-09-16 11:06:16 +00:00
|
|
|
/** dbg function hook, uses dbg_default() by default */
|
2010-03-31 15:26:39 +00:00
|
|
|
extern void (*dbg) (debug_t group, level_t level, char *fmt, ...);
|
2006-10-31 12:27:59 +00:00
|
|
|
|
2009-09-16 11:06:16 +00:00
|
|
|
/** default logging function */
|
2010-03-31 15:26:39 +00:00
|
|
|
void dbg_default(debug_t group, level_t level, char *fmt, ...);
|
2007-09-27 06:40:50 +00:00
|
|
|
|
2009-09-16 11:06:16 +00:00
|
|
|
/** set the level logged by dbg_default() */
|
2010-03-31 15:26:39 +00:00
|
|
|
void dbg_default_set_level(level_t level);
|
2009-09-16 11:06:16 +00:00
|
|
|
|
|
|
|
/** set the stream logged by dbg_default() to */
|
|
|
|
void dbg_default_set_stream(FILE *stream);
|
|
|
|
|
2009-03-24 17:43:01 +00:00
|
|
|
#endif /** DEBUG_H_ @}*/
|