2015-04-12 23:28:55 +02:00
|
|
|
/*
|
|
|
|
This file is part of libcapwap.
|
|
|
|
|
|
|
|
libcapwap 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
libcapwap 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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2015-04-05 02:10:37 +02:00
|
|
|
#ifndef __DBG_H
|
|
|
|
#define __DBG_H
|
|
|
|
|
2015-04-05 20:27:17 +02:00
|
|
|
#include "conn.h"
|
2018-03-09 07:44:17 +01:00
|
|
|
#include "cw.h"
|
2015-04-05 02:10:37 +02:00
|
|
|
|
2018-03-05 12:23:16 +01:00
|
|
|
|
2015-04-10 19:51:56 +02:00
|
|
|
#ifndef CW_LOG_DUMP_ROW_LEN
|
|
|
|
#define CW_LOG_DUMP_ROW_LEN 32
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CW_LOG_DUMP_ROW_TAB_LEN
|
|
|
|
#define CW_LOG_DUMP_ROW_TAB_LEN 8
|
|
|
|
#endif
|
|
|
|
|
2018-03-05 12:23:16 +01:00
|
|
|
|
2015-10-18 09:06:36 +02:00
|
|
|
/**
|
2018-03-25 11:14:37 +02:00
|
|
|
*@addtogroup LOGDBG
|
2015-10-18 09:06:36 +02:00
|
|
|
*@{
|
|
|
|
*/
|
|
|
|
|
2018-03-17 19:32:44 +01:00
|
|
|
/**
|
|
|
|
* Debug levels
|
|
|
|
*/
|
|
|
|
enum cw_dbg_levels{
|
|
|
|
/** Show headers of incomming CAPWAP packets */
|
|
|
|
DBG_PKT_IN=0,
|
|
|
|
|
|
|
|
/** Show headers of outgoing CAPWAP packets */
|
|
|
|
DBG_PKT_OUT,
|
|
|
|
|
|
|
|
/** Incomming CAPWAP packets with errors, wich would
|
|
|
|
usually silently discarded */
|
|
|
|
DBG_PKT_ERR,
|
|
|
|
|
|
|
|
/** Dump content of incomming packets */
|
|
|
|
DBG_PKT_DMP,
|
|
|
|
|
|
|
|
/** Display incomming CAPWAP/LWAPP messages */
|
|
|
|
DBG_MSG_IN,
|
|
|
|
|
|
|
|
/** Display outgoing CAPWAP/LWAPP messages */
|
|
|
|
DBG_MSG_OUT,
|
|
|
|
|
2018-03-18 23:51:59 +01:00
|
|
|
DBG_MSG_DMP,
|
|
|
|
|
2018-03-17 19:32:44 +01:00
|
|
|
/** Message errors */
|
|
|
|
DBG_MSG_ERR,
|
|
|
|
|
2018-03-18 21:48:34 +01:00
|
|
|
/** Show message elements in incomming messages */
|
|
|
|
DBG_ELEM_IN,
|
|
|
|
|
|
|
|
/** Show message elements assembled for outgoing messages */
|
|
|
|
DBG_ELEM_OUT,
|
2018-03-17 19:32:44 +01:00
|
|
|
|
|
|
|
/** Show message element details */
|
|
|
|
DBG_ELEM_DETAIL,
|
|
|
|
|
|
|
|
/** Error in msg elements */
|
|
|
|
DBG_ELEM_ERR,
|
|
|
|
|
|
|
|
/** Show subelements */
|
|
|
|
DBG_SUBELEM,
|
|
|
|
|
|
|
|
/** Show dump of subelements */
|
|
|
|
DBG_SUBELEM_DMP,
|
|
|
|
|
|
|
|
/** hex dump elements */
|
|
|
|
DBG_ELEM_DMP,
|
|
|
|
|
|
|
|
/** General infos, like CAPWAP state */
|
|
|
|
DBG_INFO,
|
|
|
|
|
|
|
|
/** Misc. warnings */
|
|
|
|
DBG_WARN,
|
|
|
|
|
|
|
|
/** RFC related */
|
|
|
|
DBG_RFC,
|
|
|
|
|
|
|
|
/** DTLS related messages */
|
|
|
|
DBG_DTLS,
|
|
|
|
|
|
|
|
/** DTLS BIOs in/out */
|
|
|
|
DBG_DTLS_BIO,
|
|
|
|
|
|
|
|
/** Dump DTLS BIO i/o */
|
|
|
|
DBG_DTLS_BIO_DMP,
|
|
|
|
|
|
|
|
/** Show DTLS Details */
|
|
|
|
DBG_DTLS_DETAIL,
|
2018-03-19 17:26:01 +01:00
|
|
|
|
|
|
|
DBG_CFG_DMP,
|
2018-03-17 19:32:44 +01:00
|
|
|
|
|
|
|
/** Debug Mods */
|
|
|
|
DBG_MOD,
|
|
|
|
|
|
|
|
DBG_ALL,
|
|
|
|
|
2018-03-18 23:51:59 +01:00
|
|
|
DBG_PKT_DMP_OUT,
|
|
|
|
DBG_PKT_DMP_IN,
|
|
|
|
|
|
|
|
DBG_MSG_IN_DMP,
|
|
|
|
DBG_MSG_OUT_DMP,
|
|
|
|
|
|
|
|
DBG_MSG_ASSEMBLY,
|
|
|
|
DBG_MSG_PARSING,
|
|
|
|
|
2018-03-17 19:32:44 +01:00
|
|
|
DBG_X
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define DBG_LN __FILE__,__LINE__
|
|
|
|
|
2018-03-19 17:26:01 +01:00
|
|
|
/*
|
2018-03-17 19:32:44 +01:00
|
|
|
struct dbg_Context{
|
|
|
|
int level;
|
|
|
|
};
|
2018-03-19 17:26:01 +01:00
|
|
|
*/
|
2018-03-17 19:32:44 +01:00
|
|
|
|
|
|
|
void cw_dbg_set_level (int level, int on);
|
|
|
|
int cw_dbg_set_level_from_str(const char *level);
|
|
|
|
|
2018-03-19 17:26:01 +01:00
|
|
|
/*
|
2015-04-05 20:27:17 +02:00
|
|
|
void cw_dbg_elem_(struct conn * conn, int msg, int msgelem, const uint8_t * msgbuf, int len);
|
2018-03-19 17:26:01 +01:00
|
|
|
*/
|
2018-03-17 17:29:09 +01:00
|
|
|
/*
|
2015-04-07 07:42:36 +02:00
|
|
|
void cw_dbg_missing_mand(int level,struct conn *conn,cw_action_in_t ** ml,int n,cw_action_in_t *a);
|
2018-03-17 17:29:09 +01:00
|
|
|
*/
|
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len);
|
2018-03-05 20:39:15 +01:00
|
|
|
void cw_dbg_pkt(int level,struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
|
|
|
void cw_dbg(int level, const char *format, ...);
|
|
|
|
void cw_dbg_dmp(int level, const uint8_t * data, int len, const char *format, ...);
|
2015-04-05 02:10:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|
2015-04-10 17:14:55 +02:00
|
|
|
|
|
|
|
/**
|
2015-10-18 09:49:14 +02:00
|
|
|
* @defgroup DbgOptions Debug Options
|
2015-04-10 17:14:55 +02:00
|
|
|
* @{
|
|
|
|
*/
|
2015-04-11 19:00:51 +02:00
|
|
|
|
|
|
|
|
2015-04-12 10:19:02 +02:00
|
|
|
#define DBG_DISP_LINE_NUMBERS (1<<0)
|
|
|
|
#define DBG_DISP_ASC_DMP (1<<1)
|
|
|
|
#define DBG_DISP_COLORS (1<<2)
|
2015-04-11 19:00:51 +02:00
|
|
|
|
|
|
|
#define DBG_DETAIL_ALL 0xffffffff
|
2015-04-12 10:19:02 +02:00
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
|
|
|
|
/**@}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
extern uint32_t cw_dbg_opt_display;
|
|
|
|
extern uint32_t cw_dbg_opt_level;
|
2018-03-17 19:32:44 +01:00
|
|
|
extern struct cw_StrListElem cw_dbg_strings[];
|
2015-04-11 19:00:51 +02:00
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
/*
|
2018-03-05 09:56:39 +01:00
|
|
|
#define cw_dbg cw_dbg_colored
|
2018-03-05 20:39:15 +01:00
|
|
|
*/
|
2015-04-11 19:00:51 +02:00
|
|
|
|
2018-03-05 09:56:39 +01:00
|
|
|
/*
|
2015-04-11 19:00:51 +02:00
|
|
|
#define cw_dbg_dmp(type,...) cw_dbg_dmp_(type,__FILE__,__LINE__,__VA_ARGS__)
|
2018-03-05 09:56:39 +01:00
|
|
|
*/
|
2018-03-05 20:39:15 +01:00
|
|
|
/*
|
2018-03-05 09:56:39 +01:00
|
|
|
#define cw_dbg_dmp cw_dbg_dmp_
|
2018-03-05 20:39:15 +01:00
|
|
|
*/
|
2015-04-11 19:00:51 +02:00
|
|
|
|
2018-03-05 09:56:39 +01:00
|
|
|
void cw_dbg_dmp_(int level, const uint8_t * data, int len, const char *format, ...);
|
2015-04-11 19:00:51 +02:00
|
|
|
|
|
|
|
|
2018-03-09 07:44:17 +01:00
|
|
|
|
2018-03-19 08:31:50 +01:00
|
|
|
void cw_dbg_elem(int level, struct conn *conn, int msg,
|
2018-03-19 17:26:01 +01:00
|
|
|
struct cw_ElemHandler * handler, const uint8_t * msgbuf, int len);
|
2015-04-11 19:00:51 +02:00
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
|
2016-04-10 15:58:10 +02:00
|
|
|
void cw_dbg_pkt_nc(int level,struct netconn *nc, uint8_t * packet, int len,struct sockaddr *from);
|
|
|
|
|
2015-04-12 23:28:55 +02:00
|
|
|
void cw_dbg_msg(int level,struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
|
|
|
char * cw_dbg_mkdmp(const uint8_t * data, int len);
|
2018-03-07 08:57:04 +01:00
|
|
|
void cw_dbg_version_subelem(int level, const char *context, int subtype,
|
|
|
|
uint32_t vendor_id, const uint8_t * vstr, int len);
|
2018-03-19 17:26:01 +01:00
|
|
|
void cw_dbg_ktv_dump(mavl_t ktv, uint32_t dbglevel,
|
|
|
|
const char *header, const char *prefix, const char *footer );
|
2015-04-11 19:00:51 +02:00
|
|
|
|
2015-10-18 09:06:36 +02:00
|
|
|
/**
|
|
|
|
* Set debug level
|
|
|
|
* @param level debug level to set, allowed values are enumberated in #cw_dbg_levels structure.
|
|
|
|
* @param on 1: turns the specified debug level on, 0: turns the specified debug level off.
|
|
|
|
*/
|
2018-03-17 19:32:44 +01:00
|
|
|
/*#define cw_dbg_set_level(level,on)\
|
2015-04-12 10:19:02 +02:00
|
|
|
(on ? cw_dbg_opt_level |= (1<<(level)) : (cw_dbg_opt_level &= (-1)^(1<<(level))))
|
2018-03-17 19:32:44 +01:00
|
|
|
*/
|
2015-04-12 10:19:02 +02:00
|
|
|
|
2016-03-12 09:28:35 +01:00
|
|
|
/**
|
|
|
|
* Check if a specific debug level is set.
|
|
|
|
* @param level Level to check
|
|
|
|
* @return 0 if leveln is not set, otherwise level is set
|
|
|
|
*/
|
2018-03-18 23:51:59 +01:00
|
|
|
/*
|
2015-04-12 10:19:02 +02:00
|
|
|
#define cw_dbg_is_level(level)\
|
|
|
|
(cw_dbg_opt_level & (1<<level))
|
2018-03-18 23:51:59 +01:00
|
|
|
*/
|
2018-03-25 10:07:39 +02:00
|
|
|
int cw_dbg_is_level(int level);
|
2015-04-11 19:00:51 +02:00
|
|
|
|
2015-10-18 09:06:36 +02:00
|
|
|
/**
|
2018-03-25 11:14:37 +02:00
|
|
|
*@} LOGDBG
|
2015-10-18 09:06:36 +02:00
|
|
|
*/
|