logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

revision 3001 committed: msg#00008

Subject: revision 3001 committed
Project     : madwifi
Revision    : 3001
Author      : benoit
Date        : 2007-12-02 22:00:41 +0100 (Sun, 02 Dec 2007)

Log Message :
Merge from trunk using (hope it does not break things) :
svn merge http://svn.madwifi.org/madwifi/trunk@2930 
http://svn.madwifi.org/madwifi/trunk@3000

Affected Files:
* madwifi/branches/madwifi-dfs/Makefile               updated             
* madwifi/branches/madwifi-dfs/ath/if_ath.c           updated             
* madwifi/branches/madwifi-dfs/ath/if_ath_hal_wrappers.h  updated             
* madwifi/branches/madwifi-dfs/ath/if_ath_pci.c       updated             
* madwifi/branches/madwifi-dfs/ath_hal/ah_os.h        updated             
* madwifi/branches/madwifi-dfs/include/compat.h       updated             
* madwifi/branches/madwifi-dfs/net80211/ieee80211.c   updated             
* madwifi/branches/madwifi-dfs/net80211/ieee80211_crypto.c  updated             
* madwifi/branches/madwifi-dfs/net80211/ieee80211_monitor.c  updated            
 
* madwifi/branches/madwifi-dfs/net80211/ieee80211_proto.c  updated             
* madwifi/branches/madwifi-dfs/net80211/ieee80211_proto.h  updated             
* madwifi/branches/madwifi-dfs/net80211/ieee80211_scan_ap.c  updated            
 
* madwifi/branches/madwifi-dfs/net80211/ieee80211_scan_sta.c  updated           
  
* madwifi/branches/madwifi-dfs/net80211/ieee80211_skb.c  updated             
* madwifi/branches/madwifi-dfs/net80211/ieee80211_wireless.c  updated           
  
* madwifi/branches/madwifi-dfs/regression/Makefile    added               
* madwifi/branches/madwifi-dfs/regression/ccmp/       properties updated  
* madwifi/branches/madwifi-dfs/regression/ccmp/Makefile  added               
* madwifi/branches/madwifi-dfs/regression/ccmp/test_ccmp.c  updated             
* madwifi/branches/madwifi-dfs/regression/tkip/       properties updated  
* madwifi/branches/madwifi-dfs/regression/tkip/Makefile  added               
* madwifi/branches/madwifi-dfs/regression/tkip/test_tkip.c  updated             
* madwifi/branches/madwifi-dfs/regression/wep/        properties updated  
* madwifi/branches/madwifi-dfs/regression/wep/Makefile  added               
* madwifi/branches/madwifi-dfs/regression/wep/test_wep.c  updated             
* madwifi/branches/madwifi-dfs/tools/80211debug.c     updated             
* madwifi/branches/madwifi-dfs/tools/80211stats.c     updated             
* madwifi/branches/madwifi-dfs/tools/ath_info.c       updated             
* madwifi/branches/madwifi-dfs/tools/athdebug.c       updated             
* madwifi/branches/madwifi-dfs/tools/athstats.c       updated             
* madwifi/branches/madwifi-dfs/tools/wlanconfig.c     updated             


Modified: madwifi/branches/madwifi-dfs/Makefile
===================================================================
--- madwifi/branches/madwifi-dfs/Makefile       2007-12-02 01:46:28 UTC (rev 
3000)
+++ madwifi/branches/madwifi-dfs/Makefile       2007-12-02 21:00:41 UTC (rev 
3001)
@@ -50,15 +50,13 @@
 include $(TOP)/Makefile.inc
 endif
 
-DIRS_MODULES = $(ATH) $(ATH_HAL) $(ATH_RATE) $(WLAN)
-
 obj-y := ath/ ath_hal/ ath_rate/ net80211/
 
 all: modules tools
 
 modules: configcheck svnversion.h
 ifdef LINUX24
-       for i in $(DIRS_MODULES); do \
+       for i in $(obj-y); do \
                $(MAKE) -C $$i || exit 1; \
        done
 else
@@ -90,7 +88,7 @@
        @# might cause make to abort the build
        sh scripts/find-madwifi-modules.sh -r $(KERNELRELEASE) $(DESTDIR)
 
-       for i in $(DIRS_MODULES); do \
+       for i in $(obj-y); do \
                $(MAKE) -C $$i install || exit 1; \
        done
 ifeq ($(DESTDIR),)
@@ -116,7 +114,7 @@
 reinstall-modules: uninstall-modules install-modules
 
 clean:
-       for i in $(DIRS_MODULES); do \
+       for i in $(obj-y); do \
                $(MAKE) -C $$i clean; \
        done
        -$(MAKE) -C $(TOOLS) clean

Modified: madwifi/branches/madwifi-dfs/ath/if_ath.c
===================================================================
--- madwifi/branches/madwifi-dfs/ath/if_ath.c   2007-12-02 01:46:28 UTC (rev 
3000)
+++ madwifi/branches/madwifi-dfs/ath/if_ath.c   2007-12-02 21:00:41 UTC (rev 
3001)
@@ -1593,8 +1593,7 @@
 
 /* Extend 15-bit timestamp from RX descriptor to a full 64-bit TSF using the
  * provided hardware TSF. The result is the closest value relative to hardware
- * TSF.
- */
+ * TSF. */
 
 /* NB: Not all chipsets return the same precision rstamp */
 static __inline u_int64_t
@@ -1606,13 +1605,11 @@
 
        result = (tsf & ~TSTAMP_MASK) | rstamp;
        if (result > tsf) {
-               if (result - tsf > (TSTAMP_MASK/2)) {
-                       result -= (TSTAMP_MASK+1);
-               }
+               if ((result - tsf) > (TSTAMP_MASK / 2))
+                       result -= (TSTAMP_MASK + 1);
        } else {
-               if (tsf - result > (TSTAMP_MASK/2)) {
-                       result += (TSTAMP_MASK+1);
-               }
+               if ((tsf - result) > (TSTAMP_MASK / 2))
+                       result += (TSTAMP_MASK + 1);
        }
 
        return result;
@@ -1983,15 +1980,15 @@
 
                hw_tsf = ath_hal_gettsf64(ah);
                if (last_rs_tstamp > (hw_tsf & TSTAMP_MASK)) {
-                       rollover ++;
+                       rollover++;
                        DPRINTF(sc, ATH_DEBUG_RECV,
-                         "%s: %d rollover detected for hw_tsf=%10llx\n",
+                               "%s: %d rollover detected for hw_tsf=%10llx\n",
                                DEV_NAME(sc->sc_dev),
                                rollover, hw_tsf);
                }
 
                last_rs_tstamp = 0;
