madwifi: refresh patches
[openwrt/openwrt.git] / package / madwifi / patches / 102-multicall_binary.patch
1 Index: madwifi-trunk-r3314/tools/80211debug.c
2 ===================================================================
3 --- madwifi-trunk-r3314.orig/tools/80211debug.c
4 +++ madwifi-trunk-r3314/tools/80211debug.c
5 @@ -48,6 +48,7 @@
6 #include <ctype.h>
7 #include <getopt.h>
8 #include <err.h>
9 +#include "do_multi.h"
10
11 #undef ARRAY_SIZE
12 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
13 @@ -185,7 +186,7 @@
14 #endif /* __linux__ */
15
16 int
17 -main(int argc, char *argv[])
18 +CMD(a80211debug)(int argc, char *argv[])
19 {
20 const char *ifname = "ath0";
21 const char *cp, *tp;
22 Index: madwifi-trunk-r3314/tools/80211stats.c
23 ===================================================================
24 --- madwifi-trunk-r3314.orig/tools/80211stats.c
25 +++ madwifi-trunk-r3314/tools/80211stats.c
26 @@ -59,6 +59,7 @@
27 #include "net80211/ieee80211.h"
28 #include "net80211/ieee80211_crypto.h"
29 #include "net80211/ieee80211_ioctl.h"
30 +#include "do_multi.h"
31
32 #ifndef SIOCG80211STATS
33 #define SIOCG80211STATS (SIOCDEVPRIVATE + 2)
34 @@ -240,7 +241,7 @@
35 }
36
37 int
38 -main(int argc, char *argv[])
39 +CMD(a80211stats)(int argc, char *argv[])
40 {
41 int c, len;
42 struct ieee80211req_sta_info *si;
43 Index: madwifi-trunk-r3314/tools/athchans.c
44 ===================================================================
45 --- madwifi-trunk-r3314.orig/tools/athchans.c
46 +++ madwifi-trunk-r3314/tools/athchans.c
47 @@ -58,6 +58,7 @@
48 #include "net80211/ieee80211.h"
49 #include "net80211/ieee80211_crypto.h"
50 #include "net80211/ieee80211_ioctl.h"
51 +#include "do_multi.h"
52
53 static int s = -1;
54 static const char *progname;
55 @@ -140,8 +141,9 @@
56 }
57
58 #define MAXCHAN ((int)(sizeof(struct ieee80211req_chanlist) * NBBY))
59 +
60 int
61 -main(int argc, char *argv[])
62 +CMD(athchans)(int argc, char *argv[])
63 {
64 const char *ifname = "wifi0";
65 struct ieee80211req_chanlist chanlist;
66 Index: madwifi-trunk-r3314/tools/athctrl.c
67 ===================================================================
68 --- madwifi-trunk-r3314.orig/tools/athctrl.c
69 +++ madwifi-trunk-r3314/tools/athctrl.c
70 @@ -52,6 +52,7 @@
71 #include <err.h>
72
73 #include <net/if.h>
74 +#include "do_multi.h"
75
76 static int
77 setsysctrl(const char *dev, const char *control , u_long value)
78 @@ -88,7 +89,7 @@
79 }
80
81 int
82 -main(int argc, char *argv[])
83 +CMD(athctrl)(int argc, char *argv[])
84 {
85 char device[IFNAMSIZ + 1];
86 int distance = -1;
87 Index: madwifi-trunk-r3314/tools/athdebug.c
88 ===================================================================
89 --- madwifi-trunk-r3314.orig/tools/athdebug.c
90 +++ madwifi-trunk-r3314/tools/athdebug.c
91 @@ -51,6 +51,7 @@
92 #include <ctype.h>
93 #include <getopt.h>
94 #include <err.h>
95 +#include "do_multi.h"
96
97 #undef ARRAY_SIZE
98 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
99 @@ -194,7 +195,7 @@
100 #endif /* __linux__ */
101
102 int
103 -main(int argc, char *argv[])
104 +CMD(athdebug)(int argc, char *argv[])
105 {
106 #ifdef __linux__
107 const char *ifname = "wifi0";
108 Index: madwifi-trunk-r3314/tools/athkey.c
109 ===================================================================
110 --- madwifi-trunk-r3314.orig/tools/athkey.c
111 +++ madwifi-trunk-r3314/tools/athkey.c
112 @@ -58,6 +58,7 @@
113 #include "net80211/ieee80211.h"
114 #include "net80211/ieee80211_crypto.h"
115 #include "net80211/ieee80211_ioctl.h"
116 +#include "do_multi.h"
117
118 static int s = -1;
119 static const char *progname;
120 @@ -213,8 +214,7 @@
121 exit(-1);
122 }
123
124 -int
125 -main(int argc, char *argv[])
126 +int CMD(athkey)(int argc, char *argv[])
127 {
128 const char *ifname = "wifi0";
129 struct ieee80211req_key setkey;
130 Index: madwifi-trunk-r3314/tools/athstats.c
131 ===================================================================
132 --- madwifi-trunk-r3314.orig/tools/athstats.c
133 +++ madwifi-trunk-r3314/tools/athstats.c
134 @@ -65,6 +65,7 @@
135
136 #undef ARRAY_SIZE
137 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
138 +#include "do_multi.h"
139
140 static const struct {
141 u_int phyerr;
142 @@ -228,7 +229,7 @@
143 }
144
145 int
146 -main(int argc, char *argv[])
147 +CMD(athstats)(int argc, char *argv[])
148 {
149 #ifdef __linux__
150 const char *ifname = "wifi0";
151 Index: madwifi-trunk-r3314/tools/do_multi.c
152 ===================================================================
153 --- /dev/null
154 +++ madwifi-trunk-r3314/tools/do_multi.c
155 @@ -0,0 +1,32 @@
156 +#include <string.h>
157 +#include "do_multi.h"
158 +
159 +int
160 +main(int argc, char *argv[])
161 +{
162 + char *progname;
163 + int ret = 0;
164 +
165 + progname = basename(argv[0]);
166 +
167 + if(strcmp(progname, "80211debug") == 0)
168 + ret = a80211debug_init(argc, argv);
169 + if(strcmp(progname, "80211stats") == 0)
170 + ret = a80211stats_init(argc, argv);
171 + if(strcmp(progname, "athchans") == 0)
172 + ret = athchans_init(argc, argv);
173 + if(strcmp(progname, "athctrl") == 0)
174 + ret = athctrl_init(argc, argv);
175 + if(strcmp(progname, "athdebug") == 0)
176 + ret = athdebug_init(argc, argv);
177 + if(strcmp(progname, "athkey") == 0)
178 + ret = athkey_init(argc, argv);
179 + if(strcmp(progname, "athstats") == 0)
180 + ret = athstats_init(argc, argv);
181 + if(strcmp(progname, "wlanconfig") == 0)
182 + ret = wlanconfig_init(argc, argv);
183 + if(strcmp(progname, "ath_info") == 0)
184 + ret = athinfo_init(argc, argv);
185 +
186 + return ret;
187 +}
188 Index: madwifi-trunk-r3314/tools/do_multi.h
189 ===================================================================
190 --- /dev/null
191 +++ madwifi-trunk-r3314/tools/do_multi.h
192 @@ -0,0 +1,15 @@
193 +#ifdef DO_MULTI
194 +int a80211debug_init(int argc, char *argv[]);
195 +int a80211stats_init(int argc, char *argv[]);
196 +int athchans_init(int argc, char *argv[]);
197 +int athctrl_init(int argc, char *argv[]);
198 +int athdebug_init(int argc, char *argv[]);
199 +int athkey_init(int argc, char *argv[]);
200 +int athstats_init(int argc, char *argv[]);
201 +int wlanconfig_init(int argc, char *argv[]);
202 +int athinfo_init(int argc, char *argv[]);
203 +
204 +#define CMD(name) name##_init
205 +#else
206 +#define CMD(name) main
207 +#endif
208 Index: madwifi-trunk-r3314/tools/Makefile
209 ===================================================================
210 --- madwifi-trunk-r3314.orig/tools/Makefile
211 +++ madwifi-trunk-r3314/tools/Makefile
212 @@ -46,56 +46,55 @@
213 HAL= $(TOP)/hal
214 endif
215
216 +all: compile
217
218 -ALL= athstats 80211stats athkey athchans athctrl \
219 +ALLPROGS= athstats 80211stats athkey athchans athctrl \
220 athdebug 80211debug wlanconfig ath_info
221
222 -all: $(ALL)
223 +OBJS= $(patsubst %,%.o,$(ALLPROGS))
224
225 -INCS= -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL)
226 +INCS= -I. -I../ath -I$(HAL) -I$(TOP) -I$(ATH_HAL)
227 CFLAGS= -g -O2 -Wall
228 ALL_CFLAGS= $(CFLAGS) $(INCS)
229 LDFLAGS=
230
231 -all: $(ALL)
232
233 -athstats: athstats.c
234 - $(CC) -o athstats $(ALL_CFLAGS) -I$(TOP)/ath $(LDFLAGS) athstats.c
235 -80211stats: 80211stats.c
236 - $(CC) -o 80211stats $(ALL_CFLAGS) $(LDFLAGS) 80211stats.c
237 -athkey: athkey.c
238 - $(CC) -o athkey $(ALL_CFLAGS) $(LDFLAGS) athkey.c
239 -athchans: athchans.c
240 - $(CC) -o athchans $(ALL_CFLAGS) $(LDFLAGS) athchans.c
241 -athctrl: athctrl.c
242 - $(CC) -o athctrl $(ALL_CFLAGS) $(LDFLAGS) athctrl.c
243 -athdebug: athdebug.c
244 - $(CC) -o athdebug $(ALL_CFLAGS) $(LDFLAGS) athdebug.c
245 -wlanconfig: wlanconfig.c
246 - $(CC) -o wlanconfig $(ALL_CFLAGS) $(LDFLAGS) wlanconfig.c
247 -80211debug: 80211debug.c
248 - $(CC) -o 80211debug $(ALL_CFLAGS) $(LDFLAGS) 80211debug.c
249 -ath_info: ath_info.c
250 - $(CC) -o ath_info $(CFLAGS) ath_info.c
251 +ifneq ($(DO_MULTI),)
252 +ALL_CFLAGS += -DDO_MULTI=1
253 +%.o: %.c
254 + ${CC} $(ALL_CFLAGS) -c -o $@ $<
255 +
256 +madwifi_multi: $(OBJS) do_multi.o
257 + $(CC) -o $@ $^
258 +
259 +compile: madwifi_multi
260 + for i in $(ALLPROGS); do \
261 + ln -s -f madwifi_multi $$i; \
262 + done
263 +else
264 +$(ALLPROGS):
265 + $(CC) $(ALL_CFLAGS) -o $@ $@.c
266 +
267 +compile: $(ALLPROGS)
268 +endif
269
270
271 install: $(ALL)
272 install -d $(DESTDIR)$(BINDIR)
273 - for i in $(ALL); do \
274 + for i in $(ALLPROGS) $(if $(DO_MULTI),madwifi_multi); do \
275 install $$i $(DESTDIR)$(BINDIR)/$$i; \
276 - $(STRIP) $(DESTDIR)$(BINDIR)/$$i; \
277 done
278 install -d $(DESTDIR)$(MANDIR)/man8
279 install -m 0644 man/*.8 $(DESTDIR)$(MANDIR)/man8
280 install $(TOP)/scripts/madwifi-unload $(DESTDIR)$(BINDIR)/madwifi-unload
281
282 uninstall:
283 - for i in $(ALL); do \
284 + for i in $(ALLPROGS) $(if $(DO_MULTI),madwifi_multi); do \
285 rm -f $(DESTDIR)$(BINDIR)/$$i; \
286 done
287 - for i in $(ALL:=.8); do \
288 - rm -f $(DESTDIR)$(MANDIR)/man8/$$i; \
289 + for i in $(ALLPROGS); do \
290 + rm -f $(DESTDIR)$(MANDIR)/man8/$$i.8; \
291 done
292
293 clean:
294 - rm -f $(ALL) core a.out
295 + rm -f $(ALLPROGS) madwifi_multi *.o core a.out
296 Index: madwifi-trunk-r3314/tools/wlanconfig.c
297 ===================================================================
298 --- madwifi-trunk-r3314.orig/tools/wlanconfig.c
299 +++ madwifi-trunk-r3314/tools/wlanconfig.c
300 @@ -61,6 +61,7 @@
301 #include "net80211/ieee80211.h"
302 #include "net80211/ieee80211_crypto.h"
303 #include "net80211/ieee80211_ioctl.h"
304 +#include "do_multi.h"
305
306 /*
307 * These are taken from ieee80211_node.h
308 @@ -100,7 +101,7 @@
309 static int verbose = 0;
310
311 int
312 -main(int argc, char *argv[])
313 +CMD(wlanconfig)(int argc, char *argv[])
314 {
315 const char *ifname, *cmd;
316 unsigned char bnounit = 0;
317 Index: madwifi-trunk-r3314/tools/ath_info.c
318 ===================================================================
319 --- madwifi-trunk-r3314.orig/tools/ath_info.c
320 +++ madwifi-trunk-r3314/tools/ath_info.c
321 @@ -98,6 +98,7 @@
322 #include <sys/mman.h>
323 #include <endian.h>
324 #include <byteswap.h>
325 +#include "do_multi.h"
326
327 #undef ARRAY_SIZE
328 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
329 @@ -738,7 +739,8 @@
330 "unlawful radio transmissions!\n\n");
331 }
332
333 -int main(int argc, char *argv[])
334 +int
335 +CMD(athinfo)(int argc, char *argv[])
336 {
337 u_int32_t dev_addr;
338 u_int16_t eeprom_header, srev, phy_rev_5ghz, phy_rev_2ghz;