Colored debugging...

FossilOrigin-Name: 153201cffee624726d6bcd3e428c0d69d7cc9e9cba6a84a5687de94a850550dd
This commit is contained in:
7u83@mail.ru
2015-04-11 17:00:51 +00:00
parent 4460a959b9
commit 73aba62d2b
66 changed files with 890 additions and 688 deletions

View File

@ -38,8 +38,8 @@ LOGOBJS=log.o \
log_syslog.o \
log_file.o \
cw_log_debug.o \
cw_log_str2dbglevel.o \
cw_dbg_elem.o
cw_dbg_elem.o \
dbg_strings.o
@ -74,7 +74,6 @@ LWAPPOBJS = \
lw_checksum.o \
lw_put_ac_descriptor.o \
lw_put_cisco_path_mtu.o \
lw_readelem_wtp_name.o \
lw_put_80211_wtp_wlan_radio_configuration.o \
lw_readelem_vendor_specific.o \
lw_vendor_id_to_str.o \
@ -83,6 +82,8 @@ LWAPPOBJS = \
lw_cisco_id_to_str.o \
lw_put_sockaddr.o \
# lw_readelem_wtp_name.o \
lw_readelem_wtp_board_data.o \
# LWAPP cisco vendor specific objs
@ -95,20 +96,17 @@ LWAPPCISCOOBJS = \
CAPWAPOBJS= \
cwmsg_addelem_maximum_message_length.o \
cwmsg_addelem_image_identifier.o \
cwmsg_send.o \
wtpinfo.o \
aciplist.o \
acinfo.o \
acinfo_print.o \
lwmsg_init.o \
wtpinfo_lwreadelem_wtp_descriptor.o \
hdr_print.o \
cwmsg_addelem_vendor_cisco_mwar_addr.o \
lw_readelem_wtp_board_data.o \
cw_cisco_id_to_str.o\
cw_strlist_get_str.o \
cw_strlist_get_id.o \
capwap_strings_msg.o \
capwap_strings_elem80211.o\
acpriolist.o\
@ -122,9 +120,12 @@ CAPWAPOBJS= \
cw_in_check_disc_resp.o\
cw_in_check_join_req.o \
cw_in_check_join_resp.o \
cw_in_check_img_data_req.o \
cw_in_check_img_data_req_ac.o \
cw_in_check_img_data_req_wtp.o \
cw_in_check_img_data_resp.o \
cw_out_generic.o \
cw_out_ac_descriptor.o \
cw_out_wtp_descriptor.o \
cw_out_cisco_ac_descriptor.o \
cw_out_cisco_ap_timesync.o \
cw_in_cisco_image_identifier.o\
@ -137,12 +138,15 @@ CAPWAPOBJS= \
format.o \
#acinfo.o \
# cwsend_unknow_response.o \
cw_send_configuration_update_response.o \
cwsend_echo_request.o \
cwmsg_init_echo_request.o \
cwmsg_addelem.o \
cwmsg_vaddelem.o \
cw_log_str2dbglevel.o \
cwmsg_addelem_maximum_message_length.o \
cwmsg_addelem_ac_descriptor.o \
cwmsg_addelem_wtp_descriptor.o \
cwmsg_addelem_cw_local_ip_addr.o \
@ -157,6 +161,7 @@ cw_readelem_maximum_message_length.o \
cw_readelem_result_code.o\
cw_readelem_ac_name.o \
cw_readelem_ac_descriptor.o \
conn_detect_capwap.o \
cw_readelem_radio_administrative_state.o \
cw_readelem_radio_operational_state.o \
cw_readelem_statistics_timer.o \
@ -164,6 +169,7 @@ cw_readelem_maximum_message_length.o \
cw_readelem_vendor_specific_payload.o \
cw_readelem_capwap_local_ip_addr.o \
cw_readelem_wtp_reboot_statistics.o\
cwmsg_addelem_image_identifier.o \
conn_get_response.o \
# cwsend_change_state_event_response.o \
cwread_discovery_response.o \
@ -174,6 +180,7 @@ cw_readelem_maximum_message_length.o \
cwread_wtp_event_request.o \
process_conf_status_request.o \
cw_readelem_ecn_support.o \
conn_wait_for_message.o \
# wtpinfo_readelem_wtp_mac_type.o \
# wtpinfo_readelem_wtp_descriptor.o \
@ -251,7 +258,6 @@ endif
DTLSOBJS+=dtls_bio.o
CONNOBJS= conn_create.o \
conn_detect_capwap.o \
conn_send_packet.o \
conn_process_packet.o \
conn_q_add_packet.o \
@ -266,7 +272,6 @@ CONNOBJS= conn_create.o \
cw_prepare_configuration_status_request.o \
cw_prepare_change_state_event_request.o \
conn_prepare_request.o \
conn_wait_for_message.o \
conn_init.o \
conn_send_msg.o
#conn_get_message.o \
@ -288,6 +293,7 @@ CWACTION=action.o \
cw_in_generic.o \
cw_in_wtp_descriptor.o \
cw_out_wtp_board_data.o \
cw_out_image_data.o \
cipwap_actions_ac.o \
cipwap_strings_elem.o \
capwap_strings_result.o\
@ -311,7 +317,7 @@ O:=$(OBJS);
OBJS:=$(patsubst %.o,$(ARCH)/%.o,$(OBJS))
CFLAGS = -Wall -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include
CFLAGS = -Wall -O3 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I/usr/local/include
#CFLAGS = -Wall -O3 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I/usr/local/include
CFLAGS += $(GNUTLS_CFLAGS) \
-DWITH_CW_LOG \

View File

