Purge warnings from prism2 drivers
[people/xl0/gpxe.git] / src / drivers / net / p80211hdr.h
index 50d9279..d9a8bbb 100644 (file)
 #define WLAN_FSTYPE_DEAUTHEN           0x0c
 
 /* Control */
+#define WLAN_FSTYPE_BLOCKACKREQ                0x8
+#define WLAN_FSTYPE_BLOCKACK           0x9
 #define WLAN_FSTYPE_PSPOLL             0x0a
 #define WLAN_FSTYPE_RTS                        0x0b
 #define WLAN_FSTYPE_CTS                        0x0c
 typedef UINT8 wlan_bss_ts_t[WLAN_BSS_TS_LEN];
 
 /* Generic 802.11 Header types */
-__WLAN_PRAGMA_PACK1__
+
 typedef struct p80211_hdr_a3
 {
-       UINT16  fc                      __WLAN_ATTRIB_PACK__;
-       UINT16  dur                     __WLAN_ATTRIB_PACK__;
-       UINT8   a1[WLAN_ADDR_LEN]       __WLAN_ATTRIB_PACK__;
-       UINT8   a2[WLAN_ADDR_LEN]       __WLAN_ATTRIB_PACK__;
-       UINT8   a3[WLAN_ADDR_LEN]       __WLAN_ATTRIB_PACK__;
-       UINT16  seq                     __WLAN_ATTRIB_PACK__;
+       UINT16  fc;
+       UINT16  dur;
+       UINT8   a1[WLAN_ADDR_LEN];
+       UINT8   a2[WLAN_ADDR_LEN];
+       UINT8   a3[WLAN_ADDR_LEN];
+       UINT16  seq;
 } __WLAN_ATTRIB_PACK__ p80211_hdr_a3_t;
-__WLAN_PRAGMA_PACKDFLT__
 
-__WLAN_PRAGMA_PACK1__
 typedef struct p80211_hdr_a4
 {
-       UINT16  fc                      __WLAN_ATTRIB_PACK__;
-       UINT16  dur                     __WLAN_ATTRIB_PACK__;
-       UINT8   a1[WLAN_ADDR_LEN]       __WLAN_ATTRIB_PACK__;
-       UINT8   a2[WLAN_ADDR_LEN]       __WLAN_ATTRIB_PACK__;
-       UINT8   a3[WLAN_ADDR_LEN]       __WLAN_ATTRIB_PACK__;
-       UINT16  seq                     __WLAN_ATTRIB_PACK__;
-       UINT8   a4[WLAN_ADDR_LEN]       __WLAN_ATTRIB_PACK__;
+       UINT16  fc;
+       UINT16  dur;
+       UINT8   a1[WLAN_ADDR_LEN];
+       UINT8   a2[WLAN_ADDR_LEN];
+       UINT8   a3[WLAN_ADDR_LEN];
+       UINT16  seq;
+       UINT8   a4[WLAN_ADDR_LEN];
 } __WLAN_ATTRIB_PACK__ p80211_hdr_a4_t;
-__WLAN_PRAGMA_PACKDFLT__
 
 typedef union p80211_hdr
 {
-       p80211_hdr_a3_t         a3 __WLAN_ATTRIB_PACK__;
-       p80211_hdr_a4_t         a4 __WLAN_ATTRIB_PACK__;
+       p80211_hdr_a3_t         a3;
+       p80211_hdr_a4_t         a4;
 } __WLAN_ATTRIB_PACK__ p80211_hdr_t;
 
 
@@ -257,6 +256,44 @@ typedef union p80211_hdr
 /*================================================================*/
 /* Function Declarations */
 
-void p802addr_to_str( char *buf, UINT8 *addr);
+/* Frame and header lenght macros */
+
+#define WLAN_CTL_FRAMELEN(fstype) (\
+       (fstype) == WLAN_FSTYPE_BLOCKACKREQ     ? 24 : \
+       (fstype) == WLAN_FSTYPE_BLOCKACK        ? 152 : \
+       (fstype) == WLAN_FSTYPE_PSPOLL          ? 20 : \
+       (fstype) == WLAN_FSTYPE_RTS             ? 20 : \
+       (fstype) == WLAN_FSTYPE_CTS             ? 14 : \
+       (fstype) == WLAN_FSTYPE_ACK             ? 14 : \
+       (fstype) == WLAN_FSTYPE_CFEND           ? 20 : \
+       (fstype) == WLAN_FSTYPE_CFENDCFACK      ? 20 : 4)
+
+#define WLAN_FCS_LEN                   4
+
+/* ftcl in HOST order */
+inline static UINT16 p80211_headerlen(UINT16 fctl)
+{
+       UINT16 hdrlen = 0;
+
+       switch ( WLAN_GET_FC_FTYPE(fctl) ) {
+       case WLAN_FTYPE_MGMT:
+               hdrlen = WLAN_HDR_A3_LEN;
+               break;
+       case WLAN_FTYPE_DATA:
+               hdrlen = WLAN_HDR_A3_LEN;
+               if ( WLAN_GET_FC_TODS(fctl) && WLAN_GET_FC_FROMDS(fctl) ) {
+                       hdrlen += WLAN_ADDR_LEN;
+               }
+               break;
+       case WLAN_FTYPE_CTL:
+               hdrlen = WLAN_CTL_FRAMELEN(WLAN_GET_FC_FSTYPE(fctl)) - 
+                       WLAN_FCS_LEN; 
+               break;
+       default:
+               hdrlen = WLAN_HDR_A3_LEN;
+       }
+       
+       return hdrlen;
+}
 
 #endif /* _P80211HDR_H */