From cd59b647cd04f0eb25231106b9ba775dbee804ac Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Sun, 12 Apr 2015 08:19:02 +0000 Subject: [PATCH] Colored debugging, some code cleaning. FossilOrigin-Name: 23a60b9297d5719fa502b2163680fa1af8bc0201cb777771dc30de045f84b341 --- src/ac/ac_interface.c | 10 +- src/ac/ac_main.c | 4 + src/ac/conf.c | 4 +- src/ac/wtpman.c | 18 +- src/capwap/Makefile | 4 +- src/capwap/action.h | 19 +- src/capwap/avltree.h | 10 +- src/capwap/capwap.h | 25 +- src/capwap/capwap_actions_ac.c | 6 +- src/capwap/conn_create.c | 15 +- src/capwap/conn_process_packet.c | 2 +- src/capwap/conn_send_msg.c | 4 +- src/capwap/cw_dbg_elem.c | 3 +- src/capwap/cw_in_check_img_data_req_wtp.c | 2 + src/capwap/cw_in_cisco_image_identifier.c | 1 + src/capwap/cw_in_vendor_specific_payload.c | 2 +- src/capwap/cw_in_wtp_board_data.c | 4 +- src/capwap/cw_in_wtp_descriptor.c | 2 +- src/capwap/cw_log_debug.c | 32 +- src/capwap/cw_out_ac_descriptor.c | 6 +- .../cw_out_capwap_control_ip_addr_list.c | 2 +- src/capwap/cw_out_cisco_ac_descriptor.c | 4 +- src/capwap/cw_out_generic.c | 2 +- src/capwap/cw_out_image_data.c | 5 +- src/capwap/dbg.c | 312 +++++++++++------- src/capwap/dbg.h | 98 ++++-- src/capwap/dbg_strings.c | 6 + src/capwap/dtls_bio.c | 6 +- src/capwap/dtls_gnutls.c | 2 + src/capwap/log.h | 1 - src/capwap/lw_put_ac_descriptor.c | 9 +- src/capwap/lwapp.h | 4 +- src/capwap/timer.h | 24 +- src/wtp/conf_uci.c | 5 +- src/wtp/wtp_conf.c | 2 +- src/wtp/wtp_conf.h | 2 +- src/wtp/wtp_main.c | 2 +- 37 files changed, 420 insertions(+), 239 deletions(-) diff --git a/src/ac/ac_interface.c b/src/ac/ac_interface.c index 48911635..e087f9c3 100644 --- a/src/ac/ac_interface.c +++ b/src/ac/ac_interface.c @@ -7,7 +7,6 @@ #include "capwap/sock.h" #include "socklist.h" -#include "capwap/acinfo.h" #include "conf.h" #include "capwap/capwap.h" @@ -25,6 +24,7 @@ struct radioinfo * get_radioinfo() } +/* struct ac_info * get_acinfo() { @@ -40,7 +40,7 @@ struct ac_info * get_acinfo() acinfo->limit=10000; acinfo->active_wtps=10; acinfo->max_wtps=conf_max_wtps; - acinfo->rmac=1; /* radio mac supported */ + acinfo->rmac=1; acinfo->vendor_id=conf_vendor_id; @@ -68,9 +68,11 @@ struct ac_info * get_acinfo() //acinfo->aciplist=get_aciplist(); -/* + aciplist_foreach(acinfo->aciplist,pr,NULL); */ + +/* int i; for (i=1; i<=4; i++){ acinfo->radioinfos[i].type= @@ -87,7 +89,7 @@ struct ac_info * get_acinfo() } - +*/ get_join_result() { diff --git a/src/ac/ac_main.c b/src/ac/ac_main.c index 21cadd30..ae0f8d23 100644 --- a/src/ac/ac_main.c +++ b/src/ac/ac_main.c @@ -106,6 +106,8 @@ int readelem_cisco_rad_name(struct conn *conn,struct cw_action * a,uint8_t *data int main (int argc, const char * argv[]) { + + /* intavltree_t t = intavltree_create(); int i; @@ -171,6 +173,7 @@ int main (int argc, const char * argv[]) goto errX; +printf("Debug oprtions: %08X\n",cw_dbg_opt_level); rc = ac_run(); errX: wtplist_destroy(); @@ -328,6 +331,7 @@ void process_cw_ctrl_packet(int index,struct sockaddr * addr, uint8_t * buffer, wtpman = wtpman_create(index,addr); + if (!wtpman ){ cw_log(LOG_ERR,"Error creating wtpman: %s",strerror(errno)); wtplist_unlock(); diff --git a/src/ac/conf.c b/src/ac/conf.c index 98ee4cc8..e9ba4c55 100644 --- a/src/ac/conf.c +++ b/src/ac/conf.c @@ -557,7 +557,9 @@ static int conf_read_dbg_level(cfg_t *cfg) for (i=0; iconn->addr)); cwsend_unknown_response(p->conn, p->conn->cwrmsg.seqnum, p->conn->cwrmsg.type); return 1; } +*/ - +/* struct ac_info *get_acinfo(); +*/ static void wtpman_remove(struct wtpman *wtpman) { @@ -120,7 +122,8 @@ static void wtpman_run_discovery(void *arg) */ - wtpman->conn->outgoing = ac_config; + wtpman->conn->local = ac_config; + wtpman->conn->outgoing = cw_itemstore_create(); wtpman->conn->incomming = cw_itemstore_create(); while (!cw_timer_timeout(timer) @@ -131,7 +134,7 @@ static void wtpman_run_discovery(void *arg) struct cw_item *wn = cw_itemstore_get(wtpman->conn->incomming, CW_ITEM_WTP_NAME); if (wn) { - printf("WTP Name: %s\n", wn->data); + //printf("WTP Name: %s\n", wn->data); } wtpman_remove(wtpman); @@ -284,9 +287,10 @@ static int wtpman_join(void *arg, time_t timer) // wtpman->conn->itemstore = cw_itemstore_create(); - wtpman->conn->outgoing = ac_config; + wtpman->conn->outgoing = cw_itemstore_create(); wtpman->conn->incomming = cw_itemstore_create(); - wtpman->conn->local = cw_itemstore_create(); + wtpman->conn->local = ac_config; + struct conn * conn = wtpman->conn; @@ -439,7 +443,7 @@ static void wtpman_run(void *arg) if (rc) { - cw_log(LOG_ERR,"Image download RC: %s",cw_strrc(rc)); + cw_log(LOG_ERR,"Error sending image to %s: %s",sock_addr2str(&conn->addr),cw_strrc(rc)); } else { cw_dbg(DBG_INFO,"Image '%s' sucessful sent to %s in %0.1f seconds.", diff --git a/src/capwap/Makefile b/src/capwap/Makefile index b98b1875..baaeacad 100644 --- a/src/capwap/Makefile +++ b/src/capwap/Makefile @@ -96,10 +96,8 @@ LWAPPCISCOOBJS = \ CAPWAPOBJS= \ - cwmsg_send.o \ wtpinfo.o \ aciplist.o \ - acinfo_print.o \ lwmsg_init.o \ wtpinfo_lwreadelem_wtp_descriptor.o \ hdr_print.o \ @@ -142,11 +140,13 @@ CAPWAPOBJS= \ # cwsend_unknow_response.o \ cw_send_configuration_update_response.o \ cwsend_echo_request.o \ + acinfo_print.o \ cwmsg_init_echo_request.o \ cwmsg_addelem.o \ cwmsg_vaddelem.o \ cw_log_str2dbglevel.o \ cwmsg_addelem_maximum_message_length.o \ + # cwmsg_send.o \ cwmsg_addelem_ac_descriptor.o \ cwmsg_addelem_wtp_descriptor.o \ cwmsg_addelem_cw_local_ip_addr.o \ diff --git a/src/capwap/action.h b/src/capwap/action.h index f36d11f2..6c972baf 100644 --- a/src/capwap/action.h +++ b/src/capwap/action.h @@ -26,6 +26,7 @@ #include "conn.h" #include "itemstore.h" #include "strheap.h" +#include "intavltree.h" /* Generic functions and structs */ @@ -92,16 +93,32 @@ extern cw_action_out_t * cw_actionlist_out_add(cw_actionlist_out_t t, struct cw_ extern int cw_actionlist_out_register_actions(cw_actionlist_out_t t,cw_action_out_t * actions); #define cw_actionlist_out_get(t,a) avltree_get(t,a); +/** + * Definition CAPWAP modes + */ +enum capwapmodes { + /** Standard mode as specified in RFC 5415 */ + CWMODE_STD = 0, + /** Cisco specific CAPWAP */ + CWMODE_CISCO, + /** CIPWAP, a mix of standard CAPWAP and some + Cisco extension */ + CWMODE_CIPWAP, + /** Zyxel */ + CWMODE_ZYXEL +}; + struct cw_actiondef{ cw_actionlist_in_t in; cw_actionlist_out_t out; - cw_strheap_t strmsg; cw_strheap_t strelem; + /** Supported Wireless Binding IDs (WBID) */ + struct avltree * wbids; }; diff --git a/src/capwap/avltree.h b/src/capwap/avltree.h index 68dab140..420face4 100644 --- a/src/capwap/avltree.h +++ b/src/capwap/avltree.h @@ -40,7 +40,15 @@ * Defines the structure of an AVL Node. */ struct avlnode { - void *data; + union { + void *data; + uint8_t ubyte; + uint16_t uword; + uint32_t udword; + int8_t byte; + int16_t word; + int32_t dword; + }; struct avlnode *left; struct avlnode *right; int bal; diff --git a/src/capwap/capwap.h b/src/capwap/capwap.h index f3eca5b4..67bed5ef 100644 --- a/src/capwap/capwap.h +++ b/src/capwap/capwap.h @@ -46,16 +46,6 @@ #define CAPWAP_CONTROL_PORT_STR "5246" -/** - * CAPWAP modes - */ -enum capwapmodes { - CWMODE_STD = 0, - CWMODE_CISCO, - CWMODE_CIPWAP, - CWMODE_ZYXEL -}; - /** * CAWAP States @@ -275,7 +265,7 @@ struct capwap_ctrlhdr #include "wtpinfo.h" -#include "acinfo.h" +//#include "acinfo.h" /* Frame tunnnel mode bits */ #define WTP_FRAME_TUNNEL_MODE_R 1 /* Reserved */ @@ -364,11 +354,12 @@ struct cwimage_identifier{ - +/* extern void cwmsg_addelem_wtp_descriptor(struct cwmsg *cwmsg, struct wtpinfo *wtpinfo); extern void cwmsg_addelem_ctrl_ip_addrs(struct cwmsg *msg, struct ac_info *acinfo); extern void cwmsg_addelem_wtp_board_data(struct cwmsg *cwmsg, struct wtpinfo *wtpinfo); extern void cwmsg_addelem_cw_local_ip_addr(struct cwmsg *msg, struct conn *conn); +*/ //extern void cwmsg_addelem_wtp_radio_infos(struct cwmsg * cwmsg,struct wtpinfo * wtpinfo); extern void cwmsg_addelem_wtp_radio_infos(struct cwmsg *msg, @@ -387,6 +378,8 @@ extern void cwmsg_addelem_vendor_specific_payload(struct cwmsg *msg, int vendor_ //void cwsend_discovery_response(struct conn * conn,int seqnum, struct radioinfo * radioinfo, struct ac_info * acinfo, struct wtpinfo * wtpinfo); // + +/* extern void cwsend_discovery_response(struct conn *conn, int seqnum, struct radioinfo *radioinfo, struct ac_info *acinfo, struct wtpinfo *wtpinfo); @@ -396,11 +389,13 @@ extern void cwsend_join_response(struct conn *conn, int seqnum, int rc, struct radioinfo *radioinfo, struct ac_info *acinfo, struct wtpinfo *wtpinfo); +*/ //extern void cwread_discovery_request(struct wtpinfo *wtpinfo, uint8_t * msg, int len); extern void process_join_request(struct wtpinfo *wtpinfo, uint8_t * msg, int len); extern void process_conf_status_request(struct wtpinfo *wtpinfo, uint8_t * msg, int len); +/* extern void cwread_discovery_response(struct ac_info *acinfo, uint8_t * msg, int len); extern void cwsend_image_data_response(struct conn *conn, int seqnum, int rc); extern int cwsend_image_data_request(struct conn *conn, struct cwimage_data *data, @@ -418,7 +413,7 @@ extern void cwsend_conf_status_response(struct conn *conn, int seqnum, int rc, extern void cwsend_unknown_response(struct conn *conn, int seqnum, int unknow_request); - +*/ extern int hdr_print(char *str, uint8_t * packet, int len); @@ -500,8 +495,8 @@ extern int cw_readelem_vendor_specific_payload(void *data, int msgtype, int elem extern void cw_read_image_data_request(struct cwimage_data *, uint8_t * msg, int len); -extern int cw_readelem_ac_descriptor(struct ac_info *acinfo, int type, uint8_t * msgelem, - int len); +//extern int cw_readelem_ac_descriptor(struct ac_info *acinfo, int type, uint8_t * msgelem, +// int len); extern int cw_readelem_capwap_local_ip_addr(struct sockaddr *local_ip, int type, uint8_t * msgelem, int len); diff --git a/src/capwap/capwap_actions_ac.c b/src/capwap/capwap_actions_ac.c index 8858368d..2e49830d 100644 --- a/src/capwap/capwap_actions_ac.c +++ b/src/capwap/capwap_actions_ac.c @@ -166,7 +166,7 @@ cw_action_out_t capwap_actions_ac_out[] = { /* AC Name */ {CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_AC_NAME, 0, - CW_ELEM_AC_NAME, NULL, cw_out_generic, cw_out_get_outgoing} + CW_ELEM_AC_NAME, NULL, cw_out_generic, cw_out_get_local} , /* List of CAPWAP Control IPv4 and IPv6 addresses */ @@ -243,6 +243,7 @@ int cw_register_actions_capwap_ac(struct cw_actiondef *def) def->out = cw_actionlist_out_create(); def->strmsg = cw_strheap_create(); def->strelem = cw_strheap_create(); + def->wbids = intavltree_create(); cw_actionlist_in_register_actions(def->in, capwap_actions_ac_in); cw_actionlist_out_register_actions(def->out, capwap_actions_ac_out); @@ -250,6 +251,9 @@ int cw_register_actions_capwap_ac(struct cw_actiondef *def) int rc; rc = cw_strheap_register_strings(def->strmsg, capwap_strings_msg); rc += cw_strheap_register_strings(def->strelem, capwap_strings_elem); + + + intavltree_add(defs->wbids,0); diff --git a/src/capwap/conn_create.c b/src/capwap/conn_create.c index d37d13cf..3a12afe7 100644 --- a/src/capwap/conn_create.c +++ b/src/capwap/conn_create.c @@ -31,19 +31,6 @@ #include "capwap.h" -/* -void conn_init(struct conn * conn) -{ - memset(conn,0,sizeof(struct conn)); - conn->retransmit_interval=CAPWAP_RETRANSMIT_INTERVAL; - conn->max_retransmit=CAPWAP_MAX_RETRANSMIT; - conn->wait_dtls=CAPWAP_WAIT_DTLS; - conn->wait_join=CAPWAP_WAIT_JOIN; - conn->mtu_discovery=1; -} -*/ - - /** * Create a conn object * @param socket a socket @@ -83,7 +70,7 @@ struct conn * conn_create(int sock, struct sockaddr * addr, int qsize) } conn->qrpos=-1; if (sem_init(&conn->q_sem,0,0)!=0){ - cw_log(LOG_ERR,"sem_init %s",strerror(errno)); + cw_log(LOG_ERR,"Fatal- Can't init semaphore for conn object: %s",strerror(errno)); conn_destroy(conn); return NULL; }; diff --git a/src/capwap/conn_process_packet.c b/src/capwap/conn_process_packet.c index 2f9fe1c4..ca11b088 100644 --- a/src/capwap/conn_process_packet.c +++ b/src/capwap/conn_process_packet.c @@ -217,7 +217,7 @@ static int cw_process_msg(struct conn *conn, uint8_t * rawmsg, int len) as.elem_id = cw_get_elem_id(elem); int elem_len = cw_get_elem_len(elem); - cw_dbg_elem(conn, as.msg_id, as.elem_id, cw_get_elem_data(elem), + cw_dbg_elem(DBG_ELEM,conn, as.msg_id, as.elem_id, cw_get_elem_data(elem), elem_len); diff --git a/src/capwap/conn_send_msg.c b/src/capwap/conn_send_msg.c index 22802a2c..9e6dce11 100644 --- a/src/capwap/conn_send_msg.c +++ b/src/capwap/conn_send_msg.c @@ -40,7 +40,7 @@ int conn_send_msg(struct conn * conn, uint8_t *rawmsg) hdr_print(h,ptr,mtu); cw_dbg(DBG_PKT_OUT,"Sending capwap packet to %s:\n%s",sock_addr2str(&conn->addr),h); } - cw_dbg_dmp(DBG_PKT_DMP,ptr,mtu,"Sending packet ..."); +// cw_dbg_dmp(DBG_PKT_DMP,ptr,mtu,"Sending packet ..."); if (conn->write(conn,ptr,mtu)<0) @@ -87,7 +87,7 @@ int conn_send_msg(struct conn * conn, uint8_t *rawmsg) } - cw_dbg_dmp(DBG_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); diff --git a/src/capwap/cw_dbg_elem.c b/src/capwap/cw_dbg_elem.c index 74d4a4a7..131b60ca 100644 --- a/src/capwap/cw_dbg_elem.c +++ b/src/capwap/cw_dbg_elem.c @@ -42,6 +42,7 @@ static int cw_format_vendor(char *dst, uint32_t vendor_id, int elem_id, const ui * print debug info for message elements */ +/* void cw_dbg_elem_(struct conn * conn, int msg, int msgelem, const uint8_t * msgbuf, int len) { if (!cw_dbg_is_level(DBG_ELEM)) @@ -77,4 +78,4 @@ void cw_dbg_elem_(struct conn * conn, int msg, int msgelem, const uint8_t * msgb cw_strmsg(msg), msgelem, elemname, len, ""); } - +*/ diff --git a/src/capwap/cw_in_check_img_data_req_wtp.c b/src/capwap/cw_in_check_img_data_req_wtp.c index b753572e..2c6a2934 100644 --- a/src/capwap/cw_in_check_img_data_req_wtp.c +++ b/src/capwap/cw_in_check_img_data_req_wtp.c @@ -6,6 +6,7 @@ #include "log.h" #include "capwap_items.h" +#include //Tube int cw_in_check_img_data_req_wtp(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len) @@ -13,6 +14,7 @@ int cw_in_check_img_data_req_wtp(struct conn *conn, struct cw_action_in *a, uint cw_itemstore_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0); conn->capwap_state=CW_STATE_IMAGE_DATA; +//usleep(100000); return 0; return CW_RESULT_IMAGE_DATA_ERROR; diff --git a/src/capwap/cw_in_cisco_image_identifier.c b/src/capwap/cw_in_cisco_image_identifier.c index b055bbd8..d1a1dda9 100644 --- a/src/capwap/cw_in_cisco_image_identifier.c +++ b/src/capwap/cw_in_cisco_image_identifier.c @@ -23,6 +23,7 @@ int cw_in_cisco_image_identifier(struct conn *conn,struct cw_action_in * a,uint8 case 0: dstart=4; len-=4; + break; default: vendor_id=CW_VENDOR_ID_CISCO; dstart=0; diff --git a/src/capwap/cw_in_vendor_specific_payload.c b/src/capwap/cw_in_vendor_specific_payload.c index ff38c6bf..c3295b83 100644 --- a/src/capwap/cw_in_vendor_specific_payload.c +++ b/src/capwap/cw_in_vendor_specific_payload.c @@ -24,7 +24,7 @@ int cw_in_vendor_specific_payload(struct conn *conn,struct cw_action_in * a,uint //cw_dbg(DBG_ELEM,"From might be: %s\n",sock_addr2str(&conn->addr)); if (!af) { - cw_dbg(DBG_ELEM,"Can't handle Vendor Specific Payload %s/%d, in msg %d (%s) in %s state.", + cw_dbg(DBG_SUBELEM,"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; diff --git a/src/capwap/cw_in_wtp_board_data.c b/src/capwap/cw_in_wtp_board_data.c index f5ef673d..a75fa48a 100644 --- a/src/capwap/cw_in_wtp_board_data.c +++ b/src/capwap/cw_in_wtp_board_data.c @@ -45,12 +45,12 @@ static void readsubelems_wtp_board_data(cw_itemstore_t itemstore, uint8_t * msge int sublen = val & 0xffff; i += 4; if (sublen + i > len) { - cw_dbg(DBG_ELEM, "WTP Board data sub-element too long, type=%d,len=%d", + cw_dbg(DBG_ELEM_ERR, "WTP Board data sub-element too long, type=%d,len=%d", subtype, sublen); return; } - cw_dbg(DBG_ELEM, "Reading WTP board data sub-element, type=%d, len=%d", subtype, + cw_dbg(DBG_SUBELEM, "Reading WTP board data sub-element, type=%d, len=%d", subtype, sublen); switch (subtype) { diff --git a/src/capwap/cw_in_wtp_descriptor.c b/src/capwap/cw_in_wtp_descriptor.c index 7489aab0..167cf732 100644 --- a/src/capwap/cw_in_wtp_descriptor.c +++ b/src/capwap/cw_in_wtp_descriptor.c @@ -72,7 +72,7 @@ static int readelem_wtp_descriptor(struct conn *conn, struct cw_action_in *a, ui return -1; } - cw_dbg(DBG_ELEM,"Reading WTP descriptor subelement, type=%d,len=%d",subtype,sublen); + cw_dbg(DBG_SUBELEM,"Reading WTP descriptor subelement, type=%d,len=%d",subtype,sublen); switch(subtype){ case CW_SUBELEM_WTP_HARDWARE_VERSION: diff --git a/src/capwap/cw_log_debug.c b/src/capwap/cw_log_debug.c index 0eb03f9a..9dd363de 100644 --- a/src/capwap/cw_log_debug.c +++ b/src/capwap/cw_log_debug.c @@ -39,7 +39,7 @@ int cw_log_debug_level = 0; - +/* void cw_log_dbg_(int level, const char *file, int line, const char *format, ...) { @@ -58,7 +58,7 @@ void cw_log_dbg_(int level, const char *file, int line, const char *format, ...) else cw_log(LOG_DEBUG, buf); } - +*/ @@ -76,25 +76,27 @@ void cw_log_dbg_(int level, const char *file, int line, const char *format, ...) -int cw_format_vendor(char *dst, uint32_t vendor_id, int elem_id, const uint8_t * elem_data) +int cw_format_vendor(char *dst, uint32_t vendor_id, int elem_id, + const uint8_t * elem_data) { switch (vendor_id) { case CW_VENDOR_ID_CISCO: { - sprintf(dst, "\n\t Cisco Vendor Specific: %d - %s", elem_id, - cw_cisco_id_to_str(elem_id)); + if (elem_id != CW_CISCO_SPAM_VENDOR_SPECIFIC) { + return sprintf(dst, "%d - %s", elem_id, + cw_cisco_id_to_str(elem_id)); + } + /* dive into LWAPP vendor specific decoding */ - if (elem_id == CW_CISCO_SPAM_VENDOR_SPECIFIC) { - uint32_t lw_elem_id = lw_get_word(elem_data + 4 + 6); - char b[256]; - sprintf(b, "\n\t LWAPP Cisco Specific: %d - %s", - lw_elem_id, lw_cisco_id_to_str(lw_elem_id)); - strcat(dst, b); + uint32_t lw_elem_id = lw_get_word(elem_data + 4 + 6); + return sprintf(dst, "%d/LWAPP Vendor: %d - %s", + elem_id, + lw_elem_id, + lw_cisco_id_to_str(lw_elem_id)); - } break; } @@ -111,6 +113,7 @@ int cw_format_vendor(char *dst, uint32_t vendor_id, int elem_id, const uint8_t * * print debug info for message elements */ +/* void cw_dbg_msgelem_(int msg, int msgelem, const uint8_t * msgbuf, int len) { if (!cw_dbg_is_level(DBG_ELEM)) @@ -145,8 +148,9 @@ void cw_dbg_msgelem_(int msg, int msgelem, const uint8_t * msgbuf, int len) "%s, CAPWAP element: type=%d (%s), len=%d%s\n\tDump ...", cw_strmsg(msg), msgelem, elemname, len, vendor_details); } +*/ - +/* void lw_dbg_elem_(int msg_id, int elem_id, const uint8_t * elem_data, int elem_len) { if (!cw_dbg_is_level(DBG_ELEM)) @@ -179,4 +183,4 @@ void lw_dbg_elem_(int msg_id, int elem_id, const uint8_t * elem_data, int elem_l } - +*/ diff --git a/src/capwap/cw_out_ac_descriptor.c b/src/capwap/cw_out_ac_descriptor.c index 5b6ad966..de09437e 100644 --- a/src/capwap/cw_out_ac_descriptor.c +++ b/src/capwap/cw_out_ac_descriptor.c @@ -24,7 +24,7 @@ int cw_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst uint8_t *d = dst+4; struct cw_item * i; - i = cw_itemstore_get(conn->outgoing,CW_ITEM_AC_STATUS); + i = cw_itemstore_get(conn->local,CW_ITEM_AC_STATUS); if (!i) { cw_log(LOG_ERR,"Can't send AC Descriptor, no AC Status Item found"); @@ -35,7 +35,7 @@ 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); + i = cw_itemstore_get(conn->local,CW_ITEM_AC_HARDWARE_VERSION); if ( i ) { d += cw_put_version(d,CW_SUBELEM_AC_HARDWARE_VERSION,i->data); } @@ -44,7 +44,7 @@ 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_SOFTWARE_VERSION); + i = cw_itemstore_get(conn->local,CW_ITEM_AC_SOFTWARE_VERSION); if ( i ) { d += cw_put_version(d,CW_SUBELEM_AC_SOFTWARE_VERSION,i->data); diff --git a/src/capwap/cw_out_capwap_control_ip_addr_list.c b/src/capwap/cw_out_capwap_control_ip_addr_list.c index 0d78e909..1933bf53 100644 --- a/src/capwap/cw_out_capwap_control_ip_addr_list.c +++ b/src/capwap/cw_out_capwap_control_ip_addr_list.c @@ -43,7 +43,7 @@ static int put_ip(void *priv, void *data) int cw_out_capwap_control_ip_addr_list(struct conn *conn,struct cw_action_out *a,uint8_t *dst) { - struct cw_item * item = cw_itemstore_get(conn->outgoing,a->item_id); + struct cw_item * item = cw_itemstore_get(conn->local,a->item_id); if ( !item ) { cw_log(LOG_ERR, "Can't send CAPWAP Local IPv4/IPv6 Address, not found"); diff --git a/src/capwap/cw_out_cisco_ac_descriptor.c b/src/capwap/cw_out_cisco_ac_descriptor.c index fc5cb8e5..26f03663 100644 --- a/src/capwap/cw_out_cisco_ac_descriptor.c +++ b/src/capwap/cw_out_cisco_ac_descriptor.c @@ -11,7 +11,7 @@ int cw_out_cisco_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_ uint8_t *d = dst+4; struct cw_item * i; - i = cw_itemstore_get(conn->outgoing,CW_ITEM_AC_STATUS); + i = cw_itemstore_get(conn->local,CW_ITEM_AC_STATUS); if (!i) { cw_log(LOG_ERR,"Can't send AC Descriptor, no AC Status Item found"); @@ -21,7 +21,7 @@ int cw_out_cisco_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_ d+=cw_put_ac_status(d ,(struct cw_ac_status*)(i->data)); - i = cw_itemstore_get(conn->outgoing,CW_ITEM_AC_SOFTWARE_VERSION); + i = cw_itemstore_get(conn->local,CW_ITEM_AC_SOFTWARE_VERSION); if ( i ) { d += cw_put_version(d,1,i->data); diff --git a/src/capwap/cw_out_generic.c b/src/capwap/cw_out_generic.c index a79e130f..5fc10f45 100644 --- a/src/capwap/cw_out_generic.c +++ b/src/capwap/cw_out_generic.c @@ -62,7 +62,7 @@ int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst) // ); } else{ - cw_dbg(DBG_ELEM,"No output for elemnt %d -(%s) in %s. Item %d not found.", + cw_dbg(DBG_ELEM,"No output for element %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); diff --git a/src/capwap/cw_out_image_data.c b/src/capwap/cw_out_image_data.c index e932c12d..9877fd60 100644 --- a/src/capwap/cw_out_image_data.c +++ b/src/capwap/cw_out_image_data.c @@ -7,6 +7,9 @@ #include "log.h" +#include "sock.h" + + #define BLOCK_SIZE 1024 @@ -20,7 +23,7 @@ int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst) FILE *infile = item->data; - + int bytes = fread(dst+5,1,BLOCK_SIZE,infile); if (feof(infile)){ diff --git a/src/capwap/dbg.c b/src/capwap/dbg.c index d40dbb3c..3e3d608c 100644 --- a/src/capwap/dbg.c +++ b/src/capwap/dbg.c @@ -36,13 +36,80 @@ uint32_t cw_dbg_opt_level = 0; + + +static struct cw_str color_on[] = { + { DBG_PKT_IN, "\x1b[33m" }, + { DBG_MSG_IN, "\x1b[34m" }, + { DBG_ELEM, "\x1b[39m" }, + { DBG_MSG_ERR, "\x1b[31m" }, + { DBG_X, "\x1b[31m" }, + { CW_STR_STOP, "" } +}; +static struct cw_str color_ontext[] = { + + { DBG_ELEM_DMP, "\x1b[30m"}, + { CW_STR_STOP, "" } +}; + + +static struct cw_str color_off[] = { + + { CW_STR_STOP, "\x1b[22;39m\x1b[23m" } +}; + +static struct cw_str prefix[] = { + { DBG_INFO, " Info -" }, + { DBG_PKT_IN, " Pkt IN -" }, + { DBG_MSG_IN, " Msg IN -" }, + { DBG_ELEM, " Msg Element -" }, + { DBG_MSG_ERR," Msg Error -" }, + { DBG_X, "XXXXX - "}, + { 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); + +} + + + + + + + + + /** * 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) { - if (!cw_dbg_is_level(DBG_ELEM) || n == 0) + if (!cw_dbg_is_level(DBG_MSG_ERR) || n == 0) return; char buffer[2000]; @@ -54,7 +121,7 @@ void cw_dbg_missing_mand(int level, struct conn *conn, cw_action_in_t ** ml, int 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_MSG_ERR, "Missing mandatory elements: [%s]", buffer); } int cw_format_pkt(char *dst,int level,struct conn *conn, uint8_t * packet, int len) @@ -109,6 +176,108 @@ abort: } + +char * make_dmp( const uint8_t * data, int len) +{ + + int maxtlen = 2048; + int i; + int rowlen = CW_LOG_DUMP_ROW_LEN; + int rows = len / rowlen; + int tlen = 0; + + int md; + if (cw_dbg_opt_display & DBG_DISP_ASC_DMP) + md = 2; + else + md = 1; + + + + char *dst = malloc(2*(md * (len * 3 + (rows * 2) + 8 + maxtlen))); + if (!dst) + return NULL; +/* + if (format != NULL) { + va_list args; + va_start(args, format); + tlen = vsnprintf(dst, maxtlen, format, args); + va_end(args); + } +*/ + + + if (len % CW_LOG_DUMP_ROW_LEN) + rows++; + + + + char *pdst = dst + tlen; + sprintf(pdst, "\n\t"); + pdst += 2; + + char asc_buffer[128]; + char *ascdst = asc_buffer; + + for (i = 0; i < len; i++) { + sprintf(pdst, "%02X ", data[i] & 0xff); + + if (cw_dbg_opt_display & DBG_DISP_ASC_DMP) { + int c = data[i] & 0xff; + if (c < 0x20 || c > 0x7f) + c = '.'; + *ascdst = c; + ascdst++; + } + + pdst += 3; + if ((i + 1) % rowlen == 0) { + int l; + if (cw_dbg_opt_display & DBG_DISP_ASC_DMP) { + *ascdst = 0; + l = sprintf(pdst, " | %s\n\t", asc_buffer); + ascdst = asc_buffer; + + } else { + l = sprintf(pdst, "\n\t"); + } + pdst += l; + } + + } + + if (cw_dbg_opt_display & DBG_DISP_ASC_DMP) { + *ascdst = 0; + if (strlen(asc_buffer)) + pdst += sprintf(pdst, " | %s", asc_buffer); + + } + + + +// cw_log_cb(LOG_DEBUG, "%s",dst); + + return dst; +} + + + + + + + + + + + + + + + + + + + void cw_dbg_pkt(int level,struct conn *conn, uint8_t * packet, int len) { if (!cw_dbg_is_level(level)) @@ -134,7 +303,7 @@ void cw_dbg_msg(int level,struct conn *conn, uint8_t * packet, int len) 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,"%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)); @@ -144,14 +313,13 @@ abort: - +/* void cw_dbg_packet_m(struct conn *conn, uint8_t * packet, int len) { if (!cw_dbg_is_level(DBG_PKT_IN | DBG_PKT_OUT)) return; - /* print the header */ char hdr[200]; hdr_print(hdr, packet, len); @@ -169,11 +337,12 @@ void cw_dbg_packet_m(struct conn *conn, uint8_t * packet, int len) } +*/ -void cw_dbg_dmp_(int level, const char *file, int line, + +void ycw_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; @@ -222,7 +391,7 @@ return; if (cw_dbg_opt_display & DBG_DISP_ASC_DMP) { int c = data[i] & 0xff; - if (c < 0x20 || c > 0x80) + if (c < 0x20 || c > 0x7f) c = '.'; *ascdst = c; ascdst++; @@ -251,11 +420,9 @@ return; } - 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); - } + + + cw_log_cb(LOG_DEBUG, "%s",dst); free(dst); return; @@ -294,101 +461,28 @@ void cw_dbg_elem_colored(int level, struct conn *conn, int msg, int 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, ""); + cw_dbg(DBG_ELEM, "%d (%s), len=%d", + 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, ""); + else{ + char *dmp = make_dmp(msgbuf,len); + + cw_dbg(DBG_ELEM, "%d (%s), len=%d%s%s", + msgelem, + elemname, + len, + get_dbg_color_ontext(DBG_ELEM_DMP), + dmp); + + free(dmp); + } } - - - -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)) + if (!(cw_dbg_is_level(level))) return; char fbuf[1024]; @@ -407,22 +501,6 @@ void cw_dbg_colored(int level, const char *file, int line, const char *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); } diff --git a/src/capwap/dbg.h b/src/capwap/dbg.h index 5f58ea51..c7f8fbeb 100644 --- a/src/capwap/dbg.h +++ b/src/capwap/dbg.h @@ -17,10 +17,15 @@ void cw_dbg_missing_mand(int level,struct conn *conn,cw_action_in_t ** ml,int n, void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len); +#define DBGX(f,...) cw_dbg(DBG_X,f,__VA_ARGS__) //cw_dbg(DBG_X, f ,__VA_ARGS__) +//#define DBGX(f,...) cw_dbg(DBG_X, f) +//#define DBGX(f,...) printf("hallo\n") + + #ifdef WITH_CW_LOG_DEBUG - #define cw_dbg_elem(conn,msgtype,msgelemtype,msgbuf,msglen)\ - cw_dbg_elem_(conn,msgtype,msgelemtype,msgbuf,msglen) + #define cw_dbg_elem(level,conn,msgtype,msgelemtype,msgbuf,msglen)\ + cw_dbg_elem_colored(level,conn,msgtype,msgelemtype,msgbuf,msglen) #else @@ -35,47 +40,76 @@ void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len); * @{ */ +/** + * Debug levels + */ +enum debug_levels{ + /** Show headers of incomming CAPWAP packets */ + DBG_PKT_IN=0, + /** Show headers of outgoing CAPWAP packets */ + DBG_PKT_OUT, -#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 */ + /** Incomming CAPWAP packets with errors, wich would + usually silently discarded */ + DBG_PKT_ERR, + + /** Dump content of incomming packets */ + DBG_PKT_DMP, + + /** Display incomming CAPWAP/LWAPP messages */ + DBG_MSG_IN, + + /** Display outgoing CAPWAP/LWAPP messages */ + DBG_MSG_OUT, + + /** Message errors */ + DBG_MSG_ERR, + + /** Show message elements */ + DBG_ELEM, + + /** Error in msg elements */ + DBG_ELEM_ERR, + + /** Show subelements */ + DBG_SUBELEM, + + /** hex dump elements */ + DBG_ELEM_DMP, + + /** General infos, like CAPWAP state */ + DBG_INFO, + + /** RFC related */ + DBG_RFC, + + DBG_DTLS, + DBG_DTLS_DETAIL, + DBG_DTLS_BIO, + DBG_DTLS_BIO_DMP, + + DBG_X -#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_DISP_LINE_NUMBERS (1<<0) +#define DBG_DISP_ASC_DMP (1<<1) +#define DBG_DISP_COLORS (1<<2) + #define DBG_DETAIL_ALL 0xffffffff -#define DBG_ERR (DBG_MSG_ERR | DBG_CW_PKT_ERR) + /**@}*/ @@ -88,7 +122,6 @@ 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__) @@ -107,5 +140,12 @@ 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); +#define cw_dbg_set_level(level,on)\ + (on ? cw_dbg_opt_level |= (1<<(level)) : (cw_dbg_opt_level &= (-1)^(1<<(level)))) + +#define cw_dbg_is_level(level)\ + (cw_dbg_opt_level & (1<dtls_buffer_pos += maxlen; cw_dbg(DBG_DTLS_BIO, "SSL BIO read: (maxlen = %d), read %d, remain %d", maxlen, maxlen, conn->dtls_buffer_len); - cw_dbg_dmp(DBG_DTLS_BIO_DMP, (uint8_t *) out, maxlen, "Dump..."); +// cw_dbg_dmp(DBG_DTLS_BIO_DMP, (uint8_t *) out, maxlen, "Dump..."); return maxlen; } @@ -62,7 +62,7 @@ int dtls_bio_read(struct conn *conn, char *out, int maxlen) conn->dtls_buffer_len = 0; cw_dbg(DBG_DTLS_BIO, "SSL BIO read: (maxlen = %d), read %d, remain %d", maxlen, ret, conn->dtls_buffer_len); - cw_dbg_dmp(DBG_DTLS_BIO_DMP, (uint8_t *) out, ret, "Dump..."); +// cw_dbg_dmp(DBG_DTLS_BIO_DMP, (uint8_t *) out, ret, "Dump..."); return ret; } @@ -84,7 +84,7 @@ int dtls_bio_write(struct conn *conn, const char *data, int len) cw_dbg(DBG_DTLS_BIO, "SSL BIO write: %d bytes, wrote=%d, ptr: %p", len, rc, data); - cw_dbg_dmp(DBG_DTLS_BIO_DMP, (uint8_t *) data, len, "Dump ..."); +// cw_dbg_dmp(DBG_DTLS_BIO_DMP, (uint8_t *) data, len, "Dump ..."); if (rc < 0) return rc; diff --git a/src/capwap/dtls_gnutls.c b/src/capwap/dtls_gnutls.c index 7a57deb5..99f0d7bc 100644 --- a/src/capwap/dtls_gnutls.c +++ b/src/capwap/dtls_gnutls.c @@ -56,6 +56,7 @@ int dtls_gnutls_write(struct conn * conn, const uint8_t *buffer, int len) if ( rc < 0 ){ cw_log(LOG_ERR, "DTLS - write error: %s", gnutls_strerror(rc)); conn->dtls_error=1; + errno=ECONNRESET; return -1; } @@ -84,6 +85,7 @@ int dtls_gnutls_read(struct conn * conn, uint8_t *buffer, int len) if ( rc < 0 ){ cw_log(LOG_ERR, "DTLS - read error: %s", gnutls_strerror(rc)); conn->dtls_error=1; + errno=ECONNRESET; return -1; } diff --git a/src/capwap/log.h b/src/capwap/log.h index 5682738a..a863b0c5 100644 --- a/src/capwap/log.h +++ b/src/capwap/log.h @@ -52,7 +52,6 @@ //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) diff --git a/src/capwap/lw_put_ac_descriptor.c b/src/capwap/lw_put_ac_descriptor.c index 7a2a662f..07567dea 100644 --- a/src/capwap/lw_put_ac_descriptor.c +++ b/src/capwap/lw_put_ac_descriptor.c @@ -1,19 +1,18 @@ #include -#include "acinfo.h" #include "lwapp.h" -int lw_put_ac_descriptor(uint8_t * dst, struct ac_info * acinfo) +int lw_put_ac_descriptor(uint8_t * dst) { uint8_t *d=dst; d+=lw_put_byte(d,0); /* Cisco MWAR type */ - d+=lw_put_bstr(d,acinfo->hardware_version); /* length must be 4 */ - d+=lw_put_bstr(d,acinfo->software_version); /* length must be 4 */ +// d+=lw_put_bstr(d,acinfo->hardware_version); /* length must be 4 */ +// d+=lw_put_bstr(d,acinfo->software_version); /* length must be 4 */ d+=lw_put_word(d,200); d+=lw_put_word(d,1000); d+=lw_put_word(d,2); d+=lw_put_word(d,2); - d+=lw_put_byte(d,acinfo->security); + //d+=lw_put_byte(d,acinfo->security); return d-dst; } diff --git a/src/capwap/lwapp.h b/src/capwap/lwapp.h index 42813bdd..6a2092b1 100644 --- a/src/capwap/lwapp.h +++ b/src/capwap/lwapp.h @@ -23,7 +23,7 @@ #include #include -#include "acinfo.h" +//#include "acinfo.h" #include "wtpinfo.h" @@ -218,7 +218,7 @@ extern int lw_put_sockaddr(uint8_t *dst, struct sockaddr_storage *addr); extern int lw_put_cisco_path_mtu(uint8_t *dst, uint16_t max, uint16_t padding); #define lw_put_certificate(dst,cert,len) lw_put_data(dst,cert,len) -extern int lw_put_ac_descriptor(uint8_t * dst, struct ac_info * acinfo); +//extern int lw_put_ac_descriptor(uint8_t * dst, struct ac_info * acinfo); /* function proto types */ diff --git a/src/capwap/timer.h b/src/capwap/timer.h index e29b8f82..0998e828 100644 --- a/src/capwap/timer.h +++ b/src/capwap/timer.h @@ -1,10 +1,29 @@ +/* + This file is part of libcapwap. + + libcapwap is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + libcapwap is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Foobar. If not, see . + +*/ + + #ifndef __CW_TIMER_H #define __CW_TIMER_H #include /** - * @defgroup TimerFunctions Timer functions + * @defgroup TimerFunctions Timer Functions * @{ */ @@ -31,6 +50,9 @@ #define cw_clock_stop(t)\ (((double) (clock()-(t))) / CLOCKS_PER_SEC) + + + /** @} */ diff --git a/src/wtp/conf_uci.c b/src/wtp/conf_uci.c index 4c1f61d6..38b04101 100644 --- a/src/wtp/conf_uci.c +++ b/src/wtp/conf_uci.c @@ -47,10 +47,11 @@ static void set_dbg_opt(struct uci_context *ctx,struct uci_section * section,int if (!str) return; if ((strcmp(str,"1")==0) || (strcmp(str,"true")==0)) - conf_dbg_level |= opt; + //conf_dbg_level |= opt; + cw_dbg_set_level(opt,1); if ((strcmp(str,"0")==0) || (strcmp(str,"false")==0)) - conf_dbg_level &= ((-1)^opt); + cw_dbg_set_level(opt,0); } diff --git a/src/wtp/wtp_conf.c b/src/wtp/wtp_conf.c index 03d345f2..fd3a6445 100644 --- a/src/wtp/wtp_conf.c +++ b/src/wtp/wtp_conf.c @@ -56,7 +56,7 @@ long conf_echo_interval=CONF_DEFAULT_ECHO_INTERVAL; long conf_max_retransmit=CONF_DEFAULT_MAX_RETRANSMIT; long conf_retransmit_interval=CONF_DEFAULT_RETRANSMIT_INTERVAL; -long conf_dbg_level=CONF_DEFAULT_DEBUG_LEVEL; +//long conf_dbg_level=CONF_DEFAULT_DEBUG_LEVEL; diff --git a/src/wtp/wtp_conf.h b/src/wtp/wtp_conf.h index 3b276eb7..800c7fe5 100644 --- a/src/wtp/wtp_conf.h +++ b/src/wtp/wtp_conf.h @@ -128,7 +128,7 @@ extern long conf_echo_interval; extern long conf_max_retransmit; extern long conf_retransmit_interval; -extern long conf_dbg_level; +//extern long conf_dbg_level; extern int conf_mtu_discovery; extern int conf_mtu; diff --git a/src/wtp/wtp_main.c b/src/wtp/wtp_main.c index 7f63f0fe..8037b982 100644 --- a/src/wtp/wtp_main.c +++ b/src/wtp/wtp_main.c @@ -32,7 +32,7 @@ int main() return 1; } - cw_dbg_opt_level = conf_dbg_level; +// cw_dbg_opt_level = conf_dbg_level; wtpconf_init();