Added Delete Station Message Element into Station Configuration Message.

This commit is contained in:
vemax78 2014-04-15 22:26:31 +02:00
parent 21661277a0
commit fbd717b779
5 changed files with 67 additions and 5 deletions

View File

@ -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(&notify, 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*)&notify, sizeof(struct ac_notify_delete_station_status));
}
/* */

View File

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

View File

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

View File

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

View File

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