aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/ctrl.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2010-11-19 17:31:55 (GMT)
committerJouni Malinen <j@w1.fi>2010-11-19 17:31:55 (GMT)
commitfbdd21327e51dce89a8d5b67cb0fb8d1c118d130 (patch)
treed00d178f1598e1e22b14ca5e431d91e28ca33ab7 /wlantest/ctrl.c
parenta16c859034e41ed17a7f2ed4e61a84b7ea99bf42 (diff)
downloadhostap-fbdd21327e51dce89a8d5b67cb0fb8d1c118d130.zip
hostap-fbdd21327e51dce89a8d5b67cb0fb8d1c118d130.tar.gz
hostap-fbdd21327e51dce89a8d5b67cb0fb8d1c118d130.tar.bz2
wlantest: Add add_passphrase command
This can be used to add a new known passphrase without having to restart wlantest.
Diffstat (limited to 'wlantest/ctrl.c')
-rw-r--r--wlantest/ctrl.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/wlantest/ctrl.c b/wlantest/ctrl.c
index e2cd283..156b000 100644
--- a/wlantest/ctrl.c
+++ b/wlantest/ctrl.c
@@ -686,6 +686,53 @@ static void ctrl_version(struct wlantest *wt, int sock)
}
+static void ctrl_add_passphrase(struct wlantest *wt, int sock, u8 *cmd,
+ size_t clen)
+{
+ u8 *passphrase;
+ size_t len;
+ struct wlantest_passphrase *p, *pa;
+ u8 *bssid;
+
+ passphrase = attr_get(cmd, clen, WLANTEST_ATTR_PASSPHRASE, &len);
+ if (passphrase == NULL || len < 8 || len > 63) {
+ ctrl_send_simple(wt, sock, WLANTEST_CTRL_INVALID_CMD);
+ return;
+ }
+
+ p = os_zalloc(sizeof(*p));
+ if (p == NULL) {
+ ctrl_send_simple(wt, sock, WLANTEST_CTRL_FAILURE);
+ return;
+ }
+ os_memcpy(p->passphrase, passphrase, len);
+ wpa_printf(MSG_INFO, "Add passphrase '%s'", p->passphrase);
+
+ bssid = attr_get_macaddr(cmd, clen, WLANTEST_ATTR_BSSID);
+ if (bssid) {
+ os_memcpy(p->bssid, bssid, ETH_ALEN);
+ wpa_printf(MSG_INFO, "Limit passphrase for BSSID " MACSTR,
+ MAC2STR(p->bssid));
+ }
+
+ dl_list_for_each(pa, &wt->passphrase, struct wlantest_passphrase, list)
+ {
+ if (os_strcmp(p->passphrase, pa->passphrase) == 0 &&
+ os_memcmp(p->bssid, pa->bssid, ETH_ALEN) == 0) {
+ wpa_printf(MSG_INFO, "Passphrase was already known");
+ os_free(p);
+ p = NULL;
+ break;
+ }
+ }
+
+ if (p)
+ dl_list_add(&wt->passphrase, &p->list);
+
+ ctrl_send_simple(wt, sock, WLANTEST_CTRL_SUCCESS);
+}
+
+
static void ctrl_read(int sock, void *eloop_ctx, void *sock_ctx)
{
struct wlantest *wt = eloop_ctx;
@@ -751,6 +798,9 @@ static void ctrl_read(int sock, void *eloop_ctx, void *sock_ctx)
case WLANTEST_CTRL_VERSION:
ctrl_version(wt, sock);
break;
+ case WLANTEST_CTRL_ADD_PASSPHRASE:
+ ctrl_add_passphrase(wt, sock, buf + 4, len - 4);
+ break;
default:
ctrl_send_simple(wt, sock, WLANTEST_CTRL_UNKNOWN_CMD);
break;