aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl3945-base.c
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2008-09-24 18:13:14 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-10-31 19:00:46 -0400
commit7e272fcff6f0a32a3d46e600ea5895f6058f4e2d (patch)
tree39857028913862af4d71170d1f16ee360ba49115 /drivers/net/wireless/iwlwifi/iwl3945-base.c
parentddf4ac53fb8a12a027c0486db743ae040f45b56a (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/iwl3945-base.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c48
1 files changed, 4 insertions, 44 deletions
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
110static 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
126static 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)