From 3d9d8072d00177d23e3f89590293f903fa5da787 Mon Sep 17 00:00:00 2001 From: stsp Date: Mon, 5 Feb 2018 08:44:13 +0000 Subject: [PATCH] Add a new function hook to struct ieee80211com which wireless drivers can use to process, and then acknowledge or reject, incoming AUTH requests in hostap mode. net80211 accepts an AUTH request from any STA which fits into the node cache. This behaviour doesn't work for devices which have a lower limit on concurrent STAs they can serve, so such drivers need an override. This will be used by our athn(4) USB driver soon. ok kevlo@ --- sys/net80211/ieee80211_proto.c | 39 +++++++++++++++++++++++++--------- sys/net80211/ieee80211_proto.h | 4 +++- sys/net80211/ieee80211_var.h | 4 +++- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index 8f6d804ae77..397973e665d 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_proto.c,v 1.81 2017/12/08 21:16:01 stsp Exp $ */ +/* $OpenBSD: ieee80211_proto.c,v 1.82 2018/02/05 08:44:13 stsp Exp $ */ /* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */ /*- @@ -715,6 +715,24 @@ ieee80211_delba_request(struct ieee80211com *ic, struct ieee80211_node *ni, } } +#ifndef IEEE80211_STA_ONLY +void +ieee80211_auth_open_confirm(struct ieee80211com *ic, + struct ieee80211_node *ni, uint16_t seq) +{ + struct ifnet *ifp = &ic->ic_if; + + IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_AUTH, seq + 1); + if (ifp->if_flags & IFF_DEBUG) + printf("%s: station %s %s authenticated (open)\n", + ifp->if_xname, + ether_sprintf((u_int8_t *)ni->ni_macaddr), + ni->ni_state != IEEE80211_STA_CACHE ? + "newly" : "already"); + ieee80211_node_newstate(ni, IEEE80211_STA_AUTH); +} +#endif + void ieee80211_auth_open(struct ieee80211com *ic, const struct ieee80211_frame *wh, struct ieee80211_node *ni, struct ieee80211_rxinfo *rxi, u_int16_t seq, @@ -765,15 +783,16 @@ ieee80211_auth_open(struct ieee80211com *ic, const struct ieee80211_frame *wh, ni->ni_rstamp = rxi->rxi_tstamp; ni->ni_chan = ic->ic_bss->ni_chan; } - IEEE80211_SEND_MGMT(ic, ni, - IEEE80211_FC0_SUBTYPE_AUTH, seq + 1); - if (ifp->if_flags & IFF_DEBUG) - printf("%s: station %s %s authenticated (open)\n", - ifp->if_xname, - ether_sprintf((u_int8_t *)ni->ni_macaddr), - ni->ni_state != IEEE80211_STA_CACHE ? - "newly" : "already"); - ieee80211_node_newstate(ni, IEEE80211_STA_AUTH); + + /* + * Drivers may want to set up state before confirming. + * In which case this returns EBUSY and the driver will + * later call ieee80211_auth_open_confirm() by itself. + */ + if (ic->ic_newauth && ic->ic_newauth(ic, ni, + ni->ni_state != IEEE80211_STA_CACHE, seq) != 0) + break; + ieee80211_auth_open_confirm(ic, ni, seq); break; #endif /* IEEE80211_STA_ONLY */ diff --git a/sys/net80211/ieee80211_proto.h b/sys/net80211/ieee80211_proto.h index edc008634b5..379563161f1 100644 --- a/sys/net80211/ieee80211_proto.h +++ b/sys/net80211/ieee80211_proto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_proto.h,v 1.43 2017/10/21 20:15:17 patrick Exp $ */ +/* $OpenBSD: ieee80211_proto.h,v 1.44 2018/02/05 08:44:13 stsp Exp $ */ /* $NetBSD: ieee80211_proto.h,v 1.3 2003/10/13 04:23:56 dyoung Exp $ */ /*- @@ -144,6 +144,8 @@ extern int ieee80211_ibss_merge(struct ieee80211com *, struct ieee80211_node *, u_int64_t); extern void ieee80211_reset_erp(struct ieee80211com *); extern void ieee80211_set_shortslottime(struct ieee80211com *, int); +extern void ieee80211_auth_open_confirm(struct ieee80211com *, + struct ieee80211_node *, uint16_t); extern void ieee80211_auth_open(struct ieee80211com *, const struct ieee80211_frame *, struct ieee80211_node *, struct ieee80211_rxinfo *rs, u_int16_t, u_int16_t); diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 69986415717..5b9e11179dd 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_var.h,v 1.83 2017/12/12 15:50:39 stsp Exp $ */ +/* $OpenBSD: ieee80211_var.h,v 1.84 2018/02/05 08:44:13 stsp Exp $ */ /* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */ /*- @@ -204,6 +204,8 @@ struct ieee80211com { struct ieee80211_node *, int, int, int); int (*ic_newstate)(struct ieee80211com *, enum ieee80211_state, int); + int (*ic_newauth)(struct ieee80211com *, + struct ieee80211_node *, int, uint16_t); void (*ic_newassoc)(struct ieee80211com *, struct ieee80211_node *, int); void (*ic_node_leave)(struct ieee80211com *, -- 2.20.1