Improved debugging and dumping
FossilOrigin-Name: 5950561809c897ec94899336053e683ae570c542b5343b41afb169e0e692f694
This commit is contained in:
parent
91d58b7e36
commit
8d3d8f35f1
@ -320,7 +320,7 @@
|
||||
</Compiler>
|
||||
<Linker Options="" Required="yes"/>
|
||||
<ResourceCompiler Options="" Required="no"/>
|
||||
<General OutputFile="" IntermediateDirectory="./Debug" Command="$(WorkspacePath)/src/wtp/wtp" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(WorkspacePath)/src/wtp/" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
||||
<General OutputFile="" IntermediateDirectory="./Debug" Command="$(WorkspacePath)/src/wtp/wtp" CommandArguments="-dall" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(WorkspacePath)/src/wtp/" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
||||
<Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
|
||||
<![CDATA[LD_LIBRARY_PATH=../../lib]]>
|
||||
</Environment>
|
||||
|
@ -34,5 +34,5 @@ WITH_OPENSSL=1
|
||||
#
|
||||
LIBDIR=lib
|
||||
|
||||
CFLAGS=-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -pedantic -std=c90 -Wall
|
||||
CFLAGS := -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -pedantic -std=c90 -Wall
|
||||
|
||||
|
@ -116,14 +116,14 @@
|
||||
int cw_put_cisco_ap_timesync(uint8_t * dst, time_t time, uint8_t type);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
int cw_out_cisco_ap_timesync(struct conn *conn,struct cw_action_out * a,uint8_t *dst);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
int cw_addelem_cisco_ap_regulatory_domain(uint8_t *dst, struct radioinfo * ri);
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add a Cisco MWAR message element.
|
||||
@ -151,7 +151,10 @@ extern const char * cw_cisco_id_to_str(int elem_id);
|
||||
int cw_readelem_cisco_wtp_radio_cfg(int elem_id,uint8_t *elem, int len,struct radioinfo *ri);
|
||||
int cw_addelem_cisco_wtp_radio_cfg(uint8_t*dst,struct radioinfo * ri);
|
||||
|
||||
/*
|
||||
extern int cw_out_cisco_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst) ;
|
||||
*/
|
||||
|
||||
int cw_in_cisco_image_identifier(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len,struct sockaddr *from);
|
||||
|
||||
int cw_in_cipwap_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
|
@ -353,6 +353,8 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
mand_found = mavl_create_conststr();
|
||||
unrecognized = mlist_create(NULL,NULL,sizeof(uint8_t*));
|
||||
|
||||
cw_dbg(DBG_MSG_IN,"*** parsing messe elemtns for message of type %d (%s) ***",
|
||||
message->type,message->name);
|
||||
/* iterate through message elements */
|
||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
||||
int rc;
|
||||
@ -398,6 +400,10 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
by calling the "end" function for the message */
|
||||
|
||||
cw_check_missing_mand(message,mand_found);
|
||||
|
||||
cw_dbg(DBG_MSG_IN," *** parsing of message of type %d (%s) done ***",
|
||||
message->type,message->name);
|
||||
|
||||
mavl_destroy(mand_found);
|
||||
|
||||
{
|
||||
|
@ -5,73 +5,9 @@
|
||||
|
||||
|
||||
|
||||
|
||||
const char *get_dbg_color_ontext(int level);
|
||||
|
||||
/**
|
||||
* print debug info for message elements
|
||||
*/
|
||||
|
||||
void cw_dbg_elem(int level, struct conn *conn, int msg,
|
||||
struct cw_ElemHandler * handler,
|
||||
const uint8_t * msgbuf, int len)
|
||||
{
|
||||
|
||||
|
||||
/* const char *elemname;*/
|
||||
char vendorname[256];
|
||||
char vendor_details[265];
|
||||
|
||||
|
||||
if (!cw_dbg_is_level(level))
|
||||
return;
|
||||
|
||||
*vendor_details = 0;
|
||||
|
||||
/* handler = cw_msgset_get_elemhandler(conn->msgset,0,0,msgelem);
|
||||
if (!handler)
|
||||
return;
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
/// TODO XXXX
|
||||
*/
|
||||
/* if (msgelem == -1) {
|
||||
uint32_t vendor_id = ntohl(*((uint32_t *) msgbuf));
|
||||
int type = ntohs(*((uint16_t *) (msgbuf + 4)));
|
||||
cw_format_vendor(vendor_details, vendor_id, type, msgbuf);
|
||||
elemname = vendorname;
|
||||
|
||||
} else {
|
||||
elemname=handler->name;
|
||||
}
|
||||
*/
|
||||
if (handler->vendor){
|
||||
sprintf(vendorname,"Vendor %s",cw_strvendor(handler->vendor));
|
||||
}
|
||||
else{
|
||||
sprintf(vendorname,"");
|
||||
}
|
||||
|
||||
|
||||
if (cw_dbg_is_level(DBG_ELEM_DMP)) {
|
||||
/*
|
||||
char *dmp = cw_dbg_mkdmp(msgbuf, len);
|
||||
*/
|
||||
char *dmp;
|
||||
dmp = cw_format_dump(msgbuf,len,NULL);
|
||||
|
||||
cw_dbg(DBG_ELEM, "%s %d (%s), len=%d%s%s",
|
||||
vendorname,
|
||||
handler->id, handler->name, len, /*get_dbg_color_ontext(DBG_ELEM_DMP)*/ "", dmp);
|
||||
|
||||
free(dmp);
|
||||
}
|
||||
else
|
||||
cw_dbg(DBG_ELEM, "%s %d (%s), len=%d",
|
||||
vendorname,
|
||||
handler->id, handler->name, len);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ int cw_process_element(struct cw_ElemHandlerParams *params, int proto, int vendo
|
||||
return -1;
|
||||
}
|
||||
|
||||
cw_dbg_elem(DBG_ELEM, params->conn, params->msgdata->type, handler,
|
||||
cw_dbg_elem(DBG_ELEM_IN, params->conn, params->msgdata->type, handler,
|
||||
data,len);
|
||||
|
||||
return handler->get(handler, params, data, len);
|
||||
|
@ -49,6 +49,7 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
msgptr = rawout + cw_get_hdr_msg_offset(rawout);
|
||||
type = cw_get_msg_type(msgptr);
|
||||
|
||||
/* look for message data */
|
||||
msg = cw_msgset_get_msgdata(conn->msgset,type);
|
||||
if (msg == NULL){
|
||||
cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.",
|
||||
@ -56,8 +57,10 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
return CAPWAP_RESULT_MSG_UNRECOGNIZED;
|
||||
}
|
||||
|
||||
printf("Message to send: %s (elems %d)\n",msg->name, msg->elements_list->count);
|
||||
|
||||
cw_dbg(DBG_ELEM_OUT,"*** Assenmbling message of type %d (%s) ***",
|
||||
msg->type, msg->name);
|
||||
|
||||
dst = msgptr+8;
|
||||
len =0;
|
||||
mlist_foreach(elem,msg->elements_list){
|
||||
@ -67,7 +70,7 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
|
||||
data = mlistelem_dataptr(elem);
|
||||
handler = cw_msgset_get_elemhandler(conn->msgset,data->proto,data->vendor,data->id);
|
||||
printf("Elem: %d %d %d %s\n", data->proto, data->vendor, data->id, handler->name);
|
||||
/* printf("Elem: %d %d %d %s\n", data->proto, data->vendor, data->id, handler->name);*/
|
||||
|
||||
if (handler->put == NULL){
|
||||
if (data->mand){
|
||||
@ -83,7 +86,8 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
l = handler->put(handler,¶ms,dst+len);
|
||||
len += l;
|
||||
|
||||
cw_dbg_elem(DBG_ELEM,conn,type,handler,dst+len,l);
|
||||
if(l>0)
|
||||
cw_dbg_elem(DBG_ELEM_OUT,conn,type,handler,dst+len,l);
|
||||
}
|
||||
|
||||
cw_set_msg_elems_len(msgptr, len);
|
||||
@ -109,7 +113,7 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
*/
|
||||
|
||||
|
||||
int cw_put_custom_msg(struct conn *conn, uint8_t * rawout, /*mavl_conststr_t elems*/ t)
|
||||
int cw_put_custom_msg(struct conn *conn, uint8_t * rawout, /*mavl_conststr_t elems*/ int t)
|
||||
{
|
||||
|
||||
/*
|
||||
@ -202,7 +206,7 @@ MAVLITER_DEFINE(i,0);
|
||||
}
|
||||
*/
|
||||
|
||||
return 0; //len
|
||||
return 0; /*len*/
|
||||
}
|
||||
|
||||
|
||||
|
346
src/cw/dbg.c
346
src/cw/dbg.c
@ -24,19 +24,11 @@
|
||||
* @brief Various debug functions.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "capwap.h"
|
||||
#include "dbg.h"
|
||||
#include "sock.h"
|
||||
#include "log.h"
|
||||
#include "strlist.h"
|
||||
#include "format.h"
|
||||
#include "capwap.h"
|
||||
#include "capwap_cisco.h"
|
||||
#include "lwapp_cisco.h"
|
||||
#include "cw.h"
|
||||
#include "msgset.h"
|
||||
|
||||
|
||||
|
||||
@ -50,13 +42,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
void (*cw_dbg_cb) (int level, const char *format, ...) = CW_LOG_DEFAULT_LOG;
|
||||
void (*cw_dbg_vcb) (int level, const char *fromat, va_list args) = CW_LOG_DEFAULT_VLOG;
|
||||
*/
|
||||
|
||||
|
||||
uint32_t cw_dbg_opt_display = DBG_DISP_COLORS;
|
||||
|
||||
/**
|
||||
@ -65,15 +50,17 @@ uint32_t cw_dbg_opt_display = DBG_DISP_COLORS;
|
||||
uint32_t cw_dbg_opt_level = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
#define DBG_CLR_MAGENTA "\x1b[35m"
|
||||
#define DBG_CLR_MAGENTA_L "\x1b[95m"
|
||||
|
||||
#define DBG_CLR_MAGENTA_B "\x1b[1;35m"
|
||||
#define DBG_CLR_MAGENTA_F "\x1b[2;35m"
|
||||
#define DBG_CLR_MAGENTA_I "\x1b[3;35m"
|
||||
|
||||
#define DBG_CLR_BLUE "\x1b[34m"
|
||||
#define DBG_CLR_BLUE_B "\x1b[1;34m"
|
||||
#define DBG_CLR_BLUE_L "\x1b[94m"
|
||||
#define DBG_CLR_BLUE_F "\x1b[2;34m"
|
||||
#define DBG_CLR_BLUE_I "\x1b[3;34m"
|
||||
|
||||
@ -82,37 +69,63 @@ uint32_t cw_dbg_opt_level = 0;
|
||||
|
||||
#define DBG_CLR_CYAN "\x1b[36m"
|
||||
|
||||
|
||||
#define DBG_CLR_RED "\x1b[31m"
|
||||
#define DBG_CLR_RED_I "\x1b[3;31m"
|
||||
#define DBG_CLR_RED_L "\x1b[91m"
|
||||
|
||||
#define DBG_CLR_DEFAULT "\x1b[39m"
|
||||
#define DBG_CLR_DEFAULT_I "\x1b[3;39m"
|
||||
|
||||
#define DBG_CLR_BLACK "\x1b[30m"
|
||||
#define DBG_CLR_BLACK_L "\x1b[90m"
|
||||
#define DBG_CLR_BLACK_LI "\x1b[3;90m"
|
||||
|
||||
#define DBG_CLR_WHITE "\x1b[37m"
|
||||
#define DBG_CLR_WHITE_I "\x1b[3;37m"
|
||||
|
||||
|
||||
#define DBG_CLR_OFF "\x1b[22;39m\x1b[23m"
|
||||
|
||||
|
||||
#define ANSI_DEFAULT "\x1b[39m"
|
||||
#define ANSI_BLUE "\x1b[34m"
|
||||
|
||||
#define ANSI_ITALIC "\x1b[3m"
|
||||
#define ANSI_BOLD "\x1b[1m"
|
||||
|
||||
|
||||
static struct cw_StrListElem color_on[] = {
|
||||
{DBG_PKT_IN, DBG_CLR_YELLO},
|
||||
{DBG_PKT_OUT, DBG_CLR_YELLO_I},
|
||||
|
||||
{DBG_MSG_IN, DBG_CLR_BLUE},
|
||||
{DBG_MSG_OUT, DBG_CLR_BLUE_I},
|
||||
{DBG_MSG_IN, ANSI_BLUE },
|
||||
{DBG_MSG_OUT, ANSI_BLUE ANSI_ITALIC},
|
||||
|
||||
{DBG_ELEM, "\x1b[39m"},
|
||||
{DBG_MSG_ERR, "\x1b[31m"},
|
||||
{DBG_PKT_ERR, "\x1b[31m"},
|
||||
{DBG_ELEM_ERR, "\x1b[31m"},
|
||||
{DBG_SUBELEM, "\x1b[30m"},
|
||||
{DBG_ELEM_IN, ANSI_DEFAULT},
|
||||
{DBG_ELEM_OUT, ANSI_DEFAULT ANSI_ITALIC},
|
||||
|
||||
{DBG_MSG_ERR, DBG_CLR_RED},
|
||||
{DBG_PKT_ERR, DBG_CLR_RED},
|
||||
{DBG_ELEM_ERR, DBG_CLR_RED},
|
||||
|
||||
{DBG_SUBELEM, DBG_CLR_BLACK},
|
||||
{DBG_DTLS, DBG_CLR_MAGENTA_B},
|
||||
{DBG_DTLS_DETAIL, DBG_CLR_MAGENTA},
|
||||
{DBG_DTLS_BIO, DBG_CLR_MAGENTA_L},
|
||||
|
||||
{DBG_INFO, DBG_CLR_DEFAULT},
|
||||
|
||||
{DBG_RFC, "\x1b[31m"},
|
||||
{DBG_RFC, DBG_CLR_RED},
|
||||
{DBG_X, "\x1b[31m"},
|
||||
{DBG_WARN, DBG_CLR_CYAN},
|
||||
{DBG_MOD, "\x1b[91m"},
|
||||
{DBG_MOD, DBG_CLR_WHITE},
|
||||
{CW_STR_STOP, ""}
|
||||
};
|
||||
|
||||
static struct cw_StrListElem color_ontext[] = {
|
||||
struct cw_StrListElem color_ontext[] = {
|
||||
|
||||
{DBG_ELEM_DMP, "\x1b[30m"},
|
||||
/* {DBG_ELEM_DMP, "\x1b[37m"},*/
|
||||
{DBG_ELEM_DMP, DBG_CLR_BLACK_LI},
|
||||
{CW_STR_STOP, ""}
|
||||
};
|
||||
|
||||
@ -129,7 +142,9 @@ static struct cw_StrListElem prefix[] = {
|
||||
{DBG_MSG_IN, " Msg IN -"},
|
||||
{DBG_MSG_OUT, " Msg Out -"},
|
||||
|
||||
{DBG_ELEM, " Msg Element -"},
|
||||
{DBG_ELEM_IN, " Msg Element -"},
|
||||
{DBG_ELEM_OUT, " Msg Element -"},
|
||||
|
||||
{DBG_MSG_ERR, " Msg Error -"},
|
||||
{DBG_PKT_ERR, " Pkt Error -"},
|
||||
{DBG_ELEM_ERR, " Elem Error -"},
|
||||
@ -163,7 +178,7 @@ static const char *get_dbg_prefix(int level)
|
||||
return cw_strlist_get_str(prefix, level);
|
||||
}
|
||||
|
||||
static const char *get_dbg_color_ontext(int level)
|
||||
const char *get_dbg_color_ontext(int level)
|
||||
{
|
||||
if (!(cw_dbg_opt_display & DBG_DISP_COLORS))
|
||||
return "";
|
||||
@ -175,7 +190,24 @@ static const char *get_dbg_color_ontext(int level)
|
||||
|
||||
|
||||
|
||||
static void cw_dbg_vlog_line(struct cw_LogWriter * writer,
|
||||
const char * prefix, const char * prefix_color,
|
||||
const char *textcolor,const char * format, va_list args)
|
||||
{
|
||||
char fbuf[512];
|
||||
|
||||
if ( writer->colored){
|
||||
sprintf(fbuf,"DBG: %s%s %s%s%s",
|
||||
prefix_color,prefix,textcolor,format,DBG_CLR_OFF);
|
||||
}
|
||||
else{
|
||||
sprintf(fbuf,"DBG: %s %s",
|
||||
prefix,format);
|
||||
|
||||
}
|
||||
writer->write(LOG_DEBUG,fbuf,args,writer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -247,41 +279,32 @@ void cw_dbg_pkt(int level, struct conn *conn, uint8_t * packet, int len,
|
||||
cw_dbg(level, "%s", buf);
|
||||
}
|
||||
|
||||
void cw_dbg_pkt_nc(int level, struct netconn *nc, uint8_t * packet, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
/*
|
||||
if (!cw_dbg_is_level(level))
|
||||
return;
|
||||
|
||||
char buf[1024];
|
||||
cw_format_pkt_hdr(buf, level, NULL, packet, len, from);
|
||||
|
||||
int hlen = cw_get_hdr_msg_offset(packet);
|
||||
|
||||
if (cw_dbg_is_level(DBG_PKT_DMP)) {
|
||||
char *dmp = cw_dbg_mkdmp_c(packet, len, hlen);
|
||||
cw_dbg(level, "%s%s", buf, dmp);
|
||||
free(dmp);
|
||||
} else
|
||||
cw_dbg(level, "%s", buf);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cw_dbg_dmp(int level, const uint8_t * data, int len, const char *format, ...)
|
||||
{
|
||||
char *dmp;
|
||||
|
||||
char *dmp,*s,*c;
|
||||
struct cw_FormatDumpSettings settings;
|
||||
|
||||
if (!cw_dbg_is_level(level))
|
||||
return;
|
||||
|
||||
dmp = cw_format_dump(data, len, NULL);
|
||||
cw_dbg(level, "%s%s", format, dmp);
|
||||
cw_format_get_dump_defaults(&settings);
|
||||
|
||||
settings.dump_prefix=" ";
|
||||
settings.newline="\n ";
|
||||
settings.dump_suffix="\n";
|
||||
|
||||
|
||||
dmp = cw_format_dump(data, len, &settings);
|
||||
|
||||
/* wrtie the dump line by line to the log file */
|
||||
c=dmp;
|
||||
while ((s=strchr(c,'\n'))!=NULL){
|
||||
*s=0;
|
||||
cw_dbg(level," %s",c);
|
||||
c=s+1;
|
||||
}
|
||||
|
||||
free(dmp);
|
||||
}
|
||||
|
||||
@ -304,25 +327,18 @@ void cw_dbg_msg(int level, struct conn *conn, uint8_t * packet, int len,
|
||||
|
||||
s = buf;
|
||||
|
||||
|
||||
msgptr = cw_get_hdr_msg_ptr(packet);
|
||||
/*
|
||||
// int pplen = len - (msgptr-packet);
|
||||
*/
|
||||
msg_id = cw_get_msg_id(msgptr);
|
||||
|
||||
|
||||
search.type = msg_id;
|
||||
|
||||
message = mavl_get(conn->msgset->msgdata,&search);
|
||||
|
||||
|
||||
if (!message)
|
||||
msname="Unknown";
|
||||
msname=cw_strmsg(msg_id);
|
||||
else
|
||||
msname = message->name;
|
||||
|
||||
s += sprintf(s, "%s Message (type=%d) ", msname /*cw_strmsg(msg_id)*/, msg_id);
|
||||
s += sprintf(s, "%s Message (type=%d) ", msname , msg_id);
|
||||
if (level == DBG_MSG_IN)
|
||||
s += sprintf(s, "from %s ", sock_addr2str(from,sock_buf));
|
||||
else
|
||||
@ -330,9 +346,7 @@ void cw_dbg_msg(int level, struct conn *conn, uint8_t * packet, int len,
|
||||
|
||||
s += sprintf(s, ", Seqnum: %d ElemLen: %d", cw_get_msg_seqnum(msgptr),
|
||||
cw_get_msg_elems_len(msgptr));
|
||||
/*
|
||||
//abort:
|
||||
*/
|
||||
|
||||
cw_dbg(level, "%s", buf);
|
||||
}
|
||||
|
||||
@ -395,56 +409,174 @@ void cw_dbg_version_subelem(int level, const char *context, int subtype,
|
||||
}
|
||||
|
||||
|
||||
void cw_dbg(int level, const char *format, ...)
|
||||
void cw_dbgv(struct cw_LogWriter *writer, int level, const char * format, va_list args)
|
||||
{
|
||||
char fbuf[1024];
|
||||
va_list args;
|
||||
|
||||
if (writer->colored ){
|
||||
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)
|
||||
);
|
||||
}
|
||||
else{
|
||||
sprintf(fbuf, "DBG:%s %s",
|
||||
get_dbg_prefix(level), format);
|
||||
}
|
||||
|
||||
writer->write(LOG_DEBUG,fbuf,args,&cw_log_console_writer);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void cw_dbgv1(struct cw_LogWriter *writer, int level, const char * format, ...){
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
cw_dbgv(writer,level,format,args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void cw_dbg(int level, const char *format, ...){
|
||||
int i;
|
||||
va_list args;
|
||||
|
||||
if (!(cw_dbg_is_level(level)))
|
||||
return;
|
||||
|
||||
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_vcb(level, fbuf, args);*/
|
||||
|
||||
|
||||
|
||||
cw_log_console_writer.write(LOG_DEBUG,fbuf,args,&cw_log_console_writer);
|
||||
va_end(args);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
//int cw_is_utf8(unsigned char *str, size_t len);
|
||||
*/
|
||||
|
||||
/*
|
||||
int cw_format_item(char *dst, mbag_item_t * item)
|
||||
{
|
||||
*dst = 0;
|
||||
if (item->type == MBAG_BSTR16) {
|
||||
strncpy(dst, (char *) bstr16_data(item->u2.data), bstr16_len(item->u2.data));
|
||||
*(dst + bstr16_len(item->u2.data)) = 0;
|
||||
return bstr16_len(item->u2.data);
|
||||
|
||||
|
||||
|
||||
for (i=0; cw_log_writers[i]; i++){
|
||||
va_start(args, format);
|
||||
cw_dbg_vlog_line(cw_log_writers[i],
|
||||
get_dbg_prefix(level),get_dbg_color_on(level),
|
||||
get_dbg_color_ontext(level),
|
||||
format, args);
|
||||
va_end(args);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cw_dbg_help(struct cw_LogWriter *writer, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
/* if(writer->colored){
|
||||
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));
|
||||
|
||||
if (dmp!=NULL){
|
||||
sprintf(dbuf,"%s%s%s",
|
||||
get_dbg_color_ontext(dmp_level),"%s",
|
||||
get_dbg_color_off(dmp_level)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
va_start(args, format);
|
||||
writer->write(LOG_DEBUG,format,args,writer);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void builddmp(char *fbuf, char *format, int level, char *dmp, int dmp_level, int colored ){
|
||||
|
||||
char dbuf[128];
|
||||
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));
|
||||
|
||||
|
||||
if (dmp!=NULL){
|
||||
sprintf(dbuf,"%s%s%s",get_dbg_color_ontext(dmp_level),"%s",
|
||||
get_dbg_color_off(dmp_level));
|
||||
}
|
||||
strcat(fbuf,dbuf);
|
||||
}
|
||||
|
||||
void cw_dbg_elem(int level, struct conn *conn, int msg,
|
||||
struct cw_ElemHandler * handler,
|
||||
const uint8_t * msgbuf, int len)
|
||||
{
|
||||
char vendorname[256];
|
||||
char vendor_details[265];
|
||||
char *dmp;
|
||||
int i;
|
||||
|
||||
if (!cw_dbg_is_level(level))
|
||||
return;
|
||||
|
||||
*vendor_details = 0;
|
||||
|
||||
if (handler->vendor){
|
||||
sprintf(vendorname,"Vendor %s",cw_strvendor(handler->vendor));
|
||||
}
|
||||
else{
|
||||
sprintf(vendorname,"");
|
||||
}
|
||||
|
||||
cw_dbg(level,"%s %d (%s), len=%d ",vendorname,handler->id,
|
||||
handler->name,len);
|
||||
|
||||
if (cw_dbg_is_level(DBG_ELEM_DMP)) {
|
||||
/*dmp = cw_format_dump(msgbuf,len,NULL);*/
|
||||
|
||||
cw_dbg_dmp(DBG_ELEM_DMP,msgbuf,len,"hallo");
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dmp = NULL;
|
||||
if (cw_dbg_is_level(DBG_ELEM_DMP)) {
|
||||
dmp = cw_format_dump(msgbuf,len,NULL);
|
||||
}
|
||||
|
||||
for (i=0; cw_log_writers[i]; i++){
|
||||
char fbuf[512];
|
||||
|
||||
if (cw_log_writers[i]->colored){
|
||||
builddmp(fbuf,"%s %d (%s), len=%d ",level,dmp,DBG_ELEM_DMP,cw_log_writers[i]->colored);
|
||||
cw_dbg_help(cw_log_writers[i],fbuf,vendorname,handler->id,handler->name,
|
||||
len, dmp);
|
||||
|
||||
}
|
||||
else{
|
||||
if (!dmp){
|
||||
cw_dbgv1(cw_log_writers[i],level,"%s %d (%s), len=%d ",vendorname,handler->id,
|
||||
handler->name,len);
|
||||
}
|
||||
else{
|
||||
cw_dbgv1(cw_log_writers[i],level,"%s %d (%s), len=%d\n%s",vendorname,handler->id,
|
||||
handler->name,len,dmp);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* cw_dbg(DBG_ELEM_IN, "%s %d (%s), len=%d%s%s",
|
||||
vendorname,
|
||||
handler->id, handler->name, len, get_dbg_color_ontext(DBG_ELEM_DMP), dmp);
|
||||
*/
|
||||
/* cw_dbg(DBG_ELEM_IN, "%s %d (%s), len=%d",
|
||||
vendorname,
|
||||
handler->id, handler->name, len);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
free(dmp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -69,8 +69,11 @@ enum cw_dbg_levels{
|
||||
/** Message errors */
|
||||
DBG_MSG_ERR,
|
||||
|
||||
/** Show message elements */
|
||||
DBG_ELEM,
|
||||
/** Show message elements in incomming messages */
|
||||
DBG_ELEM_IN,
|
||||
|
||||
/** Show message elements assembled for outgoing messages */
|
||||
DBG_ELEM_OUT,
|
||||
|
||||
/** Show message element details */
|
||||
DBG_ELEM_DETAIL,
|
||||
|
@ -35,23 +35,27 @@
|
||||
* Debug strings
|
||||
*/
|
||||
struct cw_StrListElem cw_dbg_strings[] = {
|
||||
{ DBG_INFO, "info" },
|
||||
{ DBG_INFO, "info", "Schow diverse info messages" },
|
||||
{ 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", "Display incomming CAPWAP/LWAPP messages." },
|
||||
{ DBG_MSG_OUT, "msg_out", "Display outgoing CAPWAP/LWAPP messages."},
|
||||
{ DBG_MSG_ERR, "msg_err" },
|
||||
{ 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", "Messages wirh errors" },
|
||||
|
||||
{ DBG_RFC, "rfc", "RFC related errors"},
|
||||
{ DBG_ELEM_IN, "elem_in", "Elements of incomming messages" },
|
||||
{ DBG_ELEM_OUT, "elem_out", "Elements of outgoing messages" },
|
||||
{ DBG_ELEM_DMP, "elem_dmp" , "Dump elements" },
|
||||
|
||||
{ DBG_SUBELEM, "subelem", "Show sub-elements." },
|
||||
{ DBG_SUBELEM_DMP, "subelem_dmp", "Dump sub-elements" },
|
||||
|
||||
{ DBG_ELEM, "elem" },
|
||||
{ DBG_ELEM_DETAIL, "elem_detail"},
|
||||
{ DBG_ELEM_DMP, "elem_dmp" },
|
||||
|
||||
{ DBG_ELEM_ERR, "elem_err" },
|
||||
|
||||
{ DBG_DTLS, "dtls" },
|
||||
|
19
src/cw/log.c
19
src/cw/log.c
@ -22,14 +22,9 @@
|
||||
#include "strlist.h"
|
||||
#include "log.h"
|
||||
|
||||
/*
|
||||
void (*cw_log_cb)(int level,const char * fromat, ...) = CW_LOG_DEFAULT_LOG;
|
||||
void (*cw_log_vcb)(int level,const char * fromat, va_list args) = CW_LOG_DEFAULT_VLOG;
|
||||
*/
|
||||
|
||||
const char * cw_log_name = "actube";
|
||||
|
||||
|
||||
static struct cw_StrListElem prefix[] = {
|
||||
{LOG_DEBUG, "DBG"},
|
||||
{LOG_INFO, "INF" },
|
||||
@ -66,7 +61,7 @@ static struct cw_StrListElem end_color[] = {
|
||||
{CW_STR_STOP, NULL}
|
||||
};
|
||||
|
||||
static struct cw_LogWriter * writers[] = {
|
||||
struct cw_LogWriter * cw_log_writers[] = {
|
||||
&cw_log_syslog_writer,
|
||||
&cw_log_console_writer,
|
||||
NULL
|
||||
@ -78,12 +73,10 @@ void cw_log(int prio, const char *format, ...)
|
||||
va_list args;
|
||||
char fbuf[1024];
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
for (i=0; writers[i]; i++){
|
||||
for (i=0; cw_log_writers[i]; i++){
|
||||
|
||||
if (writers[i]->colored){
|
||||
if (cw_log_writers[i]->colored){
|
||||
sprintf(fbuf, "%s%s%s: %s%s",
|
||||
cw_strlist_get_str(prefix_color,prio),
|
||||
cw_strlist_get_str(prefix,prio),
|
||||
@ -101,7 +94,7 @@ void cw_log(int prio, const char *format, ...)
|
||||
|
||||
}
|
||||
va_start(args, format);
|
||||
writers[i]->write(prio,fbuf,args,writers[i]);
|
||||
cw_log_writers[i]->write(prio,fbuf,args,cw_log_writers[i]);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@ -110,7 +103,7 @@ void cw_log(int prio, const char *format, ...)
|
||||
|
||||
void cw_log_init(){
|
||||
int i;
|
||||
for (i=0; writers[i]; i++){
|
||||
writers[i]->open();
|
||||
for (i=0; cw_log_writers[i]; i++){
|
||||
cw_log_writers[i]->open();
|
||||
}
|
||||
}
|
||||
|
64
src/cw/log.h
64
src/cw/log.h
@ -32,13 +32,6 @@
|
||||
#define LOG_ERROR LOG_ERR
|
||||
#endif
|
||||
|
||||
#ifndef CW_LOG_DEFAULT_LOG
|
||||
#define CW_LOG_DEFAULT_LOG cw_log_file
|
||||
#endif
|
||||
#ifndef CW_LOG_DEFAULT_VLOG
|
||||
#define CW_LOG_DEFAULT_VLOG cw_log_vfile
|
||||
#endif
|
||||
|
||||
struct cw_LogWriter {
|
||||
const char * name;
|
||||
int colored;
|
||||
@ -53,64 +46,9 @@ extern struct cw_LogWriter cw_log_console_writer;
|
||||
|
||||
void cw_log_init();
|
||||
void cw_log(int level, const char *format, ...);
|
||||
extern const char *cw_log_name;
|
||||
|
||||
|
||||
|
||||
/****/
|
||||
|
||||
/*extern void (*cw_log_cb) (int level, const char *fromat, ...);
|
||||
extern void (*cw_log_vcb) (int level, const char *fromat, va_list args);
|
||||
*/
|
||||
/* Syslog functins */
|
||||
|
||||
|
||||
|
||||
/* Log to File functions */
|
||||
|
||||
/*
|
||||
void cw_log_vfile(int level,const char * format, va_list args);
|
||||
void cw_log_file(int level,const char *format, ...);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
//extern void (*cw_log_debug_cb) (int type, const char *format, ...);
|
||||
|
||||
//extern void (*cw_log_debug_cbs[]) (const char *fromat, ...);
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
extern int cw_log_debug_dump_(int level, const uint8_t * data, int len,
|
||||
const char *format, ...);
|
||||
|
||||
|
||||
extern void cw_dbg_msgelem_(int msg, int msgelem, const uint8_t * msgbuf, int len);
|
||||
|
||||
|
||||
struct conn;
|
||||
extern void cw_dbg_missing_mand_elems_(struct conn *conn, int msgtyoe, int *mand);
|
||||
|
||||
extern void lw_dbg_elem(int msg_id, int elem_id, const uint8_t * elem_data, int elem_len);
|
||||
|
||||
extern int cw_log_debug_level;
|
||||
extern int cw_log_str2dbglevel(const char *str);
|
||||
|
||||
|
||||
extern const char *cw_log_name;
|
||||
extern struct cw_LogWriter * cw_log_writers[];
|
||||
|
||||
struct cw_dbg_cfgstrs {
|
||||
const char *name;
|
||||
int level;
|
||||
};
|
||||
|
||||
extern struct cw_dbg_cfgstrs cw_dbg_cfgstrs[];
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
include ../../Macros.mak
|
||||
include ../../Config.mak
|
||||
include ../../Config.local.mak
|
||||
include ../../Macros.mak
|
||||
|
||||
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
include ../../Macros.mak
|
||||
include ../../Config.mak
|
||||
include ../../Config.local.mak
|
||||
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ int capwap_in_vendor_specific_payload(struct cw_ElemHandler *handler,
|
||||
return 0;
|
||||
}
|
||||
|
||||
cw_dbg_elem(DBG_ELEM,params->conn,0,vhandler,data+6,len-6);
|
||||
cw_dbg_elem(DBG_ELEM_IN,params->conn,0,vhandler,data+6,len-6);
|
||||
//vhandler->get(vhandler, params, data+6, len-6);
|
||||
|
||||
cw_process_element(params,0,vendor_id,elem_id,data+6,len-6);
|
||||
|
@ -57,7 +57,7 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
|
||||
d+=cw_put_encryption_subelems(d,params->conn->capwap_mode);
|
||||
|
||||
|
||||
cw_ktv_dump(params->conn->local_cfg,DBG_INFO,"*** ktv dump ***","","*** end of dump ***");
|
||||
/*cw_ktv_dump(params->conn->local_cfg,DBG_INFO,"*** ktv dump ***","","*** end of dump ***");*/
|
||||
|
||||
/* hardware version sub element */
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
|
||||
|
@ -35,7 +35,7 @@ int cisco_out_radio_operational_state(struct conn *conn, struct cw_action_out *a
|
||||
|
||||
|
||||
|
||||
cw_dbg_elem(DBG_ELEM,conn,1,1,dst+l,l);
|
||||
cw_dbg_elem(DBG_ELEM_IN,conn,1,1,dst+l,l);
|
||||
|
||||
}
|
||||
return l;
|
||||
|
@ -200,7 +200,7 @@ int run_join(struct conn *conn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cw_dbg(DBG_ELEM, "Joined AC at %s, Join Result: %d - %s",
|
||||
cw_dbg(DBG_ELEM_IN, "Joined AC at %s, Join Result: %d - %s",
|
||||
sock_addr2str(&conn->addr), rc, cw_strresult(rc));
|
||||
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user