diff options
Diffstat (limited to 'src/libwpactrl/wpactrl_bssid_scan.c')
-rw-r--r-- | src/libwpactrl/wpactrl_bssid_scan.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libwpactrl/wpactrl_bssid_scan.c b/src/libwpactrl/wpactrl_bssid_scan.c new file mode 100644 index 0000000..ad4196c --- /dev/null +++ b/src/libwpactrl/wpactrl_bssid_scan.c @@ -0,0 +1,29 @@ +/* ISC license. */ + +#include <string.h> +#include <errno.h> +#include <skalibs/error.h> +#include <skalibs/fmtscan.h> +#include <bcnm/wpactrl.h> + +size_t wpactrl_bssid_scan (char const *s, char *bssid) +{ + unsigned int i = 0 ; + if (!strncmp(s, "any", 3)) + { + memset(bssid, 0, 6) ; + return 3 ; + } + for (; i < 5 ; i++) + { + if (!ucharn_scan(s, bssid + i, 1)) goto eproto ; + if (s[2] != ':') goto eproto ; + s += 3 ; + } + if (!ucharn_scan(s, bssid + 5, 1)) goto eproto ; + return 17 ; + + eproto: + return (errno = EPROTO, 0) ; +} + |