2008-11-30 19:24:20 +00:00
|
|
|
diff --git a/scan.c b/scan.c
|
|
|
|
index 387d487..d9cde10 100644
|
|
|
|
--- a/scan.c
|
|
|
|
+++ b/scan.c
|
|
|
|
@@ -4,6 +4,7 @@
|
|
|
|
* IOCTL handlers as well as command preperation and response routines
|
|
|
|
* for sending scan commands to the firmware.
|
|
|
|
*/
|
|
|
|
+#include <linux/version.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <asm/unaligned.h>
|
|
|
|
|
|
|
|
@@ -13,6 +14,14 @@
|
2008-11-30 16:53:16 +00:00
|
|
|
#include "scan.h"
|
|
|
|
#include "cmd.h"
|
|
|
|
|
|
|
|
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
|
2008-11-30 19:24:20 +00:00
|
|
|
+#define IWE(func, ...) func(info, __VA_ARGS__)
|
|
|
|
+#define LCP_LEN iwe_stream_lcp_len(info)
|
2008-11-30 16:53:16 +00:00
|
|
|
+#else
|
|
|
|
+#define IWE(func, ...) func(__VA_ARGS__)
|
2008-11-30 19:24:20 +00:00
|
|
|
+#define LCP_LEN IW_EV_LCP_LEN
|
2008-11-30 16:53:16 +00:00
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
//! Approximate amount of data needed to pass a scan result back to iwlist
|
|
|
|
#define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN \
|
|
|
|
+ IW_ESSID_MAX_SIZE \
|
2008-11-30 19:24:20 +00:00
|
|
|
@@ -776,6 +785,7 @@ out:
|
|
|
|
#define MAX_CUSTOM_LEN 64
|
|
|
|
|
|
|
|
static inline char *lbs_translate_scan(struct lbs_private *priv,
|
|
|
|
+ struct iw_request_info *info,
|
|
|
|
char *start, char *stop,
|
|
|
|
struct bss_descriptor *bss)
|
|
|
|
{
|
|
|
|
@@ -801,24 +811,24 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
|
|
|
|
iwe.cmd = SIOCGIWAP;
|
|
|
|
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
|
|
|
|
memcpy(iwe.u.ap_addr.sa_data, &bss->bssid, ETH_ALEN);
|
|
|
|
- start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN);
|
|
|
|
+ start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_ADDR_LEN);
|
|
|
|
|
|
|
|
/* SSID */
|
2008-11-30 16:53:16 +00:00
|
|
|
iwe.cmd = SIOCGIWESSID;
|
|
|
|
iwe.u.data.flags = 1;
|
|
|
|
iwe.u.data.length = min((uint32_t) bss->ssid_len, (uint32_t) IW_ESSID_MAX_SIZE);
|
|
|
|
- start = iwe_stream_add_point(start, stop, &iwe, bss->ssid);
|
|
|
|
+ start = IWE(iwe_stream_add_point, start, stop, &iwe, bss->ssid);
|
|
|
|
|
|
|
|
/* Mode */
|
|
|
|
iwe.cmd = SIOCGIWMODE;
|
2008-11-30 19:24:20 +00:00
|
|
|
iwe.u.mode = bss->mode;
|
|
|
|
- start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN);
|
|
|
|
+ start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_UINT_LEN);
|
|
|
|
|
|
|
|
/* Frequency */
|
|
|
|
iwe.cmd = SIOCGIWFREQ;
|
|
|
|
iwe.u.freq.m = (long)cfp->freq * 100000;
|
|
|
|
iwe.u.freq.e = 1;
|
|
|
|
- start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN);
|
|
|
|
+ start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_FREQ_LEN);
|
|
|
|
|
|
|
|
/* Add quality statistics */
|
|
|
|
iwe.cmd = IWEVQUAL;
|
|
|
|
@@ -852,7 +862,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
|
|
|
|
nf = priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
|
|
|
|
iwe.u.qual.level = CAL_RSSI(snr, nf);
|
|
|
|
}
|
|
|
|
- start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);
|
|
|
|
+ start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_QUAL_LEN);
|
|
|
|
|
|
|
|
/* Add encryption capability */
|
|
|
|
iwe.cmd = SIOCGIWENCODE;
|
|
|
|
@@ -862,9 +872,9 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
|
2008-11-30 16:53:16 +00:00
|
|
|
iwe.u.data.flags = IW_ENCODE_DISABLED;
|
|
|
|
}
|
|
|
|
iwe.u.data.length = 0;
|
|
|
|
- start = iwe_stream_add_point(start, stop, &iwe, bss->ssid);
|
|
|
|
+ start = IWE(iwe_stream_add_point, start, stop, &iwe, bss->ssid);
|
|
|
|
|
2008-11-30 19:24:20 +00:00
|
|
|
- current_val = start + IW_EV_LCP_LEN;
|
|
|
|
+ current_val = start + LCP_LEN;
|
2008-11-30 16:53:16 +00:00
|
|
|
|
2008-11-30 19:24:20 +00:00
|
|
|
iwe.cmd = SIOCGIWRATE;
|
|
|
|
iwe.u.bitrate.fixed = 0;
|
|
|
|
@@ -874,19 +884,19 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
|
2008-11-30 16:53:16 +00:00
|
|
|
for (j = 0; bss->rates[j] && (j < sizeof(bss->rates)); j++) {
|
|
|
|
/* Bit rate given in 500 kb/s units */
|
|
|
|
iwe.u.bitrate.value = bss->rates[j] * 500000;
|
|
|
|
- current_val = iwe_stream_add_value(start, current_val,
|
|
|
|
+ current_val = IWE(iwe_stream_add_value, start, current_val,
|
|
|
|
stop, &iwe, IW_EV_PARAM_LEN);
|
|
|
|
}
|
|
|
|
if ((bss->mode == IW_MODE_ADHOC) && priv->adhoccreate
|
2008-11-30 19:24:20 +00:00
|
|
|
&& !lbs_ssid_cmp(priv->curbssparams.ssid,
|
2008-11-30 16:53:16 +00:00
|
|
|
priv->curbssparams.ssid_len,
|
|
|
|
bss->ssid, bss->ssid_len)) {
|
|
|
|
iwe.u.bitrate.value = 22 * 500000;
|
|
|
|
- current_val = iwe_stream_add_value(start, current_val,
|
|
|
|
+ current_val = IWE(iwe_stream_add_value, start, current_val,
|
|
|
|
stop, &iwe, IW_EV_PARAM_LEN);
|
|
|
|
}
|
|
|
|
/* Check if we added any event */
|
2008-11-30 19:24:20 +00:00
|
|
|
- if((current_val - start) > IW_EV_LCP_LEN)
|
|
|
|
+ if((current_val - start) > LCP_LEN)
|
|
|
|
start = current_val;
|
|
|
|
|
|
|
|
memset(&iwe, 0, sizeof(iwe));
|
|
|
|
@@ -895,7 +905,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
|
2008-11-30 16:53:16 +00:00
|
|
|
memcpy(buf, bss->wpa_ie, bss->wpa_ie_len);
|
|
|
|
iwe.cmd = IWEVGENIE;
|
|
|
|
iwe.u.data.length = bss->wpa_ie_len;
|
|
|
|
- start = iwe_stream_add_point(start, stop, &iwe, buf);
|
|
|
|
+ start = IWE(iwe_stream_add_point, start, stop, &iwe, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&iwe, 0, sizeof(iwe));
|
2008-11-30 19:24:20 +00:00
|
|
|
@@ -904,7 +914,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
|
2008-11-30 16:53:16 +00:00
|
|
|
memcpy(buf, bss->rsn_ie, bss->rsn_ie_len);
|
|
|
|
iwe.cmd = IWEVGENIE;
|
|
|
|
iwe.u.data.length = bss->rsn_ie_len;
|
|
|
|
- start = iwe_stream_add_point(start, stop, &iwe, buf);
|
|
|
|
+ start = IWE(iwe_stream_add_point, start, stop, &iwe, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bss->mesh) {
|
2008-11-30 19:24:20 +00:00
|
|
|
@@ -915,7 +925,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
|
2008-11-30 16:53:16 +00:00
|
|
|
p += snprintf(p, MAX_CUSTOM_LEN, "mesh-type: olpc");
|
|
|
|
iwe.u.data.length = p - custom;
|
|
|
|
if (iwe.u.data.length)
|
|
|
|
- start = iwe_stream_add_point(start, stop, &iwe, custom);
|
|
|
|
+ start = IWE(iwe_stream_add_point, start, stop, &iwe, custom);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2008-11-30 19:24:20 +00:00
|
|
|
@@ -1036,7 +1046,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Translate to WE format this entry */
|
|
|
|
- next_ev = lbs_translate_scan(priv, ev, stop, iter_bss);
|
|
|
|
+ next_ev = lbs_translate_scan(priv, info, ev, stop, iter_bss);
|
|
|
|
if (next_ev == NULL)
|
|
|
|
continue;
|
|
|
|
ev = next_ev;
|