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, "ath_info") == 0)
168 + ret = athinfo_init(argc, argv);
173 +++ b/tools/do_multi.h
176 +int a80211debug_init(int argc, char *argv[]);
177 +int a80211stats_init(int argc, char *argv[]);
178 +int athchans_init(int argc, char *argv[]);
179 +int athctrl_init(int argc, char *argv[]);
180 +int athdebug_init(int argc, char *argv[]);
181 +int athkey_init(int argc, char *argv[]);
182 +int athstats_init(int argc, char *argv[]);
183 +int wlanconfig_init(int argc, char *argv[]);
184 +int athinfo_init(int argc, char *argv[]);
186 +#define CMD(name) name##_init
188 +#define CMD(name) main
198 -ALL= athstats 80211stats athkey athchans athctrl \
199 +ALLPROGS= athstats 80211stats athkey athchans athctrl \
200 athdebug 80211debug wlanconfig ath_info
203 +OBJS= $(patsubst %,%.o,$(ALLPROGS))
205 -INCS= -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL)
206 +INCS= -I. -I../ath -I$(HAL) -I$(TOP) -I$(ATH_HAL)
208 ALL_CFLAGS= $(CFLAGS) $(INCS)
213 -athstats: athstats.c
214 - $(CC) -o athstats $(ALL_CFLAGS) -I$(TOP)/ath $(LDFLAGS) athstats.c
215 -80211stats: 80211stats.c
216 - $(CC) -o 80211stats $(ALL_CFLAGS) $(LDFLAGS) 80211stats.c
218 - $(CC) -o athkey $(ALL_CFLAGS) $(LDFLAGS) athkey.c
219 -athchans: athchans.c
220 - $(CC) -o athchans $(ALL_CFLAGS) $(LDFLAGS) athchans.c
222 - $(CC) -o athctrl $(ALL_CFLAGS) $(LDFLAGS) athctrl.c
223 -athdebug: athdebug.c
224 - $(CC) -o athdebug $(ALL_CFLAGS) $(LDFLAGS) athdebug.c
225 -wlanconfig: wlanconfig.c
226 - $(CC) -o wlanconfig $(ALL_CFLAGS) $(LDFLAGS) wlanconfig.c
227 -80211debug: 80211debug.c
228 - $(CC) -o 80211debug $(ALL_CFLAGS) $(LDFLAGS) 80211debug.c
229 -ath_info: ath_info.c
230 - $(CC) -o ath_info $(CFLAGS) ath_info.c
231 +ifneq ($(DO_MULTI),)
232 +ALL_CFLAGS += -DDO_MULTI=1
234 + ${CC} $(ALL_CFLAGS) -c -o $@ $<
236 +madwifi_multi: $(OBJS) do_multi.o
239 +compile: madwifi_multi
240 + for i in $(ALLPROGS); do \
241 + ln -s -f madwifi_multi $$i; \
245 + $(CC) $(ALL_CFLAGS) -o $@ $@.c
247 +compile: $(ALLPROGS)
252 install -d $(DESTDIR)$(BINDIR)
253 - for i in $(ALL); do \
254 + for i in $(ALLPROGS) $(if $(DO_MULTI),madwifi_multi); do \
255 install $$i $(DESTDIR)$(BINDIR)/$$i; \
256 - $(STRIP) $(DESTDIR)$(BINDIR)/$$i; \
258 install -d $(DESTDIR)$(MANDIR)/man8
259 install -m 0644 man/*.8 $(DESTDIR)$(MANDIR)/man8
260 install $(TOP)/scripts/madwifi-unload $(DESTDIR)$(BINDIR)/madwifi-unload
263 - for i in $(ALL); do \
264 + for i in $(ALLPROGS) $(if $(DO_MULTI),madwifi_multi); do \
265 rm -f $(DESTDIR)$(BINDIR)/$$i; \
267 - for i in $(ALL:=.8); do \
268 - rm -f $(DESTDIR)$(MANDIR)/man8/$$i; \
269 + for i in $(ALLPROGS); do \
270 + rm -f $(DESTDIR)$(MANDIR)/man8/$$i.8; \
274 - rm -f $(ALL) core a.out
275 + rm -f $(ALLPROGS) madwifi_multi *.o core a.out
276 --- a/tools/wlanconfig.c
277 +++ b/tools/wlanconfig.c
279 #include "net80211/ieee80211.h"
280 #include "net80211/ieee80211_crypto.h"
281 #include "net80211/ieee80211_ioctl.h"
282 +#include "do_multi.h"
285 * These are taken from ieee80211_node.h
287 static int verbose = 0;
290 -main(int argc, char *argv[])
291 +CMD(wlanconfig)(int argc, char *argv[])
293 const char *ifname, *cmd;
294 unsigned char bnounit = 0;
295 --- a/tools/ath_info.c
296 +++ b/tools/ath_info.c
298 #include <sys/mman.h>
300 #include <byteswap.h>
301 +#include "do_multi.h"
304 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
306 "unlawful radio transmissions!\n\n");
309 -int main(int argc, char *argv[])
311 +CMD(athinfo)(int argc, char *argv[])
314 u_int16_t eeprom_header, srev, phy_rev_5ghz, phy_rev_2ghz;