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
12 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
14 #endif /* __linux__ */
17 -main(int argc, char *argv[])
18 +CMD(a80211debug)(int argc, char *argv[])
20 const char *ifname = "ath0";
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
27 #include "net80211/ieee80211.h"
28 #include "net80211/ieee80211_crypto.h"
29 #include "net80211/ieee80211_ioctl.h"
30 +#include "do_multi.h"
32 #ifndef SIOCG80211STATS
33 #define SIOCG80211STATS (SIOCDEVPRIVATE + 2)
38 -main(int argc, char *argv[])
39 +CMD(a80211stats)(int argc, char *argv[])
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
48 #include "net80211/ieee80211.h"
49 #include "net80211/ieee80211_crypto.h"
50 #include "net80211/ieee80211_ioctl.h"
51 +#include "do_multi.h"
54 static const char *progname;
58 #define MAXCHAN ((int)(sizeof(struct ieee80211req_chanlist) * NBBY))
61 -main(int argc, char *argv[])
62 +CMD(athchans)(int argc, char *argv[])
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
74 +#include "do_multi.h"
77 setsysctrl(const char *dev, const char *control , u_long value)
82 -main(int argc, char *argv[])
83 +CMD(athctrl)(int argc, char *argv[])
85 char device[IFNAMSIZ + 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
95 +#include "do_multi.h"
98 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
100 #endif /* __linux__ */
103 -main(int argc, char *argv[])
104 +CMD(athdebug)(int argc, char *argv[])
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
113 #include "net80211/ieee80211.h"
114 #include "net80211/ieee80211_crypto.h"
115 #include "net80211/ieee80211_ioctl.h"
116 +#include "do_multi.h"
119 static const char *progname;
125 -main(int argc, char *argv[])
126 +int CMD(athkey)(int argc, char *argv[])
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
137 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
138 +#include "do_multi.h"
140 static const struct {
146 -main(int argc, char *argv[])
147 +CMD(athstats)(int argc, char *argv[])
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
157 +#include "do_multi.h"
160 +main(int argc, char *argv[])
165 + progname = basename(argv[0]);
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);
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
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[]);
208 +#define CMD(name) name##_init
210 +#define CMD(name) main
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
217 PROGRAMS = athstats 80211stats athkey athchans athctrl \
218 athdebug 80211debug wlanconfig wpakey
220 +OBJS = $(patsubst %,%.o,$(PROGRAMS)) ath_info/ath_info.o
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)
229 -all: all-subdirs $(PROGRAMS)
230 +all: all-subdirs compile
233 for d in $(SUBDIRS); do \
234 $(MAKE) -C $$d || exit 1; \
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
242 - $(CC) -o athkey $(ALL_CFLAGS) $(LDFLAGS) athkey.c
243 -athchans: athchans.c
244 - $(CC) -o athchans $(ALL_CFLAGS) $(LDFLAGS) athchans.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
254 - $(CC) -o wpakey $(ALL_CFLAGS) $(LDFLAGS) wpakey.c
256 + ${CC} $(ALL_CFLAGS) -c -o $@ $<
258 +ifneq ($(DO_MULTI),)
259 +ALL_CFLAGS += -DDO_MULTI=1
260 +madwifi_multi: $(OBJS) do_multi.o
261 + $(CC) $(LDFLAGS) -o $@ $^
263 +compile: madwifi_multi
264 + for i in $(PROGRAMS); do \
265 + ln -sf madwifi_multi $$i; \
269 + $(CC) $(ALL_CFLAGS) -o $@ $@.c
271 +compile: $(PROGRAMS)
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; \
285 - for i in $(PROGRAMS); do \
286 + for i in $(PROGRAMS) $(if $(DO_MULTI),madwifi_multi); do \
287 rm -f $(DESTDIR)$(BINDIR)/$$i; \
289 for i in $(PROGRAMS:=.8); do \
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; \
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
304 #include "net80211/ieee80211.h"
305 #include "net80211/ieee80211_crypto.h"
306 #include "net80211/ieee80211_ioctl.h"
307 +#include "do_multi.h"
310 * These are taken from ieee80211_node.h
312 static int verbose = 0;
315 -main(int argc, char *argv[])
316 +CMD(wlanconfig)(int argc, char *argv[])
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
329 +all: $(if $(DO_MULTI),ath_info.o,$(PROGRAMS))
332 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
335 - $(CC) $(CFLAGS) -c $<
336 + $(CC) $(CFLAGS) $(if $(DO_MULTI),-DDO_MULTI=1 -I..) -c $<
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
345 #include <sys/mman.h>
347 #include <byteswap.h>
348 +#include "do_multi.h"
351 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
352 @@ -1982,7 +1983,8 @@
356 -int main(int argc, char *argv[])
358 +CMD(athinfo)(int argc, char *argv[])
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
369 #include <sys/ioctl.h>
370 +#include "do_multi.h"
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]
378 -int main(int argc, char** argv) {
380 +CMD(wpakey)(int argc, char** argv) {
383 int cipher = IEEE80211_CIPHER_AES_CCM;