wifi: quote value of parsed ether options
introduce wificfg() function to convert ether->opt[] strings to wifictl messages, which needs quoting for the value. so etherX=type=iwl essid='something with spaces' works.
This commit is contained in:
parent
b29e414bc6
commit
4040ea7a5e
5 changed files with 26 additions and 44 deletions
|
@ -2101,27 +2101,12 @@ iwlifstat(Ether *edev, void *buf, long n, ulong off)
|
|||
static void
|
||||
setoptions(Ether *edev)
|
||||
{
|
||||
char buf[64], *p;
|
||||
Ctlr *ctlr;
|
||||
int i;
|
||||
|
||||
ctlr = edev->ctlr;
|
||||
for(i = 0; i < edev->nopt; i++){
|
||||
snprint(buf, sizeof(buf), "%s", edev->opt[i]);
|
||||
p = strchr(buf, '=');
|
||||
if(p != nil)
|
||||
*p = 0;
|
||||
if(strcmp(buf, "debug") == 0
|
||||
|| strcmp(buf, "essid") == 0
|
||||
|| strcmp(buf, "bssid") == 0){
|
||||
if(p != nil)
|
||||
*p = ' ';
|
||||
if(!waserror()){
|
||||
wifictl(ctlr->wifi, buf, strlen(buf));
|
||||
poperror();
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i = 0; i < edev->nopt; i++)
|
||||
wificfg(ctlr->wifi, edev->opt[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1306,19 +1306,11 @@ static void
|
|||
setoptions(Ether *edev)
|
||||
{
|
||||
Ctlr *ctlr;
|
||||
char buf[64];
|
||||
int i;
|
||||
|
||||
ctlr = edev->ctlr;
|
||||
for(i = 0; i < edev->nopt; i++){
|
||||
if(strncmp(edev->opt[i], "essid=", 6) == 0){
|
||||
snprint(buf, sizeof(buf), "essid %s", edev->opt[i]+6);
|
||||
if(!waserror()){
|
||||
wifictl(ctlr->wifi, buf, strlen(buf));
|
||||
poperror();
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i = 0; i < edev->nopt; i++)
|
||||
wificfg(ctlr->wifi, edev->opt[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1491,27 +1491,12 @@ wpiifstat(Ether *edev, void *buf, long n, ulong off)
|
|||
static void
|
||||
setoptions(Ether *edev)
|
||||
{
|
||||
char buf[64], *p;
|
||||
Ctlr *ctlr;
|
||||
int i;
|
||||
|
||||
ctlr = edev->ctlr;
|
||||
for(i = 0; i < edev->nopt; i++){
|
||||
snprint(buf, sizeof(buf), "%s", edev->opt[i]);
|
||||
p = strchr(buf, '=');
|
||||
if(p != nil)
|
||||
*p = 0;
|
||||
if(strcmp(buf, "debug") == 0
|
||||
|| strcmp(buf, "essid") == 0
|
||||
|| strcmp(buf, "bssid") == 0){
|
||||
if(p != nil)
|
||||
*p = ' ';
|
||||
if(!waserror()){
|
||||
wifictl(ctlr->wifi, buf, strlen(buf));
|
||||
poperror();
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i = 0; i < edev->nopt; i++)
|
||||
wificfg(ctlr->wifi, edev->opt[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -814,6 +814,25 @@ parsekey(Wkey *k, char *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
wificfg(Wifi *wifi, char *opt)
|
||||
{
|
||||
char *p, buf[64];
|
||||
int n;
|
||||
|
||||
if(strncmp(opt, "debug=", 6))
|
||||
if(strncmp(opt, "essid=", 6))
|
||||
if(strncmp(opt, "bssid=", 6))
|
||||
return;
|
||||
if((p = strchr(opt, '=')) == nil)
|
||||
return;
|
||||
if(waserror())
|
||||
return;
|
||||
n = snprint(buf, sizeof(buf), "%.*s %q", (int)(p - opt), opt, p+1);
|
||||
wifictl(wifi, buf, n);
|
||||
poperror();
|
||||
}
|
||||
|
||||
enum {
|
||||
CMdebug,
|
||||
CMessid,
|
||||
|
|
|
@ -95,3 +95,4 @@ void wifitxfail(Wifi*, Block*);
|
|||
|
||||
long wifistat(Wifi*, void*, long, ulong);
|
||||
long wifictl(Wifi*, void*, long);
|
||||
void wificfg(Wifi*, char*);
|
||||
|
|
Loading…
Reference in a new issue