@ -137,11 +137,12 @@ static int cw_action_out_cmp(const void *elem1, const void *elem2)
*/
void *cw_actionlist_add(struct avltree *t, void *a, size_t s)
{
void *r = avltree_replace_data(t, a, sizeof(struct cw_action_in));
if (r)
return r;
void *an = malloc(sizeof(struct cw_action_in));
void *an = malloc(s);
if (!an)
return NULL;

View File

@ -78,7 +78,9 @@ struct cw_action_out{
struct cw_item *(*get)(struct conn *conn,struct cw_action_out *a);
uint8_t mand;
uint8_t itemtype;
void *defval;
int xopt;
};
@ -99,7 +101,7 @@ struct cw_actiondef{
cw_strheap_t strmsg;
cw_strheap_t strelem;
};

View File

@ -34,7 +34,7 @@
#include "conn.h"
#include "lwapp.h"
#include "strheap.h"
#include "strlist.h"
/* capwap version and iana number */
#define CW_VERSION 0
@ -86,7 +86,7 @@ enum capwap_states {
/**
* CAWAP header flags.
*/
*/
#define CW_FLAG_HDR_R1 0x01 /* bit 0 reserved 1 */
#define CW_FLAG_HDR_R2 0x02 /* bit 1 reserved 2 */
#define CW_FLAG_HDR_R3 0x04 /* bit 2 reserved 3 */
@ -478,15 +478,15 @@ extern int cw_readelem_vendor_specific_payload(void *data, int msgtype, int elem
14 Image Data Error (Invalid Checksum)
*/
#define CW_RESULT_IMAGE_DATA_IVALID_LENGTH 15 //Image Data Error (Invalid Data Length)
#define CW_RESULT_IMAGE_DATA_IVALID_LENGTH 15 //Image Data Error (Invalid Data Length)
#define CW_RESULT_IMAGE_DATA_OTHER_ERROR 16 //Image Data Error (Other Error)
#define CW_RESULT_IMAGE_DATA_ERROR 16 //Image Data Error (Other Error)
/*
17 Image Data Error (Image Already Present)
*/
#define CW_RESULT_MSG_INVALID_IN_CURRENT_STATE 18
#define CW_RESULT_MSG_UNRECOGNIZED 19
#define CW_RESULT_MSG_INVALID_IN_CURRENT_STATE 18
#define CW_RESULT_MSG_UNRECOGNIZED 19
#define CW_RESULT_MISSING_MAND_ELEM 20
/*
@ -571,36 +571,39 @@ extern int cw_readmsg_configuration_update_request(uint8_t * elems, int elems_le
* Set the HLEN field of a CAWAP Header
* @param th pointer to the header
* @param hlen velue to set (max. 5 bits)
*/
static inline void cw_set_hdr_hlen(uint8_t *th,int hlen){
*/
static inline void cw_set_hdr_hlen(uint8_t * th, int hlen)
{
uint32_t d = cw_get_dword(th);
d &= (0x1f << 19) ^ 0xffffffff;
d |= ((hlen) & 0x1f) <<19;
cw_set_dword(th,d);
d |= ((hlen) & 0x1f) << 19;
cw_set_dword(th, d);
}
/**
* Set the WBID field of a CAWAP Header
* @param th pointer to the header
* @param hlen velue to set (max. 5 bits)
*/
static inline void cw_set_hdr_wbid(uint8_t *th,int wbid){
*/
static inline void cw_set_hdr_wbid(uint8_t * th, int wbid)
{
uint32_t d = cw_get_dword(th);
d &= (0x1f << 9) ^ 0xffffffff;
d |= ((wbid) & 0x1f) <<9;
cw_set_dword(th,d);
d |= ((wbid) & 0x1f) << 9;
cw_set_dword(th, d);
}
/**
* Set the RID field of a CAWAP Header
* @param th pointer to the header
* @param hlen velue to set (max. 5 bits)
*/
static inline void cw_set_hdr_rid(uint8_t *th,int rid){
*/
static inline void cw_set_hdr_rid(uint8_t * th, int rid)
{
uint32_t d = cw_get_dword(th);
d &= (0x1f << 9) ^ 0xffffffff;
d |= ((rid) & 0x1f) <<14;
cw_set_dword(th,d);
d |= ((rid) & 0x1f) << 14;
cw_set_dword(th, d);
}
@ -641,7 +644,7 @@ static inline uint8_t *cw_get_hdr_msg_elems_ptr(uint8_t * m)
return cw_get_msg_elems_ptr(m + cw_get_hdr_msg_offset(m));
}
static inline uint8_t * cw_get_hdr_msg_ptr(uint8_t *rawmsg)
static inline uint8_t *cw_get_hdr_msg_ptr(uint8_t * rawmsg)
{
return rawmsg + cw_get_hdr_msg_offset(rawmsg);
}
@ -654,7 +657,7 @@ static inline int cw_get_hdr_msg_total_len(uint8_t * rawmsg)
{
int offset = cw_get_hdr_msg_offset(rawmsg);
return offset + cw_get_msg_elems_len(rawmsg + offset)+8 ;
return offset + cw_get_msg_elems_len(rawmsg + offset) + 8;
}
/**
@ -855,16 +858,23 @@ extern struct cw_str capwap_strings_result[];
#define cw_strresult(id) cw_strlist_get_str(capwap_strings_result,(id))
static inline const char * cw_strelemp_(cw_strheap_t h, int msg_id) {
const char * rc = cw_strheap_get(h,msg_id);
#define cw_strrc(rc) \
((rc)<0 ? ((rc)!=EAGAIN ? strerror(errno):"Timed out"): cw_strresult(rc))
static inline const char *cw_strelemp_(cw_strheap_t h, int msg_id)
{
const char *rc = cw_strheap_get(h, msg_id);
if (rc)
return rc;
return cw_strheap_get(h,CW_STR_STOP);
return cw_strheap_get(h, CW_STR_STOP);
}
#define cw_strelemp(p,id) cw_strelemp_((p)->strelem,id)
extern const char *cw_strlist_get_str(struct cw_str *s, int id);
@ -882,22 +892,27 @@ extern int cw_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, uint8
int len);
extern int cw_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len);
extern int cw_in_capwap_control_ipv4_address(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len);
extern int cw_in_capwap_control_ipv4_address(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len);
//extern int cw_out_generic(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len);
extern int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst); //, struct cw_item *item);
extern int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst); //, struct cw_item *item);
//extern int cw_out_ac_descriptor(struct conn *conn, uint32_t elem_id, uint8_t * dst,
//struct cw_item *item);
extern int cw_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst); //,struct cw_item * item)
extern int cw_out_ac_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst); //,struct cw_item * item)
extern int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a,
uint8_t * dst);
//extern int cw_out_capwap_control_ip_addrs(struct conn *conn, uint32_t elem_id,
// uint8_t * dst, struct cw_item *item);
// uint8_t * dst, struct cw_item *item);
extern int cw_out_capwap_control_ip_addr_list(struct conn *conn,struct cw_action_out *a,uint8_t *dst) ;
extern int cw_out_capwap_control_ip_addr_list(struct conn *conn, struct cw_action_out *a,
uint8_t * dst);
extern int cw_put_msg(struct conn *conn, uint8_t * rawout);
int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst); // ,struct cw_item * item)
struct cw_ac_status {
@ -918,23 +933,25 @@ struct cw_ac_status {
* This function is only useful (used) in conjunction with
* putting AC Descriptor message elements.
*/
static inline int cw_put_ac_status(uint8_t *dst, struct cw_ac_status *s){
uint8_t *d=dst;
static inline int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s)
{
uint8_t *d = dst;
d += cw_put_dword (d, (s->stations << 16) | (s->limit) );
d += cw_put_dword (d, (s->active_wtps <<16) | (s->max_wtps) );
d += cw_put_dword (d, (s->security<<24) | (s->rmac_field<<16) | (s->dtls_policy));
return d-dst;
d += cw_put_dword(d, (s->stations << 16) | (s->limit));
d += cw_put_dword(d, (s->active_wtps << 16) | (s->max_wtps));
d += cw_put_dword(d,
(s->security << 24) | (s->rmac_field << 16) | (s->dtls_policy));
return d - dst;
}
static inline int cw_put_version(uint8_t *dst,uint16_t subelem_id, uint8_t *v)
static inline int cw_put_version(uint8_t * dst, uint16_t subelem_id, uint8_t * v)
{
uint8_t *d=dst;
d += cw_put_dword(d,vendorstr_get_vendor_id(v));
d += cw_put_dword(d, (subelem_id<<16) | vendorstr_len(v));
d += cw_put_data(d,vendorstr_data(v),vendorstr_len(v));
return d-dst;
uint8_t *d = dst;
d += cw_put_dword(d, vendorstr_get_vendor_id(v));
d += cw_put_dword(d, (subelem_id << 16) | vendorstr_len(v));
d += cw_put_data(d, vendorstr_data(v), vendorstr_len(v));
return d - dst;
}
@ -944,53 +961,36 @@ int cw_register_actions_cipwap_ac(struct cw_actiondef *def);
int cw_register_actions_capwap_wtp(struct cw_actiondef *def);
int cw_in_set_state_none(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len);
int cw_in_set_state_none(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len);
struct cw_item *cw_out_get_outgoing(struct conn *conn, struct cw_action_out *a);
struct cw_item *cw_out_get_local(struct conn *conn, struct cw_action_out *a);
extern int cw_in_check_join_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len);
extern int cw_in_check_join_resp(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len);
extern int cw_in_check_disc_req(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len);
extern int cw_in_check_disc_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len);
int cw_in_check_disc_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len);
int cw_check_missing_mand(cw_action_in_t ** out, struct conn *conn, cw_action_in_t * a);
int cw_in_check_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len);
extern int cw_in_check_img_data_req_wtp(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len);
extern int cw_in_check_img_data_req_ac(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len);
int cw_in_check_img_data_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len);
int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_in_t *a);
int cw_in_check_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len);
int cw_in_check_img_data_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len);
int cw_out_wtp_board_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
int cw_out_wtp_board_data(struct conn *conn,struct cw_action_out * a,uint8_t *dst) ;
void cw_init_request(struct conn *conn,int msg_id);
struct cw_item * cw_out_get_session_id(struct conn *conn,struct cw_action_out * a);
void cw_init_request(struct conn *conn, int msg_id);
struct cw_item *cw_out_get_session_id(struct conn *conn, struct cw_action_out *a);
/**
* @defgroup TimerFunctions Timer functions
* @{
*/
/**
* Start a timer.
* @param t number of seconds until the timer expires
* @return timer value to initialize a variable of time_t
*
* Example: time_t timer = cw_timer_start(60);
*/
#define cw_timer_start(t) (time(NULL)+t)
/**
* Check if a timer is expired.
* @param t an time_t variable intializes by #cw_timer_start
* @return 0=timer is not expired\n 1=timer is expired.
*/
#define cw_timer_timeout(t) (time(NULL)>t ? 1 : 0)
/** @} */
int cw_send_request(struct conn *conn,int msg_id);
int cw_send_request(struct conn *conn, int msg_id);
#endif

View File

@ -37,15 +37,12 @@ struct cw_item *cw_out_get_local(struct conn *conn, struct cw_action_out *a)
struct cw_item * cw_out_get_session_id(struct conn *conn,struct cw_action_out * a)
{
printf("Vendor ID: %d\n", a->vendor_id);
uint8_t session_id[16];
int l = cw_rand(session_id,16);
if ( l!=16 ) {
cw_log(LOG_ERR,"Can't init session ID.");
return NULL;
}
return cw_itemstore_set_bstrn(conn->local,CW_ITEM_SESSION_ID,session_id,4);
return cw_itemstore_set_bstrn(conn->local,CW_ITEM_SESSION_ID,session_id,16);
}

View File

