From fbd717b77967f73c2e815451b20fea0dc01fef81 Mon Sep 17 00:00:00 2001 From: vemax78 Date: Tue, 15 Apr 2014 22:26:31 +0200 Subject: [PATCH] Added Delete Station Message Element into Station Configuration Message. --- src/ac/ac_dfa_run.c | 18 +++++++++++++++--- src/ac/ac_session.h | 8 ++++++++ src/ac/ac_session_data.c | 22 +++++++++++++++++++++- src/common/capwap_element.c | 2 ++ src/wtp/wtp_radio.c | 22 +++++++++++++++++++++- 5 files changed, 67 insertions(+), 5 deletions(-) diff --git a/src/ac/ac_dfa_run.c b/src/ac/ac_dfa_run.c index 55220b3..a8b52dc 100644 --- a/src/ac/ac_dfa_run.c +++ b/src/ac/ac_dfa_run.c @@ -162,10 +162,22 @@ static void execute_ieee80211_station_configuration_response_addstation(struct a /* */ static void execute_ieee80211_station_configuration_response_deletestation(struct ac_session_t* session, struct capwap_parsed_packet* packet, struct capwap_parsed_packet* requestpacket) { - //struct capwap_deletestation_element* deletestation; + struct capwap_deletestation_element* deletestation; + struct ac_notify_delete_station_status notify; + struct capwap_resultcode_element* resultcode; - /* TODO */ - //deletestation = (struct capwap_deletestation_element*)capwap_get_message_element_data(requestpacket, CAPWAP_ELEMENT_DELETESTATION); + /* */ + resultcode = (struct capwap_resultcode_element*)capwap_get_message_element_data(packet, CAPWAP_ELEMENT_RESULTCODE); + deletestation = (struct capwap_deletestation_element*)capwap_get_message_element_data(requestpacket, CAPWAP_ELEMENT_DELETESTATION); + + /* */ + memset(¬ify, 0, sizeof(struct ac_notify_delete_station_status)); + + notify.radioid = deletestation->radioid; + memcpy(notify.address, deletestation->address, MACADDRESS_EUI48_LENGTH); + notify.statuscode = resultcode->code; + + ac_session_data_send_action(session->sessiondata, AC_SESSION_DATA_ACTION_DELETE_STATION_STATUS, 0, (void*)¬ify, sizeof(struct ac_notify_delete_station_status)); } /* */ diff --git a/src/ac/ac_session.h b/src/ac/ac_session.h index e86ddab..04e464b 100644 --- a/src/ac/ac_session.h +++ b/src/ac/ac_session.h @@ -30,6 +30,7 @@ struct ac_session_control { #define AC_SESSION_DATA_ACTION_ROAMING_STATION 1 #define AC_SESSION_DATA_ACTION_ASSIGN_BSSID 2 #define AC_SESSION_DATA_ACTION_ADD_STATION_STATUS 3 +#define AC_SESSION_DATA_ACTION_DELETE_STATION_STATUS 4 /* */ struct ac_session_action { @@ -100,6 +101,13 @@ struct ac_notify_add_station_status { uint16_t statuscode; }; +/* */ +struct ac_notify_delete_station_status { + uint8_t radioid; + uint8_t address[MACADDRESS_EUI48_LENGTH]; + uint16_t statuscode; +}; + /* */ struct ac_session_t; struct ac_session_data_t; diff --git a/src/ac/ac_session_data.c b/src/ac/ac_session_data.c index 53ce3e2..b6540ff 100644 --- a/src/ac/ac_session_data.c +++ b/src/ac/ac_session_data.c @@ -21,7 +21,6 @@ static int ac_session_data_action_add_station_status(struct ac_session_data_t* s 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)); /* */ @@ -37,6 +36,22 @@ static int ac_session_data_action_add_station_status(struct ac_session_data_t* s return AC_ERROR_ACTION_SESSION; } +/* */ +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); + + /* */ + ac_stations_delete_station(sessiondata, station); + } + + return AC_ERROR_ACTION_SESSION; +} + /* */ static int ac_session_data_action_execute(struct ac_session_data_t* sessiondata, struct ac_session_action* action) { int result = AC_ERROR_ACTION_SESSION; @@ -63,6 +78,11 @@ static int ac_session_data_action_execute(struct ac_session_data_t* sessiondata, result = ac_session_data_action_add_station_status(sessiondata, (struct ac_notify_add_station_status*)action->data); break; } + + case AC_SESSION_DATA_ACTION_DELETE_STATION_STATUS: { + result = ac_session_data_action_delete_station_status(sessiondata, (struct ac_notify_delete_station_status*)action->data); + break; + } } return result; diff --git a/src/common/capwap_element.c b/src/common/capwap_element.c index e4f8146..59b3514 100644 --- a/src/common/capwap_element.c +++ b/src/common/capwap_element.c @@ -670,6 +670,8 @@ int capwap_validate_parsed_packet(struct capwap_parsed_packet* packet, struct ca } else { return 0; } + } else if (capwap_get_message_element(packet, CAPWAP_ELEMENT_DELETESTATION)) { + return 0; } break; diff --git a/src/wtp/wtp_radio.c b/src/wtp/wtp_radio.c index bf87aec..0d3d41a 100644 --- a/src/wtp/wtp_radio.c +++ b/src/wtp/wtp_radio.c @@ -720,7 +720,27 @@ uint32_t wtp_radio_add_station(struct capwap_parsed_packet* packet) { /* */ uint32_t wtp_radio_delete_station(struct capwap_parsed_packet* packet) { - /* TODO */ + struct wtp_radio* radio; + struct station_delete_params stationparams; + struct capwap_deletestation_element* deletestation; + + /* Get message elements */ + deletestation = (struct capwap_deletestation_element*)capwap_get_message_element_data(packet, CAPWAP_ELEMENT_DELETESTATION); + + /* Get physical radio */ + radio = wtp_radio_get_phy(deletestation->radioid); + if (!radio) { + return CAPWAP_RESULTCODE_FAILURE; + } + + /* Authorize station */ + memset(&stationparams, 0, sizeof(struct station_delete_params)); + stationparams.address = deletestation->address; + + if (wifi_station_delete(radio->devicehandle, &stationparams)) { + return CAPWAP_RESULTCODE_FAILURE; + } + return CAPWAP_RESULTCODE_SUCCESS; }