summaryrefslogtreecommitdiff
path: root/usr.sbin/hostapd
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2005-12-01 00:36:42 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2005-12-01 00:36:42 +0000
commit50f672c3d16ad331c278a65643b9808bb7cf1075 (patch)
tree3e18996a9e32d1586aa087e99106cdd0ec12c352 /usr.sbin/hostapd
parentd671c9ffc54857c80c061fe5d37c3055dc414d15 (diff)
deauthenticate all stations on startup which will force them to
reassociate cleanly.
Diffstat (limited to 'usr.sbin/hostapd')
-rw-r--r--usr.sbin/hostapd/apme.c34
-rw-r--r--usr.sbin/hostapd/hostapd.h3
-rw-r--r--usr.sbin/hostapd/iapp.c5
3 files changed, 39 insertions, 3 deletions
diff --git a/usr.sbin/hostapd/apme.c b/usr.sbin/hostapd/apme.c
index 6124f62b8e8..11ea738de36 100644
--- a/usr.sbin/hostapd/apme.c
+++ b/usr.sbin/hostapd/apme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apme.c,v 1.6 2005/11/20 12:02:04 reyk Exp $ */
+/* $OpenBSD: apme.c,v 1.7 2005/12/01 00:36:41 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -69,6 +69,38 @@ hostapd_apme_add(struct hostapd_config *cfg, const char *name)
return (0);
}
+int
+hostapd_apme_deauth(struct hostapd_apme *apme)
+{
+ struct hostapd_config *cfg = (struct hostapd_config *)apme->a_cfg;
+ u_int8_t buf[sizeof(struct ieee80211_frame) + sizeof(u_int16_t)];
+ struct ieee80211_frame *wh;
+
+ bzero(&buf, sizeof(buf));
+ wh = (struct ieee80211_frame *)&buf[0];
+ wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT |
+ IEEE80211_FC0_SUBTYPE_DEAUTH;
+ wh->i_fc[1] = IEEE80211_FC1_DIR_NODS;
+ memset(&wh->i_addr1, 0xff, IEEE80211_ADDR_LEN);
+ bcopy(apme->a_bssid, wh->i_addr2, IEEE80211_ADDR_LEN);
+ bcopy(apme->a_bssid, wh->i_addr3, IEEE80211_ADDR_LEN);
+ *(u_int16_t *)(wh + 1) = htole16(IEEE80211_REASON_AUTH_EXPIRE);
+
+ if (write(apme->a_raw, buf, sizeof(buf)) == -1) {
+ hostapd_log(HOSTAPD_LOG_VERBOSE,
+ "%s/%s: failed to deauthenticate all stations: %s\n",
+ cfg->c_iapp_iface, apme->a_iface,
+ strerror(errno));
+ return (EIO);
+ }
+
+ hostapd_log(HOSTAPD_LOG_VERBOSE,
+ "%s/%s: deauthenticated all stations\n",
+ apme->a_iface, cfg->c_iapp_iface);
+
+ return (0);
+}
+
struct hostapd_apme *
hostapd_apme_lookup(struct hostapd_config *cfg, const char *name)
{
diff --git a/usr.sbin/hostapd/hostapd.h b/usr.sbin/hostapd/hostapd.h
index 00d8b7967ca..153447049d6 100644
--- a/usr.sbin/hostapd/hostapd.h
+++ b/usr.sbin/hostapd/hostapd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostapd.h,v 1.10 2005/11/23 20:40:38 reyk Exp $ */
+/* $OpenBSD: hostapd.h,v 1.11 2005/12/01 00:36:41 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -333,6 +333,7 @@ int hostapd_priv_apme_setnode(struct hostapd_apme *,
struct hostapd_node *node, int);
void hostapd_apme_init(struct hostapd_apme *);
+int hostapd_apme_deauth(struct hostapd_apme *);
int hostapd_apme_add(struct hostapd_config *, const char *);
void hostapd_apme_term(struct hostapd_apme *);
struct hostapd_apme *hostapd_apme_lookup(struct hostapd_config *,
diff --git a/usr.sbin/hostapd/iapp.c b/usr.sbin/hostapd/iapp.c
index 6a6f9272c65..8fdcd972373 100644
--- a/usr.sbin/hostapd/iapp.c
+++ b/usr.sbin/hostapd/iapp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iapp.c,v 1.10 2005/11/23 20:47:29 reyk Exp $ */
+/* $OpenBSD: iapp.c,v 1.11 2005/12/01 00:36:41 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -57,6 +57,9 @@ hostapd_iapp_init(struct hostapd_config *cfg)
"%s/%s: attached Host AP interface with BSSID %s\n",
apme->a_iface, cfg->c_iapp_iface,
etheraddr_string(apme->a_bssid));
+
+ /* Deauthenticate all stations on startup */
+ hostapd_apme_deauth(apme);
}
}