Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /** |
| 2 | * Functions implementing wlan scan IOCTL and firmware command APIs |
| 3 | * |
| 4 | * IOCTL handlers as well as command preperation and response routines |
| 5 | * for sending scan commands to the firmware. |
| 6 | */ |
| 7 | #include <linux/ctype.h> |
| 8 | #include <linux/if.h> |
| 9 | #include <linux/netdevice.h> |
| 10 | #include <linux/wireless.h> |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 11 | #include <linux/etherdevice.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 12 | |
| 13 | #include <net/ieee80211.h> |
| 14 | #include <net/iw_handler.h> |
| 15 | |
Vladimir Davydov | ac630c2 | 2007-09-06 21:45:36 -0400 | [diff] [blame] | 16 | #include <asm/unaligned.h> |
| 17 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 18 | #include "host.h" |
| 19 | #include "decl.h" |
| 20 | #include "dev.h" |
| 21 | #include "scan.h" |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 22 | #include "join.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 23 | |
| 24 | //! Approximate amount of data needed to pass a scan result back to iwlist |
| 25 | #define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN \ |
| 26 | + IW_ESSID_MAX_SIZE \ |
| 27 | + IW_EV_UINT_LEN \ |
| 28 | + IW_EV_FREQ_LEN \ |
| 29 | + IW_EV_QUAL_LEN \ |
| 30 | + IW_ESSID_MAX_SIZE \ |
| 31 | + IW_EV_PARAM_LEN \ |
| 32 | + 40) /* 40 for WPAIE */ |
| 33 | |
| 34 | //! Memory needed to store a max sized channel List TLV for a firmware scan |
| 35 | #define CHAN_TLV_MAX_SIZE (sizeof(struct mrvlietypesheader) \ |
| 36 | + (MRVDRV_MAX_CHANNELS_PER_SCAN \ |
| 37 | * sizeof(struct chanscanparamset))) |
| 38 | |
| 39 | //! Memory needed to store a max number/size SSID TLV for a firmware scan |
| 40 | #define SSID_TLV_MAX_SIZE (1 * sizeof(struct mrvlietypes_ssidparamset)) |
| 41 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 42 | //! Maximum memory needed for a lbs_scan_cmd_config with all TLVs at max |
| 43 | #define MAX_SCAN_CFG_ALLOC (sizeof(struct lbs_scan_cmd_config) \ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 44 | + CHAN_TLV_MAX_SIZE \ |
| 45 | + SSID_TLV_MAX_SIZE) |
| 46 | |
| 47 | //! The maximum number of channels the firmware can scan per command |
| 48 | #define MRVDRV_MAX_CHANNELS_PER_SCAN 14 |
| 49 | |
| 50 | /** |
| 51 | * @brief Number of channels to scan per firmware scan command issuance. |
| 52 | * |
| 53 | * Number restricted to prevent hitting the limit on the amount of scan data |
| 54 | * returned in a single firmware scan command. |
| 55 | */ |
| 56 | #define MRVDRV_CHANNELS_PER_SCAN_CMD 4 |
| 57 | |
| 58 | //! Scan time specified in the channel TLV for each channel for passive scans |
| 59 | #define MRVDRV_PASSIVE_SCAN_CHAN_TIME 100 |
| 60 | |
| 61 | //! Scan time specified in the channel TLV for each channel for active scans |
| 62 | #define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100 |
| 63 | |
Dan Williams | 123e0e0 | 2007-05-25 23:23:43 -0400 | [diff] [blame] | 64 | static const u8 zeromac[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| 65 | static const u8 bcastmac[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 66 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 67 | |
| 68 | |
| 69 | |
| 70 | /*********************************************************************/ |
| 71 | /* */ |
| 72 | /* Misc helper functions */ |
| 73 | /* */ |
| 74 | /*********************************************************************/ |
| 75 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 76 | static inline void clear_bss_descriptor (struct bss_descriptor * bss) |
| 77 | { |
| 78 | /* Don't blow away ->list, just BSS data */ |
| 79 | memset(bss, 0, offsetof(struct bss_descriptor, list)); |
| 80 | } |
| 81 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 82 | /** |
| 83 | * @brief Compare two SSIDs |
| 84 | * |
| 85 | * @param ssid1 A pointer to ssid to compare |
| 86 | * @param ssid2 A pointer to ssid to compare |
| 87 | * |
| 88 | * @return 0: ssid is same, otherwise is different |
| 89 | */ |
| 90 | int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len) |
| 91 | { |
| 92 | if (ssid1_len != ssid2_len) |
| 93 | return -1; |
| 94 | |
| 95 | return memcmp(ssid1, ssid2, ssid1_len); |
| 96 | } |
| 97 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 98 | static inline int match_bss_no_security(struct lbs_802_11_security *secinfo, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 99 | struct bss_descriptor * match_bss) |
| 100 | { |
| 101 | if ( !secinfo->wep_enabled |
| 102 | && !secinfo->WPAenabled |
| 103 | && !secinfo->WPA2enabled |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 104 | && match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC |
| 105 | && match_bss->rsn_ie[0] != MFIE_TYPE_RSN |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 106 | && !(match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 107 | return 1; |
| 108 | } |
| 109 | return 0; |
| 110 | } |
| 111 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 112 | static inline int match_bss_static_wep(struct lbs_802_11_security *secinfo, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 113 | struct bss_descriptor * match_bss) |
| 114 | { |
| 115 | if ( secinfo->wep_enabled |
| 116 | && !secinfo->WPAenabled |
| 117 | && !secinfo->WPA2enabled |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 118 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 119 | return 1; |
| 120 | } |
| 121 | return 0; |
| 122 | } |
| 123 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 124 | static inline int match_bss_wpa(struct lbs_802_11_security *secinfo, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 125 | struct bss_descriptor * match_bss) |
| 126 | { |
| 127 | if ( !secinfo->wep_enabled |
| 128 | && secinfo->WPAenabled |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 129 | && (match_bss->wpa_ie[0] == MFIE_TYPE_GENERIC) |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 130 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 131 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { |
| 132 | */ |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 133 | ) { |
| 134 | return 1; |
| 135 | } |
| 136 | return 0; |
| 137 | } |
| 138 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 139 | static inline int match_bss_wpa2(struct lbs_802_11_security *secinfo, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 140 | struct bss_descriptor * match_bss) |
| 141 | { |
| 142 | if ( !secinfo->wep_enabled |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 143 | && secinfo->WPA2enabled |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 144 | && (match_bss->rsn_ie[0] == MFIE_TYPE_RSN) |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 145 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 146 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { |
| 147 | */ |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 148 | ) { |
| 149 | return 1; |
| 150 | } |
| 151 | return 0; |
| 152 | } |
| 153 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 154 | static inline int match_bss_dynamic_wep(struct lbs_802_11_security *secinfo, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 155 | struct bss_descriptor * match_bss) |
| 156 | { |
| 157 | if ( !secinfo->wep_enabled |
| 158 | && !secinfo->WPAenabled |
| 159 | && !secinfo->WPA2enabled |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 160 | && (match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC) |
| 161 | && (match_bss->rsn_ie[0] != MFIE_TYPE_RSN) |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 162 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 163 | return 1; |
| 164 | } |
| 165 | return 0; |
| 166 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 167 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 168 | static inline int is_same_network(struct bss_descriptor *src, |
| 169 | struct bss_descriptor *dst) |
| 170 | { |
| 171 | /* A network is only a duplicate if the channel, BSSID, and ESSID |
| 172 | * all match. We treat all <hidden> with the same BSSID and channel |
| 173 | * as one network */ |
| 174 | return ((src->ssid_len == dst->ssid_len) && |
| 175 | (src->channel == dst->channel) && |
| 176 | !compare_ether_addr(src->bssid, dst->bssid) && |
| 177 | !memcmp(src->ssid, dst->ssid, src->ssid_len)); |
| 178 | } |
| 179 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 180 | /** |
| 181 | * @brief Check if a scanned network compatible with the driver settings |
| 182 | * |
| 183 | * WEP WPA WPA2 ad-hoc encrypt Network |
| 184 | * enabled enabled enabled AES mode privacy WPA WPA2 Compatible |
| 185 | * 0 0 0 0 NONE 0 0 0 yes No security |
| 186 | * 1 0 0 0 NONE 1 0 0 yes Static WEP |
| 187 | * 0 1 0 0 x 1x 1 x yes WPA |
| 188 | * 0 0 1 0 x 1x x 1 yes WPA2 |
| 189 | * 0 0 0 1 NONE 1 0 0 yes Ad-hoc AES |
| 190 | * 0 0 0 0 !=NONE 1 0 0 yes Dynamic WEP |
| 191 | * |
| 192 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 193 | * @param priv A pointer to struct lbs_private |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 194 | * @param index Index in scantable to check against current driver settings |
| 195 | * @param mode Network mode: Infrastructure or IBSS |
| 196 | * |
| 197 | * @return Index in scantable, or error code if negative |
| 198 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 199 | static int is_network_compatible(struct lbs_private *priv, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 200 | struct bss_descriptor * bss, u8 mode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 201 | { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 202 | int matched = 0; |
| 203 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 204 | lbs_deb_enter(LBS_DEB_SCAN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 205 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 206 | if (bss->mode != mode) |
| 207 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 208 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 209 | if ((matched = match_bss_no_security(&priv->secinfo, bss))) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 210 | goto done; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 211 | } else if ((matched = match_bss_static_wep(&priv->secinfo, bss))) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 212 | goto done; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 213 | } else if ((matched = match_bss_wpa(&priv->secinfo, bss))) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 214 | lbs_deb_scan( |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 215 | "is_network_compatible() WPA: wpa_ie 0x%x " |
| 216 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " |
| 217 | "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 218 | priv->secinfo.wep_enabled ? "e" : "d", |
| 219 | priv->secinfo.WPAenabled ? "e" : "d", |
| 220 | priv->secinfo.WPA2enabled ? "e" : "d", |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 221 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 222 | goto done; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 223 | } else if ((matched = match_bss_wpa2(&priv->secinfo, bss))) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 224 | lbs_deb_scan( |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 225 | "is_network_compatible() WPA2: wpa_ie 0x%x " |
| 226 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " |
| 227 | "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 228 | priv->secinfo.wep_enabled ? "e" : "d", |
| 229 | priv->secinfo.WPAenabled ? "e" : "d", |
| 230 | priv->secinfo.WPA2enabled ? "e" : "d", |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 231 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 232 | goto done; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 233 | } else if ((matched = match_bss_dynamic_wep(&priv->secinfo, bss))) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 234 | lbs_deb_scan( |
| 235 | "is_network_compatible() dynamic WEP: " |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 236 | "wpa_ie 0x%x wpa2_ie 0x%x privacy 0x%x\n", |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 237 | bss->wpa_ie[0], bss->rsn_ie[0], |
| 238 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 239 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 240 | } |
| 241 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 242 | /* bss security settings don't match those configured on card */ |
| 243 | lbs_deb_scan( |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 244 | "is_network_compatible() FAILED: wpa_ie 0x%x " |
| 245 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s privacy 0x%x\n", |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 246 | bss->wpa_ie[0], bss->rsn_ie[0], |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 247 | priv->secinfo.wep_enabled ? "e" : "d", |
| 248 | priv->secinfo.WPAenabled ? "e" : "d", |
| 249 | priv->secinfo.WPA2enabled ? "e" : "d", |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 250 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 251 | |
| 252 | done: |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 253 | lbs_deb_leave_args(LBS_DEB_SCAN, "matched: %d", matched); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 254 | return matched; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 255 | } |
| 256 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 257 | |
| 258 | |
| 259 | |
| 260 | /*********************************************************************/ |
| 261 | /* */ |
| 262 | /* Main scanning support */ |
| 263 | /* */ |
| 264 | /*********************************************************************/ |
| 265 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 266 | void lbs_scan_worker(struct work_struct *work) |
| 267 | { |
| 268 | struct lbs_private *priv = |
| 269 | container_of(work, struct lbs_private, scan_work.work); |
| 270 | |
| 271 | lbs_deb_enter(LBS_DEB_SCAN); |
| 272 | lbs_scan_networks(priv, NULL, 0); |
| 273 | lbs_deb_leave(LBS_DEB_SCAN); |
| 274 | } |
| 275 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 276 | |
| 277 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 278 | * @brief Create a channel list for the driver to scan based on region info |
| 279 | * |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 280 | * Only used from lbs_scan_setup_scan_config() |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 281 | * |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 282 | * Use the driver region/band information to construct a comprehensive list |
| 283 | * of channels to scan. This routine is used for any scan that is not |
| 284 | * provided a specific channel list to scan. |
| 285 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 286 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 287 | * @param scanchanlist Output parameter: resulting channel list to scan |
| 288 | * @param filteredscan Flag indicating whether or not a BSSID or SSID filter |
| 289 | * is being sent in the command to firmware. Used to |
| 290 | * increase the number of channels sent in a scan |
| 291 | * command and to disable the firmware channel scan |
| 292 | * filter. |
| 293 | * |
| 294 | * @return void |
| 295 | */ |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 296 | static int lbs_scan_create_channel_list(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 297 | struct chanscanparamset * scanchanlist, |
| 298 | u8 filteredscan) |
| 299 | { |
| 300 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 301 | struct region_channel *scanregion; |
| 302 | struct chan_freq_power *cfp; |
| 303 | int rgnidx; |
| 304 | int chanidx; |
| 305 | int nextchan; |
| 306 | u8 scantype; |
| 307 | |
| 308 | chanidx = 0; |
| 309 | |
| 310 | /* Set the default scan type to the user specified type, will later |
| 311 | * be changed to passive on a per channel basis if restricted by |
| 312 | * regulatory requirements (11d or 11h) |
| 313 | */ |
Holger Schurig | 4f2fdaa | 2007-08-02 13:12:27 -0400 | [diff] [blame] | 314 | scantype = CMD_SCAN_TYPE_ACTIVE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 315 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 316 | for (rgnidx = 0; rgnidx < ARRAY_SIZE(priv->region_channel); rgnidx++) { |
| 317 | if (priv->enable11d && |
| 318 | (priv->connect_status != LBS_CONNECTED) && |
| 319 | (priv->mesh_connect_status != LBS_CONNECTED)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 320 | /* Scan all the supported chan for the first scan */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 321 | if (!priv->universal_channel[rgnidx].valid) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 322 | continue; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 323 | scanregion = &priv->universal_channel[rgnidx]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 324 | |
| 325 | /* clear the parsed_region_chan for the first scan */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 326 | memset(&priv->parsed_region_chan, 0x00, |
| 327 | sizeof(priv->parsed_region_chan)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 328 | } else { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 329 | if (!priv->region_channel[rgnidx].valid) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 330 | continue; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 331 | scanregion = &priv->region_channel[rgnidx]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | for (nextchan = 0; |
| 335 | nextchan < scanregion->nrcfp; nextchan++, chanidx++) { |
| 336 | |
| 337 | cfp = scanregion->CFP + nextchan; |
| 338 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 339 | if (priv->enable11d) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 340 | scantype = |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 341 | lbs_get_scan_type_11d(cfp->channel, |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 342 | &priv-> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 343 | parsed_region_chan); |
| 344 | } |
| 345 | |
| 346 | switch (scanregion->band) { |
| 347 | case BAND_B: |
| 348 | case BAND_G: |
| 349 | default: |
| 350 | scanchanlist[chanidx].radiotype = |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 351 | CMD_SCAN_RADIO_TYPE_BG; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 352 | break; |
| 353 | } |
| 354 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 355 | if (scantype == CMD_SCAN_TYPE_PASSIVE) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 356 | scanchanlist[chanidx].maxscantime = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 357 | cpu_to_le16(MRVDRV_PASSIVE_SCAN_CHAN_TIME); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 358 | scanchanlist[chanidx].chanscanmode.passivescan = |
| 359 | 1; |
| 360 | } else { |
| 361 | scanchanlist[chanidx].maxscantime = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 362 | cpu_to_le16(MRVDRV_ACTIVE_SCAN_CHAN_TIME); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 363 | scanchanlist[chanidx].chanscanmode.passivescan = |
| 364 | 0; |
| 365 | } |
| 366 | |
| 367 | scanchanlist[chanidx].channumber = cfp->channel; |
| 368 | |
| 369 | if (filteredscan) { |
| 370 | scanchanlist[chanidx].chanscanmode. |
| 371 | disablechanfilt = 1; |
| 372 | } |
| 373 | } |
| 374 | } |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 375 | return chanidx; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 376 | } |
| 377 | |
Dan Williams | 2afc0c5 | 2007-08-02 13:19:04 -0400 | [diff] [blame] | 378 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 379 | /* |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 380 | * Add SSID TLV of the form: |
| 381 | * |
| 382 | * TLV-ID SSID 00 00 |
| 383 | * length 06 00 |
| 384 | * ssid 4d 4e 54 45 53 54 |
| 385 | */ |
| 386 | static int lbs_scan_add_ssid_tlv(u8 *tlv, |
| 387 | const struct lbs_ioctl_user_scan_cfg *user_cfg) |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 388 | { |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 389 | struct mrvlietypes_ssidparamset *ssid_tlv = |
| 390 | (struct mrvlietypes_ssidparamset *)tlv; |
| 391 | ssid_tlv->header.type = cpu_to_le16(TLV_TYPE_SSID); |
| 392 | ssid_tlv->header.len = cpu_to_le16(user_cfg->ssid_len); |
| 393 | memcpy(ssid_tlv->ssid, user_cfg->ssid, user_cfg->ssid_len); |
| 394 | return sizeof(ssid_tlv->header) + user_cfg->ssid_len; |
| 395 | } |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 396 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 397 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 398 | /* |
| 399 | * Add CHANLIST TLV of the form |
| 400 | * |
| 401 | * TLV-ID CHANLIST 01 01 |
| 402 | * length 5b 00 |
| 403 | * channel 1 00 01 00 00 00 64 00 |
| 404 | * radio type 00 |
| 405 | * channel 01 |
| 406 | * scan type 00 |
| 407 | * min scan time 00 00 |
| 408 | * max scan time 64 00 |
| 409 | * channel 2 00 02 00 00 00 64 00 |
| 410 | * channel 3 00 03 00 00 00 64 00 |
| 411 | * channel 4 00 04 00 00 00 64 00 |
| 412 | * channel 5 00 05 00 00 00 64 00 |
| 413 | * channel 6 00 06 00 00 00 64 00 |
| 414 | * channel 7 00 07 00 00 00 64 00 |
| 415 | * channel 8 00 08 00 00 00 64 00 |
| 416 | * channel 9 00 09 00 00 00 64 00 |
| 417 | * channel 10 00 0a 00 00 00 64 00 |
| 418 | * channel 11 00 0b 00 00 00 64 00 |
| 419 | * channel 12 00 0c 00 00 00 64 00 |
| 420 | * channel 13 00 0d 00 00 00 64 00 |
| 421 | * |
| 422 | */ |
| 423 | static int lbs_scan_add_chanlist_tlv(u8 *tlv, |
| 424 | struct chanscanparamset *chan_list, |
| 425 | int chan_count) |
| 426 | { |
| 427 | size_t size = sizeof(struct chanscanparamset) * chan_count; |
| 428 | struct mrvlietypes_chanlistparamset *chan_tlv = |
| 429 | (struct mrvlietypes_chanlistparamset *) tlv; |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 430 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 431 | chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); |
| 432 | memcpy(chan_tlv->chanscanparam, chan_list, size); |
| 433 | chan_tlv->header.len = cpu_to_le16(size); |
| 434 | return sizeof(chan_tlv->header) + size; |
| 435 | } |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 436 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 437 | |
| 438 | /* |
| 439 | * Add RATES TLV of the form |
| 440 | * |
| 441 | * TLV-ID RATES 01 00 |
| 442 | * length 0e 00 |
| 443 | * rates 82 84 8b 96 0c 12 18 24 30 48 60 6c |
| 444 | * |
| 445 | * The rates are in lbs_bg_rates[], but for the 802.11b |
| 446 | * rates the high bit isn't set. |
| 447 | */ |
| 448 | static int lbs_scan_add_rates_tlv(u8 *tlv) |
| 449 | { |
| 450 | int i; |
| 451 | struct mrvlietypes_ratesparamset *rate_tlv = |
| 452 | (struct mrvlietypes_ratesparamset *) tlv; |
| 453 | |
| 454 | rate_tlv->header.type = cpu_to_le16(TLV_TYPE_RATES); |
| 455 | tlv += sizeof(rate_tlv->header); |
| 456 | for (i = 0; i < MAX_RATES; i++) { |
| 457 | *tlv = lbs_bg_rates[i]; |
| 458 | if (*tlv == 0) |
| 459 | break; |
| 460 | /* This code makes sure that the 802.11b rates (1 MBit/s, 2 |
| 461 | MBit/s, 5.5 MBit/s and 11 MBit/s get's the high bit set. |
| 462 | Note that the values are MBit/s * 2, to mark them as |
| 463 | basic rates so that the firmware likes it better */ |
| 464 | if (*tlv == 0x02 || *tlv == 0x04 || |
| 465 | *tlv == 0x0b || *tlv == 0x16) |
| 466 | *tlv |= 0x80; |
| 467 | tlv++; |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 468 | } |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 469 | rate_tlv->header.len = cpu_to_le16(i); |
| 470 | return sizeof(rate_tlv->header) + i; |
| 471 | } |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 472 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 473 | |
| 474 | /* |
| 475 | * Generate the CMD_802_11_SCAN command with the proper tlv |
| 476 | * for a bunch of channels. |
| 477 | */ |
| 478 | static int lbs_do_scan(struct lbs_private *priv, |
| 479 | u8 bsstype, |
| 480 | struct chanscanparamset *chan_list, |
| 481 | int chan_count, |
| 482 | const struct lbs_ioctl_user_scan_cfg *user_cfg) |
| 483 | { |
| 484 | int ret = -ENOMEM; |
| 485 | struct lbs_scan_cmd_config *scan_cmd; |
| 486 | u8 *tlv; /* pointer into our current, growing TLV storage area */ |
| 487 | |
| 488 | lbs_deb_enter_args(LBS_DEB_SCAN, "bsstype %d, chanlist[].chan %d, " |
| 489 | "chan_count %d", |
| 490 | bsstype, chan_list[0].channumber, chan_count); |
| 491 | |
| 492 | /* create the fixed part for scan command */ |
| 493 | scan_cmd = kzalloc(MAX_SCAN_CFG_ALLOC, GFP_KERNEL); |
| 494 | if (scan_cmd == NULL) |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 495 | goto out; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 496 | tlv = scan_cmd->tlvbuffer; |
| 497 | if (user_cfg) |
| 498 | memcpy(scan_cmd->bssid, user_cfg->bssid, ETH_ALEN); |
| 499 | scan_cmd->bsstype = bsstype; |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 500 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 501 | /* add TLVs */ |
| 502 | if (user_cfg && user_cfg->ssid_len) |
| 503 | tlv += lbs_scan_add_ssid_tlv(tlv, user_cfg); |
| 504 | if (chan_list && chan_count) |
| 505 | tlv += lbs_scan_add_chanlist_tlv(tlv, chan_list, chan_count); |
| 506 | tlv += lbs_scan_add_rates_tlv(tlv); |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 507 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 508 | /* This is the final data we are about to send */ |
| 509 | scan_cmd->tlvbufferlen = tlv - scan_cmd->tlvbuffer; |
| 510 | lbs_deb_hex(LBS_DEB_SCAN, "SCAN_CMD", (void *)scan_cmd, 1+6); |
| 511 | lbs_deb_hex(LBS_DEB_SCAN, "SCAN_TLV", scan_cmd->tlvbuffer, |
| 512 | scan_cmd->tlvbufferlen); |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 513 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 514 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_SCAN, 0, |
| 515 | CMD_OPTION_WAITFORRSP, 0, scan_cmd); |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 516 | out: |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 517 | kfree(scan_cmd); |
| 518 | lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); |
| 519 | return ret; |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 523 | /** |
| 524 | * @brief Internal function used to start a scan based on an input config |
| 525 | * |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 526 | * Also used from debugfs |
| 527 | * |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 528 | * Use the input user scan configuration information when provided in |
| 529 | * order to send the appropriate scan commands to firmware to populate or |
| 530 | * update the internal driver scan table |
| 531 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 532 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 533 | * @param puserscanin Pointer to the input configuration for the requested |
| 534 | * scan. |
| 535 | * |
| 536 | * @return 0 or < 0 if error |
| 537 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 538 | int lbs_scan_networks(struct lbs_private *priv, |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 539 | const struct lbs_ioctl_user_scan_cfg *user_cfg, |
Dan Williams | 2afc0c5 | 2007-08-02 13:19:04 -0400 | [diff] [blame] | 540 | int full_scan) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 541 | { |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 542 | int ret = -ENOMEM; |
| 543 | struct chanscanparamset *chan_list; |
| 544 | struct chanscanparamset *curr_chans; |
| 545 | int chan_count; |
| 546 | u8 bsstype = CMD_BSS_TYPE_ANY; |
| 547 | int numchannels = MRVDRV_CHANNELS_PER_SCAN_CMD; |
| 548 | int filteredscan = 0; |
| 549 | union iwreq_data wrqu; |
Dan Williams | f8f5510 | 2007-05-30 10:12:55 -0400 | [diff] [blame] | 550 | #ifdef CONFIG_LIBERTAS_DEBUG |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 551 | struct bss_descriptor *iter; |
Dan Williams | f8f5510 | 2007-05-30 10:12:55 -0400 | [diff] [blame] | 552 | int i = 0; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 553 | DECLARE_MAC_BUF(mac); |
Dan Williams | f8f5510 | 2007-05-30 10:12:55 -0400 | [diff] [blame] | 554 | #endif |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 555 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 556 | lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", |
| 557 | full_scan); |
Dan Williams | 2afc0c5 | 2007-08-02 13:19:04 -0400 | [diff] [blame] | 558 | |
| 559 | /* Cancel any partial outstanding partial scans if this scan |
| 560 | * is a full scan. |
| 561 | */ |
| 562 | if (full_scan && delayed_work_pending(&priv->scan_work)) |
| 563 | cancel_delayed_work(&priv->scan_work); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 564 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 565 | /* Determine same scan parameters */ |
| 566 | if (user_cfg) { |
| 567 | if (user_cfg->bsstype) |
| 568 | bsstype = user_cfg->bsstype; |
| 569 | if (compare_ether_addr(user_cfg->bssid, &zeromac[0]) != 0) { |
| 570 | numchannels = MRVDRV_MAX_CHANNELS_PER_SCAN; |
| 571 | filteredscan = 1; |
Holger Schurig | 3cf8409 | 2007-08-02 11:50:12 -0400 | [diff] [blame] | 572 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 573 | } |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 574 | lbs_deb_scan("numchannels %d, bsstype %d, " |
| 575 | "filteredscan %d\n", |
| 576 | numchannels, bsstype, filteredscan); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 577 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 578 | /* Create list of channels to scan */ |
| 579 | chan_list = kzalloc(sizeof(struct chanscanparamset) * |
| 580 | LBS_IOCTL_USER_SCAN_CHAN_MAX, GFP_KERNEL); |
| 581 | if (!chan_list) { |
| 582 | lbs_pr_alert("SCAN: chan_list empty\n"); |
| 583 | goto out; |
| 584 | } |
| 585 | |
| 586 | /* We want to scan all channels */ |
| 587 | chan_count = lbs_scan_create_channel_list(priv, chan_list, |
| 588 | filteredscan); |
| 589 | |
| 590 | netif_stop_queue(priv->dev); |
| 591 | netif_carrier_off(priv->dev); |
| 592 | if (priv->mesh_dev) { |
| 593 | netif_stop_queue(priv->mesh_dev); |
| 594 | netif_carrier_off(priv->mesh_dev); |
| 595 | } |
| 596 | |
| 597 | /* Prepare to continue an interrupted scan */ |
| 598 | lbs_deb_scan("chan_count %d, last_scanned_channel %d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 599 | chan_count, priv->last_scanned_channel); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 600 | curr_chans = chan_list; |
| 601 | /* advance channel list by already-scanned-channels */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 602 | if (priv->last_scanned_channel > 0) { |
| 603 | curr_chans += priv->last_scanned_channel; |
| 604 | chan_count -= priv->last_scanned_channel; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /* Send scan command(s) |
| 608 | * numchannels contains the number of channels we should maximally scan |
| 609 | * chan_count is the total number of channels to scan |
| 610 | */ |
| 611 | |
| 612 | while (chan_count) { |
| 613 | int to_scan = min(numchannels, chan_count); |
| 614 | lbs_deb_scan("scanning %d of %d channels\n", |
| 615 | to_scan, chan_count); |
| 616 | ret = lbs_do_scan(priv, bsstype, curr_chans, |
| 617 | to_scan, user_cfg); |
| 618 | if (ret) { |
| 619 | lbs_pr_err("SCAN_CMD failed\n"); |
| 620 | goto out2; |
| 621 | } |
| 622 | curr_chans += to_scan; |
| 623 | chan_count -= to_scan; |
| 624 | |
| 625 | /* somehow schedule the next part of the scan */ |
| 626 | if (chan_count && |
| 627 | !full_scan && |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 628 | !priv->surpriseremoved) { |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 629 | /* -1 marks just that we're currently scanning */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 630 | if (priv->last_scanned_channel < 0) |
| 631 | priv->last_scanned_channel = to_scan; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 632 | else |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 633 | priv->last_scanned_channel += to_scan; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 634 | cancel_delayed_work(&priv->scan_work); |
| 635 | queue_delayed_work(priv->work_thread, &priv->scan_work, |
| 636 | msecs_to_jiffies(300)); |
| 637 | /* skip over GIWSCAN event */ |
| 638 | goto out; |
| 639 | } |
| 640 | |
| 641 | } |
| 642 | memset(&wrqu, 0, sizeof(union iwreq_data)); |
| 643 | wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 644 | |
Dan Williams | f8f5510 | 2007-05-30 10:12:55 -0400 | [diff] [blame] | 645 | #ifdef CONFIG_LIBERTAS_DEBUG |
| 646 | /* Dump the scan table */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 647 | mutex_lock(&priv->lock); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 648 | lbs_deb_scan("scan table:\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 649 | list_for_each_entry(iter, &priv->network_list, list) |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 650 | lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n", |
| 651 | i++, print_mac(mac, iter->bssid), (s32) iter->rssi, |
| 652 | escape_essid(iter->ssid, iter->ssid_len)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 653 | mutex_unlock(&priv->lock); |
Dan Williams | f8f5510 | 2007-05-30 10:12:55 -0400 | [diff] [blame] | 654 | #endif |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 655 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 656 | out2: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 657 | priv->last_scanned_channel = 0; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 658 | |
| 659 | out: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 660 | if (priv->connect_status == LBS_CONNECTED) { |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 661 | netif_carrier_on(priv->dev); |
| 662 | netif_wake_queue(priv->dev); |
Brajesh Dave | 01d77d8 | 2007-11-20 17:44:14 -0500 | [diff] [blame] | 663 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 664 | if (priv->mesh_dev && (priv->mesh_connect_status == LBS_CONNECTED)) { |
Brajesh Dave | 01d77d8 | 2007-11-20 17:44:14 -0500 | [diff] [blame] | 665 | netif_carrier_on(priv->mesh_dev); |
| 666 | netif_wake_queue(priv->mesh_dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 667 | } |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 668 | kfree(chan_list); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 669 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 670 | lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 671 | return ret; |
| 672 | } |
| 673 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 674 | |
| 675 | |
| 676 | |
| 677 | /*********************************************************************/ |
| 678 | /* */ |
| 679 | /* Result interpretation */ |
| 680 | /* */ |
| 681 | /*********************************************************************/ |
| 682 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 683 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 684 | * @brief Interpret a BSS scan response returned from the firmware |
| 685 | * |
| 686 | * Parse the various fixed fields and IEs passed back for a a BSS probe |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 687 | * response or beacon from the scan command. Record information as needed |
| 688 | * in the scan table struct bss_descriptor for that entry. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 689 | * |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 690 | * @param bss Output parameter: Pointer to the BSS Entry |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 691 | * |
| 692 | * @return 0 or -1 |
| 693 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 694 | static int lbs_process_bss(struct bss_descriptor *bss, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 695 | u8 ** pbeaconinfo, int *bytesleft) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 696 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 697 | struct ieeetypes_fhparamset *pFH; |
| 698 | struct ieeetypes_dsparamset *pDS; |
| 699 | struct ieeetypes_cfparamset *pCF; |
| 700 | struct ieeetypes_ibssparamset *pibss; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 701 | DECLARE_MAC_BUF(mac); |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 702 | struct ieeetypes_countryinfoset *pcountryinfo; |
| 703 | u8 *pos, *end, *p; |
| 704 | u8 n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0; |
| 705 | u16 beaconsize = 0; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 706 | int ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 707 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 708 | lbs_deb_enter(LBS_DEB_SCAN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 709 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 710 | if (*bytesleft >= sizeof(beaconsize)) { |
| 711 | /* Extract & convert beacon size from the command buffer */ |
David Woodhouse | e7240ac | 2007-12-11 17:54:36 -0500 | [diff] [blame^] | 712 | beaconsize = le16_to_cpu(get_unaligned((__le16 *)*pbeaconinfo)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 713 | *bytesleft -= sizeof(beaconsize); |
| 714 | *pbeaconinfo += sizeof(beaconsize); |
| 715 | } |
| 716 | |
| 717 | if (beaconsize == 0 || beaconsize > *bytesleft) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 718 | *pbeaconinfo += *bytesleft; |
| 719 | *bytesleft = 0; |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 720 | ret = -1; |
| 721 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | /* Initialize the current working beacon pointer for this BSS iteration */ |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 725 | pos = *pbeaconinfo; |
| 726 | end = pos + beaconsize; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 727 | |
| 728 | /* Advance the return beacon pointer past the current beacon */ |
| 729 | *pbeaconinfo += beaconsize; |
| 730 | *bytesleft -= beaconsize; |
| 731 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 732 | memcpy(bss->bssid, pos, ETH_ALEN); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 733 | lbs_deb_scan("process_bss: BSSID %s\n", print_mac(mac, bss->bssid)); |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 734 | pos += ETH_ALEN; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 735 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 736 | if ((end - pos) < 12) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 737 | lbs_deb_scan("process_bss: Not enough bytes left\n"); |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 738 | ret = -1; |
| 739 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | /* |
| 743 | * next 4 fields are RSSI, time stamp, beacon interval, |
| 744 | * and capability information |
| 745 | */ |
| 746 | |
| 747 | /* RSSI is 1 byte long */ |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 748 | bss->rssi = *pos; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 749 | lbs_deb_scan("process_bss: RSSI %d\n", *pos); |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 750 | pos++; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 751 | |
| 752 | /* time stamp is 8 bytes long */ |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 753 | pos += 8; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 754 | |
| 755 | /* beacon interval is 2 bytes long */ |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 756 | bss->beaconperiod = le16_to_cpup((void *) pos); |
| 757 | pos += 2; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 758 | |
| 759 | /* capability information is 2 bytes long */ |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 760 | bss->capability = le16_to_cpup((void *) pos); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 761 | lbs_deb_scan("process_bss: capabilities 0x%04x\n", bss->capability); |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 762 | pos += 2; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 763 | |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 764 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 765 | lbs_deb_scan("process_bss: WEP enabled\n"); |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 766 | if (bss->capability & WLAN_CAPABILITY_IBSS) |
| 767 | bss->mode = IW_MODE_ADHOC; |
| 768 | else |
| 769 | bss->mode = IW_MODE_INFRA; |
| 770 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 771 | /* rest of the current buffer are IE's */ |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 772 | lbs_deb_scan("process_bss: IE len %zd\n", end - pos); |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 773 | lbs_deb_hex(LBS_DEB_SCAN, "process_bss: IE info", pos, end - pos); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 774 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 775 | /* process variable IE */ |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 776 | while (pos <= end - 2) { |
| 777 | struct ieee80211_info_element * elem = |
| 778 | (struct ieee80211_info_element *) pos; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 779 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 780 | if (pos + elem->len > end) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 781 | lbs_deb_scan("process_bss: error in processing IE, " |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 782 | "bytes left < IE length\n"); |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 783 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 784 | } |
| 785 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 786 | switch (elem->id) { |
| 787 | case MFIE_TYPE_SSID: |
| 788 | bss->ssid_len = elem->len; |
| 789 | memcpy(bss->ssid, elem->data, elem->len); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 790 | lbs_deb_scan("got SSID IE: '%s', len %u\n", |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 791 | escape_essid(bss->ssid, bss->ssid_len), |
| 792 | bss->ssid_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 793 | break; |
| 794 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 795 | case MFIE_TYPE_RATES: |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 796 | n_basic_rates = min_t(u8, MAX_RATES, elem->len); |
| 797 | memcpy(bss->rates, elem->data, n_basic_rates); |
| 798 | got_basic_rates = 1; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 799 | lbs_deb_scan("got RATES IE\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 800 | break; |
| 801 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 802 | case MFIE_TYPE_FH_SET: |
| 803 | pFH = (struct ieeetypes_fhparamset *) pos; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 804 | memmove(&bss->phyparamset.fhparamset, pFH, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 805 | sizeof(struct ieeetypes_fhparamset)); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 806 | lbs_deb_scan("got FH IE\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 807 | break; |
| 808 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 809 | case MFIE_TYPE_DS_SET: |
| 810 | pDS = (struct ieeetypes_dsparamset *) pos; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 811 | bss->channel = pDS->currentchan; |
| 812 | memcpy(&bss->phyparamset.dsparamset, pDS, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 813 | sizeof(struct ieeetypes_dsparamset)); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 814 | lbs_deb_scan("got DS IE, channel %d\n", bss->channel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 815 | break; |
| 816 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 817 | case MFIE_TYPE_CF_SET: |
| 818 | pCF = (struct ieeetypes_cfparamset *) pos; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 819 | memcpy(&bss->ssparamset.cfparamset, pCF, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 820 | sizeof(struct ieeetypes_cfparamset)); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 821 | lbs_deb_scan("got CF IE\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 822 | break; |
| 823 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 824 | case MFIE_TYPE_IBSS_SET: |
| 825 | pibss = (struct ieeetypes_ibssparamset *) pos; |
David Woodhouse | e7240ac | 2007-12-11 17:54:36 -0500 | [diff] [blame^] | 826 | bss->atimwindow = le16_to_cpu(pibss->atimwindow); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 827 | memmove(&bss->ssparamset.ibssparamset, pibss, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 828 | sizeof(struct ieeetypes_ibssparamset)); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 829 | lbs_deb_scan("got IBSS IE\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 830 | break; |
| 831 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 832 | case MFIE_TYPE_COUNTRY: |
| 833 | pcountryinfo = (struct ieeetypes_countryinfoset *) pos; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 834 | lbs_deb_scan("got COUNTRY IE\n"); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 835 | if (pcountryinfo->len < sizeof(pcountryinfo->countrycode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 836 | || pcountryinfo->len > 254) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 837 | lbs_deb_scan("process_bss: 11D- Err " |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 838 | "CountryInfo len %d, min %zd, max 254\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 839 | pcountryinfo->len, |
| 840 | sizeof(pcountryinfo->countrycode)); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 841 | ret = -1; |
| 842 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 843 | } |
| 844 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 845 | memcpy(&bss->countryinfo, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 846 | pcountryinfo, pcountryinfo->len + 2); |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 847 | lbs_deb_hex(LBS_DEB_SCAN, "process_bss: 11d countryinfo", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 848 | (u8 *) pcountryinfo, |
| 849 | (u32) (pcountryinfo->len + 2)); |
| 850 | break; |
| 851 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 852 | case MFIE_TYPE_RATES_EX: |
| 853 | /* only process extended supported rate if data rate is |
| 854 | * already found. Data rate IE should come before |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 855 | * extended supported rate IE |
| 856 | */ |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 857 | lbs_deb_scan("got RATESEX IE\n"); |
| 858 | if (!got_basic_rates) { |
| 859 | lbs_deb_scan("... but ignoring it\n"); |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 860 | break; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 861 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 862 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 863 | n_ex_rates = elem->len; |
| 864 | if (n_basic_rates + n_ex_rates > MAX_RATES) |
| 865 | n_ex_rates = MAX_RATES - n_basic_rates; |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 866 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 867 | p = bss->rates + n_basic_rates; |
| 868 | memcpy(p, elem->data, n_ex_rates); |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 869 | break; |
| 870 | |
| 871 | case MFIE_TYPE_GENERIC: |
| 872 | if (elem->len >= 4 && |
| 873 | elem->data[0] == 0x00 && |
| 874 | elem->data[1] == 0x50 && |
| 875 | elem->data[2] == 0xf2 && |
| 876 | elem->data[3] == 0x01) { |
| 877 | bss->wpa_ie_len = min(elem->len + 2, |
| 878 | MAX_WPA_IE_LEN); |
| 879 | memcpy(bss->wpa_ie, elem, bss->wpa_ie_len); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 880 | lbs_deb_scan("got WPA IE\n"); |
| 881 | lbs_deb_hex(LBS_DEB_SCAN, "WPA IE", bss->wpa_ie, |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 882 | elem->len); |
Luis Carlos Cobo | 1e838bf | 2007-08-02 10:51:27 -0400 | [diff] [blame] | 883 | } else if (elem->len >= MARVELL_MESH_IE_LENGTH && |
| 884 | elem->data[0] == 0x00 && |
| 885 | elem->data[1] == 0x50 && |
| 886 | elem->data[2] == 0x43 && |
| 887 | elem->data[3] == 0x04) { |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 888 | lbs_deb_scan("got mesh IE\n"); |
Luis Carlos Cobo | 1e838bf | 2007-08-02 10:51:27 -0400 | [diff] [blame] | 889 | bss->mesh = 1; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 890 | } else { |
| 891 | lbs_deb_scan("got generiec IE: " |
| 892 | "%02x:%02x:%02x:%02x, len %d\n", |
| 893 | elem->data[0], elem->data[1], |
| 894 | elem->data[2], elem->data[3], |
| 895 | elem->len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 896 | } |
| 897 | break; |
| 898 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 899 | case MFIE_TYPE_RSN: |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 900 | lbs_deb_scan("got RSN IE\n"); |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 901 | bss->rsn_ie_len = min(elem->len + 2, MAX_WPA_IE_LEN); |
| 902 | memcpy(bss->rsn_ie, elem, bss->rsn_ie_len); |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 903 | lbs_deb_hex(LBS_DEB_SCAN, "process_bss: RSN_IE", |
| 904 | bss->rsn_ie, elem->len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 905 | break; |
| 906 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 907 | default: |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 908 | lbs_deb_scan("got IE 0x%04x, len %d\n", |
| 909 | elem->id, elem->len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 910 | break; |
| 911 | } |
| 912 | |
Dan Williams | ab61797 | 2007-08-02 10:48:02 -0400 | [diff] [blame] | 913 | pos += elem->len + 2; |
| 914 | } |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 915 | |
| 916 | /* Timestamp */ |
| 917 | bss->last_scanned = jiffies; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 918 | lbs_unset_basic_rate_flags(bss->rates, sizeof(bss->rates)); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 919 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 920 | ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 921 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 922 | done: |
| 923 | lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); |
| 924 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 928 | * @brief This function finds a specific compatible BSSID in the scan list |
| 929 | * |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 930 | * Used in association code |
| 931 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 932 | * @param priv A pointer to struct lbs_private |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 933 | * @param bssid BSSID to find in the scan list |
| 934 | * @param mode Network mode: Infrastructure or IBSS |
| 935 | * |
| 936 | * @return index in BSSID list, or error return code (< 0) |
| 937 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 938 | struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_private *priv, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 939 | u8 * bssid, u8 mode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 940 | { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 941 | struct bss_descriptor * iter_bss; |
| 942 | struct bss_descriptor * found_bss = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 943 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 944 | lbs_deb_enter(LBS_DEB_SCAN); |
| 945 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 946 | if (!bssid) |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 947 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 948 | |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 949 | lbs_deb_hex(LBS_DEB_SCAN, "looking for", |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 950 | bssid, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 951 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 952 | /* Look through the scan table for a compatible match. The loop will |
| 953 | * continue past a matched bssid that is not compatible in case there |
| 954 | * is an AP with multiple SSIDs assigned to the same BSSID |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 955 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 956 | mutex_lock(&priv->lock); |
| 957 | list_for_each_entry (iter_bss, &priv->network_list, list) { |
Dan Williams | 3cf20931 | 2007-05-25 17:28:30 -0400 | [diff] [blame] | 958 | if (compare_ether_addr(iter_bss->bssid, bssid)) |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 959 | continue; /* bssid doesn't match */ |
| 960 | switch (mode) { |
| 961 | case IW_MODE_INFRA: |
| 962 | case IW_MODE_ADHOC: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 963 | if (!is_network_compatible(priv, iter_bss, mode)) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 964 | break; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 965 | found_bss = iter_bss; |
| 966 | break; |
| 967 | default: |
| 968 | found_bss = iter_bss; |
| 969 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 970 | } |
| 971 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 972 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 973 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 974 | out: |
| 975 | lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 976 | return found_bss; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | /** |
| 980 | * @brief This function finds ssid in ssid list. |
| 981 | * |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 982 | * Used in association code |
| 983 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 984 | * @param priv A pointer to struct lbs_private |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 985 | * @param ssid SSID to find in the list |
| 986 | * @param bssid BSSID to qualify the SSID selection (if provided) |
| 987 | * @param mode Network mode: Infrastructure or IBSS |
| 988 | * |
| 989 | * @return index in BSSID list |
| 990 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 991 | struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 992 | u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode, |
Dan Williams | aeea0ab | 2007-05-25 22:30:48 -0400 | [diff] [blame] | 993 | int channel) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 994 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 995 | u8 bestrssi = 0; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 996 | struct bss_descriptor * iter_bss = NULL; |
| 997 | struct bss_descriptor * found_bss = NULL; |
| 998 | struct bss_descriptor * tmp_oldest = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 999 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1000 | lbs_deb_enter(LBS_DEB_SCAN); |
| 1001 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1002 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1003 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1004 | list_for_each_entry (iter_bss, &priv->network_list, list) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1005 | if ( !tmp_oldest |
| 1006 | || (iter_bss->last_scanned < tmp_oldest->last_scanned)) |
| 1007 | tmp_oldest = iter_bss; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1008 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1009 | if (lbs_ssid_cmp(iter_bss->ssid, iter_bss->ssid_len, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1010 | ssid, ssid_len) != 0) |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1011 | continue; /* ssid doesn't match */ |
Dan Williams | 3cf20931 | 2007-05-25 17:28:30 -0400 | [diff] [blame] | 1012 | if (bssid && compare_ether_addr(iter_bss->bssid, bssid) != 0) |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1013 | continue; /* bssid doesn't match */ |
Dan Williams | aeea0ab | 2007-05-25 22:30:48 -0400 | [diff] [blame] | 1014 | if ((channel > 0) && (iter_bss->channel != channel)) |
| 1015 | continue; /* channel doesn't match */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1016 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1017 | switch (mode) { |
| 1018 | case IW_MODE_INFRA: |
| 1019 | case IW_MODE_ADHOC: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1020 | if (!is_network_compatible(priv, iter_bss, mode)) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1021 | break; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1022 | |
| 1023 | if (bssid) { |
| 1024 | /* Found requested BSSID */ |
| 1025 | found_bss = iter_bss; |
| 1026 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1027 | } |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1028 | |
| 1029 | if (SCAN_RSSI(iter_bss->rssi) > bestrssi) { |
| 1030 | bestrssi = SCAN_RSSI(iter_bss->rssi); |
| 1031 | found_bss = iter_bss; |
| 1032 | } |
| 1033 | break; |
| 1034 | case IW_MODE_AUTO: |
| 1035 | default: |
| 1036 | if (SCAN_RSSI(iter_bss->rssi) > bestrssi) { |
| 1037 | bestrssi = SCAN_RSSI(iter_bss->rssi); |
| 1038 | found_bss = iter_bss; |
| 1039 | } |
| 1040 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1041 | } |
| 1042 | } |
| 1043 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1044 | out: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1045 | mutex_unlock(&priv->lock); |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1046 | lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1047 | return found_bss; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1048 | } |
| 1049 | |
| 1050 | /** |
| 1051 | * @brief This function finds the best SSID in the Scan List |
| 1052 | * |
| 1053 | * Search the scan table for the best SSID that also matches the current |
| 1054 | * adapter network preference (infrastructure or adhoc) |
| 1055 | * |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1056 | * @param priv A pointer to struct lbs_private |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1057 | * |
| 1058 | * @return index in BSSID list |
| 1059 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1060 | static struct bss_descriptor *lbs_find_best_ssid_in_list( |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1061 | struct lbs_private *priv, |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1062 | u8 mode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1063 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1064 | u8 bestrssi = 0; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1065 | struct bss_descriptor * iter_bss; |
| 1066 | struct bss_descriptor * best_bss = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1067 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1068 | lbs_deb_enter(LBS_DEB_SCAN); |
| 1069 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1070 | mutex_lock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1071 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1072 | list_for_each_entry (iter_bss, &priv->network_list, list) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1073 | switch (mode) { |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1074 | case IW_MODE_INFRA: |
| 1075 | case IW_MODE_ADHOC: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1076 | if (!is_network_compatible(priv, iter_bss, mode)) |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1077 | break; |
| 1078 | if (SCAN_RSSI(iter_bss->rssi) <= bestrssi) |
| 1079 | break; |
| 1080 | bestrssi = SCAN_RSSI(iter_bss->rssi); |
| 1081 | best_bss = iter_bss; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1082 | break; |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 1083 | case IW_MODE_AUTO: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1084 | default: |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1085 | if (SCAN_RSSI(iter_bss->rssi) <= bestrssi) |
| 1086 | break; |
| 1087 | bestrssi = SCAN_RSSI(iter_bss->rssi); |
| 1088 | best_bss = iter_bss; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1089 | break; |
| 1090 | } |
| 1091 | } |
| 1092 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1093 | mutex_unlock(&priv->lock); |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1094 | lbs_deb_leave_args(LBS_DEB_SCAN, "best_bss %p", best_bss); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1095 | return best_bss; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1096 | } |
| 1097 | |
| 1098 | /** |
| 1099 | * @brief Find the AP with specific ssid in the scan list |
| 1100 | * |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1101 | * Used from association worker. |
| 1102 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1103 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1104 | * @param pSSID A pointer to AP's ssid |
| 1105 | * |
| 1106 | * @return 0--success, otherwise--fail |
| 1107 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1108 | int lbs_find_best_network_ssid(struct lbs_private *priv, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1109 | u8 *out_ssid, u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1110 | { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1111 | int ret = -1; |
| 1112 | struct bss_descriptor * found; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1113 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1114 | lbs_deb_enter(LBS_DEB_SCAN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1115 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1116 | lbs_scan_networks(priv, NULL, 1); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1117 | if (priv->surpriseremoved) |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1118 | goto out; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1119 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1120 | found = lbs_find_best_ssid_in_list(priv, preferred_mode); |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1121 | if (found && (found->ssid_len > 0)) { |
| 1122 | memcpy(out_ssid, &found->ssid, IW_ESSID_MAX_SIZE); |
| 1123 | *out_ssid_len = found->ssid_len; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1124 | *out_mode = found->mode; |
| 1125 | ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1126 | } |
| 1127 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1128 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1129 | lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1130 | return ret; |
| 1131 | } |
| 1132 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1133 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1134 | /** |
| 1135 | * @brief Send a scan command for all available channels filtered on a spec |
| 1136 | * |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1137 | * Used in association code and from debugfs |
| 1138 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1139 | * @param priv A pointer to struct lbs_private structure |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1140 | * @param ssid A pointer to the SSID to scan for |
| 1141 | * @param ssid_len Length of the SSID |
| 1142 | * @param clear_ssid Should existing scan results with this SSID |
| 1143 | * be cleared? |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1144 | * |
| 1145 | * @return 0-success, otherwise fail |
| 1146 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1147 | int lbs_send_specific_ssid_scan(struct lbs_private *priv, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1148 | u8 *ssid, u8 ssid_len, u8 clear_ssid) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1149 | { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1150 | struct lbs_ioctl_user_scan_cfg scancfg; |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 1151 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1152 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1153 | lbs_deb_enter_args(LBS_DEB_SCAN, "SSID '%s', clear %d", |
| 1154 | escape_essid(ssid, ssid_len), clear_ssid); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1155 | |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1156 | if (!ssid_len) |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 1157 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1158 | |
| 1159 | memset(&scancfg, 0x00, sizeof(scancfg)); |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1160 | memcpy(scancfg.ssid, ssid, ssid_len); |
| 1161 | scancfg.ssid_len = ssid_len; |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 1162 | scancfg.clear_ssid = clear_ssid; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1163 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1164 | lbs_scan_networks(priv, &scancfg, 1); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1165 | if (priv->surpriseremoved) { |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1166 | ret = -1; |
| 1167 | goto out; |
| 1168 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1169 | |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 1170 | out: |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1171 | lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); |
Dan Williams | eb8f733 | 2007-05-25 16:25:21 -0400 | [diff] [blame] | 1172 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1173 | } |
| 1174 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1175 | |
| 1176 | |
| 1177 | |
| 1178 | /*********************************************************************/ |
| 1179 | /* */ |
| 1180 | /* Support for Wireless Extensions */ |
| 1181 | /* */ |
| 1182 | /*********************************************************************/ |
| 1183 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1184 | |
Dan Williams | 00af015 | 2007-08-02 13:14:56 -0400 | [diff] [blame] | 1185 | #define MAX_CUSTOM_LEN 64 |
| 1186 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1187 | static inline char *lbs_translate_scan(struct lbs_private *priv, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1188 | char *start, char *stop, |
| 1189 | struct bss_descriptor *bss) |
| 1190 | { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1191 | struct chan_freq_power *cfp; |
| 1192 | char *current_val; /* For rates */ |
| 1193 | struct iw_event iwe; /* Temporary buffer */ |
| 1194 | int j; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1195 | #define PERFECT_RSSI ((u8)50) |
| 1196 | #define WORST_RSSI ((u8)0) |
| 1197 | #define RSSI_DIFF ((u8)(PERFECT_RSSI - WORST_RSSI)) |
| 1198 | u8 rssi; |
| 1199 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1200 | lbs_deb_enter(LBS_DEB_SCAN); |
| 1201 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1202 | cfp = lbs_find_cfp_by_band_and_channel(priv, 0, bss->channel); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1203 | if (!cfp) { |
| 1204 | lbs_deb_scan("Invalid channel number %d\n", bss->channel); |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1205 | start = NULL; |
| 1206 | goto out; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1207 | } |
| 1208 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1209 | /* First entry *MUST* be the BSSID */ |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1210 | iwe.cmd = SIOCGIWAP; |
| 1211 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; |
| 1212 | memcpy(iwe.u.ap_addr.sa_data, &bss->bssid, ETH_ALEN); |
| 1213 | start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN); |
| 1214 | |
| 1215 | /* SSID */ |
| 1216 | iwe.cmd = SIOCGIWESSID; |
| 1217 | iwe.u.data.flags = 1; |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1218 | iwe.u.data.length = min((u32) bss->ssid_len, (u32) IW_ESSID_MAX_SIZE); |
| 1219 | start = iwe_stream_add_point(start, stop, &iwe, bss->ssid); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1220 | |
| 1221 | /* Mode */ |
| 1222 | iwe.cmd = SIOCGIWMODE; |
| 1223 | iwe.u.mode = bss->mode; |
| 1224 | start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN); |
| 1225 | |
| 1226 | /* Frequency */ |
| 1227 | iwe.cmd = SIOCGIWFREQ; |
| 1228 | iwe.u.freq.m = (long)cfp->freq * 100000; |
| 1229 | iwe.u.freq.e = 1; |
| 1230 | start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN); |
| 1231 | |
| 1232 | /* Add quality statistics */ |
| 1233 | iwe.cmd = IWEVQUAL; |
| 1234 | iwe.u.qual.updated = IW_QUAL_ALL_UPDATED; |
| 1235 | iwe.u.qual.level = SCAN_RSSI(bss->rssi); |
| 1236 | |
| 1237 | rssi = iwe.u.qual.level - MRVDRV_NF_DEFAULT_SCAN_VALUE; |
| 1238 | iwe.u.qual.qual = |
| 1239 | (100 * RSSI_DIFF * RSSI_DIFF - (PERFECT_RSSI - rssi) * |
| 1240 | (15 * (RSSI_DIFF) + 62 * (PERFECT_RSSI - rssi))) / |
| 1241 | (RSSI_DIFF * RSSI_DIFF); |
| 1242 | if (iwe.u.qual.qual > 100) |
| 1243 | iwe.u.qual.qual = 100; |
| 1244 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1245 | if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1246 | iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; |
| 1247 | } else { |
| 1248 | iwe.u.qual.noise = |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1249 | CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1250 | } |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1251 | |
Dan Williams | 80e78ef | 2007-05-25 22:18:47 -0400 | [diff] [blame] | 1252 | /* Locally created ad-hoc BSSs won't have beacons if this is the |
| 1253 | * only station in the adhoc network; so get signal strength |
| 1254 | * from receive statistics. |
| 1255 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1256 | if ((priv->mode == IW_MODE_ADHOC) |
| 1257 | && priv->adhoccreate |
| 1258 | && !lbs_ssid_cmp(priv->curbssparams.ssid, |
| 1259 | priv->curbssparams.ssid_len, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1260 | bss->ssid, bss->ssid_len)) { |
Dan Williams | 80e78ef | 2007-05-25 22:18:47 -0400 | [diff] [blame] | 1261 | int snr, nf; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1262 | snr = priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; |
| 1263 | nf = priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; |
Dan Williams | 80e78ef | 2007-05-25 22:18:47 -0400 | [diff] [blame] | 1264 | iwe.u.qual.level = CAL_RSSI(snr, nf); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1265 | } |
| 1266 | start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN); |
| 1267 | |
| 1268 | /* Add encryption capability */ |
| 1269 | iwe.cmd = SIOCGIWENCODE; |
Dan Williams | 0c9ca690 | 2007-08-02 10:43:44 -0400 | [diff] [blame] | 1270 | if (bss->capability & WLAN_CAPABILITY_PRIVACY) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1271 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; |
| 1272 | } else { |
| 1273 | iwe.u.data.flags = IW_ENCODE_DISABLED; |
| 1274 | } |
| 1275 | iwe.u.data.length = 0; |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1276 | start = iwe_stream_add_point(start, stop, &iwe, bss->ssid); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1277 | |
| 1278 | current_val = start + IW_EV_LCP_LEN; |
| 1279 | |
| 1280 | iwe.cmd = SIOCGIWRATE; |
| 1281 | iwe.u.bitrate.fixed = 0; |
| 1282 | iwe.u.bitrate.disabled = 0; |
| 1283 | iwe.u.bitrate.value = 0; |
| 1284 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 1285 | for (j = 0; bss->rates[j] && (j < sizeof(bss->rates)); j++) { |
| 1286 | /* Bit rate given in 500 kb/s units */ |
| 1287 | iwe.u.bitrate.value = bss->rates[j] * 500000; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1288 | current_val = iwe_stream_add_value(start, current_val, |
| 1289 | stop, &iwe, IW_EV_PARAM_LEN); |
| 1290 | } |
| 1291 | if ((bss->mode == IW_MODE_ADHOC) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1292 | && !lbs_ssid_cmp(priv->curbssparams.ssid, |
| 1293 | priv->curbssparams.ssid_len, |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 1294 | bss->ssid, bss->ssid_len) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1295 | && priv->adhoccreate) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1296 | iwe.u.bitrate.value = 22 * 500000; |
| 1297 | current_val = iwe_stream_add_value(start, current_val, |
| 1298 | stop, &iwe, IW_EV_PARAM_LEN); |
| 1299 | } |
| 1300 | /* Check if we added any event */ |
| 1301 | if((current_val - start) > IW_EV_LCP_LEN) |
| 1302 | start = current_val; |
| 1303 | |
| 1304 | memset(&iwe, 0, sizeof(iwe)); |
| 1305 | if (bss->wpa_ie_len) { |
| 1306 | char buf[MAX_WPA_IE_LEN]; |
| 1307 | memcpy(buf, bss->wpa_ie, bss->wpa_ie_len); |
| 1308 | iwe.cmd = IWEVGENIE; |
| 1309 | iwe.u.data.length = bss->wpa_ie_len; |
| 1310 | start = iwe_stream_add_point(start, stop, &iwe, buf); |
| 1311 | } |
| 1312 | |
| 1313 | memset(&iwe, 0, sizeof(iwe)); |
| 1314 | if (bss->rsn_ie_len) { |
| 1315 | char buf[MAX_WPA_IE_LEN]; |
| 1316 | memcpy(buf, bss->rsn_ie, bss->rsn_ie_len); |
| 1317 | iwe.cmd = IWEVGENIE; |
| 1318 | iwe.u.data.length = bss->rsn_ie_len; |
| 1319 | start = iwe_stream_add_point(start, stop, &iwe, buf); |
| 1320 | } |
| 1321 | |
Dan Williams | 00af015 | 2007-08-02 13:14:56 -0400 | [diff] [blame] | 1322 | if (bss->mesh) { |
| 1323 | char custom[MAX_CUSTOM_LEN]; |
| 1324 | char *p = custom; |
| 1325 | |
| 1326 | iwe.cmd = IWEVCUSTOM; |
| 1327 | p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), |
| 1328 | "mesh-type: olpc"); |
| 1329 | iwe.u.data.length = p - custom; |
| 1330 | if (iwe.u.data.length) |
| 1331 | start = iwe_stream_add_point(start, stop, &iwe, custom); |
| 1332 | } |
| 1333 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1334 | out: |
| 1335 | lbs_deb_leave_args(LBS_DEB_SCAN, "start %p", start); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1336 | return start; |
| 1337 | } |
| 1338 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1339 | |
| 1340 | /** |
| 1341 | * @brief Handle Scan Network ioctl |
| 1342 | * |
| 1343 | * @param dev A pointer to net_device structure |
| 1344 | * @param info A pointer to iw_request_info structure |
| 1345 | * @param vwrq A pointer to iw_param structure |
| 1346 | * @param extra A pointer to extra data buf |
| 1347 | * |
| 1348 | * @return 0 --success, otherwise fail |
| 1349 | */ |
| 1350 | int lbs_set_scan(struct net_device *dev, struct iw_request_info *info, |
| 1351 | struct iw_param *wrqu, char *extra) |
| 1352 | { |
| 1353 | struct lbs_private *priv = dev->priv; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1354 | |
| 1355 | lbs_deb_enter(LBS_DEB_SCAN); |
| 1356 | |
| 1357 | if (!netif_running(dev)) |
| 1358 | return -ENETDOWN; |
| 1359 | |
| 1360 | /* mac80211 does this: |
| 1361 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1362 | if (sdata->type != IEEE80211_IF_TYPE_xxx) |
| 1363 | return -EOPNOTSUPP; |
| 1364 | |
| 1365 | if (wrqu->data.length == sizeof(struct iw_scan_req) && |
| 1366 | wrqu->data.flags & IW_SCAN_THIS_ESSID) { |
| 1367 | req = (struct iw_scan_req *)extra; |
| 1368 | ssid = req->essid; |
| 1369 | ssid_len = req->essid_len; |
| 1370 | } |
| 1371 | */ |
| 1372 | |
| 1373 | if (!delayed_work_pending(&priv->scan_work)) |
| 1374 | queue_delayed_work(priv->work_thread, &priv->scan_work, |
| 1375 | msecs_to_jiffies(50)); |
| 1376 | /* set marker that currently a scan is taking place */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1377 | priv->last_scanned_channel = -1; |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1378 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1379 | if (priv->surpriseremoved) |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1380 | return -EIO; |
| 1381 | |
| 1382 | lbs_deb_leave(LBS_DEB_SCAN); |
| 1383 | return 0; |
| 1384 | } |
| 1385 | |
| 1386 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1387 | /** |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1388 | * @brief Handle Retrieve scan table ioctl |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1389 | * |
| 1390 | * @param dev A pointer to net_device structure |
| 1391 | * @param info A pointer to iw_request_info structure |
| 1392 | * @param dwrq A pointer to iw_point structure |
| 1393 | * @param extra A pointer to extra data buf |
| 1394 | * |
| 1395 | * @return 0 --success, otherwise fail |
| 1396 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1397 | int lbs_get_scan(struct net_device *dev, struct iw_request_info *info, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1398 | struct iw_point *dwrq, char *extra) |
| 1399 | { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1400 | #define SCAN_ITEM_SIZE 128 |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1401 | struct lbs_private *priv = dev->priv; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1402 | int err = 0; |
| 1403 | char *ev = extra; |
| 1404 | char *stop = ev + dwrq->length; |
| 1405 | struct bss_descriptor * iter_bss; |
| 1406 | struct bss_descriptor * safe; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1407 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1408 | lbs_deb_enter(LBS_DEB_SCAN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1409 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1410 | /* iwlist should wait until the current scan is finished */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1411 | if (priv->last_scanned_channel) |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1412 | return -EAGAIN; |
| 1413 | |
Dan Williams | 80e78ef | 2007-05-25 22:18:47 -0400 | [diff] [blame] | 1414 | /* Update RSSI if current BSS is a locally created ad-hoc BSS */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1415 | if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1416 | lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1417 | CMD_OPTION_WAITFORRSP, 0, NULL); |
Dan Williams | 80e78ef | 2007-05-25 22:18:47 -0400 | [diff] [blame] | 1418 | } |
| 1419 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1420 | mutex_lock(&priv->lock); |
| 1421 | list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1422 | char * next_ev; |
| 1423 | unsigned long stale_time; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1424 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1425 | if (stop - ev < SCAN_ITEM_SIZE) { |
| 1426 | err = -E2BIG; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1427 | break; |
| 1428 | } |
| 1429 | |
Luis Carlos Cobo | 1e838bf | 2007-08-02 10:51:27 -0400 | [diff] [blame] | 1430 | /* For mesh device, list only mesh networks */ |
| 1431 | if (dev == priv->mesh_dev && !iter_bss->mesh) |
| 1432 | continue; |
| 1433 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1434 | /* Prune old an old scan result */ |
| 1435 | stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE; |
| 1436 | if (time_after(jiffies, stale_time)) { |
| 1437 | list_move_tail (&iter_bss->list, |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1438 | &priv->network_free_list); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1439 | clear_bss_descriptor(iter_bss); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1440 | continue; |
| 1441 | } |
| 1442 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1443 | /* Translate to WE format this entry */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1444 | next_ev = lbs_translate_scan(priv, ev, stop, iter_bss); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1445 | if (next_ev == NULL) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1446 | continue; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1447 | ev = next_ev; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1448 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1449 | mutex_unlock(&priv->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1450 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1451 | dwrq->length = (ev - extra); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1452 | dwrq->flags = 0; |
| 1453 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1454 | lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", err); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1455 | return err; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1456 | } |
| 1457 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1458 | |
| 1459 | |
| 1460 | |
| 1461 | /*********************************************************************/ |
| 1462 | /* */ |
| 1463 | /* Command execution */ |
| 1464 | /* */ |
| 1465 | /*********************************************************************/ |
| 1466 | |
| 1467 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1468 | /** |
| 1469 | * @brief Prepare a scan command to be sent to the firmware |
| 1470 | * |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1471 | * Called via lbs_prepare_and_send_command(priv, CMD_802_11_SCAN, ...) |
| 1472 | * from cmd.c |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1473 | * |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1474 | * Sends a fixed lenght data part (specifying the BSS type and BSSID filters) |
| 1475 | * as well as a variable number/length of TLVs to the firmware. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1476 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1477 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1478 | * @param cmd A pointer to cmd_ds_command structure to be sent to |
| 1479 | * firmware with the cmd_DS_801_11_SCAN structure |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1480 | * @param pdata_buf Void pointer cast of a lbs_scan_cmd_config struct used |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1481 | * to set the fields/TLVs for the command sent to firmware |
| 1482 | * |
| 1483 | * @return 0 or -1 |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1484 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1485 | int lbs_cmd_80211_scan(struct lbs_private *priv, |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1486 | struct cmd_ds_command *cmd, void *pdata_buf) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1487 | { |
| 1488 | struct cmd_ds_802_11_scan *pscan = &cmd->params.scan; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1489 | struct lbs_scan_cmd_config *pscancfg = pdata_buf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1490 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1491 | lbs_deb_enter(LBS_DEB_SCAN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1492 | |
| 1493 | /* Set fixed field variables in scan command */ |
| 1494 | pscan->bsstype = pscancfg->bsstype; |
Dan Williams | 492b6da | 2007-08-02 11:16:07 -0400 | [diff] [blame] | 1495 | memcpy(pscan->bssid, pscancfg->bssid, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1496 | memcpy(pscan->tlvbuffer, pscancfg->tlvbuffer, pscancfg->tlvbufferlen); |
| 1497 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1498 | /* size is equal to the sizeof(fixed portions) + the TLV len + header */ |
Dan Williams | 492b6da | 2007-08-02 11:16:07 -0400 | [diff] [blame] | 1499 | cmd->size = cpu_to_le16(sizeof(pscan->bsstype) + ETH_ALEN |
| 1500 | + pscancfg->tlvbufferlen + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1501 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1502 | lbs_deb_leave(LBS_DEB_SCAN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1503 | return 0; |
| 1504 | } |
| 1505 | |
| 1506 | /** |
| 1507 | * @brief This function handles the command response of scan |
| 1508 | * |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1509 | * Called from handle_cmd_response() in cmdrespc. |
| 1510 | * |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1511 | * The response buffer for the scan command has the following |
| 1512 | * memory layout: |
| 1513 | * |
| 1514 | * .-----------------------------------------------------------. |
| 1515 | * | header (4 * sizeof(u16)): Standard command response hdr | |
| 1516 | * .-----------------------------------------------------------. |
| 1517 | * | bufsize (u16) : sizeof the BSS Description data | |
| 1518 | * .-----------------------------------------------------------. |
| 1519 | * | NumOfSet (u8) : Number of BSS Descs returned | |
| 1520 | * .-----------------------------------------------------------. |
| 1521 | * | BSSDescription data (variable, size given in bufsize) | |
| 1522 | * .-----------------------------------------------------------. |
| 1523 | * | TLV data (variable, size calculated using header->size, | |
| 1524 | * | bufsize and sizeof the fixed fields above) | |
| 1525 | * .-----------------------------------------------------------. |
| 1526 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1527 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1528 | * @param resp A pointer to cmd_ds_command |
| 1529 | * |
| 1530 | * @return 0 or -1 |
| 1531 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1532 | int lbs_ret_80211_scan(struct lbs_private *priv, struct cmd_ds_command *resp) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1533 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1534 | struct cmd_ds_802_11_scan_rsp *pscan; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1535 | struct bss_descriptor * iter_bss; |
| 1536 | struct bss_descriptor * safe; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1537 | u8 *pbssinfo; |
| 1538 | u16 scanrespsize; |
| 1539 | int bytesleft; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1540 | int idx; |
| 1541 | int tlvbufsize; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1542 | int ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1543 | |
Holger Schurig | e56188a | 2007-10-09 14:15:19 +0200 | [diff] [blame] | 1544 | lbs_deb_enter(LBS_DEB_SCAN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1545 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1546 | /* Prune old entries from scan table */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1547 | list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1548 | unsigned long stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE; |
| 1549 | if (time_before(jiffies, stale_time)) |
| 1550 | continue; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1551 | list_move_tail (&iter_bss->list, &priv->network_free_list); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1552 | clear_bss_descriptor(iter_bss); |
| 1553 | } |
| 1554 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1555 | pscan = &resp->params.scanresp; |
| 1556 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1557 | if (pscan->nr_sets > MAX_NETWORK_COUNT) { |
| 1558 | lbs_deb_scan( |
| 1559 | "SCAN_RESP: too many scan results (%d, max %d)!!\n", |
| 1560 | pscan->nr_sets, MAX_NETWORK_COUNT); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1561 | ret = -1; |
| 1562 | goto done; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1563 | } |
| 1564 | |
David Woodhouse | e7240ac | 2007-12-11 17:54:36 -0500 | [diff] [blame^] | 1565 | bytesleft = le16_to_cpu(pscan->bssdescriptsize); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1566 | lbs_deb_scan("SCAN_RESP: bssdescriptsize %d\n", bytesleft); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1567 | |
David Woodhouse | e7240ac | 2007-12-11 17:54:36 -0500 | [diff] [blame^] | 1568 | scanrespsize = le16_to_cpu(resp->size); |
| 1569 | lbs_deb_scan("SCAN_RESP: scan results %d\n", pscan->nr_sets); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1570 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1571 | pbssinfo = pscan->bssdesc_and_tlvbuffer; |
| 1572 | |
| 1573 | /* The size of the TLV buffer is equal to the entire command response |
| 1574 | * size (scanrespsize) minus the fixed fields (sizeof()'s), the |
| 1575 | * BSS Descriptions (bssdescriptsize as bytesLef) and the command |
| 1576 | * response header (S_DS_GEN) |
| 1577 | */ |
| 1578 | tlvbufsize = scanrespsize - (bytesleft + sizeof(pscan->bssdescriptsize) |
| 1579 | + sizeof(pscan->nr_sets) |
| 1580 | + S_DS_GEN); |
| 1581 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1582 | /* |
| 1583 | * Process each scan response returned (pscan->nr_sets). Save |
| 1584 | * the information in the newbssentry and then insert into the |
| 1585 | * driver scan table either as an update to an existing entry |
| 1586 | * or as an addition at the end of the table |
| 1587 | */ |
| 1588 | for (idx = 0; idx < pscan->nr_sets && bytesleft; idx++) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1589 | struct bss_descriptor new; |
| 1590 | struct bss_descriptor * found = NULL; |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1591 | struct bss_descriptor * oldest = NULL; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 1592 | DECLARE_MAC_BUF(mac); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1593 | |
| 1594 | /* Process the data fields and IEs returned for this BSS */ |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1595 | memset(&new, 0, sizeof (struct bss_descriptor)); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1596 | if (lbs_process_bss(&new, &pbssinfo, &bytesleft) != 0) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1597 | /* error parsing the scan response, skipped */ |
| 1598 | lbs_deb_scan("SCAN_RESP: process_bss returned ERROR\n"); |
| 1599 | continue; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1600 | } |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1601 | |
| 1602 | /* Try to find this bss in the scan table */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1603 | list_for_each_entry (iter_bss, &priv->network_list, list) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1604 | if (is_same_network(iter_bss, &new)) { |
| 1605 | found = iter_bss; |
| 1606 | break; |
| 1607 | } |
| 1608 | |
| 1609 | if ((oldest == NULL) || |
| 1610 | (iter_bss->last_scanned < oldest->last_scanned)) |
| 1611 | oldest = iter_bss; |
| 1612 | } |
| 1613 | |
| 1614 | if (found) { |
| 1615 | /* found, clear it */ |
| 1616 | clear_bss_descriptor(found); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1617 | } else if (!list_empty(&priv->network_free_list)) { |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1618 | /* Pull one from the free list */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1619 | found = list_entry(priv->network_free_list.next, |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1620 | struct bss_descriptor, list); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1621 | list_move_tail(&found->list, &priv->network_list); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1622 | } else if (oldest) { |
| 1623 | /* If there are no more slots, expire the oldest */ |
| 1624 | found = oldest; |
| 1625 | clear_bss_descriptor(found); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1626 | list_move_tail(&found->list, &priv->network_list); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1627 | } else { |
| 1628 | continue; |
| 1629 | } |
| 1630 | |
Holger Schurig | ffd074f | 2007-12-07 16:52:10 +0100 | [diff] [blame] | 1631 | lbs_deb_scan("SCAN_RESP: BSSID %s\n", |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 1632 | print_mac(mac, new.bssid)); |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1633 | |
Dan Williams | fcdb53d | 2007-05-25 16:15:56 -0400 | [diff] [blame] | 1634 | /* Copy the locally created newbssentry to the scan table */ |
| 1635 | memcpy(found, &new, offsetof(struct bss_descriptor, list)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1636 | } |
| 1637 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1638 | ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1639 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1640 | done: |
| 1641 | lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); |
| 1642 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1643 | } |