Some improvements with dbg levels
FossilOrigin-Name: 4f1f8f238cb3fd097504bfba3b51805d359135256160fe8fdba34908495ec50b
This commit is contained in:
parent
93914678e0
commit
d4fa4269e7
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="actube" Database="">
|
||||
<Project Name="ac" Path="ac.project" Active="Yes"/>
|
||||
<Project Name="ac" Path="ac.project" Active="No"/>
|
||||
<Project Name="wtp" Path="wtp.project" Active="No"/>
|
||||
<Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
|
||||
<Project Name="mod_capwap" Path="mod_capwap.project" Active="No"/>
|
||||
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
||||
<Project Name="libcw" Path="libcw.project" Active="No"/>
|
||||
<Project Name="libcw" Path="libcw.project" Active="Yes"/>
|
||||
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
||||
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
||||
<BuildMatrix>
|
||||
|
@ -252,8 +252,6 @@
|
||||
<File Name="src/cw/cw_type_byte.c"/>
|
||||
<File Name="src/cw/cw_type_word.c"/>
|
||||
<File Name="src/cw/cw_type_dword.c"/>
|
||||
<File Name="src/cw/debug.h"/>
|
||||
<File Name="src/cw/debug.c"/>
|
||||
<File Name="src/cw/mavl_get_ptr.c"/>
|
||||
<File Name="src/cw/mavliter_init.c"/>
|
||||
<File Name="src/cw/mavl_add_ptr.c"/>
|
||||
@ -297,6 +295,9 @@
|
||||
<File Name="src/cw/cw_ktv_get_word.c"/>
|
||||
<File Name="src/cw/cw_ktv_get_byte.c"/>
|
||||
<File Name="src/cw/cw_ktv_std_types.c"/>
|
||||
<File Name="src/cw/dbg_help_strings.c"/>
|
||||
<File Name="src/cw/cw_dbg_set_level.c"/>
|
||||
<File Name="src/cw/cw_dbg_set_level_from_str.c"/>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<Description/>
|
||||
|
@ -551,13 +551,13 @@ extern int cw_readmsg_configuration_update_request(uint8_t * elems, int elems_le
|
||||
/* Message to text stuff */
|
||||
|
||||
/* Constants to string conversion lists */
|
||||
extern struct cw_strlist_elem capwap_strings_msg[];
|
||||
extern struct cw_strlist_elem capwap_strings_state[];
|
||||
extern struct cw_strlist_elem capwap_strings_vendor[];
|
||||
extern struct cw_strlist_elem capwap_strings_elem[];
|
||||
extern struct cw_strlist_elem capwap_strings_result[];
|
||||
extern struct cw_strlist_elem capwap_strings_board[];
|
||||
extern struct cw_strlist_elem mbag_item_strings[];
|
||||
extern struct cw_StrListElem capwap_strings_msg[];
|
||||
extern struct cw_StrListElem capwap_strings_state[];
|
||||
extern struct cw_StrListElem capwap_strings_vendor[];
|
||||
extern struct cw_StrListElem capwap_strings_elem[];
|
||||
extern struct cw_StrListElem capwap_strings_result[];
|
||||
extern struct cw_StrListElem capwap_strings_board[];
|
||||
extern struct cw_StrListElem mbag_item_strings[];
|
||||
|
||||
|
||||
|
||||
|
@ -129,7 +129,7 @@ int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst
|
||||
/*
|
||||
//extern int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def);
|
||||
*/
|
||||
extern struct cw_strlist_elem capwap_strings_elem80211[];
|
||||
extern struct cw_StrListElem capwap_strings_elem80211[];
|
||||
/*
|
||||
//extern int cw_register_actions_capwap_80211_ac(struct cw_actiondef *def);
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include "capwap.h"
|
||||
|
||||
struct cw_strlist_elem capwap_strings_board[] = {
|
||||
struct cw_StrListElem capwap_strings_board[] = {
|
||||
{CW_BOARDDATA_MODELNO, "Model-No"},
|
||||
{CW_BOARDDATA_SERIALNO,"Serial-No"},
|
||||
{CW_BOARDDATA_BOARDID,"Board-ID"},
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include "capwap.h"
|
||||
|
||||
struct cw_strlist_elem capwap_strings_elem[] = {
|
||||
struct cw_StrListElem capwap_strings_elem[] = {
|
||||
|
||||
{CAPWAP_ELEM_AC_DESCRIPTOR, "AC Descriptor"},
|
||||
{CAPWAP_ELEM_AC_IPV4_LIST, "AC IPv4 List"},
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "capwap80211.h"
|
||||
#include "strlist.h"
|
||||
|
||||
struct cw_strlist_elem capwap_strings_elem80211[] = {
|
||||
struct cw_StrListElem capwap_strings_elem80211[] = {
|
||||
|
||||
{CW_ELEM80211_ADD_WLAN, "802.11 Add WLAN"},
|
||||
{CW_ELEM80211_ANTENNA, "802.11 Antenna"},
|
||||
|
@ -25,7 +25,7 @@
|
||||
/**
|
||||
* CAPWAP Message Strings
|
||||
*/
|
||||
struct cw_strlist_elem capwap_strings_msg[] = {
|
||||
struct cw_StrListElem capwap_strings_msg[] = {
|
||||
{ CAPWAP_MSG_DISCOVERY_REQUEST, "Discovery Request" },
|
||||
{ CAPWAP_MSG_DISCOVERY_RESPONSE,"Discovery Response" },
|
||||
{ CAPWAP_MSG_JOIN_REQUEST, "Join Request"},
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "capwap.h"
|
||||
|
||||
|
||||
struct cw_strlist_elem capwap_strings_result[] = {
|
||||
struct cw_StrListElem capwap_strings_result[] = {
|
||||
|
||||
{CAPWAP_RESULT_SUCCESS,"Success"}, /* 0 */
|
||||
{CW_RESULT_MISSING_AC_LIST,"AC List Message Element MUST be Present"}, /* 1 */
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include "capwap.h"
|
||||
|
||||
struct cw_strlist_elem capwap_strings_state[] = {
|
||||
struct cw_StrListElem capwap_strings_state[] = {
|
||||
{ CAPWAP_STATE_DISCOVERY, "Discovery" },
|
||||
{ CAPWAP_STATE_JOIN,"Join" },
|
||||
{ CW_STATE_RUN,"Run" },
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "capwap.h"
|
||||
#include "vendors.h"
|
||||
|
||||
struct cw_strlist_elem capwap_strings_vendor[] = {
|
||||
struct cw_StrListElem capwap_strings_vendor[] = {
|
||||
{ CW_VENDOR_ID_CISCO, "Cisco" },
|
||||
{ CW_VENDOR_ID_ZYXEL, "Zyxel" },
|
||||
{ CW_VENDOR_ID_FSF, "FSF"},
|
||||
|
26
src/cw/cw_dbg_set_level.c
Normal file
26
src/cw/cw_dbg_set_level.c
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
#include "dbg.h"
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
void cw_dbg_set_level (int level, int on)
|
||||
{
|
||||
switch (level) {
|
||||
case DBG_ALL:
|
||||
if (on)
|
||||
cw_dbg_opt_level = 0xffffffff;
|
||||
else
|
||||
cw_dbg_opt_level = 0;
|
||||
break;
|
||||
default:
|
||||
if (on)
|
||||
cw_dbg_opt_level |= (1 << (level));
|
||||
else
|
||||
cw_dbg_opt_level &= (0xffffffff) ^ (1 << (level));
|
||||
}
|
||||
}
|
||||
|
30
src/cw/cw_dbg_set_level_from_str.c
Normal file
30
src/cw/cw_dbg_set_level_from_str.c
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
#include "dbg.h"
|
||||
|
||||
int cw_dbg_set_level_from_str(const char *level)
|
||||
{
|
||||
int blevel,on;
|
||||
const char *slevel;
|
||||
|
||||
switch(*level){
|
||||
case '-':
|
||||
case '!':
|
||||
on =0;
|
||||
slevel=level+1;
|
||||
break;
|
||||
case '+':
|
||||
slevel=level+1;
|
||||
on=1;
|
||||
break;
|
||||
default:
|
||||
slevel=level;
|
||||
on=1;
|
||||
}
|
||||
|
||||
blevel = cw_strlist_get_id(cw_dbg_strings, slevel);
|
||||
if (blevel==-1)
|
||||
return 0;
|
||||
|
||||
cw_dbg_set_level(blevel,on);
|
||||
return 1;
|
||||
}
|
@ -44,8 +44,6 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
struct mlistelem * elem;
|
||||
int len,l;
|
||||
|
||||
\
|
||||
|
||||
/* rawout is already initialized, so we can get
|
||||
* msg type from buffer */
|
||||
msgptr = rawout + cw_get_hdr_msg_offset(rawout);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "strlist.h"
|
||||
|
||||
int cw_strlist_get_id(struct cw_strlist_elem *s,const char *str)
|
||||
int cw_strlist_get_id(struct cw_StrListElem *s,const char *str)
|
||||
{
|
||||
while ( s->id!=CW_STR_STOP){
|
||||
if (strcmp(s->str,str)==0)
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include "strlist.h"
|
||||
|
||||
const char * cw_strlist_get_str(struct cw_strlist_elem *s,int id)
|
||||
const char * cw_strlist_get_str(struct cw_StrListElem *s,int id)
|
||||
{
|
||||
while ( s->id!=CW_STR_STOP){
|
||||
if (s->id==id)
|
||||
|
13
src/cw/dbg.c
13
src/cw/dbg.c
@ -57,7 +57,7 @@ void (*cw_dbg_vcb) (int level, const char *fromat, va_list args) = CW_LOG_DEFAUL
|
||||
*/
|
||||
|
||||
|
||||
uint32_t cw_dbg_opt_display = 0;
|
||||
uint32_t cw_dbg_opt_display = DBG_DISP_COLORS;
|
||||
|
||||
/**
|
||||
* Current debug level
|
||||
@ -86,7 +86,7 @@ uint32_t cw_dbg_opt_level = 0;
|
||||
#define DBG_CLR_RED_I "\x1b[3;31m"
|
||||
|
||||
|
||||
static struct cw_strlist_elem color_on[] = {
|
||||
static struct cw_StrListElem color_on[] = {
|
||||
{DBG_PKT_IN, DBG_CLR_YELLO},
|
||||
{DBG_PKT_OUT, DBG_CLR_YELLO_I},
|
||||
|
||||
@ -110,19 +110,19 @@ static struct cw_strlist_elem color_on[] = {
|
||||
{CW_STR_STOP, ""}
|
||||
};
|
||||
|
||||
static struct cw_strlist_elem color_ontext[] = {
|
||||
static struct cw_StrListElem color_ontext[] = {
|
||||
|
||||
{DBG_ELEM_DMP, "\x1b[30m"},
|
||||
{CW_STR_STOP, ""}
|
||||
};
|
||||
|
||||
|
||||
static struct cw_strlist_elem color_off[] = {
|
||||
static struct cw_StrListElem color_off[] = {
|
||||
|
||||
{CW_STR_STOP, "\x1b[22;39m\x1b[23m"}
|
||||
};
|
||||
|
||||
static struct cw_strlist_elem prefix[] = {
|
||||
static struct cw_StrListElem prefix[] = {
|
||||
{DBG_INFO, " Info -"},
|
||||
{DBG_PKT_IN, " Pkt IN -"},
|
||||
{DBG_PKT_OUT, " Pkt Out -"},
|
||||
@ -413,6 +413,9 @@ void cw_dbg(int level, const char *format, ...)
|
||||
|
||||
va_start(args, format);
|
||||
/* cw_log_vcb(level, fbuf, args);*/
|
||||
|
||||
|
||||
|
||||
cw_log_console_writer.write(LOG_DEBUG,fbuf,args,&cw_log_console_writer);
|
||||
va_end(args);
|
||||
|
||||
|
113
src/cw/dbg.h
113
src/cw/dbg.h
@ -43,6 +43,90 @@
|
||||
*@{
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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,
|
||||
|
||||
/** Message errors */
|
||||
DBG_MSG_ERR,
|
||||
|
||||
/** Show message elements */
|
||||
DBG_ELEM,
|
||||
|
||||
/** 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,
|
||||
|
||||
/** Debug Mods */
|
||||
DBG_MOD,
|
||||
|
||||
DBG_ALL,
|
||||
|
||||
DBG_X
|
||||
};
|
||||
|
||||
|
||||
#define DBG_LN __FILE__,__LINE__
|
||||
|
||||
|
||||
struct dbg_Context{
|
||||
int level;
|
||||
};
|
||||
|
||||
void cw_dbg_set_level (int level, int on);
|
||||
int cw_dbg_set_level_from_str(const char *level);
|
||||
|
||||
|
||||
void cw_dbg_elem_(struct conn * conn, int msg, int msgelem, const uint8_t * msgbuf, int len);
|
||||
|
||||
@ -55,18 +139,6 @@ void cw_dbg_pkt(int level,struct conn *conn, uint8_t * packet, int len,struct so
|
||||
void cw_dbg(int level, const char *format, ...);
|
||||
void cw_dbg_dmp(int level, const uint8_t * data, int len, const char *format, ...);
|
||||
|
||||
/*
|
||||
#define DBGX(f,...) cw_dbg(DBG_X,f,__VA_ARGS__) //cw_dbg(DBG_X, f ,__VA_ARGS__)
|
||||
//#define DBGX(f,...) cw_dbg(DBG_X, f)
|
||||
//#define DBGX(f,...) printf("hallo\n")
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
#define cw_dbg_elem(level,conn,msgtype,msgelemtype,msgbuf,msglen)\
|
||||
cw_dbg_elem_colored(level,conn,msgtype,msgelemtype,msgbuf,msglen)
|
||||
*/
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -74,18 +146,6 @@ void cw_dbg_dmp(int level, const uint8_t * data, int len, const char *format, ..
|
||||
* @defgroup DbgOptions Debug Options
|
||||
* @{
|
||||
*/
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
|
||||
/* driver specific debugs */
|
||||
|
||||
#define DBG_DRV 0x00010000
|
||||
#define DBG_DRV_ERR 0x00020000
|
||||
|
||||
/* DTLS debugs */
|
||||
|
||||
|
||||
|
||||
|
||||
#define DBG_DISP_LINE_NUMBERS (1<<0)
|
||||
@ -103,7 +163,7 @@ void cw_dbg_dmp(int level, const uint8_t * data, int len, const char *format, ..
|
||||
|
||||
extern uint32_t cw_dbg_opt_display;
|
||||
extern uint32_t cw_dbg_opt_level;
|
||||
extern struct cw_strlist_elem cw_dbg_strings[];
|
||||
extern struct cw_StrListElem cw_dbg_strings[];
|
||||
|
||||
/*
|
||||
#define cw_dbg cw_dbg_colored
|
||||
@ -137,8 +197,9 @@ void cw_dbg_version_subelem(int level, const char *context, int subtype,
|
||||
* @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.
|
||||
*/
|
||||
#define cw_dbg_set_level(level,on)\
|
||||
/*#define cw_dbg_set_level(level,on)\
|
||||
(on ? cw_dbg_opt_level |= (1<<(level)) : (cw_dbg_opt_level &= (-1)^(1<<(level))))
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check if a specific debug level is set.
|
||||
|
0
src/cw/dbg_help_strings.c
Normal file
0
src/cw/dbg_help_strings.c
Normal file
@ -34,30 +34,36 @@
|
||||
/**
|
||||
* Debug strings
|
||||
*/
|
||||
struct cw_strlist_elem cw_dbg_strings[] = {
|
||||
{ DBG_INFO, "info" },
|
||||
{ DBG_PKT_IN, "pkt_in" },
|
||||
{ DBG_PKT_OUT, "pkt_out" },
|
||||
{ DBG_PKT_ERR, "pkt_err" },
|
||||
{ DBG_PKT_DMP, "pkt_dmp" },
|
||||
{ DBG_RFC, "rfc" },
|
||||
{ DBG_SUBELEM, "subelem" },
|
||||
struct cw_StrListElem cw_dbg_strings[] = {
|
||||
{ DBG_INFO, "info" },
|
||||
{ DBG_PKT_IN, "pkt_in" , "Show headers of incomming CAPWAP packets"},
|
||||
{ DBG_PKT_OUT, "pkt_out", "Show headers of outgoing CAPWAP packets" },
|
||||
{ DBG_PKT_ERR, "pkt_err", "Incomming CAPWAP packets with errors, wich would"
|
||||
"usually silently discarded" },
|
||||
{ DBG_PKT_DMP, "pkt_dmp", "Dump content of incomming/outgoing packets."
|
||||
"Requires pkt_in/pkt_out"},
|
||||
{ DBG_RFC, "rfc", },
|
||||
{ DBG_SUBELEM, "subelem" },
|
||||
{ DBG_SUBELEM_DMP, "subelem_dmp" },
|
||||
{ DBG_MSG_IN, "msg_in" },
|
||||
{ DBG_MSG_OUT, "msg_out"},
|
||||
{ DBG_MSG_IN, "msg_in", "Display incomming CAPWAP/LWAPP messages." },
|
||||
{ DBG_MSG_OUT, "msg_out", "Display outgoing CAPWAP/LWAPP messages."},
|
||||
{ DBG_MSG_ERR, "msg_err" },
|
||||
|
||||
{ DBG_ELEM, "elem" },
|
||||
{ DBG_ELEM_DETAIL, "elem_detail"},
|
||||
{ DBG_ELEM_DMP, "elem_dmp" },
|
||||
{ DBG_ELEM_ERR, "elem_err" },
|
||||
|
||||
{ DBG_DTLS, "dtls" },
|
||||
{ DBG_DTLS_BIO, "dtls_bio" },
|
||||
{ DBG_DTLS_BIO_DMP, "dtls_bio_dmp"},
|
||||
{ DBG_DTLS_DETAIL, "dtls_detail"},
|
||||
|
||||
{ DBG_WARN, "warn" },
|
||||
|
||||
{ DBG_MOD,"mod"},
|
||||
|
||||
{ DBG_X,"x" },
|
||||
{ DBG_ALL, "all"},
|
||||
|
||||
{ CW_STR_STOP, NULL }
|
||||
};
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include "debug.h"
|
||||
|
||||
#include "dbg.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
void cw_debug(const char * file, int line, struct dbg_Context *ctx, int level,
|
||||
const char * format, ...){
|
||||
va_list args;
|
||||
if (!(cw_dbg_is_level(level)))
|
||||
return;
|
||||
|
||||
/* char fbuf[1024];
|
||||
|
||||
sprintf(fbuf, "DBG:%s%s %s%s%s",
|
||||
get_dbg_color_on(level),
|
||||
get_dbg_prefix(level),
|
||||
get_dbg_color_ontext(level), format, get_dbg_color_off(level)
|
||||
);
|
||||
|
||||
*/
|
||||
|
||||
va_start(args, format);
|
||||
cw_log_console_writer.write(LOG_DEBUG,format,args,&cw_log_console_writer);
|
||||
va_end(args);
|
||||
}
|
||||
|
@ -1,92 +0,0 @@
|
||||
#ifndef __DEBUG_H
|
||||
#define __DEBUG_H
|
||||
|
||||
/**
|
||||
* 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,
|
||||
|
||||
/** Message errors */
|
||||
DBG_MSG_ERR,
|
||||
|
||||
/** Show message elements */
|
||||
DBG_ELEM,
|
||||
|
||||
/** 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,
|
||||
|
||||
/** Debug Mods */
|
||||
DBG_MOD,
|
||||
|
||||
DBG_X
|
||||
};
|
||||
|
||||
|
||||
#define DBG_LN __FILE__,__LINE__
|
||||
|
||||
|
||||
struct dbg_Context{
|
||||
int level;
|
||||
};
|
||||
|
||||
|
||||
void cw_debug( const char * file, int line, struct dbg_Context *ctx, int level,
|
||||
const char * format, ...);
|
||||
|
||||
|
||||
#define DBG_START(ctx,level) cw_debug(__FILE__,__LINE__,ctx,level,
|
||||
#define DBG_END );
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -30,7 +30,7 @@ void (*cw_log_vcb)(int level,const char * fromat, va_list args) = CW_LOG_DEFAULT
|
||||
const char * cw_log_name = "actube";
|
||||
|
||||
|
||||
static struct cw_strlist_elem prefix[] = {
|
||||
static struct cw_StrListElem prefix[] = {
|
||||
{LOG_DEBUG, "DBG"},
|
||||
{LOG_INFO, "INF" },
|
||||
{LOG_NOTICE, "NOTICE"},
|
||||
@ -39,7 +39,7 @@ static struct cw_strlist_elem prefix[] = {
|
||||
{CW_STR_STOP, NULL}
|
||||
};
|
||||
|
||||
static struct cw_strlist_elem prefix_color[] = {
|
||||
static struct cw_StrListElem prefix_color[] = {
|
||||
{LOG_DEBUG, ""},
|
||||
{LOG_INFO, "" },
|
||||
{LOG_NOTICE, ""},
|
||||
@ -48,7 +48,7 @@ static struct cw_strlist_elem prefix_color[] = {
|
||||
{CW_STR_STOP, NULL}
|
||||
};
|
||||
|
||||
static struct cw_strlist_elem text_color[] = {
|
||||
static struct cw_StrListElem text_color[] = {
|
||||
{LOG_DEBUG, ""},
|
||||
{LOG_INFO, "" },
|
||||
{LOG_NOTICE, ""},
|
||||
@ -57,7 +57,7 @@ static struct cw_strlist_elem text_color[] = {
|
||||
{CW_STR_STOP, NULL}
|
||||
};
|
||||
|
||||
static struct cw_strlist_elem end_color[] = {
|
||||
static struct cw_StrListElem end_color[] = {
|
||||
{LOG_DEBUG, ""},
|
||||
{LOG_INFO, "" },
|
||||
{LOG_NOTICE, ""},
|
||||
|
@ -222,7 +222,7 @@ void *mavl_add ( struct mavl *t, const void *data, int *exists )
|
||||
else
|
||||
*exists=0;
|
||||
}
|
||||
return d;
|
||||
return (void*)d;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -230,4 +230,4 @@ void *mavl_add ( struct mavl *t, const void *data)
|
||||
{
|
||||
return mavl_add_exists(t,data,NULL);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "mavl.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "dbg.h"
|
||||
#include "log.h"
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
static int cmp(const void *v1,const void*v2)
|
||||
{
|
||||
return ((struct cw_strlist_elem *)v1)->id - ((struct cw_strlist_elem *)v2)->id;
|
||||
return ((struct cw_StrListElem *)v1)->id - ((struct cw_StrListElem *)v2)->id;
|
||||
}
|
||||
|
||||
static void del(void* d)
|
||||
@ -17,13 +17,13 @@ cw_strheap_t cw_strheap_create()
|
||||
return mavl_create(cmp,del,1312);
|
||||
}
|
||||
|
||||
const char * cw_strheap_add(cw_strheap_t t, struct cw_strlist_elem *s)
|
||||
const char * cw_strheap_add(cw_strheap_t t, struct cw_StrListElem *s)
|
||||
{
|
||||
mavl_del(t,s);
|
||||
return mavl_add(t,s,NULL);
|
||||
}
|
||||
|
||||
int cw_strheap_register_strings(cw_strheap_t h, struct cw_strlist_elem *s)
|
||||
int cw_strheap_register_strings(cw_strheap_t h, struct cw_StrListElem *s)
|
||||
{
|
||||
int n=0;
|
||||
while ( s->id!=CW_STR_STOP){
|
||||
@ -37,9 +37,9 @@ int cw_strheap_register_strings(cw_strheap_t h, struct cw_strlist_elem *s)
|
||||
|
||||
|
||||
const char * cw_strheap_get(cw_strheap_t h, int id) {
|
||||
struct cw_strlist_elem s;
|
||||
struct cw_StrListElem s;
|
||||
s.id=id;
|
||||
struct cw_strlist_elem *r = mavl_get(h,&s);
|
||||
struct cw_StrListElem *r = mavl_get(h,&s);
|
||||
if (r)
|
||||
return r->str;
|
||||
return NULL;
|
||||
|
@ -11,7 +11,7 @@ typedef struct mavl * cw_strheap_t;
|
||||
|
||||
|
||||
extern cw_strheap_t cw_strheap_create();
|
||||
extern int cw_strheap_register_strings(cw_strheap_t h, struct cw_strlist_elem *s);
|
||||
extern int cw_strheap_register_strings(cw_strheap_t h, struct cw_StrListElem *s);
|
||||
|
||||
const char * cw_strheap_get(cw_strheap_t h, int id);
|
||||
|
||||
|
@ -8,25 +8,25 @@
|
||||
|
||||
|
||||
/**
|
||||
*Key/String pair, used for string tables,
|
||||
*to display message element names and so on...
|
||||
* Key/String pair, used for string tables,
|
||||
* to display message element names, help texts
|
||||
* and so on...
|
||||
*/
|
||||
struct cw_strlist_elem {
|
||||
/** ID, an integer value */
|
||||
int id;
|
||||
/** a pointer to the string */
|
||||
const char *str;
|
||||
struct cw_StrListElem {
|
||||
int id; /**< ID, an integer value */
|
||||
const char *str; /**< a pointer to the string */
|
||||
const char *descr; /**< Description */
|
||||
};
|
||||
|
||||
typedef struct cw_strlist_elem* cw_strlist_t;
|
||||
typedef struct cw_StrListElem* cw_StrList_t;
|
||||
|
||||
|
||||
/** Stopper, indicates the last element in a strlist */
|
||||
#define CW_STR_STOP 0xffffffff
|
||||
|
||||
|
||||
extern const char *cw_strlist_get_str(struct cw_strlist_elem *s, int id);
|
||||
extern int cw_strlist_get_id(struct cw_strlist_elem *s, const char *str);
|
||||
extern const char *cw_strlist_get_str(struct cw_StrListElem *s, int id);
|
||||
extern int cw_strlist_get_id(struct cw_StrListElem *s, const char *str);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -36,12 +36,10 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'd':{
|
||||
int b = cw_strlist_get_id(cw_dbg_strings, optarg);
|
||||
if (b==-1){
|
||||
if (!cw_dbg_set_level_from_str(optarg)){
|
||||
fprintf(stderr,"Invalid debug option: %s\n",optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
cw_dbg_set_level(b, 1);
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
|
Loading…
Reference in New Issue
Block a user