mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Get clients for all hostapd ifaces
This commit is contained in:
parent
e444dd57db
commit
742b6d9cf2
3 changed files with 21 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue