switch everything to new log API and drop old one
This commit is contained in:
@ -53,19 +53,19 @@ static void wifi_wlan_getrates(struct wifi_device* device,
|
||||
/* Retrieve capability */
|
||||
capability = wifi_device_getcapability(device);
|
||||
if (!capability) {
|
||||
capwap_logging_debug("getrates: getcapability failed");
|
||||
log_printf(LOG_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);
|
||||
log_printf(LOG_DEBUG, "getrates: no radiotype for freq %d", device->currentfrequency.frequency);
|
||||
return;
|
||||
}
|
||||
capwap_logging_debug("getrates: radiotype %d, freq: %d", radiotype, device->currentfrequency.frequency);
|
||||
log_printf(LOG_DEBUG, "getrates: radiotype %d, freq: %d", radiotype, device->currentfrequency.frequency);
|
||||
|
||||
capwap_logging_debug("getrates: Band %d", device->currentfrequency.band);
|
||||
log_printf(LOG_DEBUG, "getrates: Band %d", device->currentfrequency.band);
|
||||
|
||||
/* Check type of rate mode */
|
||||
for (i = 0; i < ratescount; i++) {
|
||||
@ -86,7 +86,7 @@ static void wifi_wlan_getrates(struct wifi_device* device,
|
||||
}
|
||||
}
|
||||
|
||||
capwap_logging_debug("getrates: Mode %d", mode);
|
||||
log_printf(LOG_DEBUG, "getrates: Mode %d", mode);
|
||||
|
||||
#if 0
|
||||
/* WTF: the AC should know what it's doing and set those rate when it want's them */
|
||||
@ -102,14 +102,14 @@ static void wifi_wlan_getrates(struct wifi_device* device,
|
||||
}
|
||||
#endif
|
||||
|
||||
capwap_logging_debug("getrates: Bands Count %lu", capability->bands->count);
|
||||
log_printf(LOG_DEBUG, "getrates: Bands Count %lu", 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 %lu", bandcap->band);
|
||||
log_printf(LOG_DEBUG, "getrates: Bandcap Band %lu", bandcap->band);
|
||||
|
||||
if (bandcap->band != device->currentfrequency.band)
|
||||
continue;
|
||||
@ -166,7 +166,7 @@ static void wifi_wlan_getrates(struct wifi_device* device,
|
||||
}
|
||||
|
||||
for (i = 0; i < device_params->basicratescount; i++) {
|
||||
capwap_logging_debug("getrates: Basic Rate %d: %d", i, device_params->basicrates[i]);
|
||||
log_printf(LOG_DEBUG, "getrates: Basic Rate %d: %d", i, device_params->basicrates[i]);
|
||||
}
|
||||
for (i = 0; i < device_params->supportedratescount; i++) {
|
||||
log_printf(LOG_DEBUG, "getrates: Supported Rate %d: %.1f Mbit (%d)",
|
||||
@ -199,7 +199,7 @@ static void wifi_hash_station_free(void* data) {
|
||||
ASSERT(data != NULL);
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Destroy station: %s", station->addrtext);
|
||||
log_printf(LOG_INFO, "Destroy station: %s", station->addrtext);
|
||||
capwap_free(station);
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ static void wifi_station_delete(struct wifi_station* station)
|
||||
ASSERT(station != NULL);
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Delete station: %s", station->addrtext);
|
||||
log_printf(LOG_INFO, "Delete station: %s", station->addrtext);
|
||||
|
||||
/* */
|
||||
wifi_station_clean(station);
|
||||
@ -309,23 +309,23 @@ static struct wifi_station* wifi_station_create(struct wifi_wlan* wlan, const ui
|
||||
station = wifi_station_get(NULL, address);
|
||||
if (station) {
|
||||
if (station->wlan && (station->wlan != wlan)) {
|
||||
capwap_logging_info("Roaming station: %s", buffer);
|
||||
log_printf(LOG_INFO, "Roaming station: %s", buffer);
|
||||
wifi_wlan_deauthentication_station(station->wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 1);
|
||||
} else {
|
||||
capwap_logging_info("Reuse station: %s", buffer);
|
||||
log_printf(LOG_INFO, "Reuse station: %s", buffer);
|
||||
wifi_station_clean(station);
|
||||
}
|
||||
}
|
||||
|
||||
/* Checks if it has reached the maximum number of stations */
|
||||
if (wlan->stationscount >= wlan->maxstationscount) {
|
||||
capwap_logging_warning("Unable create station: reached the maximum number of stations");
|
||||
log_printf(LOG_WARNING, "Unable create station: reached the maximum number of stations");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Create new station */
|
||||
if (!station) {
|
||||
capwap_logging_info("Create new station: %s", buffer);
|
||||
log_printf(LOG_INFO, "Create new station: %s", buffer);
|
||||
|
||||
/* */
|
||||
station = (struct wifi_station*)capwap_alloc(sizeof(struct wifi_station));
|
||||
@ -364,15 +364,15 @@ static void wifi_wlan_send_mgmt_deauthentication(struct wifi_wlan* wlan, const u
|
||||
responselength = ieee80211_create_deauthentication(g_bufferIEEE80211, sizeof(g_bufferIEEE80211), &ieee80211_params);
|
||||
if (responselength > 0) {
|
||||
if (!wlan->device->instance->ops->wlan_sendframe(wlan, g_bufferIEEE80211, responselength, wlan->device->currentfrequency.frequency, 0, 0, 0, 0)) {
|
||||
capwap_logging_info("Sent IEEE802.11 Deuthentication to %s station", stationaddress);
|
||||
log_printf(LOG_INFO, "Sent IEEE802.11 Deuthentication to %s station", stationaddress);
|
||||
|
||||
/* Forwards the station deauthentication also to AC */
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)g_bufferIEEE80211, responselength, 0, 0, 0);
|
||||
} else {
|
||||
capwap_logging_warning("Unable to send IEEE802.11 Deuthentication to %s station", stationaddress);
|
||||
log_printf(LOG_WARNING, "Unable to send IEEE802.11 Deuthentication to %s station", stationaddress);
|
||||
}
|
||||
} else {
|
||||
capwap_logging_warning("Unable to create IEEE802.11 Deauthentication to %s station", stationaddress);
|
||||
log_printf(LOG_WARNING, "Unable to create IEEE802.11 Deauthentication to %s station", stationaddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ static void wifi_station_timeout_deauth(EV_P_ ev_timer *w, int revents)
|
||||
(((char *)w) - offsetof(struct wifi_station, timeout));
|
||||
struct wifi_wlan* wlan = (struct wifi_wlan *)w->data;
|
||||
|
||||
capwap_logging_warning("The %s station has not completed the association in time",
|
||||
log_printf(LOG_WARNING, "The %s station has not completed the association in time",
|
||||
station->addrtext);
|
||||
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
|
||||
}
|
||||
@ -483,7 +483,7 @@ static void wifi_wlan_receive_station_mgmt_probe_request(struct wifi_wlan* wlan,
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, rssi, snr, rate);
|
||||
}
|
||||
} else {
|
||||
capwap_logging_warning("Unable to send IEEE802.11 Probe Response");
|
||||
log_printf(LOG_WARNING, "Unable to send IEEE802.11 Probe Response");
|
||||
}
|
||||
}
|
||||
|
||||
@ -569,13 +569,13 @@ static void wifi_wlan_receive_station_mgmt_authentication(struct wifi_wlan* wlan
|
||||
/* Information Elements packet length */
|
||||
ielength = length - (sizeof(struct ieee80211_header) + sizeof(frame->authetication));
|
||||
if (ielength < 0) {
|
||||
capwap_logging_info("Receive invalid IEEE802.11 Authentication Request");
|
||||
log_printf(LOG_INFO, "Receive invalid IEEE802.11 Authentication Request");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ignore authentication packet from same AP */
|
||||
if (!memcmp(frame->sa, wlan->address, MACADDRESS_EUI48_LENGTH)) {
|
||||
capwap_logging_info("Ignore IEEE802.11 Authentication Request from same AP");
|
||||
log_printf(LOG_INFO, "Ignore IEEE802.11 Authentication Request from same AP");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -585,18 +585,18 @@ static void wifi_wlan_receive_station_mgmt_authentication(struct wifi_wlan* wlan
|
||||
/* Get ACL Station */
|
||||
acl = wtp_radio_acl_station(frame->sa);
|
||||
if (acl == WTP_RADIO_ACL_STATION_DENY) {
|
||||
capwap_logging_info("Denied IEEE802.11 Authentication Request from %s station", stationaddress);
|
||||
log_printf(LOG_INFO, "Denied IEEE802.11 Authentication Request from %s station", stationaddress);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Parsing Information Elements */
|
||||
if (ieee80211_retrieve_information_elements_position(&ieitems, &frame->authetication.ie[0], ielength)) {
|
||||
capwap_logging_info("Invalid IEEE802.11 Authentication Request from %s station", stationaddress);
|
||||
log_printf(LOG_INFO, "Invalid IEEE802.11 Authentication Request from %s station", stationaddress);
|
||||
return;
|
||||
}
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Receive IEEE802.11 Authentication Request from %s station", stationaddress);
|
||||
log_printf(LOG_INFO, "Receive IEEE802.11 Authentication Request from %s station", stationaddress);
|
||||
|
||||
/* Create station reference */
|
||||
station = wifi_station_create(wlan, frame->sa);
|
||||
@ -644,7 +644,7 @@ static void wifi_wlan_receive_station_mgmt_authentication(struct wifi_wlan* wlan
|
||||
if (responselength > 0) {
|
||||
/* Send authentication response */
|
||||
if (!wlan->device->instance->ops->wlan_sendframe(wlan, g_bufferIEEE80211, responselength, wlan->device->currentfrequency.frequency, 0, 0, 0, 0)) {
|
||||
capwap_logging_info("Sent IEEE802.11 Authentication Response to %s station with %d status code", stationaddress, (int)responsestatuscode);
|
||||
log_printf(LOG_INFO, "Sent IEEE802.11 Authentication Response to %s station with %d status code", stationaddress, (int)responsestatuscode);
|
||||
|
||||
/* Notify authentication request message also to AC */
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, rssi, snr, rate);
|
||||
@ -652,11 +652,11 @@ static void wifi_wlan_receive_station_mgmt_authentication(struct wifi_wlan* wlan
|
||||
/* Forwards the authentication response message also to AC */
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)g_bufferIEEE80211, responselength, 0, 0, 0);
|
||||
} else if (station) {
|
||||
capwap_logging_warning("Unable to send IEEE802.11 Authentication Response to %s station", stationaddress);
|
||||
log_printf(LOG_WARNING, "Unable to send IEEE802.11 Authentication Response to %s station", stationaddress);
|
||||
wifi_station_delete(station);
|
||||
}
|
||||
} else if (station) {
|
||||
capwap_logging_warning("Unable to create IEEE802.11 Authentication Response to %s station", stationaddress);
|
||||
log_printf(LOG_WARNING, "Unable to create IEEE802.11 Authentication Response to %s station", stationaddress);
|
||||
wifi_station_delete(station);
|
||||
}
|
||||
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
|
||||
@ -676,7 +676,7 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
/* Information Elements packet length */
|
||||
ielength = length - (sizeof(struct ieee80211_header) + sizeof(frame->associationrequest));
|
||||
if (ielength < 0) {
|
||||
capwap_logging_info("Receive invalid IEEE802.11 Association Request");
|
||||
log_printf(LOG_INFO, "Receive invalid IEEE802.11 Association Request");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -686,7 +686,7 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
/* Invalid station, send deauthentication message */
|
||||
capwap_logging_info("Receive IEEE802.11 Association Request from %s unknown station", capwap_printf_macaddress(buffer, frame->sa, MACADDRESS_EUI48_LENGTH));
|
||||
log_printf(LOG_INFO, "Receive IEEE802.11 Association Request from %s unknown station", capwap_printf_macaddress(buffer, frame->sa, MACADDRESS_EUI48_LENGTH));
|
||||
wifi_wlan_send_mgmt_deauthentication(wlan, frame->sa, IEEE80211_REASON_CLASS2_FRAME_FROM_NONAUTH_STA);
|
||||
return;
|
||||
}
|
||||
@ -694,20 +694,20 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
/* */
|
||||
if (!(station->flags & WIFI_STATION_FLAGS_AUTHENTICATED)) {
|
||||
/* Invalid station, send deauthentication message */
|
||||
capwap_logging_info("Receive IEEE802.11 Association Request from %s unauthorized station", station->addrtext);
|
||||
log_printf(LOG_INFO, "Receive IEEE802.11 Association Request from %s unauthorized station", station->addrtext);
|
||||
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_CLASS2_FRAME_FROM_NONAUTH_STA, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Parsing Information Elements */
|
||||
if (ieee80211_retrieve_information_elements_position(&ieitems, &frame->associationrequest.ie[0], ielength)) {
|
||||
capwap_logging_info("Invalid IEEE802.11 Association Request from %s station", station->addrtext);
|
||||
log_printf(LOG_INFO, "Invalid IEEE802.11 Association Request from %s station", station->addrtext);
|
||||
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Receive IEEE802.11 Association Request from %s station", station->addrtext);
|
||||
log_printf(LOG_INFO, "Receive IEEE802.11 Association Request from %s station", station->addrtext);
|
||||
|
||||
if (ieitems.wmm_ie != NULL && ieitems.wmm_ie->version == 1) {
|
||||
station->flags |= WIFI_STATION_FLAGS_WMM;
|
||||
@ -750,7 +750,7 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
responselength = ieee80211_create_associationresponse_response(g_bufferIEEE80211, sizeof(g_bufferIEEE80211), ¶ms);
|
||||
if (responselength > 0) {
|
||||
if (!wlan->device->instance->ops->wlan_sendframe(wlan, g_bufferIEEE80211, responselength, wlan->device->currentfrequency.frequency, 0, 0, 0, 0)) {
|
||||
capwap_logging_info("Sent IEEE802.11 Association Response to %s station with %d status code", station->addrtext, (int)resultstatuscode);
|
||||
log_printf(LOG_INFO, "Sent IEEE802.11 Association Response to %s station with %d status code", station->addrtext, (int)resultstatuscode);
|
||||
|
||||
/* Notify association request message also to AC */
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)frame, length, rssi, snr, rate);
|
||||
@ -758,11 +758,11 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
/* Forwards the association response message also to AC */
|
||||
wifi_wlan_send_frame(wlan, (uint8_t*)g_bufferIEEE80211, responselength, 0, 0, 0);
|
||||
} else {
|
||||
capwap_logging_warning("Unable to send IEEE802.11 Association Response to %s station", station->addrtext);
|
||||
log_printf(LOG_WARNING, "Unable to send IEEE802.11 Association Response to %s station", station->addrtext);
|
||||
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
|
||||
}
|
||||
} else {
|
||||
capwap_logging_warning("Unable to create IEEE802.11 Association Response to %s station", station->addrtext);
|
||||
log_printf(LOG_WARNING, "Unable to create IEEE802.11 Association Response to %s station", station->addrtext);
|
||||
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
|
||||
}
|
||||
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
|
||||
@ -903,7 +903,7 @@ static void wifi_wlan_receive_station_mgmt_authentication_ack(struct wifi_wlan*
|
||||
|
||||
/* Check if authenticate */
|
||||
if ((algorithm == IEEE80211_AUTHENTICATION_ALGORITHM_OPEN) && (transactionseqnumber == 2)) {
|
||||
capwap_logging_info("IEEE802.11 Authentication complete to %s station", station->addrtext);
|
||||
log_printf(LOG_INFO, "IEEE802.11 Authentication complete to %s station", station->addrtext);
|
||||
station->flags |= WIFI_STATION_FLAGS_AUTHENTICATED;
|
||||
} else if ((algorithm == IEEE80211_AUTHENTICATION_ALGORITHM_SHARED_KEY) && (transactionseqnumber == 4)) {
|
||||
/* TODO */
|
||||
@ -930,7 +930,7 @@ static void wifi_wlan_receive_station_mgmt_association_response_ack(struct wifi_
|
||||
/* */
|
||||
statuscode = __le16_to_cpu(frame->associationresponse.statuscode);
|
||||
if (statuscode == IEEE80211_STATUS_SUCCESS) {
|
||||
capwap_logging_info("IEEE802.11 Association complete to %s station", station->addrtext);
|
||||
log_printf(LOG_INFO, "IEEE802.11 Association complete to %s station", station->addrtext);
|
||||
|
||||
/* */
|
||||
station->flags |= WIFI_STATION_FLAGS_ASSOCIATE;
|
||||
@ -1018,7 +1018,7 @@ static int wifi_wlan_receive_ac_mgmt_association_response(struct wifi_wlan* wlan
|
||||
if (station) {
|
||||
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_LOCAL) {
|
||||
if (frame->associationresponse.statuscode != IEEE80211_STATUS_SUCCESS) {
|
||||
capwap_logging_info("AC request deauthentication of station: %s", station->addrtext);
|
||||
log_printf(LOG_INFO, "AC request deauthentication of station: %s", station->addrtext);
|
||||
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
|
||||
}
|
||||
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
|
||||
@ -1287,7 +1287,7 @@ struct wifi_device* wifi_device_connect(const char* ifname, const char* driver)
|
||||
/* Check */
|
||||
length = strlen(ifname);
|
||||
if ((length <= 0) || (length >= IFNAMSIZ)) {
|
||||
capwap_logging_warning("Wifi device name error: %s", ifname);
|
||||
log_printf(LOG_WARNING, "Wifi device name error: %s", ifname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1457,10 +1457,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);
|
||||
log_printf(LOG_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);
|
||||
log_printf(LOG_DEBUG, "update rates: basic rates failed: %d", buildrate.basicratescount);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1492,7 +1492,7 @@ struct wifi_wlan* wifi_wlan_create(struct wifi_device* device, const char* ifnam
|
||||
/* Check */
|
||||
length = strlen(ifname);
|
||||
if ((length <= 0) || (length >= IFNAMSIZ)) {
|
||||
capwap_logging_warning("Wifi device name error: %s", ifname);
|
||||
log_printf(LOG_WARNING, "Wifi device name error: %s", ifname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1512,7 +1512,7 @@ struct wifi_wlan* wifi_wlan_create(struct wifi_device* device, const char* ifnam
|
||||
/* Create interface */
|
||||
wlan->handle = device->instance->ops->wlan_create(device, wlan);
|
||||
if (!wlan->handle) {
|
||||
capwap_logging_warning("Unable to create virtual interface: %s", ifname);
|
||||
log_printf(LOG_WARNING, "Unable to create virtual interface: %s", ifname);
|
||||
wifi_wlan_destroy(wlan);
|
||||
return NULL;
|
||||
}
|
||||
@ -1520,7 +1520,7 @@ struct wifi_wlan* wifi_wlan_create(struct wifi_device* device, const char* ifnam
|
||||
/* Interface info */
|
||||
wlan->virtindex = wifi_iface_index(ifname);
|
||||
if (wifi_iface_hwaddr(g_wifiglobal.sock_util, wlan->virtname, wlan->address)) {
|
||||
capwap_logging_warning("Unable to get macaddress: %s", ifname);
|
||||
log_printf(LOG_WARNING, "Unable to get macaddress: %s", ifname);
|
||||
wifi_wlan_destroy(wlan);
|
||||
return NULL;
|
||||
}
|
||||
@ -1652,7 +1652,7 @@ int wifi_wlan_startap(struct wifi_wlan* wlan, struct wlan_startap_params* params
|
||||
result = wlan->device->instance->ops->wlan_startap(wlan);
|
||||
if (!result) {
|
||||
wlan->device->wlanactive++;
|
||||
capwap_logging_info("Configured interface: %s, SSID: '%s'", wlan->virtname, wlan->ssid);
|
||||
log_printf(LOG_INFO, "Configured interface: %s, SSID: '%s'", wlan->virtname, wlan->ssid);
|
||||
} else {
|
||||
wifi_wlan_stopap(wlan);
|
||||
}
|
||||
@ -1839,7 +1839,7 @@ int wifi_wlan_send_frame(struct wifi_wlan* wlan, const uint8_t* data, int length
|
||||
/* Send packet to AC */
|
||||
result = wtp_kmod_send_data(wlan->radioid, data, length, rssi, snr, rate);
|
||||
if (result) {
|
||||
capwap_logging_warning("Unable to sent packet to AC: %d error code", result);
|
||||
log_printf(LOG_WARNING, "Unable to sent packet to AC: %d error code", result);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -222,7 +222,7 @@ static int nl80211_get_multicast_id(struct nl80211_global_handle* globalhandle,
|
||||
if (!result) {
|
||||
result = resource.id;
|
||||
} else {
|
||||
capwap_logging_error("Unable get multicast id, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable get multicast id, error code: %d", result);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -250,7 +250,7 @@ static int nl80211_wlan_set_type(struct wifi_wlan* wlan, uint32_t type) {
|
||||
/* */
|
||||
result = nl80211_send_and_recv_msg(wlanhandle->devicehandle->globalhandle, msg, NULL, NULL);
|
||||
if (result) {
|
||||
capwap_logging_error("Unable set type, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable set type, error code: %d", result);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -293,7 +293,7 @@ static uint32_t nl80211_wlan_get_type(struct wifi_wlan* wlan) {
|
||||
/* */
|
||||
result = nl80211_send_and_recv_msg(wlanhandle->devicehandle->globalhandle, msg, cb_get_type, &type);
|
||||
if (result) {
|
||||
capwap_logging_error("Unable get type, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable get type, error code: %d", result);
|
||||
type = NL80211_IFTYPE_UNSPECIFIED;
|
||||
}
|
||||
|
||||
@ -365,9 +365,9 @@ static int nl80211_device_changefrequency(struct wifi_device* device, struct wif
|
||||
/* Set wifi frequency */
|
||||
result = nl80211_send_and_recv_msg(devicehandle->globalhandle, msg, NULL, NULL);
|
||||
if (!result) {
|
||||
capwap_logging_info("Change %s frequency %d", wlan->virtname, (int)freq->frequency);
|
||||
log_printf(LOG_INFO, "Change %s frequency %d", wlan->virtname, (int)freq->frequency);
|
||||
} else {
|
||||
capwap_logging_error("Unable set frequency %d, error code: %d", (int)freq->frequency, result);
|
||||
log_printf(LOG_ERR, "Unable set frequency %d, error code: %d", (int)freq->frequency, result);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -421,7 +421,7 @@ static int nl80211_wlan_event(struct wifi_wlan* wlan, struct genlmsghdr* gnlh, s
|
||||
}
|
||||
|
||||
default: {
|
||||
capwap_logging_debug("*** nl80211_wlan_event: %d", (int)gnlh->cmd);
|
||||
log_printf(LOG_DEBUG, "*** nl80211_wlan_event: %d", (int)gnlh->cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -483,7 +483,7 @@ static int nl80211_global_destroy_virtdevice(struct nl80211_global_handle* globa
|
||||
/* Destroy virtual device */
|
||||
result = nl80211_send_and_recv_msg(globalhandle, msg, NULL, NULL);
|
||||
if (result) {
|
||||
capwap_logging_error("Unable destroy interface, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable destroy interface, error code: %d", result);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -543,13 +543,13 @@ static void nl80211_global_destroy_all_virtdevice(struct nl80211_global_handle*
|
||||
wifi_iface_down(globalhandle->sock_util, virtitem->virtname);
|
||||
result = nl80211_global_destroy_virtdevice(globalhandle, virtitem->virtindex);
|
||||
if (result) {
|
||||
capwap_logging_error("Unable to destroy virtual device, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable to destroy virtual device, error code: %d", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Error get virtual devices */
|
||||
capwap_logging_error("Unable retrieve virtual device info, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable retrieve virtual device info, error code: %d", result);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -592,7 +592,7 @@ static wifi_wlan_handle nl80211_wlan_create(struct wifi_device* device, struct w
|
||||
|
||||
/* Check interface */
|
||||
if (result || !wifi_iface_index(wlan->virtname)) {
|
||||
capwap_logging_error("Unable create interface %s, error code: %d", wlan->virtname, result);
|
||||
log_printf(LOG_ERR, "Unable create interface %s, error code: %d", wlan->virtname, result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -612,11 +612,11 @@ static void nl80211_global_event_receive_cb(EV_P_ ev_io *w, int revents)
|
||||
(((char *)w) - offsetof(struct nl80211_global_handle, nl_event_ev));
|
||||
int res;
|
||||
|
||||
capwap_logging_warning("nl80211_global_event_receive_cb on fd %d", w->fd);
|
||||
log_printf(LOG_WARNING, "nl80211_global_event_receive_cb on fd %d", w->fd);
|
||||
/* */
|
||||
res = nl_recvmsgs(globalhandle->nl_event, globalhandle->nl_cb);
|
||||
if (res) {
|
||||
capwap_logging_warning("Receive nl80211 message failed: %d", res);
|
||||
log_printf(LOG_WARNING, "Receive nl80211 message failed: %d", res);
|
||||
}
|
||||
}
|
||||
|
||||
@ -626,11 +626,11 @@ static void nl80211_wlan_event_receive_cb(EV_P_ ev_io *w, int revents)
|
||||
(((char *)w) - offsetof(struct nl80211_wlan_handle, nl_ev));
|
||||
int res;
|
||||
|
||||
capwap_logging_warning("nl80211_wlan_event_receive_cb on fd %d", w->fd);
|
||||
log_printf(LOG_WARNING, "nl80211_wlan_event_receive_cb on fd %d", w->fd);
|
||||
/* */
|
||||
res = nl_recvmsgs(wlanhandle->nl, wlanhandle->nl_cb);
|
||||
if (res) {
|
||||
capwap_logging_warning("Receive nl80211 message failed: %d", res);
|
||||
log_printf(LOG_WARNING, "Receive nl80211 message failed: %d", res);
|
||||
}
|
||||
}
|
||||
|
||||
@ -727,7 +727,7 @@ static int nl80211_wlan_setbeacon(struct wifi_wlan* wlan) {
|
||||
/* Start AP */
|
||||
result = nl80211_send_and_recv_msg(wlanhandle->devicehandle->globalhandle, msg, NULL, NULL);
|
||||
if (result) {
|
||||
capwap_logging_error("Unable set beacon, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable set beacon, error code: %d", result);
|
||||
}
|
||||
|
||||
nlmsg_free(msg);
|
||||
@ -767,7 +767,7 @@ static int nl80211_wlan_setbeacon(struct wifi_wlan* wlan) {
|
||||
if (!result) {
|
||||
wlan->flags |= WIFI_WLAN_SET_BEACON;
|
||||
} else {
|
||||
capwap_logging_error("Unable set BSS, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable set BSS, error code: %d", result);
|
||||
}
|
||||
|
||||
nlmsg_free(msg);
|
||||
@ -809,7 +809,7 @@ static int nl80211_wlan_startap(struct wifi_wlan* wlan) {
|
||||
for (i = 0; i < sizeof(g_stypes) / sizeof(g_stypes[0]); i++) {
|
||||
result = nl80211_wlan_registerframe(wlan, (IEEE80211_FRAMECONTROL_TYPE_MGMT << 2) | (g_stypes[i] << 4), NULL, 0);
|
||||
if (result) {
|
||||
capwap_logging_error("Unable to register frame %d, error code: %d", g_stypes[i], result);
|
||||
log_printf(LOG_ERR, "Unable to register frame %d, error code: %d", g_stypes[i], result);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -820,9 +820,9 @@ static int nl80211_wlan_startap(struct wifi_wlan* wlan) {
|
||||
uint32_t flags = ((wlan->tunnelmode == CAPWAP_ADD_WLAN_TUNNELMODE_80211) ? WTP_KMOD_FLAGS_TUNNEL_NATIVE : WTP_KMOD_FLAGS_TUNNEL_8023);
|
||||
|
||||
if (!wtp_kmod_join_mac80211_device(wlan, flags)) {
|
||||
capwap_logging_info("Joined the interface %d in kernel mode ", wlan->virtindex);
|
||||
log_printf(LOG_INFO, "Joined the interface %d in kernel mode ", wlan->virtindex);
|
||||
} else {
|
||||
capwap_logging_error("Unable to join the interface %d in kernel mode ", wlan->virtindex);
|
||||
log_printf(LOG_ERR, "Unable to join the interface %d in kernel mode ", wlan->virtindex);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -974,7 +974,7 @@ static int nl80211_wlan_sendframe(struct wifi_wlan* wlan, uint8_t* frame, int le
|
||||
cookie = 0;
|
||||
result = nl80211_send_and_recv_msg(wlanhandle->devicehandle->globalhandle, msg, cb_wlan_send_frame, &cookie);
|
||||
if (result) {
|
||||
capwap_logging_error("Unable send frame, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable send frame, error code: %d", result);
|
||||
}
|
||||
|
||||
nlmsg_free(msg);
|
||||
@ -1092,13 +1092,13 @@ int nl80211_station_authorize(struct wifi_wlan* wlan, struct wifi_station* stati
|
||||
if (result == -EEXIST) {
|
||||
result = 0;
|
||||
} else {
|
||||
capwap_logging_error("Unable to authorized station, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable to authorized station, error code: %d", result);
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
if (!result) {
|
||||
capwap_logging_info("Authorized station: %s", station->addrtext);
|
||||
log_printf(LOG_INFO, "Authorized station: %s", station->addrtext);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -1134,14 +1134,14 @@ int nl80211_station_deauthorize(struct wifi_wlan* wlan, const uint8_t* address)
|
||||
if (result == -ENOENT) {
|
||||
result = 0;
|
||||
} else {
|
||||
capwap_logging_error("Unable delete station, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable delete station, error code: %d", result);
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
if (!result) {
|
||||
char addrtext[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
capwap_logging_info("Deauthorize station: %s", capwap_printf_macaddress(addrtext, address, MACADDRESS_EUI48_LENGTH));
|
||||
log_printf(LOG_INFO, "Deauthorize station: %s", capwap_printf_macaddress(addrtext, address, MACADDRESS_EUI48_LENGTH));
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -1214,7 +1214,7 @@ int nl80211_device_init(wifi_global_handle handle, struct wifi_device* device) {
|
||||
}
|
||||
} else {
|
||||
/* Error get physical devices */
|
||||
capwap_logging_error("Unable retrieve physical device info, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable retrieve physical device info, error code: %d", result);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -1442,7 +1442,7 @@ static int cb_get_phydevice_capability(struct nl_msg* msg, void* data) {
|
||||
if (bandcap->band == WIFI_BAND_UNKNOWN) {
|
||||
bandcap->band = band;
|
||||
} else if (bandcap->band != band) {
|
||||
capwap_logging_warning("Multiple wireless band into logical band");
|
||||
log_printf(LOG_WARNING, "Multiple wireless band into logical band");
|
||||
}
|
||||
|
||||
/* Retrieve frequency and channel */
|
||||
@ -1552,7 +1552,7 @@ static int nl80211_device_getcapability(struct wifi_device* device, struct wifi_
|
||||
capability->device = device;
|
||||
result = nl80211_send_and_recv_msg(devicehandle->globalhandle, msg, cb_get_phydevice_capability, capability);
|
||||
if (result) {
|
||||
capwap_logging_error("Unable retrieve physical device capability, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable retrieve physical device capability, error code: %d", result);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -1573,7 +1573,7 @@ static void nl80211_device_updatebeacons(struct wifi_device* device) {
|
||||
wlan = (struct wifi_wlan*)wlansearch->item;
|
||||
if (wlan->flags & WIFI_WLAN_SET_BEACON) {
|
||||
if (nl80211_wlan_setbeacon(wlan)) {
|
||||
capwap_logging_warning("Unable to update beacon on interface %d", wlan->virtindex);
|
||||
log_printf(LOG_WARNING, "Unable to update beacon on interface %d", wlan->virtindex);
|
||||
wifi_wlan_stopap(wlan);
|
||||
}
|
||||
}
|
||||
@ -1648,7 +1648,7 @@ static int nl80211_device_settxqueue(struct wifi_device* device, int queue, int
|
||||
|
||||
result = nl80211_send_and_recv_msg(devicehandle->globalhandle, msg, NULL, NULL);
|
||||
if (result)
|
||||
capwap_logging_error("Unable set TX Queue, error code: %d", result);
|
||||
log_printf(LOG_ERR, "Unable set TX Queue, error code: %d", result);
|
||||
|
||||
nlmsg_free(msg);
|
||||
return result;
|
||||
@ -1837,7 +1837,7 @@ static wifi_global_handle nl80211_global_init()
|
||||
/* Get nl80211 netlink family */
|
||||
globalhandle->nl80211_id = genl_ctrl_resolve(globalhandle->nl, "nl80211");
|
||||
if (globalhandle->nl80211_id < 0) {
|
||||
capwap_logging_warning("Unable to found mac80211 kernel module");
|
||||
log_printf(LOG_WARNING, "Unable to found mac80211 kernel module");
|
||||
nl80211_global_deinit((wifi_global_handle)globalhandle);
|
||||
return NULL;
|
||||
}
|
||||
|
138
src/wtp/wtp.c
138
src/wtp/wtp.c
@ -208,67 +208,67 @@ static int wtp_parsing_radio_80211n_cfg(config_setting_t *elem,
|
||||
|
||||
sect = config_setting_get_member(elem, "ieee80211n");
|
||||
if (!sect) {
|
||||
capwap_logging_error("application.radio.ieee80211n not found");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
radio->n_radio_cfg.radioid = radio->radioid;
|
||||
|
||||
if (config_setting_lookup_bool(sect, "a-msdu", &boolval) != CONFIG_TRUE) {
|
||||
capwap_logging_error("application.radio.ieee80211n.a-msdu not found or wrong type");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n.a-msdu not found or wrong type");
|
||||
return 0;
|
||||
}
|
||||
if (boolval)
|
||||
radio->n_radio_cfg.flags |= CAPWAP_80211N_RADIO_CONF_A_MSDU;
|
||||
|
||||
if (config_setting_lookup_bool(sect, "a-mpdu", &boolval) != CONFIG_TRUE) {
|
||||
capwap_logging_error("application.radio.ieee80211n.a-mpdu not found or wrong type");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n.a-mpdu not found or wrong type");
|
||||
return 0;
|
||||
}
|
||||
if (boolval)
|
||||
radio->n_radio_cfg.flags |= CAPWAP_80211N_RADIO_CONF_A_MPDU;
|
||||
|
||||
if (config_setting_lookup_bool(sect, "require-ht", &boolval) != CONFIG_TRUE) {
|
||||
capwap_logging_error("application.radio.ieee80211n.require-ht not found or wrong type");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n.require-ht not found or wrong type");
|
||||
return 0;
|
||||
}
|
||||
if (boolval)
|
||||
radio->n_radio_cfg.flags |= CAPWAP_80211N_RADIO_CONF_11N_ONLY;
|
||||
|
||||
if (config_setting_lookup_bool(sect, "short-gi", &boolval) != CONFIG_TRUE) {
|
||||
capwap_logging_error("application.radio.ieee80211n.short-gi not found or wrong type");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n.short-gi not found or wrong type");
|
||||
return 0;
|
||||
}
|
||||
if (boolval)
|
||||
radio->n_radio_cfg.flags |= CAPWAP_80211N_RADIO_CONF_SHORT_GUARD_INTERVAL;
|
||||
|
||||
if (config_setting_lookup_bool(sect, "ht40", &boolval) != CONFIG_TRUE) {
|
||||
capwap_logging_error("application.radio.ieee80211n.ht40 not found or wrong type");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n.ht40 not found or wrong type");
|
||||
return 0;
|
||||
}
|
||||
if (!boolval)
|
||||
radio->n_radio_cfg.flags |= CAPWAP_80211N_RADIO_CONF_20MHZ_BANDWITH;
|
||||
|
||||
if (config_setting_lookup_int(sect, "max-sup-mcs", &intval) != CONFIG_TRUE) {
|
||||
capwap_logging_error("application.radio.ieee80211n.max-sup-mcs not found or wrong type");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n.max-sup-mcs not found or wrong type");
|
||||
return 0;
|
||||
}
|
||||
radio->n_radio_cfg.maxsupmcs = intval;
|
||||
|
||||
if (config_setting_lookup_int(sect, "max-mand-mcs", &intval) != CONFIG_TRUE) {
|
||||
capwap_logging_error("application.radio.ieee80211n.max-mand-mcs not found or wrong type");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n.max-mand-mcs not found or wrong type");
|
||||
return 0;
|
||||
}
|
||||
radio->n_radio_cfg.maxmandmcs = intval;
|
||||
|
||||
if (config_setting_lookup_int(sect, "tx-antenna", &intval) != CONFIG_TRUE) {
|
||||
capwap_logging_error("application.radio.ieee80211n.tx-antenna not found or wrong type");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n.tx-antenna not found or wrong type");
|
||||
return 0;
|
||||
}
|
||||
radio->n_radio_cfg.txant = intval;
|
||||
|
||||
if (config_setting_lookup_int(sect, "rx-antenna", &intval) != CONFIG_TRUE) {
|
||||
capwap_logging_error("application.radio.ieee80211n.rx-antenna not found or wrong type");
|
||||
log_printf(LOG_ERR, "application.radio.ieee80211n.rx-antenna not found or wrong type");
|
||||
return 0;
|
||||
}
|
||||
radio->n_radio_cfg.rxant = intval;
|
||||
@ -559,7 +559,7 @@ static int wtp_parsing_radio_section_configuration(config_setting_t* configSetti
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!IS_VALID_RADIOID(g_wtp.radios->count + 1)) {
|
||||
capwap_logging_error("Exceeded max number of radio device");
|
||||
log_printf(LOG_ERR, "Exceeded max number of radio device");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -569,12 +569,12 @@ static int wtp_parsing_radio_section_configuration(config_setting_t* configSetti
|
||||
continue;
|
||||
|
||||
if (config_setting_lookup_string(configElement, "device", &configString) != CONFIG_TRUE) {
|
||||
capwap_logging_error("Invalid configuration file, element application.radio.device not found");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, element application.radio.device not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*configString && (strlen(configString) >= IFNAMSIZ)) {
|
||||
capwap_logging_error("Invalid configuration file, application.radio.device string length exceeded");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, application.radio.device string length exceeded");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -588,7 +588,7 @@ static int wtp_parsing_radio_section_configuration(config_setting_t* configSetti
|
||||
|
||||
/* Retrieve radio capability */
|
||||
if (wtp_parsing_radio_configuration(configElement, radio) == 0) {
|
||||
capwap_logging_error("Invalid configuration file, application.radio");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, application.radio");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -601,11 +601,11 @@ static int wtp_parsing_radio_section_configuration(config_setting_t* configSetti
|
||||
radio->devicehandle = wifi_device_connect(radio->device, configString);
|
||||
if (!radio->devicehandle) {
|
||||
radio->status = WTP_RADIO_HWFAILURE;
|
||||
capwap_logging_warning("Unable to register radio device: %s - %s", radio->device, configString);
|
||||
log_printf(LOG_WARNING, "Unable to register radio device: %s - %s", radio->device, configString);
|
||||
}
|
||||
|
||||
radio->status = WTP_RADIO_ENABLED;
|
||||
capwap_logging_info("Register radioid %d with radio device: %s - %s", radio->radioid, radio->device, configString);
|
||||
log_printf(LOG_INFO, "Register radioid %d with radio device: %s - %s", radio->radioid, radio->device, configString);
|
||||
|
||||
/* Update radio capability with device query */
|
||||
capability = wifi_device_getcapability(radio->devicehandle);
|
||||
@ -621,7 +621,7 @@ static int wtp_parsing_radio_section_configuration(config_setting_t* configSetti
|
||||
|
||||
sprintf(wlanname, "%s%02d.%02d", radio->wlanprefix, (int)radio->radioid, (int)bssid + 1);
|
||||
if (wifi_iface_index(wlanname)) {
|
||||
capwap_logging_error("interface %s already exists", wlanname);
|
||||
log_printf(LOG_ERR, "interface %s already exists", wlanname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -631,11 +631,11 @@ static int wtp_parsing_radio_section_configuration(config_setting_t* configSetti
|
||||
wlan->radio = radio;
|
||||
wlan->wlanhandle = wifi_wlan_create(radio->devicehandle, wlanname);
|
||||
if (!wlan->wlanhandle) {
|
||||
capwap_logging_error("Unable to create interface: %s", wlanname);
|
||||
log_printf(LOG_ERR, "Unable to create interface: %s", wlanname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
capwap_logging_debug("Created wlan interface: %s", wlanname);
|
||||
log_printf(LOG_DEBUG, "Created wlan interface: %s", wlanname);
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,18 +670,18 @@ static int wtp_parsing_cfg_boardinfo_element(config_t *config)
|
||||
continue;
|
||||
|
||||
if (config_setting_lookup_string(configElement, "name", &configName) != CONFIG_TRUE) {
|
||||
capwap_logging_error("Invalid configuration file, element application.boardinfo.element.name not found");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, element application.boardinfo.element.name not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (config_setting_lookup_string(configElement, "value", &configValue) != CONFIG_TRUE) {
|
||||
capwap_logging_error("Invalid configuration file, element application.boardinfo.element.value not found");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, element application.boardinfo.element.value not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
lengthValue = strlen(configValue);
|
||||
if (lengthValue >= CAPWAP_BOARD_SUBELEMENT_MAXDATA) {
|
||||
capwap_logging_error("Invalid configuration file, application.boardinfo.element.value string length exceeded");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, application.boardinfo.element.value string length exceeded");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -707,7 +707,7 @@ static int wtp_parsing_cfg_boardinfo_element(config_t *config)
|
||||
const char* configType;
|
||||
|
||||
if (config_setting_lookup_string(configElement, "type", &configType) != CONFIG_TRUE) {
|
||||
capwap_logging_error("Invalid configuration file, element application.boardinfo.element.type not found");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, element application.boardinfo.element.type not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -718,17 +718,17 @@ static int wtp_parsing_cfg_boardinfo_element(config_t *config)
|
||||
element->type = CAPWAP_BOARD_SUBELEMENT_MACADDRESS;
|
||||
element->length = capwap_get_macaddress_from_interface(configValue, macaddress);
|
||||
if (!element->length || ((element->length != MACADDRESS_EUI64_LENGTH) && (element->length != MACADDRESS_EUI48_LENGTH))) {
|
||||
capwap_logging_error("Invalid configuration file, unable found macaddress of interface: '%s'", configValue);
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unable found macaddress of interface: '%s'", configValue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
element->data = (uint8_t*)capwap_clone((void*)macaddress, element->length);
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.boardinfo.element.type value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown application.boardinfo.element.type value");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.boardinfo.element.name value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown application.boardinfo.element.name value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -761,23 +761,23 @@ static int wtp_parsing_cfg_descriptor_info(config_t *config)
|
||||
continue;
|
||||
|
||||
if (config_setting_lookup_int(configElement, "idvendor", &configVendor) != CONFIG_TRUE) {
|
||||
capwap_logging_error("Invalid configuration file, element application.descriptor.info.idvendor not found");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, element application.descriptor.info.idvendor not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (config_setting_lookup_string(configElement, "type", &configType) != CONFIG_TRUE) {
|
||||
capwap_logging_error("Invalid configuration file, element application.descriptor.info.type not found");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, element application.descriptor.info.type not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (config_setting_lookup_string(configElement, "value", &configValue) != CONFIG_TRUE) {
|
||||
capwap_logging_error("Invalid configuration file, element application.descriptor.info.value not found");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, element application.descriptor.info.value not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
lengthValue = strlen(configValue);
|
||||
if (lengthValue >= CAPWAP_WTPDESC_SUBELEMENT_MAXDATA) {
|
||||
capwap_logging_error("Invalid configuration file, application.descriptor.info.value string length exceeded");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, application.descriptor.info.value string length exceeded");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -790,7 +790,7 @@ static int wtp_parsing_cfg_descriptor_info(config_t *config)
|
||||
} else if (!strcmp(configType, "other")) {
|
||||
type = CAPWAP_WTPDESC_SUBELEMENT_OTHERVERSION;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.descriptor.info.type value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown application.descriptor.info.type value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -829,7 +829,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
} else if (!strcmp(configString, "debug")) {
|
||||
capwap_logging_verboselevel(LOG_DEBUG);
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown logging.level value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown logging.level value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -851,7 +851,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
} else if (!strcmp(configString, "stderr")) {
|
||||
capwap_logging_enable_console(1);
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown logging.output value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown logging.output value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -868,7 +868,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
/* Set name of WTP */
|
||||
if (config_lookup_string(config, "application.name", &configString) == CONFIG_TRUE) {
|
||||
if (strlen(configString) > CAPWAP_WTPNAME_MAXLENGTH) {
|
||||
capwap_logging_error("Invalid configuration file, application.name string length exceeded");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, application.name string length exceeded");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -879,7 +879,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
/* Set location of WTP */
|
||||
if (config_lookup_string(config, "application.location", &configString) == CONFIG_TRUE) {
|
||||
if (strlen(configString) > CAPWAP_LOCATION_MAXLENGTH) {
|
||||
capwap_logging_error("Invalid configuration file, application.location string length exceeded");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, application.location string length exceeded");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -894,7 +894,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
} else if (!strcmp(configString, "EPCGlobal")) {
|
||||
g_wtp.binding = CAPWAP_WIRELESS_BINDING_EPCGLOBAL;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.binding value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown application.binding value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -907,9 +907,9 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
|
||||
case CAPWAP_WIRELESS_BINDING_IEEE80211: {
|
||||
/* Initialize wifi binding driver */
|
||||
capwap_logging_info("Initializing wifi binding engine");
|
||||
log_printf(LOG_INFO, "Initializing wifi binding engine");
|
||||
if (wifi_driver_init()) {
|
||||
capwap_logging_fatal("Unable initialize wifi binding engine");
|
||||
log_printf(LOG_EMERG, "Unable initialize wifi binding engine");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -917,7 +917,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
}
|
||||
|
||||
default: {
|
||||
capwap_logging_fatal("Unable initialize unknown binding engine: %hu", g_wtp.binding);
|
||||
log_printf(LOG_EMERG, "Unable initialize unknown binding engine: %hu", g_wtp.binding);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -951,7 +951,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
} else if (!strcmp(configString, "splitmac")) {
|
||||
g_wtp.mactype.type = CAPWAP_SPLITMAC;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.mactype value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown application.mactype value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -972,7 +972,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
if ((length > 0) && (length < WTP_PREFIX_NAME_MAX_LENGTH)) {
|
||||
strcpy(g_wtp.wlanprefix, configString);
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, wlan.prefix string length exceeded");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, wlan.prefix string length exceeded");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -999,7 +999,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
} else if (!strcmp(encryption, "802.11_TKIP")) {
|
||||
capability |= 0; /* TODO */
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, invalid application.descriptor.encryption value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, invalid application.descriptor.encryption value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1011,7 +1011,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
encrypt->wbid = g_wtp.binding;
|
||||
encrypt->capabilities = capability;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, application.descriptor.encryption not found");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, application.descriptor.encryption not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1026,7 +1026,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
} else if (!strcmp(configString, "limited")) {
|
||||
g_wtp.ecn.flag = CAPWAP_LIMITED_ECN_SUPPORT;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.ecn value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown application.ecn value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1036,7 +1036,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
if ((configInt > 0) && (configInt < 65536)) {
|
||||
g_wtp.statisticstimer.timer = (unsigned short)configInt;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, invalid application.timer.statistics value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, invalid application.timer.statistics value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1073,7 +1073,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
} else if (!strcmp(configString, "presharedkey")) {
|
||||
dtlsparam.mode = CAPWAP_DTLS_MODE_PRESHAREDKEY;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.dtls.type value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown application.dtls.type value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1156,7 +1156,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
/* Set interface binding of WTP */
|
||||
if (config_lookup_string(config, "application.network.binding", &configString) == CONFIG_TRUE) {
|
||||
if (strlen(configString) > (IFNAMSIZ - 1)) {
|
||||
capwap_logging_error("Invalid configuration file, application.network.binding string length exceeded");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, application.network.binding string length exceeded");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1168,7 +1168,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
if ((configInt > 0) && (configInt < 65536)) {
|
||||
g_wtp.mtu = (unsigned short)configInt;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, invalid application.network.mtu value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, invalid application.network.mtu value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1180,7 +1180,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
} else if (!strcmp(configString, "udplite")) {
|
||||
g_wtp.transport.type = CAPWAP_UDPLITE_TRANSPORT;
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unknown application.network.transport value");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unknown application.network.transport value");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1211,7 +1211,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
acaddr.resolved = 1;
|
||||
g_wtp.discoverytype.type = CAPWAP_DISCOVERYTYPE_TYPE_STATIC;
|
||||
} else {
|
||||
capwap_logging_info("%s:%d Could not resolve application.acdiscovery.host %s", __FILE__, __LINE__, address);
|
||||
log_printf(LOG_INFO, "%s:%d Could not resolve application.acdiscovery.host %s", __FILE__, __LINE__, address);
|
||||
}
|
||||
memcpy(capwap_array_get_item_pointer(g_wtp.acdiscoveryarray, g_wtp.acdiscoveryarray->count), &acaddr, sizeof(struct addr_capwap));
|
||||
}
|
||||
@ -1238,7 +1238,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
||||
}
|
||||
acaddr.resolved = 1;
|
||||
} else {
|
||||
capwap_logging_info("%s:%d Could not resolve application.acprefered.host %s", __FILE__, __LINE__, acaddr.fqdn);
|
||||
log_printf(LOG_INFO, "%s:%d Could not resolve application.acprefered.host %s", __FILE__, __LINE__, acaddr.fqdn);
|
||||
}
|
||||
memcpy(capwap_array_get_item_pointer(g_wtp.acpreferedarray, g_wtp.acpreferedarray->count), &acaddr, sizeof(struct addr_capwap));
|
||||
}
|
||||
@ -1257,9 +1257,9 @@ static int wtp_parsing_configuration(config_t* config) {
|
||||
return wtp_parsing_configuration_1_0(config);
|
||||
}
|
||||
|
||||
capwap_logging_error("Invalid configuration file, '%s' is not supported", configString);
|
||||
log_printf(LOG_ERR, "Invalid configuration file, '%s' is not supported", configString);
|
||||
} else {
|
||||
capwap_logging_error("Invalid configuration file, unable to found version tag");
|
||||
log_printf(LOG_ERR, "Invalid configuration file, unable to found version tag");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1287,7 +1287,7 @@ static int wtp_load_configuration(int argc, char **argv) {
|
||||
if (strlen(optarg) < sizeof(g_configurationfile)) {
|
||||
strcpy(g_configurationfile, optarg);
|
||||
} else {
|
||||
capwap_logging_error("Invalid -%c argument", optopt);
|
||||
log_printf(LOG_ERR, "Invalid -%c argument", optopt);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1296,9 +1296,9 @@ static int wtp_load_configuration(int argc, char **argv) {
|
||||
|
||||
case '?': {
|
||||
if (optopt == 'c') {
|
||||
capwap_logging_error("Option -%c requires an argument", optopt);
|
||||
log_printf(LOG_ERR, "Option -%c requires an argument", optopt);
|
||||
} else {
|
||||
capwap_logging_error("Unknown option character `\\x%x'", optopt);
|
||||
log_printf(LOG_ERR, "Unknown option character `\\x%x'", optopt);
|
||||
}
|
||||
|
||||
wtp_print_usage();
|
||||
@ -1315,7 +1315,7 @@ static int wtp_load_configuration(int argc, char **argv) {
|
||||
result = wtp_parsing_configuration(&config);
|
||||
} else {
|
||||
result = -1;
|
||||
capwap_logging_error("Unable load the configuration file '%s': %s (%d)", g_configurationfile, config_error_text(&config), config_error_line(&config));
|
||||
log_printf(LOG_ERR, "Unable load the configuration file '%s': %s (%d)", g_configurationfile, config_error_text(&config), config_error_line(&config));
|
||||
}
|
||||
|
||||
/* Free libconfig */
|
||||
@ -1337,7 +1337,7 @@ static int wtp_configure(void) {
|
||||
|
||||
/* Bind control address */
|
||||
if (capwap_bind_sockets(&g_wtp.net)) {
|
||||
capwap_logging_fatal("Cannot bind control address");
|
||||
log_printf(LOG_EMERG, "Cannot bind control address");
|
||||
return WTP_ERROR_NETWORK;
|
||||
}
|
||||
wtp_socket_io_start();
|
||||
@ -1382,7 +1382,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
/* Init capwap */
|
||||
if (geteuid() != 0) {
|
||||
capwap_logging_fatal("Request root privileges");
|
||||
log_printf(LOG_EMERG, "Request root privileges");
|
||||
result = CAPWAP_REQUEST_ROOT;
|
||||
|
||||
goto out_close_log;
|
||||
@ -1394,7 +1394,7 @@ int main(int argc, char** argv) {
|
||||
/* Init crypt */
|
||||
if (capwap_crypt_init()) {
|
||||
result = CAPWAP_CRYPT_ERROR;
|
||||
capwap_logging_fatal("Error to init crypt engine");
|
||||
log_printf(LOG_EMERG, "Error to init crypt engine");
|
||||
|
||||
goto out_check_memory;
|
||||
}
|
||||
@ -1402,7 +1402,7 @@ int main(int argc, char** argv) {
|
||||
/* Init WTP */
|
||||
if (!wtp_init()) {
|
||||
result = WTP_ERROR_SYSTEM_FAILER;
|
||||
capwap_logging_fatal("Error to init WTP engine");
|
||||
log_printf(LOG_EMERG, "Error to init WTP engine");
|
||||
|
||||
goto out_release_crypto;
|
||||
}
|
||||
@ -1411,7 +1411,7 @@ int main(int argc, char** argv) {
|
||||
value = wtp_load_configuration(argc, argv);
|
||||
if (value < 0) {
|
||||
result = WTP_ERROR_LOAD_CONFIGURATION;
|
||||
capwap_logging_fatal("Error to load configuration");
|
||||
log_printf(LOG_EMERG, "Error to load configuration");
|
||||
|
||||
goto out_destroy_wtp;
|
||||
} else if (value == 0)
|
||||
@ -1423,23 +1423,23 @@ int main(int argc, char** argv) {
|
||||
|
||||
/* Console logging is disabled in daemon mode */
|
||||
capwap_logging_disable_console();
|
||||
capwap_logging_info("Running WTP in daemon mode");
|
||||
log_printf(LOG_INFO, "Running WTP in daemon mode");
|
||||
}
|
||||
|
||||
/* Wait the initialization of radio interfaces */
|
||||
capwap_logging_info("Wait for the initialization of radio interfaces");
|
||||
log_printf(LOG_INFO, "Wait for the initialization of radio interfaces");
|
||||
wtp_wait_radio_ready();
|
||||
|
||||
/* Connect WTP with kernel module */
|
||||
if (wtp_kmod_init()) {
|
||||
capwap_logging_fatal("Unable to connect with kernel module");
|
||||
log_printf(LOG_EMERG, "Unable to connect with kernel module");
|
||||
goto out_close_radio;
|
||||
}
|
||||
|
||||
capwap_logging_info("SmartCAPWAP kernel module connected");
|
||||
log_printf(LOG_INFO, "SmartCAPWAP kernel module connected");
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Startup WTP");
|
||||
log_printf(LOG_INFO, "Startup WTP");
|
||||
|
||||
/* Complete configuration WTP */
|
||||
result = wtp_configure();
|
||||
@ -1457,7 +1457,7 @@ int main(int argc, char** argv) {
|
||||
wtp_kmod_free();
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Terminate WTP");
|
||||
log_printf(LOG_INFO, "Terminate WTP");
|
||||
|
||||
out_close_radio:
|
||||
/* Close radio */
|
||||
@ -1465,7 +1465,7 @@ out_close_radio:
|
||||
|
||||
/* Free binding */
|
||||
if (g_wtp.binding == CAPWAP_WIRELESS_BINDING_IEEE80211) {
|
||||
capwap_logging_info("Free wifi binding engine");
|
||||
log_printf(LOG_INFO, "Free wifi binding engine");
|
||||
wifi_driver_free();
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ static void wtp_dfa_execute(struct capwap_parsed_packet* packet)
|
||||
|
||||
if (!is_valid_state(g_wtp.state) ||
|
||||
!dfa_states[g_wtp.state].state_execute) {
|
||||
capwap_logging_debug("Got packet in invalid WTP state: %lu", g_wtp.state);
|
||||
log_printf(LOG_DEBUG, "Got packet in invalid WTP state: %lu", g_wtp.state);
|
||||
wtp_teardown_connection();
|
||||
} else
|
||||
dfa_states[g_wtp.state].state_execute(packet);
|
||||
@ -157,7 +157,7 @@ static void wtp_dfa_process_packet(void *buffer, int buffersize,
|
||||
/* Check source */
|
||||
if (g_wtp.state != CAPWAP_DISCOVERY_STATE &&
|
||||
capwap_compare_ip(&g_wtp.dtls.peeraddr, fromaddr)) {
|
||||
capwap_logging_debug("CAPWAP packet from unknown WTP when not in DISCOVERY, drop packet");
|
||||
log_printf(LOG_DEBUG, "CAPWAP packet from unknown WTP when not in DISCOVERY, drop packet");
|
||||
return; /* Unknown source */
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ static void wtp_dfa_process_packet(void *buffer, int buffersize,
|
||||
}
|
||||
|
||||
case CAPWAP_WRONG_PACKET:
|
||||
capwap_logging_debug("Warning: sanity check failure");
|
||||
log_printf(LOG_DEBUG, "Warning: sanity check failure");
|
||||
/* Drop packet */
|
||||
return;
|
||||
|
||||
@ -203,7 +203,7 @@ static void wtp_dfa_process_packet(void *buffer, int buffersize,
|
||||
/* TODO: Really? Previosly, this was hidden in the
|
||||
* overly deep indention, check if that is correct */
|
||||
|
||||
capwap_logging_debug("Warning: wtp_dfa_running took default fall through");
|
||||
log_printf(LOG_DEBUG, "Warning: wtp_dfa_running took default fall through");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -226,9 +226,9 @@ static void wtp_dfa_process_packet(void *buffer, int buffersize,
|
||||
g_wtp.remoteseqnumber == rxmngpacket->ctrlmsg.seq) {
|
||||
/* Retransmit response */
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.responsefragmentpacket)) {
|
||||
capwap_logging_error("Error to resend response packet");
|
||||
log_printf(LOG_ERR, "Error to resend response packet");
|
||||
} else {
|
||||
capwap_logging_debug("Retransmitted control packet");
|
||||
log_printf(LOG_DEBUG, "Retransmitted control packet");
|
||||
}
|
||||
|
||||
/* Discard fragments */
|
||||
@ -240,11 +240,11 @@ static void wtp_dfa_process_packet(void *buffer, int buffersize,
|
||||
res = capwap_check_message_type(rxmngpacket);
|
||||
if (res != VALID_MESSAGE_TYPE) {
|
||||
if (res == INVALID_REQUEST_MESSAGE_TYPE) {
|
||||
capwap_logging_warning("Unexpected Unrecognized Request, send Response Packet with error");
|
||||
log_printf(LOG_WARNING, "Unexpected Unrecognized Request, send Response Packet with error");
|
||||
wtp_send_invalid_request(rxmngpacket, CAPWAP_RESULTCODE_MSG_UNEXPECTED_UNRECOGNIZED_REQUEST);
|
||||
}
|
||||
|
||||
capwap_logging_debug("Invalid message type");
|
||||
log_printf(LOG_DEBUG, "Invalid message type");
|
||||
wtp_free_packet_rxmng();
|
||||
return;
|
||||
}
|
||||
@ -257,13 +257,13 @@ static void wtp_dfa_process_packet(void *buffer, int buffersize,
|
||||
if (res != PARSING_COMPLETE) {
|
||||
if (res == UNRECOGNIZED_MESSAGE_ELEMENT &&
|
||||
capwap_is_request_type(rxmngpacket->ctrlmsg.type)) {
|
||||
capwap_logging_warning("Unrecognized Message Element, send Response Packet with error");
|
||||
log_printf(LOG_WARNING, "Unrecognized Message Element, send Response Packet with error");
|
||||
wtp_send_invalid_request(rxmngpacket, CAPWAP_RESULTCODE_FAILURE_UNRECOGNIZED_MESSAGE_ELEMENT);
|
||||
/* TODO: add the unrecognized message element */
|
||||
}
|
||||
|
||||
/* */
|
||||
capwap_logging_debug("Failed parsing packet");
|
||||
log_printf(LOG_DEBUG, "Failed parsing packet");
|
||||
capwap_free_parsed_packet(&packet);
|
||||
wtp_free_packet_rxmng();
|
||||
return;
|
||||
@ -272,12 +272,12 @@ static void wtp_dfa_process_packet(void *buffer, int buffersize,
|
||||
/* Validate packet */
|
||||
if (capwap_validate_parsed_packet(&packet, NULL)) {
|
||||
if (capwap_is_request_type(rxmngpacket->ctrlmsg.type)) {
|
||||
capwap_logging_warning("Missing Mandatory Message Element, send Response Packet with error");
|
||||
log_printf(LOG_WARNING, "Missing Mandatory Message Element, send Response Packet with error");
|
||||
wtp_send_invalid_request(rxmngpacket, CAPWAP_RESULTCODE_FAILURE_MISSING_MANDATORY_MSG_ELEMENT);
|
||||
}
|
||||
|
||||
/* */
|
||||
capwap_logging_debug("Failed validation parsed packet");
|
||||
log_printf(LOG_DEBUG, "Failed validation parsed packet");
|
||||
capwap_free_parsed_packet(&packet);
|
||||
wtp_free_packet_rxmng();
|
||||
return;
|
||||
@ -314,7 +314,7 @@ int wtp_dfa_running()
|
||||
|
||||
void wtp_socket_io_start()
|
||||
{
|
||||
capwap_logging_debug("Start EV_IO on socket %d", g_wtp.net.socket);
|
||||
log_printf(LOG_DEBUG, "Start EV_IO on socket %d", g_wtp.net.socket);
|
||||
|
||||
/* Configure libev struct */
|
||||
ev_io_init (&g_wtp.socket_ev, capwap_control_cb, g_wtp.net.socket, EV_READ);
|
||||
@ -323,7 +323,7 @@ void wtp_socket_io_start()
|
||||
|
||||
void wtp_socket_io_stop()
|
||||
{
|
||||
capwap_logging_debug("Stop EV_IO on socket %d", g_wtp.socket_ev.fd);
|
||||
log_printf(LOG_DEBUG, "Stop EV_IO on socket %d", g_wtp.socket_ev.fd);
|
||||
|
||||
ev_io_stop(EV_DEFAULT_UC_ &g_wtp.socket_ev);
|
||||
}
|
||||
@ -338,14 +338,14 @@ static void capwap_control_cb(EV_P_ ev_io *w, int revents)
|
||||
while (42) {
|
||||
/* If request wait packet from AC */
|
||||
do {
|
||||
capwap_logging_debug("Receive CAPWAP Control Channel message");
|
||||
log_printf(LOG_DEBUG, "Receive CAPWAP Control Channel message");
|
||||
r = capwap_recvfrom(w->fd, &buffer, sizeof(buffer),
|
||||
&fromaddr, &toaddr);
|
||||
} while (r < 0 && errno == EINTR);
|
||||
capwap_logging_debug("WTP got data: r: %zd", r);
|
||||
log_printf(LOG_DEBUG, "WTP got data: r: %zd", r);
|
||||
|
||||
if (!g_wtp.running) {
|
||||
capwap_logging_debug("Closing WTP, Teardown connection");
|
||||
log_printf(LOG_DEBUG, "Closing WTP, Teardown connection");
|
||||
|
||||
ev_io_stop (EV_A_ w);
|
||||
break;
|
||||
@ -353,7 +353,7 @@ static void capwap_control_cb(EV_P_ ev_io *w, int revents)
|
||||
|
||||
if (r < 0) {
|
||||
if (errno != EAGAIN) {
|
||||
capwap_logging_debug("capwap_control_cb I/O error %m, exiting loop");
|
||||
log_printf(LOG_DEBUG, "capwap_control_cb I/O error %m, exiting loop");
|
||||
ev_io_stop (EV_A_ w);
|
||||
ev_break (EV_A_ EVBREAK_ONE);
|
||||
}
|
||||
@ -361,7 +361,7 @@ static void capwap_control_cb(EV_P_ ev_io *w, int revents)
|
||||
}
|
||||
|
||||
if (g_wtp.teardown) {
|
||||
capwap_logging_debug("WTP is in teardown, drop packet");
|
||||
log_printf(LOG_DEBUG, "WTP is in teardown, drop packet");
|
||||
continue; /* Drop packet */
|
||||
}
|
||||
|
||||
@ -372,7 +372,7 @@ static void capwap_control_cb(EV_P_ ev_io *w, int revents)
|
||||
/* Change WTP state machine */
|
||||
void wtp_dfa_change_state(int state) {
|
||||
if (state != g_wtp.state) {
|
||||
capwap_logging_debug("WTP change state from %s to %s",
|
||||
log_printf(LOG_DEBUG, "WTP change state from %s to %s",
|
||||
capwap_dfa_getname(g_wtp.state),
|
||||
capwap_dfa_getname(state));
|
||||
g_wtp.state = state;
|
||||
@ -402,7 +402,7 @@ void wtp_free_reference_last_response(void) {
|
||||
static void wtp_dfa_retransmition_timeout_cb(EV_P_ ev_timer *w, int revents)
|
||||
{
|
||||
if (!g_wtp.requestfragmentpacket->count) {
|
||||
capwap_logging_warning("Invalid retransmition request packet");
|
||||
log_printf(LOG_WARNING, "Invalid retransmition request packet");
|
||||
wtp_teardown_connection();
|
||||
|
||||
return;
|
||||
@ -410,7 +410,7 @@ static void wtp_dfa_retransmition_timeout_cb(EV_P_ ev_timer *w, int revents)
|
||||
|
||||
g_wtp.retransmitcount++;
|
||||
if (g_wtp.retransmitcount >= WTP_MAX_RETRANSMIT) {
|
||||
capwap_logging_info("Retransmition request packet timeout");
|
||||
log_printf(LOG_INFO, "Retransmition request packet timeout");
|
||||
|
||||
/* Timeout state */
|
||||
wtp_free_reference_last_request();
|
||||
@ -420,9 +420,9 @@ static void wtp_dfa_retransmition_timeout_cb(EV_P_ ev_timer *w, int revents)
|
||||
}
|
||||
|
||||
/* Retransmit request */
|
||||
capwap_logging_debug("Retransmition request packet");
|
||||
log_printf(LOG_DEBUG, "Retransmition request packet");
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
|
||||
capwap_logging_error("Error to send request packet");
|
||||
log_printf(LOG_ERR, "Error to send request packet");
|
||||
}
|
||||
|
||||
/* Update timeout */
|
||||
|
@ -121,7 +121,7 @@ void wtp_dfa_state_configure_enter(void)
|
||||
/* Send Configuration Status request to AC */
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
|
||||
/* Error to send packets */
|
||||
capwap_logging_debug("Warning: error to send configuration status request packet");
|
||||
log_printf(LOG_DEBUG, "Warning: error to send configuration status request packet");
|
||||
wtp_free_reference_last_request();
|
||||
wtp_teardown_connection();
|
||||
|
||||
@ -140,7 +140,7 @@ void wtp_dfa_state_configure(struct capwap_parsed_packet* packet)
|
||||
struct capwap_resultcode_element* resultcode;
|
||||
|
||||
if (packet->rxmngpacket->ctrlmsg.type != CAPWAP_CONFIGURATION_STATUS_RESPONSE) {
|
||||
capwap_logging_debug("Unexpected message %d in state Configure",
|
||||
log_printf(LOG_DEBUG, "Unexpected message %d in state Configure",
|
||||
packet->rxmngpacket->ctrlmsg.type);
|
||||
return;
|
||||
}
|
||||
@ -148,12 +148,12 @@ void wtp_dfa_state_configure(struct capwap_parsed_packet* packet)
|
||||
/* */
|
||||
binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
if (binding != g_wtp.binding) {
|
||||
capwap_logging_debug("Configuration Status Response for invalid binding");
|
||||
log_printf(LOG_DEBUG, "Configuration Status Response for invalid binding");
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_wtp.localseqnumber != packet->rxmngpacket->ctrlmsg.seq) {
|
||||
capwap_logging_debug("Configuration Status Response with invalid sequence (%d != %d)",
|
||||
log_printf(LOG_DEBUG, "Configuration Status Response with invalid sequence (%d != %d)",
|
||||
g_wtp.localseqnumber, packet->rxmngpacket->ctrlmsg.seq);
|
||||
return;
|
||||
}
|
||||
@ -169,7 +169,7 @@ void wtp_dfa_state_configure(struct capwap_parsed_packet* packet)
|
||||
resultcode = (struct capwap_resultcode_element*)capwap_get_message_element_data(packet,
|
||||
CAPWAP_ELEMENT_RESULTCODE);
|
||||
if (resultcode && !CAPWAP_RESULTCODE_OK(resultcode->code)) {
|
||||
capwap_logging_warning("Receive Configure Status Response with error: %d",
|
||||
log_printf(LOG_WARNING, "Receive Configure Status Response with error: %d",
|
||||
(int)resultcode->code);
|
||||
wtp_teardown_connection();
|
||||
return;
|
||||
@ -182,7 +182,7 @@ void wtp_dfa_state_configure(struct capwap_parsed_packet* packet)
|
||||
|
||||
/* Binding values */
|
||||
if (wtp_radio_setconfiguration(packet)) {
|
||||
capwap_logging_warning("Receive Configure Status Response with invalid elements");
|
||||
log_printf(LOG_WARNING, "Receive Configure Status Response with invalid elements");
|
||||
wtp_teardown_connection();
|
||||
return;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void wtp_dfa_state_datacheck_enter(void)
|
||||
/* Send Change State Event request to AC */
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
|
||||
/* Error to send packets */
|
||||
capwap_logging_debug("Warning: error to send change state event request packet");
|
||||
log_printf(LOG_DEBUG, "Warning: error to send change state event request packet");
|
||||
wtp_free_reference_last_request();
|
||||
wtp_teardown_connection();
|
||||
|
||||
@ -54,7 +54,7 @@ void wtp_dfa_state_datacheck(struct capwap_parsed_packet* packet)
|
||||
struct capwap_resultcode_element* resultcode;
|
||||
|
||||
if (packet->rxmngpacket->ctrlmsg.type != CAPWAP_CHANGE_STATE_EVENT_RESPONSE) {
|
||||
capwap_logging_debug("Unexpected message %d in state Data Check",
|
||||
log_printf(LOG_DEBUG, "Unexpected message %d in state Data Check",
|
||||
packet->rxmngpacket->ctrlmsg.type);
|
||||
return;
|
||||
}
|
||||
@ -62,12 +62,12 @@ void wtp_dfa_state_datacheck(struct capwap_parsed_packet* packet)
|
||||
/* */
|
||||
binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
if (binding != g_wtp.binding) {
|
||||
capwap_logging_debug("Change State Event for invalid binding");
|
||||
log_printf(LOG_DEBUG, "Change State Event for invalid binding");
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_wtp.localseqnumber != packet->rxmngpacket->ctrlmsg.seq) {
|
||||
capwap_logging_debug("Configuration Status Response with invalid sequence (%d != %d)",
|
||||
log_printf(LOG_DEBUG, "Configuration Status Response with invalid sequence (%d != %d)",
|
||||
g_wtp.localseqnumber, packet->rxmngpacket->ctrlmsg.seq);
|
||||
return;
|
||||
}
|
||||
@ -83,7 +83,7 @@ void wtp_dfa_state_datacheck(struct capwap_parsed_packet* packet)
|
||||
resultcode = (struct capwap_resultcode_element*)capwap_get_message_element_data(packet,
|
||||
CAPWAP_ELEMENT_RESULTCODE);
|
||||
if (resultcode && !CAPWAP_RESULTCODE_OK(resultcode->code)) {
|
||||
capwap_logging_warning("Receive Data Check Response with error: %d",
|
||||
log_printf(LOG_WARNING, "Receive Data Check Response with error: %d",
|
||||
(int)resultcode->code);
|
||||
wtp_teardown_connection();
|
||||
|
||||
|
@ -30,7 +30,7 @@ static void wtp_send_discovery_request()
|
||||
|
||||
if (g_wtp.net.socket < 0)
|
||||
if (capwap_bind_sockets(&g_wtp.net) < 0) {
|
||||
capwap_logging_fatal("Cannot bind control address");
|
||||
log_printf(LOG_EMERG, "Cannot bind control address");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -75,14 +75,14 @@ static void wtp_send_discovery_request()
|
||||
addr->resolved = 1;
|
||||
g_wtp.discoverytype.type = CAPWAP_DISCOVERYTYPE_TYPE_STATIC;
|
||||
} else {
|
||||
capwap_logging_info("%s:%d Could not resolve application.acdiscovery.host %s",
|
||||
log_printf(LOG_INFO, "%s:%d Could not resolve application.acdiscovery.host %s",
|
||||
__FILE__, __LINE__, addr->fqdn);
|
||||
}
|
||||
}
|
||||
if (!capwap_sendto_fragmentpacket(g_wtp.net.socket,
|
||||
g_wtp.requestfragmentpacket,
|
||||
&addr->sockaddr)) {
|
||||
capwap_logging_debug("Warning: error to send discovery request packet");
|
||||
log_printf(LOG_DEBUG, "Warning: error to send discovery request packet");
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ static void wtp_dfa_state_discovery_timeout(EV_P_ ev_timer *w, int revents)
|
||||
}
|
||||
acpreferredaddr->resolved = 1;
|
||||
} else {
|
||||
capwap_logging_info("%s:%d Could not resolve application.acprefered.host %s", __FILE__, __LINE__, acpreferredaddr->fqdn);
|
||||
log_printf(LOG_INFO, "%s:%d Could not resolve application.acprefered.host %s", __FILE__, __LINE__, acpreferredaddr->fqdn);
|
||||
}
|
||||
}
|
||||
if (!capwap_compare_ip(&acpreferredaddr->sockaddr, &checkaddr)) {
|
||||
@ -167,7 +167,7 @@ static void wtp_dfa_state_discovery_timeout(EV_P_ ev_timer *w, int revents)
|
||||
}
|
||||
acpreferredaddr->resolved = 1;
|
||||
} else {
|
||||
capwap_logging_info("Could not resolve application.acprefered.host %s", acpreferredaddr->fqdn);
|
||||
log_printf(LOG_INFO, "Could not resolve application.acprefered.host %s", acpreferredaddr->fqdn);
|
||||
}
|
||||
}
|
||||
if (!capwap_compare_ip(&acpreferredaddr->sockaddr, &checkaddr)) {
|
||||
@ -196,7 +196,7 @@ static void wtp_dfa_state_discovery_timeout(EV_P_ ev_timer *w, int revents)
|
||||
union sockaddr_capwap localaddr;
|
||||
|
||||
if (capwap_connect_socket(&g_wtp.net, &peeraddr) < 0) {
|
||||
capwap_logging_fatal("Cannot bind control address");
|
||||
log_printf(LOG_EMERG, "Cannot bind control address");
|
||||
wtp_socket_io_stop();
|
||||
capwap_close_sockets(&g_wtp.net);
|
||||
return;
|
||||
@ -204,7 +204,7 @@ static void wtp_dfa_state_discovery_timeout(EV_P_ ev_timer *w, int revents)
|
||||
|
||||
/* Retrieve local address */
|
||||
if (capwap_getsockname(&g_wtp.net, &localaddr) < 0) {
|
||||
capwap_logging_fatal("Cannot get local endpoint address");
|
||||
log_printf(LOG_EMERG, "Cannot get local endpoint address");
|
||||
wtp_socket_io_stop();
|
||||
capwap_close_sockets(&g_wtp.net);
|
||||
return;
|
||||
@ -267,7 +267,7 @@ void wtp_dfa_state_discovery(struct capwap_parsed_packet* packet)
|
||||
ASSERT(packet != NULL);
|
||||
|
||||
if (packet->rxmngpacket->ctrlmsg.type != CAPWAP_DISCOVERY_RESPONSE) {
|
||||
capwap_logging_debug("Unexpected message %d in state Discovery",
|
||||
log_printf(LOG_DEBUG, "Unexpected message %d in state Discovery",
|
||||
packet->rxmngpacket->ctrlmsg.type);
|
||||
return;
|
||||
}
|
||||
@ -275,12 +275,12 @@ void wtp_dfa_state_discovery(struct capwap_parsed_packet* packet)
|
||||
/* */
|
||||
binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
if (binding != g_wtp.binding) {
|
||||
capwap_logging_debug("Discovery Response for invalid binding");
|
||||
log_printf(LOG_DEBUG, "Discovery Response for invalid binding");
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_wtp.localseqnumber != packet->rxmngpacket->ctrlmsg.seq) {
|
||||
capwap_logging_debug("Discovery Response with invalid sequence (%d != %d)",
|
||||
log_printf(LOG_DEBUG, "Discovery Response with invalid sequence (%d != %d)",
|
||||
g_wtp.localseqnumber, packet->rxmngpacket->ctrlmsg.seq);
|
||||
return;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ void wtp_start_datachannel(void)
|
||||
#ifdef DEBUG
|
||||
{
|
||||
char addr[INET6_ADDRSTRLEN];
|
||||
capwap_logging_debug("Create data channel with peer %s:%d",
|
||||
log_printf(LOG_DEBUG, "Create data channel with peer %s:%d",
|
||||
capwap_address_to_string(&dataaddr, addr, INET6_ADDRSTRLEN),
|
||||
(int)CAPWAP_GET_NETWORK_PORT(&dataaddr));
|
||||
}
|
||||
@ -59,12 +59,12 @@ void wtp_start_datachannel(void)
|
||||
/* Bind data address and Connect to AC data channel */
|
||||
if (wtp_kmod_create(g_wtp.net.localaddr.ss.ss_family, &dataaddr.ss, &g_wtp.sessionid, g_wtp.mtu) != 0) {
|
||||
/* Error to send packets */
|
||||
capwap_logging_error("Error to send data channel keepalive packet");
|
||||
log_printf(LOG_ERR, "Error to send data channel keepalive packet");
|
||||
wtp_teardown_connection();
|
||||
return;
|
||||
}
|
||||
|
||||
capwap_logging_error("Data channel connected");
|
||||
log_printf(LOG_ERR, "Data channel connected");
|
||||
/* Reset AC Prefered List Position */
|
||||
g_wtp.acpreferedselected = 0;
|
||||
|
||||
|
@ -26,7 +26,7 @@ static int wtp_join_prefered_ac()
|
||||
wtp_socket_io_stop();
|
||||
capwap_close_sockets(&g_wtp.net);
|
||||
if (capwap_bind_sockets(&g_wtp.net) < 0) {
|
||||
capwap_logging_fatal("Cannot bind control address");
|
||||
log_printf(LOG_EMERG, "Cannot bind control address");
|
||||
return -1;
|
||||
}
|
||||
wtp_socket_io_start();
|
||||
@ -38,12 +38,12 @@ static int wtp_join_prefered_ac()
|
||||
}
|
||||
peeraddr->resolved = 1;
|
||||
} else {
|
||||
capwap_logging_info("%s:%d Could not resolve application.acprefered.host %s", __FILE__, __LINE__, peeraddr->fqdn);
|
||||
log_printf(LOG_INFO, "%s:%d Could not resolve application.acprefered.host %s", __FILE__, __LINE__, peeraddr->fqdn);
|
||||
}
|
||||
}
|
||||
|
||||
if (capwap_connect_socket(&g_wtp.net, &peeraddr->sockaddr) < 0) {
|
||||
capwap_logging_fatal("Cannot bind control address");
|
||||
log_printf(LOG_EMERG, "Cannot bind control address");
|
||||
wtp_socket_io_stop();
|
||||
capwap_close_sockets(&g_wtp.net);
|
||||
return -1;
|
||||
@ -51,7 +51,7 @@ static int wtp_join_prefered_ac()
|
||||
|
||||
/* Retrieve local address */
|
||||
if (capwap_getsockname(&g_wtp.net, &localaddr) < 0) {
|
||||
capwap_logging_fatal("Cannot get local endpoint address");
|
||||
log_printf(LOG_EMERG, "Cannot get local endpoint address");
|
||||
wtp_socket_io_stop();
|
||||
capwap_close_sockets(&g_wtp.net);
|
||||
return -1;
|
||||
@ -84,7 +84,7 @@ void wtp_dfa_state_idle_enter(void)
|
||||
|
||||
if (g_wtp.net.socket < 0) {
|
||||
if (capwap_bind_sockets(&g_wtp.net) < 0) {
|
||||
capwap_logging_fatal("Cannot bind control address");
|
||||
log_printf(LOG_EMERG, "Cannot bind control address");
|
||||
exit(-1);
|
||||
}
|
||||
wtp_socket_io_start();
|
||||
|
@ -26,7 +26,7 @@ void wtp_dfa_state_join_enter(void)
|
||||
char sessionname[33];
|
||||
|
||||
capwap_sessionid_printf(&g_wtp.sessionid, sessionname);
|
||||
capwap_logging_debug("Create WTP sessionid: %s", sessionname);
|
||||
log_printf(LOG_DEBUG, "Create WTP sessionid: %s", sessionname);
|
||||
} while (0);
|
||||
#endif
|
||||
|
||||
@ -79,7 +79,7 @@ void wtp_dfa_state_join_enter(void)
|
||||
/* Send join request to AC */
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
|
||||
/* Error to send packets */
|
||||
capwap_logging_debug("Warning: error to send join request packet");
|
||||
log_printf(LOG_DEBUG, "Warning: error to send join request packet");
|
||||
wtp_free_reference_last_request();
|
||||
wtp_teardown_connection();
|
||||
|
||||
@ -99,7 +99,7 @@ void wtp_dfa_state_join(struct capwap_parsed_packet* packet)
|
||||
struct capwap_resultcode_element* resultcode;
|
||||
|
||||
if (packet->rxmngpacket->ctrlmsg.type != CAPWAP_JOIN_RESPONSE) {
|
||||
capwap_logging_debug("Unexpected message %d in state Join",
|
||||
log_printf(LOG_DEBUG, "Unexpected message %d in state Join",
|
||||
packet->rxmngpacket->ctrlmsg.type);
|
||||
return;
|
||||
}
|
||||
@ -107,12 +107,12 @@ void wtp_dfa_state_join(struct capwap_parsed_packet* packet)
|
||||
/* */
|
||||
binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
if (binding != g_wtp.binding) {
|
||||
capwap_logging_debug("Join Response for invalid binding");
|
||||
log_printf(LOG_DEBUG, "Join Response for invalid binding");
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_wtp.localseqnumber != packet->rxmngpacket->ctrlmsg.seq) {
|
||||
capwap_logging_debug("Join Response with invalid sequence (%d != %d)",
|
||||
log_printf(LOG_DEBUG, "Join Response with invalid sequence (%d != %d)",
|
||||
g_wtp.localseqnumber, packet->rxmngpacket->ctrlmsg.seq);
|
||||
return;
|
||||
}
|
||||
@ -128,7 +128,7 @@ void wtp_dfa_state_join(struct capwap_parsed_packet* packet)
|
||||
resultcode = (struct capwap_resultcode_element*)capwap_get_message_element_data(packet,
|
||||
CAPWAP_ELEMENT_RESULTCODE);
|
||||
if (resultcode && !CAPWAP_RESULTCODE_OK(resultcode->code)) {
|
||||
capwap_logging_warning("Receive Join Response with error: %d",
|
||||
log_printf(LOG_WARNING, "Receive Join Response with error: %d",
|
||||
(int)resultcode->code);
|
||||
wtp_teardown_connection();
|
||||
return;
|
||||
@ -140,7 +140,7 @@ void wtp_dfa_state_join(struct capwap_parsed_packet* packet)
|
||||
acdescriptor = (struct capwap_acdescriptor_element*)capwap_get_message_element_data(packet,
|
||||
CAPWAP_ELEMENT_ACDESCRIPTION);
|
||||
if (!(g_wtp.validdtlsdatapolicy & acdescriptor->dtlspolicy)) {
|
||||
capwap_logging_warning("Receive Join Response with invalid DTLS data policy");
|
||||
log_printf(LOG_WARNING, "Receive Join Response with invalid DTLS data policy");
|
||||
wtp_teardown_connection();
|
||||
return;
|
||||
}
|
||||
@ -155,7 +155,7 @@ void wtp_dfa_state_join(struct capwap_parsed_packet* packet)
|
||||
|
||||
/* Binding values */
|
||||
if (wtp_radio_setconfiguration(packet)) {
|
||||
capwap_logging_warning("Receive Join Response with invalid elements");
|
||||
log_printf(LOG_WARNING, "Receive Join Response with invalid elements");
|
||||
wtp_teardown_connection();
|
||||
return;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ static int send_echo_request(void)
|
||||
/* Send echo request to AC */
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
|
||||
/* Error to send packets */
|
||||
capwap_logging_debug("Warning: error to send echo request packet");
|
||||
log_printf(LOG_DEBUG, "Warning: error to send echo request packet");
|
||||
wtp_free_reference_last_request();
|
||||
|
||||
return result;
|
||||
@ -55,7 +55,7 @@ static int receive_echo_response(struct capwap_parsed_packet* packet) {
|
||||
/* Check the success of the Request */
|
||||
resultcode = (struct capwap_resultcode_element*)capwap_get_message_element_data(packet, CAPWAP_ELEMENT_RESULTCODE);
|
||||
if (resultcode && !CAPWAP_RESULTCODE_OK(resultcode->code)) {
|
||||
capwap_logging_warning("Receive Echo Response with error: %d", (int)resultcode->code);
|
||||
log_printf(LOG_WARNING, "Receive Echo Response with error: %d", (int)resultcode->code);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -77,12 +77,12 @@ static void receive_reset_request(struct capwap_parsed_packet* packet)
|
||||
/* */
|
||||
binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
if (binding != g_wtp.binding) {
|
||||
capwap_logging_debug("Reset Request for invalid binding");
|
||||
log_printf(LOG_DEBUG, "Reset Request for invalid binding");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IS_SEQUENCE_SMALLER(g_wtp.remoteseqnumber, packet->rxmngpacket->ctrlmsg.seq)) {
|
||||
capwap_logging_debug("Reset Request with invalid sequence (%d < %d)",
|
||||
log_printf(LOG_DEBUG, "Reset Request with invalid sequence (%d < %d)",
|
||||
g_wtp.remoteseqnumber, packet->rxmngpacket->ctrlmsg.seq);
|
||||
return;
|
||||
}
|
||||
@ -112,7 +112,7 @@ static void receive_reset_request(struct capwap_parsed_packet* packet)
|
||||
|
||||
/* Send Reset response to AC */
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.responsefragmentpacket)) {
|
||||
capwap_logging_debug("Warning: error to send reset response packet");
|
||||
log_printf(LOG_DEBUG, "Warning: error to send reset response packet");
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,12 +129,12 @@ static void receive_station_configuration_request(struct capwap_parsed_packet* p
|
||||
/* */
|
||||
binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
if (binding != g_wtp.binding) {
|
||||
capwap_logging_debug("Station Configuration Request for invalid binding");
|
||||
log_printf(LOG_DEBUG, "Station Configuration Request for invalid binding");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IS_SEQUENCE_SMALLER(g_wtp.remoteseqnumber, packet->rxmngpacket->ctrlmsg.seq)) {
|
||||
capwap_logging_debug("Station Configuration Request with invalid sequence (%d < %d)",
|
||||
log_printf(LOG_DEBUG, "Station Configuration Request with invalid sequence (%d < %d)",
|
||||
g_wtp.remoteseqnumber, packet->rxmngpacket->ctrlmsg.seq);
|
||||
return;
|
||||
}
|
||||
@ -171,7 +171,7 @@ static void receive_station_configuration_request(struct capwap_parsed_packet* p
|
||||
|
||||
/* Send Station Configuration response to AC */
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.responsefragmentpacket)) {
|
||||
capwap_logging_debug("Warning: error to send Station Configuration response packet");
|
||||
log_printf(LOG_DEBUG, "Warning: error to send Station Configuration response packet");
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,12 +190,12 @@ static void receive_ieee80211_wlan_configuration_request(struct capwap_parsed_pa
|
||||
/* */
|
||||
binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
if (binding != g_wtp.binding) {
|
||||
capwap_logging_debug("IEEE 802.11 WLAN Configuration Request for invalid binding");
|
||||
log_printf(LOG_DEBUG, "IEEE 802.11 WLAN Configuration Request for invalid binding");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IS_SEQUENCE_SMALLER(g_wtp.remoteseqnumber, packet->rxmngpacket->ctrlmsg.seq)) {
|
||||
capwap_logging_debug("IEEE 802.11 WLAN Configuration Request with invalid sequence (%d < %d)",
|
||||
log_printf(LOG_DEBUG, "IEEE 802.11 WLAN Configuration Request with invalid sequence (%d < %d)",
|
||||
g_wtp.remoteseqnumber, packet->rxmngpacket->ctrlmsg.seq);
|
||||
return;
|
||||
}
|
||||
@ -241,16 +241,16 @@ static void receive_ieee80211_wlan_configuration_request(struct capwap_parsed_pa
|
||||
|
||||
/* Send IEEE802.11 WLAN Configuration response to AC */
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.responsefragmentpacket)) {
|
||||
capwap_logging_debug("Warning: error to send IEEE802.11 WLAN Configuration response packet");
|
||||
log_printf(LOG_DEBUG, "Warning: error to send IEEE802.11 WLAN Configuration response packet");
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
static void wtp_dfa_state_run_echo_timeout(EV_P_ ev_timer *w, int revents)
|
||||
{
|
||||
capwap_logging_debug("Send Echo Request");
|
||||
log_printf(LOG_DEBUG, "Send Echo Request");
|
||||
if (send_echo_request()) {
|
||||
capwap_logging_error("Unable to send Echo Request");
|
||||
log_printf(LOG_ERR, "Unable to send Echo Request");
|
||||
wtp_teardown_connection();
|
||||
return;
|
||||
}
|
||||
@ -262,12 +262,12 @@ static void wtp_dfa_state_run_echo_timeout(EV_P_ ev_timer *w, int revents)
|
||||
/* */
|
||||
static void wtp_dfa_state_run_keepalive_timeout(EV_P_ ev_timer *w, int revents)
|
||||
{
|
||||
capwap_logging_debug("Send Keep-Alive");
|
||||
log_printf(LOG_DEBUG, "Send Keep-Alive");
|
||||
|
||||
ev_timer_again(EV_A_ &g_wtp.timerkeepalivedead);
|
||||
|
||||
if (wtp_kmod_send_keepalive()) {
|
||||
capwap_logging_error("Unable to send Keep-Alive");
|
||||
log_printf(LOG_ERR, "Unable to send Keep-Alive");
|
||||
wtp_teardown_connection();
|
||||
}
|
||||
}
|
||||
@ -275,13 +275,13 @@ static void wtp_dfa_state_run_keepalive_timeout(EV_P_ ev_timer *w, int revents)
|
||||
/* */
|
||||
static void wtp_dfa_state_run_keepalivedead_timeout(EV_P_ ev_timer *w, int revents)
|
||||
{
|
||||
capwap_logging_info("Keep-Alive timeout, teardown");
|
||||
log_printf(LOG_INFO, "Keep-Alive timeout, teardown");
|
||||
wtp_teardown_connection();
|
||||
}
|
||||
|
||||
/* */
|
||||
void wtp_recv_data_keepalive(void) {
|
||||
capwap_logging_debug("Receive Keep-Alive");
|
||||
log_printf(LOG_DEBUG, "Receive Keep-Alive");
|
||||
|
||||
/* Receive Data Keep-Alive, wait for next packet */
|
||||
if (ev_is_active(&g_wtp.timerkeepalivedead))
|
||||
@ -353,7 +353,7 @@ void wtp_dfa_state_run(struct capwap_parsed_packet* packet)
|
||||
|
||||
case CAPWAP_ECHO_RESPONSE:
|
||||
if (!receive_echo_response(packet)) {
|
||||
capwap_logging_debug("Receive Echo Response");
|
||||
log_printf(LOG_DEBUG, "Receive Echo Response");
|
||||
|
||||
g_wtp.timerecho.repeat = g_wtp.echointerval / 1000.0;
|
||||
ev_timer_again(EV_DEFAULT_UC_ &g_wtp.timerecho);
|
||||
|
@ -176,7 +176,7 @@ static int wtp_kmod_link(void) {
|
||||
if (result == -EALREADY) {
|
||||
result = 0;
|
||||
} else {
|
||||
capwap_logging_warning("Unable to connect kernel module, error code: %d", result);
|
||||
log_printf(LOG_WARNING, "Unable to connect kernel module, error code: %d", result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ static void wtp_kmod_event_receive(EV_P_ ev_io *w, int revents)
|
||||
/* */
|
||||
res = nl_recvmsgs(kmodhandle->nl, kmodhandle->nl_cb);
|
||||
if (res) {
|
||||
capwap_logging_warning("Receive kernel module message failed: %d", res);
|
||||
log_printf(LOG_WARNING, "Receive kernel module message failed: %d", res);
|
||||
}
|
||||
}
|
||||
|
||||
@ -520,7 +520,7 @@ int wtp_kmod_init(void) {
|
||||
/* Get nlsmartcapwap netlink family */
|
||||
g_wtp.kmodhandle.nlsmartcapwap_id = genl_ctrl_resolve(g_wtp.kmodhandle.nl, NLSMARTCAPWAP_GENL_NAME);
|
||||
if (g_wtp.kmodhandle.nlsmartcapwap_id < 0) {
|
||||
capwap_logging_warning("Unable to found kernel module");
|
||||
log_printf(LOG_WARNING, "Unable to found kernel module");
|
||||
wtp_kmod_free();
|
||||
return -1;
|
||||
}
|
||||
|
@ -26,7 +26,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");
|
||||
log_printf(LOG_DEBUG, "Config Phy: Supported rate not set");
|
||||
return -1; /* Supported rate not set */
|
||||
}
|
||||
|
||||
@ -38,30 +38,30 @@ 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");
|
||||
log_printf(LOG_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");
|
||||
log_printf(LOG_DEBUG, "Config Phy: RI id mismatch");
|
||||
return -1;
|
||||
} else if (radio->radioid != radio->radioconfig.radioid) {
|
||||
capwap_logging_debug("Config Phy: RC id mismatch");
|
||||
log_printf(LOG_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");
|
||||
log_printf(LOG_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");
|
||||
log_printf(LOG_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");
|
||||
log_printf(LOG_DEBUG, "Config Phy: OFDM A mismatch");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ int wtp_radio_setconfiguration(struct capwap_parsed_packet* packet)
|
||||
break;
|
||||
}
|
||||
|
||||
capwap_logging_debug("wtp_radio_setconfiguration result #1: %d", result);
|
||||
log_printf(LOG_DEBUG, "wtp_radio_setconfiguration result #1: %d", result);
|
||||
|
||||
/* Update radio frequency */
|
||||
for (i = 0; (i < updateitems->count) && !result; i++) {
|
||||
@ -474,7 +474,7 @@ int wtp_radio_setconfiguration(struct capwap_parsed_packet* packet)
|
||||
}
|
||||
}
|
||||
|
||||
capwap_logging_debug("wtp_radio_setconfiguration result #2: %d", result);
|
||||
log_printf(LOG_DEBUG, "wtp_radio_setconfiguration result #2: %d", result);
|
||||
|
||||
/* Update radio configuration */
|
||||
for (i = 0; (i < updateitems->count) && !result; i++) {
|
||||
@ -508,7 +508,7 @@ int wtp_radio_setconfiguration(struct capwap_parsed_packet* packet)
|
||||
}
|
||||
}
|
||||
|
||||
capwap_logging_debug("wtp_radio_setconfiguration result #3: %d", result);
|
||||
log_printf(LOG_DEBUG, "wtp_radio_setconfiguration result #3: %d", result);
|
||||
|
||||
/* */
|
||||
capwap_array_free(updateitems);
|
||||
@ -557,12 +557,12 @@ 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);
|
||||
log_printf(LOG_DEBUG, "wtp_radio_get_wlan: invalid wlanid (%d)", wlanid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (wlanid > radio->wlan->count) {
|
||||
capwap_logging_warning("wtp_radio_get_wlan: invalid wlanid (%d > %lu)",
|
||||
log_printf(LOG_WARNING, "wtp_radio_get_wlan: invalid wlanid (%d > %lu)",
|
||||
wlanid, radio->wlan->count);
|
||||
return NULL;
|
||||
}
|
||||
@ -656,31 +656,31 @@ uint32_t wtp_radio_create_wlan(struct capwap_parsed_packet* packet,
|
||||
/* 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");
|
||||
log_printf(LOG_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");
|
||||
log_printf(LOG_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 && !wlan->wlanhandle) {
|
||||
capwap_logging_debug("Create WLAN: invalid WLAN ID");
|
||||
log_printf(LOG_DEBUG, "Create WLAN: invalid WLAN ID");
|
||||
return CAPWAP_RESULTCODE_FAILURE;
|
||||
}
|
||||
if (wlan->in_use) {
|
||||
capwap_logging_debug("Create WLAN: vif already exists");
|
||||
log_printf(LOG_DEBUG, "Create WLAN: vif already exists");
|
||||
return CAPWAP_RESULTCODE_FAILURE;
|
||||
}
|
||||
|
||||
/* Prepare physical interface for create wlan */
|
||||
if (wtp_radio_configure_phy(radio)) {
|
||||
capwap_logging_debug("Create WLAN: config phy failed");
|
||||
log_printf(LOG_DEBUG, "Create WLAN: config phy failed");
|
||||
return CAPWAP_RESULTCODE_FAILURE;
|
||||
}
|
||||
|
||||
@ -699,7 +699,7 @@ uint32_t wtp_radio_create_wlan(struct capwap_parsed_packet* packet,
|
||||
|
||||
/* Start AP */
|
||||
if (wifi_wlan_startap(wlan->wlanhandle, ¶ms)) {
|
||||
capwap_logging_debug("Create WLAN: start AP failes");
|
||||
log_printf(LOG_DEBUG, "Create WLAN: start AP failes");
|
||||
return CAPWAP_RESULTCODE_FAILURE;
|
||||
}
|
||||
|
||||
@ -746,21 +746,21 @@ uint32_t wtp_radio_add_station(struct capwap_parsed_packet* packet) {
|
||||
capwap_get_message_element_data(packet, CAPWAP_ELEMENT_80211N_STATION_INFO);
|
||||
|
||||
if (!station80211 || (addstation->radioid != station80211->radioid)) {
|
||||
capwap_logging_debug("add_station: error no station or wrong radio");
|
||||
log_printf(LOG_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");
|
||||
log_printf(LOG_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);
|
||||
log_printf(LOG_DEBUG, "add_station: radio_get_wlan failed (%p, %d)", radio, station80211->wlanid);
|
||||
return CAPWAP_RESULTCODE_FAILURE;
|
||||
}
|
||||
|
||||
@ -809,17 +809,17 @@ uint32_t wtp_radio_add_station(struct capwap_parsed_packet* packet) {
|
||||
|
||||
err = wtp_kmod_add_station(addstation->radioid, station80211->address, station80211->wlanid);
|
||||
if (err < 0) {
|
||||
capwap_logging_debug("add_station: CAPWAP add_station failed with: %d", err);
|
||||
log_printf(LOG_DEBUG, "add_station: CAPWAP add_station failed with: %d", err);
|
||||
return CAPWAP_RESULTCODE_FAILURE;
|
||||
}
|
||||
|
||||
if (wifi_station_authorize(wlan->wlanhandle, &stationparams)) {
|
||||
wtp_kmod_del_station(addstation->radioid, station80211->address);
|
||||
capwap_logging_debug("add_station: station_authorize failed");
|
||||
log_printf(LOG_DEBUG, "add_station: station_authorize failed");
|
||||
return CAPWAP_RESULTCODE_FAILURE;
|
||||
}
|
||||
|
||||
capwap_logging_debug("add_station: SUCCESS");
|
||||
log_printf(LOG_DEBUG, "add_station: SUCCESS");
|
||||
return CAPWAP_RESULTCODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user