aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2011-01-28 13:33:21 +0200
committerJouni Malinen <j@w1.fi>2011-01-28 13:33:21 +0200
commit9a994178f19a3632c7a12b892c508e323de18cdb (patch)
treeae600e295e837e25d502445461f1bdd3531cdf8f /wlantest
parentdfaeda049203eea631f0a916f49fadf08cd5cd6f (diff)
downloadexternal_wpa_supplicant_8_ti-9a994178f19a3632c7a12b892c508e323de18cdb.zip
external_wpa_supplicant_8_ti-9a994178f19a3632c7a12b892c508e323de18cdb.tar.gz
external_wpa_supplicant_8_ti-9a994178f19a3632c7a12b892c508e323de18cdb.tar.bz2
wlantest: Add command for adding WEP keys during run time
Diffstat (limited to 'wlantest')
-rw-r--r--wlantest/ctrl.c27
-rw-r--r--wlantest/wlantest.c12
-rw-r--r--wlantest/wlantest.h1
-rw-r--r--wlantest/wlantest_ctrl.h1
4 files changed, 35 insertions, 6 deletions
diff --git a/wlantest/ctrl.c b/wlantest/ctrl.c
index e97448d..2e470dd 100644
--- a/wlantest/ctrl.c
+++ b/wlantest/ctrl.c
@@ -788,7 +788,32 @@ static void ctrl_add_passphrase(struct wlantest *wt, int sock, u8 *cmd,
u8 *bssid;
passphrase = attr_get(cmd, clen, WLANTEST_ATTR_PASSPHRASE, &len);
- if (passphrase == NULL || len < 8 || len > 63) {
+ if (passphrase == NULL) {
+ u8 *wepkey;
+ char *key;
+ enum wlantest_ctrl_cmd res;
+
+ wepkey = attr_get(cmd, clen, WLANTEST_ATTR_WEPKEY, &len);
+ if (wepkey == NULL) {
+ ctrl_send_simple(wt, sock, WLANTEST_CTRL_INVALID_CMD);
+ return;
+ }
+ key = os_zalloc(len + 1);
+ if (key == NULL) {
+ ctrl_send_simple(wt, sock, WLANTEST_CTRL_FAILURE);
+ return;
+ }
+ os_memcpy(key, wepkey, len);
+ if (add_wep(wt, key) < 0)
+ res = WLANTEST_CTRL_FAILURE;
+ else
+ res = WLANTEST_CTRL_SUCCESS;
+ os_free(key);
+ ctrl_send_simple(wt, sock, res);
+ return;
+ }
+
+ if (len < 8 || len > 63) {
ctrl_send_simple(wt, sock, WLANTEST_CTRL_INVALID_CMD);
return;
}
diff --git a/wlantest/wlantest.c b/wlantest/wlantest.c
index 17b3dd3..040cda1 100644
--- a/wlantest/wlantest.c
+++ b/wlantest/wlantest.c
@@ -136,25 +136,26 @@ static void add_secret(struct wlantest *wt, const char *secret)
}
-static void add_wep(struct wlantest *wt, const char *key)
+int add_wep(struct wlantest *wt, const char *key)
{
struct wlantest_wep *w;
size_t len = os_strlen(key);
if (len != 2 * 5 && len != 2 * 13) {
wpa_printf(MSG_INFO, "Invalid WEP key '%s'", key);
- return;
+ return -1;
}
w = os_zalloc(sizeof(*w));
if (w == NULL)
- return;
+ return -1;
if (hexstr2bin(key, w->key, len / 2) < 0) {
os_free(w);
wpa_printf(MSG_INFO, "Invalid WEP key '%s'", key);
- return;
+ return -1;
}
w->key_len = len / 2;
dl_list_add(&wt->wep, &w->list);
+ return 0;
}
@@ -217,7 +218,8 @@ int main(int argc, char *argv[])
write_file = optarg;
break;
case 'W':
- add_wep(&wt, optarg);
+ if (add_wep(&wt, optarg) < 0)
+ return -1;
break;
default:
usage();
diff --git a/wlantest/wlantest.h b/wlantest/wlantest.h
index 32794ca..a6165cc 100644
--- a/wlantest/wlantest.h
+++ b/wlantest/wlantest.h
@@ -177,6 +177,7 @@ struct wlantest {
int last_mgmt_valid;
};
+int add_wep(struct wlantest *wt, const char *key);
int read_cap_file(struct wlantest *wt, const char *fname);
int read_wired_cap_file(struct wlantest *wt, const char *fname);
int write_pcap_init(struct wlantest *wt, const char *fname);
diff --git a/wlantest/wlantest_ctrl.h b/wlantest/wlantest_ctrl.h
index a91b6cd..91f5af6 100644
--- a/wlantest/wlantest_ctrl.h
+++ b/wlantest/wlantest_ctrl.h
@@ -60,6 +60,7 @@ enum wlantest_ctrl_attr {
WLANTEST_ATTR_FRAME,
WLANTEST_ATTR_TDLS_COUNTER,
WLANTEST_ATTR_STA2_ADDR,
+ WLANTEST_ATTR_WEPKEY,
};
enum wlantest_bss_counter {