1 --- a/tools/80211debug.c
2 +++ b/tools/80211debug.c
10 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
12 #endif /* __linux__ */
15 -main(int argc, char *argv[])
16 +CMD(a80211debug)(int argc, char *argv[])
18 const char *ifname = "ath0";
20 --- a/tools/80211stats.c
21 +++ b/tools/80211stats.c
23 #include "net80211/ieee80211.h"
24 #include "net80211/ieee80211_crypto.h"
25 #include "net80211/ieee80211_ioctl.h"
26 +#include "do_multi.h"
28 #ifndef SIOCG80211STATS
29 #define SIOCG80211STATS (SIOCDEVPRIVATE + 2)
34 -main(int argc, char *argv[])
35 +CMD(a80211stats)(int argc, char *argv[])
38 struct ieee80211req_sta_info *si;
39 --- a/tools/athchans.c
40 +++ b/tools/athchans.c
42 #include "net80211/ieee80211.h"
43 #include "net80211/ieee80211_crypto.h"
44 #include "net80211/ieee80211_ioctl.h"
45 +#include "do_multi.h"
48 static const char *progname;
52 #define MAXCHAN ((int)(sizeof(struct ieee80211req_chanlist) * NBBY))
55 -main(int argc, char *argv[])
56 +CMD(athchans)(int argc, char *argv[])
58 const char *ifname = "wifi0";
59 struct ieee80211req_chanlist chanlist;
66 +#include "do_multi.h"
69 setsysctrl(const char *dev, const char *control , u_long value)
74 -main(int argc, char *argv[])
75 +CMD(athctrl)(int argc, char *argv[])
77 char device[IFNAMSIZ + 1];
79 --- a/tools/athdebug.c
80 +++ b/tools/athdebug.c
85 +#include "do_multi.h"
88 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
90 #endif /* __linux__ */
93 -main(int argc, char *argv[])
94 +CMD(athdebug)(int argc, char *argv[])
97 const char *ifname = "wifi0";
101 #include "net80211/ieee80211.h"
102 #include "net80211/ieee80211_crypto.h"
103 #include "net80211/ieee80211_ioctl.h"
104 +#include "do_multi.h"
107 static const char *progname;
113 -main(int argc, char *argv[])
114 +int CMD(athkey)(int argc, char *argv[])
116 const char *ifname = "wifi0";
117 struct ieee80211req_key setkey;
118 --- a/tools/athstats.c
119 +++ b/tools/athstats.c
123 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
124 +#include "do_multi.h"
126 static const struct {
132 -main(int argc, char *argv[])
133 +CMD(athstats)(int argc, char *argv[])
136 const char *ifname = "wifi0";
138 +++ b/tools/do_multi.c
141 +#include "do_multi.h"
144 +main(int argc, char *argv[])
149 + progname = basename(argv[0]);
151 + if(strcmp(progname, "80211debug") == 0)
152 + ret = a80211debug_init(argc, argv);
153 + if(strcmp(progname, "80211stats") == 0)
154 + ret = a80211stats_init(argc, argv);
155 + if(strcmp(progname, "athchans") == 0)
156 + ret = athchans_init(argc, argv);
157 + if(strcmp(progname, "athctrl") == 0)
158 + ret = athctrl_init(argc, argv);
159 + if(strcmp(progname, "athdebug") == 0)
160 + ret = athdebug_init(argc, argv);
161 + if(strcmp(progname, "athkey") == 0)
162 + ret = athkey_init(argc, argv);
163 + if(strcmp(progname, "athstats") == 0)
164 + ret = athstats_init(argc, argv);
165 + if(strcmp(progname, "wlanconfig") == 0)
166 + ret = wlanconfig_init(argc, argv);
167 + if(strcmp(progname, "wpakey") == 0)
168 + ret = wpakey_init(argc, argv);
169 + if(strcmp(progname, "athchans") == 0)
170 + ret = athchans_init(argc, argv);
171 + if(strcmp(progname, "ath_info") == 0)
172 + ret = athinfo_init(argc, argv);
177 +++ b/tools/do_multi.h
180 +int a80211debug_init(int argc, char *argv[]);
181 +int a80211stats_init(int argc, char *argv[]);
182 +int athchans_init(int argc, char *argv[]);
183 +int athctrl_init(int argc, char *argv[]);
184 +int athdebug_init(int argc, char *argv[]);
185 +int athkey_init(int argc, char *argv[]);
186 +int athstats_init(int argc, char *argv[]);
187 +int wlanconfig_init(int argc, char *argv[]);
188 +int athinfo_init(int argc, char *argv[]);
190 +#define CMD(name) name##_init
192 +#define CMD(name) main
197 PROGRAMS = athstats 80211stats athkey athchans athctrl \
198 athdebug 80211debug wlanconfig wpakey
200 +OBJS = $(patsubst %,%.o,$(PROGRAMS)) ath_info/ath_info.o
203 -INCS = -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL)
204 +INCS = -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL) -I$(TOP)/ath
205 CFLAGS = -g -O2 -Wall
206 ALL_CFLAGS = $(CFLAGS) $(INCS)
209 -all: all-subdirs $(PROGRAMS)
210 +all: all-subdirs compile
213 for d in $(SUBDIRS); do \
214 $(MAKE) -C $$d || exit 1; \
217 -athstats: athstats.c
218 - $(CC) -o athstats $(ALL_CFLAGS) -I$(TOP)/ath $(LDFLAGS) athstats.c
219 -80211stats: 80211stats.c
220 - $(CC) -o 80211stats $(ALL_CFLAGS) $(LDFLAGS) 80211stats.c
222 - $(CC) -o athkey $(ALL_CFLAGS) $(LDFLAGS) athkey.c
223 -athchans: athchans.c
224 - $(CC) -o athchans $(ALL_CFLAGS) $(LDFLAGS) athchans.c
226 - $(CC) -o athctrl $(ALL_CFLAGS) $(LDFLAGS) athctrl.c
227 -athdebug: athdebug.c
228 - $(CC) -o athdebug $(ALL_CFLAGS) $(LDFLAGS) athdebug.c
229 -wlanconfig: wlanconfig.c
230 - $(CC) -o wlanconfig $(ALL_CFLAGS) $(LDFLAGS) wlanconfig.c
231 -80211debug: 80211debug.c
232 - $(CC) -o 80211debug $(ALL_CFLAGS) $(LDFLAGS) 80211debug.c
234 - $(CC) -o wpakey $(ALL_CFLAGS) $(LDFLAGS) wpakey.c
236 + ${CC} $(ALL_CFLAGS) -c -o $@ $<
238 +ifneq ($(DO_MULTI),)
239 +ALL_CFLAGS += -DDO_MULTI=1
240 +madwifi_multi: $(OBJS) do_multi.o
241 + $(CC) $(LDFLAGS) -o $@ $^
243 +compile: madwifi_multi
244 + for i in $(PROGRAMS); do \
245 + ln -sf madwifi_multi $$i; \
249 + $(CC) $(ALL_CFLAGS) -o $@ $@.c
251 +compile: $(PROGRAMS)
255 install -d $(DESTDIR)$(BINDIR)
256 - for i in $(PROGRAMS); do \
257 + for i in $(PROGRAMS) $(if $(DO_MULTI),madwifi_multi); do \
258 install $$i $(DESTDIR)$(BINDIR)/$$i; \
259 $(STRIP) $(DESTDIR)$(BINDIR)/$$i; \
265 - for i in $(PROGRAMS); do \
266 + for i in $(PROGRAMS) $(if $(DO_MULTI),madwifi_multi); do \
267 rm -f $(DESTDIR)$(BINDIR)/$$i; \
269 for i in $(PROGRAMS:=.8); do \
274 - rm -f $(PROGRAMS) core a.out
275 + rm -f $(if $(DO_MULTI), madwifi_multi) $(PROGRAMS) core a.out *.o
276 for d in $(SUBDIRS); do \
277 $(MAKE) -C $$d clean; \
279 --- a/tools/wlanconfig.c
280 +++ b/tools/wlanconfig.c
282 #include "net80211/ieee80211.h"
283 #include "net80211/ieee80211_crypto.h"
284 #include "net80211/ieee80211_ioctl.h"
285 +#include "do_multi.h"
288 * These are taken from ieee80211_node.h
290 static int verbose = 0;
293 -main(int argc, char *argv[])
294 +CMD(wlanconfig)(int argc, char *argv[])
296 const char *ifname, *cmd;
297 unsigned char bnounit = 0;
298 --- a/tools/ath_info/Makefile
299 +++ b/tools/ath_info/Makefile
305 +ifneq ($(DO_MULTI),)
306 +ath_info: ath_info.o
308 + ln -s ../madwifi_multi $@
311 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
315 - $(CC) $(CFLAGS) -c $<
316 + $(CC) $(CFLAGS) $(if $(DO_MULTI),-DDO_MULTI=1 -I..) -c $<
319 rm -f *.o $(PROGRAMS)
320 --- a/tools/ath_info/ath_info.c
321 +++ b/tools/ath_info/ath_info.c
323 #include <sys/mman.h>
325 #include <byteswap.h>
326 +#include "do_multi.h"
329 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
330 @@ -1982,7 +1983,8 @@
334 -int main(int argc, char *argv[])
336 +CMD(athinfo)(int argc, char *argv[])
338 unsigned long long dev_addr;
339 u_int16_t srev, phy_rev_5ghz, phy_rev_2ghz, ee_magic;
345 #include <sys/ioctl.h>
346 +#include "do_multi.h"
348 #define MACS "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
349 #define MACP(mac) (mac)[0], (mac)[1], (mac)[2], (mac)[3], (mac)[4], (mac)[5]
354 -int main(int argc, char** argv) {
356 +CMD(wpakey)(int argc, char** argv) {
359 int cipher = IEEE80211_CIPHER_AES_CCM;