Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Support hidden ESSID APs.



details:   https://anonhg.NetBSD.org/src/rev/f623e1ed2222
branches:  trunk
changeset: 584645:f623e1ed2222
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sun Sep 25 11:55:05 2005 +0000

description:
Support hidden ESSID APs.

Use the newer scan command as this one doesn't crash the firmware when
scanning 802.11a channels.

Thanks to scw and blymn for testing.

Closes PR 31295.

diffstat:

 sys/dev/pci/if_iwi.c    |  47 +++++++++++++++++++++++++++++++++++++----------
 sys/dev/pci/if_iwireg.h |  35 +++++++++++++++++++++++++++++++----
 2 files changed, 68 insertions(+), 14 deletions(-)

diffs (157 lines):

diff -r 1a8dbec3ac2c -r f623e1ed2222 sys/dev/pci/if_iwi.c
--- a/sys/dev/pci/if_iwi.c      Sun Sep 25 09:01:21 2005 +0000
+++ b/sys/dev/pci/if_iwi.c      Sun Sep 25 11:55:05 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_iwi.c,v 1.25 2005/09/25 06:49:54 skrll Exp $  */
+/*     $NetBSD: if_iwi.c,v 1.26 2005/09/25 11:55:05 skrll Exp $  */
 
 /*-
  * Copyright (c) 2004, 2005
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.25 2005/09/25 06:49:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.26 2005/09/25 11:55:05 skrll Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver
@@ -2110,24 +2110,49 @@
 iwi_scan(struct iwi_softc *sc)
 {
        struct ieee80211com *ic = &sc->sc_ic;
-       struct iwi_scan scan;
+       struct iwi_scan_v2 scan;
+       uint32_t type;
        uint8_t *p;
-       int i, count;
+       int i, count, idx;
 
        (void)memset(&scan, 0, sizeof scan);
-       scan.type = IWI_SCAN_TYPE_BROADCAST;
-       scan.dwelltime = htole16(sc->dwelltime);
+       scan.dwelltime[IWI_SCAN_TYPE_ACTIVE_BROADCAST] =
+           htole16(sc->dwelltime);
+       scan.dwelltime[IWI_SCAN_TYPE_ACTIVE_BDIRECT] =
+           htole16(sc->dwelltime);
+
+       /* tell the firmware about the desired essid */
+       if (ic->ic_des_esslen) {
+               int error;
+
+               DPRINTF(("%s: Setting adapter desired ESSID to %s\n",
+                   __func__, ic->ic_des_essid));
 
-       p = scan.channels;
-       count = 0;
+               error = iwi_cmd(sc, IWI_CMD_SET_ESSID,
+                   ic->ic_des_essid, ic->ic_des_esslen, 1);
+               if (error)
+                       return error;
+
+               type = IWI_SCAN_TYPE_ACTIVE_BDIRECT;
+       } else {
+               type = IWI_SCAN_TYPE_ACTIVE_BROADCAST;
+       }
+
+       p = &scan.channels[0];
+       count = idx = 0;
        for (i = 0; i <= IEEE80211_CHAN_MAX; i++) {
                if (IEEE80211_IS_CHAN_5GHZ(&ic->ic_channels[i]) &&
                    isset(ic->ic_chan_active, i)) {
                        *++p = i;
                        count++;
+                       idx++;
+                       iwi_scan_type_set(scan, idx, type);
                }
        }
-       *(p - count) = IWI_CHAN_5GHZ | count;
+       if (count) {
+               *(p - count) = IWI_CHAN_5GHZ | count;
+               p++;
+       }
 
        count = 0;
        for (i = 0; i <= IEEE80211_CHAN_MAX; i++) {
@@ -2135,12 +2160,14 @@
                    isset(ic->ic_chan_active, i)) {
                        *++p = i;
                        count++;
+                       idx++;
+                       iwi_scan_type_set(scan, idx, type);
                }
        }
        *(p - count) = IWI_CHAN_2GHZ | count;
 
        DPRINTF(("Start scanning\n"));
-       return iwi_cmd(sc, IWI_CMD_SCAN, &scan, sizeof scan, 1);
+       return iwi_cmd(sc, IWI_CMD_SCAN_V2, &scan, sizeof scan, 1);
 }
 
 static int
diff -r 1a8dbec3ac2c -r f623e1ed2222 sys/dev/pci/if_iwireg.h
--- a/sys/dev/pci/if_iwireg.h   Sun Sep 25 09:01:21 2005 +0000
+++ b/sys/dev/pci/if_iwireg.h   Sun Sep 25 11:55:05 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_iwireg.h,v 1.8 2005/09/25 06:49:54 skrll Exp $ */
+/*     $NetBSD: if_iwireg.h,v 1.9 2005/09/25 11:55:05 skrll Exp $ */
 
 /*-
  * Copyright (c) 2004, 2005
@@ -256,6 +256,7 @@
 #define IWI_CMD_ASSOCIATE                      21
 #define IWI_CMD_SET_RATES                      22
 #define IWI_CMD_ABORT_SCAN                     23
+#define IWI_CMD_SCAN_V2                                26
 #define IWI_CMD_SET_OPTIE                      31
 #define IWI_CMD_DISABLE                                33
 #define IWI_CMD_SET_IV                         34
@@ -326,12 +327,16 @@
 
 #define IWI_SCAN_CHANNELS      54
 
+#define IWI_SCAN_TYPE_FIRST_BEACON     0
+#define IWI_SCAN_TYPE_PASSIVE          1
+#define IWI_SCAN_TYPE_ACTIVE_DIRECT    2
+#define IWI_SCAN_TYPE_ACTIVE_BROADCAST 3
+#define IWI_SCAN_TYPE_ACTIVE_BDIRECT   4
+#define IWI_SCAN_TYPES                 5
+
 /* structure for command IWI_CMD_SCAN */
 struct iwi_scan {
        uint8_t         type;
-#define IWI_SCAN_TYPE_PASSIVE          1
-#define IWI_SCAN_TYPE_BROADCAST                3
-
        uint16_t        dwelltime;
        uint8_t         channels[IWI_SCAN_CHANNELS];
 #define IWI_CHAN_5GHZ  (0 << 6)
@@ -340,6 +345,28 @@
        uint8_t         reserved[3];
 } __attribute__((__packed__));
 
+#define iwi_scan_type_set(s, i, t)                     \
+       do {                                            \
+               if ((i) % 2 == 0)                       \
+                       (s).type[(i) / 2].lsn = (t);    \
+               else                                    \
+                       (s).type[(i) / 2].msn = (t);    \
+       } while(0)
+
+/* structure for command IWI_CMD_SCAN_V2 */
+struct iwi_scan_v2 {
+       u_int32_t       fsidx;
+       u_int8_t        channels[IWI_SCAN_CHANNELS];
+       struct {
+               u_int8_t lsn:4;
+               u_int8_t msn:4;
+       } __attribute__ ((__packed__)) type[IWI_SCAN_CHANNELS / 2];
+
+       u_int8_t        reserved1;
+       u_int16_t       dwelltime[IWI_SCAN_TYPES];
+
+} __attribute__ ((__packed__));
+
 /* structure for command IWI_CMD_SET_CONFIGURATION */
 struct iwi_configuration {
        uint8_t bluetooth_coexistence;



Home | Main Index | Thread Index | Old Index