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
142 +#include "do_multi.h"
145 +main(int argc, char *argv[])
150 + progname = basename(argv[0]);
152 + if(strcmp(progname, "80211debug") == 0)
153 + ret = a80211debug_init(argc, argv);
154 + if(strcmp(progname, "80211stats") == 0)
155 + ret = a80211stats_init(argc, argv);
156 + if(strcmp(progname, "athchans") == 0)
157 + ret = athchans_init(argc, argv);
158 + if(strcmp(progname, "athctrl") == 0)
159 + ret = athctrl_init(argc, argv);
160 + if(strcmp(progname, "athdebug") == 0)
161 + ret = athdebug_init(argc, argv);
162 + if(strcmp(progname, "athkey") == 0)
163 + ret = athkey_init(argc, argv);
164 + if(strcmp(progname, "athstats") == 0)
165 + ret = athstats_init(argc, argv);
166 + if(strcmp(progname, "wlanconfig") == 0)
167 + ret = wlanconfig_init(argc, argv);
168 + if(strcmp(progname, "ath_info") == 0)
169 + ret = athinfo_init(argc, argv);
174 +++ b/tools/do_multi.h
177 +int a80211debug_init(int argc, char *argv[]);
178 +int a80211stats_init(int argc, char *argv[]);
179 +int athchans_init(int argc, char *argv[]);
180 +int athctrl_init(int argc, char *argv[]);
181 +int athdebug_init(int argc, char *argv[]);
182 +int athkey_init(int argc, char *argv[]);
183 +int athstats_init(int argc, char *argv[]);
184 +int wlanconfig_init(int argc, char *argv[]);
185 +int athinfo_init(int argc, char *argv[]);
187 +#define CMD(name) name##_init
189 +#define CMD(name) main
199 -ALL= athstats 80211stats athkey athchans athctrl \
200 +ALLPROGS= athstats 80211stats athkey athchans athctrl \
201 athdebug 80211debug wlanconfig ath_info
204 +OBJS= $(patsubst %,%.o,$(ALLPROGS))
206 -INCS= -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL)
207 +INCS= -I. -I../ath -I$(HAL) -I$(TOP) -I$(ATH_HAL)
209 ALL_CFLAGS= $(CFLAGS) $(INCS)
214 -athstats: athstats.c
215 - $(CC) -o athstats $(ALL_CFLAGS) -I$(TOP)/ath $(LDFLAGS) athstats.c
216 -80211stats: 80211stats.c
217 - $(CC) -o 80211stats $(ALL_CFLAGS) $(LDFLAGS) 80211stats.c
219 - $(CC) -o athkey $(ALL_CFLAGS) $(LDFLAGS) athkey.c
220 -athchans: athchans.c
221 - $(CC) -o athchans $(ALL_CFLAGS) $(LDFLAGS) athchans.c
223 - $(CC) -o athctrl $(ALL_CFLAGS) $(LDFLAGS) athctrl.c
224 -athdebug: athdebug.c
225 - $(CC) -o athdebug $(ALL_CFLAGS) $(LDFLAGS) athdebug.c
226 -wlanconfig: wlanconfig.c
227 - $(CC) -o wlanconfig $(ALL_CFLAGS) $(LDFLAGS) wlanconfig.c
228 -80211debug: 80211debug.c
229 - $(CC) -o 80211debug $(ALL_CFLAGS) $(LDFLAGS) 80211debug.c
230 -ath_info: ath_info.c
231 - $(CC) -o ath_info $(CFLAGS) ath_info.c
232 +ifneq ($(DO_MULTI),)
233 +ALL_CFLAGS += -DDO_MULTI=1
235 + ${CC} $(ALL_CFLAGS) -c -o $@ $<
237 +madwifi_multi: $(OBJS) do_multi.o
240 +compile: madwifi_multi
241 + for i in $(ALLPROGS); do \
242 + ln -s -f madwifi_multi $$i; \
246 + $(CC) $(ALL_CFLAGS) -o $@ $@.c
248 +compile: $(ALLPROGS)
253 install -d $(DESTDIR)$(BINDIR)
254 - for i in $(ALL); do \
255 + for i in $(ALLPROGS) $(if $(DO_MULTI),madwifi_multi); do \
256 install $$i $(DESTDIR)$(BINDIR)/$$i; \
257 - $(STRIP) $(DESTDIR)$(BINDIR)/$$i; \
259 install -d $(DESTDIR)$(MANDIR)/man8
260 install -m 0644 man/*.8 $(DESTDIR)$(MANDIR)/man8
261 install $(TOP)/scripts/madwifi-unload $(DESTDIR)$(BINDIR)/madwifi-unload
264 - for i in $(ALL); do \
265 + for i in $(ALLPROGS) $(if $(DO_MULTI),madwifi_multi); do \
266 rm -f $(DESTDIR)$(BINDIR)/$$i; \
268 - for i in $(ALL:=.8); do \
269 - rm -f $(DESTDIR)$(MANDIR)/man8/$$i; \
270 + for i in $(ALLPROGS); do \
271 + rm -f $(DESTDIR)$(MANDIR)/man8/$$i.8; \
275 - rm -f $(ALL) core a.out
276 + rm -f $(ALLPROGS) madwifi_multi *.o core a.out
277 --- a/tools/wlanconfig.c
278 +++ b/tools/wlanconfig.c
280 #include "net80211/ieee80211.h"
281 #include "net80211/ieee80211_crypto.h"
282 #include "net80211/ieee80211_ioctl.h"
283 +#include "do_multi.h"
286 * These are taken from ieee80211_node.h
288 static int verbose = 0;
291 -main(int argc, char *argv[])
292 +CMD(wlanconfig)(int argc, char *argv[])
294 const char *ifname, *cmd;
295 unsigned char bnounit = 0;
296 --- a/tools/ath_info.c
297 +++ b/tools/ath_info.c
299 #include <sys/mman.h>
301 #include <byteswap.h>
302 +#include "do_multi.h"
305 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
307 "unlawful radio transmissions!\n\n");
310 -int main(int argc, char *argv[])
312 +CMD(athinfo)(int argc, char *argv[])
315 u_int16_t eeprom_header, srev, phy_rev_5ghz, phy_rev_2ghz;