wifi: make "auth" command non-blocking, let aux/wpa do the waiting for bss scan to complete.
This commit is contained in:
parent
24e8c78cb2
commit
b6122a4c42
2 changed files with 7 additions and 16 deletions
|
@ -766,7 +766,6 @@ wifictl(Wifi *wifi, void *buf, long n)
|
||||||
Cmdtab *ct;
|
Cmdtab *ct;
|
||||||
Wnode *wn;
|
Wnode *wn;
|
||||||
Wkey *k;
|
Wkey *k;
|
||||||
int i;
|
|
||||||
|
|
||||||
cb = nil;
|
cb = nil;
|
||||||
if(waserror()){
|
if(waserror()){
|
||||||
|
@ -818,16 +817,6 @@ wifictl(Wifi *wifi, void *buf, long n)
|
||||||
setstatus(wifi, wn, Sconn);
|
setstatus(wifi, wn, Sconn);
|
||||||
sendauth(wifi, wn);
|
sendauth(wifi, wn);
|
||||||
}
|
}
|
||||||
/* wait 3 seconds for authentication response */
|
|
||||||
for(i=0; i < 30; i++){
|
|
||||||
if(wifi->bss != nil)
|
|
||||||
goto done;
|
|
||||||
if(!waserror()){
|
|
||||||
tsleep(&up->sleep, return0, 0, 100);
|
|
||||||
poperror();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
error("connect timeout");
|
|
||||||
break;
|
break;
|
||||||
case CMbssid:
|
case CMbssid:
|
||||||
memmove(wifi->bssid, addr, Eaddrlen);
|
memmove(wifi->bssid, addr, Eaddrlen);
|
||||||
|
@ -859,7 +848,6 @@ wifictl(Wifi *wifi, void *buf, long n)
|
||||||
setstatus(wifi, wn, Sassoc);
|
setstatus(wifi, wn, Sassoc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
done:
|
|
||||||
poperror();
|
poperror();
|
||||||
free(cb);
|
free(cb);
|
||||||
return n;
|
return n;
|
||||||
|
|
|
@ -531,7 +531,7 @@ main(int argc, char *argv[])
|
||||||
char addr[128];
|
char addr[128];
|
||||||
uchar *rsne;
|
uchar *rsne;
|
||||||
int rsnelen;
|
int rsnelen;
|
||||||
int n;
|
int n, try;
|
||||||
|
|
||||||
quotefmtinstall();
|
quotefmtinstall();
|
||||||
fmtinstall('H', Hfmt);
|
fmtinstall('H', Hfmt);
|
||||||
|
@ -617,11 +617,14 @@ main(int argc, char *argv[])
|
||||||
fprint(2, "rsne: %.*H\n", rsnelen, rsne);
|
fprint(2, "rsne: %.*H\n", rsnelen, rsne);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we use write() instead of fprint so message gets written
|
* we use write() instead of fprint so the message gets written
|
||||||
* at once and not chunked up on fprint buffer.
|
* at once and not chunked up on fprint buffer. bss scan might
|
||||||
|
* not be complete yet, so retry for 10 seconds.
|
||||||
*/
|
*/
|
||||||
n = sprint((char*)buf, "auth %.*H", rsnelen, rsne);
|
n = sprint((char*)buf, "auth %.*H", rsnelen, rsne);
|
||||||
if(write(cfd, buf, n) != n)
|
for(try = 10; try >= 0 && write(cfd, buf, n) != n; try--)
|
||||||
|
sleep(1000);
|
||||||
|
if(try < 0)
|
||||||
sysfatal("write auth: %r");
|
sysfatal("write auth: %r");
|
||||||
|
|
||||||
if(!debug){
|
if(!debug){
|
||||||
|
|
Loading…
Reference in a new issue