Fix libertas compile on 2.6.27.
[openwrt/openwrt.git] / package / libertas / patches / 100-wext.patch
1 diff --git a/scan.c b/scan.c
2 index 387d487..d9cde10 100644
3 --- a/scan.c
4 +++ b/scan.c
5 @@ -4,6 +4,7 @@
6 * IOCTL handlers as well as command preperation and response routines
7 * for sending scan commands to the firmware.
8 */
9 +#include <linux/version.h>
10 #include <linux/etherdevice.h>
11 #include <asm/unaligned.h>
12
13 @@ -13,6 +14,14 @@
14 #include "scan.h"
15 #include "cmd.h"
16
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)
20 +#else
21 +#define IWE(func, ...) func(__VA_ARGS__)
22 +#define LCP_LEN IW_EV_LCP_LEN
23 +#endif
24 +
25 //! Approximate amount of data needed to pass a scan result back to iwlist
26 #define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN \
27 + IW_ESSID_MAX_SIZE \
28 @@ -776,6 +785,7 @@ out:
29 #define MAX_CUSTOM_LEN 64
30
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)
35 {
36 @@ -801,24 +811,24 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
37 iwe.cmd = SIOCGIWAP;
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);
42
43 /* SSID */
44 iwe.cmd = SIOCGIWESSID;
45 iwe.u.data.flags = 1;
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);
49
50 /* Mode */
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);
55
56 /* Frequency */
57 iwe.cmd = SIOCGIWFREQ;
58 iwe.u.freq.m = (long)cfp->freq * 100000;
59 iwe.u.freq.e = 1;
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);
62
63 /* Add quality statistics */
64 iwe.cmd = IWEVQUAL;
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);
68 }
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);
71
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;
76 }
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);
80
81 - current_val = start + IW_EV_LCP_LEN;
82 + current_val = start + LCP_LEN;
83
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);
93 }
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);
102 }
103 /* Check if we added any event */
104 - if((current_val - start) > IW_EV_LCP_LEN)
105 + if((current_val - start) > LCP_LEN)
106 start = current_val;
107
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);
111 iwe.cmd = IWEVGENIE;
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);
115 }
116
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);
120 iwe.cmd = IWEVGENIE;
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);
124 }
125
126 if (bss->mesh) {
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);
133 }
134
135 out:
136 @@ -1036,7 +1046,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
137 }
138
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);
142 if (next_ev == NULL)
143 continue;
144 ev = next_ev;