Index: head/sys/dev/ath/if_ath.c =================================================================== --- head/sys/dev/ath/if_ath.c +++ head/sys/dev/ath/if_ath.c @@ -3483,10 +3483,10 @@ /* calculate XOR of eight 6bit values */ dl = LLADDR((struct sockaddr_dl *) ifma->ifma_addr); - val = LE_READ_4(dl + 0); + val = le32dec(dl + 0); pos = (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val; - val = LE_READ_4(dl + 3); + val = le32dec(dl + 3); pos ^= (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val; pos &= 0x3f; Index: head/sys/dev/ath/if_ath_beacon.c =================================================================== --- head/sys/dev/ath/if_ath_beacon.c +++ head/sys/dev/ath/if_ath_beacon.c @@ -942,11 +942,11 @@ ATH_UNLOCK(sc); /* extract tstamp from last beacon and convert to TU */ - nexttbtt = TSF_TO_TU(LE_READ_4(ni->ni_tstamp.data + 4), - LE_READ_4(ni->ni_tstamp.data)); + nexttbtt = TSF_TO_TU(le32dec(ni->ni_tstamp.data + 4), + le32dec(ni->ni_tstamp.data)); - tsf_beacon = ((uint64_t) LE_READ_4(ni->ni_tstamp.data + 4)) << 32; - tsf_beacon |= LE_READ_4(ni->ni_tstamp.data); + tsf_beacon = ((uint64_t) le32dec(ni->ni_tstamp.data + 4)) << 32; + tsf_beacon |= le32dec(ni->ni_tstamp.data); if (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_MBSS) { Index: head/sys/dev/ath/if_ath_misc.h =================================================================== --- head/sys/dev/ath/if_ath_misc.h +++ head/sys/dev/ath/if_ath_misc.h @@ -39,15 +39,6 @@ * and into something else. */ -/* unaligned little endian access */ -#define LE_READ_2(p) \ - ((u_int16_t) \ - ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8))) -#define LE_READ_4(p) \ - ((u_int32_t) \ - ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8) | \ - (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))) - extern int ath_rxbuf; extern int ath_txbuf; extern int ath_txbuf_mgmt; Index: head/sys/dev/ath/if_ath_rx.c =================================================================== --- head/sys/dev/ath/if_ath_rx.c +++ head/sys/dev/ath/if_ath_rx.c @@ -344,8 +344,8 @@ uint64_t tsf_beacon_target; int tsf_intval; - tsf_beacon_old = ((uint64_t) LE_READ_4(ni->ni_tstamp.data + 4)) << 32; - tsf_beacon_old |= LE_READ_4(ni->ni_tstamp.data); + tsf_beacon_old = ((uint64_t) le32dec(ni->ni_tstamp.data + 4)) << 32; + tsf_beacon_old |= le32dec(ni->ni_tstamp.data); #define TU_TO_TSF(_tu) (((u_int64_t)(_tu)) << 10) tsf_intval = 1; @@ -378,8 +378,8 @@ ATH_RSSI_LPF(sc->sc_halstats.ns_avgbrssi, rssi); - tsf_beacon = ((uint64_t) LE_READ_4(ni->ni_tstamp.data + 4)) << 32; - tsf_beacon |= LE_READ_4(ni->ni_tstamp.data); + tsf_beacon = ((uint64_t) le32dec(ni->ni_tstamp.data + 4)) << 32; + tsf_beacon |= le32dec(ni->ni_tstamp.data); nexttbtt = ath_hal_getnexttbtt(sc->sc_ah); Index: head/sys/dev/otus/if_otus.c =================================================================== --- head/sys/dev/otus/if_otus.c +++ head/sys/dev/otus/if_otus.c @@ -62,7 +62,6 @@ #include #include #include -#include #ifdef IEEE80211_SUPPORT_SUPERG #include #endif @@ -2307,7 +2306,7 @@ uint32_t val; dl = LLADDR((struct sockaddr_dl *) ifma->ifma_addr); - val = LE_READ_4(dl + 4); + val = le32dec(dl + 4); /* Get address byte 5 */ val = val & 0x0000ff00; val = val >> 8; Index: head/sys/dev/rtwn/if_rtwn.c =================================================================== --- head/sys/dev/rtwn/if_rtwn.c +++ head/sys/dev/rtwn/if_rtwn.c @@ -1265,8 +1265,8 @@ rtwn_write_4(sc, R92C_CR, reg); /* Set BSSID. */ - rtwn_write_4(sc, R92C_BSSID + 0, LE_READ_4(&ni->ni_bssid[0])); - rtwn_write_4(sc, R92C_BSSID + 4, LE_READ_2(&ni->ni_bssid[4])); + rtwn_write_4(sc, R92C_BSSID + 0, le32dec(&ni->ni_bssid[0])); + rtwn_write_4(sc, R92C_BSSID + 4, le16dec(&ni->ni_bssid[4])); if (ic->ic_curmode == IEEE80211_MODE_11B) rtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 0); Index: head/sys/dev/rtwn/if_rtwnreg.h =================================================================== --- head/sys/dev/rtwn/if_rtwnreg.h +++ head/sys/dev/rtwn/if_rtwnreg.h @@ -895,10 +895,6 @@ #define R92C_RAID_11B 6 -/* Macros to access unaligned little-endian memory. */ -#define LE_READ_2(x) ((x)[0] | (x)[1] << 8) -#define LE_READ_4(x) ((x)[0] | (x)[1] << 8 | (x)[2] << 16 | (x)[3] << 24) - /* * Macros to access subfields in registers. */ Index: head/sys/dev/urtwn/if_urtwn.c =================================================================== --- head/sys/dev/urtwn/if_urtwn.c +++ head/sys/dev/urtwn/if_urtwn.c @@ -66,7 +66,6 @@ #include #include -#include #include #include #include @@ -2266,20 +2265,20 @@ /* Write key. */ for (i = 0; i < 4; i++) { error = urtwn_cam_write(sc, R92C_CAM_KEY(k->wk_keyix, i), - LE_READ_4(&k->wk_key[i * 4])); + le32dec(&k->wk_key[i * 4])); if (error != 0) goto fail; } /* Write CTL0 last since that will validate the CAM entry. */ error = urtwn_cam_write(sc, R92C_CAM_CTL1(k->wk_keyix), - LE_READ_4(&k->wk_macaddr[2])); + le32dec(&k->wk_macaddr[2])); if (error != 0) goto fail; error = urtwn_cam_write(sc, R92C_CAM_CTL0(k->wk_keyix), SM(R92C_CAM_ALGO, algo) | SM(R92C_CAM_KEYID, keyid) | - SM(R92C_CAM_MACLO, LE_READ_2(&k->wk_macaddr[0])) | + SM(R92C_CAM_MACLO, le16dec(&k->wk_macaddr[0])) | R92C_CAM_VALID); if (error != 0) goto fail; @@ -2579,8 +2578,8 @@ urtwn_set_mode(sc, mode); /* Set BSSID. */ - urtwn_write_4(sc, R92C_BSSID + 0, LE_READ_4(&ni->ni_bssid[0])); - urtwn_write_4(sc, R92C_BSSID + 4, LE_READ_2(&ni->ni_bssid[4])); + urtwn_write_4(sc, R92C_BSSID + 0, le32dec(&ni->ni_bssid[0])); + urtwn_write_4(sc, R92C_BSSID + 4, le16dec(&ni->ni_bssid[4])); if (ic->ic_curmode == IEEE80211_MODE_11B) urtwn_write_1(sc, R92C_INIRTS_RATE_SEL, 0); Index: head/sys/net80211/ieee80211_hostap.c =================================================================== --- head/sys/net80211/ieee80211_hostap.c +++ head/sys/net80211/ieee80211_hostap.c @@ -1165,7 +1165,7 @@ wpa_cipher(const uint8_t *sel, uint8_t *keylen) { #define WPA_SEL(x) (((x)<<24)|WPA_OUI) - uint32_t w = LE_READ_4(sel); + uint32_t w = le32dec(sel); switch (w) { case WPA_SEL(WPA_CSE_NULL): @@ -1195,7 +1195,7 @@ wpa_keymgmt(const uint8_t *sel) { #define WPA_SEL(x) (((x)<<24)|WPA_OUI) - uint32_t w = LE_READ_4(sel); + uint32_t w = le32dec(sel); switch (w) { case WPA_SEL(WPA_ASE_8021X_UNSPEC): @@ -1242,7 +1242,7 @@ } frm += 6, len -= 4; /* NB: len is payload only */ /* NB: iswpaoui already validated the OUI and type */ - w = LE_READ_2(frm); + w = le16dec(frm); if (w != WPA_VERSION) { IEEE80211_DISCARD_IE(vap, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA, @@ -1258,7 +1258,7 @@ frm += 4, len -= 4; /* unicast ciphers */ - n = LE_READ_2(frm); + n = le16dec(frm); frm += 2, len -= 2; if (len < n*4+2) { IEEE80211_DISCARD_IE(vap, @@ -1278,7 +1278,7 @@ rsn->rsn_ucastcipher = IEEE80211_CIPHER_AES_CCM; /* key management algorithms */ - n = LE_READ_2(frm); + n = le16dec(frm); frm += 2, len -= 2; if (len < n*4) { IEEE80211_DISCARD_IE(vap, @@ -1298,7 +1298,7 @@ rsn->rsn_keymgmt = WPA_ASE_8021X_PSK; if (len > 2) /* optional capabilities */ - rsn->rsn_caps = LE_READ_2(frm); + rsn->rsn_caps = le16dec(frm); return 0; } @@ -1312,7 +1312,7 @@ rsn_cipher(const uint8_t *sel, uint8_t *keylen) { #define RSN_SEL(x) (((x)<<24)|RSN_OUI) - uint32_t w = LE_READ_4(sel); + uint32_t w = le32dec(sel); switch (w) { case RSN_SEL(RSN_CSE_NULL): @@ -1344,7 +1344,7 @@ rsn_keymgmt(const uint8_t *sel) { #define RSN_SEL(x) (((x)<<24)|RSN_OUI) - uint32_t w = LE_READ_4(sel); + uint32_t w = le32dec(sel); switch (w) { case RSN_SEL(RSN_ASE_8021X_UNSPEC): @@ -1389,7 +1389,7 @@ return IEEE80211_REASON_IE_INVALID; } frm += 2; - w = LE_READ_2(frm); + w = le16dec(frm); if (w != RSN_VERSION) { IEEE80211_DISCARD_IE(vap, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA, @@ -1405,7 +1405,7 @@ frm += 4, len -= 4; /* unicast ciphers */ - n = LE_READ_2(frm); + n = le16dec(frm); frm += 2, len -= 2; if (len < n*4+2) { IEEE80211_DISCARD_IE(vap, @@ -1425,7 +1425,7 @@ rsn->rsn_ucastcipher = IEEE80211_CIPHER_AES_CCM; /* key management algorithms */ - n = LE_READ_2(frm); + n = le16dec(frm); frm += 2, len -= 2; if (len < n*4) { IEEE80211_DISCARD_IE(vap, @@ -1446,7 +1446,7 @@ /* optional RSN capabilities */ if (len > 2) - rsn->rsn_caps = LE_READ_2(frm); + rsn->rsn_caps = le16dec(frm); /* XXXPMKID */ return 0; Index: head/sys/net80211/ieee80211_ht.c =================================================================== --- head/sys/net80211/ieee80211_ht.c +++ head/sys/net80211/ieee80211_ht.c @@ -1424,7 +1424,7 @@ } else ni->ni_flags &= ~IEEE80211_NODE_HTCOMPAT; - ni->ni_htcap = LE_READ_2(ie + + ni->ni_htcap = le16dec(ie + __offsetof(struct ieee80211_ie_htcap, hc_cap)); ni->ni_htparam = ie[__offsetof(struct ieee80211_ie_htcap, hc_param)]; } @@ -1437,9 +1437,9 @@ ni->ni_htctlchan = htinfo->hi_ctrlchannel; ni->ni_ht2ndchan = SM(htinfo->hi_byte1, IEEE80211_HTINFO_2NDCHAN); - w = LE_READ_2(&htinfo->hi_byte2); + w = le16dec(&htinfo->hi_byte2); ni->ni_htopmode = SM(w, IEEE80211_HTINFO_OPMODE); - w = LE_READ_2(&htinfo->hi_byte45); + w = le16dec(&htinfo->hi_byte45); ni->ni_htstbc = SM(w, IEEE80211_HTINFO_BASIC_STBCMCS); } @@ -1932,9 +1932,9 @@ int tid; dialogtoken = frm[2]; - baparamset = LE_READ_2(frm+3); - batimeout = LE_READ_2(frm+5); - baseqctl = LE_READ_2(frm+7); + baparamset = le16dec(frm+3); + batimeout = le16dec(frm+5); + baseqctl = le16dec(frm+7); tid = MS(baparamset, IEEE80211_BAPS_TID); @@ -1997,12 +1997,12 @@ int tid, bufsiz; dialogtoken = frm[2]; - code = LE_READ_2(frm+3); - baparamset = LE_READ_2(frm+5); + code = le16dec(frm+3); + baparamset = le16dec(frm+5); tid = MS(baparamset, IEEE80211_BAPS_TID); bufsiz = MS(baparamset, IEEE80211_BAPS_BUFSIZ); policy = MS(baparamset, IEEE80211_BAPS_POLICY); - batimeout = LE_READ_2(frm+7); + batimeout = le16dec(frm+7); tap = &ni->ni_tx_ampdu[tid]; if ((tap->txa_flags & IEEE80211_AGGR_XCHGPEND) == 0) { @@ -2069,8 +2069,8 @@ uint16_t baparamset, code; int tid; - baparamset = LE_READ_2(frm+2); - code = LE_READ_2(frm+4); + baparamset = le16dec(frm+2); + code = le16dec(frm+4); tid = MS(baparamset, IEEE80211_DELBAPS_TID); Index: head/sys/net80211/ieee80211_hwmp.c =================================================================== --- head/sys/net80211/ieee80211_hwmp.c +++ head/sys/net80211/ieee80211_hwmp.c @@ -118,18 +118,6 @@ static struct timeval ieee80211_hwmp_preqminint = { 0, 100000 }; static struct timeval ieee80211_hwmp_perrminint = { 0, 100000 }; -/* unalligned little endian access */ -#define LE_WRITE_2(p, v) do { \ - ((uint8_t *)(p))[0] = (v) & 0xff; \ - ((uint8_t *)(p))[1] = ((v) >> 8) & 0xff; \ -} while (0) -#define LE_WRITE_4(p, v) do { \ - ((uint8_t *)(p))[0] = (v) & 0xff; \ - ((uint8_t *)(p))[1] = ((v) >> 8) & 0xff; \ - ((uint8_t *)(p))[2] = ((v) >> 16) & 0xff; \ - ((uint8_t *)(p))[3] = ((v) >> 24) & 0xff; \ -} while (0) - /* NB: the Target Address set in a Proactive PREQ is the broadcast address. */ static const uint8_t broadcastaddr[IEEE80211_ADDR_LEN] = @@ -440,18 +428,18 @@ preq->preq_flags = *iefrm_t++; preq->preq_hopcount = *iefrm_t++; preq->preq_ttl = *iefrm_t++; - preq->preq_id = LE_READ_4(iefrm_t); iefrm_t += 4; + preq->preq_id = le32dec(iefrm_t); iefrm_t += 4; IEEE80211_ADDR_COPY(preq->preq_origaddr, iefrm_t); iefrm_t += 6; - preq->preq_origseq = LE_READ_4(iefrm_t); iefrm_t += 4; + preq->preq_origseq = le32dec(iefrm_t); iefrm_t += 4; /* NB: may have Originator Proxied Address */ if (preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_AE) { IEEE80211_ADDR_COPY( preq->preq_orig_ext_addr, iefrm_t); iefrm_t += 6; } - preq->preq_lifetime = LE_READ_4(iefrm_t); iefrm_t += 4; - preq->preq_metric = LE_READ_4(iefrm_t); iefrm_t += 4; + preq->preq_lifetime = le32dec(iefrm_t); iefrm_t += 4; + preq->preq_metric = le32dec(iefrm_t); iefrm_t += 4; preq->preq_tcount = *iefrm_t++; for (i = 0; i < preq->preq_tcount; i++) { @@ -460,7 +448,7 @@ preq->preq_targets[i].target_addr, iefrm_t); iefrm_t += 6; preq->preq_targets[i].target_seq = - LE_READ_4(iefrm_t); + le32dec(iefrm_t); iefrm_t += 4; } @@ -489,18 +477,18 @@ prep->prep_ttl = *iefrm_t++; IEEE80211_ADDR_COPY(prep->prep_targetaddr, iefrm_t); iefrm_t += 6; - prep->prep_targetseq = LE_READ_4(iefrm_t); iefrm_t += 4; + prep->prep_targetseq = le32dec(iefrm_t); iefrm_t += 4; /* NB: May have Target Proxied Address */ if (prep->prep_flags & IEEE80211_MESHPREP_FLAGS_AE) { IEEE80211_ADDR_COPY( prep->prep_target_ext_addr, iefrm_t); iefrm_t += 6; } - prep->prep_lifetime = LE_READ_4(iefrm_t); iefrm_t += 4; - prep->prep_metric = LE_READ_4(iefrm_t); iefrm_t += 4; + prep->prep_lifetime = le32dec(iefrm_t); iefrm_t += 4; + prep->prep_metric = le32dec(iefrm_t); iefrm_t += 4; IEEE80211_ADDR_COPY(prep->prep_origaddr, iefrm_t); iefrm_t += 6; - prep->prep_origseq = LE_READ_4(iefrm_t); iefrm_t += 4; + prep->prep_origseq = le32dec(iefrm_t); iefrm_t += 4; hwmp_recv_prep(vap, ni, wh, prep); IEEE80211_FREE(prep, M_80211_MESH_PREP); @@ -533,7 +521,7 @@ IEEE80211_ADDR_COPY( perr->perr_dests[i].dest_addr, iefrm_t); iefrm_t += 6; - perr->perr_dests[i].dest_seq = LE_READ_4(iefrm_t); + perr->perr_dests[i].dest_seq = le32dec(iefrm_t); iefrm_t += 4; /* NB: May have Target Proxied Address */ if (perr->perr_dests[i].dest_flags & @@ -544,7 +532,7 @@ iefrm_t += 6; } perr->perr_dests[i].dest_rcode = - LE_READ_2(iefrm_t); + le16dec(iefrm_t); iefrm_t += 2; } @@ -566,9 +554,9 @@ return 1; } memcpy(&rann, mrann, sizeof(rann)); - rann.rann_seq = LE_READ_4(&mrann->rann_seq); - rann.rann_interval = LE_READ_4(&mrann->rann_interval); - rann.rann_metric = LE_READ_4(&mrann->rann_metric); + rann.rann_seq = le32dec(&mrann->rann_seq); + rann.rann_interval = le32dec(&mrann->rann_interval); + rann.rann_metric = le32dec(&mrann->rann_metric); hwmp_recv_rann(vap, ni, wh, &rann); found++; break; @@ -682,12 +670,11 @@ } #define ADDSHORT(frm, v) do { \ - frm[0] = (v) & 0xff; \ - frm[1] = (v) >> 8; \ + le16enc(frm, v); \ frm += 2; \ } while (0) #define ADDWORD(frm, v) do { \ - LE_WRITE_4(frm, v); \ + le32enc(frm, v); \ frm += 4; \ } while (0) /* Index: head/sys/net80211/ieee80211_input.h =================================================================== --- head/sys/net80211/ieee80211_input.h +++ head/sys/net80211/ieee80211_input.h @@ -80,70 +80,58 @@ } while (0) #endif /* !IEEE80211_DEBUG */ -/* unalligned little endian access */ -#define LE_READ_2(p) \ - ((uint16_t) \ - ((((const uint8_t *)(p))[0] ) | \ - (((const uint8_t *)(p))[1] << 8))) -#define LE_READ_4(p) \ - ((uint32_t) \ - ((((const uint8_t *)(p))[0] ) | \ - (((const uint8_t *)(p))[1] << 8) | \ - (((const uint8_t *)(p))[2] << 16) | \ - (((const uint8_t *)(p))[3] << 24))) +#include /* For le16toh() / le32dec() */ static __inline int iswpaoui(const uint8_t *frm) { - return frm[1] > 3 && LE_READ_4(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI); + return frm[1] > 3 && le32dec(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI); } static __inline int iswmeoui(const uint8_t *frm) { - return frm[1] > 3 && LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI); + return frm[1] > 3 && le32dec(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI); } static __inline int iswmeparam(const uint8_t *frm) { - return frm[1] > 5 && LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI) && + return frm[1] > 5 && le32dec(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI) && frm[6] == WME_PARAM_OUI_SUBTYPE; } static __inline int iswmeinfo(const uint8_t *frm) { - return frm[1] > 5 && LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI) && + return frm[1] > 5 && le32dec(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI) && frm[6] == WME_INFO_OUI_SUBTYPE; } static __inline int isatherosoui(const uint8_t *frm) { - return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI); + return frm[1] > 3 && le32dec(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI); } static __inline int istdmaoui(const uint8_t *frm) { - return frm[1] > 3 && LE_READ_4(frm+2) == ((TDMA_OUI_TYPE<<24)|TDMA_OUI); + return frm[1] > 3 && le32dec(frm+2) == ((TDMA_OUI_TYPE<<24)|TDMA_OUI); } static __inline int ishtcapoui(const uint8_t *frm) { - return frm[1] > 3 && LE_READ_4(frm+2) == ((BCM_OUI_HTCAP<<24)|BCM_OUI); + return frm[1] > 3 && le32dec(frm+2) == ((BCM_OUI_HTCAP<<24)|BCM_OUI); } static __inline int ishtinfooui(const uint8_t *frm) { - return frm[1] > 3 && LE_READ_4(frm+2) == ((BCM_OUI_HTINFO<<24)|BCM_OUI); + return frm[1] > 3 && le32dec(frm+2) == ((BCM_OUI_HTINFO<<24)|BCM_OUI); } -#include /* For le16toh() */ - /* * Check the current frame sequence number against the current TID * state and return whether it's in sequence or should be dropped. Index: head/sys/net80211/ieee80211_input.c =================================================================== --- head/sys/net80211/ieee80211_input.c +++ head/sys/net80211/ieee80211_input.c @@ -549,7 +549,7 @@ break; case IEEE80211_ELEMID_FHPARMS: if (ic->ic_phytype == IEEE80211_T_FH) { - scan->fhdwell = LE_READ_2(&frm[2]); + scan->fhdwell = le16dec(&frm[2]); scan->chan = IEEE80211_FH_CHAN(frm[4], frm[5]); scan->fhindex = frm[6]; } Index: head/sys/net80211/ieee80211_mesh.c =================================================================== --- head/sys/net80211/ieee80211_mesh.c +++ head/sys/net80211/ieee80211_mesh.c @@ -1710,7 +1710,7 @@ } /* XXX: are we sure there is no reallocating after m_pullup? */ - seq = LE_READ_4(mc->mc_seq); + seq = le32dec(mc->mc_seq); if (IEEE80211_IS_MULTICAST(wh->i_addr1)) addr = wh->i_addr3; else if (ae == IEEE80211_MESH_AE_01) @@ -2135,12 +2135,12 @@ mpie = (const struct ieee80211_meshpeer_ie *) frm; memset(mp, 0, sizeof(*mp)); mp->peer_len = mpie->peer_len; - mp->peer_proto = LE_READ_2(&mpie->peer_proto); - mp->peer_llinkid = LE_READ_2(&mpie->peer_llinkid); + mp->peer_proto = le16dec(&mpie->peer_proto); + mp->peer_llinkid = le16dec(&mpie->peer_llinkid); switch (subtype) { case IEEE80211_ACTION_MESHPEERING_CONFIRM: mp->peer_linkid = - LE_READ_2(&mpie->peer_linkid); + le16dec(&mpie->peer_linkid); break; case IEEE80211_ACTION_MESHPEERING_CLOSE: /* NB: peer link ID is optional */ @@ -2148,12 +2148,12 @@ (IEEE80211_MPM_BASE_SZ + 2)) { mp->peer_linkid = 0; mp->peer_rcode = - LE_READ_2(&mpie->peer_linkid); + le16dec(&mpie->peer_linkid); } else { mp->peer_linkid = - LE_READ_2(&mpie->peer_linkid); + le16dec(&mpie->peer_linkid); mp->peer_rcode = - LE_READ_2(&mpie->peer_rcode); + le16dec(&mpie->peer_rcode); } break; } @@ -2550,8 +2550,8 @@ ie->gann_hopcount = gannie->gann_hopcount; ie->gann_ttl = gannie->gann_ttl; IEEE80211_ADDR_COPY(ie->gann_addr, gannie->gann_addr); - ie->gann_seq = LE_READ_4(&gannie->gann_seq); - ie->gann_interval = LE_READ_2(&gannie->gann_interval); + ie->gann_seq = le32dec(&gannie->gann_seq); + ie->gann_interval = le16dec(&gannie->gann_interval); break; } frm += frm[1] + 2; Index: head/sys/net80211/ieee80211_output.c =================================================================== --- head/sys/net80211/ieee80211_output.c +++ head/sys/net80211/ieee80211_output.c @@ -77,18 +77,6 @@ #define ETHER_HEADER_COPY(dst, src) \ memcpy(dst, src, sizeof(struct ether_header)) -/* unalligned little endian access */ -#define LE_WRITE_2(p, v) do { \ - ((uint8_t *)(p))[0] = (v) & 0xff; \ - ((uint8_t *)(p))[1] = ((v) >> 8) & 0xff; \ -} while (0) -#define LE_WRITE_4(p, v) do { \ - ((uint8_t *)(p))[0] = (v) & 0xff; \ - ((uint8_t *)(p))[1] = ((v) >> 8) & 0xff; \ - ((uint8_t *)(p))[2] = ((v) >> 16) & 0xff; \ - ((uint8_t *)(p))[3] = ((v) >> 24) & 0xff; \ -} while (0) - static int ieee80211_fragment(struct ieee80211vap *, struct mbuf *, u_int hdrsize, u_int ciphdrsize, u_int mtu); static void ieee80211_tx_mgt_cb(struct ieee80211_node *, void *, int); @@ -1518,7 +1506,7 @@ } mc->mc_ttl = ms->ms_ttl; ms->ms_seq++; - LE_WRITE_4(mc->mc_seq, ms->ms_seq); + le32enc(mc->mc_seq, ms->ms_seq); break; #endif case IEEE80211_M_WDS: /* NB: is4addr should always be true */ @@ -1843,7 +1831,7 @@ ieee80211_add_cfparms(uint8_t *frm, struct ieee80211com *ic) { #define ADDSHORT(frm, v) do { \ - LE_WRITE_2(frm, v); \ + le16enc(frm, v); \ frm += 2; \ } while (0) *frm++ = IEEE80211_ELEMID_CFPARMS; @@ -1898,7 +1886,7 @@ { #define SM(_v, _f) (((_v) << _f##_S) & _f) #define ADDSHORT(frm, v) do { \ - LE_WRITE_2(frm, v); \ + le16enc(frm, v); \ frm += 2; \ } while (0) /* NB: this works 'cuz a param has an info at the front */ Index: head/sys/net80211/ieee80211_scan_sta.c =================================================================== --- head/sys/net80211/ieee80211_scan_sta.c +++ head/sys/net80211/ieee80211_scan_sta.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -785,7 +786,7 @@ } else for (i = 31; i >= 0 && isclr(htcap->hc_mcsset, i); i--); if (i >= 0) { - caps = LE_READ_2(&htcap->hc_cap); + caps = le16dec(&htcap->hc_cap); if ((caps & IEEE80211_HTCAP_CHWIDTH40) && (caps & IEEE80211_HTCAP_SHORTGI40)) rmax = ieee80211_htrates[i].ht40_rate_400ns; Index: head/sys/net80211/ieee80211_sta.c =================================================================== --- head/sys/net80211/ieee80211_sta.c +++ head/sys/net80211/ieee80211_sta.c @@ -1120,7 +1120,7 @@ wmep->wmep_aifsn = MS(frm[0], WME_PARAM_AIFSN); wmep->wmep_logcwmin = MS(frm[1], WME_PARAM_LOGCWMIN); wmep->wmep_logcwmax = MS(frm[1], WME_PARAM_LOGCWMAX); - wmep->wmep_txopLimit = LE_READ_2(frm+2); + wmep->wmep_txopLimit = le16dec(frm+2); frm += 4; } wme->wme_wmeChanParams.cap_info = qosinfo; Index: head/sys/net80211/ieee80211_superg.c =================================================================== --- head/sys/net80211/ieee80211_superg.c +++ head/sys/net80211/ieee80211_superg.c @@ -195,7 +195,7 @@ (const struct ieee80211_ath_ie *) ie; ni->ni_ath_flags = ath->ath_capability; - ni->ni_ath_defkeyix = LE_READ_2(&ath->ath_defkeyix); + ni->ni_ath_defkeyix = le16dec(&ath->ath_defkeyix); } int @@ -216,7 +216,7 @@ } ath = (const struct ieee80211_ath_ie *)frm; capschanged = (ni->ni_ath_flags != ath->ath_capability); - defkeyix = LE_READ_2(ath->ath_defkeyix); + defkeyix = le16dec(ath->ath_defkeyix); if (capschanged || defkeyix != ni->ni_ath_defkeyix) { ni->ni_ath_flags = ath->ath_capability; ni->ni_ath_defkeyix = defkeyix;