renamed a lot of cw_format_* to format_*
FossilOrigin-Name: 23ddf0840bc6910dc3ddf4f763ff9976441573173d8e669cc02cbc0520f12f00
This commit is contained in:
parent
10efce8ee2
commit
1dbb599802
@ -22,3 +22,4 @@ CC=clang
|
|||||||
|
|
||||||
COMPDEFS=-DWITH_CW_LOG
|
COMPDEFS=-DWITH_CW_LOG
|
||||||
COMPDEFS+=-DWITH_CW_LOG_DEBUG
|
COMPDEFS+=-DWITH_CW_LOG_DEBUG
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ include ../Config.mak
|
|||||||
|
|
||||||
#
|
#
|
||||||
SSL_LIBRARY=GNUTLS
|
SSL_LIBRARY=GNUTLS
|
||||||
|
#WITH_OPENSSL=1
|
||||||
|
|
||||||
|
|
||||||
CFLAGS += -I/usr/include/libnl3
|
CFLAGS += -I/usr/include/libnl3
|
||||||
|
@ -24,7 +24,7 @@ uint8_t * bstr16_create_from_str(const char *s)
|
|||||||
msize++;
|
msize++;
|
||||||
uint8_t * mem = malloc(2+msize);
|
uint8_t * mem = malloc(2+msize);
|
||||||
*((uint16_t*)mem)=msize;
|
*((uint16_t*)mem)=msize;
|
||||||
cw_format_scan_hex_bytes(mem+2,s+2,l);
|
format_scan_hex_bytes(mem+2,s+2,l);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ uint8_t * bstr_create_from_str(const char *s)
|
|||||||
msize++;
|
msize++;
|
||||||
uint8_t * mem = malloc(1+msize);
|
uint8_t * mem = malloc(1+msize);
|
||||||
*((uint8_t*)mem)=msize;
|
*((uint8_t*)mem)=msize;
|
||||||
cw_format_scan_hex_bytes(mem+2,s+2,l);
|
format_scan_hex_bytes(mem+2,s+2,l);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ int cw_format_pkt(char *dst,int level,struct conn *conn, uint8_t * packet, int l
|
|||||||
|
|
||||||
|
|
||||||
s+=sprintf(s," Flgs:");
|
s+=sprintf(s," Flgs:");
|
||||||
s+=cw_format_hdr_flags(s,packet);
|
s+=format_hdr_flags(s,packet);
|
||||||
|
|
||||||
if (len<8)
|
if (len<8)
|
||||||
goto abort;
|
goto abort;
|
||||||
@ -252,7 +252,7 @@ int cw_format_pkt(char *dst,int level,struct conn *conn, uint8_t * packet, int l
|
|||||||
plen=10;
|
plen=10;
|
||||||
|
|
||||||
s+=sprintf(s," R-MAC:");
|
s+=sprintf(s," R-MAC:");
|
||||||
s+=cw_format_mac(s,cw_get_hdr_rmac_data(packet),plen);
|
s+=format_mac(s,cw_get_hdr_rmac_data(packet),plen);
|
||||||
if (rmac_len>10){
|
if (rmac_len>10){
|
||||||
s+=sprintf(s," ... (len=%d)",rmac_len);
|
s+=sprintf(s," ... (len=%d)",rmac_len);
|
||||||
}
|
}
|
||||||
|
@ -194,6 +194,11 @@ void cw_dbg_version_subelem(int level,const char*context,int subtype,bstrv_t vst
|
|||||||
#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))))
|
(on ? cw_dbg_opt_level |= (1<<(level)) : (cw_dbg_opt_level &= (-1)^(1<<(level))))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a specific debug level is set.
|
||||||
|
* @param level Level to check
|
||||||
|
* @return 0 if leveln is not set, otherwise level is set
|
||||||
|
*/
|
||||||
#define cw_dbg_is_level(level)\
|
#define cw_dbg_is_level(level)\
|
||||||
(cw_dbg_opt_level & (1<<level))
|
(cw_dbg_opt_level & (1<<level))
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of libcapwap.
|
This file is part of actube.
|
||||||
|
|
||||||
libcapwap is free software: you can redistribute it and/or modify
|
actube is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
@ -51,6 +51,7 @@ struct cw_strlist_elem cw_dbg_strings[] = {
|
|||||||
{ DBG_ELEM_ERR, "elem_err" },
|
{ DBG_ELEM_ERR, "elem_err" },
|
||||||
{ DBG_DTLS, "dtls" },
|
{ DBG_DTLS, "dtls" },
|
||||||
{ DBG_DTLS_BIO, "dtls_bio" },
|
{ DBG_DTLS_BIO, "dtls_bio" },
|
||||||
|
{ DBG_DTLS_BIO_DMP, "dtls_bio_dmp"},
|
||||||
{ DBG_WARN, "warn" },
|
{ DBG_WARN, "warn" },
|
||||||
{ DBG_MOD,"mod"},
|
{ DBG_MOD,"mod"},
|
||||||
|
|
||||||
@ -96,14 +97,4 @@ struct cw_dbg_cfgstrs cw_dbg_cfgstrs[] = {
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
int cw_log_str2dbglevel(const char * str)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i=0; cw_dbg_cfgstrs[i].name; i++) {
|
|
||||||
if (!strcmp(str,cw_dbg_cfgstrs[i].name))
|
|
||||||
return cw_dbg_cfgstrs[i].level;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
* where x is the number of characters. A formatted hex byte needs (typically 2).
|
* where x is the number of characters. A formatted hex byte needs (typically 2).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int cw_format_hex_bytes(char *dst, const char *format, const char *delim,
|
int format_hex_bytes(char *dst, const char *format, const char *delim,
|
||||||
const uint8_t * src, int len)
|
const uint8_t * src, int len)
|
||||||
{
|
{
|
||||||
char *d = dst;
|
char *d = dst;
|
||||||
@ -68,7 +68,7 @@ int cw_format_hex_bytes(char *dst, const char *format, const char *delim,
|
|||||||
* @return 0 if all was ok \n 1 if an error has occured.
|
* @return 0 if all was ok \n 1 if an error has occured.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len)
|
int format_scan_hex_bytes(uint8_t *dst,const char *s, int len)
|
||||||
{
|
{
|
||||||
int rc ;
|
int rc ;
|
||||||
int err=0;
|
int err=0;
|
||||||
|
@ -18,19 +18,19 @@
|
|||||||
/**
|
/**
|
||||||
*@file
|
*@file
|
||||||
*@brief prototypes for format-functions
|
*@brief prototypes for format-functions
|
||||||
*@defgroup FormatFunctions FORMAT Functions
|
*@defgroup FORMAT FORMAT
|
||||||
*@{
|
*@{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __CW_FORMAT_H
|
#ifndef __FORMAT_H
|
||||||
#define __CW_FORMAT_H
|
#define __FORMAT_H
|
||||||
|
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
|
|
||||||
extern int cw_format_hex_bytes(char *dst, const char *format, const char *delim,
|
extern int format_hex_bytes(char *dst, const char *format, const char *delim,
|
||||||
const uint8_t * src, int len);
|
const uint8_t * src, int len);
|
||||||
extern int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
|
extern int format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -44,39 +44,28 @@ extern int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
|
|||||||
* Make sure, the destination buffer can hold at least len * 2 characters + the trailing
|
* Make sure, the destination buffer can hold at least len * 2 characters + the trailing
|
||||||
* zero for strings.
|
* zero for strings.
|
||||||
*/
|
*/
|
||||||
#define cw_format_hexl(dst,bytes,len)\
|
#define format_hexl(dst,bytes,len)\
|
||||||
cw_format_hex_bytes(dst,"%02x","",bytes,len)
|
format_hex_bytes(dst,"%02x","",bytes,len)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format bytes as hex string. Same as #cw_format_hexl, but
|
* Format bytes as hex string. Same as #format_hexl, but
|
||||||
* hexadecimal letters are upper-case.
|
* hexadecimal letters are upper-case.
|
||||||
*/
|
*/
|
||||||
#define cw_format_hexu(dst,bytes,len)\
|
#define format_hexu(dst,bytes,len)\
|
||||||
cw_format_hex_bytes(dst,"%02X","",bytes,len)
|
format_hex_bytes(dst,"%02X","",bytes,len)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias for #cw_format_hexl.
|
* Alias for #format_hexl.
|
||||||
*/
|
*/
|
||||||
#define cw_format_hex cw_format_hexl
|
#define format_hex format_hexl
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format MAC Address.
|
* Format MAC Address.
|
||||||
*/
|
*/
|
||||||
#define cw_format_mac(dst,src,len)\
|
#define format_mac(dst,src,len)\
|
||||||
cw_format_hex_bytes(dst,"%02x",":",src,len)
|
format_hex_bytes(dst,"%02x",":",src,len)
|
||||||
|
|
||||||
/*#define cw_format_hdr_flags(s,th) \
|
static inline int format_hdr_flags(char *dst,uint8_t *th)
|
||||||
sprintf(s,"(T=%d,F=%d,L=%d,W=%d,M=%d,K=%d)",\
|
|
||||||
cw_get_hdr_flag_t(packet),\
|
|
||||||
cw_get_hdr_flag_f(packet),\
|
|
||||||
cw_get_hdr_flag_l(packet),\
|
|
||||||
cw_get_hdr_flag_w(packet),\
|
|
||||||
cw_get_hdr_flag_m(packet),\
|
|
||||||
cw_get_hdr_flag_k(packet)\
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline int cw_format_hdr_flags(char *dst,uint8_t *th)
|
|
||||||
{
|
{
|
||||||
char * s = dst;
|
char * s = dst;
|
||||||
s+=sprintf(s,"%s", "(");
|
s+=sprintf(s,"%s", "(");
|
||||||
|
@ -22,7 +22,7 @@ static int to_str(void *item,char *dst)
|
|||||||
d += sprintf(d, "%.*s", bstr16_len(i->data), bstr16_data(i->data));
|
d += sprintf(d, "%.*s", bstr16_len(i->data), bstr16_data(i->data));
|
||||||
} else {
|
} else {
|
||||||
d += sprintf(d, ".x");
|
d += sprintf(d, ".x");
|
||||||
d += cw_format_hex(d, bstr16_data(i->data), bstr16_len(i->data));
|
d += format_hex(d, bstr16_data(i->data), bstr16_len(i->data));
|
||||||
}
|
}
|
||||||
return d-dst;
|
return d-dst;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ static int to_str(void *item,char *dst)
|
|||||||
bstrv_data(i->data));
|
bstrv_data(i->data));
|
||||||
} else {
|
} else {
|
||||||
d += sprintf(d, ".x");
|
d += sprintf(d, ".x");
|
||||||
d += cw_format_hex(d, bstrv_data(i->data), bstrv_len(i->data));
|
d += format_hex(d, bstrv_data(i->data), bstrv_len(i->data));
|
||||||
}
|
}
|
||||||
|
|
||||||
return d-dst;
|
return d-dst;
|
||||||
|
@ -30,7 +30,7 @@ uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s)
|
|||||||
bstrv_set_vendor_id(mem,vendor_id);
|
bstrv_set_vendor_id(mem,vendor_id);
|
||||||
bstrv_set_len(mem,msize);
|
bstrv_set_len(mem,msize);
|
||||||
|
|
||||||
cw_format_scan_hex_bytes(bstrv_data(mem),s+2,l);
|
format_scan_hex_bytes(bstrv_data(mem),s+2,l);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ int setup_conf(struct conn * conn)
|
|||||||
* base rmac */
|
* base rmac */
|
||||||
char name[32];
|
char name[32];
|
||||||
strcpy(name,WTP_DEFAULT_NAME_PREFIX);
|
strcpy(name,WTP_DEFAULT_NAME_PREFIX);
|
||||||
int l = cw_format_hexu(name+strlen(WTP_DEFAULT_NAME_PREFIX),
|
int l = format_hexu(name+strlen(WTP_DEFAULT_NAME_PREFIX),
|
||||||
bstr_data(conn->base_rmac),bstr_len(conn->base_rmac));
|
bstr_data(conn->base_rmac),bstr_len(conn->base_rmac));
|
||||||
|
|
||||||
name[l+strlen(WTP_DEFAULT_NAME_PREFIX)]=0;
|
name[l+strlen(WTP_DEFAULT_NAME_PREFIX)]=0;
|
||||||
|
Loading…
Reference in New Issue
Block a user