@ -127,13 +127,26 @@ cw_action_in_t capwap_actions_ac_in[] = {
/* Message: Image Data Request - in Config State */
{0, 0, CW_STATE_CONFIGURE, CW_MSG_IMAGE_DATA_REQUEST, 0,
0, cw_in_check_img_data_req}
0, cw_in_check_img_data_req_ac}
,
{0, 0, CW_STATE_CONFIGURE, CW_MSG_IMAGE_DATA_REQUEST,
CW_ACTION_IN_IMAGE_IDENTIFIER,
0}
,
/* ------------------------------------------------------------------------------- */
/* Message Image Data Response IN */
{0, 0, CW_STATE_IMAGE_DATA, CW_MSG_IMAGE_DATA_RESPONSE, 0,
0, cw_in_check_img_data_resp }
,
/* Element: Result Code */
{0, 0, CW_STATE_IMAGE_DATA, CW_MSG_IMAGE_DATA_RESPONSE,
CW_ACTION_IN_RESULT_CODE, 1}
,
@ -198,6 +211,21 @@ cw_action_out_t capwap_actions_ac_out[] = {
,
/* -------------------------------------------------------------------------------
* Image Data Request OUT
*/
{CW_MSG_IMAGE_DATA_REQUEST, CW_ITEM_NONE}
,
/* Image Data */
{CW_MSG_IMAGE_DATA_REQUEST, CW_ITEM_IMAGE_FILEHANDLE, 0,
CW_ELEM_IMAGE_DATA, NULL,cw_out_image_data, cw_out_get_outgoing,0}
,
/* End of list */
{0, 0}
@ -224,7 +252,6 @@ int cw_register_actions_capwap_ac(struct cw_actiondef *def)
rc += cw_strheap_register_strings(def->strelem, capwap_strings_elem);
printf("Registered %d strings\n", rc);
return 1;
}

View File

@ -68,6 +68,26 @@ cw_action_in_t capwap_actions_wtp_in[] = {
CW_ACTION_IN_RESULT_CODE, 1}
,
/* ------------------------------------------------------------------------------- */
/* Message Image Data Response */
{0, 0, CW_STATE_CONFIGURE, CW_MSG_IMAGE_DATA_RESPONSE, 0,
0, cw_in_check_img_data_resp }
,
/* Element: Result Code */
{0, 0, CW_STATE_CONFIGURE, CW_MSG_IMAGE_DATA_RESPONSE,
CW_ACTION_IN_RESULT_CODE, 1}
,
/* ------------------------------------------------------------------------------- */
/* Message Image Data Request */
{0, 0, CW_STATE_IMAGE_DATA, CW_MSG_IMAGE_DATA_REQUEST, 0,
0, cw_in_check_img_data_req_wtp }
,
@ -113,21 +133,60 @@ cw_action_out_t capwap_actions_wtp_out[] = {
/* WTP Board Data */
{CW_MSG_JOIN_REQUEST, CW_ITEM_WTP_BOARD_DATA, 0,
CW_ELEM_WTP_BOARD_DATA, NULL,cw_out_wtp_board_data, cw_out_get_outgoing}
CW_ELEM_WTP_BOARD_DATA, NULL,cw_out_wtp_board_data, cw_out_get_outgoing,1}
,
/* WTP Descriptor */
{CW_MSG_JOIN_REQUEST, CW_ITEM_WTP_DESCRIPTOR, 0,
CW_ELEM_WTP_DESCRIPTOR, NULL,cw_out_wtp_descriptor, NULL,1}
,
/* WTP Name */
{CW_MSG_JOIN_REQUEST, CW_ITEM_WTP_NAME, 0,
CW_ELEM_WTP_NAME, NULL,cw_out_generic, cw_out_get_local,1}
,
/* WTP MAC Type */
{CW_MSG_JOIN_REQUEST, CW_ITEM_WTP_MAC_TYPE, 0,
CW_ELEM_WTP_MAC_TYPE, NULL,cw_out_generic, cw_out_get_local,1}
,
/* WTP MAC Type */
{CW_MSG_JOIN_REQUEST, CW_ITEM_WTP_FRAME_TUNNEL_MODE, 0,
CW_ELEM_WTP_FRAME_TUNNEL_MODE, NULL,cw_out_generic, cw_out_get_local,1}
,
/* Session ID */
{CW_MSG_JOIN_REQUEST, CW_ITEM_SESSION_ID, 0,
CW_ELEM_SESSION_ID, NULL,cw_out_generic, cw_out_get_session_id,1}
,
/* -------------------------------------------------------------------------------
* Image Data Request OUT
*/
{CW_MSG_IMAGE_DATA_REQUEST, CW_ITEM_NONE}
,
/* Image Identifier */
{CW_MSG_IMAGE_DATA_REQUEST, CW_ITEM_IMAGE_IDENTIFIER, 0,
CW_ELEM_IMAGE_IDENTIFIER, NULL,cw_out_generic, cw_out_get_outgoing,0}
,
/* -------------------------------------------------------------------------------
* Image Data Response OUT
*/
{CW_MSG_IMAGE_DATA_RESPONSE, CW_ITEM_NONE}
,
/* Result Code */
{CW_MSG_IMAGE_DATA_RESPONSE, CW_ITEM_RESULT_CODE, 0,
CW_ELEM_RESULT_CODE, NULL,cw_out_generic, cw_out_get_outgoing, 1}
,
{0, 0}
};
@ -151,7 +210,6 @@ int cw_register_actions_capwap_wtp(struct cw_actiondef *def)
rc += cw_strheap_register_strings(def->strelem, capwap_strings_elem);
printf("Registered %d strings\n", rc);
return 1;
}

View File

@ -53,9 +53,10 @@ enum capwap_items {
/* Other Items */
CW_ITEM_AC_IMAGE_DIR, /* Path where WTP images are stored */
CW_ITEM_WTP_IMAGE_FILENAME, /* Full path of image filename */
CW_ITEM_IMAGE_FILENAME, /* Full path of image filename */
CW_ITEM_DISCOVERIES,
CW_ITEM_AC_PRIO_LIST /* AC Name with Priority list */
CW_ITEM_AC_PRIO_LIST, /* AC Name with Priority list */
CW_ITEM_IMAGE_FILEHANDLE /* FILE handle for uploading and downloading images */
};

View File

