summaryrefslogtreecommitdiff
path: root/sys/src/9/pc
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-10-09 05:10:47 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-10-09 05:10:47 +0200
commit4040ea7a5eda976098131794e8df3b162cafa8f4 (patch)
tree99416d4a3ba5ed78a5a402a6bde4599448a2051f /sys/src/9/pc
parentb29e414bc64537c9af8d5ebd8f73775bceaa5fa2 (diff)
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.
Diffstat (limited to 'sys/src/9/pc')
-rw-r--r--sys/src/9/pc/etheriwl.c19
-rw-r--r--sys/src/9/pc/etherrt2860.c12
-rw-r--r--sys/src/9/pc/etherwpi.c19
-rw-r--r--sys/src/9/pc/wifi.c19
-rw-r--r--sys/src/9/pc/wifi.h1
5 files changed, 26 insertions, 44 deletions
diff --git a/sys/src/9/pc/etheriwl.c b/sys/src/9/pc/etheriwl.c
index 0077061be..aba316f0f 100644
--- a/sys/src/9/pc/etheriwl.c
+++ b/sys/src/9/pc/etheriwl.c
@@ -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
diff --git a/sys/src/9/pc/etherrt2860.c b/sys/src/9/pc/etherrt2860.c
index 79e4ef68b..6544a80a7 100644
--- a/sys/src/9/pc/etherrt2860.c
+++ b/sys/src/9/pc/etherrt2860.c
@@ -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
diff --git a/sys/src/9/pc/etherwpi.c b/sys/src/9/pc/etherwpi.c
index 00e1e4847..4dbc65e6d 100644
--- a/sys/src/9/pc/etherwpi.c
+++ b/sys/src/9/pc/etherwpi.c
@@ -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
diff --git a/sys/src/9/pc/wifi.c b/sys/src/9/pc/wifi.c
index a594df78b..55b9ce326 100644
--- a/sys/src/9/pc/wifi.c
+++ b/sys/src/9/pc/wifi.c
@@ -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,
diff --git a/sys/src/9/pc/wifi.h b/sys/src/9/pc/wifi.h
index d9a8514a6..bca2e07e9 100644
--- a/sys/src/9/pc/wifi.h
+++ b/sys/src/9/pc/wifi.h
@@ -95,3 +95,4 @@ void wifitxfail(Wifi*, Block*);
long wifistat(Wifi*, void*, long, ulong);
long wifictl(Wifi*, void*, long);
+void wificfg(Wifi*, char*);