diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-08-10 20:51:40 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-08-10 20:51:40 +0000 |
commit | 5445a1d653cddb7b9321c87aec6b025c7627fe1d (patch) | |
tree | 1fad42bb0b4abbda9c35eb3ff829fb84bbcb8d78 /src/libwpactrl/wpactrl_startscan.c | |
parent | babf43abf301d072192bda1f72a47440c354b072 (diff) | |
download | bcnm-5445a1d653cddb7b9321c87aec6b025c7627fe1d.tar.xz |
Complete first draft of libwpactrl, with documentation
Diffstat (limited to 'src/libwpactrl/wpactrl_startscan.c')
-rw-r--r-- | src/libwpactrl/wpactrl_startscan.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/libwpactrl/wpactrl_startscan.c b/src/libwpactrl/wpactrl_startscan.c new file mode 100644 index 0000000..7ce5f52 --- /dev/null +++ b/src/libwpactrl/wpactrl_startscan.c @@ -0,0 +1,30 @@ +/* ISC license. */ + +#include <errno.h> +#include <bcnm/wpactrl.h> +#include "wpactrl-internal.h" + +static int wpactrl_scan_cb (wpactrl_t *a, char const *s, size_t len, void *aux, tain_t *stamp) +{ + wpactrl_xchg_cbres_t *res = aux ; + char buf[WPACTRL_PACKET_MAX] ; + ssize_t r = wpactrl_query(a, "SCAN_RESULTS", buf, WPACTRL_PACKET_MAX, stamp) ; + if (r <= 0) return 0 ; + (void)s ; + (void)len ; + return wpactrl_scan_parse(buf, r, &res->parsed, &res->storage) ; +} + +static wpactrl_xchgitem_t wpactrl_xchgitem_scan = +{ + .filter = "CTRL-EVENT-SCAN-RESULTS", + .cb = &wpactrl_scan_cb +} ; + +int wpactrl_startscan (wpactrl_t *a, wpactrl_xchg_t *xchg, wpactrl_xchg_cbres_t *res, tain_t const *deadline, tain_t *stamp) +{ + wparesponse_t r = wpactrl_command(a, "SCAN", stamp) ; + if (r != WPA_OK && r != WPA_FAILBUSY) return (errno = EIO, 0) ; + wpactrl_xchg_init(xchg, &wpactrl_xchgitem_scan, 1, deadline, res) ; + return wpactrl_xchg_start(a, xchg) ; +} |