aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-03-04 14:23:44 (GMT)
committerJouni Malinen <j@w1.fi>2009-11-22 09:35:22 (GMT)
commitbbd2206afd993110580e287dd1917924a44392b1 (patch)
tree87f4ad2f39b7877595be07dd504ddee73f508d4d
parent8e2a2b9e9accb1664cb91569d65153fc900447c9 (diff)
downloadhostap-06-bbd2206afd993110580e287dd1917924a44392b1.zip
hostap-06-bbd2206afd993110580e287dd1917924a44392b1.tar.gz
hostap-06-bbd2206afd993110580e287dd1917924a44392b1.tar.bz2
Use bit mask/shift and helper functions instead of C bit fields
(cherry picked from commit 979be3fecf48e36ac6faab90ef7d2512c8999d54)
-rw-r--r--hostapd/wme.c28
-rw-r--r--hostapd/wme.h38
2 files changed, 35 insertions, 31 deletions
diff --git a/hostapd/wme.c b/hostapd/wme.c
index d178dbc..10f6f90 100644
--- a/hostapd/wme.c
+++ b/hostapd/wme.c
@@ -30,6 +30,24 @@
static u8 wmm_oui[3] = { 0x00, 0x50, 0xf2 };
+static inline u8 wmm_aci_aifsn(int aifsn, int acm, int aci)
+{
+ u8 ret;
+ ret = (aifsn << WMM_AC_AIFNS_SHIFT) & WMM_AC_AIFSN_MASK;
+ if (acm)
+ ret |= WMM_AC_ACM;
+ ret |= (aci << WMM_AC_ACI_SHIFT) & WMM_AC_ACI_MASK;
+ return ret;
+}
+
+
+static inline u8 wmm_ecw(int ecwmin, int ecwmax)
+{
+ return ((ecwmin << WMM_AC_ECWMIN_SHIFT) & WMM_AC_ECWMIN_MASK) |
+ ((ecwmax << WMM_AC_ECWMAX_SHIFT) & WMM_AC_ECWMAX_MASK);
+}
+
+
/*
* Add WMM Parameter Element to Beacon, Probe Response, and (Re)Association
* Response frames.
@@ -58,12 +76,10 @@ u8 * hostapd_eid_wmm(struct hostapd_data *hapd, u8 *eid)
struct hostapd_wmm_ac_params *acp =
&hapd->iconf->wmm_ac_params[e];
- ac->aifsn = acp->aifs;
- ac->acm = acp->admission_control_mandatory;
- ac->aci = e;
- ac->reserved = 0;
- ac->e_cw_min = acp->cwmin;
- ac->e_cw_max = acp->cwmax;
+ ac->aci_aifsn = wmm_aci_aifsn(acp->aifs,
+ acp->admission_control_mandatory,
+ e);
+ ac->cw = wmm_ecw(acp->cwmin, acp->cwmax);
ac->txop_limit = host_to_le16(acp->txop_limit);
}
diff --git a/hostapd/wme.h b/hostapd/wme.h
index 37767de..92c5c52 100644
--- a/hostapd/wme.h
+++ b/hostapd/wme.h
@@ -42,32 +42,20 @@ struct wmm_information_element {
} __attribute__ ((packed));
+#define WMM_AC_AIFSN_MASK 0x0f
+#define WMM_AC_AIFNS_SHIFT 0
+#define WMM_AC_ACM 0x10
+#define WMM_AC_ACI_MASK 0x60
+#define WMM_AC_ACI_SHIFT 5
+
+#define WMM_AC_ECWMIN_MASK 0x0f
+#define WMM_AC_ECWMIN_SHIFT 0
+#define WMM_AC_ECWMAX_MASK 0xf0
+#define WMM_AC_ECWMAX_SHIFT 4
+
struct wmm_ac_parameter {
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- /* byte 1: ACI/AIFSN */
- u8 aifsn:4,
- acm:1,
- aci:2,
- reserved:1;
-
- /* byte 2: ECWmin/ECWmax (CW = 2^ECW - 1) */
- u8 e_cw_min:4,
- e_cw_max:4;
-#elif __BYTE_ORDER == __BIG_ENDIAN
- /* byte 1: ACI/AIFSN */
- u8 reserved:1,
- aci:2,
- acm:1,
- aifsn:4;
-
- /* byte 2: ECWmin/ECWmax */
- u8 e_cw_max:4,
- e_cw_min:4;
-#else
-#error "Please fix <endian.h>"
-#endif
-
- /* bytes 3 & 4 */
+ u8 aci_aifsn; /* AIFSN, ACM, ACI */
+ u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */
le16 txop_limit;
} __attribute__ ((packed));