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 dawn_init_ubus(const char *ubus_socket, char *hostapd_dir);
|
||||||
int parse_to_probe_req(struct blob_attr *msg, probe_entry *prob_req);
|
int parse_to_probe_req(struct blob_attr *msg, probe_entry *prob_req);
|
||||||
|
char* hostapd_dir_glob;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,6 +35,7 @@ int main(int argc, char **argv) {
|
||||||
case 'h':
|
case 'h':
|
||||||
snprintf(opt_hostapd_dir, BUFSIZE_DIR, "%s", optarg);
|
snprintf(opt_hostapd_dir, BUFSIZE_DIR, "%s", optarg);
|
||||||
printf("hostapd dir: %s\n", opt_hostapd_dir);
|
printf("hostapd dir: %s\n", opt_hostapd_dir);
|
||||||
|
hostapd_dir_glob = optarg;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,11 +349,23 @@ static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ubus_get_clients() {
|
static int ubus_get_clients() {
|
||||||
uint32_t id;
|
DIR *dirp;
|
||||||
int ret = ubus_lookup_id(ctx, "hostapd.wlan0", &id);
|
struct dirent *entry;
|
||||||
if (ret)
|
|
||||||
return ret;
|
dirp = opendir(hostapd_dir_glob); // error handling?
|
||||||
int timeout = 1;
|
while ((entry = readdir(dirp)) != NULL) {
|
||||||
int ubus_shit = ubus_invoke(ctx, id, "get_clients", NULL, ubus_get_clients_cb, NULL, timeout * 1000);
|
if (entry->d_type == DT_SOCK) {
|
||||||
return ubus_shit;
|
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