Remove support for Linux kernels older than 2.6.13
[madwifi/.git] / net80211 / ieee80211_scan_ap.c
index a3f4cf8aa79dec9712d879f022a3b7ad2df5fd4b..e7f63a8fb67546eb1354a221a8e6912844426ac4 100644 (file)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * Copyright (c) 2005  Matt Mackall <mpm@selenic.com>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,7 +38,7 @@
 /*
  * IEEE 802.11 ap scanning support.
  */
-#ifndef AUTOCONF_INCLUDED
+#if !defined(AUTOCONF_INCLUDED) && !defined(CONFIG_LOCALVERSION)
 #include <linux/config.h>
 #endif
 #include <linux/version.h>
 #include <linux/netdevice.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
-#include "sort.c"
-#else
 #include <linux/sort.h>
-#endif
 
 #include "if_media.h"
 
@@ -731,9 +727,9 @@ pick_channel(struct ieee80211_scan_state *ss, struct ieee80211vap *vap,
 
        sort(chans, ss_last, sizeof(*chans), pc_cmp, pc_swap);
 
+#ifdef IEEE80211_DEBUG
        for (i = 0; i < ss_last; i++) {
                int chan = ieee80211_chan2ieee(ic, chans[i].chan);
-
                IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, "%s: channel %u, "
                                "rssi %d, radar %d, cn %d, km %d\n",
                                __func__, chan, as->as_maxrssi[chan], 
@@ -742,6 +738,7 @@ pick_channel(struct ieee80211_scan_state *ss, struct ieee80211vap *vap,
                                !!IEEE80211_ARE_CHANS_SAME_MODE(chans[i].chan, 
                                        ic->ic_bsschan));
        }
+#endif /* IEEE80211_DEBUG */
 
        best = NULL;
        best_rssi = 0xff; /* If signal is bigger than 0xff, we'd be melting. */
@@ -756,7 +753,8 @@ pick_channel(struct ieee80211_scan_state *ss, struct ieee80211vap *vap,
                        continue;
 
                /* Verify channel is not marked for non-occupancy */
-               if (IEEE80211_IS_CHAN_RADAR(c->chan))
+               if (IEEE80211_IS_CHAN_RADAR(c->chan) &&
+                   (ic->ic_flags & IEEE80211_F_DOTH))
                        continue;
 
                /* Do not select 802.11a ST if mode is specified and is not 
@@ -767,7 +765,7 @@ pick_channel(struct ieee80211_scan_state *ss, struct ieee80211vap *vap,
                        continue;
 
                /* Verify mode matches any fixed mode specified */
-               if((c->chan->ic_flags & as->as_required_mode) != 
+               if ((c->chan->ic_flags & as->as_required_mode) != 
                                as->as_required_mode)
                        continue;
 
@@ -781,6 +779,12 @@ pick_channel(struct ieee80211_scan_state *ss, struct ieee80211vap *vap,
                                /* break the loop as the subsequent chans won't be 
                                 * better */
                                break;
+
+                       if (!IEEE80211_ARE_CHANS_SAME_MODE(c->chan,
+                               ic->ic_bsschan))
+                               /* break the loop as the subsequent chans won't be
+                                * better */
+                               break;
                }
 
                if (sta_assoc != 0) {