gluon-mesh-*: do not count wifi clients/neighbours inactive for more than 60s

This commit is contained in:
Matthias Schiffer 2018-11-17 20:12:25 +01:00
parent f61d252361
commit 6d4d4792d5
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
2 changed files with 18 additions and 2 deletions

View File

@ -63,6 +63,8 @@
#define STRINGIFY(s) _STRINGIFY(s) #define STRINGIFY(s) _STRINGIFY(s)
#include <stdlib.h> #include <stdlib.h>
#define MAX_INACTIVITY 60000
#define SOCKET_INPUT_BUFFER_SIZE 255 #define SOCKET_INPUT_BUFFER_SIZE 255
#define BABEL_PORT 33123 #define BABEL_PORT 33123
#define VPN_INTERFACE "mesh-vpn" #define VPN_INTERFACE "mesh-vpn"
@ -461,8 +463,12 @@ static void count_iface_stations(size_t *wifi24, size_t *wifi5, const char *ifna
return; return;
struct iwinfo_assoclist_entry *entry; struct iwinfo_assoclist_entry *entry;
for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++) for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++) {
if (entry->inactive > MAX_INACTIVITY)
continue;
(*wifi)++; (*wifi)++;
}
} }
static void count_stations(size_t *wifi24, size_t *wifi5) { static void count_stations(size_t *wifi24, size_t *wifi5) {
@ -623,6 +629,9 @@ static struct json_object * get_wifi_neighbours(const char *ifname) {
struct iwinfo_assoclist_entry *entry; struct iwinfo_assoclist_entry *entry;
for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++) { for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++) {
if (entry->inactive > MAX_INACTIVITY)
continue;
struct json_object *obj = json_object_new_object(); struct json_object *obj = json_object_new_object();
json_object_object_add(obj, "signal", json_object_new_int(entry->signal)); json_object_object_add(obj, "signal", json_object_new_int(entry->signal));

View File

@ -444,8 +444,12 @@ static void count_iface_stations(size_t *wifi24, size_t *wifi5, const char *ifna
return; return;
struct iwinfo_assoclist_entry *entry; struct iwinfo_assoclist_entry *entry;
for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++) for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++) {
if (entry->inactive > MAX_INACTIVITY)
continue;
(*wifi)++; (*wifi)++;
}
} }
static void count_stations(size_t *wifi24, size_t *wifi5) { static void count_stations(size_t *wifi24, size_t *wifi5) {
@ -712,6 +716,9 @@ static struct json_object * get_wifi_neighbours(const char *ifname) {
struct iwinfo_assoclist_entry *entry; struct iwinfo_assoclist_entry *entry;
for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++) { for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++) {
if (entry->inactive > MAX_INACTIVITY)
continue;
struct json_object *obj = json_object_new_object(); struct json_object *obj = json_object_new_object();
json_object_object_add(obj, "signal", json_object_new_int(entry->signal)); json_object_object_add(obj, "signal", json_object_new_int(entry->signal));