New message handler format

FossilOrigin-Name: bb2a1847072e2bf5e381dfdf0c4465b064c3feaab0faf51f93a7f4b8d2bcd999
This commit is contained in:
7u83@mail.ru
2018-03-09 06:44:17 +00:00
parent 06e50e8318
commit 5718781138
33 changed files with 351 additions and 261 deletions

View File

@ -3,11 +3,16 @@
#include "dbg.h"
#include "format.h"
/**
* print debug info for message elements
*/
void cw_dbg_elem_x(int level, struct conn *conn, int msg, int msgelem,
void cw_dbg_elem(int level, struct conn *conn, int msg,
struct cw_ElemHandler * handler,
const uint8_t * msgbuf, int len)
{
@ -16,46 +21,57 @@ void cw_dbg_elem_x(int level, struct conn *conn, int msg, int msgelem,
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 == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
/* 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);
// sprintf(vendorname, "%s/%s/%s",
// cw_strelemp(conn->actions, msgelem),
// (char *) cw_strvendor(vendor_id), vendor_details);
elemname = vendorname;
} else {
// elemname = cw_strelemp(conn->actions, msgelem);
elemname=0;
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)) {
cw_dbg(DBG_ELEM, "%d (%s), len=%d", msgelem, elemname, len);
} else {
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, "%d (%s), len=%d%s%s",
msgelem, elemname, len, get_dbg_color_ontext(DBG_ELEM_DMP), dmp);
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);
}