1 Index: madwifi-trunk-r3314/tools/80211debug.c
2 ===================================================================
3 --- madwifi-trunk-r3314.orig/tools/80211debug.c 2008-05-19 13:58:46.000000000 +0200
4 +++ madwifi-trunk-r3314/tools/80211debug.c 2008-05-19 14:15:10.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-r3314/tools/80211stats.c
23 ===================================================================
24 --- madwifi-trunk-r3314.orig/tools/80211stats.c 2008-05-19 13:58:46.000000000 +0200
25 +++ madwifi-trunk-r3314/tools/80211stats.c 2008-05-19 14:16:17.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-r3314/tools/athchans.c
44 ===================================================================
45 --- madwifi-trunk-r3314.orig/tools/athchans.c 2008-05-19 13:58:46.000000000 +0200
46 +++ madwifi-trunk-r3314/tools/athchans.c 2008-05-19 14:15:28.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-r3314/tools/athctrl.c
67 ===================================================================
68 --- madwifi-trunk-r3314.orig/tools/athctrl.c 2008-05-19 13:58:46.000000000 +0200
69 +++ madwifi-trunk-r3314/tools/athctrl.c 2008-05-19 14:15:44.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-r3314/tools/athdebug.c
88 ===================================================================
89 --- madwifi-trunk-r3314.orig/tools/athdebug.c 2008-05-19 13:58:46.000000000 +0200
90 +++ madwifi-trunk-r3314/tools/athdebug.c 2008-05-19 14:15:59.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-r3314/tools/athkey.c
109 ===================================================================
110 --- madwifi-trunk-r3314.orig/tools/athkey.c 2008-05-19 13:58:46.000000000 +0200
111 +++ madwifi-trunk-r3314/tools/athkey.c 2008-05-19 14:13:06.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-r3314/tools/athstats.c
131 ===================================================================
132 --- madwifi-trunk-r3314.orig/tools/athstats.c 2008-05-19 13:58:46.000000000 +0200
133 +++ madwifi-trunk-r3314/tools/athstats.c 2008-05-19 14:13:44.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-r3314/tools/do_multi.c
152 ===================================================================
153 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
154 +++ madwifi-trunk-r3314/tools/do_multi.c 2008-05-19 14:56:28.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, "ath_info") == 0)
184 + ret = athinfo_init(argc, argv);
188 Index: madwifi-trunk-r3314/tools/do_multi.h
189 ===================================================================
190 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
191 +++ madwifi-trunk-r3314/tools/do_multi.h 2008-05-19 14:42:44.000000000 +0200
194 +int a80211debug_init(int argc, char *argv[]);
195 +int a80211stats_init(int argc, char *argv[]);
196 +int athchans_init(int argc, char *argv[]);
197 +int athctrl_init(int argc, char *argv[]);
198 +int athdebug_init(int argc, char *argv[]);
199 +int athkey_init(int argc, char *argv[]);
200 +int athstats_init(int argc, char *argv[]);
201 +int wlanconfig_init(int argc, char *argv[]);
202 +int athinfo_init(int argc, char *argv[]);
204 +#define CMD(name) name##_init
206 +#define CMD(name) main
208 Index: madwifi-trunk-r3314/tools/Makefile
209 ===================================================================
210 --- madwifi-trunk-r3314.orig/tools/Makefile 2008-05-19 13:58:46.000000000 +0200
211 +++ madwifi-trunk-r3314/tools/Makefile 2008-05-19 14:56:55.000000000 +0200
218 -ALL= athstats 80211stats athkey athchans athctrl \
219 +ALLPROGS= athstats 80211stats athkey athchans athctrl \
220 athdebug 80211debug wlanconfig ath_info
223 +OBJS= $(patsubst %,%.o,$(ALLPROGS))
225 -INCS= -I. -I$(HAL) -I$(TOP) -I$(ATH_HAL)
226 +INCS= -I. -I../ath -I$(HAL) -I$(TOP) -I$(ATH_HAL)
228 ALL_CFLAGS= $(CFLAGS) $(INCS)
233 -athstats: athstats.c
234 - $(CC) -o athstats $(ALL_CFLAGS) -I$(TOP)/ath $(LDFLAGS) athstats.c
235 -80211stats: 80211stats.c
236 - $(CC) -o 80211stats $(ALL_CFLAGS) $(LDFLAGS) 80211stats.c
238 - $(CC) -o athkey $(ALL_CFLAGS) $(LDFLAGS) athkey.c
239 -athchans: athchans.c
240 - $(CC) -o athchans $(ALL_CFLAGS) $(LDFLAGS) athchans.c
242 - $(CC) -o athctrl $(ALL_CFLAGS) $(LDFLAGS) athctrl.c
243 -athdebug: athdebug.c
244 - $(CC) -o athdebug $(ALL_CFLAGS) $(LDFLAGS) athdebug.c
245 -wlanconfig: wlanconfig.c
246 - $(CC) -o wlanconfig $(ALL_CFLAGS) $(LDFLAGS) wlanconfig.c
247 -80211debug: 80211debug.c
248 - $(CC) -o 80211debug $(ALL_CFLAGS) $(LDFLAGS) 80211debug.c
249 -ath_info: ath_info.c
250 - $(CC) -o ath_info $(CFLAGS) ath_info.c
251 +ifneq ($(DO_MULTI),)
252 +ALL_CFLAGS += -DDO_MULTI=1
254 + ${CC} $(ALL_CFLAGS) -c -o $@ $<
256 +madwifi_multi: $(OBJS) do_multi.o
259 +compile: madwifi_multi
260 + for i in $(ALLPROGS); do \
261 + ln -s -f madwifi_multi $$i; \
265 + $(CC) $(ALL_CFLAGS) -o $@ $@.c
267 +compile: $(ALLPROGS)
272 install -d $(DESTDIR)$(BINDIR)
273 - for i in $(ALL); do \
274 + for i in $(ALLPROGS) $(if $(DO_MULTI),madwifi_multi); do \
275 install $$i $(DESTDIR)$(BINDIR)/$$i; \
276 - $(STRIP) $(DESTDIR)$(BINDIR)/$$i; \
278 install -d $(DESTDIR)$(MANDIR)/man8
279 install -m 0644 man/*.8 $(DESTDIR)$(MANDIR)/man8
280 install $(TOP)/scripts/madwifi-unload $(DESTDIR)$(BINDIR)/madwifi-unload
283 - for i in $(ALL); do \
284 + for i in $(ALLPROGS) $(if $(DO_MULTI),madwifi_multi); do \
285 rm -f $(DESTDIR)$(BINDIR)/$$i; \
287 - for i in $(ALL:=.8); do \
288 - rm -f $(DESTDIR)$(MANDIR)/man8/$$i; \
289 + for i in $(ALLPROGS); do \
290 + rm -f $(DESTDIR)$(MANDIR)/man8/$$i.8; \
294 - rm -f $(ALL) core a.out
295 + rm -f $(ALLPROGS) madwifi_multi *.o core a.out
296 Index: madwifi-trunk-r3314/tools/wlanconfig.c
297 ===================================================================
298 --- madwifi-trunk-r3314.orig/tools/wlanconfig.c 2008-05-19 13:58:46.000000000 +0200
299 +++ madwifi-trunk-r3314/tools/wlanconfig.c 2008-05-19 14:14:07.000000000 +0200
301 #include "net80211/ieee80211.h"
302 #include "net80211/ieee80211_crypto.h"
303 #include "net80211/ieee80211_ioctl.h"
304 +#include "do_multi.h"
307 * These are taken from ieee80211_node.h
309 static int verbose = 0;
312 -main(int argc, char *argv[])
313 +CMD(wlanconfig)(int argc, char *argv[])
315 const char *ifname, *cmd;
316 unsigned char bnounit = 0;
317 Index: madwifi-trunk-r3314/tools/ath_info.c
318 ===================================================================
319 --- madwifi-trunk-r3314.orig/tools/ath_info.c 2008-05-19 13:58:46.000000000 +0200
320 +++ madwifi-trunk-r3314/tools/ath_info.c 2008-05-19 14:44:45.000000000 +0200
322 #include <sys/mman.h>
324 #include <byteswap.h>
325 +#include "do_multi.h"
328 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
330 "unlawful radio transmissions!\n\n");
333 -int main(int argc, char *argv[])
335 +CMD(athinfo)(int argc, char *argv[])
338 u_int16_t eeprom_header, srev, phy_rev_5ghz, phy_rev_2ghz;