diff --git a/src/common/capwap_element.c b/src/common/capwap_element.c index 3ed130a..fe0e99e 100644 --- a/src/common/capwap_element.c +++ b/src/common/capwap_element.c @@ -207,6 +207,7 @@ int capwap_parsing_packet(struct capwap_packet_rxmng* rxmngpacket, struct capwap } /* Check type */ + capwap_logging_debug("MESSAGE ELEMENT: %d", type); if (!IS_VALID_MESSAGE_ELEMENTS(type)) { return UNRECOGNIZED_MESSAGE_ELEMENT; } @@ -227,6 +228,7 @@ int capwap_parsing_packet(struct capwap_packet_rxmng* rxmngpacket, struct capwap /* Reader function */ read_ops = capwap_get_message_element_ops(type); + capwap_logging_debug("read_ops: %p", read_ops); if (!read_ops) { return INVALID_MESSAGE_ELEMENT; } diff --git a/src/wtp/binding/ieee80211/wifi_drivers.c b/src/wtp/binding/ieee80211/wifi_drivers.c index 20a2e33..67f8658 100644 --- a/src/wtp/binding/ieee80211/wifi_drivers.c +++ b/src/wtp/binding/ieee80211/wifi_drivers.c @@ -46,14 +46,19 @@ static void wifi_wlan_getrates(struct wifi_device* device, uint8_t* rates, int r /* Retrieve capability */ capability = wifi_device_getcapability(device); if (!capability) { + capwap_logging_debug("getrates: getcapability failed"); return; } /* Get radio type for basic rate */ radiotype = wifi_frequency_to_radiotype(device->currentfrequency.frequency); if (radiotype < 0) { + capwap_logging_debug("getrates: no radiotype for freq %d", device->currentfrequency.frequency); return; } + capwap_logging_debug("getrates: radiotype %d, freq: %d", radiotype, device->currentfrequency.frequency); + + capwap_logging_debug("getrates: Band %d", device->currentfrequency.band); /* Check type of rate mode */ for (i = 0; i < ratescount; i++) { @@ -74,6 +79,8 @@ static void wifi_wlan_getrates(struct wifi_device* device, uint8_t* rates, int r } } + capwap_logging_debug("getrates: Mode %d", mode); + /* Add implicit 802.11b rate with only 802.11g rate */ if ((device->currentfrequency.band == WIFI_BAND_2GHZ) && !(mode & CAPWAP_RADIO_TYPE_80211B) && (device->currentfrequency.mode & CAPWAP_RADIO_TYPE_80211B)) { device_params->supportedrates[device_params->supportedratescount++] = IEEE80211_RATE_1M; @@ -82,10 +89,14 @@ static void wifi_wlan_getrates(struct wifi_device* device, uint8_t* rates, int r device_params->supportedrates[device_params->supportedratescount++] = IEEE80211_RATE_11M; } + capwap_logging_debug("getrates: Bands Count %d", capability->bands->count); + /* Filter band */ for (i = 0; i < capability->bands->count; i++) { struct wifi_band_capability* bandcap = (struct wifi_band_capability*)capwap_array_get_item_pointer(capability->bands, i); + capwap_logging_debug("getrates: Bandcap Band %d", bandcap->band); + if (bandcap->band == device->currentfrequency.band) { for (j = 0; j < bandcap->rate->count; j++) { struct wifi_rate_capability* ratecapability = (struct wifi_rate_capability*)capwap_array_get_item_pointer(bandcap->rate, j); @@ -127,6 +138,13 @@ static void wifi_wlan_getrates(struct wifi_device* device, uint8_t* rates, int r if (!(mode & CAPWAP_RADIO_TYPE_80211N) && (device->currentfrequency.mode & CAPWAP_RADIO_TYPE_80211N)) { device_params->supportedrates[device_params->supportedratescount++] = IEEE80211_RATE_80211N; } + + for (i = 0; i < device_params->basicratescount; i++) { + capwap_logging_debug("getrates: Basic Rate %d: %d", i, device_params->basicrates[i]); + } + for (i = 0; i < device_params->supportedratescount; i++) { + capwap_logging_debug("getrates: Supported Rate %d: %d", i, device_params->supportedrates[i]); + } } /* */ @@ -1402,8 +1420,10 @@ int wifi_device_updaterates(struct wifi_device* device, uint8_t* rates, int rate /* */ wifi_wlan_getrates(device, rates, ratescount, &buildrate); if (!buildrate.supportedratescount || (buildrate.supportedratescount > IEEE80211_SUPPORTEDRATE_MAX_COUNT)) { + capwap_logging_debug("update rates: supported rates failed, (%d .. %d)", buildrate.supportedratescount, IEEE80211_SUPPORTEDRATE_MAX_COUNT); return -1; } else if (!buildrate.basicratescount || (buildrate.basicratescount > IEEE80211_SUPPORTEDRATE_MAX_COUNT)) { + capwap_logging_debug("update rates: basic rates failed: %d", buildrate.basicratescount); return -1; } diff --git a/src/wtp/wtp_dfa.c b/src/wtp/wtp_dfa.c index d037da6..7ed741f 100644 --- a/src/wtp/wtp_dfa.c +++ b/src/wtp/wtp_dfa.c @@ -350,18 +350,21 @@ int wtp_dfa_running(void) { buffer = bufferencrypt; buffersize = CAPWAP_MAX_PACKET_SIZE; index = wtp_recvfrom(&g_wtp.fds, buffer, &buffersize, &fromaddr, &toaddr); + capwap_logging_debug("WTP got data: idx: %d, size: %d", index, buffersize); if (!g_wtp.running) { capwap_logging_debug("Closing WTP, Teardown connection"); wtp_dfa_closeapp(); break; } else if (index >= 0) { if (g_wtp.teardown) { + capwap_logging_debug("WTP is in teardown, drop packet"); continue; /* Drop packet */ } else { int check; /* Check source */ if (capwap_compare_ip(&g_wtp.dtls.peeraddr, &fromaddr)) { + capwap_logging_debug("WTP compare failed, drop packet"); continue; /* Unknown source */ } diff --git a/src/wtp/wtp_radio.c b/src/wtp/wtp_radio.c index 90f8df1..74026b5 100644 --- a/src/wtp/wtp_radio.c +++ b/src/wtp/wtp_radio.c @@ -21,6 +21,7 @@ static int wtp_radio_configure_phy(struct wtp_radio* radio) { /* Default rate set is all supported rate */ if (radio->radioid != radio->rateset.radioid) { if (radio->radioid != radio->supportedrates.radioid) { + capwap_logging_debug("Config Phy: Supported rate not set"); return -1; /* Supported rate not set */ } @@ -31,20 +32,26 @@ static int wtp_radio_configure_phy(struct wtp_radio* radio) { /* Update rates */ if (wifi_device_updaterates(radio->devicehandle, radio->rateset.rateset, radio->rateset.ratesetcount)) { + capwap_logging_debug("Config Phy: update rates failed"); return -1; } } /* Check channel radio */ if (radio->radioid != radio->radioinformation.radioid) { + capwap_logging_debug("Config Phy: RI id mismatch"); return -1; } else if (radio->radioid != radio->radioconfig.radioid) { + capwap_logging_debug("Config Phy: RC id mismatch"); return -1; } else if ((!radio->directsequencecontrol.radioid && !radio->ofdmcontrol.radioid) || ((radio->directsequencecontrol.radioid == radio->radioid) && (radio->ofdmcontrol.radioid == radio->radioid))) { + capwap_logging_debug("Config Phy: DSSS / OFDM mismatch"); return -1; /* Only one from DSSS and OFDM can select */ } else if ((radio->radioid == radio->directsequencecontrol.radioid) && !(radio->radioinformation.radiotype & (CAPWAP_RADIO_TYPE_80211B | CAPWAP_RADIO_TYPE_80211G))) { + capwap_logging_debug("Config Phy: DSSS B/G mismatch"); return -1; } else if ((radio->radioid == radio->ofdmcontrol.radioid) && !(radio->radioinformation.radiotype & CAPWAP_RADIO_TYPE_80211A)) { + capwap_logging_debug("Config Phy: OFDM A mismatch"); return -1; } @@ -432,6 +439,8 @@ int wtp_radio_setconfiguration(struct capwap_parsed_packet* packet) { } } + capwap_logging_debug("wtp_radio_setconfiguration result #1: %d", result); + /* Update radio frequency */ for (i = 0; (i < updateitems->count) && !result; i++) { struct wtp_update_configuration_item* item = (struct wtp_update_configuration_item*)capwap_array_get_item_pointer(updateitems, i); @@ -449,6 +458,8 @@ int wtp_radio_setconfiguration(struct capwap_parsed_packet* packet) { } } + capwap_logging_debug("wtp_radio_setconfiguration result #2: %d", result); + /* Update radio configuration */ for (i = 0; (i < updateitems->count) && !result; i++) { struct wtp_update_configuration_item* item = (struct wtp_update_configuration_item*)capwap_array_get_item_pointer(updateitems, i); @@ -475,6 +486,8 @@ int wtp_radio_setconfiguration(struct capwap_parsed_packet* packet) { } } + capwap_logging_debug("wtp_radio_setconfiguration result #3: %d", result); + /* */ capwap_array_free(updateitems); return result; @@ -524,12 +537,14 @@ struct wtp_radio_wlan* wtp_radio_get_wlan(struct wtp_radio* radio, uint8_t wlani /* Check */ if (!IS_VALID_WLANID(wlanid)) { + capwap_logging_debug("wtp_radio_get_wlan: invalid wlanid (%d)", wlanid); return NULL; } /* Retrieve BSS */ for (itemwlan = radio->wlan->first; itemwlan != NULL; itemwlan = itemwlan->next) { struct wtp_radio_wlan* wlan = (struct wtp_radio_wlan*)itemwlan->item; + capwap_logging_debug("wtp_radio_get_wlan: checking (%d .. %d)", wlanid, wlan->wlanid); if (wlanid == wlan->wlanid) { return wlan; } @@ -618,29 +633,34 @@ uint32_t wtp_radio_create_wlan(struct capwap_parsed_packet* packet, struct capwa /* Get message elements */ addwlan = (struct capwap_80211_addwlan_element*)capwap_get_message_element_data(packet, CAPWAP_ELEMENT_80211_ADD_WLAN); if (!addwlan) { + capwap_logging_debug("Create WLAN: no wlan"); return CAPWAP_RESULTCODE_FAILURE; } /* Get physical radio */ radio = wtp_radio_get_phy(addwlan->radioid); if (!radio) { + capwap_logging_debug("Create WLAN: no radio"); return CAPWAP_RESULTCODE_FAILURE; } /* Check if virtual interface is already exist */ wlan = wtp_radio_get_wlan(radio, addwlan->wlanid); if (wlan) { + capwap_logging_debug("Create WLAN: vif already exists"); return CAPWAP_RESULTCODE_FAILURE; } /* Verify exist interface into pool */ if (!radio->wlanpool->first) { + capwap_logging_debug("Create WLAN: not first if in pool"); return CAPWAP_RESULTCODE_FAILURE; } /* Prepare physical interface for create wlan */ if (!radio->wlan->count) { if (wtp_radio_configure_phy(radio)) { + capwap_logging_debug("Create WLAN: config phy failed"); return CAPWAP_RESULTCODE_FAILURE; } } @@ -671,6 +691,7 @@ uint32_t wtp_radio_create_wlan(struct capwap_parsed_packet* packet, struct capwa /* Start AP */ if (wifi_wlan_startap(wlanpool->wlanhandle, ¶ms)) { + capwap_logging_debug("Create WLAN: start AP failes"); /* Set interface to pool */ capwap_itemlist_free(itemwlan); capwap_itemlist_insert_before(radio->wlanpool, NULL, itemwlanpool); @@ -716,18 +737,21 @@ uint32_t wtp_radio_add_station(struct capwap_parsed_packet* packet) { addstation = (struct capwap_addstation_element*)capwap_get_message_element_data(packet, CAPWAP_ELEMENT_ADDSTATION); station80211 = (struct capwap_80211_station_element*)capwap_get_message_element_data(packet, CAPWAP_ELEMENT_80211_STATION); if (!station80211 || (addstation->radioid != station80211->radioid)) { + capwap_logging_debug("add_station: error no station or wrong radio"); return CAPWAP_RESULTCODE_FAILURE; } /* Get physical radio */ radio = wtp_radio_get_phy(addstation->radioid); if (!radio) { + capwap_logging_debug("add_station: radio_get_phy failed"); return CAPWAP_RESULTCODE_FAILURE; } /* Get virtual interface */ wlan = wtp_radio_get_wlan(radio, station80211->wlanid); if (!wlan) { + capwap_logging_debug("add_station: radio_get_wlan failed (%p, %d)", radio, station80211->wlanid); return CAPWAP_RESULTCODE_FAILURE; } @@ -736,9 +760,11 @@ uint32_t wtp_radio_add_station(struct capwap_parsed_packet* packet) { stationparams.address = station80211->address; if (wifi_station_authorize(wlan->wlanhandle, &stationparams)) { + capwap_logging_debug("add_station: station_authorize failed"); return CAPWAP_RESULTCODE_FAILURE; } + capwap_logging_debug("add_station: SUCCESS"); return CAPWAP_RESULTCODE_SUCCESS; }