Fix disconnect station in local mac.

Fix management of AC IEEE802.11 management packet to station.
This commit is contained in:
vemax78 2014-04-23 22:11:24 +02:00
parent ebb4eb0c98
commit 1c810c2d72
4 changed files with 49 additions and 81 deletions

View File

@ -430,19 +430,16 @@ void ac_stations_deauthorize_station(struct ac_session_data_t* sessiondata, stru
ASSERT(sessiondata->wlans != NULL);
ASSERT(station != NULL);
/* Deauthorize station */
if (station->flags & AC_STATION_FLAGS_AUTHORIZED) {
/* Deauthorize station */
memset(&notify, 0, sizeof(struct ac_notify_station_configuration_ieee8011_delete_station));
notify.radioid = station->wlan->radioid;
memcpy(notify.address, station->address, MACADDRESS_EUI48_LENGTH);
/* */
station->flags &= ~AC_STATION_FLAGS_AUTHORIZED;
station->flags &= ~(AC_STATION_FLAGS_AUTHENTICATED | AC_STATION_FLAGS_ASSOCIATE | AC_STATION_FLAGS_AUTHORIZED);
ac_session_send_action(sessiondata->session, AC_SESSION_ACTION_STATION_CONFIGURATION_IEEE80211_DELETE_STATION, 0, &notify, sizeof(struct ac_notify_station_configuration_ieee8011_delete_station));
}
/* Deauthenticate station */
if (station->flags & AC_STATION_FLAGS_AUTHENTICATED) {
} else if (station->flags & AC_STATION_FLAGS_AUTHENTICATED) {
/* Create deauthentication packet */
memset(&ieee80211_params, 0, sizeof(struct ieee80211_deauthentication_params));
memcpy(ieee80211_params.bssid, station->wlan->bssid, MACADDRESS_EUI48_LENGTH);

View File

@ -902,21 +902,16 @@ static void wifi_wlan_receive_station_mgmt_ackframe(struct wifi_wlan* wlan, cons
static int wifi_wlan_receive_ac_mgmt_authentication(struct wifi_wlan* wlan, const struct ieee80211_header_mgmt* frame, int length) {
int ielength;
struct wifi_station* station;
int forwardframe = 1;
int forwardframe = 0;
/* Information Elements packet length */
ielength = length - (sizeof(struct ieee80211_header) + sizeof(frame->authetication));
if (ielength < 0) {
return 0;
}
/* */
station = wifi_station_get(wlan, frame->da);
if (station) {
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_LOCAL) {
forwardframe = 0;
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
/* TODO */
if (ielength >= 0) {
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
station = wifi_station_get(wlan, frame->da);
if (station) {
/* TODO */
}
}
}
@ -927,30 +922,23 @@ static int wifi_wlan_receive_ac_mgmt_authentication(struct wifi_wlan* wlan, cons
static int wifi_wlan_receive_ac_mgmt_association_response(struct wifi_wlan* wlan, const struct ieee80211_header_mgmt* frame, int length) {
int ielength;
struct wifi_station* station;
int forwardframe = 1;
int forwardframe = 0;
/* Information Elements packet length */
ielength = length - (sizeof(struct ieee80211_header) + sizeof(frame->associationresponse));
if (ielength < 0) {
return 0;
}
if (ielength >= 0) {
station = wifi_station_get(wlan, frame->da);
if (station) {
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_LOCAL) {
if (frame->associationresponse.statuscode != IEEE80211_STATUS_SUCCESS) {
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
/* */
station = wifi_station_get(wlan, frame->da);
if (station) {
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_LOCAL) {
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
/* */
forwardframe = 0;
/* */
if (frame->associationresponse.statuscode != IEEE80211_STATUS_SUCCESS) {
capwap_logging_info("AC request deauthentication of station: %s", capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH));
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
capwap_logging_info("AC request deauthentication of station: %s", capwap_printf_macaddress(buffer, station->address, MACADDRESS_EUI48_LENGTH));
wifi_wlan_deauthentication_station(wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
}
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
/* TODO */
}
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
/* TODO */
}
}
@ -961,21 +949,16 @@ static int wifi_wlan_receive_ac_mgmt_association_response(struct wifi_wlan* wlan
static int wifi_wlan_receive_ac_mgmt_reassociation_response(struct wifi_wlan* wlan, const struct ieee80211_header_mgmt* frame, int length) {
int ielength;
struct wifi_station* station;
int forwardframe = 1;
int forwardframe = 0;
/* Information Elements packet length */
ielength = length - (sizeof(struct ieee80211_header) + sizeof(frame->reassociationresponse));
if (ielength < 0) {
return 0;
}
/* */
station = wifi_station_get(wlan, frame->da);
if (station) {
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_LOCAL) {
forwardframe = 0;
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
/* TODO */
if (ielength >= 0) {
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
station = wifi_station_get(wlan, frame->da);
if (station) {
/* TODO */
}
}
}
@ -986,7 +969,6 @@ static int wifi_wlan_receive_ac_mgmt_reassociation_response(struct wifi_wlan* wl
static int wifi_wlan_receive_ac_mgmt_disassociation(struct wifi_wlan* wlan, const struct ieee80211_header_mgmt* frame, int length) {
int ielength;
struct wifi_station* station;
int forwardframe = 1;
/* Information Elements packet length */
ielength = length - (sizeof(struct ieee80211_header) + sizeof(frame->disassociation));
@ -997,21 +979,23 @@ static int wifi_wlan_receive_ac_mgmt_disassociation(struct wifi_wlan* wlan, cons
/* */
station = wifi_station_get(wlan, frame->da);
if (station) {
if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_LOCAL) {
/* TODO */
} else if (wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
/* TODO */
/* Deautherize station */
if (station->flags & WIFI_STATION_FLAGS_AUTHORIZED) {
station->flags &= ~WIFI_STATION_FLAGS_AUTHORIZED;
wlan->device->instance->ops->station_deauthorize(wlan, station->address);
}
/* Deassociate station */
station->flags &= ~WIFI_STATION_FLAGS_ASSOCIATE;
}
return forwardframe;
return 1;
}
/* */
static int wifi_wlan_receive_ac_mgmt_deauthentication(struct wifi_wlan* wlan, const struct ieee80211_header_mgmt* frame, int length) {
int ielength;
struct wifi_station* station;
int forwardframe = 1;
/* Information Elements packet length */
ielength = length - (sizeof(struct ieee80211_header) + sizeof(frame->deauthetication));
@ -1019,18 +1003,18 @@ static int wifi_wlan_receive_ac_mgmt_deauthentication(struct wifi_wlan* wlan, co
return 0;
}
/* Clean station */
/* Delete station */
station = wifi_station_get(wlan, frame->da);
if (station) {
wifi_station_delete(station);
}
return forwardframe;
return 1;
}
/* */
static int wifi_wlan_receive_ac_mgmt_frame(struct wifi_wlan* wlan, const struct ieee80211_header_mgmt* frame, int length, uint16_t framecontrol_subtype) {
int forwardframe = 1;
int forwardframe = 0;
switch (framecontrol_subtype) {
case IEEE80211_FRAMECONTROL_MGMT_SUBTYPE_AUTHENTICATION: {
@ -1665,27 +1649,24 @@ int wifi_station_authorize(struct wifi_wlan* wlan, struct station_add_params* pa
}
/* */
int wifi_station_deauthorize(struct wifi_device* device, struct station_delete_params* params) {
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(params != NULL);
ASSERT(address != NULL);
/* Get station */
station = wifi_station_get(NULL, params->address);
station = wifi_station_get(NULL, address);
if (!station || !station->wlan) {
return -1;
} else if (!(station->flags & WIFI_STATION_FLAGS_AUTHORIZED)) {
return 0;
}
/* */
capwap_logging_info("Deauthorize station: %s", capwap_printf_macaddress(buffer, params->address, MACADDRESS_EUI48_LENGTH));
/* Station deauthorized */
station->flags &= ~WIFI_STATION_FLAGS_AUTHORIZED;
return device->instance->ops->station_deauthorize(station->wlan, station->address);
capwap_logging_info("Deauthorize station: %s", capwap_printf_macaddress(buffer, address, MACADDRESS_EUI48_LENGTH));
wifi_wlan_deauthentication_station(station->wlan, station, IEEE80211_REASON_PREV_AUTH_NOT_VALID, 0);
return 1;
}
/* */

View File

@ -123,11 +123,6 @@ struct station_add_params {
uint8_t* address;
};
/* */
struct station_delete_params {
uint8_t* address;
};
/* Interface capability */
struct wifi_freq_capability {
unsigned long flags;
@ -423,7 +418,7 @@ void wifi_wlan_receive_ac_frame(struct wifi_wlan* wlan, const struct ieee80211_h
/* Station management */
int wifi_station_authorize(struct wifi_wlan* wlan, struct station_add_params* params);
int wifi_station_deauthorize(struct wifi_device* device, struct station_delete_params* params);
int wifi_station_deauthorize(struct wifi_device* device, const uint8_t* address);
/* Util functions */
uint32_t wifi_iface_index(const char* ifname);

View File

@ -767,7 +767,6 @@ uint32_t wtp_radio_add_station(struct capwap_parsed_packet* packet) {
/* */
uint32_t wtp_radio_delete_station(struct capwap_parsed_packet* packet) {
struct wtp_radio* radio;
struct station_delete_params stationparams;
struct capwap_deletestation_element* deletestation;
/* Get message elements */
@ -779,11 +778,7 @@ uint32_t wtp_radio_delete_station(struct capwap_parsed_packet* packet) {
return CAPWAP_RESULTCODE_FAILURE;
}
/* Authorize station */
memset(&stationparams, 0, sizeof(struct station_delete_params));
stationparams.address = deletestation->address;
if (wifi_station_deauthorize(radio->devicehandle, &stationparams)) {
if (wifi_station_deauthorize(radio->devicehandle, deletestation->address)) {
return CAPWAP_RESULTCODE_FAILURE;
}