Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net80211 Introduce ieee80211_recv_mgmt_deauth.
details: https://anonhg.NetBSD.org/src/rev/3b481a7093aa
branches: trunk
changeset: 358789:3b481a7093aa
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Jan 16 16:04:16 2018 +0000
description:
Introduce ieee80211_recv_mgmt_deauth.
diffstat:
sys/net80211/ieee80211_input.c | 102 +++++++++++++++++++++++-----------------
1 files changed, 58 insertions(+), 44 deletions(-)
diffs (130 lines):
diff -r eca03b7f9afd -r 3b481a7093aa sys/net80211/ieee80211_input.c
--- a/sys/net80211/ieee80211_input.c Tue Jan 16 16:00:17 2018 +0000
+++ b/sys/net80211/ieee80211_input.c Tue Jan 16 16:04:16 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_input.c,v 1.101 2018/01/16 16:00:17 maxv Exp $ */
+/* $NetBSD: ieee80211_input.c,v 1.102 2018/01/16 16:04:16 maxv Exp $ */
/*
* Copyright (c) 2001 Atsushi Onoe
@@ -37,7 +37,7 @@
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.81 2005/08/10 16:22:29 sam Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.101 2018/01/16 16:00:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.102 2018/01/16 16:04:16 maxv Exp $");
#endif
#ifdef _KERNEL_OPT
@@ -2802,6 +2802,59 @@
ieee80211_new_state(ic, IEEE80211_S_RUN, subtype);
}
+static void
+ieee80211_recv_mgmt_deauth(struct ieee80211com *ic, struct mbuf *m0,
+ struct ieee80211_node *ni, int subtype, int rssi, u_int32_t rstamp)
+{
+ struct ieee80211_frame *wh;
+ u_int8_t *frm, *efrm;
+ IEEE80211_DEBUGVAR(char ebuf[3 * ETHER_ADDR_LEN]);
+
+ wh = mtod(m0, struct ieee80211_frame *);
+ frm = (u_int8_t *)(wh + 1);
+ efrm = mtod(m0, u_int8_t *) + m0->m_len;
+
+ u_int16_t reason;
+
+ if (ic->ic_state == IEEE80211_S_SCAN) {
+ ic->ic_stats.is_rx_mgtdiscard++;
+ return;
+ }
+ /*
+ * deauth frame format
+ * [2] reason
+ */
+ IEEE80211_VERIFY_LENGTH(efrm - frm, 2);
+ reason = le16toh(*(u_int16_t *)frm);
+ __USE(reason);
+ ic->ic_stats.is_rx_deauth++;
+ IEEE80211_NODE_STAT(ni, rx_deauth);
+
+ if (!IEEE80211_ADDR_EQ(wh->i_addr1, ic->ic_myaddr)) {
+ /* Not intended for this station. */
+ ic->ic_stats.is_rx_mgtdiscard++;
+ return;
+ }
+ IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
+ "[%s] recv deauthenticate (reason %d)\n",
+ ether_snprintf(ebuf, sizeof(ebuf), ni->ni_macaddr), reason);
+ switch (ic->ic_opmode) {
+ case IEEE80211_M_STA:
+ ieee80211_new_state(ic, IEEE80211_S_AUTH,
+ wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
+ break;
+ case IEEE80211_M_HOSTAP:
+#ifndef IEEE80211_NO_HOSTAP
+ if (ni != ic->ic_bss)
+ ieee80211_node_leave(ic, ni);
+#endif /* !IEEE80211_NO_HOSTAP */
+ break;
+ default:
+ ic->ic_stats.is_rx_mgtdiscard++;
+ break;
+ }
+}
+
/* -------------------------------------------------------------------------- */
void
@@ -2840,48 +2893,9 @@
ieee80211_recv_mgmt_assoc_resp(ic, m0, ni, subtype, rssi, rstamp);
return;
- case IEEE80211_FC0_SUBTYPE_DEAUTH: {
- u_int16_t reason;
-
- if (ic->ic_state == IEEE80211_S_SCAN) {
- ic->ic_stats.is_rx_mgtdiscard++;
- return;
- }
- /*
- * deauth frame format
- * [2] reason
- */
- IEEE80211_VERIFY_LENGTH(efrm - frm, 2);
- reason = le16toh(*(u_int16_t *)frm);
- __USE(reason);
- ic->ic_stats.is_rx_deauth++;
- IEEE80211_NODE_STAT(ni, rx_deauth);
-
- if (!IEEE80211_ADDR_EQ(wh->i_addr1, ic->ic_myaddr)) {
- /* Not intended for this station. */
- ic->ic_stats.is_rx_mgtdiscard++;
- break;
- }
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "[%s] recv deauthenticate (reason %d)\n",
- ether_snprintf(ebuf, sizeof(ebuf), ni->ni_macaddr), reason);
- switch (ic->ic_opmode) {
- case IEEE80211_M_STA:
- ieee80211_new_state(ic, IEEE80211_S_AUTH,
- wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
- break;
- case IEEE80211_M_HOSTAP:
-#ifndef IEEE80211_NO_HOSTAP
- if (ni != ic->ic_bss)
- ieee80211_node_leave(ic, ni);
-#endif /* !IEEE80211_NO_HOSTAP */
- break;
- default:
- ic->ic_stats.is_rx_mgtdiscard++;
- break;
- }
- break;
- }
+ case IEEE80211_FC0_SUBTYPE_DEAUTH:
+ ieee80211_recv_mgmt_deauth(ic, m0, ni, subtype, rssi, rstamp);
+ return;
case IEEE80211_FC0_SUBTYPE_DISASSOC: {
u_int16_t reason;
Home |
Main Index |
Thread Index |
Old Index