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 | |
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')
-rw-r--r-- | drivers/net/wireless/iwlwifi/Kconfig | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-scan.c | 52 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 48 |
3 files changed, 12 insertions, 90 deletions
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig index b0ac0ce3fb9f..47bee0ee0a7c 100644 --- a/drivers/net/wireless/iwlwifi/Kconfig +++ b/drivers/net/wireless/iwlwifi/Kconfig | |||
@@ -4,6 +4,7 @@ config IWLWIFI | |||
4 | config IWLCORE | 4 | config IWLCORE |
5 | tristate "Intel Wireless Wifi Core" | 5 | tristate "Intel Wireless Wifi Core" |
6 | depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL | 6 | depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL |
7 | select LIB80211 | ||
7 | select IWLWIFI | 8 | select IWLWIFI |
8 | select MAC80211_LEDS if IWLWIFI_LEDS | 9 | select MAC80211_LEDS if IWLWIFI_LEDS |
9 | select LEDS_CLASS if IWLWIFI_LEDS | 10 | select LEDS_CLASS if IWLWIFI_LEDS |
@@ -105,6 +106,7 @@ config IWL3945 | |||
105 | tristate "Intel PRO/Wireless 3945ABG/BG Network Connection" | 106 | tristate "Intel PRO/Wireless 3945ABG/BG Network Connection" |
106 | depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL | 107 | depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL |
107 | select FW_LOADER | 108 | select FW_LOADER |
109 | select LIB80211 | ||
108 | select IWLWIFI | 110 | select IWLWIFI |
109 | select MAC80211_LEDS if IWL3945_LEDS | 111 | select MAC80211_LEDS if IWL3945_LEDS |
110 | select LEDS_CLASS if IWL3945_LEDS | 112 | select LEDS_CLASS if IWL3945_LEDS |
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); |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 2cd33b4e9e13..370cc46b4888 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/if_arp.h> | 41 | #include <linux/if_arp.h> |
42 | 42 | ||
43 | #include <net/ieee80211_radiotap.h> | 43 | #include <net/ieee80211_radiotap.h> |
44 | #include <net/lib80211.h> | ||
44 | #include <net/mac80211.h> | 45 | #include <net/mac80211.h> |
45 | 46 | ||
46 | #include <asm/div64.h> | 47 | #include <asm/div64.h> |
@@ -107,46 +108,6 @@ static const struct ieee80211_supported_band *iwl3945_get_band( | |||
107 | return priv->hw->wiphy->bands[band]; | 108 | return priv->hw->wiphy->bands[band]; |
108 | } | 109 | } |
109 | 110 | ||
110 | static int iwl3945_is_empty_essid(const char *essid, int essid_len) | ||
111 | { | ||
112 | /* Single white space is for Linksys APs */ | ||
113 | if (essid_len == 1 && essid[0] == ' ') | ||
114 | return 1; | ||
115 | |||
116 | /* Otherwise, if the entire essid is 0, we assume it is hidden */ | ||
117 | while (essid_len) { | ||
118 | essid_len--; | ||
119 | if (essid[essid_len] != '\0') | ||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | return 1; | ||
124 | } | ||
125 | |||
126 | static const char *iwl3945_escape_essid(const char *essid, u8 essid_len) | ||
127 | { | ||
128 | static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; | ||
129 | const char *s = essid; | ||
130 | char *d = escaped; | ||
131 | |||
132 | if (iwl3945_is_empty_essid(essid, essid_len)) { | ||
133 | memcpy(escaped, "<hidden>", sizeof("<hidden>")); | ||
134 | return escaped; | ||
135 | } | ||
136 | |||
137 | essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE); | ||
138 | while (essid_len--) { | ||
139 | if (*s == '\0') { | ||
140 | *d++ = '\\'; | ||
141 | *d++ = '0'; | ||
142 | s++; | ||
143 | } else | ||
144 | *d++ = *s++; | ||
145 | } | ||
146 | *d = '\0'; | ||
147 | return escaped; | ||
148 | } | ||
149 | |||
150 | /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** | 111 | /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** |
151 | * DMA services | 112 | * DMA services |
152 | * | 113 | * |
@@ -6193,8 +6154,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data) | |||
6193 | if (priv->one_direct_scan) { | 6154 | if (priv->one_direct_scan) { |
6194 | IWL_DEBUG_SCAN | 6155 | IWL_DEBUG_SCAN |
6195 | ("Kicking off one direct scan for '%s'\n", | 6156 | ("Kicking off one direct scan for '%s'\n", |
6196 | iwl3945_escape_essid(priv->direct_ssid, | 6157 | escape_ssid(priv->direct_ssid, priv->direct_ssid_len)); |
6197 | priv->direct_ssid_len)); | ||
6198 | scan->direct_scan[0].id = WLAN_EID_SSID; | 6158 | scan->direct_scan[0].id = WLAN_EID_SSID; |
6199 | scan->direct_scan[0].len = priv->direct_ssid_len; | 6159 | scan->direct_scan[0].len = priv->direct_ssid_len; |
6200 | memcpy(scan->direct_scan[0].ssid, | 6160 | memcpy(scan->direct_scan[0].ssid, |
@@ -6203,7 +6163,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data) | |||
6203 | } else if (!iwl3945_is_associated(priv) && priv->essid_len) { | 6163 | } else if (!iwl3945_is_associated(priv) && priv->essid_len) { |
6204 | IWL_DEBUG_SCAN | 6164 | IWL_DEBUG_SCAN |
6205 | ("Kicking off one direct scan for '%s' when not associated\n", | 6165 | ("Kicking off one direct scan for '%s' when not associated\n", |
6206 | iwl3945_escape_essid(priv->essid, priv->essid_len)); | 6166 | escape_ssid(priv->essid, priv->essid_len)); |
6207 | scan->direct_scan[0].id = WLAN_EID_SSID; | 6167 | scan->direct_scan[0].id = WLAN_EID_SSID; |
6208 | scan->direct_scan[0].len = priv->essid_len; | 6168 | scan->direct_scan[0].len = priv->essid_len; |
6209 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); | 6169 | memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); |
@@ -7018,7 +6978,7 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) | |||
7018 | } | 6978 | } |
7019 | if (len) { | 6979 | if (len) { |
7020 | IWL_DEBUG_SCAN("direct scan for %s [%d]\n ", | 6980 | IWL_DEBUG_SCAN("direct scan for %s [%d]\n ", |
7021 | iwl3945_escape_essid(ssid, len), (int)len); | 6981 | escape_ssid(ssid, len), (int)len); |
7022 | 6982 | ||
7023 | priv->one_direct_scan = 1; | 6983 | priv->one_direct_scan = 1; |
7024 | priv->direct_ssid_len = (u8) | 6984 | priv->direct_ssid_len = (u8) |