huge madwifi update (work in progress, disabled by default, compiles but breaks at...
[openwrt/svn-archive/archive.git] / package / madwifi / patches-r3776 / 102-multicall_binary.patch
1 Index: madwifi-trunk-r3776/tools/80211debug.c
2 ===================================================================
3 --- madwifi-trunk-r3776.orig/tools/80211debug.c 2008-07-17 00:22:03.000000000 +0200
4 +++ madwifi-trunk-r3776/tools/80211debug.c 2008-07-17 00:23:16.000000000 +0200
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-r3776/tools/80211stats.c
23 ===================================================================
24 --- madwifi-trunk-r3776.orig/tools/80211stats.c 2008-07-17 00:22:03.000000000 +0200
25 +++ madwifi-trunk-r3776/tools/80211stats.c 2008-07-17 00:23:16.000000000 +0200
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 @@ -241,7 +242,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-r3776/tools/athchans.c
44 ===================================================================
45 --- madwifi-trunk-r3776.orig/tools/athchans.c 2008-07-17 00:22:03.000000000 +0200
46 +++ madwifi-trunk-r3776/tools/athchans.c 2008-07-17 00:23:16.000000000 +0200
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-r3776/tools/athctrl.c
67 ===================================================================
68 --- madwifi-trunk-r3776.orig/tools/athctrl.c 2008-07-17 00:22:03.000000000 +0200
69 +++ madwifi-trunk-r3776/tools/athctrl.c 2008-07-17 00:23:16.000000000 +0200
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-r3776/tools/athdebug.c
88 ===================================================================
89 --- madwifi-trunk-r3776.orig/tools/athdebug.c 2008-07-17 00:22:03.000000000 +0200
90 +++ madwifi-trunk-r3776/tools/athdebug.c 2008-07-17 00:23:16.000000000 +0200
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-r3776/tools/athkey.c
109 ===================================================================
110 --- madwifi-trunk-r3776.orig/tools/athkey.c 2008-07-17 00:22:03.000000000 +0200
111 +++ madwifi-trunk-r3776/tools/athkey.c 2008-07-17 00:23:16.000000000 +0200
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-r3776/tools/athstats.c
131 ===================================================================
132 --- madwifi-trunk-r3776.orig/tools/athstats.c 2008-07-17 00:22:03.000000000 +0200
133 +++ madwifi-trunk-r3776/tools/athstats.c 2008-07-17 00:23:16.000000000 +0200
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-r3776/tools/do_multi.c
152 ===================================================================
153 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
154 +++ madwifi-trunk-r3776/tools/do_multi.c 2008-07-17 00:46:52.000000000 +0200
155 @@ -0,0 +1,36 @@
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, "wpakey") == 0)
184 + ret = wpakey_init(argc, argv);
185 + if(strcmp(progname, "athchans") == 0)
186 + ret = athchans_init(argc, argv);
187 + if(strcmp(progname, "ath_info") == 0)
188 + ret = athinfo_init(argc, argv);
189 +
190 + return ret;
191 +}
192 Index: madwifi-trunk-r3776/tools/do_multi.h
193 ===================================================================
194 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
195 +++ madwifi-trunk-r3776/tools/do_multi.h 2008-07-17 00:23:16.000000000 +0200
196 @@ -0,0 +1,15 @@
197 +#ifdef DO_MULTI
198 +int a80211debug_init(int argc, char *argv[]);
199 +int a80211stats_init(int argc, char *argv[]);
200 +int athchans_init(int argc, char *argv[]);
201 +int athctrl_init(int argc, char *argv[]);
202 +int athdebug_init(int argc, char *argv[]);
203 +int athkey_init(int argc, char *argv[]);
204 +int athstats_init(int argc, char *argv[]);
205 +int wlanconfig_init(int argc, char *argv[]);
206 +int athinfo_init(int argc, char *argv[]);
207 +
208 +#define CMD(name) name##_init
209 +#else
210 +#define CMD(name) main
211 +#endif
212 Index: madwifi-trunk-r3776/tools/Makefile
213 ===================================================================
214 --- madwifi-trunk-r3776.orig/tools/Makefile 2008-07-17 00:22:03.000000000 +0200
215 +++ madwifi-trunk-r3776/tools/Makefile 2008-07-17 00:45:15.000000000 +0200
216 @@ -50,42 +50,43 @@
217 PROGRAMS = athstats 80211stats athkey athchans athctrl \
218 athdebug 80211debug wlanconfig wpakey
219
220 +OBJS = $(patsubst %,%.o,$(PROGRAMS)) ath_info/ath_info.o
221 SUBDIRS = ath_info
222
223 -INCS = -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL)
224 +INCS = -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL) -I$(TOP)/ath
225 CFLAGS = -g -O2 -Wall
226 ALL_CFLAGS = $(CFLAGS) $(INCS)
227 LDFLAGS =
228
229 -all: all-subdirs $(PROGRAMS)
230 +all: all-subdirs compile
231
232 all-subdirs:
233 for d in $(SUBDIRS); do \
234 $(MAKE) -C $$d || exit 1; \
235 done
236
237 -athstats: athstats.c
238 - $(CC) -o athstats $(ALL_CFLAGS) -I$(TOP)/ath $(LDFLAGS) athstats.c
239 -80211stats: 80211stats.c
240 - $(CC) -o 80211stats $(ALL_CFLAGS) $(LDFLAGS) 80211stats.c
241 -athkey: athkey.c
242 - $(CC) -o athkey $(ALL_CFLAGS) $(LDFLAGS) athkey.c
243 -athchans: athchans.c
244 - $(CC) -o athchans $(ALL_CFLAGS) $(LDFLAGS) athchans.c
245 -athctrl: athctrl.c
246 - $(CC) -o athctrl $(ALL_CFLAGS) $(LDFLAGS) athctrl.c
247 -athdebug: athdebug.c
248 - $(CC) -o athdebug $(ALL_CFLAGS) $(LDFLAGS) athdebug.c
249 -wlanconfig: wlanconfig.c
250 - $(CC) -o wlanconfig $(ALL_CFLAGS) $(LDFLAGS) wlanconfig.c
251 -80211debug: 80211debug.c
252 - $(CC) -o 80211debug $(ALL_CFLAGS) $(LDFLAGS) 80211debug.c
253 -wpakey: wpakey.c
254 - $(CC) -o wpakey $(ALL_CFLAGS) $(LDFLAGS) wpakey.c
255 +%.o: %.c
256 + ${CC} $(ALL_CFLAGS) -c -o $@ $<
257 +
258 +ifneq ($(DO_MULTI),)
259 +ALL_CFLAGS += -DDO_MULTI=1
260 +madwifi_multi: $(OBJS) do_multi.o
261 + $(CC) $(LDFLAGS) -o $@ $^
262 +
263 +compile: madwifi_multi
264 + for i in $(PROGRAMS); do \
265 + ln -sf madwifi_multi $$i; \
266 + done
267 +else
268 +$(PROGRAMS):
269 + $(CC) $(ALL_CFLAGS) -o $@ $@.c
270 +
271 +compile: $(PROGRAMS)
272 +endif
273
274 install: all
275 install -d $(DESTDIR)$(BINDIR)
276 - for i in $(PROGRAMS); do \
277 + for i in $(PROGRAMS) $(if $(DO_MULTI),madwifi_multi); do \
278 install $$i $(DESTDIR)$(BINDIR)/$$i; \
279 $(STRIP) $(DESTDIR)$(BINDIR)/$$i; \
280 done
281 @@ -97,7 +98,7 @@
282 done
283
284 uninstall:
285 - for i in $(PROGRAMS); do \
286 + for i in $(PROGRAMS) $(if $(DO_MULTI),madwifi_multi); do \
287 rm -f $(DESTDIR)$(BINDIR)/$$i; \
288 done
289 for i in $(PROGRAMS:=.8); do \
290 @@ -108,7 +109,7 @@
291 done
292
293 clean:
294 - rm -f $(PROGRAMS) core a.out
295 + rm -f $(if $(DO_MULTI), madwifi_multi) $(PROGRAMS) core a.out *.o
296 for d in $(SUBDIRS); do \
297 $(MAKE) -C $$d clean; \
298 done
299 Index: madwifi-trunk-r3776/tools/wlanconfig.c
300 ===================================================================
301 --- madwifi-trunk-r3776.orig/tools/wlanconfig.c 2008-07-17 00:22:03.000000000 +0200
302 +++ madwifi-trunk-r3776/tools/wlanconfig.c 2008-07-17 00:45:42.000000000 +0200
303 @@ -61,6 +61,7 @@
304 #include "net80211/ieee80211.h"
305 #include "net80211/ieee80211_crypto.h"
306 #include "net80211/ieee80211_ioctl.h"
307 +#include "do_multi.h"
308
309 /*
310 * These are taken from ieee80211_node.h
311 @@ -100,7 +101,7 @@
312 static int verbose = 0;
313
314 int
315 -main(int argc, char *argv[])
316 +CMD(wlanconfig)(int argc, char *argv[])
317 {
318 const char *ifname, *cmd;
319 unsigned char bnounit = 0;
320 Index: madwifi-trunk-r3776/tools/ath_info/Makefile
321 ===================================================================
322 --- madwifi-trunk-r3776.orig/tools/ath_info/Makefile 2008-07-17 00:21:42.000000000 +0200
323 +++ madwifi-trunk-r3776/tools/ath_info/Makefile 2008-07-17 00:36:23.000000000 +0200
324 @@ -15,13 +15,13 @@
325 PROGRAMS = ath_info
326 MANS = ath_info.8
327
328 -all: $(PROGRAMS)
329 +all: $(if $(DO_MULTI),ath_info.o,$(PROGRAMS))
330
331 ath_info: ath_info.o
332 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
333
334 .c.o:
335 - $(CC) $(CFLAGS) -c $<
336 + $(CC) $(CFLAGS) $(if $(DO_MULTI),-DDO_MULTI=1 -I..) -c $<
337
338 clean:
339 rm -f *.o $(PROGRAMS)
340 Index: madwifi-trunk-r3776/tools/ath_info/ath_info.c
341 ===================================================================
342 --- madwifi-trunk-r3776.orig/tools/ath_info/ath_info.c 2008-07-17 00:24:08.000000000 +0200
343 +++ madwifi-trunk-r3776/tools/ath_info/ath_info.c 2008-07-17 00:24:15.000000000 +0200
344 @@ -28,6 +28,7 @@
345 #include <sys/mman.h>
346 #include <endian.h>
347 #include <byteswap.h>
348 +#include "do_multi.h"
349
350 #undef ARRAY_SIZE
351 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
352 @@ -1982,7 +1983,8 @@
353 printf("\n");
354 }
355
356 -int main(int argc, char *argv[])
357 +int
358 +CMD(athinfo)(int argc, char *argv[])
359 {
360 unsigned long long dev_addr;
361 u_int16_t srev, phy_rev_5ghz, phy_rev_2ghz, ee_magic;
362 Index: madwifi-trunk-r3776/tools/wpakey.c
363 ===================================================================
364 --- madwifi-trunk-r3776.orig/tools/wpakey.c 2008-07-17 00:21:30.000000000 +0200
365 +++ madwifi-trunk-r3776/tools/wpakey.c 2008-07-17 00:46:18.000000000 +0200
366 @@ -25,6 +25,7 @@
367
368 #include <unistd.h>
369 #include <sys/ioctl.h>
370 +#include "do_multi.h"
371
372 #define MACS "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
373 #define MACP(mac) (mac)[0], (mac)[1], (mac)[2], (mac)[3], (mac)[4], (mac)[5]
374 @@ -234,7 +235,8 @@
375 "", dev);
376 }
377
378 -int main(int argc, char** argv) {
379 +int
380 +CMD(wpakey)(int argc, char** argv) {
381 int keyidx = 0;
382 uint8_t mac[6];
383 int cipher = IEEE80211_CIPHER_AES_CCM;