Get clients for all hostapd ifaces

This commit is contained in:
PolynomialDivision 2017-07-16 21:15:13 +02:00
parent e444dd57db
commit 742b6d9cf2
3 changed files with 21 additions and 7 deletions

View file

@ -7,5 +7,6 @@
int dawn_init_ubus(const char *ubus_socket, char *hostapd_dir);
int parse_to_probe_req(struct blob_attr *msg, probe_entry *prob_req);
char* hostapd_dir_glob;
#endif

View file

@ -35,6 +35,7 @@ int main(int argc, char **argv) {
case 'h':
snprintf(opt_hostapd_dir, BUFSIZE_DIR, "%s", optarg);
printf("hostapd dir: %s\n", opt_hostapd_dir);
hostapd_dir_glob = optarg;
default:
break;
}

View file

@ -349,11 +349,23 @@ static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_
}
static int ubus_get_clients() {
uint32_t id;
int ret = ubus_lookup_id(ctx, "hostapd.wlan0", &id);
if (ret)
return ret;
int timeout = 1;
int ubus_shit = ubus_invoke(ctx, id, "get_clients", NULL, ubus_get_clients_cb, NULL, timeout * 1000);
return ubus_shit;
DIR *dirp;
struct dirent *entry;
dirp = opendir(hostapd_dir_glob); // error handling?
while ((entry = readdir(dirp)) != NULL) {
if (entry->d_type == DT_SOCK) {
char hostapd_iface[256];
uint32_t id;
sprintf(hostapd_iface, "hostapd.%s", entry->d_name);
printf("Subscribing to %s\n", hostapd_iface);
int ret = ubus_lookup_id(ctx, hostapd_iface, &id);
if(!ret)
{
int timeout = 1;
ubus_invoke(ctx, id, "get_clients", NULL, ubus_get_clients_cb, NULL, timeout * 1000);
}
}
}
return 0;
}