1 diff --git a/scan.c b/scan.c
2 index 387d487..d9cde10 100644
6 * IOCTL handlers as well as command preperation and response routines
7 * for sending scan commands to the firmware.
9 +#include <linux/version.h>
10 #include <linux/etherdevice.h>
11 #include <asm/unaligned.h>
17 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
18 +#define IWE(func, ...) func(info, __VA_ARGS__)
19 +#define LCP_LEN iwe_stream_lcp_len(info)
21 +#define IWE(func, ...) func(__VA_ARGS__)
22 +#define LCP_LEN IW_EV_LCP_LEN
25 //! Approximate amount of data needed to pass a scan result back to iwlist
26 #define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN \
28 @@ -776,6 +785,7 @@ out:
29 #define MAX_CUSTOM_LEN 64
31 static inline char *lbs_translate_scan(struct lbs_private *priv,
32 + struct iw_request_info *info,
33 char *start, char *stop,
34 struct bss_descriptor *bss)
36 @@ -801,24 +811,24 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
38 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
39 memcpy(iwe.u.ap_addr.sa_data, &bss->bssid, ETH_ALEN);
40 - start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN);
41 + start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_ADDR_LEN);
44 iwe.cmd = SIOCGIWESSID;
46 iwe.u.data.length = min((uint32_t) bss->ssid_len, (uint32_t) IW_ESSID_MAX_SIZE);
47 - start = iwe_stream_add_point(start, stop, &iwe, bss->ssid);
48 + start = IWE(iwe_stream_add_point, start, stop, &iwe, bss->ssid);
51 iwe.cmd = SIOCGIWMODE;
52 iwe.u.mode = bss->mode;
53 - start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN);
54 + start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_UINT_LEN);
57 iwe.cmd = SIOCGIWFREQ;
58 iwe.u.freq.m = (long)cfp->freq * 100000;
60 - start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN);
61 + start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_FREQ_LEN);
63 /* Add quality statistics */
65 @@ -852,7 +862,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
66 nf = priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
67 iwe.u.qual.level = CAL_RSSI(snr, nf);
69 - start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);
70 + start = IWE(iwe_stream_add_event, start, stop, &iwe, IW_EV_QUAL_LEN);
72 /* Add encryption capability */
73 iwe.cmd = SIOCGIWENCODE;
74 @@ -862,9 +872,9 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
75 iwe.u.data.flags = IW_ENCODE_DISABLED;
77 iwe.u.data.length = 0;
78 - start = iwe_stream_add_point(start, stop, &iwe, bss->ssid);
79 + start = IWE(iwe_stream_add_point, start, stop, &iwe, bss->ssid);
81 - current_val = start + IW_EV_LCP_LEN;
82 + current_val = start + LCP_LEN;
84 iwe.cmd = SIOCGIWRATE;
85 iwe.u.bitrate.fixed = 0;
86 @@ -874,19 +884,19 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
87 for (j = 0; bss->rates[j] && (j < sizeof(bss->rates)); j++) {
88 /* Bit rate given in 500 kb/s units */
89 iwe.u.bitrate.value = bss->rates[j] * 500000;
90 - current_val = iwe_stream_add_value(start, current_val,
91 + current_val = IWE(iwe_stream_add_value, start, current_val,
92 stop, &iwe, IW_EV_PARAM_LEN);
94 if ((bss->mode == IW_MODE_ADHOC) && priv->adhoccreate
95 && !lbs_ssid_cmp(priv->curbssparams.ssid,
96 priv->curbssparams.ssid_len,
97 bss->ssid, bss->ssid_len)) {
98 iwe.u.bitrate.value = 22 * 500000;
99 - current_val = iwe_stream_add_value(start, current_val,
100 + current_val = IWE(iwe_stream_add_value, start, current_val,
101 stop, &iwe, IW_EV_PARAM_LEN);
103 /* Check if we added any event */
104 - if((current_val - start) > IW_EV_LCP_LEN)
105 + if((current_val - start) > LCP_LEN)
108 memset(&iwe, 0, sizeof(iwe));
109 @@ -895,7 +905,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
110 memcpy(buf, bss->wpa_ie, bss->wpa_ie_len);
112 iwe.u.data.length = bss->wpa_ie_len;
113 - start = iwe_stream_add_point(start, stop, &iwe, buf);
114 + start = IWE(iwe_stream_add_point, start, stop, &iwe, buf);
117 memset(&iwe, 0, sizeof(iwe));
118 @@ -904,7 +914,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
119 memcpy(buf, bss->rsn_ie, bss->rsn_ie_len);
121 iwe.u.data.length = bss->rsn_ie_len;
122 - start = iwe_stream_add_point(start, stop, &iwe, buf);
123 + start = IWE(iwe_stream_add_point, start, stop, &iwe, buf);
127 @@ -915,7 +925,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
128 p += snprintf(p, MAX_CUSTOM_LEN, "mesh-type: olpc");
129 iwe.u.data.length = p - custom;
130 if (iwe.u.data.length)
131 - start = iwe_stream_add_point(start, stop, &iwe, custom);
132 + start = IWE(iwe_stream_add_point, start, stop, &iwe, custom);
136 @@ -1036,7 +1046,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
139 /* Translate to WE format this entry */
140 - next_ev = lbs_translate_scan(priv, ev, stop, iter_bss);
141 + next_ev = lbs_translate_scan(priv, info, ev, stop, iter_bss);