Add business logic of Authentication/Association in SplitMAC mode.
This commit is contained in:
@ -4,18 +4,18 @@
|
||||
#include "ac_backend.h"
|
||||
|
||||
/* */
|
||||
static void ac_stations_delete_station_from_global_cache(struct ac_session_data_t* sessiondata, uint8_t* address) {
|
||||
struct ac_session_data_t* ownersession;
|
||||
static void ac_stations_delete_station_from_global_cache(struct ac_session_t* session, uint8_t* address) {
|
||||
struct ac_session_t* ownersession;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(address != NULL);
|
||||
|
||||
/* */
|
||||
capwap_rwlock_wrlock(&g_ac.stationslock);
|
||||
|
||||
/* Can delete global reference only if match session handler */
|
||||
ownersession = (struct ac_session_data_t*)capwap_hash_search(g_ac.stations, address);
|
||||
if (ownersession == sessiondata) {
|
||||
ownersession = (struct ac_session_t*)capwap_hash_search(g_ac.stations, address);
|
||||
if (ownersession == session) {
|
||||
capwap_hash_delete(g_ac.stations, address);
|
||||
}
|
||||
|
||||
@ -23,18 +23,26 @@ static void ac_stations_delete_station_from_global_cache(struct ac_session_data_
|
||||
}
|
||||
|
||||
/* */
|
||||
static void ac_stations_reset_station(struct ac_session_data_t* sessiondata, struct ac_station* station, struct ac_wlan* wlan) {
|
||||
ASSERT(sessiondata != NULL);
|
||||
static void ac_stations_reset_station(struct ac_session_t* session, struct ac_station* station, struct ac_wlan* wlan) {
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(station != NULL);
|
||||
|
||||
/* Remove reference from current WLAN */
|
||||
if (station->wlan) {
|
||||
if (station->aid) {
|
||||
if (station->wlan->macmode == CAPWAP_ADD_WLAN_MACMODE_SPLIT) {
|
||||
ieee80211_aid_free(station->wlan->aidbitfield, station->aid);
|
||||
}
|
||||
|
||||
station->aid = 0;
|
||||
}
|
||||
|
||||
/* Remove reference from current WLAN */
|
||||
capwap_itemlist_remove(station->wlan->stations, station->wlanitem);
|
||||
}
|
||||
|
||||
/* Remove timers */
|
||||
if (station->idtimeout != CAPWAP_TIMEOUT_INDEX_NO_SET) {
|
||||
capwap_timeout_deletetimer(sessiondata->timeout, station->idtimeout);
|
||||
capwap_timeout_deletetimer(session->sessiondata->timeout, station->idtimeout);
|
||||
station->idtimeout = CAPWAP_TIMEOUT_INDEX_NO_SET;
|
||||
}
|
||||
|
||||
@ -49,21 +57,21 @@ 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) {
|
||||
ASSERT(sessiondata != NULL);
|
||||
static void ac_stations_destroy_station(struct ac_session_t* session, struct ac_station* station) {
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(station != NULL);
|
||||
|
||||
/* */
|
||||
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);
|
||||
ac_stations_delete_station_from_global_cache(session, station->address);
|
||||
|
||||
/* Remove reference from WLAN */
|
||||
ac_stations_reset_station(sessiondata, station, NULL);
|
||||
ac_stations_reset_station(session, station, NULL);
|
||||
|
||||
/* */
|
||||
capwap_hash_delete(sessiondata->wlans->stations, station->address);
|
||||
capwap_hash_delete(session->wlans->stations, station->address);
|
||||
|
||||
/* Free station reference with itemlist */
|
||||
capwap_itemlist_free(station->wlanitem);
|
||||
@ -79,33 +87,39 @@ static unsigned long ac_wlans_item_gethash(const void* key, unsigned long keysiz
|
||||
}
|
||||
|
||||
/* */
|
||||
void ac_wlans_init(struct ac_session_data_t* sessiondata) {
|
||||
ASSERT(sessiondata != NULL);
|
||||
void ac_wlans_init(struct ac_session_t* session) {
|
||||
int i;
|
||||
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans == NULL);
|
||||
|
||||
/* */
|
||||
sessiondata->wlans = (struct ac_wlans*)capwap_alloc(sizeof(struct ac_wlans));
|
||||
memset(sessiondata->wlans, 0, sizeof(struct ac_wlans));
|
||||
session->wlans = (struct ac_wlans*)capwap_alloc(sizeof(struct ac_wlans));
|
||||
memset(session->wlans, 0, sizeof(struct ac_wlans));
|
||||
|
||||
/* */
|
||||
sessiondata->wlans->stations = capwap_hash_create(AC_WLANS_STATIONS_HASH_SIZE, AC_WLANS_STATIONS_KEY_SIZE, ac_wlans_item_gethash, NULL, NULL);
|
||||
session->wlans->stations = capwap_hash_create(AC_WLANS_STATIONS_HASH_SIZE, AC_WLANS_STATIONS_KEY_SIZE, ac_wlans_item_gethash, NULL, NULL);
|
||||
for (i = 0; i < RADIOID_MAX_COUNT; i++) {
|
||||
session->wlans->devices[i].radioid = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
void ac_wlans_destroy(struct ac_session_data_t* sessiondata) {
|
||||
void ac_wlans_destroy(struct ac_session_t* session) {
|
||||
int i;
|
||||
struct capwap_list* items;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
|
||||
/* */
|
||||
for (i = 0; i < RADIOID_MAX_COUNT; i++) {
|
||||
if (sessiondata->wlans->wlans[i]) {
|
||||
items = sessiondata->wlans->wlans[i];
|
||||
if (session->wlans->devices[i].wlans) {
|
||||
items = session->wlans->devices[i].wlans;
|
||||
|
||||
/* Delete WLANS */
|
||||
while (items->first) {
|
||||
ac_wlans_delete_bssid(sessiondata, i + 1, ((struct ac_wlan*)items->first->item)->bssid);
|
||||
ac_wlans_delete_bssid(session, i + 1, ((struct ac_wlan*)items->first->item)->address);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -114,51 +128,52 @@ void ac_wlans_destroy(struct ac_session_data_t* sessiondata) {
|
||||
}
|
||||
|
||||
/* */
|
||||
ASSERT(sessiondata->wlans->stations->count == 0);
|
||||
ASSERT(session->wlans->stations->count == 0);
|
||||
|
||||
/* */
|
||||
capwap_hash_free(sessiondata->wlans->stations);
|
||||
capwap_free(sessiondata->wlans);
|
||||
capwap_hash_free(session->wlans->stations);
|
||||
capwap_free(session->wlans);
|
||||
}
|
||||
|
||||
/* */
|
||||
int ac_wlans_assign_bssid(struct ac_session_data_t* sessiondata, struct ac_wlan* wlan) {
|
||||
int ac_wlans_assign_bssid(struct ac_session_t* session, struct ac_wlan* wlan) {
|
||||
char buffer[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(wlan != NULL);
|
||||
ASSERT(IS_VALID_RADIOID(wlan->radioid));
|
||||
ASSERT(wlan->device != NULL);
|
||||
ASSERT(IS_VALID_RADIOID(wlan->device->radioid));
|
||||
ASSERT(IS_VALID_WLANID(wlan->wlanid));
|
||||
|
||||
/* */
|
||||
if (ac_wlans_get_bssid(sessiondata, wlan->radioid, wlan->bssid)) {
|
||||
if (ac_wlans_get_bssid(session, wlan->device->radioid, wlan->address)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* */
|
||||
wlan->session = sessiondata->session;
|
||||
wlan->sessiondata = sessiondata;
|
||||
wlan->session = session;
|
||||
wlan->sessiondata = session->sessiondata;
|
||||
|
||||
/* Create WLAN list */
|
||||
if (!sessiondata->wlans->wlans[wlan->radioid - 1]) {
|
||||
sessiondata->wlans->wlans[wlan->radioid - 1] = capwap_list_create();
|
||||
if (!session->wlans->devices[wlan->device->radioid - 1].wlans) {
|
||||
session->wlans->devices[wlan->device->radioid - 1].wlans = capwap_list_create();
|
||||
}
|
||||
|
||||
/* Append WLAN to list */
|
||||
capwap_itemlist_insert_after(sessiondata->wlans->wlans[wlan->radioid - 1], NULL, wlan->wlanitem);
|
||||
capwap_itemlist_insert_after(session->wlans->devices[wlan->device->radioid - 1].wlans, NULL, wlan->wlanitem);
|
||||
|
||||
/* */
|
||||
capwap_logging_info("Added new wlan with radioid: %d, wlanid: %d, bssid: %s", (int)wlan->radioid, (int)wlan->wlanid, capwap_printf_macaddress(buffer, wlan->bssid, MACADDRESS_EUI48_LENGTH));
|
||||
capwap_logging_info("Added new wlan with radioid: %d, wlanid: %d, bssid: %s", (int)wlan->device->radioid, (int)wlan->wlanid, capwap_printf_macaddress(buffer, wlan->address, MACADDRESS_EUI48_LENGTH));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* */
|
||||
struct ac_wlan* ac_wlans_create_bssid(uint8_t radioid, uint8_t wlanid, const uint8_t* bssid, struct capwap_80211_addwlan_element* addwlan) {
|
||||
struct ac_wlan* ac_wlans_create_bssid(struct ac_device* device, uint8_t wlanid, const uint8_t* bssid, struct capwap_80211_addwlan_element* addwlan) {
|
||||
struct ac_wlan* wlan;
|
||||
struct capwap_list_item* wlanitem;
|
||||
|
||||
ASSERT(IS_VALID_RADIOID(radioid));
|
||||
ASSERT(device != NULL);
|
||||
ASSERT(IS_VALID_WLANID(wlanid));
|
||||
ASSERT(bssid != NULL);
|
||||
|
||||
@ -169,8 +184,8 @@ struct ac_wlan* ac_wlans_create_bssid(uint8_t radioid, uint8_t wlanid, const uin
|
||||
|
||||
/* Init WLAN */
|
||||
wlan->wlanitem = wlanitem;
|
||||
memcpy(wlan->bssid, bssid, MACADDRESS_EUI48_LENGTH);
|
||||
wlan->radioid = radioid;
|
||||
memcpy(wlan->address, bssid, MACADDRESS_EUI48_LENGTH);
|
||||
wlan->device = device;
|
||||
wlan->wlanid = wlanid;
|
||||
wlan->stations = capwap_list_create();
|
||||
|
||||
@ -192,34 +207,30 @@ struct ac_wlan* ac_wlans_create_bssid(uint8_t radioid, uint8_t wlanid, const uin
|
||||
wlan->tunnelmode = addwlan->tunnelmode;
|
||||
|
||||
wlan->suppressssid = addwlan->suppressssid;
|
||||
wlan->ssid = (uint8_t*)capwap_duplicate_string((const char*)addwlan->ssid);
|
||||
strcpy(wlan->ssid, (const char*)addwlan->ssid);
|
||||
|
||||
return wlan;
|
||||
}
|
||||
|
||||
/* */
|
||||
struct ac_wlan* ac_wlans_get_bssid(struct ac_session_data_t* sessiondata, uint8_t radioid, const uint8_t* bssid) {
|
||||
struct ac_wlan* ac_wlans_get_bssid(struct ac_session_t* session, uint8_t radioid, const uint8_t* bssid) {
|
||||
struct capwap_list_item* search;
|
||||
struct ac_wlan* wlan = NULL;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(IS_VALID_RADIOID(radioid));
|
||||
ASSERT(bssid != NULL);
|
||||
|
||||
/* */
|
||||
if (sessiondata->wlans->wlans[radioid - 1]) {
|
||||
search = sessiondata->wlans->wlans[radioid - 1]->first;
|
||||
while (search) {
|
||||
if (session->wlans->devices[radioid - 1].wlans) {
|
||||
for (search = session->wlans->devices[radioid - 1].wlans->first; search; search = search->next) {
|
||||
struct ac_wlan* item = (struct ac_wlan*)search->item;
|
||||
|
||||
if (!memcmp(bssid, item->bssid, MACADDRESS_EUI48_LENGTH)) {
|
||||
if (!memcmp(bssid, item->address, MACADDRESS_EUI48_LENGTH)) {
|
||||
wlan = item;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Next */
|
||||
search = search->next;
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,28 +238,24 @@ struct ac_wlan* ac_wlans_get_bssid(struct ac_session_data_t* sessiondata, uint8_
|
||||
}
|
||||
|
||||
/* */
|
||||
struct ac_wlan* ac_wlans_get_bssid_with_wlanid(struct ac_session_data_t* sessiondata, uint8_t radioid, uint8_t wlanid) {
|
||||
struct ac_wlan* ac_wlans_get_bssid_with_wlanid(struct ac_session_t* session, uint8_t radioid, uint8_t wlanid) {
|
||||
struct capwap_list_item* search;
|
||||
struct ac_wlan* wlan = NULL;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(IS_VALID_RADIOID(radioid));
|
||||
ASSERT(IS_VALID_WLANID(wlanid));
|
||||
|
||||
/* */
|
||||
if (sessiondata->wlans->wlans[radioid - 1]) {
|
||||
search = sessiondata->wlans->wlans[radioid - 1]->first;
|
||||
while (search) {
|
||||
if (session->wlans->devices[radioid - 1].wlans) {
|
||||
for (search = session->wlans->devices[radioid - 1].wlans->first; search; search = search->next) {
|
||||
struct ac_wlan* item = (struct ac_wlan*)search->item;
|
||||
|
||||
if (wlanid == item->wlanid) {
|
||||
wlan = item;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Next */
|
||||
search = search->next;
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,19 +263,19 @@ struct ac_wlan* ac_wlans_get_bssid_with_wlanid(struct ac_session_data_t* session
|
||||
}
|
||||
|
||||
/* */
|
||||
static void ac_wlans_destroy_bssid(struct ac_session_data_t* sessiondata, struct ac_wlan* wlan) {
|
||||
static void ac_wlans_destroy_bssid(struct ac_session_t* session, struct ac_wlan* wlan) {
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(wlan != NULL);
|
||||
|
||||
/* Free capability */
|
||||
if (wlan->key) {
|
||||
capwap_free(wlan->key);
|
||||
}
|
||||
|
||||
if (wlan->ssid) {
|
||||
capwap_free(wlan->ssid);
|
||||
}
|
||||
|
||||
/* Remove stations */
|
||||
while (wlan->stations->first) {
|
||||
ac_stations_destroy_station(sessiondata, (struct ac_station*)wlan->stations->first->item);
|
||||
ac_stations_destroy_station(session, (struct ac_station*)wlan->stations->first->item);
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -276,43 +283,39 @@ static void ac_wlans_destroy_bssid(struct ac_session_data_t* sessiondata, struct
|
||||
}
|
||||
|
||||
/* */
|
||||
void ac_wlans_delete_bssid(struct ac_session_data_t* sessiondata, uint8_t radioid, const uint8_t* bssid) {
|
||||
void ac_wlans_delete_bssid(struct ac_session_t* session, uint8_t radioid, const uint8_t* bssid) {
|
||||
struct capwap_list_item* search;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(IS_VALID_RADIOID(radioid));
|
||||
ASSERT(bssid != NULL);
|
||||
|
||||
/* */
|
||||
if (sessiondata->wlans->wlans[radioid - 1]) {
|
||||
search = sessiondata->wlans->wlans[radioid - 1]->first;
|
||||
while (search) {
|
||||
if (session->wlans->devices[radioid - 1].wlans) {
|
||||
for (search = session->wlans->devices[radioid - 1].wlans->first; search; search = search->next) {
|
||||
struct ac_wlan* item = (struct ac_wlan*)search->item;
|
||||
|
||||
if (!memcmp(bssid, item->bssid, MACADDRESS_EUI48_LENGTH)) {
|
||||
ac_wlans_destroy_bssid(sessiondata, item);
|
||||
capwap_itemlist_free(capwap_itemlist_remove(sessiondata->wlans->wlans[radioid - 1], search));
|
||||
if (!memcmp(bssid, item->address, MACADDRESS_EUI48_LENGTH)) {
|
||||
ac_wlans_destroy_bssid(session, item);
|
||||
capwap_itemlist_free(capwap_itemlist_remove(session->wlans->devices[radioid - 1].wlans, search));
|
||||
break;
|
||||
}
|
||||
|
||||
/* Next */
|
||||
search = search->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
struct ac_station* ac_stations_get_station(struct ac_session_data_t* sessiondata, uint8_t radioid, const uint8_t* bssid, const uint8_t* address) {
|
||||
struct ac_station* ac_stations_get_station(struct ac_session_t* session, uint8_t radioid, const uint8_t* bssid, const uint8_t* address) {
|
||||
struct ac_station* station;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(address != NULL);
|
||||
|
||||
/* Get station */
|
||||
station = (struct ac_station*)capwap_hash_search(sessiondata->wlans->stations, address);
|
||||
if (station && (station->flags & AC_STATION_FLAGS_ENABLED) && ((radioid == RADIOID_ANY) || (radioid == station->wlan->radioid)) && (!bssid || !memcmp(bssid, station->wlan->bssid, MACADDRESS_EUI48_LENGTH))) {
|
||||
station = (struct ac_station*)capwap_hash_search(session->wlans->stations, address);
|
||||
if (station && (station->flags & AC_STATION_FLAGS_ENABLED) && ((radioid == RADIOID_ANY) || (radioid == station->wlan->device->radioid)) && (!bssid || !memcmp(bssid, station->wlan->address, MACADDRESS_EUI48_LENGTH))) {
|
||||
return station;
|
||||
}
|
||||
|
||||
@ -320,16 +323,16 @@ struct ac_station* ac_stations_get_station(struct ac_session_data_t* sessiondata
|
||||
}
|
||||
|
||||
/* */
|
||||
struct ac_station* ac_stations_create_station(struct ac_session_data_t* sessiondata, uint8_t radioid, const uint8_t* bssid, const uint8_t* address) {
|
||||
struct ac_station* ac_stations_create_station(struct ac_session_t* session, uint8_t radioid, const uint8_t* bssid, const uint8_t* address) {
|
||||
char buffer1[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
char buffer2[CAPWAP_MACADDRESS_EUI48_BUFFER];
|
||||
struct ac_wlan* wlan;
|
||||
struct ac_session_data_t* ownersession;
|
||||
struct ac_station* station;
|
||||
struct ac_session_t* ownersession;
|
||||
struct capwap_list_item* stationitem;
|
||||
struct ac_station* station = NULL;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(IS_VALID_RADIOID(radioid));
|
||||
ASSERT(bssid != NULL);
|
||||
ASSERT(address != NULL);
|
||||
@ -339,74 +342,79 @@ struct ac_station* ac_stations_create_station(struct ac_session_data_t* sessiond
|
||||
capwap_printf_macaddress(buffer2, address, MACADDRESS_EUI48_LENGTH);
|
||||
capwap_logging_info("Create station to radioid: %d, bssid: %s, station address: %s", (int)radioid, buffer1, buffer2);
|
||||
|
||||
/* Get session that owns the station */
|
||||
capwap_rwlock_rdlock(&g_ac.stationslock);
|
||||
ownersession = (struct ac_session_data_t*)capwap_hash_search(g_ac.stations, address);
|
||||
capwap_rwlock_exit(&g_ac.stationslock);
|
||||
/* */
|
||||
wlan = ac_wlans_get_bssid(session, radioid, bssid);
|
||||
if (wlan) {
|
||||
/* Get session that owns the station */
|
||||
capwap_rwlock_rdlock(&g_ac.stationslock);
|
||||
ownersession = (struct ac_session_t*)capwap_hash_search(g_ac.stations, address);
|
||||
capwap_rwlock_exit(&g_ac.stationslock);
|
||||
|
||||
/* If request change owner of station */
|
||||
if (ownersession != sessiondata) {
|
||||
/* Release station from old owner */
|
||||
if (ownersession) {
|
||||
ac_session_data_send_action(ownersession, AC_SESSION_DATA_ACTION_ROAMING_STATION, 0, (void*)address, MACADDRESS_EUI48_LENGTH);
|
||||
/* If request change owner of station */
|
||||
if (ownersession != session) {
|
||||
/* Release station from old owner */
|
||||
if (ownersession) {
|
||||
ac_session_data_send_action(ownersession->sessiondata, AC_SESSION_DATA_ACTION_ROAMING_STATION, 0, (void*)address, MACADDRESS_EUI48_LENGTH);
|
||||
}
|
||||
|
||||
/* Set station into Global Cache Stations List */
|
||||
capwap_rwlock_wrlock(&g_ac.stationslock);
|
||||
capwap_hash_add(g_ac.stations, address, session);
|
||||
capwap_rwlock_exit(&g_ac.stationslock);
|
||||
}
|
||||
|
||||
/* Set station into Global Cache Stations List */
|
||||
capwap_rwlock_wrlock(&g_ac.stationslock);
|
||||
capwap_hash_add(g_ac.stations, address, sessiondata);
|
||||
capwap_rwlock_exit(&g_ac.stationslock);
|
||||
}
|
||||
|
||||
/* */
|
||||
wlan = ac_wlans_get_bssid(sessiondata, radioid, bssid);
|
||||
station = (struct ac_station*)capwap_hash_search(sessiondata->wlans->stations, address);
|
||||
if (!station) {
|
||||
stationitem = capwap_itemlist_create(sizeof(struct ac_station));
|
||||
station = (struct ac_station*)stationitem->item;
|
||||
memset(station, 0, sizeof(struct ac_station));
|
||||
|
||||
/* */
|
||||
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;
|
||||
station = (struct ac_station*)capwap_hash_search(session->wlans->stations, address);
|
||||
if (!station) {
|
||||
stationitem = capwap_itemlist_create(sizeof(struct ac_station));
|
||||
station = (struct ac_station*)stationitem->item;
|
||||
memset(station, 0, sizeof(struct ac_station));
|
||||
|
||||
/* */
|
||||
capwap_hash_add(sessiondata->wlans->stations, address, station);
|
||||
/* */
|
||||
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;
|
||||
|
||||
/* */
|
||||
capwap_hash_add(session->wlans->stations, address, station);
|
||||
}
|
||||
|
||||
/* Set station to WLAN */
|
||||
ac_stations_reset_station(session, station, wlan);
|
||||
station->flags |= AC_STATION_FLAGS_ENABLED;
|
||||
} else {
|
||||
capwap_logging_warning("Unable to find radioid: %d, bssid: %s", (int)radioid, buffer1);
|
||||
}
|
||||
|
||||
/* Set station to WLAN */
|
||||
ac_stations_reset_station(sessiondata, station, wlan);
|
||||
station->flags |= AC_STATION_FLAGS_ENABLED;
|
||||
|
||||
return station;
|
||||
}
|
||||
|
||||
/* */
|
||||
void ac_stations_delete_station(struct ac_session_data_t* sessiondata, struct ac_station* station) {
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
void ac_stations_delete_station(struct ac_session_t* session, struct ac_station* station) {
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(station != NULL);
|
||||
|
||||
/* Deauthorize station */
|
||||
ac_stations_deauthorize_station(sessiondata, station);
|
||||
ac_stations_deauthorize_station(session, station);
|
||||
|
||||
/* Destroy station reference */
|
||||
ac_stations_destroy_station(sessiondata, station);
|
||||
ac_stations_destroy_station(session, station);
|
||||
}
|
||||
|
||||
/* */
|
||||
void ac_stations_authorize_station(struct ac_session_data_t* sessiondata, struct ac_station* station) {
|
||||
void ac_stations_authorize_station(struct ac_session_t* session, struct ac_station* station) {
|
||||
struct ac_notify_station_configuration_ieee8011_add_station notify;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(station != NULL);
|
||||
|
||||
/* Active Station only if Authenticated, Associated and not Authrizated */
|
||||
if ((station->flags & AC_STATION_FLAGS_AUTHENTICATED) && (station->flags & AC_STATION_FLAGS_ASSOCIATE) && !(station->flags & AC_STATION_FLAGS_AUTHORIZED)) {
|
||||
memset(¬ify, 0, sizeof(struct ac_notify_station_configuration_ieee8011_add_station));
|
||||
notify.radioid = station->wlan->radioid;
|
||||
notify.radioid = station->wlan->device->radioid;
|
||||
memcpy(notify.address, station->address, MACADDRESS_EUI48_LENGTH);
|
||||
notify.wlanid = station->wlan->wlanid;
|
||||
notify.associationid = station->aid;
|
||||
@ -414,34 +422,34 @@ void ac_stations_authorize_station(struct ac_session_data_t* sessiondata, struct
|
||||
notify.supportedratescount = station->supportedratescount;
|
||||
memcpy(notify.supportedrates, station->supportedrates, station->supportedratescount);
|
||||
|
||||
ac_session_send_action(sessiondata->session, AC_SESSION_ACTION_STATION_CONFIGURATION_IEEE80211_ADD_STATION, 0, ¬ify, sizeof(struct ac_notify_station_configuration_ieee8011_add_station));
|
||||
ac_session_send_action(session, AC_SESSION_ACTION_STATION_CONFIGURATION_IEEE80211_ADD_STATION, 0, ¬ify, sizeof(struct ac_notify_station_configuration_ieee8011_add_station));
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
void ac_stations_deauthorize_station(struct ac_session_data_t* sessiondata, struct ac_station* station) {
|
||||
void ac_stations_deauthorize_station(struct ac_session_t* session, struct ac_station* station) {
|
||||
int responselength;
|
||||
uint8_t buffer[IEEE80211_MTU];
|
||||
struct ieee80211_deauthentication_params ieee80211_params;
|
||||
struct ac_notify_station_configuration_ieee8011_delete_station notify;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(sessiondata->wlans != NULL);
|
||||
ASSERT(session != NULL);
|
||||
ASSERT(session->wlans != NULL);
|
||||
ASSERT(station != NULL);
|
||||
|
||||
if (station->flags & AC_STATION_FLAGS_AUTHORIZED) {
|
||||
/* Deauthorize station */
|
||||
memset(¬ify, 0, sizeof(struct ac_notify_station_configuration_ieee8011_delete_station));
|
||||
notify.radioid = station->wlan->radioid;
|
||||
notify.radioid = station->wlan->device->radioid;
|
||||
memcpy(notify.address, station->address, MACADDRESS_EUI48_LENGTH);
|
||||
|
||||
/* */
|
||||
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, ¬ify, sizeof(struct ac_notify_station_configuration_ieee8011_delete_station));
|
||||
ac_session_send_action(session, AC_SESSION_ACTION_STATION_CONFIGURATION_IEEE80211_DELETE_STATION, 0, ¬ify, sizeof(struct ac_notify_station_configuration_ieee8011_delete_station));
|
||||
} 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);
|
||||
memcpy(ieee80211_params.bssid, station->wlan->address, MACADDRESS_EUI48_LENGTH);
|
||||
memcpy(ieee80211_params.station, station->address, MACADDRESS_EUI48_LENGTH);
|
||||
ieee80211_params.reasoncode = IEEE80211_REASON_PREV_AUTH_NOT_VALID;
|
||||
|
||||
@ -449,7 +457,7 @@ void ac_stations_deauthorize_station(struct ac_session_data_t* sessiondata, stru
|
||||
responselength = ieee80211_create_deauthentication(buffer, IEEE80211_MTU, &ieee80211_params);
|
||||
if (responselength > 0) {
|
||||
station->flags &= ~(AC_STATION_FLAGS_AUTHENTICATED | AC_STATION_FLAGS_ASSOCIATE);
|
||||
ac_session_data_send_data_packet(sessiondata, station->wlan->radioid, station->wlan->wlanid, buffer, responselength, 1);
|
||||
ac_session_data_send_data_packet(session->sessiondata, station->wlan->device->radioid, station->wlan->wlanid, buffer, responselength, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -464,7 +472,7 @@ void ac_stations_timeout(struct capwap_timeout* timeout, unsigned long index, vo
|
||||
switch (station->timeoutaction) {
|
||||
case AC_STATION_TIMEOUT_ACTION_DEAUTHENTICATE: {
|
||||
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);
|
||||
ac_stations_delete_station((struct ac_session_t*)param, station);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user