mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-02-12 08:41:51 +00:00
ubus/datastorage/msghandler: cleanup
- Simplify linked list search - code was unnecessarily complex for no benefit - AP record is uniquely identified by BSSID, so remove unnecessary search on SSID as well - Change some data handling to simplify passing of records, pointers, etc - Assure sort order to simplify generating network map - Removed unused fields for collision domain and bandwidth [cleanup commit message] Signed-off-by: Nick Hainke <vincent@systemli.org>
This commit is contained in:
parent
6e03e37ce8
commit
6bf3cd7754
5 changed files with 147 additions and 157 deletions
|
@ -246,24 +246,26 @@ typedef struct client_s {
|
||||||
uint8_t rrm_enabled_capa; //the first byte is enough
|
uint8_t rrm_enabled_capa; //the first byte is enough
|
||||||
} client;
|
} client;
|
||||||
|
|
||||||
|
// (1) Set in parse_to_clients()
|
||||||
|
// (2) Set by list insert operations
|
||||||
typedef struct ap_s {
|
typedef struct ap_s {
|
||||||
struct ap_s* next_ap;
|
struct ap_s* next_ap; // (2)
|
||||||
struct dawn_mac bssid_addr;
|
struct dawn_mac bssid_addr; // (1)
|
||||||
uint32_t freq; // ap_get_nr()
|
uint32_t freq; // ap_get_nr() // (1)
|
||||||
uint8_t ht_support; // eval_probe_metric()
|
uint8_t ht_support; // eval_probe_metric() // (1)
|
||||||
uint8_t vht_support; // eval_probe_metric()
|
uint8_t vht_support; // eval_probe_metric() // (1)
|
||||||
uint32_t channel_utilization; // eval_probe_metric()
|
uint32_t channel_utilization; // eval_probe_metric() // (1)
|
||||||
time_t time; // remove_old...entries
|
time_t time; // remove_old...entries // (2)
|
||||||
uint32_t station_count; // compare_station_count() <- better_ap_available()
|
uint32_t station_count; // compare_station_count() <- better_ap_available() // (1)
|
||||||
uint8_t ssid[SSID_MAX_LEN + 1]; // compare_sid() < -better_ap_available()
|
uint8_t ssid[SSID_MAX_LEN + 1]; // compare_sid() < -better_ap_available() // (1)
|
||||||
char neighbor_report[NEIGHBOR_REPORT_LEN];
|
char neighbor_report[NEIGHBOR_REPORT_LEN]; // (1) // TODO: Check whether we should store and AP one or generate on fly for client
|
||||||
uint32_t op_class; // ubus_send_beacon_report()
|
uint32_t op_class; // ubus_send_beacon_report() // (1)
|
||||||
uint32_t channel; // ubus_send_beacon_report()
|
uint32_t channel; // ubus_send_beacon_report() // (1)
|
||||||
uint32_t collision_domain; // TODO: ap_get_collision_count() never evaluated?
|
//uint32_t collision_domain; // TODO: ap_get_collision_count() never evaluated?
|
||||||
uint32_t bandwidth; // TODO: Never evaluated?
|
//uint32_t bandwidth; // TODO: Never evaluated?
|
||||||
uint32_t ap_weight; // eval_probe_metric()
|
uint32_t ap_weight; // eval_probe_metric() // (1)
|
||||||
char iface[MAX_INTERFACE_NAME];
|
char iface[MAX_INTERFACE_NAME]; // (1)
|
||||||
char hostname[HOST_NAME_MAX];
|
char hostname[HOST_NAME_MAX]; // (1)
|
||||||
} ap;
|
} ap;
|
||||||
|
|
||||||
// ---------------- Defines ----------------
|
// ---------------- Defines ----------------
|
||||||
|
@ -307,7 +309,7 @@ void remove_old_client_entries(time_t current_time, long long int threshold);
|
||||||
|
|
||||||
client *insert_client_to_array(client *entry, time_t expiry);
|
client *insert_client_to_array(client *entry, time_t expiry);
|
||||||
|
|
||||||
int kick_clients(ap* kicking_ap, uint32_t id);
|
int kick_clients(struct dawn_mac bssid, uint32_t id);
|
||||||
|
|
||||||
void update_iw_info(struct dawn_mac bssid);
|
void update_iw_info(struct dawn_mac bssid);
|
||||||
|
|
||||||
|
@ -329,11 +331,11 @@ void remove_old_ap_entries(time_t current_time, long long int threshold);
|
||||||
|
|
||||||
void print_ap_array();
|
void print_ap_array();
|
||||||
|
|
||||||
ap *ap_array_get_ap(struct dawn_mac bssid_mac, const uint8_t* ssid);
|
ap *ap_array_get_ap(struct dawn_mac bssid_mac);
|
||||||
|
|
||||||
int probe_array_set_all_probe_count(struct dawn_mac client_addr, uint32_t probe_count);
|
int probe_array_set_all_probe_count(struct dawn_mac client_addr, uint32_t probe_count);
|
||||||
|
|
||||||
int ap_get_collision_count(int col_domain);
|
//int ap_get_collision_count(int col_domain);
|
||||||
|
|
||||||
void send_beacon_reports(ap *a, int id);
|
void send_beacon_reports(ap *a, int id);
|
||||||
|
|
||||||
|
|
|
@ -158,52 +158,6 @@ static probe_entry** probe_array_find_first_entry(struct dawn_mac client_mac, st
|
||||||
return lo_ptr;
|
return lo_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ap** ap_array_find_first_entry(struct dawn_mac bssid_mac, const uint8_t* ssid)
|
|
||||||
{
|
|
||||||
int lo = 0;
|
|
||||||
ap** lo_ptr = &ap_set;
|
|
||||||
int hi = ap_entry_last;
|
|
||||||
|
|
||||||
dawnlog_debug_func("Entering...");
|
|
||||||
|
|
||||||
while (lo < hi) {
|
|
||||||
ap** i = lo_ptr;
|
|
||||||
int scan_pos = lo;
|
|
||||||
int this_cmp;
|
|
||||||
|
|
||||||
// m is next test position of binary search
|
|
||||||
int m = (lo + hi) / 2;
|
|
||||||
|
|
||||||
// find entry with ordinal position m
|
|
||||||
while (scan_pos++ < m)
|
|
||||||
{
|
|
||||||
i = &((*i)->next_ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ssid)
|
|
||||||
{
|
|
||||||
this_cmp = strcmp((char*)(*i)->ssid, (char*)ssid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this_cmp = 0;
|
|
||||||
}
|
|
||||||
this_cmp = this_cmp ? this_cmp : mac_compare_bb((*i)->bssid_addr, bssid_mac);
|
|
||||||
|
|
||||||
if (this_cmp < 0)
|
|
||||||
{
|
|
||||||
lo = m + 1;
|
|
||||||
lo_ptr = &((*i)->next_ap);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hi = m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lo_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Manage a list of client entries sorted by BSSID and client MAC
|
// Manage a list of client entries sorted by BSSID and client MAC
|
||||||
static struct client_s** client_skip_array_find_first_entry(struct dawn_mac client_mac, struct dawn_mac bssid_mac, bool do_bssid)
|
static struct client_s** client_skip_array_find_first_entry(struct dawn_mac client_mac, struct dawn_mac bssid_mac, bool do_bssid)
|
||||||
{
|
{
|
||||||
|
@ -538,7 +492,7 @@ int better_ap_available(ap *kicking_ap, struct dawn_mac client_mac, struct kicki
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ap* candidate_ap = ap_array_get_ap(i->bssid_addr, kicking_ap->ssid);
|
ap* candidate_ap = ap_array_get_ap(i->bssid_addr);
|
||||||
|
|
||||||
if (candidate_ap == NULL) {
|
if (candidate_ap == NULL) {
|
||||||
dawnlog_trace("Candidate AP not in array\n");
|
dawnlog_trace("Candidate AP not in array\n");
|
||||||
|
@ -621,9 +575,11 @@ int better_ap_available(ap *kicking_ap, struct dawn_mac client_mac, struct kicki
|
||||||
return kick;
|
return kick;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kick_clients(ap* kicking_ap, uint32_t id) {
|
int kick_clients(struct dawn_mac bssid_mac, uint32_t id) {
|
||||||
dawnlog_debug_func("Entering...");
|
dawnlog_debug_func("Entering...");
|
||||||
|
|
||||||
|
ap* kicking_ap = ap_array_get_ap(bssid_mac);
|
||||||
|
|
||||||
pthread_mutex_lock(&client_array_mutex);
|
pthread_mutex_lock(&client_array_mutex);
|
||||||
pthread_mutex_lock(&probe_array_mutex);
|
pthread_mutex_lock(&probe_array_mutex);
|
||||||
|
|
||||||
|
@ -1167,29 +1123,47 @@ probe_entry* insert_to_array(probe_entry* entry, int inc_counter, int save_80211
|
||||||
return entry; // return pointer to what we used, which may not be what was passed in
|
return entry; // return pointer to what we used, which may not be what was passed in
|
||||||
}
|
}
|
||||||
|
|
||||||
ap *insert_to_ap_array(ap* entry, time_t expiry) {
|
static __inline__ ap* ap_array_unlink_entry(ap** i)
|
||||||
dawnlog_debug_func("Entering...");
|
{
|
||||||
|
ap* entry = *i;
|
||||||
pthread_mutex_lock(&ap_array_mutex);
|
*i = entry->next_ap;
|
||||||
|
entry = NULL;
|
||||||
// TODO: Why do we delete and add here rather than update existing?
|
ap_entry_last--;
|
||||||
ap* old_entry = *ap_array_find_first_entry(entry->bssid_addr, entry->ssid);
|
|
||||||
|
|
||||||
if (old_entry != NULL &&
|
|
||||||
mac_is_equal_bb((old_entry)->bssid_addr, entry->bssid_addr) &&
|
|
||||||
!strcmp((char*)old_entry->ssid, (char*)entry->ssid))
|
|
||||||
ap_array_delete(old_entry);
|
|
||||||
|
|
||||||
entry->time = expiry;
|
|
||||||
ap_array_insert(entry);
|
|
||||||
pthread_mutex_unlock(&ap_array_mutex);
|
|
||||||
|
|
||||||
print_ap_array();
|
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ap* ap_array_update_entry(ap* entry) {
|
||||||
|
dawnlog_debug_func("Entering...");
|
||||||
|
|
||||||
|
ap* old_entry = NULL;
|
||||||
|
ap** i = &ap_set;
|
||||||
|
while (*i != NULL && mac_compare_bb(entry->bssid_addr, (*i)->bssid_addr) != 0) {
|
||||||
|
i = &((*i)->next_ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the SSID has not changed
|
||||||
|
if (*i && strcmp((char*)(*i)->ssid, (char*)entry->ssid) == 0)
|
||||||
|
{
|
||||||
|
// Swap entries if same SSID...
|
||||||
|
old_entry = *i;
|
||||||
|
entry->next_ap = old_entry->next_ap;
|
||||||
|
old_entry->next_ap = NULL;
|
||||||
|
*i = entry;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ... otherwise find new position
|
||||||
|
if (*i)
|
||||||
|
old_entry = ap_array_unlink_entry(i);
|
||||||
|
|
||||||
|
ap_array_insert(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return old_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0 // Delete pending if no longer required
|
||||||
// TODO: What is collision domain used for?
|
// TODO: What is collision domain used for?
|
||||||
int ap_get_collision_count(int col_domain) {
|
int ap_get_collision_count(int col_domain) {
|
||||||
|
|
||||||
|
@ -1207,65 +1181,78 @@ int ap_get_collision_count(int col_domain) {
|
||||||
|
|
||||||
return ret_sta_count;
|
return ret_sta_count;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ap *insert_to_ap_array(ap* entry, time_t expiry) {
|
||||||
|
dawnlog_debug_func("Entering...");
|
||||||
|
|
||||||
|
entry->time = expiry;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&ap_array_mutex);
|
||||||
|
ap* old_entry = ap_array_update_entry(entry);
|
||||||
|
pthread_mutex_unlock(&ap_array_mutex);
|
||||||
|
|
||||||
|
if (old_entry)
|
||||||
|
dawn_free(old_entry);
|
||||||
|
|
||||||
|
print_ap_array();
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: Do we need to order this set? Scan of randomly arranged elements is just
|
// AP entries are sorted by SSID and BSSID to simplify display of network tree
|
||||||
// as quick if we're not using an optimised search.
|
void ap_array_insert(ap* entry) {
|
||||||
void ap_array_insert(ap* entry) {
|
|
||||||
ap** i;
|
|
||||||
dawnlog_debug_func("Entering...");;
|
dawnlog_debug_func("Entering...");;
|
||||||
|
|
||||||
for (i = &ap_set; *i != NULL; i = &((*i)->next_ap)) {
|
ap** insert_pos = &ap_set;
|
||||||
// TODO: Not sure these tests are right way around to ensure SSID / MAC ordering
|
|
||||||
// TODO: Do we do any SSID checks elsewhere?
|
while (*insert_pos != NULL)
|
||||||
int sc = strcmp((char*)entry->ssid, (char*)(*i)->ssid);
|
{
|
||||||
if ((sc < 0) || (sc == 0 && mac_compare_bb(entry->bssid_addr, (*i)->bssid_addr) < 0)) {
|
int this_cmp = strcmp((char*)entry->ssid, (char*)(*insert_pos)->ssid);
|
||||||
break;
|
|
||||||
|
if (this_cmp == 0)
|
||||||
|
{
|
||||||
|
this_cmp = mac_compare_bb(entry->bssid_addr, (*insert_pos)->bssid_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this_cmp <= 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
insert_pos = &((*insert_pos)->next_ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->next_ap = *i;
|
entry->next_ap = *insert_pos;
|
||||||
*i = entry;
|
*insert_pos = entry;
|
||||||
ap_entry_last++;
|
ap_entry_last++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ap* ap_array_get_ap(struct dawn_mac bssid_mac, const uint8_t* ssid) {
|
ap* ap_array_get_ap(struct dawn_mac bssid_mac) {
|
||||||
|
|
||||||
dawnlog_debug_func("Entering...");;
|
dawnlog_debug_func("Entering...");;
|
||||||
|
|
||||||
pthread_mutex_lock(&ap_array_mutex);
|
pthread_mutex_lock(&ap_array_mutex);
|
||||||
|
|
||||||
ap* ret = *ap_array_find_first_entry(bssid_mac, ssid);
|
ap* ret = ap_set;
|
||||||
|
|
||||||
|
while (ret && mac_compare_bb(bssid_mac, ret->bssid_addr) != 0) {
|
||||||
|
ret = ret->next_ap;
|
||||||
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&ap_array_mutex);
|
pthread_mutex_unlock(&ap_array_mutex);
|
||||||
|
|
||||||
if (ret != NULL && !mac_is_equal_bb((ret)->bssid_addr, bssid_mac))
|
|
||||||
ret = NULL;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ void ap_array_unlink_next(ap** i)
|
int ap_array_delete(ap* entry) {
|
||||||
{
|
|
||||||
dawnlog_debug_func("Entering...");;
|
|
||||||
|
|
||||||
ap* entry = *i;
|
|
||||||
*i = entry->next_ap;
|
|
||||||
dawn_free(entry);
|
|
||||||
entry = NULL;
|
|
||||||
ap_entry_last--;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ap_array_delete(ap *entry) {
|
|
||||||
int not_found = 1;
|
int not_found = 1;
|
||||||
|
|
||||||
dawnlog_debug_func("Entering...");;
|
dawnlog_debug_func("Entering...");;
|
||||||
|
|
||||||
// TODO: Some parts of AP entry management look at SSID as well. Not this?
|
|
||||||
ap** i = &ap_set;
|
ap** i = &ap_set;
|
||||||
while ( *i != NULL) {
|
while (*i != NULL) {
|
||||||
if (*i == entry) {
|
if (*i == entry) {
|
||||||
ap_array_unlink_next(i);
|
dawn_free(ap_array_unlink_entry(i));
|
||||||
not_found = 0;
|
not_found = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1308,7 +1295,7 @@ void remove_old_ap_entries(time_t current_time, long long int threshold) {
|
||||||
ap **i = &ap_set;
|
ap **i = &ap_set;
|
||||||
while (*i != NULL) {
|
while (*i != NULL) {
|
||||||
if (((*i)->time) < (current_time - threshold)) {
|
if (((*i)->time) < (current_time - threshold)) {
|
||||||
ap_array_unlink_next(i);
|
dawn_free(ap_array_unlink_entry(i));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
i = &((*i)->next_ap);
|
i = &((*i)->next_ap);
|
||||||
|
@ -1470,10 +1457,10 @@ void print_client_array() {
|
||||||
static void print_ap_entry(int level, ap *entry) {
|
static void print_ap_entry(int level, ap *entry) {
|
||||||
if (dawnlog_showing(DAWNLOG_INFO))
|
if (dawnlog_showing(DAWNLOG_INFO))
|
||||||
{
|
{
|
||||||
dawnlog_info("ssid: %s, bssid_addr: " MACSTR ", freq: %d, ht: %d, vht: %d, chan_utilz: %d, col_d: %d, bandwidth: %d, col_count: %d neighbor_report: %s\n",
|
dawnlog_info("ssid: %s, bssid_addr: " MACSTR ", freq: %d, ht: %d, vht: %d, chan_utilz: %d, neighbor_report: %s\n",
|
||||||
entry->ssid, MAC2STR(entry->bssid_addr.u8), entry->freq, entry->ht_support, entry->vht_support,
|
entry->ssid, MAC2STR(entry->bssid_addr.u8), entry->freq, entry->ht_support, entry->vht_support, entry->channel_utilization,
|
||||||
entry->channel_utilization, entry->collision_domain, entry->bandwidth,
|
//entry->collision_domain, ap_get_collision_count(entry->collision_domain), // TODO: Fix format string if readding
|
||||||
ap_get_collision_count(entry->collision_domain), entry->neighbor_report
|
entry->neighbor_report
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ static int array_auto_helper(int action, int i0, int i1)
|
||||||
time_moves_on();
|
time_moves_on();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ap_array_delete(ap_array_get_ap(this_mac, NULL));
|
ap_array_delete(ap_array_get_ap(this_mac));
|
||||||
break;
|
break;
|
||||||
case HELPER_CLIENT:
|
case HELPER_CLIENT:
|
||||||
; // Empty statement to allow label before declaration
|
; // Empty statement to allow label before declaration
|
||||||
|
@ -681,8 +681,8 @@ static int consume_actions(int argc, char* argv[], int harness_verbosity)
|
||||||
memset(ap0->ssid, '*', SSID_MAX_LEN);
|
memset(ap0->ssid, '*', SSID_MAX_LEN);
|
||||||
ap0->ssid[SSID_MAX_LEN] = '\0';
|
ap0->ssid[SSID_MAX_LEN] = '\0';
|
||||||
ap0->neighbor_report[0] = 0;
|
ap0->neighbor_report[0] = 0;
|
||||||
ap0->collision_domain = 0;
|
//ap0->collision_domain = 0;
|
||||||
ap0->bandwidth = 0;
|
//ap0->bandwidth = 0;
|
||||||
ap0->ap_weight = 0;
|
ap0->ap_weight = 0;
|
||||||
|
|
||||||
args_required = 1;
|
args_required = 1;
|
||||||
|
@ -701,8 +701,8 @@ static int consume_actions(int argc, char* argv[], int harness_verbosity)
|
||||||
else if (!strncmp(fn, "stations=", 9)) load_u32(&ap0->station_count, fn + 9);
|
else if (!strncmp(fn, "stations=", 9)) load_u32(&ap0->station_count, fn + 9);
|
||||||
else if (!strncmp(fn, "ssid=", 5)) load_ssid(ap0->ssid, fn + 5);
|
else if (!strncmp(fn, "ssid=", 5)) load_ssid(ap0->ssid, fn + 5);
|
||||||
else if (!strncmp(fn, "neighbors=", 10)) load_string(NEIGHBOR_REPORT_LEN, ap0->neighbor_report, fn + 10);
|
else if (!strncmp(fn, "neighbors=", 10)) load_string(NEIGHBOR_REPORT_LEN, ap0->neighbor_report, fn + 10);
|
||||||
else if (!strncmp(fn, "col_d=", 6)) load_u32(&ap0->collision_domain, fn + 6);
|
//else if (!strncmp(fn, "col_d=", 6)) load_u32(&ap0->collision_domain, fn + 6);
|
||||||
else if (!strncmp(fn, "bandwidth=", 10)) load_u32(&ap0->bandwidth, fn + 10);
|
//else if (!strncmp(fn, "bandwidth=", 10)) load_u32(&ap0->bandwidth, fn + 10);
|
||||||
else if (!strncmp(fn, "weight=", 7)) load_u32(&ap0->ap_weight, fn + 7);
|
else if (!strncmp(fn, "weight=", 7)) load_u32(&ap0->ap_weight, fn + 7);
|
||||||
else {
|
else {
|
||||||
printf("ERROR: Loading AP, but don't recognise assignment \"%s\"\n", fn);
|
printf("ERROR: Loading AP, but don't recognise assignment \"%s\"\n", fn);
|
||||||
|
@ -876,7 +876,7 @@ static int consume_actions(int argc, char* argv[], int harness_verbosity)
|
||||||
hwaddr_aton(argv[1], kick_mac.u8);
|
hwaddr_aton(argv[1], kick_mac.u8);
|
||||||
load_u32(&kick_id, argv[2]);
|
load_u32(&kick_id, argv[2]);
|
||||||
|
|
||||||
while ((kick_clients(ap_array_get_ap(kick_mac, NULL), kick_id) != 0) && safety_count--);
|
while ((kick_clients(kick_mac, kick_id) != 0) && safety_count--);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(*argv, "better_ap_available") == 0)
|
else if (strcmp(*argv, "better_ap_available") == 0)
|
||||||
|
@ -911,11 +911,11 @@ static int consume_actions(int argc, char* argv[], int harness_verbosity)
|
||||||
strcpy(nb, argv[4]);
|
strcpy(nb, argv[4]);
|
||||||
}
|
}
|
||||||
strncpy(neighbor.nr, nb, NEIGHBOR_REPORT_LEN);
|
strncpy(neighbor.nr, nb, NEIGHBOR_REPORT_LEN);
|
||||||
tr = better_ap_available(ap_array_get_ap(bssid_mac, NULL), client_mac, &neighbor_list);
|
tr = better_ap_available(ap_array_get_ap(bssid_mac), client_mac, &neighbor_list);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tr = better_ap_available(ap_array_get_ap(bssid_mac, NULL), client_mac, NULL);
|
tr = better_ap_available(ap_array_get_ap(bssid_mac), client_mac, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("better_ap_available returned %d (with neighbour report %s)\n", tr, nb);
|
printf("better_ap_available returned %d (with neighbour report %s)\n", tr, nb);
|
||||||
|
@ -940,7 +940,7 @@ static int consume_actions(int argc, char* argv[], int harness_verbosity)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ap* ap_entry = ap_array_get_ap(pr0->bssid_addr, NULL);
|
ap* ap_entry = ap_array_get_ap(pr0->bssid_addr);
|
||||||
|
|
||||||
int this_metric = eval_probe_metric(pr0, ap_entry);
|
int this_metric = eval_probe_metric(pr0, ap_entry);
|
||||||
dawnlog_info("Score: %d of:\n", this_metric);
|
dawnlog_info("Score: %d of:\n", this_metric);
|
||||||
|
|
|
@ -66,8 +66,8 @@ enum {
|
||||||
CLIENT_TABLE_VHT,
|
CLIENT_TABLE_VHT,
|
||||||
CLIENT_TABLE_CHAN_UTIL,
|
CLIENT_TABLE_CHAN_UTIL,
|
||||||
CLIENT_TABLE_NUM_STA,
|
CLIENT_TABLE_NUM_STA,
|
||||||
CLIENT_TABLE_COL_DOMAIN,
|
//CLIENT_TABLE_COL_DOMAIN,
|
||||||
CLIENT_TABLE_BANDWIDTH,
|
//CLIENT_TABLE_BANDWIDTH,
|
||||||
CLIENT_TABLE_WEIGHT,
|
CLIENT_TABLE_WEIGHT,
|
||||||
CLIENT_TABLE_NEIGHBOR,
|
CLIENT_TABLE_NEIGHBOR,
|
||||||
CLIENT_TABLE_IFACE,
|
CLIENT_TABLE_IFACE,
|
||||||
|
@ -84,8 +84,8 @@ static const struct blobmsg_policy client_table_policy[__CLIENT_TABLE_MAX] = {
|
||||||
[CLIENT_TABLE_VHT] = {.name = "vht_supported", .type = BLOBMSG_TYPE_INT8},
|
[CLIENT_TABLE_VHT] = {.name = "vht_supported", .type = BLOBMSG_TYPE_INT8},
|
||||||
[CLIENT_TABLE_CHAN_UTIL] = {.name = "channel_utilization", .type = BLOBMSG_TYPE_INT32},
|
[CLIENT_TABLE_CHAN_UTIL] = {.name = "channel_utilization", .type = BLOBMSG_TYPE_INT32},
|
||||||
[CLIENT_TABLE_NUM_STA] = {.name = "num_sta", .type = BLOBMSG_TYPE_INT32},
|
[CLIENT_TABLE_NUM_STA] = {.name = "num_sta", .type = BLOBMSG_TYPE_INT32},
|
||||||
[CLIENT_TABLE_COL_DOMAIN] = {.name = "collision_domain", .type = BLOBMSG_TYPE_INT32},
|
//[CLIENT_TABLE_COL_DOMAIN] = {.name = "collision_domain", .type = BLOBMSG_TYPE_INT32},
|
||||||
[CLIENT_TABLE_BANDWIDTH] = {.name = "bandwidth", .type = BLOBMSG_TYPE_INT32},
|
//[CLIENT_TABLE_BANDWIDTH] = {.name = "bandwidth", .type = BLOBMSG_TYPE_INT32},
|
||||||
[CLIENT_TABLE_WEIGHT] = {.name = "ap_weight", .type = BLOBMSG_TYPE_INT32},
|
[CLIENT_TABLE_WEIGHT] = {.name = "ap_weight", .type = BLOBMSG_TYPE_INT32},
|
||||||
[CLIENT_TABLE_NEIGHBOR] = {.name = "neighbor_report", .type = BLOBMSG_TYPE_STRING},
|
[CLIENT_TABLE_NEIGHBOR] = {.name = "neighbor_report", .type = BLOBMSG_TYPE_STRING},
|
||||||
[CLIENT_TABLE_IFACE] = {.name = "iface", .type = BLOBMSG_TYPE_STRING},
|
[CLIENT_TABLE_IFACE] = {.name = "iface", .type = BLOBMSG_TYPE_STRING},
|
||||||
|
@ -530,7 +530,7 @@ int parse_to_clients(struct blob_attr* msg, int do_kick, uint32_t id) {
|
||||||
if (tb[CLIENT_TABLE_SSID]) {
|
if (tb[CLIENT_TABLE_SSID]) {
|
||||||
strcpy((char*)ap_entry->ssid, blobmsg_get_string(tb[CLIENT_TABLE_SSID]));
|
strcpy((char*)ap_entry->ssid, blobmsg_get_string(tb[CLIENT_TABLE_SSID]));
|
||||||
}
|
}
|
||||||
|
#if 0 // Pending deletion if no longer required
|
||||||
if (tb[CLIENT_TABLE_COL_DOMAIN]) {
|
if (tb[CLIENT_TABLE_COL_DOMAIN]) {
|
||||||
ap_entry->collision_domain = blobmsg_get_u32(tb[CLIENT_TABLE_COL_DOMAIN]);
|
ap_entry->collision_domain = blobmsg_get_u32(tb[CLIENT_TABLE_COL_DOMAIN]);
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ int parse_to_clients(struct blob_attr* msg, int do_kick, uint32_t id) {
|
||||||
else {
|
else {
|
||||||
ap_entry->bandwidth = -1;
|
ap_entry->bandwidth = -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
ap_entry->station_count = num_stations;
|
ap_entry->station_count = num_stations;
|
||||||
|
|
||||||
if (tb[CLIENT_TABLE_WEIGHT]) {
|
if (tb[CLIENT_TABLE_WEIGHT]) {
|
||||||
|
@ -582,7 +582,7 @@ int parse_to_clients(struct blob_attr* msg, int do_kick, uint32_t id) {
|
||||||
|
|
||||||
if (do_kick && dawn_metric.kicking) {
|
if (do_kick && dawn_metric.kicking) {
|
||||||
update_iw_info(ap_entry->bssid_addr);
|
update_iw_info(ap_entry->bssid_addr);
|
||||||
kick_clients(ap_entry, id);
|
kick_clients(ap_entry->bssid_addr, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -288,7 +288,7 @@ int parse_to_beacon_rep(struct blob_attr *msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t *ssid = (const uint8_t*)blobmsg_get_string(tb[BEACON_REP_SSID]);
|
const uint8_t *ssid = (const uint8_t*)blobmsg_get_string(tb[BEACON_REP_SSID]);
|
||||||
ap *ap_entry_rep = ap_array_get_ap(msg_bssid, ssid);
|
ap *ap_entry_rep = ap_array_get_ap(msg_bssid);
|
||||||
|
|
||||||
// no client from network!!
|
// no client from network!!
|
||||||
if (ap_entry_rep == NULL) {
|
if (ap_entry_rep == NULL) {
|
||||||
|
@ -396,7 +396,7 @@ bool discard_entry = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// find own probe entry and calculate score
|
// find own probe entry and calculate score
|
||||||
ap* this_ap = ap_array_get_ap(tmp->bssid_addr, tmp->ssid);
|
ap* this_ap = ap_array_get_ap(tmp->bssid_addr);
|
||||||
if (this_ap != NULL && better_ap_available(this_ap, tmp->client_addr, NULL) > 0) {
|
if (this_ap != NULL && better_ap_available(this_ap, tmp->client_addr, NULL) > 0) {
|
||||||
dawnlog_trace("Deny authentication due to better AP available");
|
dawnlog_trace("Deny authentication due to better AP available");
|
||||||
deny_request = 1;
|
deny_request = 1;
|
||||||
|
@ -468,8 +468,8 @@ int discard_entry = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// find own probe entry and calculate score
|
// find own probe entry and calculate score
|
||||||
ap* this_ap = ap_array_get_ap(tmp->bssid_addr, tmp->ssid);
|
ap* this_ap = ap_array_get_ap(assoc_req->bssid_addr);
|
||||||
if (this_ap != NULL && better_ap_available(this_ap, tmp->client_addr, NULL) > 0) {
|
if (this_ap != NULL && better_ap_available(this_ap, assoc_req->client_addr, NULL) > 0) {
|
||||||
dawnlog_trace("Deny association due to better AP available");
|
dawnlog_trace("Deny association due to better AP available");
|
||||||
deny_request = 1;
|
deny_request = 1;
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ static int handle_probe_req(struct blob_attr* msg) {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// find own probe entry and calculate score
|
// find own probe entry and calculate score
|
||||||
ap* this_ap = ap_array_get_ap(probe_req_updated->bssid_addr, probe_req_updated->ssid);
|
ap* this_ap = ap_array_get_ap(probe_req_updated->bssid_addr);
|
||||||
if (this_ap != NULL && better_ap_available(this_ap, probe_req_updated->client_addr, NULL) > 0) {
|
if (this_ap != NULL && better_ap_available(this_ap, probe_req_updated->client_addr, NULL) > 0) {
|
||||||
dawnlog_trace("Deny probe due to better AP available");
|
dawnlog_trace("Deny probe due to better AP available");
|
||||||
deny_request = 1;
|
deny_request = 1;
|
||||||
|
@ -729,14 +729,15 @@ int dawn_init_ubus(const char *ubus_socket, const char *hostapd_dir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_band_from_bssid(struct dawn_mac bssid) {
|
static int get_band_from_bssid(struct dawn_mac bssid) {
|
||||||
ap *a;
|
int ret = -1;
|
||||||
dawnlog_debug_func("Entering...");
|
|
||||||
|
|
||||||
for (a = ap_set; a; a = a->next_ap) {
|
dawnlog_debug_func("Entering...");
|
||||||
if (mac_is_equal_bb(a->bssid_addr, bssid))
|
ap* a = ap_array_get_ap(bssid);
|
||||||
return get_band(a->freq);
|
|
||||||
}
|
if (a)
|
||||||
return -1;
|
ret = get_band(a->freq);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_attr *msg) {
|
static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_attr *msg) {
|
||||||
|
@ -979,7 +980,7 @@ void update_beacon_reports(struct uloop_timeout *t) {
|
||||||
struct hostapd_sock_entry *sub;
|
struct hostapd_sock_entry *sub;
|
||||||
list_for_each_entry(sub, &hostapd_sock_list, list)
|
list_for_each_entry(sub, &hostapd_sock_list, list)
|
||||||
{
|
{
|
||||||
if (sub->subscribed && (a = ap_array_get_ap(sub->bssid_addr, (uint8_t*)sub->ssid))) {
|
if (sub->subscribed && (a = ap_array_get_ap(sub->bssid_addr))) {
|
||||||
dawnlog_debug("Sending beacon report Sub!\n");
|
dawnlog_debug("Sending beacon report Sub!\n");
|
||||||
send_beacon_reports(a, sub->id);
|
send_beacon_reports(a, sub->id);
|
||||||
}
|
}
|
||||||
|
@ -1715,7 +1716,7 @@ int build_hearing_map_sort_client(struct blob_buf *b) {
|
||||||
ssid_list = blobmsg_open_table(b, (char*)m->ssid);
|
ssid_list = blobmsg_open_table(b, (char*)m->ssid);
|
||||||
probe_entry* i = probe_set;
|
probe_entry* i = probe_set;
|
||||||
while (i != NULL) {
|
while (i != NULL) {
|
||||||
ap *ap_entry_i = ap_array_get_ap(i->bssid_addr, m->ssid);
|
ap *ap_entry_i = ap_array_get_ap(i->bssid_addr);
|
||||||
|
|
||||||
if (ap_entry_i == NULL) {
|
if (ap_entry_i == NULL) {
|
||||||
i = i->next_probe;
|
i = i->next_probe;
|
||||||
|
@ -1734,7 +1735,7 @@ int build_hearing_map_sort_client(struct blob_buf *b) {
|
||||||
k != NULL && mac_is_equal_bb(k->client_addr, i->client_addr);
|
k != NULL && mac_is_equal_bb(k->client_addr, i->client_addr);
|
||||||
k = k->next_probe) {
|
k = k->next_probe) {
|
||||||
|
|
||||||
ap *ap_k = ap_array_get_ap(k->bssid_addr, m->ssid);
|
ap *ap_k = ap_array_get_ap(k->bssid_addr);
|
||||||
|
|
||||||
if (ap_k == NULL || strcmp((char*)ap_k->ssid, (char*)m->ssid) != 0) {
|
if (ap_k == NULL || strcmp((char*)ap_k->ssid, (char*)m->ssid) != 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1845,7 +1846,7 @@ int build_network_overview(struct blob_buf *b) {
|
||||||
}
|
}
|
||||||
blobmsg_add_u8(b, "ht", k->ht);
|
blobmsg_add_u8(b, "ht", k->ht);
|
||||||
blobmsg_add_u8(b, "vht", k->vht);
|
blobmsg_add_u8(b, "vht", k->vht);
|
||||||
blobmsg_add_u32(b, "collision_count", ap_get_collision_count(m->collision_domain));
|
//blobmsg_add_u32(b, "collision_count", ap_get_collision_count(m->collision_domain));
|
||||||
|
|
||||||
pthread_mutex_lock(&probe_array_mutex);
|
pthread_mutex_lock(&probe_array_mutex);
|
||||||
|
|
||||||
|
@ -1912,7 +1913,7 @@ int ap_get_nr(struct blob_buf *b_local, struct dawn_mac own_bssid_addr, const ch
|
||||||
|
|
||||||
void* nbs = blobmsg_open_array(b_local, "list");
|
void* nbs = blobmsg_open_array(b_local, "list");
|
||||||
|
|
||||||
own_ap = ap_array_get_ap(own_bssid_addr, (uint8_t*)ssid);
|
own_ap = ap_array_get_ap(own_bssid_addr);
|
||||||
if (!own_ap)
|
if (!own_ap)
|
||||||
return -1;
|
return -1;
|
||||||
for (int band = 0; band < __DAWN_BAND_MAX; band++) {
|
for (int band = 0; band < __DAWN_BAND_MAX; band++) {
|
||||||
|
@ -1931,7 +1932,7 @@ int ap_get_nr(struct blob_buf *b_local, struct dawn_mac own_bssid_addr, const ch
|
||||||
pthread_mutex_unlock(&ap_array_mutex);
|
pthread_mutex_unlock(&ap_array_mutex);
|
||||||
|
|
||||||
for (n = preferred_list; n; n = n->next_mac) {
|
for (n = preferred_list; n; n = n->next_mac) {
|
||||||
if ((i = ap_array_get_ap(n->mac, (uint8_t*)ssid)))
|
if ((i = ap_array_get_ap(n->mac)))
|
||||||
blobmsg_add_nr(b_local, i);
|
blobmsg_add_nr(b_local, i);
|
||||||
}
|
}
|
||||||
blobmsg_close_array(b_local, nbs);
|
blobmsg_close_array(b_local, nbs);
|
||||||
|
|
Loading…
Reference in a new issue