summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-07-18 16:16:31 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-07-18 16:16:31 +0200
commit4755fce1dc286432a952fa5acb54c7fa880fe1b2 (patch)
tree6a4a0c0180adf2cd982bd83fb0c3240eaf183ee2
parentb6122a4c42b4f078f671a62c95a8147e34ffb38c (diff)
wpa: wait for bss to connect
waiting at the auth command is too late because we want to read the brsne first to build the rsne used in the auth message.
-rw-r--r--sys/src/cmd/aux/wpa.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/sys/src/cmd/aux/wpa.c b/sys/src/cmd/aux/wpa.c
index 61f765146..430d1b091 100644
--- a/sys/src/cmd/aux/wpa.c
+++ b/sys/src/cmd/aux/wpa.c
@@ -155,6 +155,22 @@ getessid(void)
}
int
+connected(void)
+{
+ char status[1024];
+
+ if(getifstats("status:", status, sizeof(status)) == nil)
+ return 0;
+ if(strcmp(status, "connecting") == 0)
+ return 0;
+ if(strcmp(status, "unauthenticated") == 0)
+ return 0;
+ if(debug)
+ fprint(2, "status: %s\n", status);
+ return 1;
+}
+
+int
buildrsne(uchar rsne[258])
{
char buf[1024];
@@ -598,6 +614,10 @@ main(int argc, char *argv[])
free(s);
}
+ /* bss scan might not be complete yet, so check for 10 seconds. */
+ for(try = 10; try >= 0 && !connected(); try--)
+ sleep(1000);
+
if(rsnelen <= 0){
static uchar brsne[258];
@@ -618,13 +638,10 @@ main(int argc, char *argv[])
/*
* we use write() instead of fprint so the message gets written
- * at once and not chunked up on fprint buffer. bss scan might
- * not be complete yet, so retry for 10 seconds.
+ * at once and not chunked up on fprint buffer.
*/
n = sprint((char*)buf, "auth %.*H", rsnelen, rsne);
- for(try = 10; try >= 0 && write(cfd, buf, n) != n; try--)
- sleep(1000);
- if(try < 0)
+ if(write(cfd, buf, n) != n)
sysfatal("write auth: %r");
if(!debug){