switch everything to new log API and drop old one

This commit is contained in:
Andreas Schultz
2016-03-30 14:47:57 +02:00
parent dd6f6fcfe2
commit 29ed6544c5
113 changed files with 641 additions and 638 deletions

View File

@ -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), &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 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;

View File

@ -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;
}