diff options
author | John W. Linville <linville@tuxdriver.com> | 2008-09-24 18:13:14 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-10-31 19:00:46 -0400 |
commit | 7e272fcff6f0a32a3d46e600ea5895f6058f4e2d (patch) | |
tree | 39857028913862af4d71170d1f16ee360ba49115 /drivers/net/wireless/iwlwifi/iwl-scan.c | |
parent | ddf4ac53fb8a12a027c0486db743ae040f45b56a (diff) |
wireless: consolidate on a single escape_essid implementation
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-scan.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-scan.c | 52 |
1 files changed, 6 insertions, 46 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 86b74571b513..1cc8aa592821 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c | |||
@@ -25,8 +25,10 @@ | |||
25 | * Tomas Winkler <tomas.winkler@intel.com> | 25 | * Tomas Winkler <tomas.winkler@intel.com> |
26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
27 | *****************************************************************************/ | 27 | *****************************************************************************/ |
28 | #include <net/mac80211.h> | 28 | #include <linux/types.h> |
29 | #include <linux/etherdevice.h> | 29 | #include <linux/etherdevice.h> |
30 | #include <net/lib80211.h> | ||
31 | #include <net/mac80211.h> | ||
30 | 32 | ||
31 | #include "iwl-eeprom.h" | 33 | #include "iwl-eeprom.h" |
32 | #include "iwl-dev.h" | 34 | #include "iwl-dev.h" |
@@ -64,48 +66,6 @@ | |||
64 | #define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) | 66 | #define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) |
65 | 67 | ||
66 | 68 | ||
67 | static int iwl_is_empty_essid(const char *essid, int essid_len) | ||
68 | { | ||
69 | /* Single white space is for Linksys APs */ | ||
70 | if (essid_len == 1 && essid[0] == ' ') | ||
71 | return 1; | ||
72 | |||
73 | /* Otherwise, if the entire essid is 0, we assume it is hidden */ | ||
74 | while (essid_len) { | ||
75 | essid_len--; | ||
76 | if (essid[essid_len] != '\0') | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | return 1; | ||
81 | } | ||
82 | |||
83 | |||
84 | |||
85 | static const char *iwl_escape_essid(const char *essid, u8 essid_len) | ||
86 | { | ||
87 | static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; | ||
88 | const char *s = essid; | ||
89 | char *d = escaped; | ||
90 | |||
91 | if (iwl_is_empty_essid(essid, essid_len)) { | ||
92 | memcpy(escaped, "<hidden>", sizeof("<hidden>")); | ||
93 | return escaped; | ||
94 | } | ||
95 | |||
96 | essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE); | ||
97 | while (essid_len--) { | ||
98 | if (*s == '\0') { | ||
99 | *d++ = '\\'; | ||
100 | *d++ = '0'; | ||
101 | s++; | ||
102 | } else | ||
103 | *d++ = *s++; | ||
104 | } | ||
105 | *d = '\0'; | ||
106 | return escaped; | ||
107 | } | ||
108 | |||
109 | /** | 69 | /** |
110 | * iwl_scan_cancel - Cancel any currently executing HW scan | 70 | * iwl_scan_cancel - Cancel any currently executing HW scan |
111 | * | 71 | * |
@@ -775,8 +735,8 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
775 | /* We should add the ability for user to lock to PASSIVE ONLY */ | 735 | /* We should add the ability for user to lock to PASSIVE ONLY */ |
776 | if (priv->one_direct_scan) { | 736 | if (priv->one_direct_scan) { |
777 | IWL_DEBUG_SCAN("Start direct scan for '%s'\n", | 737 | IWL_DEBUG_SCAN("Start direct scan for '%s'\n", |
778 | iwl_escape_essid(priv->direct_ssid, | 738 | escape_ssid(priv->direct_ssid, |
779 | priv->direct_ssid_len)); | 739 | priv->direct_ssid_len)); |
780 | scan->direct_scan[0].id = WLAN_EID_SSID; | 740 | scan->direct_scan[0].id = WLAN_EID_SSID; |
781 | scan->direct_scan[0].len = priv->direct_ssid_len; | 741 | scan->direct_scan[0].len = priv->direct_ssid_len; |
782 | memcpy(scan->direct_scan[0].ssid, | 742 | memcpy(scan->direct_scan[0].ssid, |
@@ -784,7 +744,7 @@ static void iwl_bg_request_scan(struct work_struct *data) | |||
784 | n_probes++; | 744 | n_probes++; |
785 | } else if (!iwl_is_associated(priv) && priv->essid_len) { | 745 | } else if (!iwl_is_associated(priv) && priv->essid_len) { |
786 | IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n", | 746 | IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n", |
787 | iwl_escape_essid(priv->essid, priv->essid_len)); | 747 | escape_ssid(priv->essid, priv->essid_len)); |
788 | scan->direct_scan[0].id = WLAN_EID_SSID; | 748 | scan->direct_scan[0].id = WLAN_EID_SSID; |
789 | scan->direct_scan[0].len = priv->essid_len; | 749 | scan->direct_scan[0].len = priv->essid_len; |
790 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); | 750 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); |