nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * Wireless Tools
3 *
4 * Jean II - HPL 04
5 *
6 * Main code for "iwmulticall". This is a wrapper for the multicall version
7 * of the wireless tools.
8 * You need to link this code against "-lm".
9 * Thanks to Ned Ludd <solar@gentoo.org> for the inspiration...
10 *
11 * This file is released under the GPL license.
12 * Copyright (c) 1997-2004 Jean Tourrilhes <jt@hpl.hp.com>
13 */
14  
15 /***************************** INCLUDES *****************************/
16  
17 #include <libgen.h> /* Basename */
18  
19 /**************************** PROTOTYPES ****************************/
20  
21 /* Prototypes of the main of each tool */
22 extern int
23 main_iwconfig(int argc,
24 char ** argv);
25 extern int
26 main_iwlist(int argc,
27 char ** argv);
28 extern int
29 main_iwspy(int argc,
30 char ** argv);
31 extern int
32 main_iwpriv(int argc,
33 char ** argv);
34 extern int
35 main_iwgetid(int argc,
36 char ** argv);
37  
38 /************************** MULTICALL HACK **************************/
39 /*
40 * The idea for multicall is to put all the tools and the library in
41 * the same binary. This way, you can save the overhead of the library,
42 * of each tool, can better optimise the code and throw away the stuff
43 * you don't need from the library.
44 * This almost divide the size of the tools by two (without stripping).
45 * On the down side, you no longer have the libiw for other tools to
46 * use, but for the target systems (embedded), this doesn't matter
47 * much, as they just need to configure the card...
48 * Note that splitting the lib and the multicall tools would not
49 * make sense, as most gains are found in the inclusion of the lib...
50 *
51 * Our strategy is to include directly the *.c, rather than compile
52 * them separatly. This allow to simplify compilation and hide the
53 * multicall tweaks from the other tools.
54 * Yeah, this leads to a bit a preprocessor abuse...
55 * Jean II
56 */
57  
58 /* We need the library */
59 #include "iwlib.c"
60  
61 /* Get iwconfig in there. Mandatory. */
62 #define main(args...) main_iwconfig(args)
63 #define iw_usage(args...) iwconfig_usage(args)
64 #define find_command(args...) iwconfig_find_command(args)
65 #include "iwconfig.c"
66 #undef find_command
67 #undef iw_usage
68 #undef main
69  
70 /* Get iwlist in there. Scanning support is pretty sweet. */
71 #define main(args...) main_iwlist(args)
72 #define iw_usage(args...) iwlist_usage(args)
73 #define find_command(args...) iwlist_find_command(args)
74 #include "iwlist.c"
75 #undef find_command
76 #undef iw_usage
77 #undef main
78  
79 #ifndef WE_ESSENTIAL
80 /* Get iwspy in there, it's not that big. */
81 #define main(args...) main_iwspy(args)
82 #include "iwspy.c"
83 #undef main
84 #endif /* WE_ESSENTIAL */
85  
86 /* Get iwpriv in there. Mandatory for HostAP and some other drivers. */
87 #define main(args...) main_iwpriv(args)
88 #define iw_usage(args...) iwpriv_usage(args)
89 #include "iwpriv.c"
90 #undef iw_usage
91 #undef main
92  
93 /* Do we really need iwgetid ? Well, it's not like it's a big one */
94 #define main(args...) main_iwgetid(args)
95 #define iw_usage(args...) iwgetid_usage(args)
96 #include "iwgetid.c"
97 #undef iw_usage
98 #undef main
99  
100 /* iwevent is useless for most people, don't grab it ? */
101  
102 /* ifrename is big and useless for those systems */
103  
104  
105 /******************************* MAIN ********************************/
106  
107 /*------------------------------------------------------------------*/
108 /*
109 * The main !
110 */
111 int
112 main(int argc,
113 char ** argv)
114 {
115 char * call_name = basename(argv[0]); /* Strip path */
116  
117 /* This is a testing hack */
118 if(!strcmp(call_name, "iwmulticall") && (argc > 0))
119 {
120 argv++;
121 argc--;
122 call_name = basename(argv[0]);
123 }
124  
125 /* Just check the name under which we were called... */
126  
127 if(!strcmp(call_name, "iwconfig"))
128 return(main_iwconfig(argc, argv));
129 if(!strcmp(call_name, "iwlist"))
130 return(main_iwlist(argc, argv));
131 #ifndef WE_ESSENTIAL
132 if(!strcmp(call_name, "iwspy"))
133 return(main_iwspy(argc, argv));
134 #endif /* WE_ESSENTIAL */
135 if(!strcmp(call_name, "iwpriv"))
136 return(main_iwpriv(argc, argv));
137 if(!strcmp(call_name, "iwgetid"))
138 return(main_iwgetid(argc, argv));
139  
140 /* Uh oh... Not supposed to come here. */
141 printf("iwmulticall : you are not supposed to call me this way...\n");
142 return(0);
143 }