diff --git a/src/ac/ac.default.conf b/src/ac/ac.default.conf index 2888932c..b029b66a 100644 --- a/src/ac/ac.default.conf +++ b/src/ac/ac.default.conf @@ -209,6 +209,7 @@ # dbg += dtls_bio # DTLS BIO operations # dbg += dtls_bio_dmp # HeXy dump data in BIO operations # dbg += warn # misc warnings +# dbg += mod # Debugs specific to mod # # dbg += all # all of the above # dbg += err # Same as dbg_err and pkt_err diff --git a/src/cw/dbg.c b/src/cw/dbg.c index 2804550f..4d985e6b 100644 --- a/src/cw/dbg.c +++ b/src/cw/dbg.c @@ -71,6 +71,9 @@ uint32_t cw_dbg_opt_level = 0; #define DBG_CLR_CYAN "\x1b[36m" +#define DBG_CLR_RED_I "\x1b[3;31m" + + static struct cw_strlist_elem color_on[] = { { DBG_PKT_IN, DBG_CLR_YELLO }, { DBG_PKT_OUT, DBG_CLR_YELLO_I }, @@ -88,6 +91,7 @@ static struct cw_strlist_elem color_on[] = { { DBG_RFC, "\x1b[31m" }, { DBG_X, "\x1b[31m" }, { DBG_WARN, DBG_CLR_CYAN }, + { DBG_MOD, "\x1b[91m" }, { CW_STR_STOP, "" } }; static struct cw_strlist_elem color_ontext[] = { @@ -117,6 +121,7 @@ static struct cw_strlist_elem prefix[] = { { DBG_SUBELEM," Sub-Element - "}, { DBG_DTLS, " DTLS - "}, { DBG_WARN, " Warning - "}, + { DBG_MOD, " Mod - "}, { DBG_X, "XXXXX - "}, { CW_STR_STOP, "" } diff --git a/src/cw/dbg.h b/src/cw/dbg.h index 30d56a2d..7121ef77 100644 --- a/src/cw/dbg.h +++ b/src/cw/dbg.h @@ -125,6 +125,9 @@ enum cw_dbg_levels{ /** Dump DTLS BIO i/o */ DBG_DTLS_BIO_DMP, + + /** Debug Mods */ + DBG_MOD, DBG_X diff --git a/src/cw/dbg_strings.c b/src/cw/dbg_strings.c index ad394cd4..b4910024 100644 --- a/src/cw/dbg_strings.c +++ b/src/cw/dbg_strings.c @@ -52,6 +52,7 @@ struct cw_strlist_elem cw_dbg_strings[] = { { DBG_DTLS, "dtls" }, { DBG_DTLS_BIO, "dtls_bio" }, { DBG_WARN, "warn" }, + { DBG_MOD,"mod"}, { DBG_X,"dbgx" }, { CW_STR_STOP, NULL } diff --git a/src/mod/capwap/mod_capwap_ac.c b/src/mod/capwap/mod_capwap_ac.c index 2c59b3d3..59dab493 100644 --- a/src/mod/capwap/mod_capwap_ac.c +++ b/src/mod/capwap/mod_capwap_ac.c @@ -17,7 +17,7 @@ extern int capwap_register_actions_ac(struct cw_actiondef *def); static int init() { - cw_dbg(DBG_INFO, "Initialiazing mod_capwap ..."); + cw_dbg(DBG_MOD, "Initialiazing mod_capwap."); // int rc = capwap_register_actions_ac(&actions); // cw_dbg(DBG_INFO, "Initialized mod capwap with %d actions", rc); return 0; @@ -29,7 +29,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele { if (mode != MOD_DETECT_CAPWAP) return 0; - + cw_dbg(DBG_MOD,"CAPWAP detected: yes"); return 1; } diff --git a/src/mod/capwap/mod_capwap_wtp.c b/src/mod/capwap/mod_capwap_wtp.c index b2a7b2a4..bb1c0cc7 100644 --- a/src/mod/capwap/mod_capwap_wtp.c +++ b/src/mod/capwap/mod_capwap_wtp.c @@ -29,8 +29,6 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele { if (mode != MOD_DETECT_CAPWAP) return 0; - - cw_log(LOG_INFO, "Detecting ..."); conn->detected = 1; conn->actions = &actions; return 1; diff --git a/src/mod/capwap80211/mod_capwap80211_ac.c b/src/mod/capwap80211/mod_capwap80211_ac.c index e58b6bde..36ba7ef8 100644 --- a/src/mod/capwap80211/mod_capwap80211_ac.c +++ b/src/mod/capwap80211/mod_capwap80211_ac.c @@ -31,9 +31,11 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele return 0; int wbid = cw_get_hdr_wbid(rawmsg); - if (wbid != CW_WBID_IEEE80211 ) + if (wbid != CW_WBID_IEEE80211 ) { + cw_dbg(DBG_MOD,"CAPWAP80211 detected: no, my wbid=%d, remote wbid=%d",CW_WBID_IEEE80211,wbid); return 0; - + } + cw_dbg(DBG_MOD,"CAPWAP80211 detected: yes"); return 1; } diff --git a/src/mod/cipwap/mod_cipwap_ac.c b/src/mod/cipwap/mod_cipwap_ac.c index b2d18ab6..f1912a93 100644 --- a/src/mod/cipwap/mod_cipwap_ac.c +++ b/src/mod/cipwap/mod_cipwap_ac.c @@ -1,6 +1,7 @@ #include "cw/mod.h" #include "cw/log.h" +#include "cw/dbg.h" #include "mod_cipwap.h" @@ -14,8 +15,10 @@ int cipwap_init() static int detect(struct conn *conn,const uint8_t *rawmsg, int rawlen,int elems_len, struct sockaddr *from, int mode) { + if (mode != MOD_DETECT_CAPWAP) + return 0; - cw_log(LOG_INFO,"Detecting ..."); + cw_dbg(DBG_MOD,"CIPWAP detected: no"); return 0; } diff --git a/src/mod/cisco/mod_cisco_ac.c b/src/mod/cisco/mod_cisco_ac.c index 2d97f785..75fdc340 100644 --- a/src/mod/cisco/mod_cisco_ac.c +++ b/src/mod/cisco/mod_cisco_ac.c @@ -48,6 +48,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele if (mode != MOD_DETECT_CAPWAP) return 0; + int offset = cw_get_hdr_msg_offset(rawmsg); const uint8_t *msg_ptr = rawmsg + offset; @@ -63,6 +64,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem)); if (vendor_id == CW_VENDOR_ID_CISCO) { conn->actions = &actions; + cw_dbg(DBG_MOD,"CISCO detected: yes"); return 1; } @@ -71,6 +73,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele } + cw_dbg(DBG_MOD,"CISCO detected: no"); return 0; } diff --git a/src/wtp/wtp_main.c b/src/wtp/wtp_main.c index 73c6d131..8577b2c5 100644 --- a/src/wtp/wtp_main.c +++ b/src/wtp/wtp_main.c @@ -185,6 +185,8 @@ int main() mbag_set_byte(conn->local, CW_ITEM_WTP_MAC_TYPE, 0); mbag_set_byte(conn->local, CW_ITEM_WTP_FRAME_TUNNEL_MODE, 0); + conn->wbid=1; +