aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/ctrl.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2011-01-28 11:33:21 (GMT)
committerJouni Malinen <j@w1.fi>2011-01-28 11:33:21 (GMT)
commit9a994178f19a3632c7a12b892c508e323de18cdb (patch)
treeae600e295e837e25d502445461f1bdd3531cdf8f /wlantest/ctrl.c
parentdfaeda049203eea631f0a916f49fadf08cd5cd6f (diff)
downloadhostap-9a994178f19a3632c7a12b892c508e323de18cdb.zip
hostap-9a994178f19a3632c7a12b892c508e323de18cdb.tar.gz
hostap-9a994178f19a3632c7a12b892c508e323de18cdb.tar.bz2
wlantest: Add command for adding WEP keys during run time
Diffstat (limited to 'wlantest/ctrl.c')
-rw-r--r--wlantest/ctrl.c27
1 files changed, 26 insertions, 1 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;
}