-               for (bf=prev_rxbufcur; bf; bf = STAILQ_NEXT(bf, bf_list)) {
+               for (bf = prev_rxbufcur; bf; bf = STAILQ_NEXT(bf, bf_list)) {
                        ds = bf->bf_desc;
                        if (ds->ds_link == bf->bf_daddr) {
                                /* NB: never process the self-linked entry at
@@ -2001,20 +1998,19 @@
 
                        /* we only process buffers who needs RX timestamps
                         * adjustements */
-
                        if  (bf->bf_status & ATH_BUFSTATUS_RXTSTAMP) {
                                bf->bf_status &= ~ATH_BUFSTATUS_RXTSTAMP;
 
-
                                /* update rollover */
-                               if (last_rs_tstamp > bf->bf_tsf) {
-                                       rollover --;
-                               }
+                               if (last_rs_tstamp > bf->bf_tsf)
+                                       rollover--;
 
                                /* update last_rs_tstamp */
                                last_rs_tstamp = bf->bf_tsf;
-                               bf->bf_tsf =(hw_tsf & ~TSTAMP_MASK)|bf->bf_tsf;
-                               bf->bf_tsf -= rollover * (TSTAMP_MASK+1);
+                               bf->bf_tsf = 
+                                       (hw_tsf & ~TSTAMP_MASK) | bf->bf_tsf;
+                               bf->bf_tsf -= rollover * (TSTAMP_MASK + 1);
+
                                DPRINTF(sc, ATH_DEBUG_RECV,
                                        "%s: bf_tsf=%10llx hw_tsf=%10llx\n",
                                        DEV_NAME(sc->sc_dev),
@@ -3556,7 +3552,6 @@
        const u_int8_t mac0[IEEE80211_ADDR_LEN],
        struct ieee80211_node *bss)
 {
-#define        N(a)    ((int)(sizeof(a)/sizeof(a[0])))
        static const u_int8_t ciphermap[] = {
                HAL_CIPHER_WEP,         /* IEEE80211_CIPHER_WEP */
                HAL_CIPHER_TKIP,        /* IEEE80211_CIPHER_TKIP */
@@ -3579,7 +3574,7 @@
         * so that rx frames have an entry to match.
         */
        if ((k->wk_flags & IEEE80211_KEY_SWCRYPT) == 0) {
-               KASSERT(cip->ic_cipher < N(ciphermap),
+               KASSERT(cip->ic_cipher < ARRAY_SIZE(ciphermap),
                        ("invalid cipher type %u", cip->ic_cipher));
                hk.kv_type = ciphermap[cip->ic_cipher];
                hk.kv_len = k->wk_keylen;
@@ -3607,7 +3602,6 @@
                return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), &hk, mac, 
                                AH_FALSE);
        }
-#undef N
 }
 
 /*
@@ -3617,13 +3611,12 @@
 static ieee80211_keyix_t
 key_alloc_2pair(struct ath_softc *sc)
 {
-#define        N(a)    ((int)(sizeof(a)/sizeof(a[0])))
        u_int i;
        ieee80211_keyix_t keyix;
 
        KASSERT(sc->sc_splitmic, ("key cache !split"));
        /* XXX could optimize */
-       for (i = 0; i < N(sc->sc_keymap) / 4; i++) {
+       for (i = 0; i < ARRAY_SIZE(sc->sc_keymap) / 4; i++) {
                u_int8_t b = sc->sc_keymap[i];
                if (b != 0xff) {
                        /*
@@ -3660,7 +3653,6 @@
        }
        DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: out of pair space\n", __func__);
        return IEEE80211_KEYIX_NONE;
-#undef N
 }
 
 /*
@@ -3670,13 +3662,12 @@
 static ieee80211_keyix_t
 key_alloc_pair(struct ath_softc *sc)
 {
-#define        N(a)    (sizeof(a)/sizeof(a[0]))
        u_int i;
        ieee80211_keyix_t keyix;
 
        KASSERT(!sc->sc_splitmic, ("key cache split"));
        /* XXX could optimize */
-       for (i = 0; i < N(sc->sc_keymap)/4; i++) {
+       for (i = 0; i < ARRAY_SIZE(sc->sc_keymap)/4; i++) {
                u_int8_t b = sc->sc_keymap[i];
                if (b != 0xff) {
                        /*
@@ -3707,7 +3698,6 @@
        }
        DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: out of pair space\n", __func__);
        return IEEE80211_KEYIX_NONE;
-#undef N
 }
 
 /*
@@ -3716,12 +3706,11 @@
 static ieee80211_keyix_t
 key_alloc_single(struct ath_softc *sc)
 {
-#define        N(a)    ((int)(sizeof(a)/sizeof(a[0])))
        u_int i;
        ieee80211_keyix_t keyix;
 
        /* XXX: try i, i + 32, i + 64, i + 32 + 64 to minimize key pair 
conflicts */
-       for (i = 0; i < N(sc->sc_keymap); i++) {
+       for (i = 0; i < ARRAY_SIZE(sc->sc_keymap); i++) {
                u_int8_t b = sc->sc_keymap[i];
                if (b != 0xff) {
                        /*
@@ -3738,7 +3727,6 @@
        }
        DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: out of space\n", __func__);
        return IEEE80211_KEYIX_NONE;
-#undef N
 }
 
 /*
@@ -4702,10 +4690,8 @@
        /*
         * Enable the CAB queue before the beacon queue to
         * ensure cab frames are triggered by this beacon.
-        */
-       /* NB: only at DTIM do we set BITCTL_BUFD_MCAST bit */
+        * We only set BITCTL_BUFD_MCAST bit when its DTIM */
        if (tim_bitctl & BITCTL_BUFD_MCAST) {
-
                struct ath_txq *cabq = sc->sc_cabq;
                struct ath_buf *bfmcast;
                /*
@@ -6006,29 +5992,35 @@
 {
        struct ath_softc *sc = dev->priv;
        struct ieee80211com *ic = &sc->sc_ic;
-       struct ieee80211_frame *wh = (struct ieee80211_frame *) skb->data;
-       unsigned int headersize = ieee80211_anyhdrsize(wh);
-       int padbytes = roundup(headersize, 4) - headersize;
-
-       KASSERT(ic->ic_flags & IEEE80211_F_DATAPAD,
-               ("data padding not enabled?"));
-
-       if (padbytes > 0) {
-               /* Remove hw pad bytes */
-               struct sk_buff *skb1 = skb_copy(skb, GFP_ATOMIC);
-               if (skb1 == NULL)
-                       return;
-               memmove(skb1->data + padbytes, skb1->data, headersize);
-               skb_pull(skb1, padbytes);
-               /* We must duplicate the reference after an skb_copy! */
-               if (SKB_CB(skb)->ni != NULL) {
-                       SKB_CB(skb1)->ni = ieee80211_ref_node(SKB_CB(skb)->ni);
+       struct ieee80211_frame *wh = (struct ieee80211_frame *)skb->data;
+       struct sk_buff *tskb = skb;
+       unsigned int headersize;
+       int padbytes;
+  
+       KASSERT(ic->ic_flags & IEEE80211_F_DATAPAD,
+               ("data padding not enabled?"));
+  
+       /* Only non-control frames have bodies, and hence padding. */
+       if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=  
+                       IEEE80211_FC0_TYPE_CTL) {
+               headersize = ieee80211_anyhdrsize(wh);
+               padbytes = roundup(headersize, 4) - headersize;
+               if (padbytes > 0) {
+                       /* Copy skb and remove HW pad bytes */
+                       tskb = skb_copy(skb, GFP_ATOMIC);
+                       if (tskb == NULL)
+                               return;
+                       /* Reference any node from the source skb. */
+                       if (SKB_CB(skb)->ni != NULL)
+                               SKB_CB(tskb)->ni = 
ieee80211_ref_node(SKB_CB(skb)->ni);
+                       memmove(tskb->data + padbytes, tskb->data, headersize);
+                       skb_pull(tskb, padbytes);
                }
-               ieee80211_input_monitor(ic, skb1, bf, 0, rtsf, sc);
-               ieee80211_dev_kfree_skb(&skb1);
-       } else {
-               ieee80211_input_monitor(ic, skb, bf, 0, rtsf, sc);
-       }
+       }
+       
+       ieee80211_input_monitor(ic, tskb, bf, 0, rtsf, sc);
+       if (tskb != skb)
+               ieee80211_dev_kfree_skb(&tskb);
 }
 
 
@@ -6068,17 +6060,22 @@
                skb_orphan(skb);
        }
 
-       wh = (struct ieee80211_frame *) skb->data;
-       headersize = ieee80211_anyhdrsize(wh);
-       padbytes = roundup(headersize, 4) - headersize;
-       if (padbytes > 0) {
-               /* Unlike in rx_capture, we're freeing the skb at the end
-                * anyway, so we don't need to worry about using a copy */
-               memmove(skb->data + padbytes, skb->data, headersize);
-               skb_pull(skb, padbytes);
+       /* Only non-control frames have bodies, and hence padding. */
+       wh = (struct ieee80211_frame *)skb->data;
+       if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=  
+                       IEEE80211_FC0_TYPE_CTL) {
+               headersize = ieee80211_anyhdrsize(wh);
+               padbytes = roundup(headersize, 4) - headersize;
+               if (padbytes > 0) {
+                       /* Unlike in rx_capture, we're freeing the skb at the 
+                        * end anyway, so we don't need to worry about using a 
+                        * copy. */
+                       memmove(skb->data + padbytes, skb->data, headersize);
+                       skb_pull(skb, padbytes);
+               }
        }
 
-       if (skb_headroom(skb) < extra &&
+       if ((skb_headroom(skb) < extra) &&
            pskb_expand_head(skb, extra, 0, GFP_ATOMIC)) {
                printk("%s:%d %s\n", __FILE__, __LINE__, __func__);
                goto done;
@@ -6087,8 +6084,7 @@
        if (sc->sc_nmonvaps > 0) {
                /* Pass up tsf clock in mactime
                 * TX descriptor contains the transmit time in TUs,
-                * (bits 25-10 of the TSF).
-                */
+                * (bits 25-10 of the TSF). */
                tstamp = ts->ts_tstamp << 10;
 
                if ((tsf & 0x3ffffff) < tstamp)
@@ -6398,7 +6394,6 @@
                skb_put(skb, len);
                skb->protocol = __constant_htons(ETH_P_CONTROL);
 
-               /* Pass up TSF clock in MAC time */
                if (sc->sc_nmonvaps > 0) {
                        /*
                         * Some vap is in monitor mode, so send to
@@ -6625,7 +6620,6 @@
 static void
 ath_grppoll_txq_setup(struct ath_softc *sc, int qtype, int period)
 {
-#define        N(a)    ((int)(sizeof(a)/sizeof(a[0])))
        struct ath_hal *ah = sc->sc_ah;
        HAL_TXQ_INFO qi;
        int qnum;
@@ -6647,9 +6641,10 @@
                qnum = ath_hal_setuptxqueue(ah, qtype, &qi);
                if (qnum == -1)
                        return ;
-               if (qnum >= N(sc->sc_txq)) {
+               if (qnum >= ARRAY_SIZE(sc->sc_txq)) {
                        printk("%s: HAL qnum %u out of range, max %u!\n",
-                                  DEV_NAME(sc->sc_dev), qnum, N(sc->sc_txq));
+                                  DEV_NAME(sc->sc_dev), qnum,
+                                  (unsigned)ARRAY_SIZE(sc->sc_txq));
                        ath_hal_releasetxqueue(ah, qnum);
                        return;
                }
@@ -6667,8 +6662,6 @@
        txq->axq_compbufsz = compbufsz;
        txq->axq_compbufp = compbufp;
        ath_hal_resettxqueue(ah, txq->axq_qnum); /* push to h/w */
-#undef N
-
 }
 
 /*
@@ -6947,7 +6940,6 @@
 static struct ath_txq *
 ath_txq_setup(struct ath_softc *sc, int qtype, int subtype)
 {
-#define        N(a)    ((int)(sizeof(a)/sizeof(a[0])))
        struct ath_hal *ah = sc->sc_ah;
        HAL_TXQ_INFO qi;
        int qnum;
@@ -7017,9 +7009,10 @@
 #endif
                return NULL;
        }
-       if (qnum >= N(sc->sc_txq)) {
+       if (qnum >= ARRAY_SIZE(sc->sc_txq)) {
                printk("%s: HAL qnum %u out of range, max %u!\n",
-                       DEV_NAME(sc->sc_dev), qnum, N(sc->sc_txq));
+                       DEV_NAME(sc->sc_dev), qnum,
+                       (unsigned)ARRAY_SIZE(sc->sc_txq));
 #ifdef ATH_SUPERG_COMP
                if (compbuf) {
                        bus_free_consistent(sc->sc_bdev, compbufsz,
@@ -7046,7 +7039,6 @@
                sc->sc_txqsetup |= 1 << qnum;
        }
        return &sc->sc_txq[qnum];
-#undef N
 }
 
 /*
@@ -7061,12 +7053,12 @@
 static int
 ath_tx_setup(struct ath_softc *sc, int ac, int haltype)
 {
-#define        N(a)    ((int)(sizeof(a)/sizeof(a[0])))
        struct ath_txq *txq;
 
-       if (ac >= N(sc->sc_ac2q)) {
+       if (ac >= ARRAY_SIZE(sc->sc_ac2q)) {
                printk("%s: AC %u out of range, max %u!\n",
-                      DEV_NAME(sc->sc_dev), ac, (unsigned)N(sc->sc_ac2q));
+                      DEV_NAME(sc->sc_dev), ac,
+                      (unsigned)ARRAY_SIZE(sc->sc_ac2q));
                return 0;
        }
        txq = ath_txq_setup(sc, HAL_TX_QUEUE_DATA, haltype);
@@ -7075,7 +7067,6 @@
                return 1;
        } else
                return 0;
-#undef N
 }
 
 /*
@@ -8906,7 +8897,6 @@
                                if (error < 0)
                                        goto bad;
                        }
-
                        /*
                         * if the turbo flags have changed, then beacon and 
turbo
                         * need to be reconfigured.
@@ -9781,7 +9771,6 @@
 static void
 ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode)
 {
-#define        N(a)    ((int)(sizeof(a)/sizeof(a[0])))
        /* NB: on/off times from the Atheros NDIS driver, w/ permission */
        static const struct {
                u_int           rate;           /* tx/rx 802.11 rate */
@@ -9825,7 +9814,7 @@
                    rt->info[ix].phy == IEEE80211_T_OFDM)
                        sc->sc_hwmap[i].flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
                /* setup blink rate table to avoid per-packet lookup */
-               for (j = 0; j < N(blinkrates) - 1; j++)
+               for (j = 0; j < ARRAY_SIZE(blinkrates) - 1; j++)
                        if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate)
                                break;
                /* NB: this uses the last entry if the rate isn't found */
@@ -9843,7 +9832,6 @@
        sc->sc_protrix = (mode == IEEE80211_MODE_11G ? 1 : 0);
        /* rate index used to send mgt frames */
        sc->sc_minrateix = 0;
-#undef N
 }
 
 #ifdef ATH_SUPERG_FF

Modified: madwifi/branches/madwifi-dfs/ath/if_ath_hal_wrappers.h
===================================================================
--- madwifi/branches/madwifi-dfs/ath/if_ath_hal_wrappers.h      2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/ath/if_ath_hal_wrappers.h      2007-12-02 
21:00:41 UTC (rev 3001)
@@ -283,7 +283,7 @@
 
 static inline HAL_BOOL ath_hal_setintmit(struct ath_hal *ah, u_int32_t v)
 {
-       return (ath_hal_setcapability(ah, HAL_CAP_INTMIT, 1, v, NULL) == 
HAL_OK);
+       return (ath_hal_setcapability(ah, HAL_CAP_INTMIT, 1, v, NULL));
 }
 
 #endif                         /* #ifndef _IF_ATH_HAL_WRAPPERS_H_ */

Modified: madwifi/branches/madwifi-dfs/ath/if_ath_pci.c
===================================================================
--- madwifi/branches/madwifi-dfs/ath/if_ath_pci.c       2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/ath/if_ath_pci.c       2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -217,7 +217,7 @@
 
        /* looking for device type from broken device id */
        vdevice = id->device;
-       for (i = 0; i < (sizeof(ath_devidmap) / sizeof(ath_devidmap[0])); i++) {
+       for (i = 0; i < ARRAY_SIZE(ath_devidmap); i++) {
                if (id->device == ath_devidmap[i][0]) {
                        vdevice = ath_devidmap[i][1];
                        break;

Modified: madwifi/branches/madwifi-dfs/ath_hal/ah_os.h
===================================================================
--- madwifi/branches/madwifi-dfs/ath_hal/ah_os.h        2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/ath_hal/ah_os.h        2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -42,16 +42,16 @@
  * Atheros Hardware Access Layer (HAL) OS Dependent Definitions.
  */
 
-/* 
-MadWifi safe register operations:
+/*
+   MadWifi safe register operations:
 
-       When hacking on registers directly we need to use the macros
-       below, to avoid concurrent PCI access and abort mode errors.
+       When hacking on registers directly, we need to use the macros below to
+       avoid concurrent PCI access and abort mode errors.
 
        * ath_reg_read
        * ATH_REG_WRITE
 
-HAL-ONLY register operations: 
+   HAL-ONLY register operations:
 
        * _OS_REG_READ
        * _OS_REG_WRITE
@@ -60,26 +60,27 @@
        * ath_hal_reg_read.
        * ath_hal_reg_write
 
-       When compiled in HAL:
-               * We do not require locking overhead and function call unless 
user is debugging.
-               * All HAL operations are executed in the context of a MadWifi 
wrapper call which holds 
-                 the HAL lock.
-               * Normally HAL is build with the non-modified version of this 
file so it doesnt have our 
-                 funny macros anyway.
+    When compiled in HAL:
+       * We don't require locking overhead and function call except for
+         debugging.
+       * All HAL operations are executed in the context of a MadWifi wrapper
+         call that holds the HAL lock.
+       * Normally HAL is built with the non-modified version of this file, so
+         it doesn't have our funny macros anyway.
 
-       When compiled in MadWifi:
-               * The HAL wrapper API takes the HAL lock before invoking the 
HAL.
-               * HAL access is already protected, and MadWifi must NOT access 
the functions listed above.
-
+    When compiled in MadWifi:
+       * The HAL wrapper API takes the HAL lock before invoking the HAL.
+       * HAL access is already protected, and MadWifi must NOT access the
+         functions listed above.
 */
 
 /*
- * When building the HAL proper we use no GPL-contaminated include
- * files and must define these types ourself.  Beware of these being
- * mismatched against the contents of <linux/types.h>
+ * When building the HAL proper, we use no GPL-licensed include files and must
+ * define Linux types ourselves.  Please note that the definitions below don't
+ * exactly match those in <linux/types.h>
  */
 #ifndef _LINUX_TYPES_H
-/* NB: arm defaults to unsigned so be explicit */
+/* NB: ARM defaults to unsigned, so be explicit */
 typedef signed char            int8_t;
 typedef short                  int16_t;
 typedef int                    int32_t;
@@ -93,36 +94,35 @@
 typedef unsigned int           size_t;
 typedef unsigned int           u_int;
 typedef        void*                   va_list;
-#endif
+#endif                         /* !_LINUX_TYPES_H */
 
 /*
  * Linux/BSD gcc compatibility shims.
  */
 #define        __printflike(_a,_b) \
-       __attribute__ ((__format__ (__printf__, _a, _b)))
-#define        __va_list       va_list 
+       __attribute__((__format__ (__printf__, _a, _b)))
+#define        __va_list       va_list
 #define        OS_INLINE       __inline
 
 extern int ath_hal_dma_beacon_response_time;
 extern int ath_hal_sw_beacon_response_time;
 extern int ath_hal_additional_swba_backoff;
 
-void __ahdecl ath_hal_vprintf(struct ath_hal *ah, const char* fmt,
-                             va_list ap);
-void __ahdecl ath_hal_printf(struct ath_hal *ah, const char* fmt, ...);
-const char* __ahdecl ath_hal_ether_sprintf(const u_int8_t *mac);
+void __ahdecl ath_hal_vprintf(struct ath_hal *ah, const char *fmt, va_list ap);
+void __ahdecl ath_hal_printf(struct ath_hal *ah, const char *fmt, ...);
+const char *__ahdecl ath_hal_ether_sprintf(const u_int8_t *mac);
 int __ahdecl ath_hal_memcmp(const void *a, const void *b, size_t n);
-void * __ahdecl ath_hal_malloc(size_t size);
-void __ahdecl ath_hal_free(void* p);
+void *__ahdecl ath_hal_malloc(size_t size);
+void __ahdecl ath_hal_free(void *p);
 
 /* Delay n microseconds. */
-extern void __ahdecl ath_hal_delay(int);
+extern void __ahdecl ath_hal_delay(int);
 #define        OS_DELAY(_n)            ath_hal_delay(_n)
 
 #define        OS_MEMZERO(_a, _n)      ath_hal_memzero((_a), (_n))
 extern void __ahdecl ath_hal_memzero(void *, size_t);
 #define        OS_MEMCPY(_d, _s, _n)   ath_hal_memcpy(_d,_s,_n)
-extern void * __ahdecl ath_hal_memcpy(void *, const void *, size_t);
+extern void *__ahdecl ath_hal_memcpy(void *, const void *, size_t);
 
 #ifndef abs
 #define        abs(_a)                 __builtin_abs(_a)
@@ -133,7 +133,7 @@
 #endif
 
 struct ath_hal;
-extern u_int32_t __ahdecl ath_hal_getuptime(struct ath_hal *);
+extern u_int32_t __ahdecl ath_hal_getuptime(struct ath_hal *);
 #define        OS_GETUPTIME(_ah)       ath_hal_getuptime(_ah)
 
 /* Byte order/swapping support. */
@@ -142,9 +142,8 @@
 
 #ifndef AH_BYTE_ORDER
 /*
- * When the .inc file is not available (e.g. when building
- * in a kernel source tree); look for some other way to
- * setup the host byte order.
+ * When the .inc file is not available (e.g. when building in the kernel source
+ * tree), look for some other way to determine the host byte order.
  */
 #ifdef __LITTLE_ENDIAN
 #define        AH_BYTE_ORDER   AH_LITTLE_ENDIAN
@@ -155,93 +154,98 @@
 #ifndef AH_BYTE_ORDER
 #error "Do not know host byte order"
 #endif
-#endif /* AH_BYTE_ORDER */
+#endif                         /* AH_BYTE_ORDER */
 
 /*
- * Note that register accesses are done using target-specific 
- * functions when debugging is enabled (AH_DEBUG) or we are 
- * explicitly configured this way.
+ * Some big-endian architectures don't set CONFIG_GENERIC_IOMAP, but fail to
+ * implement iowrite32be and ioread32be.  Provide compatibility macros when
+ * it's needed.
  *
- * The hardware registers are native little-endian byte order.
- * Big-endian hosts are handled by enabling hardware byte-swap
- * of register reads and writes at reset.  But the PCI clock
- * domain registers are not byte swapped!  Thus, on big-endian
- * platforms we have to byte-swap thoese registers specifically.
- * Most of this code is collapsed at compile time because the
- * register values are constants.
+ * As of Linux 2.6.24, only MIPS, PARISC and PowerPC implement iowrite32be and
+ * ioread32be as functions.
  *
- * Presumably when talking about hardware byte-swapping, the above
- * text is referring to the Atheros chipset, as the registers 
- * referred to are in the PCI memory address space, and these are
- * never byte-swapped by PCI chipsets or bridges, but always 
- * written directly (i.e. the format defined by the manufacturer).
+ * The downside or the replacement macros it that we may be byte-swapping data
+ * for the second time, so the native implementations should be preferred.
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)) && \
+       !defined(CONFIG_GENERIC_IOMAP) && (AH_BYTE_ORDER == AH_BIG_ENDIAN) && \
+       !defined(__mips__) && !defined(__hppa__) && !defined(__powerpc__)
+# ifndef iowrite32be
+#  define iowrite32be(_val, _addr) iowrite32(swab32((_val)), (_addr))
+# endif
+# ifndef ioread32be
+#  define ioread32be(_addr) swab32(ioread32((_addr)))
+# endif
+#endif
+
+/*
+ * The register accesses are done using target-specific functions when
+ * debugging is enabled (AH_DEBUG) or it's explicitly requested for the target.
+ *
+ * The hardware registers use little-endian byte order natively.  Big-endian
+ * systems are configured by HAL to enable hardware byte-swap of register reads
+ * and writes at reset.  This avoid the need to byte-swap the data in software.
+ * However, the registers in a certain area from 0x4000 to 0x4fff (PCI clock
+ * domain registers) are not byte swapped!
+ *
+ * Since Linux I/O primitives default to little-endian operations, we only
+ * need to suppress byte-swapping on big-endian systems outside the area used
+ * by the PCI clock domain registers.
+ */
+#if (AH_BYTE_ORDER == AH_BIG_ENDIAN)
+#define is_reg_le(__reg) ((0x4000 <= (__reg) && (__reg) < 0x5000))
+#else
+#define is_reg_le(__reg) 1
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
-# if (AH_BYTE_ORDER == AH_BIG_ENDIAN)
 #define _OS_REG_WRITE(_ah, _reg, _val) do {                    \
-       (0x4000 <= (_reg) && (_reg) < 0x5000) ?                 \
+        is_reg_le(_reg) ?                                      \
         iowrite32((_val), (_ah)->ah_sh + (_reg)) :             \
         iowrite32be((_val), (_ah)->ah_sh + (_reg));            \
        } while (0)
 #define _OS_REG_READ(_ah, _reg)                                        \
-       ((0x4000 <= (_reg) && (_reg) < 0x5000) ?                \
+       (is_reg_le(_reg) ?                                      \
         ioread32((_ah)->ah_sh + (_reg)) :                      \
-        ioread32be((_ah)->ah_sh + (_reg)));
-# else /* AH_LITTLE_ENDIAN */
-#define _OS_REG_WRITE(_ah, _reg, _val) do {                    \
-       iowrite32(_val, (_ah)->ah_sh + (_reg));                 \
-       } while (0)
-#define _OS_REG_READ(_ah, _reg)                                        \
-       ioread32((_ah)->ah_sh + (_reg))
-       
-# endif /* AH_BYTE_ORDER */
+        ioread32be((_ah)->ah_sh + (_reg)))
 #else
-# if (AH_BYTE_ORDER == AH_BIG_ENDIAN)
 #define _OS_REG_WRITE(_ah, _reg, _val) do {                    \
-        writel((0x4000 <= (_reg) && (_reg) < 0x5000) ?         \
+        writel(is_reg_le(_reg) ?                               \
                (_val) : cpu_to_le32(_val),                     \
                (_ah)->ah_sh + (_reg));                         \
        } while (0)
 #define _OS_REG_READ(_ah, _reg)                                        \
-       ((0x4000 <= (_reg) && (_reg) < 0x5000) ?                \
+       (is_reg_le(_reg) ?                                      \
         readl((_ah)->ah_sh + (_reg)) :                         \
         cpu_to_le32(readl((_ah)->ah_sh + (_reg))))
-# else /* AH_LITTLE_ENDIAN */
-#define _OS_REG_WRITE(_ah, _reg, _val) do {                    \
-       writel(_val, (_ah)->ah_sh + (_reg));                    \
-       } while (0)
-#define _OS_REG_READ(_ah, _reg)                                        \
-       readl((_ah)->ah_sh + (_reg))
-# endif /* AH_BYTE_ORDER */
-#endif /* KERNEL_VERSON(2,6,12) */
+#endif                         /* KERNEL_VERSION(2,6,12) */
 
-/* 
-The functions in this section are not intended to be invoked by MadWifi driver
-code, but by the HAL.  They are NOT safe for direct invocation when the 
-sc->sc_hal_lock is not held.  Use ath_reg_read and ATH_REG_WRITE instead!
+/*
+ * The functions in this section are not intended to be invoked by MadWifi
+ * driver code, but by the HAL.  They are NOT safe to call directly when the
+ * sc->sc_hal_lock is not held.  Use ath_reg_read and ATH_REG_WRITE instead!
 */
 #if defined(AH_DEBUG) || defined(AH_REGOPS_FUNC) || defined(AH_DEBUG_ALQ)
 #define        OS_REG_WRITE(_ah, _reg, _val)   ath_hal_reg_write(_ah, _reg, 
_val)
 #define        OS_REG_READ(_ah, _reg)          ath_hal_reg_read(_ah, _reg)
-extern void __ahdecl ath_hal_reg_write(struct ath_hal *ah, u_int reg, 
u_int32_t val);
-extern u_int32_t __ahdecl ath_hal_reg_read(struct ath_hal *ah, u_int reg);
+extern void __ahdecl ath_hal_reg_write(struct ath_hal *ah, u_int reg,
+                                      u_int32_t val);
+extern u_int32_t __ahdecl ath_hal_reg_read(struct ath_hal *ah, u_int reg);
 #else
 #define OS_REG_WRITE(_ah, _reg, _val)  _OS_REG_WRITE(_ah, _reg, _val)
 #define OS_REG_READ(_ah, _reg)         _OS_REG_READ(_ah, _reg)
-#endif /* AH_DEBUG || AH_REGFUNC || AH_DEBUG_ALQ */
+#endif                         /* AH_DEBUG || AH_REGFUNC || AH_DEBUG_ALQ */
 
 extern char *ath_hal_func;
 static inline void ath_hal_set_function(const char *name)
-#if defined(AH_DEBUG)
 {
+#ifdef AH_DEBUG
        ath_hal_func = (char *)name;
+#endif
 }
-#else
-{ }
-#endif
 
 #ifdef AH_DEBUG_ALQ
-extern void __ahdecl OS_MARK(struct ath_hal *, u_int id, u_int32_t value);
+extern void __ahdecl OS_MARK(struct ath_hal *, u_int id, u_int32_t value);
 #else
 #define        OS_MARK(_ah, _id, _v)
 #endif
@@ -253,8 +257,9 @@
  *     compiled with the default calling convention and are not called
  *     from within the HAL.
  */
-extern struct ath_hal *_ath_hal_attach(u_int16_t devid, HAL_SOFTC,
-               HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*);
-extern void _ath_hal_detach(struct ath_hal *);
+extern struct ath_hal *_ath_hal_attach(u_int16_t devid, HAL_SOFTC,
+                                      HAL_BUS_TAG, HAL_BUS_HANDLE,
+                                      HAL_STATUS *);
+extern void _ath_hal_detach(struct ath_hal *);
 
-#endif /* _ATH_AH_OSDEP_H_ */
+#endif                         /* _ATH_AH_OSDEP_H_ */

Modified: madwifi/branches/madwifi-dfs/include/compat.h
===================================================================
--- madwifi/branches/madwifi-dfs/include/compat.h       2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/include/compat.h       2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -83,8 +83,6 @@
 #define        __packed        __attribute__((__packed__))
 #endif
 
-#define        __printflike(_a,_b) \
-       __attribute__ ((__format__ (__printf__, _a, _b)))
 #define        __offsetof(t,m) offsetof(t,m)
 
 #ifndef ALIGNED_POINTER

Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211.c
===================================================================
--- madwifi/branches/madwifi-dfs/net80211/ieee80211.c   2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/net80211/ieee80211.c   2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -1466,7 +1466,6 @@
 int
 ieee80211_rate2media(struct ieee80211com *ic, int rate, enum ieee80211_phymode 
mode)
 {
-#define        N(a)    (sizeof(a) / sizeof(a[0]))
        static const struct {
                u_int   m;      /* rate & mode */
                u_int   r;      /* if_media rate */
@@ -1533,18 +1532,16 @@
                mask |= IFM_IEEE80211_11G;
                break;
        }
-       for (i = 0; i < N(rates); i++)
+       for (i = 0; i < ARRAY_SIZE(rates); i++)
                if (rates[i].m == mask)
                        return rates[i].r;
        return IFM_AUTO;
-#undef N
 }
 EXPORT_SYMBOL(ieee80211_rate2media);
 
 int
 ieee80211_media2rate(int mword)
 {
-#define        N(a)    (sizeof(a) / sizeof(a[0]))
        static const int ieeerates[] = {
                -1,             /* IFM_AUTO */
                0,              /* IFM_MANUAL */
@@ -1572,9 +1569,8 @@
                108,            /* IFM_IEEE80211_OFDM54 */
                144,            /* IFM_IEEE80211_OFDM72 */
        };
-       return IFM_SUBTYPE(mword) < N(ieeerates) ?
+       return IFM_SUBTYPE(mword) < ARRAY_SIZE(ieeerates) ?
                ieeerates[IFM_SUBTYPE(mword)] : 0;
-#undef N
 }
 EXPORT_SYMBOL(ieee80211_media2rate);
 
@@ -1663,7 +1659,6 @@
 void
 ieee80211_build_countryie(struct ieee80211com *ic)
 {
-#define        N(a)    (sizeof (a) / sizeof (a[0]))
        int i, found;
        struct net_device *dev = ic->ic_dev;
        struct ieee80211_channel *c;
@@ -1675,7 +1670,7 @@
 
        /* Initialize country IE */
        found = 0;
-       for (i = 0; i < N(country_strings); i++) {
+       for (i = 0; i < ARRAY_SIZE(country_strings); i++) {
                if (country_strings[i].iso_code == ic->ic_country_code) {
                        ic->ic_country_ie.country_str[0] = 
country_strings[i].iso_name[0];
                        ic->ic_country_ie.country_str[1] = 
country_strings[i].iso_name[1];
@@ -1779,7 +1774,6 @@
        if (ic->ic_country_ie.country_len & 1)
                ic->ic_country_ie.country_len++;
 
-#undef N
 }
 
 void

Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_crypto.c
===================================================================
--- madwifi/branches/madwifi-dfs/net80211/ieee80211_crypto.c    2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/net80211/ieee80211_crypto.c    2007-12-02 
21:00:41 UTC (rev 3001)
@@ -252,7 +252,6 @@
 int
 ieee80211_crypto_available(struct ieee80211vap *vap, u_int cipher)
 {
-#define        N(a)    (sizeof(a) / sizeof(a[0]))
        unsigned int status = 0;
 
        if (cipher < IEEE80211_CIPHER_MAX) {
@@ -263,7 +262,7 @@
                         * than numbers and craft a module name based on the 
cipher
                         * name; e.g. wlan_cipher_<cipher-name>.
                         */
-                       if (cipher < N(cipher_modnames)) {
+                       if (cipher < ARRAY_SIZE(cipher_modnames)) {
                                IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
                                                "%s: unregistered cipher %u, 
load module %s\n",
                                                __func__, cipher, 
cipher_modnames[cipher]);
@@ -278,7 +277,7 @@
                                        IEEE80211_DPRINTF(vap, 
IEEE80211_MSG_CRYPTO,
                                                        "%s: unable to load 
cipher %u, module %s\n",
                                                        __func__, cipher,
-                                                       cipher < 
N(cipher_modnames) ?
+                                                       cipher < 
ARRAY_SIZE(cipher_modnames) ?
                                                        cipher_modnames[cipher] 
: "<unknown>");
                                        vap->iv_stats.is_crypto_nocipher++;
                                } else
@@ -288,7 +287,6 @@
                        status = 1;
        }
        return status;
-#undef N
 }
 EXPORT_SYMBOL(ieee80211_crypto_available);
 

Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_monitor.c
===================================================================
--- madwifi/branches/madwifi-dfs/net80211/ieee80211_monitor.c   2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/net80211/ieee80211_monitor.c   2007-12-02 
21:00:41 UTC (rev 3001)
@@ -246,6 +246,11 @@
                                        p = start + roundup(p - start, 8) + 8;
                                        break;
 
+                               case IEEE80211_RADIOTAP_DATA_RETRIES:
+                                       ph->try0 = *p;
+                                       p++;
+                                       break;
+
                                default:
                                        present = 0;
                                        break;
@@ -256,7 +261,8 @@
                        /* Remove FCS from the end of frames to transmit */
                        skb_trim(skb, skb->len - IEEE80211_CRC_LEN);
                wh = (struct ieee80211_frame *)skb->data;
-               if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == 
IEEE80211_FC0_TYPE_CTL)
+               if (!ph->try0 &&
+                   (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == 
IEEE80211_FC0_TYPE_CTL)
                        ph->try0 = 1;
                break;
        }

Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_proto.c
===================================================================
--- madwifi/branches/madwifi-dfs/net80211/ieee80211_proto.c     2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/net80211/ieee80211_proto.c     2007-12-02 
21:00:41 UTC (rev 3001)
@@ -554,13 +554,12 @@
 int
 ieee80211_iserp_rateset(struct ieee80211com *ic, struct ieee80211_rateset *rs)
 {
-#define N(a)   (sizeof(a) / sizeof(a[0]))
        static const int rates[] = { 2, 4, 11, 22, 12, 24, 48 };
        int i, j;
 
-       if (rs->rs_nrates < N(rates))
+       if (rs->rs_nrates < ARRAY_SIZE(rates))
                return 0;
-       for (i = 0; i < N(rates); i++) {
+       for (i = 0; i < ARRAY_SIZE(rates); i++) {
                for (j = 0; j < rs->rs_nrates; j++) {
                        int r = rs->rs_rates[j] & IEEE80211_RATE_VAL;
                        if (rates[i] == r)
@@ -573,7 +572,6 @@
                ;
        }
        return 1;
-#undef N
 }
 
 static const struct ieee80211_rateset basic11g[IEEE80211_MODE_MAX] = {

Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_proto.h
===================================================================
--- madwifi/branches/madwifi-dfs/net80211/ieee80211_proto.h     2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/net80211/ieee80211_proto.h     2007-12-02 
21:00:41 UTC (rev 3001)
@@ -119,13 +119,16 @@
 {
        const struct ieee80211_frame *wh = data;
 
-       if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) {
+       if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) {
                switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) {
                case IEEE80211_FC0_SUBTYPE_CTS:
                case IEEE80211_FC0_SUBTYPE_ACK:
                        return sizeof(struct ieee80211_frame_ack);
+                       break;
+               default:
+                       return sizeof(struct ieee80211_frame_min);
+                       break;
                }
-               return sizeof(struct ieee80211_frame_min);
        } else
                return ieee80211_hdrsize(data);
 }

Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_scan_ap.c
===================================================================
--- madwifi/branches/madwifi-dfs/net80211/ieee80211_scan_ap.c   2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/net80211/ieee80211_scan_ap.c   2007-12-02 
21:00:41 UTC (rev 3001)
@@ -202,12 +202,11 @@
        struct ieee80211_scan_state *ss,
        enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
 {
-#define        N(a)    (sizeof(a) / sizeof(a[0]))
        struct ieee80211_channel *c, *cg;
        u_int modeflags;
        int i;
 
-       KASSERT(mode < N(chanflags), ("Unexpected mode %u", mode));
+       KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
        modeflags = chanflags[mode];
        for (i = 0; i < nfreq; i++) {
                c = ieee80211_find_channel(ic, freq[i], modeflags);
@@ -226,7 +225,6 @@
                        break;
                ss->ss_chans[ss->ss_last++] = c;
        }
-#undef N
 }
 
 /* This function must be invoked with locks acquired */

Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_scan_sta.c
===================================================================
--- madwifi/branches/madwifi-dfs/net80211/ieee80211_scan_sta.c  2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/net80211/ieee80211_scan_sta.c  2007-12-02 
21:00:41 UTC (rev 3001)
@@ -356,12 +356,11 @@
        struct ieee80211_scan_state *ss,
        enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
 {
-#define        N(a)    (sizeof(a) / sizeof(a[0]))
        struct ieee80211_channel *c, *cg;
        u_int modeflags;
        int i;
 
-       KASSERT(mode < N(chanflags), ("Unexpected mode %u", mode));
+       KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
        modeflags = chanflags[mode];
        for (i = 0; i < nfreq; i++) {
                c = ieee80211_find_channel(ic, freq[i], modeflags);
@@ -380,7 +379,6 @@
                        break;
                ss->ss_chans[ss->ss_last++] = c;
        }
-#undef N
 }
 
 static const u_int16_t rcl1[] =                /* 8 FCC channel: 52, 56, 60, 
64, 36, 40, 44, 48 */
@@ -466,7 +464,6 @@
 static int
 sta_start(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
 {
-#define        N(a)    (sizeof(a)/sizeof(a[0]))
        struct ieee80211com *ic = vap->iv_ic;
        struct sta_table *st = ss->ss_priv;
        const struct scanlist *scan;
@@ -577,7 +574,6 @@
        st->st_newscan = 1;
 
        return 0;
-#undef N
 }
 
 /*
@@ -1178,7 +1174,6 @@
 static int
 adhoc_start(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
 {
-#define        N(a)    (sizeof(a)/sizeof(a[0]))
        struct ieee80211com *ic = vap->iv_ic;
        struct sta_table *st = ss->ss_priv;
        const struct scanlist *scan;
@@ -1244,7 +1239,6 @@
        st->st_newscan = 1;
 
        return 0;
-#undef N
 }
 
 /*

Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_skb.c
===================================================================
--- madwifi/branches/madwifi-dfs/net80211/ieee80211_skb.c       2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/net80211/ieee80211_skb.c       2007-12-02 
21:00:41 UTC (rev 3001)
@@ -407,6 +407,7 @@
                untrack_skb(skb, -1, func1, line1, func2, line2);
        }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
        if ((in_irq() || irqs_disabled()) 
             && (type == UNREF_USE_KFREE_SKB || type == 
UNREF_USE_DEV_KFREE_SKB)) 
        {
@@ -417,6 +418,7 @@
                type = UNREF_USE_DEV_KFREE_SKB_ANY;
                dump_stack();
        }
+#endif
 
        switch (type) {
        case UNREF_USE_DEV_KFREE_SKB_ANY:
@@ -710,7 +712,9 @@
 struct sk_buff * skb_share_check_debug(struct sk_buff *skb, gfp_t pri,
                      const char *func, int line)
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
        might_sleep_if(pri & __GFP_WAIT);
+#endif
        if (skb_shared(skb)) {
                struct sk_buff *nskb = track_skb(
                        clean_clone_or_copy(skb_clone(skb, pri)), 
@@ -733,7 +737,9 @@
 struct sk_buff *  skb_unshare_debug(struct sk_buff *skb, gfp_t pri,
                  const char *func, int line)
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
        might_sleep_if(pri & __GFP_WAIT);
+#endif
        if (skb_cloned(skb)) {
                struct sk_buff *nskb = track_skb(
                        clean_clone_or_copy(skb_copy(skb, pri)), 0,

Modified: madwifi/branches/madwifi-dfs/net80211/ieee80211_wireless.c
===================================================================
--- madwifi/branches/madwifi-dfs/net80211/ieee80211_wireless.c  2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/net80211/ieee80211_wireless.c  2007-12-02 
21:00:41 UTC (rev 3001)
@@ -5610,17 +5610,15 @@
 };
 
 static struct iw_handler_def ieee80211_iw_handler_def = {
-#define        N(a)    (sizeof (a) / sizeof (a[0]))
        .standard               = (iw_handler *) ieee80211_handlers,
-       .num_standard           = N(ieee80211_handlers),
+       .num_standard           = ARRAY_SIZE(ieee80211_handlers),
        .private                = (iw_handler *) ieee80211_priv_handlers,
-       .num_private            = N(ieee80211_priv_handlers),
+       .num_private            = ARRAY_SIZE(ieee80211_priv_handlers),
        .private_args           = (struct iw_priv_args *) ieee80211_priv_args,
-       .num_private_args       = N(ieee80211_priv_args),
+       .num_private_args       = ARRAY_SIZE(ieee80211_priv_args),
 #if IW_HANDLER_VERSION >= 7
        .get_wireless_stats     = ieee80211_iw_getstats,
 #endif
-#undef N
 };
 
 /*

Copied: madwifi/branches/madwifi-dfs/regression/Makefile (from rev 3000, 
madwifi/trunk/regression/Makefile)
===================================================================
--- madwifi/branches/madwifi-dfs/regression/Makefile                            
(rev 0)
+++ madwifi/branches/madwifi-dfs/regression/Makefile    2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -0,0 +1,28 @@
+ifeq ($(obj),)
+obj=   .
+endif
+
+TOP = $(obj)/..
+
+obj-y := ccmp/ tkip/ wep/
+
+include $(TOP)/Makefile.inc
+
+modules:
+ifdef LINUX24
+       for i in $(obj-y); do \
+               $(MAKE) -C $$i || exit 1; \
+       done
+else
+       $(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
+endif
+
+install:
+       for i in $(obj-y); do \
+               $(MAKE) -C $$i install || exit 1; \
+       done
+
+clean:
+       for i in $(obj-y); do \
+               $(MAKE) -C $$i clean; \
+       done


Property changes on: madwifi/branches/madwifi-dfs/regression/ccmp
___________________________________________________________________
Name: svn:ignore
   + .*.cmd
.*.flags
*.o
*.ko
*.mod.c


Copied: madwifi/branches/madwifi-dfs/regression/ccmp/Makefile (from rev 3000, 
madwifi/trunk/regression/ccmp/Makefile)
===================================================================
--- madwifi/branches/madwifi-dfs/regression/ccmp/Makefile                       
        (rev 0)
+++ madwifi/branches/madwifi-dfs/regression/ccmp/Makefile       2007-12-02 
21:00:41 UTC (rev 3001)
@@ -0,0 +1,34 @@
+#
+# Makefile for the CCMP regression test.
+#
+ifeq ($(obj),)
+obj=   .
+endif
+
+TOP = $(obj)/../..
+
+obj-m                  += ath_test_ccmp.o
+ath_test_ccmp-objs     := test_ccmp.o
+
+include $(TOP)/Makefile.inc
+
+INCS += -I$(TOP) -I$(WLAN)
+
+EXTRA_CFLAGS+= $(INCS) $(COPTS)
+
+-include $(TOPDIR)/Rules.make
+
+all:
+       $(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
+
+install:
+       test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
+       install -m 0644 ath_test_ccmp.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
+
+clean:
+       -rm -f *~ *.o *.ko *.mod.c
+       -rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
+       -rm -rf .tmp_versions
+
+ath_test_ccmp.o: $(ath_test_ccmp-objs)
+       $(LD) $(LDOPTS) -o ath_test_ccmp.$(KMODSUF) -r $(ath_test_ccmp-objs)

Modified: madwifi/branches/madwifi-dfs/regression/ccmp/test_ccmp.c
===================================================================
--- madwifi/branches/madwifi-dfs/regression/ccmp/test_ccmp.c    2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/regression/ccmp/test_ccmp.c    2007-12-02 
21:00:41 UTC (rev 3001)
@@ -528,7 +528,7 @@
        test##n##_encrypted, sizeof(test##n##_encrypted) \
 }
 
-struct ciphertest {
+static struct ciphertest {
        const char      *name;
        int             cipher;
        int             keyix;
@@ -555,7 +555,7 @@
 {
        int i;
 
-       printk("%s: 0x%p len %u", tag, p, len);
+       printk("%s: 0x%p len %zu", tag, p, len);
        for (i = 0; i < len; i++) {
                if ((i % 16) == 0)
                        printk("\n%03d:", i);
@@ -578,32 +578,39 @@
        dumpdata("Reference", ref, reflen);
 }
 
-int
-runtest(struct ieee80211com *ic, struct ciphertest *t)
+static int
+runtest(struct ieee80211vap *vap, struct ciphertest *t)
 {
-       struct ieee80211_key key;
+       struct ieee80211_key *key;
        struct sk_buff *skb = NULL;
        const struct ieee80211_cipher *cip;
        u_int8_t mac[IEEE80211_ADDR_LEN];
+       int hdrlen;
 
        printk("%s: ", t->name);
 
+       if (!ieee80211_crypto_available(vap, t->cipher)) {
+               printk("FAIL: ieee80211_crypto_available failed\n");
+               return 0;
+       }
+
        /*
         * Setup key.
         */
-       memset(&key, 0, sizeof(key));
-       key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
-       key.wk_cipher = &ieee80211_cipher_none;
-       if (!ieee80211_crypto_newkey(ic, t->cipher, &key)) {
+       key = &vap->iv_nw_keys[t->keyix];
+       key->wk_keyix = t->keyix;
+       if (!ieee80211_crypto_newkey(vap, t->cipher,
+                                    IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV,
+                                    key)) {
                printk("FAIL: ieee80211_crypto_newkey failed\n");
                goto bad;
        }
 
-       memcpy(key.wk_key, t->key, t->key_len);
-       key.wk_keylen = t->key_len;
-       key.wk_keyrsc = 0;
-       key.wk_keytsc = t->pn - 1;      /* PN-1 since we do encap */
-       if (!ieee80211_crypto_setkey(ic, &key, mac)) {
+       memcpy(key->wk_key, t->key, t->key_len);
+       key->wk_keylen = t->key_len;
+       memset(key->wk_keyrsc, 0, sizeof(key->wk_keyrsc));
+       key->wk_keytsc = t->pn - 1;     /* PN-1 since we do encap */
+       if (!ieee80211_crypto_setkey(vap, key, mac, NULL)) {
                printk("FAIL: ieee80211_crypto_setkey failed\n");
                goto bad;
        }
@@ -611,7 +618,7 @@
        /*
         * Craft frame from plaintext data.
         */
-       cip = key.wk_cipher;
+       cip = key->wk_cipher;
        skb = ieee80211_dev_alloc_skb(t->plaintext_len +
                cip->ic_header + cip->ic_trailer);
        if (skb == NULL) {
@@ -624,7 +631,7 @@
        /*
         * Encrypt frame w/ MIC.
         */
-       if (!(*cip->ic_encap)(&key, skb, t->keyix << 6)) {
+       if (!(*cip->ic_encap)(key, skb, t->keyix << 6)) {
                printk("FAIL: ccmp encap failed\n");
                goto bad;
        }
@@ -647,7 +654,8 @@
        /*
         * Decrypt frame; strip MIC.
         */
-       if (!(*cip->ic_decap)(&key, skb)) {
+       hdrlen = ieee80211_hdrspace(vap->iv_ic, skb->data);
+       if (!(*cip->ic_decap)(key, skb, hdrlen)) {
                printk("FAIL: ccmp decap failed\n");
                cmpfail(skb->data, skb->len,
                        t->plaintext, t->plaintext_len);
@@ -668,13 +676,13 @@
                goto bad;
        }
        ieee80211_dev_kfree_skb(&skb);
-       ieee80211_crypto_delkey(ic, &key);
+       ieee80211_crypto_delkey(vap, key, NULL);
        printk("PASS\n");
        return 1;
 bad:
        if (skb != NULL)
                ieee80211_dev_kfree_skb(&skb);
-       ieee80211_crypto_delkey(ic, &key);
+       ieee80211_crypto_delkey(vap, key, NULL);
        return 0;
 }
 
@@ -688,36 +696,46 @@
 #endif
 
 static int tests = -1;
+static int debug = 0;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,52))
 MODULE_PARM(tests, "i");
+MODULE_PARM(debug, "i");
+#else
+#include <linux/moduleparam.h>
+module_param(tests, int, 0600);
+module_param(debug, int, 0600);
+#endif
+
 MODULE_PARM_DESC(tests, "Specify which tests to run");
-
-static int debug = 0;
-MODULE_PARM(debug, "i");
 MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
 
 static int __init
 init_crypto_ccmp_test(void)
 {
-#define        N(a)    (sizeof(a)/sizeof(a[0]))
        struct ieee80211com ic;
+       struct ieee80211vap vap;
        int i, pass, total;
 
        memset(&ic, 0, sizeof(ic));
+       memset(&vap, 0, sizeof(vap));
+       vap.iv_ic = &ic;
        if (debug)
-               ic.msg_enable = IEEE80211_MSG_CRYPTO;
+               vap.iv_debug = IEEE80211_MSG_CRYPTO;
        ieee80211_crypto_attach(&ic);
+       ieee80211_crypto_vattach(&vap);
 
        pass = 0;
        total = 0;
-       for (i = 0; i < N(ccmptests); i++)
+       for (i = 0; i < ARRAY_SIZE(ccmptests); i++)
                if (tests & (1 << i)) {
                        total++;
-                       pass += runtest(&ic, &ccmptests[i]);
+                       pass += runtest(&vap, &ccmptests[i]);
                }
        printk("%u of %u 802.11i AES-CCMP test vectors passed\n", pass, total);
+       ieee80211_crypto_vdetach(&vap);
        ieee80211_crypto_detach(&ic);
-       return (pass == total ? 0 : -1);
-#undef N
+       return (pass == total ? 0 : -ENXIO);
 }
 module_init(init_crypto_ccmp_test);
 


Property changes on: madwifi/branches/madwifi-dfs/regression/tkip
___________________________________________________________________
Name: svn:ignore
   + .*.cmd
.*.flags
*.o
*.ko
*.mod.c


Copied: madwifi/branches/madwifi-dfs/regression/tkip/Makefile (from rev 3000, 
madwifi/trunk/regression/tkip/Makefile)
===================================================================
--- madwifi/branches/madwifi-dfs/regression/tkip/Makefile                       
        (rev 0)
+++ madwifi/branches/madwifi-dfs/regression/tkip/Makefile       2007-12-02 
21:00:41 UTC (rev 3001)
@@ -0,0 +1,34 @@
+#
+# Makefile for the TKIP regression test.
+#
+ifeq ($(obj),)
+obj=   .
+endif
+
+TOP = $(obj)/../..
+
+obj-m                  += ath_test_tkip.o
+ath_test_tkip-objs     := test_tkip.o
+
+include $(TOP)/Makefile.inc
+
+INCS += -I$(TOP) -I$(WLAN)
+
+EXTRA_CFLAGS+= $(INCS) $(COPTS)
+
+-include $(TOPDIR)/Rules.make
+
+all:
+       $(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
+
+install:
+       test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
+       install -m 0644 ath_test_tkip.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
+
+clean:
+       -rm -f *~ *.o *.ko *.mod.c
+       -rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
+       -rm -rf .tmp_versions
+
+ath_test_tkip.o: $(ath_test_tkip-objs)
+       $(LD) $(LDOPTS) -o ath_test_tkip.$(KMODSUF) -r $(ath_test_tkip-objs)

Modified: madwifi/branches/madwifi-dfs/regression/tkip/test_tkip.c
===================================================================
--- madwifi/branches/madwifi-dfs/regression/tkip/test_tkip.c    2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/regression/tkip/test_tkip.c    2007-12-02 
21:00:41 UTC (rev 3001)
@@ -55,7 +55,7 @@
 Phase2 00 20 01 4c fe 67 be d2 7c 86 7b 1b f8 02 8b 1c 
 */
 
-static const u_int8_t ref_key[] = {
+static const u_int8_t test1_key[] = {
        0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12,
        0x34, 0x56, 0x78, 0x90, 0x12,
 
@@ -74,16 +74,16 @@
        0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78,         /* TX copy */
 #endif
 };
-static const u_int8_t ref_phase1[] = {
+static const u_int8_t test1_phase1[] = {
        0xbb, 0x58, 0x07, 0x1f, 0x9e, 0x93, 0xb4, 0x38, 0x25, 0x4b
 };
-static const u_int8_t ref_phase2[] = {
+static const u_int8_t test1_phase2[] = {
        0x00, 0x20, 0x01, 0x4c, 0xfe, 0x67, 0xbe, 0xd2, 0x7c, 0x86,
        0x7b, 0x1b, 0xf8, 0x02, 0x8b, 0x1c,
 };
 
 /* Plaintext MPDU with MIC */
-static const u_int8_t ref_plaintext[] = {
+static const u_int8_t test1_plaintext[] = {
 
0x08,0x42,0x2c,0x00,0x02,0x03,0x04,0x05,0x06,0x08,0x02,0x03,0x04,0x05,0x06,0x07,
 0x02,0x03,0x04,0x05,0x06,0x07,0xd0,0x02,
 
0xaa,0xaa,0x03,0x00,0x00,0x00,0x08,0x00,0x45,0x00,0x00,0x54,0x00,0x00,0x40,0x00,
@@ -96,7 +96,7 @@
 };
 
 /* Encrypted MPDU with MIC and ICV */
-static const u_int8_t ref_encrypted[] = {
+static const u_int8_t test1_encrypted[] = {
 
0x08,0x42,0x2c,0x00,0x02,0x03,0x04,0x05,0x06,0x08,0x02,0x03,0x04,0x05,0x06,0x07,
 
0x02,0x03,0x04,0x05,0x06,0x07,0xd0,0x02,0x00,0x20,0x01,0x20,0x00,0x00,0x00,0x00,
 
0xc0,0x0e,0x14,0xfc,0xe7,0xcf,0xab,0xc7,0x75,0x47,0xe6,0x66,0xe5,0x7c,0x0d,0xac,
@@ -108,17 +108,31 @@
 0xee,0x5b,0xfc,0x14,0xf6,0xf8,0xe5,0xf8
 };
 
-struct tkip_ctx {
-       struct ieee80211com *tc_ic;     /* for diagnostics */
+#define        TEST(n,name,cipher,keyix) { \
+       name, IEEE80211_CIPHER_##cipher, keyix, \
+       test##n##_key,   sizeof(test##n##_key), \
+       test##n##_plaintext, sizeof(test##n##_plaintext), \
+       test##n##_encrypted, sizeof(test##n##_encrypted), \
+       test##n##_phase1, sizeof(test##n##_phase1), \
+       test##n##_phase2, sizeof(test##n##_phase2) \
+}
 
-       u16     tx_ttak[5];
-       int     tx_phase1_done;
-       u8      tx_rc4key[16];
-
-       u16     rx_ttak[5];
-       int     rx_phase1_done;
-       u8      rx_rc4key[16];
-       u_int64_t rx_rsc;               /* held until MIC verified */
+static struct ciphertest {
+       const char      *name;
+       int             cipher;
+       int             keyix;
+       const u_int8_t  *key;
+       size_t          key_len;
+       const u_int8_t  *plaintext;
+       size_t          plaintext_len;
+       const u_int8_t  *encrypted;
+       size_t          encrypted_len;
+       const u_int8_t  *phase1;
+       size_t          phase1_len;
+       const u_int8_t  *phase2;
+       size_t          phase2_len;
+} tkiptests[] = {
+       TEST(1, "TKIP test mpdu 1", TKIP, 0),
 };
 
 static void
@@ -126,7 +140,7 @@
 {
        int i;
 
-       printk("%s: 0x%p len %u", tag, p, len);
+       printk("%s: 0x%p len %zu", tag, p, len);
        for (i = 0; i < len; i++) {
                if ((i % 16) == 0)
                        printk("\n%03d:", i);
@@ -149,32 +163,55 @@
        dumpdata("Reference", ref, reflen);
 }
 
-void
-tkip_test(struct ieee80211com *ic)
+struct tkip_ctx {
+       struct ieee80211vap *tc_vap;    /* for diagnostics + statistics */
+       struct ieee80211com *tc_ic;
+
+       u16     tx_ttak[5];
+       int     tx_phase1_done;
+       u8      tx_rc4key[16];          /* XXX for test module; make locals? */
+
+       u16     rx_ttak[5];
+       int     rx_phase1_done;
+       u8      rx_rc4key[16];          /* XXX for test module; make locals? */
+       uint64_t rx_rsc;                /* held until MIC verified */
+};
+
+static int
+runtest(struct ieee80211vap *vap, struct ciphertest *t)
 {
-       struct tkip_ctx *ctx;
-       struct ieee80211_key key;
+       struct ieee80211_key *key;
        struct sk_buff *skb = NULL;
        const struct ieee80211_cipher *cip;
        u_int8_t mac[IEEE80211_ADDR_LEN];
+       struct tkip_ctx *ctx;
+       int hdrlen;
 
+       printk("%s: ", t->name);
+
+       if (!ieee80211_crypto_available(vap, t->cipher)) {
+               printk("FAIL: ieee80211_crypto_available failed\n");
+               return 0;
+       }
+
        /*
         * Setup key.
         */
-       memset(&key, 0, sizeof(key));
-       key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
-       key.wk_cipher = &ieee80211_cipher_none;
-       if (!ieee80211_crypto_newkey(ic, IEEE80211_CIPHER_TKIP, &key)) {
-               printk("ieee80211_crypto_newkey failed\n");
+       key = &vap->iv_nw_keys[t->keyix];
+       key->wk_keyix = t->keyix;
+       if (!ieee80211_crypto_newkey(vap, t->cipher,
+                                    IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV,
+                                    key)) {
+               printk("FAIL: ieee80211_crypto_newkey failed\n");
                goto bad;
        }
 
-       memcpy(key.wk_key, ref_key, sizeof(ref_key));
-       key.wk_keylen = 128 / NBBY;
-       key.wk_keyrsc = 0;
-       key.wk_keytsc = 0;
-       if (!ieee80211_crypto_setkey(ic, &key, mac)) {
-               printk("ieee80211_crypto_setkey failed\n");
+       memcpy(key->wk_key, t->key, t->key_len);
+       key->wk_keylen = 128 / NBBY;
+       memset(key->wk_keyrsc, 0, sizeof(key->wk_keyrsc));
+       key->wk_keytsc = 0;
+       if (!ieee80211_crypto_setkey(vap, key, mac, NULL)) {
+               printk("FAIL: ieee80211_crypto_setkey failed\n");
                goto bad;
        }
 
@@ -183,124 +220,129 @@
         * we leave the MIC off as we'll add it ourself
         * and then check it against the reference data.
         */
-       cip = key.wk_cipher;
-       skb = ieee80211_dev_alloc_skb(sizeof(ref_plaintext) +
+       cip = key->wk_cipher;
+       skb = ieee80211_dev_alloc_skb(t->plaintext_len +
                cip->ic_miclen + cip->ic_header + cip->ic_trailer);
        if (skb == NULL) {
-               printk("unable to allocate skbuff\n");
+               printk("FAIL: unable to allocate skbuff\n");
                goto bad;
        }
        skb_reserve(skb, cip->ic_header);
-       memcpy(skb_put(skb, sizeof(ref_plaintext) - cip->ic_miclen),
-               ref_plaintext, sizeof(ref_plaintext) - cip->ic_miclen);
+       memcpy(skb_put(skb, t->plaintext_len - cip->ic_miclen),
+               t->plaintext, t->plaintext_len - cip->ic_miclen);
 
        /*
         * Add MIC.
         */
-       if (!ieee80211_crypto_enmic(ic, &key, skb)) {
-               printk("tkip enmic failed\n");
+       if (!ieee80211_crypto_enmic(vap, key, skb, 0)) {
+               printk("FAIL: tkip enmic failed\n");
                goto bad;
        }
        /*
         * Verify: frame length, frame contents.
         */
-       if (skb->len != sizeof(ref_plaintext)) {
-               printk("enmic botch; length mismatch\n");
+       if (skb->len != t->plaintext_len) {
+               printk("FAIL: enmic botch; length mismatch\n");
                cmpfail(skb->data, skb->len,
-                       ref_plaintext, sizeof(ref_plaintext));
+                       t->plaintext, t->plaintext_len);
                goto bad;
        }
-       if (memcmp(skb->data, ref_plaintext, sizeof(ref_plaintext))) {
-               printk("enmic botch\n");
+       if (memcmp(skb->data, t->plaintext, t->plaintext_len)) {
+               printk("FAIL: enmic botch\n");
                cmpfail(skb->data, skb->len,
-                       ref_plaintext, sizeof(ref_plaintext));
+                       t->plaintext, t->plaintext_len);
                goto bad;
        }
        /*
         * Encrypt frame w/ MIC.
         */
-       if (!(*cip->ic_encap)(&key, skb, 0 << 6)) {
-               printk("tkip encap failed\n");
+       if (!(*cip->ic_encap)(key, skb, t->keyix << 6)) {
+               printk("FAIL: tkip encap failed\n");
                goto bad;
        }
        /*
         * Verify: phase1, phase2, frame length, frame contents.
         */
-       ctx = key.wk_private;
-       if (memcmp(ctx->tx_ttak, ref_phase1, sizeof(ref_phase1))) {
-               printk("encrypt phase1 botch\n");
+       ctx = key->wk_private;
+       if (memcmp(ctx->tx_ttak, t->phase1, t->phase1_len)) {
+               printk("FAIL: encrypt phase1 botch\n");
                cmpfail(ctx->tx_ttak, sizeof(ctx->tx_ttak),
-                       ref_phase1, sizeof(ref_phase1));
+                       t->phase1, t->phase1_len);
                goto bad;
-       } else if (memcmp(ctx->tx_rc4key, ref_phase2, sizeof(ref_phase2))) {
-               printf("encrypt phase2 botch\n");
+       } else if (memcmp(ctx->tx_rc4key, t->phase2, t->phase2_len)) {
+               printf("FAIL: encrypt phase2 botch\n");
                cmpfail(ctx->tx_rc4key, sizeof(ctx->tx_rc4key),
-                       ref_phase2, sizeof(ref_phase2));
+                       t->phase2, t->phase2_len);
                goto bad;
-       } else if (skb->len != sizeof(ref_encrypted)) {
-               printk("encrypt data length mismatch\n");
+       } else if (skb->len != t->encrypted_len) {
+               printk("FAIL: encrypt data length mismatch\n");
                cmpfail(skb->data, skb->len,
-                       ref_encrypted, sizeof(ref_encrypted));
+                       t->encrypted, t->encrypted_len);
                goto bad;
-       } else if (memcmp(skb->data, ref_encrypted, skb->len)) {
-               printk("encrypt data does not compare\n");
+       } else if (memcmp(skb->data, t->encrypted, skb->len)) {
+               printk("FAIL: encrypt data does not compare\n");
                cmpfail(skb->data, skb->len,
-                       ref_encrypted, sizeof(ref_encrypted));
-               dumpdata("Plaintext", ref_plaintext, sizeof(ref_plaintext));
+                       t->encrypted, t->encrypted_len);
+               dumpdata("Plaintext", t->plaintext, t->plaintext_len);
                goto bad;
        }
 
        /*
         * Decrypt frame.
         */
-       if (!(*cip->ic_decap)(&key, skb)) {
-               printk("tkip decap failed\n");
+       hdrlen = ieee80211_hdrspace(vap->iv_ic, skb->data);
+       if (!(*cip->ic_decap)(key, skb, hdrlen)) {
+               printk("FAIL: tkip decap failed\n");
                /*
                 * Check reason for failure: phase1, phase2, frame data (ICV).
                 */
-               if (memcmp(ctx->rx_ttak, ref_phase1, sizeof(ref_phase1))) {
+               if (memcmp(ctx->rx_ttak, t->phase1, t->phase1_len)) {
                        printk("decrypt phase1 botch\n");
                        cmpfail(ctx->rx_ttak, sizeof(ctx->rx_ttak),
-                               ref_phase1, sizeof(ref_phase1));
-               } else if (memcmp(ctx->rx_rc4key, ref_phase2, 
sizeof(ref_phase2))) {
+                               t->phase1, t->phase1_len);
+               } else if (memcmp(ctx->rx_rc4key, t->phase2, t->phase2_len)) {
                        printf("decrypt phase2 botch\n");
                        cmpfail(ctx->rx_rc4key, sizeof(ctx->rx_rc4key),
-                               ref_phase2, sizeof(ref_phase2));
+                               t->phase2, t->phase2_len);
                } else {
                        printk("decrypt data does not compare\n");
                        cmpfail(skb->data, skb->len,
-                               ref_plaintext, sizeof(ref_plaintext));
+                               t->plaintext, t->plaintext_len);
                }
                goto bad;
        }
        /*
         * Verify: frame length, frame contents.
         */
-       if (skb->len != sizeof(ref_plaintext)) {
-               printk("decap botch; length mismatch\n");
+       if (skb->len != t->plaintext_len) {
+               printk("FAIL: decap botch; length mismatch\n");
                cmpfail(skb->data, skb->len,
-                       ref_plaintext, sizeof(ref_plaintext));
+                       t->plaintext, t->plaintext_len);
                goto bad;
        }
-       if (memcmp(skb->data, ref_plaintext, sizeof(ref_plaintext))) {
-               printk("decap botch; data does not compare\n");
+       if (memcmp(skb->data, t->plaintext, t->plaintext_len)) {
+               printk("FAIL: decap botch; data does not compare\n");
                cmpfail(skb->data, skb->len,
-                       ref_plaintext, sizeof(ref_plaintext));
+                       t->plaintext, t->plaintext_len);
                goto bad;
        }
        /*
         * De-MIC decrypted frame.
         */
-       if (!ieee80211_crypto_demic(ic, &key, skb)) {
-               printk("tkip demic failed\n");
+       if (!ieee80211_crypto_demic(vap, key, skb, hdrlen)) {
+               printk("FAIL: tkip demic failed\n");
                goto bad;
        }
        /* XXX check frame length and contents... */
-       printk("802.11i TKIP test vectors passed\n");
+       ieee80211_dev_kfree_skb(&skb);
+       ieee80211_crypto_delkey(vap, key, NULL);
+       printk("PASS\n");
+       return 1;
 bad:
        if (skb != NULL)
                ieee80211_dev_kfree_skb(&skb);
-       ieee80211_crypto_delkey(ic, &key);
+       ieee80211_crypto_delkey(vap, key, NULL);
+       return 0;
 }
 
 /*
@@ -312,24 +354,47 @@
 MODULE_LICENSE("Dual BSD/GPL");
 #endif
 
+static int tests = -1;
 static int debug = 0;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,52))
+MODULE_PARM(tests, "i");
 MODULE_PARM(debug, "i");
+#else
+#include <linux/moduleparam.h>
+module_param(tests, int, 0600);
+module_param(debug, int, 0600);
+#endif
+
+MODULE_PARM_DESC(tests, "Specify which tests to run");
 MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
 
 static int __init
 init_crypto_tkip_test(void)
 {
        struct ieee80211com ic;
+       struct ieee80211vap vap;
+       int i, pass, total;
 
        memset(&ic, 0, sizeof(ic));
+       memset(&vap, 0, sizeof(vap));
+       vap.iv_ic = &ic;
        if (debug)
-               ic.msg_enable = IEEE80211_MSG_CRYPTO;
+               vap.iv_debug = IEEE80211_MSG_CRYPTO;
        ieee80211_crypto_attach(&ic);
+       ieee80211_crypto_vattach(&vap);
 
-       tkip_test(&ic);
-
+       pass = 0;
+       total = 0;
+       for (i = 0; i < ARRAY_SIZE(tkiptests); i++)
+               if (tests & (1 << i)) {
+                       total++;
+                       pass += runtest(&vap, &tkiptests[i]);
+               }
+       printk("%u of %u 802.11i TKIP test vectors passed\n", pass, total);
+       ieee80211_crypto_vdetach(&vap);
        ieee80211_crypto_detach(&ic);
-       return 0;
+       return (pass == total ? 0 : -ENXIO);
 }
 module_init(init_crypto_tkip_test);
 


Property changes on: madwifi/branches/madwifi-dfs/regression/wep
___________________________________________________________________
Name: svn:ignore
   + .*.cmd
.*.flags
*.o
*.ko
*.mod.c


Copied: madwifi/branches/madwifi-dfs/regression/wep/Makefile (from rev 3000, 
madwifi/trunk/regression/wep/Makefile)
===================================================================
--- madwifi/branches/madwifi-dfs/regression/wep/Makefile                        
        (rev 0)
+++ madwifi/branches/madwifi-dfs/regression/wep/Makefile        2007-12-02 
21:00:41 UTC (rev 3001)
@@ -0,0 +1,34 @@
+#
+# Makefile for the WEP regression test.
+#
+ifeq ($(obj),)
+obj=   .
+endif
+
+TOP = $(obj)/../..
+
+obj-m                  += ath_test_wep.o
+ath_test_wep-objs      := test_wep.o
+
+include $(TOP)/Makefile.inc
+
+INCS += -I$(TOP) -I$(WLAN)
+
+EXTRA_CFLAGS+= $(INCS) $(COPTS)
+
+-include $(TOPDIR)/Rules.make
+
+all:
+       $(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
+
+install:
+       test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
+       install -m 0644 ath_test_wep.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
+
+clean:
+       -rm -f *~ *.o *.ko *.mod.c
+       -rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
+       -rm -rf .tmp_versions
+
+ath_test_wep.o: $(ath_test_wep-objs)
+       $(LD) $(LDOPTS) -o ath_test_wep.$(KMODSUF) -r $(ath_test_wep-objs)

Modified: madwifi/branches/madwifi-dfs/regression/wep/test_wep.c
===================================================================
--- madwifi/branches/madwifi-dfs/regression/wep/test_wep.c      2007-12-02 
01:46:28 UTC (rev 3000)
+++ madwifi/branches/madwifi-dfs/regression/wep/test_wep.c      2007-12-02 
21:00:41 UTC (rev 3001)
@@ -133,7 +133,7 @@
        test##n##_encrypted, sizeof(test##n##_encrypted) \
 }
 
-struct ciphertest {
+static struct ciphertest {
        const char      *name;
        int             cipher;
        int             keyix;
@@ -153,7 +153,7 @@
 {
        int i;
 
-       printk("%s: 0x%p len %u", tag, p, len);
+       printk("%s: 0x%p len %zu", tag, p, len);
        for (i = 0; i < len; i++) {
                if ((i % 16) == 0)
                        printk("\n%03d:", i);
@@ -177,39 +177,47 @@
 }
 
 struct wep_ctx_hw {                    /* for use with h/w support */
+       struct ieee80211vap *wc_vap;    /* for diagnostics + statistics */
        struct ieee80211com *wc_ic;     /* for diagnostics */
        u_int32_t       wc_iv;          /* initial vector for crypto */
 };
 
-int
-runtest(struct ieee80211com *ic, struct ciphertest *t)
+static int
+runtest(struct ieee80211vap *vap, struct ciphertest *t)
 {
-       struct ieee80211_key key;
+       struct ieee80211_key *key;
        struct sk_buff *skb = NULL;
        const struct ieee80211_cipher *cip;
        u_int8_t mac[IEEE80211_ADDR_LEN];
        struct wep_ctx_hw *ctx;
+       int hdrlen;
 
        printk("%s: ", t->name);
 
+       if (!ieee80211_crypto_available(vap, t->cipher)) {
+               printk("FAIL: ieee80211_crypto_available failed\n");
+               return 0;
+       }
+
        /*
         * Setup key.
         */
-       memset(&key, 0, sizeof(key));
-       key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
-       key.wk_cipher = &ieee80211_cipher_none;
-       if (!ieee80211_crypto_newkey(ic, t->cipher, &key)) {
+       key = &vap->iv_nw_keys[t->keyix];
+       key->wk_keyix = t->keyix;
+       if (!ieee80211_crypto_newkey(vap, t->cipher,
+                                    IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV,
+                                    key)) {
                printk("FAIL: ieee80211_crypto_newkey failed\n");
                goto bad;
        }
 
-       memcpy(key.wk_key, t->key, t->key_len);
-       key.wk_keylen = t->key_len;
-       if (!ieee80211_crypto_setkey(ic, &key, mac)) {
+       memcpy(key->wk_key, t->key, t->key_len);
+       key->wk_keylen = t->key_len;
+       if (!ieee80211_crypto_setkey(vap, key, mac, NULL)) {
                printk("FAIL: ieee80211_crypto_setkey failed\n");
                goto bad;
        }
-       cip = key.wk_cipher;
+       cip = key->wk_cipher;
 
        /*
         * Craft encrypted frame from known data.
@@ -224,7 +232,8 @@
        /*
         * Decrypt frame.
         */
-       if (!(*cip->ic_decap)(&key, skb)) {
+       hdrlen = ieee80211_hdrspace(vap->iv_ic, skb->data);
+       if (!(*cip->ic_decap)(key, skb, hdrlen)) {
                printk("FAIL: wep decap failed\n");
                cmpfail(skb->data, skb->len,
                        t->plaintext, t->plaintext_len);
@@ -248,9 +257,9 @@
        /*
         * Encrypt frame.
         */
-       ctx = (struct wep_ctx_hw *) key.wk_private;
+       ctx = (struct wep_ctx_hw *) key->wk_private;
        memcpy(&ctx->wc_iv, t->iv, sizeof(t->iv));      /* for encap/encrypt */
-       if (!(*cip->ic_encap)(&key, skb, t->keyix << 6)) {
+       if (!(*cip->ic_encap)(key, skb, t->keyix << 6)) {
                printk("FAIL: wep encap failed\n");
                goto bad;
        }
@@ -271,13 +280,13 @@
        }
        if (skb != NULL)
                ieee80211_dev_kfree_skb(&skb);
-       ieee80211_crypto_delkey(ic, &key);
+       ieee80211_crypto_delkey(vap, key, NULL);
        printk("PASS\n");
        return 1;
 bad:
        if (skb != NULL)
                ieee80211_dev_kfree_skb(&skb);
-       ieee80211_crypto_delkey(ic, &key);
+       ieee80211_crypto_delkey(vap, key, NULL);
        return 0;
 }
 
@@ -291,35 +300,45 @@
 #endif
 
 static int tests = -1;
+static int debug = 0;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,52))
 MODULE_PARM(tests, "i");
+MODULE_PARM(debug, "i");
+#else
+#include <linux/moduleparam.h>
+module_param(tests, int, 0600);
+module_param(debug, int, 0600);
+#endif
+
 MODULE_PARM_DESC(tests, "Specify which tests to run");
-
-static int debug = 0;
-MODULE_PARM(debug, "i");
 MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
 
 static int __init
 init_crypto_wep_test(void)
 {
-#define        N(a)    (sizeof(a)/sizeof(a[0]))
        struct ieee80211com ic;
+       struct ieee80211vap vap;
        int i, pass, total;
 
        memset(&ic, 0, sizeof(ic));
+       memset(&vap, 0, sizeof(vap));
+       vap.iv_ic = &ic;
        if (debug)
-               ic.msg_enable = IEEE80211_MSG_CRYPTO;
+               vap.iv_debug = IEEE80211_MSG_CRYPTO;
        ieee80211_crypto_attach(&ic);
+       ieee80211_crypto_vattach(&vap);
        pass = 0;
        total = 0;
-       for (i = 0; i < N(weptests); i++)
+       for (i = 0; i < ARRAY_SIZE(weptests); i++)
                if (tests & (1 << i)) {
                        total++;
-                       pass += runtest(&ic, &weptests[i]);
+                       pass += runtest(&vap, &weptests[i]);
                }
        printk("%u of %u 802.11i WEP test vectors passed\n", pass, total);
+       ieee80211_crypto_vdetach(&vap);
        ieee80211_crypto_detach(&ic);
-       return (pass == total ? 0 : -1);
-#undef N
+       return (pass == total ? 0 : -ENXIO);
 }
 module_init(init_crypto_wep_test);
 

Modified: madwifi/branches/madwifi-dfs/tools/80211debug.c
===================================================================
--- madwifi/branches/madwifi-dfs/tools/80211debug.c     2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/tools/80211debug.c     2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -49,7 +49,8 @@
 #include <getopt.h>
 #include <err.h>
 
-#define        N(a)    (sizeof(a)/sizeof(a[0]))
+#undef ARRAY_SIZE
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 static const char *progname;
 
@@ -122,7 +123,7 @@
 {
        int i;
 
-       for (i = 0; i < N(flags); i++)
+       for (i = 0; i < ARRAY_SIZE(flags); i++)
                if (strncasecmp(flags[i].name, name, len) == 0)
                        return flags[i].bit;
        return 0;
@@ -135,7 +136,7 @@
 
        fprintf(stderr, "usage: %s [-i interface] [(+/-) flags]\n", progname);
        fprintf(stderr, "\twhere flags are:\n\n");
-       for (i = 0; i < N(flags); i++)
+       for (i = 0; i < ARRAY_SIZE(flags); i++)
                printf("\t%12s\t0x%08x\t%s\n", flags[i].name, flags[i].bit, 
flags[i].desc);
        exit(-1);
 }
@@ -259,14 +260,14 @@
        } else
                printf("%s: 0x%08x", oid, debug);
        sep = "<";
-       for (i = 0; i < N(flags); i++)
+       for (i = 0; i < ARRAY_SIZE(flags); i++)
                if (debug & flags[i].bit) {
                        printf("%s%s", sep, flags[i].name);
                        sep = ",";
                }
        printf("%s\n", *sep != '<' ? ">" : "");
        printf("Details:\n");
-       for (i = 0; i < N(flags); i++)
+       for (i = 0; i < ARRAY_SIZE(flags); i++)
                printf("%12s %s 0x%08x - %s\n", flags[i].name, debug & 
flags[i].bit ? "+" : " ", flags[i].bit, flags[i].desc);
        return 0;
 }

Modified: madwifi/branches/madwifi-dfs/tools/80211stats.c
===================================================================
--- madwifi/branches/madwifi-dfs/tools/80211stats.c     2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/tools/80211stats.c     2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -74,7 +74,6 @@
 static void
 printstats(FILE *fd, const struct ieee80211_stats *stats)
 {
-#define        N(a)    (sizeof(a) / sizeof(a[0]))
 #define        STAT(x,fmt) \
        if (stats->is_##x) fprintf(fd, "%u " fmt "\n", stats->is_##x)
        STAT(rx_badversion,     "rx frame with bad version");
@@ -158,7 +157,6 @@
        STAT(crypto_swfallback, "crypto fell back to s/w implementation");
        STAT(crypto_keyfail,    "setkey failed due to driver key alloc failed");
 #undef STAT
-#undef N
 }
 
 static struct ifreq ifr;

Modified: madwifi/branches/madwifi-dfs/tools/ath_info.c
===================================================================
--- madwifi/branches/madwifi-dfs/tools/ath_info.c       2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/tools/ath_info.c       2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -99,6 +99,9 @@
 #include <endian.h>
 #include <byteswap.h>
 
+#undef ARRAY_SIZE
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
 #define dbg(fmt, __args__...) \
 do { \
        if (verbose) \
@@ -109,7 +112,6 @@
 fprintf(stderr, "#ERR %s: " fmt "\n", __FUNCTION__, ##__args__)
 
 #define AR5K_PCI_MEM_SIZE 0x10000
-#define AR5K_ELEMENTS(_array)  (sizeof(_array) / sizeof(_array[0]))
 
 #define AR5K_NUM_GPIO  6
 
@@ -534,7 +536,7 @@
        const char *name = "xxxxx";
        int i;
 
-       for (i = 0; i < AR5K_ELEMENTS(ath5k_srev_names); i++) {
+       for (i = 0; i < ARRAY_SIZE(ath5k_srev_names); i++) {
                if (ath5k_srev_names[i].sr_type != type ||
                    ath5k_srev_names[i].sr_val == AR5K_SREV_UNKNOWN)
                        continue;

Modified: madwifi/branches/madwifi-dfs/tools/athdebug.c
===================================================================
--- madwifi/branches/madwifi-dfs/tools/athdebug.c       2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/tools/athdebug.c       2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -52,7 +52,8 @@
 #include <getopt.h>
 #include <err.h>
 
-#define        N(a)    (sizeof(a)/sizeof(a[0]))
+#undef ARRAY_SIZE
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 static const char *progname;
 
@@ -129,7 +130,7 @@
 {
        int i;
 
-       for (i = 0; i < N(flags); i++)
+       for (i = 0; i < ARRAY_SIZE(flags); i++)
                if (strncasecmp(flags[i].name, name, len) == 0)
                        return flags[i].bit;
        return 0;
@@ -142,7 +143,7 @@
 
        fprintf(stderr, "usage: %s [-i device] [(+/-) flags]\n", progname);
        fprintf(stderr, "\twhere flags are:\n\n");
-       for (i = 0; i < N(flags); i++)
+       for (i = 0; i < ARRAY_SIZE(flags); i++)
                printf("\t%12s\t0x%08x\t%s\n", flags[i].name, flags[i].bit, 
flags[i].desc);
        exit(-1);
 }
@@ -271,14 +272,14 @@
        } else
                printf("%s: 0x%08x", oid, debug);
        sep = "<";
-       for (i = 0; i < N(flags); i++)
+       for (i = 0; i < ARRAY_SIZE(flags); i++)
                if (debug & flags[i].bit) {
                        printf("%s%s", sep, flags[i].name);
                        sep = ",";
                }
        printf("%s\n", *sep != '<' ? ">" : "");
        printf("Details:\n");
-       for (i = 0; i < N(flags); i++)
+       for (i = 0; i < ARRAY_SIZE(flags); i++)
                printf("%12s %s 0x%08x - %s\n", flags[i].name, debug & 
flags[i].bit ? "+" : " ", flags[i].bit, flags[i].desc);
        return 0;
 }

Modified: madwifi/branches/madwifi-dfs/tools/athstats.c
===================================================================
--- madwifi/branches/madwifi-dfs/tools/athstats.c       2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/tools/athstats.c       2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -63,6 +63,9 @@
 #include "wireless_copy.h"
 #include "if_athioctl.h"
 
+#undef ARRAY_SIZE
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
 static const struct {
        u_int           phyerr;
        const char*     desc;
@@ -91,7 +94,6 @@
 static void
 printstats(FILE *fd, const struct ath_stats *stats)
 {
-#define        N(a)    (sizeof(a) / sizeof(a[0]))
 #define        STAT(x,fmt) \
        if (stats->ast_##x) fprintf(fd, "%u " fmt "\n", stats->ast_##x)
 #define        STATI(x,fmt) \
@@ -138,10 +140,10 @@
                for (i = 0; i < 32; i++) {
                        if (stats->ast_rx_phy[i] == 0)
                                continue;
-                       for (j = 0; j < N(phyerrdescriptions); j++)
+                       for (j = 0; j < ARRAY_SIZE(phyerrdescriptions); j++)
                                if (phyerrdescriptions[j].phyerr == i)
                                        break;
-                       if (j == N(phyerrdescriptions))
+                       if (j == ARRAY_SIZE(phyerrdescriptions))
                                fprintf(fd,
                                        "    %u (unknown phy error code %u)\n",
                                        stats->ast_rx_phy[i], i);
@@ -172,7 +174,6 @@
                                stats->ast_ant_tx[i], stats->ast_ant_rx[i]);
 #undef STAT
 #undef STATI
-#undef N
 }
 
 static u_int

Modified: madwifi/branches/madwifi-dfs/tools/wlanconfig.c
===================================================================
--- madwifi/branches/madwifi-dfs/tools/wlanconfig.c     2007-12-02 01:46:28 UTC 
(rev 3000)
+++ madwifi/branches/madwifi-dfs/tools/wlanconfig.c     2007-12-02 21:00:41 UTC 
(rev 3001)
@@ -74,6 +74,9 @@
 
 #define        streq(a,b)      (strncasecmp(a, b, sizeof(b) - 1) == 0)
 
+#undef ARRAY_SIZE
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
 static int if_split_name(const char *, char **, unsigned int *);
 static void vap_create(struct ifreq *);
 static void vap_destroy(const char *);
@@ -925,8 +928,6 @@
 static int
 do80211priv(struct iwreq *iwr, const char *ifname, int op, void *data, size_t 
len)
 {
-#define        N(a)    (sizeof(a)/sizeof(a[0]))
-
        memset(iwr, 0, sizeof(struct iwreq));
        strncpy(iwr->ifr_name, ifname, IFNAMSIZ);
        if (len < IFNAMSIZ) {
@@ -970,14 +971,13 @@
                        IOCTL_ERR(IEEE80211_IOCTL_WRITEREG),
                };
                op -= SIOCIWFIRSTPRIV;
-               if (0 <= op && op < N(opnames))
+               if (0 <= op && op < ARRAY_SIZE(opnames))
                        perror(opnames[op]);
                else
                        perror("ioctl[unknown???]");
                return -1;
        }
        return 0;
-#undef N
 }
 
 static int

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4


<Prev in Thread] Current Thread [Next in Thread>