@ -6,6 +6,7 @@ struct cw_str capwap_strings_result[] = {
{CW_RESULT_SUCCESS,"Success"}, /* 0 */
{CW_RESULT_MISSING_AC_LIST,"AC List Message Element MUST be Present"}, /* 1 */
{CW_RESULT_SUCCESS_NAT,"Success - NAT Detected"}, /* 2 */
{CW_RESULT_IMAGE_DATA_ERROR,"Image Data Error (Unspecified)"}, /* 16 */
{CW_RESULT_MISSING_MAND_ELEM,"Missing Mandatory Message Element"}, /* 20 */
{CW_STR_STOP,"Unknown Result Code"}

View File

@ -5,6 +5,7 @@ struct cw_str capwap_strings_state[] = {
{ CW_STATE_JOIN,"Join" },
{ CW_STATE_RUN,"Run" },
{ CW_STATE_CONFIGURE,"Configure" },
{ CW_STR_STOP,"Undefined" }
{ CW_STATE_IMAGE_DATA,"Image Data" },
{ CW_STR_STOP,"Undefined" },
};

View File

@ -173,7 +173,8 @@ static int cw_process_msg(struct conn *conn, uint8_t * rawmsg, int len)
"Message type %d (%s) unexpected/illigal in %s State, discarding.",
as.msg_id, cw_strmsg(as.msg_id),
cw_strstate(conn->capwap_state));
return 0;
errno=EAGAIN;
return -1;
}
/* Request message not found in current state, check if we know
@ -339,65 +340,61 @@ static int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen,
//int conn_process_packet(struct conn *conn, uint8_t * packet, int len,
// int (*cb) (void *, uint8_t *, int), void *cbarg)
int conn_process_packet(struct conn *conn, uint8_t * packet, int len)
{
/* log this packet */
cw_dbg_pkt(DBG_PKT_IN,conn, packet, len);
if (len < 8) {
/* packet too short */
cw_dbg(DBG_CW_PKT_ERR,
cw_dbg(DBG_PKT_ERR,
"Discarding packet from %s, packet too short, len=%d",
sock_addr2str(&conn->addr), len);
return 0;
errno = EAGAIN;
return -1;
}
int preamble = cw_get_hdr_preamble(packet);
if ((preamble & 0xf0) != CW_VERSION) {
/* wrong version */
cw_dbg(DBG_CW_PKT_ERR,
cw_dbg(DBG_PKT_ERR,
"Discarding packet from %s, wrong version, version=%d",
sock_addr2str(&conn->addr), (preamble & 0xf0) >> 8);
return 0;
errno=EAGAIN;
return -1;
}
if (preamble & 0xf) {
/* decode dtls */
return 0;
/* dtls encoded, this shuold never happen here */
cw_dbg(DBG_PKT_ERR,
"Discarding packet from %s, encrypted data, after encryption ...",
sock_addr2str(&conn->addr));
errno = EAGAIN;
return -1;
}
/* log this packet */
cw_dbg_packet(conn, packet, len);
int offs = cw_get_hdr_msg_offset(packet);
int payloadlen = len - offs;
if (payloadlen < 0) {
cw_dbg(DBG_CW_PKT_ERR,
cw_dbg(DBG_PKT_ERR,
"Discarding packet from %s, header length greater than len, hlen=%d",
sock_addr2str(&conn->addr), offs);
/* EINVAL */
return 0;
}
/*
struct cwrmsg cwrmsg;
cwrmsg.wbid=(val>>9) & 0x1f;
cwrmsg.rid=(val>>14) & 0x1f;
*/
//printf ("Offs is %d RML is %d\n",offs,cw_get_hdr_rmac_len(packet));
/* Check Radio MAC if preset */
if (cw_get_hdr_flag_m(packet)) {
if (cw_get_hdr_rmac_len(packet) + 8 > offs) {
/* wrong rmac size */
cw_dbg(DBG_CW_PKT_ERR,
cw_dbg(DBG_PKT_ERR,
"Discarding packet, wrong R-MAC size, size=%d",
*(packet + 8));
return 0;
@ -415,7 +412,7 @@ int conn_process_packet(struct conn *conn, uint8_t * packet, int len)
if (f == NULL)
return 0;
cw_dbg_packet(conn, f + 4, *(uint32_t *) f);
// cw_dbg_packet(conn, f + 4, *(uint32_t *) f);
// extern int cw_process_msg(struct conn * conn,uint8_t*msg,int len);
@ -445,6 +442,9 @@ int conn_process_packet(struct conn *conn, uint8_t * packet, int len)
//}
//msg_4*((val >> 19) & 0x1f);
cw_dbg_msg(DBG_MSG_IN,conn,packet,len);
return process_message(conn, packet, len, NULL,NULL);
}
@ -462,7 +462,7 @@ int cw_read_messages(struct conn *conn)
return n;
if (n > 0) {
printf("Have a packet with %d bytes\n",n);
// printf("Have a packet with %d bytes\n",n);
return conn_process_packet(conn, buf, n);
}
//printf("DTLS_ERROR: %d\n",conn->dtls_error);

View File

@ -19,8 +19,9 @@
#include <stdlib.h>
#include <string.h>
#include "log.h"
#include "dbg.h"
#include "conn.h"
#include "sock.h"
void conn_q_add_packet(struct conn * conn,uint8_t *packet,int len)
@ -31,7 +32,8 @@ void conn_q_add_packet(struct conn * conn,uint8_t *packet,int len)
if (conn->qrpos==qwpos){
/* no buffers, discard packet */
cw_dbg(DBG_CW_PKT_ERR, "Discarding packet, no queue buffers left");
cw_dbg(DBG_PKT_ERR, "Discarding packe from %s, no queue buffers left",
sock_addr2str(&conn->addr));
return;
}

View File

@ -1,7 +1,7 @@
#include "conn.h"
#include "capwap.h"
#include "log.h"
#include "dbg.h"
#include "sock.h"
@ -10,7 +10,7 @@ int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
int packetlen = cw_get_hdr_msg_total_len(rawmsg);
uint8_t * msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg);
//uint8_t * msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg);
/* Zyxel doesn't count msg element length from
@ -34,12 +34,13 @@ int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
//XXX
{
char h[200];
hdr_print(h,ptr,mtu);
cw_dbg(DBG_CW_PKT_OUT,"Sending capwap packet to %s:\n%s",sock_addr2str(&conn->addr),h);
cw_dbg(DBG_PKT_OUT,"Sending capwap packet to %s:\n%s",sock_addr2str(&conn->addr),h);
}
cw_dbg_dmp(DBG_CW_PKT_DMP,ptr,mtu,"Sending packet ...");
cw_dbg_dmp(DBG_PKT_DMP,ptr,mtu,"Sending packet ...");
if (conn->write(conn,ptr,mtu)<0)
@ -86,12 +87,12 @@ int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
}
cw_dbg_dmp(DBG_CW_PKT_DMP,ptr,packetlen,"Sending packet ...");
cw_dbg_dmp(DBG_PKT_DMP,ptr,packetlen,"Sending packet ...");
//return conn->write(conn,ptr,msglen-fragoffset*8+hlen);
printf("Send packet len %p %d\n",ptr,packetlen);
//printf("Send packet len %p %d\n",ptr,packetlen);
return conn->write(conn,ptr,packetlen);
}

View File

@ -9,7 +9,7 @@ struct args {
struct avltree *mand;
int n;
};
/*
static int check_mand_cb(void *priv, void *val)
{
@ -47,7 +47,7 @@ return 1;
return 1;
}
*/
int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_in_t *a)
{

View File

@ -40,10 +40,11 @@ int cw_foreach_msgelem(uint8_t * msgelems, int len,
elen = val & 0xffff;
if (i + elen + 4 > len) {
/*
printf("***************************************************************************\n");
printf("Type: %d\n",type);
printf("Bumm %d %d\n",i+elen+4,len);
*/
return 0;
}

View File

@ -20,7 +20,7 @@ int cw_in_check_disc_req(struct conn *conn, struct cw_action_in *a, uint8_t * da
/* if mandatory elements are missing send no discovery response */
if (n) {
cw_dbg(DBG_CW_INFO,
cw_dbg(DBG_MSG_ERR,
"Ignoring Discovery Request from %s - missing mandatory elements.",
sock_addr2str(&conn->addr));
return -1;

View File

@ -13,12 +13,12 @@ int cw_in_check_disc_resp(struct conn *conn, struct cw_action_in *a, uint8_t * d
int n = cw_check_missing_mand(mlist, conn, a);
cw_dbg_missing_mand(DBG_ELEM, conn, mlist, n, a);
cw_dbg(DBG_CW_INFO,"This response came from: %s\n",sock_addr2str(&conn->addr));
//cw_dbg(DBG_INFO,"This response came from: %s",sock_addr2str(&conn->addr));
/* if mandatory elements are missing, ignore this response */
if (n) {
cw_dbg(DBG_CW_INFO,
cw_dbg(DBG_MSG_ERR,
"Ignoring Discovery Response from %s - missing mandatory elements.",
sock_addr2str(&conn->addr));
return -1;

View File

@ -7,7 +7,7 @@
#include "capwap_items.h"
int cw_in_check_img_data_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int cw_in_check_img_data_req_ac(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len)
{
/* Check for mandatory elements */
@ -25,11 +25,13 @@ int cw_in_check_img_data_req(struct conn *conn, struct cw_action_in *a, uint8_t
uint32_t vendor_id = vendorstr_get_vendor_id(i->data);
const char * image_dir;
//XXX image_dir = cw_itemstore_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR);
image_dir = cw_itemstore_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR);
if ( !image_dir )
image_dir="./img/"; //XXX
char * image_filename = malloc(6+vendorstr_len(i->data)+1+strlen(image_dir));
if (!image_filename)
return CW_RESULT_IMAGE_DATA_OTHER_ERROR;
return CW_RESULT_IMAGE_DATA_ERROR;
sprintf(image_filename,"%s%04X/%s",image_dir,vendor_id,vendorstr_data(i->data));
@ -39,21 +41,17 @@ int cw_in_check_img_data_req(struct conn *conn, struct cw_action_in *a, uint8_t
cw_log(LOG_WARNING,"Can't open image file: %s - %s - requestet by WTP",
image_filename,strerror(errno));
free(image_filename);
return CW_RESULT_IMAGE_DATA_OTHER_ERROR;
return CW_RESULT_IMAGE_DATA_ERROR;
}
cw_itemstore_set_str(conn->outgoing,CW_ITEM_WTP_IMAGE_FILENAME,image_filename);
cw_itemstore_set_str(conn->outgoing,CW_ITEM_IMAGE_FILENAME,image_filename);
cw_itemstore_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0);
conn->capwap_state=CW_STATE_IMAGE_DATA;
return 0;
}
/* set result code to ok and change to configure state */
// cw_itemstore_set_dword(conn->local,CW_ITEM_RESULT_CODE,0);
// conn->capwap_state = CW_STATE_CONFIGURE;
cw_itemstore_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0);
conn->capwap_state=CW_STATE_IMAGE_DATA;
return 0;
return CW_RESULT_IMAGE_DATA_ERROR;
}

View File

@ -9,8 +9,6 @@ int cw_in_check_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * da
int len)
{
printf("join req checker\n");
cw_action_in_t * mlist[60];
/* Check for mandatory elements */

View File

@ -1,6 +1,6 @@
#include "action.h"
#include "log.h"
#include "dbg.h"
#include "itemstore.h"
#include "capwap.h"

View File

@ -1,6 +1,6 @@
#include "action.h"
#include "log.h"
#include "dbg.h"
#include "itemstore.h"
#include "capwap.h"

View File

@ -1,5 +1,6 @@
#include "capwap.h"
#include "dbg.h"
#include "log.h"
#include "sock.h" //Tube
/**
@ -20,10 +21,10 @@ int cw_in_vendor_specific_payload(struct conn *conn,struct cw_action_in * a,uint
af = cw_actionlist_in_get(conn->actions->in,&as);
cw_dbg(DBG_ELEM,"From might be: %s\n",sock_addr2str(&conn->addr));
//cw_dbg(DBG_ELEM,"From might be: %s\n",sock_addr2str(&conn->addr));
if (!af) {
cw_log(DBG_ELEM,"Can't handle Vendor Specific Payload %s/%d, in msg %d (%s) in %s state.",
cw_dbg(DBG_ELEM,"Can't handle Vendor Specific Payload %s/%d, in msg %d (%s) in %s state.",
cw_strvendor(as.vendor_id),
as.elem_id,as.msg_id,cw_strmsg(as.msg_id),cw_strstate(as.capwap_state));
return 0;

View File

@ -29,7 +29,7 @@
#include "itemstore.h"
#include "cw_util.h"
#include "log.h"
#include "dbg.h"

View File

@ -23,7 +23,7 @@
#include "wtpinfo.h"
#include "cw_util.h"
#include "log.h"
#include "dbg.h"
@ -43,7 +43,7 @@ static int readelem_wtp_descriptor(struct conn *conn, struct cw_action_in *a, ui
int i;
if (ncrypt == 0 ){
/* non-conform */
cw_dbg(DBG_CW_RFC,"Non-standard-conform WTP descriptor detected (See RFC 5415)");
cw_dbg(DBG_RFC,"Non-standard-conform WTP descriptor detected (See RFC 5415)");
if (!cq)
i=3;
else
@ -102,7 +102,7 @@ int cw_in_wtp_descriptor(struct conn *conn,struct cw_action_in * a,uint8_t *data
{
int rc =readelem_wtp_descriptor(conn, a,data,len,0);
if (rc==-1){
cw_dbg(DBG_CW_RFC,"Bad WTP descriptor, trying cisco hack");
cw_dbg(DBG_RFC,"Bad WTP descriptor, trying cisco hack");
rc =readelem_wtp_descriptor(conn, a,data,len,1);
}

View File

@ -34,10 +34,7 @@
#include "cw_util.h"
int cw_dbg_opt_detail = 0;
int cw_dbg_opt_level = 0;
#include "dbg.h"
int cw_log_debug_level = 0;
@ -56,7 +53,7 @@ void cw_log_dbg_(int level, const char *file, int line, const char *format, ...)
vsprintf(buf, format, args);
va_end(args);
if (cw_dbg_opt_detail & DBG_DETAIL_LINE_NUMBERS)
if (cw_dbg_opt_display & DBG_DISP_LINE_NUMBERS)
cw_log(LOG_DEBUG, "%s:%d: %s", file, line, buf);
else
cw_log(LOG_DEBUG, buf);

View File

@ -36,12 +36,11 @@ int cw_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst
i = cw_itemstore_get(conn->outgoing,CW_ITEM_AC_HARDWARE_VERSION);
if ( i ) {
d += cw_put_version(d,CW_SUBELEM_AC_HARDWARE_VERSION,i->data);
}
else {
cw_dbg(DBG_ELEM_ERR, "Can't send hard version in AC descriptor, not set.");
cw_log(LOG_ERR, "Can't send hard version in AC descriptor, not set.");
}
@ -51,7 +50,7 @@ int cw_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst
d += cw_put_version(d,CW_SUBELEM_AC_SOFTWARE_VERSION,i->data);
}
else {
cw_dbg(DBG_ELEM_ERR, "Can't send software version in AC descriptor, not set.");
cw_log(LOG_ERR, "Can't send software version in AC descriptor, not set.");
}
int len = d-dst-4;

View File

@ -27,7 +27,7 @@ int cw_out_cisco_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_
d += cw_put_version(d,1,i->data);
}
else {
cw_dbg(DBG_ELEM_ERR, "Can't send software version in AC descriptor, not set.");
cw_log(LOG_ERR, "Can't set Software Version in AC descriptor, No value defined.");
}
int len = d-dst-4;

View File

@ -4,6 +4,7 @@
#include "capwap.h"
#include "capwap_items.h"
#include "dbg.h"
#include "log.h"
@ -19,8 +20,17 @@ int cw_put_item(uint8_t * dst, struct cw_item *item)
case CW_ITEMTYPE_DWORD:
return cw_put_dword(dst, item->dword);
case CW_ITEMTYPE_BSTR:
return cw_put_bstr(dst,item->data);
return cw_put_bstr(dst, item->data);
case CW_ITEMTYPE_VENDORSTR:
{
int l=0;
l+=cw_put_dword(dst, vendorstr_get_vendor_id(item->data));
l+=cw_put_data(dst+4, vendorstr_data(item->data),vendorstr_len(item->data));
return l;
}
default:
cw_log(LOG_ERR,"No method to put items of type %d",item->type);
}
return 0;
@ -45,8 +55,17 @@ int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst) //
int len;
if (!item) {
if (a->mand) {
cw_log(LOG_ERR, "Error: Cannot send mandatory message element %d - (%s)",
a->elem_id, cw_strelemp(conn->actions, a->elem_id));
cw_log(LOG_ERR,
"Can't put mandatory element %d - (%s) into %s. No value found.",
a->elem_id, cw_strelemp(conn->actions, a->elem_id)
, cw_strmsg(a->msg_id)
);
}
else{
cw_dbg(DBG_ELEM,"No output for elemnt %d -(%s) in %s. Item %d not found.",
a->elem_id, cw_strelemp(conn->actions, a->elem_id)
, cw_strmsg(a->msg_id),a->item_id);
}
return 0;
} else {

View File

@ -64,7 +64,7 @@ int cw_out_wtp_board_data(struct conn *conn, struct cw_action_out *a, uint8_t *
d += cw_put_data(d, bstr_data(i->data), bstr_len(i->data));
}
int l = d - dst;
return l + cw_put_elem_hdr(dst, CW_ELEM_WTP_BOARD_DATA, l - 4);
int l = d - dst-4;
return l + cw_put_elem_hdr(dst, CW_ELEM_WTP_BOARD_DATA, l );
}

View File

@ -26,6 +26,7 @@
#include "conn.h"
#include "log.h"
#include "dbg.h"
/**
@ -66,21 +67,37 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
int len = 0;
while(NULL != (ae=avliter_next(&i))) {
printf("Put %d %d\n",ae->msg_id,ae->elem_id);
//printf("Put %d %d\n",ae->msg_id,ae->elem_id);
if (ae->msg_id != as.msg_id) {
/* Element is from next msg, close action */
break;
}
if (ae->out) {
len += ae->out(conn, ae, dst+len);
int l=0;
l= ae->out(conn, ae, dst+len);
len +=l;
// cw_dbg_elem_colored(DBG_ELEM, conn, ae->msg_id, ae->elem_id,
// dst+len-l,l);
}
//cw_dbg_elem_colored(DBG_ELEM,"Adding element %d to msg %d, len = %d",ae->msg_id,ae->elem_id,l);
};
cw_set_msg_elems_len(msgptr, len);
if (as.msg_id) {
/* It's a request, so we have to set seqnum */
int s = conn_get_next_seqnum(conn);
cw_set_msg_seqnum(msgptr,s);
// printf("Set seqnum to : %d\n",s);
}
return len;
}

View File

@ -38,7 +38,7 @@
* Send an image file to an AP
*
*/
void cw_send_image_file(struct conn *conn, FILE *infile)
void cw_send_image_file(struct conn *conn)
{
/*
@ -53,8 +53,14 @@ void cw_send_image_file(struct conn *conn, FILE *infile)
cw_log(LOG_INFO, "Sending image file %s to %s", filename, sock_addr2str(&conn->addr));
*/
struct cwrmsg *cwrmsg;
uint8_t buffer[1024]; /* buffer MUST be 1024 */
struct cwimage_data data;
memset(&data,0,sizeof(struct cwimage_data));
data.data = buffer;
@ -82,8 +88,8 @@ void cw_send_image_file(struct conn *conn, FILE *infile)
bl++;
conn_prepare_image_data_request(conn, &data, 0);
cwrmsg = conn_send_request(conn);
// conn_prepare_image_data_request(conn, &data, 0);
// cwrmsg = conn_send_request(conn);
if (!cwrmsg) {
cw_log(LOG_ERR,"Error sneding image file to %s",sock_addr2str(&conn->addr));

View File

@ -1,4 +1,5 @@
#include "capwap.h"
#include "strlist.h"
const char * cw_strlist_get_str(struct cw_str *s,int id)
{

View File

@ -23,6 +23,7 @@
#include "log.h"
#include "capwap.h"
/*
void cw_mand_elem_found(int *l,int type)
{
if (!cw_dbg_is_level(DBG_CW_RFC))
@ -37,7 +38,9 @@ void cw_mand_elem_found(int *l,int type)
}
}
*/
/*
void cw_get_missing_mand_elems(char *dst, int *l)
{
if (!cw_dbg_is_level(DBG_CW_RFC))
@ -54,6 +57,7 @@ void cw_get_missing_mand_elems(char *dst, int *l)
}
}
*/
/*
int cw_is_missing_mand_elems(int *l)

View File

@ -21,31 +21,133 @@
#include "sock.h"
#include "log.h"
#include "strlist.h"
#include "format.h"
#include "capwap.h"
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 = 0;
uint32_t cw_dbg_opt_level = 0;
/**
* Put a list of missing mandatory message elements to debug output
*/
void cw_dbg_missing_mand(int level,struct conn *conn,cw_action_in_t ** ml,int n,cw_action_in_t *a)
void cw_dbg_missing_mand(int level, struct conn *conn, cw_action_in_t ** ml, int n,
cw_action_in_t * a)
{
if (!cw_dbg_is_level(DBG_ELEM) || n==0)
if (!cw_dbg_is_level(DBG_ELEM) || n == 0)
return;
char buffer[2000];
char *p=buffer;
char *p = buffer;
int i;
char *delim="";
for(i=0; i<n; i++) {
p+=sprintf(p,"%s",delim); delim=", ";
p+=sprintf(p,"%s",cw_strelemp(conn->actions,ml[i]->elem_id));
char *delim = "";
for (i = 0; i < n; i++) {
p += sprintf(p, "%s", delim);
delim = ", ";
p += sprintf(p, "%s", cw_strelemp(conn->actions, ml[i]->elem_id));
}
cw_dbg(DBG_ELEM,"Missing mandatory elements: [%s]",buffer);
cw_dbg(DBG_ELEM, "Missing mandatory elements: [%s]", buffer);
}
int cw_format_pkt(char *dst,int level,struct conn *conn, uint8_t * packet, int len)
{
char *s=dst;
switch (level) {
case DBG_PKT_IN:
s+=sprintf(s,"From %s",sock_addr2str(&conn->addr));
break;
case DBG_PKT_OUT:
s+=sprintf(s,"To %s",sock_addr2str(&conn->addr));
break;
}
s+=sprintf(s," l=%d: ",len);
int preamble = cw_get_hdr_preamble(packet);
if (preamble==01){
s+=sprintf(s," (encrypted)");
return s-dst;
}
if (len<4)
goto abort;
if (cw_get_hdr_flag_f(packet)){
s+=sprintf(s," (fragmented)");
}
int hlen = cw_get_hdr_hlen(packet);
int rid = cw_get_hdr_rid(packet);
int wbid = cw_get_hdr_wbid(packet);
s+=sprintf(s," H:%d R:%02d W:%02d",hlen,rid,wbid);
s+=sprintf(s," Flgs:");
s+=cw_format_hdr_flags(s,packet);
if (len<8)
goto abort;
int frag_id = cw_get_hdr_fragid(packet);
int frag_offs = cw_get_hdr_fragoffset(packet);
s+=sprintf(s," Frag/Offs: %d/%d",frag_id,frag_offs);
return s-dst;
abort:
s+=sprintf(s," Incomplete...");
return s-dst;
}
void cw_dbg_pkt(int level,struct conn *conn, uint8_t * packet, int len)
{
if (!cw_dbg_is_level(level))
return;
char buf[1024];
cw_format_pkt(buf,level,conn,packet,len);
cw_dbg(level,"%s",buf);
}
void cw_dbg_msg(int level,struct conn *conn, uint8_t * packet, int len)
{
if (!cw_dbg_is_level(level))
return;
char buf[1024];
char *s = buf;
uint8_t * msgptr = cw_get_hdr_msg_ptr(packet);
int pplen = len - (msgptr-packet);
int msg_id=cw_get_msg_id(msgptr);
s+=sprintf(s,"%s Message type %d",cw_strmsg(msg_id),msg_id);
s+=sprintf(s,"from %s ",sock_addr2str(&conn->addr));
s+=sprintf(s,", Seqnum: %d ElemLen: %d",cw_get_msg_seqnum(msgptr),cw_get_msg_elems_len(msgptr));
abort:
cw_dbg(level,"%s",buf);
}
void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len)
void cw_dbg_packet_m(struct conn *conn, uint8_t * packet, int len)
{
if (!cw_dbg_is_level(DBG_CW_PKT_IN || DBG_CW_PKT_OUT))
if (!cw_dbg_is_level(DBG_PKT_IN | DBG_PKT_OUT))
return;
@ -54,24 +156,24 @@ void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len)
hdr_print(hdr, packet, len);
if (!cw_dbg_is_level(DBG_CW_PKT_DMP)) {
cw_dbg(DBG_CW_PKT_IN, "Processing capwap packet from %s, len=%d\n%s",
if (!cw_dbg_is_level(DBG_PKT_DMP)) {
cw_dbg(DBG_PKT_IN, "Processing capwap packet from %s, len=%d\n%s",
sock_addr2str(&conn->addr), len, hdr);
return;
}
cw_dbg_dmp(DBG_CW_PKT_DMP, packet, len,
cw_dbg_dmp(DBG_PKT_DMP, packet, len,
"Processing packet from %s, len=%d\n%s\n\tDump:",
sock_addr2str(&conn->addr), len, hdr);
}
void cw_log_dbg_dmp_(int level, const char *file, int line,
void cw_dbg_dmp_(int level, const char *file, int line,
const uint8_t * data, int len, const char *format, ...)
{
return;
if (!(level & cw_dbg_opt_level))
return;
@ -83,14 +185,14 @@ void cw_log_dbg_dmp_(int level, const char *file, int line,
int tlen = 0;
int md;
if (cw_dbg_opt_detail & DBG_DETAIL_ASC_DMP)
if (cw_dbg_opt_display & DBG_DISP_ASC_DMP)
md = 2;
else
md = 1;
char *dst = malloc(md * (len * 3 + (rows * 2) + 8 + maxtlen));
char *dst = malloc(2*(md * (len * 3 + (rows * 2) + 8 + maxtlen)));
if (!dst)
return;
@ -118,7 +220,7 @@ void cw_log_dbg_dmp_(int level, const char *file, int line,
for (i = 0; i < len; i++) {
sprintf(pdst, "%02X ", data[i] & 0xff);
if (cw_dbg_opt_detail & DBG_DETAIL_ASC_DMP) {
if (cw_dbg_opt_display & DBG_DISP_ASC_DMP) {
int c = data[i] & 0xff;
if (c < 0x20 || c > 0x80)
c = '.';
@ -129,7 +231,7 @@ void cw_log_dbg_dmp_(int level, const char *file, int line,
pdst += 3;
if ((i + 1) % rowlen == 0) {
int l;
if (cw_dbg_opt_detail & DBG_DETAIL_ASC_DMP) {
if (cw_dbg_opt_display & DBG_DISP_ASC_DMP) {
*ascdst = 0;
l = sprintf(pdst, " | %s\n\t", asc_buffer);
ascdst = asc_buffer;
@ -142,17 +244,18 @@ void cw_log_dbg_dmp_(int level, const char *file, int line,
}
if (cw_dbg_opt_detail & DBG_DETAIL_ASC_DMP) {
if (cw_dbg_opt_display & DBG_DISP_ASC_DMP) {
*ascdst = 0;
if (strlen(asc_buffer))
pdst += sprintf(pdst, " | %s", asc_buffer);
}
if (cw_dbg_opt_detail & DBG_DETAIL_LINE_NUMBERS)
cw_log(LOG_DEBUG, "%s:%d: %s", file, line, dst);
else
cw_log(LOG_DEBUG, dst);
if (cw_dbg_opt_display & DBG_DISP_LINE_NUMBERS)
cw_log_cb(LOG_DEBUG, "%s:%d: %s", file, line, dst);
else{
cw_log_cb(LOG_DEBUG, "%s",dst);
}
free(dst);
return;
@ -160,3 +263,166 @@ void cw_log_dbg_dmp_(int level, const char *file, int line,
/**
* print debug info for message elements
*/
void cw_dbg_elem_colored(int level, struct conn *conn, int msg, int msgelem,
const uint8_t * msgbuf, int len)
{
if (!cw_dbg_is_level(level))
return;
const char *elemname;
char vendorname[256];
char vendor_details[265];
*vendor_details = 0;
if (msgelem == CW_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
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 *) lw_vendor_id_to_str(vendor_id), vendor_details);
elemname = vendorname;
} else {
elemname = cw_strelemp(conn->actions, msgelem);
}
if (!cw_dbg_is_level(DBG_ELEM_DMP))
cw_dbg(DBG_ELEM,
"%s, CAWPAP element: %d (%s), len=%d%s",
cw_strmsg(msg), msgelem, elemname, len, "");
else
cw_dbg_dmp(DBG_ELEM, msgbuf, len,
"%s, CAPWAP element: %d (%s), len=%d%s\n\tDump ...",
cw_strmsg(msg), msgelem, elemname, len, "");
}
static struct cw_str color_on[] = {
{ DBG_PKT_IN, "\x1b[33m" },
{ CW_STR_STOP, "" }
};
static struct cw_str color_ontext[] = {
{ CW_STR_STOP, "" }
};
static struct cw_str color_off[] = {
{ CW_STR_STOP, "\033[22;39m" }
};
static struct cw_str prefix[] = {
{ DBG_INFO, " Info -" },
{ DBG_PKT_IN, " Pkt IN -" },
{ CW_STR_STOP, "" }
};
static const char * get_dbg_color_on(int level){
if ( ! (cw_dbg_opt_display & DBG_DISP_COLORS ) )
return "";
return cw_strlist_get_str(color_on,level);
}
static const char * get_dbg_color_off(int level){
if ( ! (cw_dbg_opt_display & DBG_DISP_COLORS ) )
return "";
return cw_strlist_get_str(color_off,level);
}
static const char * get_dbg_prefix(int level){
return cw_strlist_get_str(prefix,level);
}
static const char * get_dbg_color_ontext(int level){
if ( ! (cw_dbg_opt_display & DBG_DISP_COLORS ) )
return "";
return cw_strlist_get_str(color_ontext,level);
}
/*
void cw_log_colored(int level, const char *format, ...)
{
char fbuf[1024];
sprintf(fbuf, "%s%s%s: %s%s",
get_log_color_on(level),
get_log_prefix(level),
get_log_color_ontext(level),
format,
get_log_color_off(level)
);
va_list args;
va_start(args, format);
cw_log_vcb(level,fbuf,args);
va_end(args);
}
*/
void cw_dbg_colored(int level, const char *file, int line, const char *format, ...)
{
if (!(level & cw_dbg_opt_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_list args;
va_start(args, format);
cw_log_vcb(level,fbuf,args);
va_end(args);
return;
char buf[2048];
// va_list args;
va_start(args, format);
vsprintf(buf, format, args);
va_end(args);
if (cw_dbg_opt_display & DBG_DISP_LINE_NUMBERS)
cw_log(LOG_DEBUG, "%s:%d: %s", file, line, buf);
else
cw_log(LOG_DEBUG, buf);
}

View File

@ -30,18 +30,82 @@ void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len);
#endif
/**
* @defgroup DebugOptions Dbug Options
* @{
*/
#define CW_DBG_PKT_IN 0x00000001 /* Headers of incoming CAPWAP packets */
#define CW_DBG_PKT_OUT 0x00000002 /* Headers of outgoing CAPWAP packets */
#define DBG_PKT_IN 0x00000001 /* Headers of incoming CAPWAP packets */
#define DBG_PKT_OUT 0x00000002 /* Headers of outgoing CAPWAP packets */
#define DBG_PKT_ERR 0x00000004 /* Error of packets */
#define DBG_PKT_DMP 0x00000008 /* Dump packts */
#define DBG_MSG_IN 0x00000010 /* Parsed CAPWAP/LWAPP messages */
#define DBG_MSG_OUT 0x00000020 /* Parsed CAPWAP/LWAPP messages */
#define DBG_ELEM 0x00000000 /* Show message elements */
#define DBG_ELEM_DMP 0x00000000 /* Dump message elements */
#define DBG_INFO 0x00000000
#define DBG_RFC 0x00000080 /* RCF-realted CAPWAP errors */
#define DBG_MSG_ERR 0x00000000 /* Errors in CAPWAP messages */
#define DBG_ELEM_ERR 0x00000000
/* driver specific debugs */
#define DBG_DRV 0x00010000
#define DBG_DRV_ERR 0x00020000
/* DTLS debugs */
#define DBG_DTLS 0x10000000
#define DBG_DTLS_DETAIL 0x20000000
#define DBG_DTLS_BIO 0x40000000
#define DBG_DTLS_BIO_DMP 0x80000000
#define DBG_ALL 0xffffffff
#define DBG_PKT_INOUT (DBG_CW_PKT_IN | DBG_CW_PKT_OUT)
#define DBG_DISP_LINE_NUMBERS 0x00000001
#define DBG_DISP_ASC_DMP 0x00000002
#define DBG_DISP_COLORS 0x00000004
#define DBG_DETAIL_ALL 0xffffffff
#define DBG_ERR (DBG_MSG_ERR | DBG_CW_PKT_ERR)
/**@}*/
extern uint32_t cw_dbg_opt_display;
extern uint32_t cw_dbg_opt_level;
extern struct cw_str cw_dbg_strings[];
/**@}*/
#define cw_dbg(type,...) cw_dbg_colored(type,__FILE__,__LINE__,__VA_ARGS__)
#define cw_dbg_dmp(type,...) cw_dbg_dmp_(type,__FILE__,__LINE__,__VA_ARGS__)
void cw_dbg_colored(int level, const char *file, int line, const char *format, ...);
void cw_dbg_dmp_(int level, const char *file, int line,
const uint8_t * data, int len, const char *format, ...);
extern void cw_dbg_elem_colored(int level, struct conn *conn, int msg, int msgelem,
const uint8_t * msgbuf, int len);
void cw_dbg_pkt(int level,struct conn *conn, uint8_t * packet, int len);
void cw_dbg_msg(int level,struct conn *conn, uint8_t * packet, int len);

View File

@ -19,9 +19,21 @@
#include <string.h>
#include "log.h"
#include "dbg.h"
struct cw_str cw_dbg_strings[] = {
{ DBG_INFO, "info" },
{ DBG_PKT_IN, "pkt_in" },
{ DBG_PKT_OUT, "pkt_out" },
{ CW_STR_STOP, NULL }
};
/*
struct cw_dbg_cfgstrs cw_dbg_cfgstrs[] = {
{"info",DBG_CW_INFO},
@ -50,7 +62,9 @@ struct cw_dbg_cfgstrs cw_dbg_cfgstrs[] = {
{0,0}
};
*/
/*
int cw_log_str2dbglevel(const char * str)
{
int i;
@ -60,4 +74,4 @@ int cw_log_str2dbglevel(const char * str)
}
return 0;
}
*/

View File

@ -25,6 +25,7 @@
#include <arpa/inet.h>
#include "log.h"
#include "dbg.h"
#include "dtls.h"

View File

@ -25,11 +25,13 @@
#include "conn.h"
#include "log.h"
#include "dbg.h"
#include "cw_util.h"
#include "timer.h"
int dtls_gnutls_init()
{
cw_dbg(DBG_CW_INFO,"Init SSL library - using GnuTLS %s",gnutls_check_version(NULL));
cw_dbg(DBG_INFO,"Init SSL library - using GnuTLS %s",gnutls_check_version(NULL));
gnutls_global_init();
return 1;
}

View File

@ -25,10 +25,12 @@
#include "conn.h"
#include "dbg.h"
#include "log.h"
#include "sock.h"
#include "capwap.h"
#include "dtls_gnutls.h"
#include "timer.h"
int dtls_gnutls_accept(struct conn *conn)

View File

@ -24,6 +24,7 @@
#include "dtls.h"
#include "dtls_gnutls.h"
#include "capwap.h"
#include "timer.h"

View File

@ -7,6 +7,7 @@
#include "conn.h"
#include "log.h"
#include "dbg.h"

View File

@ -23,9 +23,13 @@
#include "dtls_openssl.h"
#include "capwap.h"
#include "dbg.h"
#include "log.h"
#include "cw_util.h"
#include "rand.h"
#include "conn.h"
#include "sock.h"
@ -120,7 +124,7 @@ int pem_passwd_cb(char *buf, int size, int rwflag, void *password)
int dtls_openssl_init()
{
const char * version = SSLeay_version(SSLEAY_VERSION);
cw_dbg(DBG_CW_INFO,"Init SSL library - %s",version);
cw_dbg(DBG_INFO,"Init SSL library - %s",version);
SSL_load_error_strings();
int rc = SSL_library_init();
return rc;

View File

@ -5,6 +5,7 @@
#include "conn.h"
#include "log.h"
#include "dbg.h"
BIO_METHOD *dtls_openssl_bio_method()

View File

@ -2,7 +2,9 @@
#include "dtls_openssl.h"
#include "log.h"
#include "dbg.h"
#include "cw_util.h"
#include "timer.h"
/*
static BIO_METHOD bio_methods = {

View File

@ -54,3 +54,8 @@ int cw_format_hex_bytes(char *dst, const char *format, const char *delim,
}
return d - dst;
}

View File

@ -55,4 +55,30 @@ extern int cw_format_hex_bytes(char *dst, const char *format, const char *delim,
/*#define cw_format_hdr_flags(s,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;
s+=sprintf(s,"%s", "(");
s+=sprintf(s,"%s", cw_get_hdr_flag_t(th) ? "T":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_f(th) ? "F":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_l(th) ? "L":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_w(th) ? "W":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_m(th) ? "M":"");
s+=sprintf(s,"%s", cw_get_hdr_flag_k(th) ? "K":"");
s+=sprintf(s,"%s", ")");
return s-dst;
}
#endif

View File

@ -58,10 +58,8 @@ int hdr_print(char *str, uint8_t *packet, int len)
int hlen = cw_get_hdr_hlen(packet); //CWTH_GET_HLEN(packet);
int rid = cw_get_hdr_rid(packet);
int wbid = cw_get_hdr_wbid(packet);
s+=sprintf(s,"\tHLEN: %d, RID: %02X, WBID %02X",hlen,rid,wbid);

View File

@ -71,6 +71,7 @@ static inline struct cw_item *cw_itemstore_get(cw_itemstore_t s, uint32_t id)
extern cw_itemstore_t cw_itemstore_create();
extern int cw_itemstore_set_const_ptr(cw_itemstore_t s, uint32_t id, void *ptr);
extern int cw_itemstore_set_strn(cw_itemstore_t s, uint32_t id, const char *str, int n);
extern int cw_itemstore_set_str(cw_itemstore_t s, uint32_t id, const char *str);
extern int cw_itemstore_set_ptr(cw_itemstore_t s, uint32_t id, void *ptr);

View File

@ -45,61 +45,12 @@
/**
* @defgroup DebugOptions Dbug Options
* @{
*/
#define DBG_MSG 0x00000001 /* Parsed CAPWAP/LWAPP messages */
#define DBG_ELEM 0x00000002 /* Parsed CAPWAP/LWAPP message elements */
#define DBG_ELEM_DMP 0x00000004 /* Dump CAPWAP message elements */
#define DBG_CW_INFO 0x00000008
#define DBG_CW_RFC 0x00000010 /* RCF-realted CAPWAP errors */
#define DBG_CW_STRICT 0x00000010
#define DBG_CW_PKT_IN 0x00000020 /* Headers of incoming CAPWAP packets */
#define DBG_CW_PKT_OUT 0x00000040 /* Headers of outgoing CAPWAP packets */
#define DBG_CW_PKT_DMP 0x00000080 /* Dump packts */
#define DBG_CW_PKT_DTL 0x00000100
#define DBG_CW_PKT_ERR 0x00000200
#define DBG_MSG_ERR 0x00000400 /* Errors in CAPWAP messages */
#define DBG_CW_IMG_DTL 0x00000800 /* Detail about image transfer */
#define DBG_ELEM_ERR 0x00001000
/* driver specific debugs */
#define DBG_DRV 0x00010000
#define DBG_DRV_ERR 0x00020000
/* DTLS debugs */
#define DBG_DTLS 0x10000000
#define DBG_DTLS_DETAIL 0x20000000
#define DBG_DTLS_BIO 0x40000000
#define DBG_DTLS_BIO_DMP 0x80000000
#define DBG_ALL 0xffffffff
#define DBG_CW_PKT_INOUT (DBG_CW_PKT_IN | DBG_CW_PKT_OUT)
#define DBG_DETAIL_LINE_NUMBERS 0x00000001
#define DBG_DETAIL_ASC_DMP 0x00000002
#define DBG_DETAIL_ALL 0xffffffff
#define DBG_ERR (DBG_MSG_ERR | DBG_CW_PKT_ERR)
/**@}*/
extern void cw_log_dbg_(int type, const char *file, int line, const char *fromat, ...);
extern void cw_log_dbg_dmp_(int type, const char *file, int line, const uint8_t * data,
int len, const char *format, ...);
extern int cw_dbg_opt_detail;
extern int cw_dbg_opt_level;
//extern void cw_log_dbg_(int type, const char *file, int line, const char *fromat, ...);
//extern void cw_log_dbg_dmp_(int type, const char *file, int line, const uint8_t * data,
//int len, const char *format, ...);
#define cw_dbg_is_level(level) (cw_dbg_opt_level & level)
@ -111,28 +62,31 @@ extern int cw_dbg_opt_level;
#define cw_log(...)
#endif
#ifdef WITH_CW_LOG_DEBUG
//#ifdef WITH_CW_LOG_DEBUG
#define cw_log_dbg(type,...) cw_log_dbg_(type,__FILE__,__LINE__,__VA_ARGS__)
#define cw_dbg(type,...) cw_log_dbg_(type,__FILE__,__LINE__,__VA_ARGS__)
#define cw_log_dbg_dmp(type,str,len,...) cw_log_dbg_dmp_(type,__FILE__,__LINE__,str,len,__VA_ARGS__)
#define cw_dbg_dmp(type,str,len,...) cw_log_dbg_dmp_(type,__FILE__,__LINE__,str,len,__VA_ARGS__)
#define cw_dbg_msgelem(msgtype,msgelemtype,msgbuf,msglen) cw_dbg_msgelem_(msgtype,msgelemtype,msgbuf,msglen)
#define cw_dbg_missing_mand_elems(conn, msgtyoe, mand) cw_dbg_missing_mand_elems_(conn, msgtyoe, mand)
//#define cw_log_dbg(type,...) cw_log_dbg_(type,__FILE__,__LINE__,__VA_ARGS__)
#define lw_dbg_elem(msgtype,msgelemtype,msgbuf,msglen) lw_dbg_elem_(msgtype,msgelemtype,msgbuf,msglen)
#else
#define cw_log_dbg(...)
#define cw_dbg(...)
#define cw_dbg_missing_mand_elems(conn, msgtyoe, mand)
//#define cw_log_dbg_dmp(type,str,len,...) cw_log_dbg_dmp_(type,__FILE__,__LINE__,str,len,__VA_ARGS__)
//#define cw_dbg_dmp(type,str,len,...) cw_log_dbg_dmp_(type,__FILE__,__LINE__,str,len,__VA_ARGS__)
#endif
//#define cw_dbg_msgelem(msgtype,msgelemtype,msgbuf,msglen) cw_dbg_msgelem_(msgtype,msgelemtype,msgbuf,msglen)
//#define cw_dbg_missing_mand_elems(conn, msgtyoe, mand) cw_dbg_missing_mand_elems_(conn, msgtyoe, mand)
//#define lw_dbg_elem(msgtype,msgelemtype,msgbuf,msglen) lw_dbg_elem_(msgtype,msgelemtype,msgbuf,msglen)
//#else
//#define cw_log_dbg(...)
//#define cw_dbg(...)
//#define cw_dbg_missing_mand_elems(conn, msgtyoe, mand)
//#endif
extern void (*cw_log_cb) (int level, const char *fromat, ...);
extern void (*cw_vlog_cb) (int level, const char *fromat, va_list args);
extern void (*cw_log_vcb) (int level, const char *fromat, va_list args);
/* Syslog functins */
extern void cw_log_syslog(int level, const char *format, ...);

View File

@ -10,21 +10,8 @@ char * cw_log_filename = NULL;
void cw_log_vfile(int level,const char * format, va_list args)
{
/* switch(level){
case LOG_DEBUG:
printf("DBG:");
break;
case LOG_INFO:
printf("INFO:");
break;
case LOG_ERR:
printf("ERROR:");
break;
}
*/
vprintf(format,args);
printf("\n");
}
void cw_log_file(int level,const char *format, ...)

View File

@ -4,6 +4,7 @@
#include "capwap.h"
#include "log.h"
#include "sock.h"
#include "timer.h"
int cw_send_request(struct conn *conn,int msg_id)
{
@ -18,6 +19,9 @@ int cw_send_request(struct conn *conn,int msg_id)
int i;
int rc=-1;
for (i=0; i<conn->max_retransmit && rc<0; i++){
if ( i>0 ){
cw_log(LOG_WARNING,"Retransmitting request ... %d",i);
}
time_t timer = cw_timer_start(conn->retransmit_interval);
while (!cw_timer_timeout(timer) && rc<0){
@ -36,9 +40,13 @@ int cw_send_request(struct conn *conn,int msg_id)
}
if ( rc <0 ) {
if ( rc <0 && errno != EAGAIN) {
cw_log(LOG_ERR,"Error reading from %s:%s",sock_addr2str(&conn->addr),strerror(errno));
}
if ( rc <0 && errno == EAGAIN) {
errno=ETIMEDOUT;
rc=-1;
}
return rc;
}

View File

@ -3,17 +3,12 @@
#include <stdint.h>
#include "strlist.h"
#include "avltree.h"
typedef struct avltree * cw_strheap_t;
struct cw_str {
int id;
const char *str;
};
#define CW_STR_STOP -1138
extern cw_strheap_t cw_strheap_create();
extern int cw_strheap_register_strings(cw_strheap_t h, struct cw_str *s);