sync code with last fixes and improvements from OpenBSD

This commit is contained in:
purplerain 2023-07-20 23:56:46 +00:00
parent f57be82572
commit 58b04bcee7
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
468 changed files with 9958 additions and 7882 deletions

View file

@ -1107,7 +1107,7 @@ enum {
*/
enum ieee80211_htprot {
IEEE80211_HTPROT_NONE = 0, /* only 20/40MHz HT STAs exist */
IEEE80211_HTPROT_NONMEMBER, /* non-HT STA overlaps our channel */
IEEE80211_HTPROT_NONMEMBER, /* non-HT STA overlaps our channel */
IEEE80211_HTPROT_20MHZ, /* 20MHz HT STA on a 40MHz channel */
IEEE80211_HTPROT_NONHT_MIXED /* non-HT STA associated to our BSS */
};

View file

@ -55,7 +55,7 @@ enum ieee80211_akm {
#define IEEE80211_PMK_LEN 32
#ifdef _KERNEL
#ifdef _KERNEL
static __inline int
ieee80211_is_8021x_akm(enum ieee80211_akm akm)

View file

@ -114,7 +114,7 @@ ieee80211_ccmp_phase1(AES_CTX *ctx, const struct ieee80211_frame *wh,
aad += IEEE80211_ADDR_LEN;
}
if (ieee80211_has_qos(wh)) {
/*
/*
* XXX 802.11-2012 11.4.3.3.3 g says the A-MSDU present bit
* must be set here if both STAs are SPP A-MSDU capable.
*/

View file

@ -167,7 +167,7 @@ ieee80211_input_hwdecrypt(struct ieee80211com *ic, struct ieee80211_node *ni,
k = ieee80211_get_rxkey(ic, m, ni);
if (k == NULL)
return NULL;
wh = mtod(m, struct ieee80211_frame *);
hdrlen = ieee80211_get_hdrlen(wh);
@ -343,7 +343,7 @@ ieee80211_inputm(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni,
}
}
#endif
/*
/*
* If Block Ack was explicitly requested, check
* if we have a BA agreement for this RA/TID.
*/
@ -359,7 +359,7 @@ ieee80211_inputm(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni,
goto err;
}
/*
/*
* Check if we have an explicit or implicit
* Block Ack Request for a valid BA agreement.
*/
@ -841,11 +841,11 @@ ieee80211_input_ba(struct ieee80211com *ic, struct mbuf *m,
ic->ic_stats.is_ht_rx_frame_above_ba_winend++;
count = (sn - ba->ba_winend) & 0xfff;
if (count > ba->ba_winsize) {
/*
/*
* Check whether we're consistently behind the window,
* and let the window move forward if necessary.
*/
if (ba->ba_winmiss < IEEE80211_BA_MAX_WINMISS) {
if (ba->ba_winmiss < IEEE80211_BA_MAX_WINMISS) {
if (ba->ba_missedsn == ((sn - 1) & 0xfff))
ba->ba_winmiss++;
else
@ -893,7 +893,7 @@ ieee80211_input_ba(struct ieee80211com *ic, struct mbuf *m,
ieee80211_input_ba_flush(ic, ni, ba, ml);
}
/*
/*
* Forward buffered frames with sequence number lower than max_seq.
* See 802.11-2012 9.21.7.6.2 b.
*/
@ -961,7 +961,7 @@ ieee80211_input_ba_flush(struct ieee80211com *ic, struct ieee80211_node *ni,
timeout_add_msec(&ba->ba_gap_to, IEEE80211_BA_GAP_TIMEOUT);
}
/*
/*
* Forcibly move the BA window forward to remove a leading gap which has
* been causing frames to linger in the reordering buffer for too long.
* A leading gap will occur if a particular A-MPDU subframe never arrives
@ -1004,7 +1004,7 @@ ieee80211_input_ba_gap_timeout(void *arg)
if_input(&ic->ic_if, &ml);
}
splx(s);
splx(s);
}
@ -1182,7 +1182,7 @@ ieee80211_amsdu_decap_validate(struct ieee80211com *ic, struct mbuf *m,
const uint8_t llc_hdr_mac[ETHER_ADDR_LEN] = {
/* MAC address matching the 802.2 LLC header. */
LLC_SNAP_LSAP, LLC_SNAP_LSAP, LLC_UI, 0, 0, 0
};
};
/*
* We are sorry, but this particular MAC address cannot be used.
@ -1299,13 +1299,13 @@ ieee80211_amsdu_decap(struct ieee80211com *ic, struct mbuf *m,
}
ml_enqueue(&subframes, m);
m = n;
/* remove padding */
pad = ((len + 3) & ~3) - len;
m_adj(m, pad);
}
while ((n = ml_dequeue(&subframes)) != NULL)
ieee80211_enqueue_data(ic, n, ni, mcast, ml);
@ -1895,7 +1895,7 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m,
ic->ic_updatedtim(ic);
}
/*
/*
* Reset management timer. If it is non-zero in RUN state, the
* driver sent a probe request after a missed beacon event.
* This probe response indicates the AP is still serving us

View file

@ -184,7 +184,7 @@ ieee80211_disable_wep(struct ieee80211com *ic)
{
struct ieee80211_key *k;
int i;
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
k = &ic->ic_nw_keys[i];
if (k->k_cipher != IEEE80211_CIPHER_NONE)
@ -534,7 +534,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
memcmp(join.i_nwid, ic->ic_des_essid,
join.i_len) == 0)
update_ic = 1;
if (join.i_flags & IEEE80211_JOIN_DEL_ALL &&
if (join.i_flags & IEEE80211_JOIN_DEL_ALL &&
ieee80211_get_ess(ic, ic->ic_des_essid,
ic->ic_des_esslen) != NULL)
update_ic = 1;

View file

@ -648,7 +648,7 @@ ieee80211_switch_ess(struct ieee80211com *ic)
}
void
ieee80211_set_ess(struct ieee80211com *ic, struct ieee80211_ess *ess,
ieee80211_set_ess(struct ieee80211com *ic, struct ieee80211_ess *ess,
struct ieee80211_node *ni)
{
memset(ic->ic_des_essid, 0, IEEE80211_NWID_LEN);
@ -967,7 +967,7 @@ ieee80211_create_ibss(struct ieee80211com* ic, struct ieee80211_channel *chan)
struct ieee80211_edca_ac_params *ac;
int aci;
/*
/*
* Configure HT protection. This will be updated later
* based on the number of non-HT nodes in the node cache.
*/
@ -1199,14 +1199,14 @@ ieee80211_node_tx_stopped(struct ieee80211com *ic,
if ((ic->ic_flags & IEEE80211_F_BGSCAN) == 0)
return;
/*
/*
* Install a callback which will switch us to the new AP once
* the de-auth frame has been processed by hardware.
* Pass on the existing ni->ni_unref_arg argument.
*/
ic->ic_bss->ni_unref_cb = ieee80211_node_switch_bss;
/*
/*
* All data frames queued to hardware have been flushed and
* A-MPDU Tx has been stopped. We are now going to switch APs.
* Queue a de-auth frame addressed at our current AP.
@ -1234,7 +1234,7 @@ ieee80211_node_tx_flushed(struct ieee80211com *ic, struct ieee80211_node *ni)
/* All data frames queued to hardware have been flushed. */
if (ic->ic_caps & IEEE80211_C_TX_AMPDU) {
/*
/*
* Install a callback which will switch us to the
* new AP once Tx agg sessions have been stopped,
* which involves sending a DELBA frame.
@ -1351,7 +1351,7 @@ ieee80211_node_join_bss(struct ieee80211com *ic, struct ieee80211_node *selbs)
timeout_del(&ic->ic_bgscan_timeout);
ic->ic_flags &= ~IEEE80211_F_BGSCAN;
/*
/*
* After a background scan, we have now switched APs.
* Pretend we were just de-authed, which makes
* ieee80211_new_state() try to re-auth and thus send
@ -1375,7 +1375,7 @@ struct ieee80211_node *
ieee80211_node_choose_bss(struct ieee80211com *ic, int bgscan,
struct ieee80211_node **curbs)
{
struct ieee80211_node *ni, *nextbs, *selbs = NULL,
struct ieee80211_node *ni, *nextbs, *selbs = NULL,
*selbs2 = NULL, *selbs5 = NULL;
uint8_t min_5ghz_rssi;
@ -1530,7 +1530,7 @@ ieee80211_end_scan(struct ifnet *ifp)
goto notfound;
}
/*
/*
* After a background scan we might end up choosing the
* same AP again. Or the newly selected AP's RSSI level
* might be low enough to trigger another background scan.
@ -1562,7 +1562,7 @@ ieee80211_end_scan(struct ifnet *ifp)
ieee80211_chan2mode(ic, ni->ni_chan));
return;
}
arg = malloc(sizeof(*arg), M_DEVBUF, M_NOWAIT | M_ZERO);
if (arg == NULL) {
ic->ic_flags &= ~IEEE80211_F_BGSCAN;
@ -1587,7 +1587,7 @@ ieee80211_end_scan(struct ifnet *ifp)
return;
}
/*
/*
* Install a callback which will switch us to the new AP once
* all dispatched frames have been processed by hardware.
*/
@ -1990,7 +1990,7 @@ ieee80211_needs_rxnode(struct ieee80211com *ic,
return monitor || rc;
}
/*
/*
* Drivers call this, so increase the reference count before returning
* the node.
*/
@ -2283,7 +2283,7 @@ ieee80211_clean_nodes(struct ieee80211com *ic, int cache_timeout)
}
}
/*
/*
* During a cache timeout we iterate over all nodes.
* Check for node leaks by comparing the actual number of cached
* nodes with the ic_nnodes count, which is maintained while adding
@ -2371,7 +2371,7 @@ ieee80211_setup_htcaps(struct ieee80211_node *ni, const uint8_t *data,
}
#ifndef IEEE80211_STA_ONLY
/*
/*
* Handle nodes switching from 11n into legacy modes.
*/
void
@ -2466,7 +2466,7 @@ ieee80211_setup_vhtop(struct ieee80211_node *ni, const uint8_t *data,
}
#ifndef IEEE80211_STA_ONLY
/*
/*
* Handle nodes switching from 11ac into legacy modes.
*/
void

View file

@ -420,13 +420,13 @@ struct ieee80211_node {
#define IEEE80211_NODE_SA_QUERY 0x0800 /* SA Query in progress */
#define IEEE80211_NODE_SA_QUERY_FAILED 0x1000 /* last SA Query failed */
#define IEEE80211_NODE_RSN_NEW_PTK 0x2000 /* expecting a new PTK */
#define IEEE80211_NODE_HT_SGI20 0x4000 /* SGI on 20 MHz negotiated */
#define IEEE80211_NODE_HT_SGI40 0x8000 /* SGI on 40 MHz negotiated */
#define IEEE80211_NODE_HT_SGI20 0x4000 /* SGI on 20 MHz negotiated */
#define IEEE80211_NODE_HT_SGI40 0x8000 /* SGI on 40 MHz negotiated */
#define IEEE80211_NODE_VHT 0x10000 /* VHT negotiated */
#define IEEE80211_NODE_HTCAP 0x20000 /* claims to support HT */
#define IEEE80211_NODE_VHTCAP 0x40000 /* claims to support VHT */
#define IEEE80211_NODE_VHT_SGI80 0x80000 /* SGI on 80 MHz negotiated */
#define IEEE80211_NODE_VHT_SGI160 0x100000 /* SGI on 160 MHz negotiated */
#define IEEE80211_NODE_VHT_SGI80 0x80000 /* SGI on 80 MHz negotiated */
#define IEEE80211_NODE_VHT_SGI160 0x100000 /* SGI on 160 MHz negotiated */
/* If not NULL, this function gets called when ni_refcnt hits zero. */
void (*ni_unref_cb)(struct ieee80211com *,
@ -484,7 +484,7 @@ ieee80211_unref_node(struct ieee80211_node **ni)
*ni = NULL; /* guard against use */
}
/*
/*
* Check if the peer supports HT.
* Require a HT capabilities IE and at least one of the mandatory MCS.
* MCS 0-7 are mandatory but some APs have particular MCS disabled.
@ -521,7 +521,7 @@ ieee80211_node_supports_ht_chan40(struct ieee80211_node *ni)
(ni->ni_htop0 & IEEE80211_HTOP0_CHW));
}
/*
/*
* Check if the peer supports VHT.
* Require a VHT capabilities IE and support for VHT MCS with a single
* spatial stream.
@ -565,8 +565,8 @@ ieee80211_node_supports_vht_chan80(struct ieee80211_node *ni)
cap_chan_width = (ni->ni_vhtcaps & IEEE80211_VHTCAP_CHAN_WIDTH_MASK) >>
IEEE80211_VHTCAP_CHAN_WIDTH_SHIFT;
if (cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_80 &&
cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_160 &&
if (cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_80 &&
cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_160 &&
cap_chan_width != IEEE80211_VHTCAP_CHAN_WIDTH_160_8080)
return 0;

View file

@ -197,7 +197,7 @@ ieee80211_recv_4way_msg1(struct ieee80211com *ic,
ic->ic_opmode != IEEE80211_M_IBSS)
return;
#endif
/*
/*
* Message 1 is always expected while RSN is active since some
* APs will rekey the PTK by sending Msg1/4 after some time.
*/
@ -340,7 +340,7 @@ ieee80211_recv_4way_msg2(struct ieee80211com *ic,
}
#endif /* IEEE80211_STA_ONLY */
/*
/*
* Check if a group key must be updated with a new GTK from an EAPOL frame.
* Manipulated group key handshake messages could trick clients into
* reinstalling an already used group key and hence lower or reset the
@ -534,7 +534,7 @@ ieee80211_recv_4way_msg3(struct ieee80211com *ic,
if (ieee80211_send_4way_msg4(ic, ni) != 0)
return; /* ..authenticator will retry */
/*
/*
* Only install a new pairwise key if we are still expecting a new key,
* as indicated by the NODE_RSN_NEW_PTK flag. An adversary could be
* sending manipulated retransmissions of message 3 of the 4-way

View file

@ -135,7 +135,7 @@ ieee80211_ra_use_ht_sgi(struct ieee80211_node *ni)
return 1;
} else if (ni->ni_flags & IEEE80211_NODE_HT_SGI20)
return 1;
return 0;
}

View file

@ -17,7 +17,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
/*
* Goodput statistics struct. Measures the effective data rate of an MCS.
* All uint64_t numbers in this struct use fixed-point arithmetic.
*/

View file

@ -140,7 +140,7 @@ ieee80211_ra_vht_use_sgi(struct ieee80211_node *ni)
if (ni->ni_flags & IEEE80211_NODE_VHT_SGI80)
return 1;
}
return 0;
}

View file

@ -17,7 +17,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
/*
* Goodput statistics struct. Measures the effective data rate of a rate.
* All uint64_t numbers in this struct use fixed-point arithmetic.
*/

View file

@ -498,8 +498,8 @@ int ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode);
enum ieee80211_phymode ieee80211_next_mode(struct ifnet *);
enum ieee80211_phymode ieee80211_chan2mode(struct ieee80211com *,
const struct ieee80211_channel *);
void ieee80211_disable_wep(struct ieee80211com *);
void ieee80211_disable_rsn(struct ieee80211com *);
void ieee80211_disable_wep(struct ieee80211com *);
void ieee80211_disable_rsn(struct ieee80211com *);
int ieee80211_add_ess(struct ieee80211com *, struct ieee80211_join *);
void ieee80211_del_ess(struct ieee80211com *, char *, int, int);
void ieee80211_set_ess(struct ieee80211com *, struct ieee80211_ess *,