Removed the necessity of having to calculate each time the string of
macaddress stations.
This commit is contained in:
parent
1c810c2d72
commit
d4d7649f3b
@ -26,7 +26,6 @@ static void ac_ieee80211_mgmt_authentication_packet(struct ac_session_data_t* se
|
||||
int ielength;
|
||||
struct ieee80211_ie_items ieitems;
|
||||
struct ac_station* station;
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
/* Parsing Information Elements */
|
||||
ielength = mgmtlength - (sizeof(struct ieee80211_header) + sizeof(mgmt->authetication));
|
||||
@ -39,8 +38,7 @@ static void ac_ieee80211_mgmt_authentication_packet(struct ac_session_data_t* se
|
||||
station = ac_stations_create_station(sessiondata, radioid, mgmt->bssid, mgmt->sa);
|
||||
|
||||
/* */
|
||||
capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH);
|
||||
capwap_logging_info("Receive IEEE802.11 Authentication Request from %s station", buffer);
|
||||
capwap_logging_info("Receive IEEE802.11 Authentication Request from %s station", station->addrtext);
|
||||
|
||||
/* A station is removed if the association does not complete within a given period of time */
|
||||
station->timeoutaction = AC_STATION_TIMEOUT_ACTION_DEAUTHENTICATE;
|
||||
@ -63,8 +61,7 @@ static void ac_ieee80211_mgmt_authentication_packet(struct ac_session_data_t* se
|
||||
statuscode = __le16_to_cpu(mgmt->authetication.statuscode);
|
||||
|
||||
/* */
|
||||
capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH);
|
||||
capwap_logging_info("Receive IEEE802.11 Authentication Response to %s station with %d status code", buffer, (int)statuscode);
|
||||
capwap_logging_info("Receive IEEE802.11 Authentication Response to %s station with %d status code", station->addrtext, (int)statuscode);
|
||||
|
||||
if (statuscode == IEEE80211_STATUS_SUCCESS) {
|
||||
algorithm = __le16_to_cpu(mgmt->authetication.algorithm);
|
||||
@ -86,7 +83,6 @@ static void ac_ieee80211_mgmt_association_request_packet(struct ac_session_data_
|
||||
int ielength;
|
||||
struct ieee80211_ie_items ieitems;
|
||||
struct ac_station* station;
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
/* Parsing Information Elements */
|
||||
ielength = mgmtlength - (sizeof(struct ieee80211_header) + sizeof(mgmt->associationrequest));
|
||||
@ -99,8 +95,7 @@ static void ac_ieee80211_mgmt_association_request_packet(struct ac_session_data_
|
||||
station = ac_stations_get_station(sessiondata, radioid, mgmt->bssid, mgmt->sa);
|
||||
|
||||
/* */
|
||||
capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH);
|
||||
capwap_logging_info("Receive IEEE802.11 Association Request from %s station", buffer);
|
||||
capwap_logging_info("Receive IEEE802.11 Association Request from %s station", station->addrtext);
|
||||
|
||||
/* Get Station Info */
|
||||
station->capability = __le16_to_cpu(mgmt->associationrequest.capability);
|
||||
@ -133,7 +128,6 @@ static void ac_ieee80211_mgmt_association_response_packet(struct ac_session_data
|
||||
int ielength;
|
||||
struct ieee80211_ie_items ieitems;
|
||||
struct ac_station* station;
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
/* Parsing Information Elements */
|
||||
ielength = mgmtlength - (sizeof(struct ieee80211_header) + sizeof(mgmt->associationresponse));
|
||||
@ -145,8 +139,7 @@ static void ac_ieee80211_mgmt_association_response_packet(struct ac_session_data
|
||||
if (!memcmp(mgmt->bssid, mgmt->sa, MACADDRESS_EUI48_LENGTH) && memcmp(mgmt->bssid, mgmt->da, MACADDRESS_EUI48_LENGTH)) {
|
||||
station = ac_stations_get_station(sessiondata, radioid, mgmt->bssid, mgmt->da);
|
||||
if (station && (station->wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_LOCAL)) {
|
||||
capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH);
|
||||
capwap_logging_info("Receive IEEE802.11 Association Response to %s station with %d status code", buffer, (int)mgmt->associationresponse.statuscode);
|
||||
capwap_logging_info("Receive IEEE802.11 Association Response to %s station with %d status code", station->addrtext, (int)mgmt->associationresponse.statuscode);
|
||||
|
||||
if (mgmt->associationresponse.statuscode == IEEE80211_STATUS_SUCCESS) {
|
||||
/* Get Station Info */
|
||||
|
@ -14,14 +14,13 @@
|
||||
static int ac_session_data_action_add_station_status(struct ac_session_data_t* sessiondata, struct ac_notify_add_station_status* notify) {
|
||||
struct ac_wlan* wlan;
|
||||
struct ac_station* station;
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
wlan = ac_wlans_get_bssid_with_wlanid(sessiondata, notify->radioid, notify->wlanid);
|
||||
if (wlan) {
|
||||
station = ac_stations_get_station(sessiondata, notify->radioid, wlan->bssid, notify->address);
|
||||
if (station) {
|
||||
if (CAPWAP_RESULTCODE_OK(notify->statuscode)) {
|
||||
capwap_logging_info("Authorized station: %s", capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH));
|
||||
capwap_logging_info("Authorized station: %s", station->addrtext);
|
||||
|
||||
/* */
|
||||
station->flags |= AC_STATION_FLAGS_AUTHORIZED;
|
||||
@ -39,11 +38,10 @@ static int ac_session_data_action_add_station_status(struct ac_session_data_t* s
|
||||
/* */
|
||||
static int ac_session_data_action_delete_station_status(struct ac_session_data_t* sessiondata, struct ac_notify_delete_station_status* notify) {
|
||||
struct ac_station* station;
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
station = ac_stations_get_station(sessiondata, notify->radioid, NULL, notify->address);
|
||||
if (station) {
|
||||
capwap_logging_info("Deauthorized station: %s with %d result code", capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH), (int)notify->statuscode);
|
||||
capwap_logging_info("Deauthorized station: %s with %d result code", station->addrtext, (int)notify->statuscode);
|
||||
|
||||
/* */
|
||||
ac_stations_delete_station(sessiondata, station);
|
||||
|
@ -50,13 +50,11 @@ static void ac_stations_reset_station(struct ac_session_data_t* sessiondata, str
|
||||
|
||||
/* */
|
||||
static void ac_stations_destroy_station(struct ac_session_data_t* sessiondata, struct ac_station* station) {
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(station != NULL);
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Destroy station: %s", capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH));
|
||||
capwap_logging_info("Destroy station: %s", station->addrtext);
|
||||
|
||||
/* Remove reference from Global Cache Stations List */
|
||||
ac_stations_delete_station_from_global_cache(sessiondata, station->address);
|
||||
@ -370,6 +368,7 @@ struct ac_station* ac_stations_create_station(struct ac_session_data_t* sessiond
|
||||
/* */
|
||||
station->idtimeout = CAPWAP_TIMEOUT_INDEX_NO_SET;
|
||||
memcpy(station->address, address, MACADDRESS_EUI48_LENGTH);
|
||||
capwap_printf_macaddress(station->addrtext, address, MACADDRESS_EUI48_LENGTH);
|
||||
station->wlanitem = stationitem;
|
||||
|
||||
/* */
|
||||
@ -457,18 +456,14 @@ void ac_stations_deauthorize_station(struct ac_session_data_t* sessiondata, stru
|
||||
|
||||
/* */
|
||||
void ac_stations_timeout(struct capwap_timeout* timeout, unsigned long index, void* context, void* param) {
|
||||
char stationaddress[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
struct ac_station* station = (struct ac_station*)context;
|
||||
|
||||
ASSERT(station != NULL);
|
||||
|
||||
/* */
|
||||
capwap_printf_macaddress(stationaddress, station->address, MACADDRESS_EUI48_LENGTH);
|
||||
|
||||
if (station->idtimeout == index) {
|
||||
switch (station->timeoutaction) {
|
||||
case AC_STATION_TIMEOUT_ACTION_DEAUTHENTICATE: {
|
||||
capwap_logging_warning("The %s station has not completed the association in time", stationaddress);
|
||||
capwap_logging_warning("The %s station has not completed the association in time", station->addrtext);
|
||||
ac_stations_delete_station((struct ac_session_data_t*)param, station);
|
||||
break;
|
||||
}
|
||||
|
@ -55,6 +55,9 @@ struct ac_wlan {
|
||||
/* AC Station */
|
||||
struct ac_station {
|
||||
uint8_t address[MACADDRESS_EUI48_LENGTH];
|
||||
char addrtext[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
/* */
|
||||
unsigned long flags;
|
||||
|
||||
/* Reference of WLAN */
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "capwap.h"
|
||||
#include "capwap_network.h"
|
||||
#include <linux/socket.h>
|
||||
#include "wifi_drivers.h"
|
||||
#include "netlink_link.h"
|
||||
|
@ -142,14 +142,12 @@ static unsigned long wifi_hash_station_gethash(const void* key, unsigned long ke
|
||||
|
||||
/* */
|
||||
static void wifi_hash_station_free(const void* key, unsigned long keysize, void* data) {
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
struct wifi_station* station = (struct wifi_station*)data;
|
||||
|
||||
ASSERT(data != NULL);
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Destroy station: %s", capwap_printf_macaddress(buffer, (uint8_t*)key, MACADDRESS_EUI48_LENGTH));
|
||||
|
||||
capwap_logging_info("Destroy station: %s", station->addrtext);
|
||||
capwap_free(station);
|
||||
}
|
||||
|
||||
@ -231,12 +229,10 @@ static void wifi_station_clean(struct wifi_station* station) {
|
||||
|
||||
/* */
|
||||
static void wifi_station_delete(struct wifi_station* station) {
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
ASSERT(station != NULL);
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Delete station: %s", capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH));
|
||||
capwap_logging_info("Delete station: %s", station->addrtext);
|
||||
|
||||
/* */
|
||||
wifi_station_clean(station);
|
||||
@ -285,6 +281,7 @@ static struct wifi_station* wifi_station_create(struct wifi_wlan* wlan, const ui
|
||||
|
||||
/* Initialize station */
|
||||
memcpy(station->address, address, MACADDRESS_EUI48_LENGTH);
|
||||
capwap_printf_macaddress(station->addrtext, address, MACADDRESS_EUI48_LENGTH);
|
||||
station->idtimeout = CAPWAP_TIMEOUT_INDEX_NO_SET;
|
||||
|
||||
/* Add to pool */
|
||||
@ -348,14 +345,10 @@ static void wifi_wlan_deauthentication_station(struct wifi_wlan* wlan, struct wi
|
||||
|
||||
/* */
|
||||
static void wifi_station_timeout(struct capwap_timeout* timeout, unsigned long index, void* context, void* param) {
|
||||
char stationaddress[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
struct wifi_station* station = (struct wifi_station*)context;
|
||||
|
||||
ASSERT(station != NULL);
|
||||
|
||||
/* */
|
||||
capwap_printf_macaddress(stationaddress, station->address, MACADDRESS_EUI48_LENGTH);
|
||||
|
||||
if (station->idtimeout == index) {
|
||||
switch (station->timeoutaction) {
|
||||
case WIFI_STATION_TIMEOUT_ACTION_DELETE: {
|
||||
@ -366,7 +359,7 @@ static void wifi_station_timeout(struct capwap_timeout* timeout, unsigned long i
|
||||
}
|
||||
|
||||
case WIFI_STATION_TIMEOUT_ACTION_DEAUTHENTICATE: {
|
||||
capwap_logging_warning("The %s station has not completed the association in time", stationaddress);
|
||||
capwap_logging_warning("The %s station has not completed the association in time", station->addrtext);
|
||||
wifi_wlan_deauthentication_station((struct wifi_wlan*)param, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
|
||||
break;
|
||||
}
|
||||
@ -626,7 +619,6 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
struct ieee80211_associationresponse_params ieee80211_params;
|
||||
struct wifi_station* station;
|
||||
uint16_t resultstatuscode;
|
||||
char stationaddress[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
/* Information Elements packet length */
|
||||
ielength = length - (sizeof(struct ieee80211_header) + sizeof(frame->associationrequest));
|
||||
@ -636,13 +628,15 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
}
|
||||
|
||||
/* */
|
||||
capwap_printf_macaddress(stationaddress, frame->sa, MACADDRESS_EUI48_LENGTH);
|
||||
;
|
||||
|
||||
/* Get station reference */
|
||||
station = wifi_station_get(wlan, frame->sa);
|
||||
if (!station) {
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
/* Invalid station, send deauthentication message */
|
||||
capwap_logging_info("Receive IEEE802.11 Association Request from %s unknown station", stationaddress);
|
||||
capwap_logging_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;
|
||||
}
|
||||
@ -650,20 +644,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", stationaddress);
|
||||
capwap_logging_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", stationaddress);
|
||||
capwap_logging_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", stationaddress);
|
||||
capwap_logging_info("Receive IEEE802.11 Association Request from %s station", station->addrtext);
|
||||
|
||||
/* */
|
||||
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_LOCAL) {
|
||||
@ -682,7 +676,7 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
responselength = ieee80211_create_associationresponse_response(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 Association Response to %s station with %d status code", stationaddress, (int)resultstatuscode);
|
||||
capwap_logging_info("Sent IEEE802.11 Association Response to %s station with %d status code", station->addrtext, (int)resultstatuscode);
|
||||
|
||||
/* Notify association request message also to AC */
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, frame, length);
|
||||
@ -690,11 +684,11 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
/* Forwards the association response message also to AC */
|
||||
wlan->send_frame(wlan->send_frame_to_ac_cbparam, (struct ieee80211_header_mgmt*)g_bufferIEEE80211, responselength);
|
||||
} else {
|
||||
capwap_logging_warning("Unable to send IEEE802.11 Association Response to %s station", stationaddress);
|
||||
capwap_logging_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", stationaddress);
|
||||
capwap_logging_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) {
|
||||
@ -931,9 +925,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) {
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
capwap_logging_info("AC request deauthentication of station: %s", capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH));
|
||||
capwap_logging_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) {
|
||||
@ -1617,7 +1609,6 @@ void wifi_wlan_receive_ac_frame(struct wifi_wlan* wlan, const struct ieee80211_h
|
||||
/* */
|
||||
int wifi_station_authorize(struct wifi_wlan* wlan, struct station_add_params* params) {
|
||||
struct wifi_station* station;
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
ASSERT(wlan != NULL);
|
||||
ASSERT(wlan->device != NULL);
|
||||
@ -1632,7 +1623,7 @@ int wifi_station_authorize(struct wifi_wlan* wlan, struct station_add_params* pa
|
||||
}
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Authorized station: %s", capwap_printf_macaddress(buffer, params->address, MACADDRESS_EUI48_LENGTH));
|
||||
capwap_logging_info("Authorized station: %s", station->addrtext);
|
||||
|
||||
/* */
|
||||
capwap_timeout_deletetimer(g_wifiglobal.timeout, station->idtimeout);
|
||||
@ -1651,7 +1642,6 @@ int wifi_station_authorize(struct wifi_wlan* wlan, struct station_add_params* pa
|
||||
/* */
|
||||
int wifi_station_deauthorize(struct wifi_device* device, const uint8_t* address) {
|
||||
struct wifi_station* station;
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
ASSERT(device != NULL);
|
||||
ASSERT(address != NULL);
|
||||
@ -1663,7 +1653,7 @@ int wifi_station_deauthorize(struct wifi_device* device, const uint8_t* address)
|
||||
}
|
||||
|
||||
/* Station deauthorized */
|
||||
capwap_logging_info("Deauthorize station: %s", capwap_printf_macaddress(buffer, address, MACADDRESS_EUI48_LENGTH));
|
||||
capwap_logging_info("Deauthorize station: %s", station->addrtext);
|
||||
wifi_wlan_deauthentication_station(station->wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
|
||||
|
||||
return 1;
|
||||
|
@ -331,6 +331,7 @@ struct wifi_wlan {
|
||||
|
||||
struct wifi_station {
|
||||
uint8_t address[MACADDRESS_EUI48_LENGTH];
|
||||
char addrtext[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
/* */
|
||||
struct wifi_wlan* wlan;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "capwap_array.h"
|
||||
#include "capwap_list.h"
|
||||
#include "capwap_element.h"
|
||||
#include "capwap_network.h"
|
||||
#include <netlink/genl/genl.h>
|
||||
#include <netlink/genl/family.h>
|
||||
#include <netlink/genl/ctrl.h>
|
||||
|
Loading…
Reference in New Issue
Block a user