1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Sat, 23 Jan 2010 08:28:26 +0000
3 Subject: [PATCH] Add option to build a multicall binary
5 This allows building both hostapd and wpa_supplicant as a single binary
11 ALL=hostapd hostapd_cli
14 +-include $(if $(MULTICALL), ../wpa_supplicant/.config)
15 include ../src/build.rules
18 @@ -199,7 +200,8 @@ endif
21 CFLAGS += -DCONFIG_NO_VLAN
24 +ifneq ($(findstring CONFIG_NO_VLAN,$(CFLAGS)), CONFIG_NO_VLAN)
25 OBJS += ../src/ap/vlan_init.o
26 OBJS += ../src/ap/vlan_ifconfig.o
27 OBJS += ../src/ap/vlan.o
28 @@ -358,10 +360,14 @@ CFLAGS += -DCONFIG_MBO
29 OBJS += ../src/ap/mbo_ap.o
33 +CFLAGS += -DNO_SUPPLICANT
36 include ../src/drivers/drivers.mak
37 -OBJS += $(DRV_AP_OBJS)
38 -CFLAGS += $(DRV_AP_CFLAGS)
39 -LDFLAGS += $(DRV_AP_LDFLAGS)
40 +OBJS += $(sort $(DRV_AP_OBJS) $(if $(MULTICALL),$(DRV_WPA_OBJS)))
41 +CFLAGS += $(DRV_AP_CFLAGS) $(if $(MULTICALL),$(DRV_WPA_CFLAGS))
42 +LDFLAGS += $(DRV_AP_LDFLAGS) $(if $(MULTICALL),$(DRV_WPA_LDFLAGS))
43 LIBS += $(DRV_AP_LIBS)
45 ifdef CONFIG_L2_PACKET
46 @@ -1392,6 +1398,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR)
48 include ../src/objs.mk
50 +hostapd_multi.a: $(BCHECK) $(OBJS)
51 + $(Q)$(CC) -c -o hostapd_multi.o -Dmain=hostapd_main $(CFLAGS) main.c
54 + @$(AR) cr $@ hostapd_multi.o $(OBJS)
57 $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
59 @@ -1472,6 +1484,12 @@ include ../src/objs.mk
61 include ../src/objs.mk
64 + @printf "%s " "$(CFLAGS)"
67 + @printf "%s " "$(LDFLAGS) $(LIBS) $(EXTRALIBS)"
69 nt_password_hash: $(NOBJS)
70 $(Q)$(CC) $(LDFLAGS) -o nt_password_hash $(NOBJS) $(LIBS_n)
74 @@ -705,6 +705,11 @@ fail:
78 +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
79 + union wpa_event_data *data);
81 +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
82 + union wpa_event_data *data);
85 static int gen_uuid(const char *txt_addr)
86 @@ -798,6 +803,8 @@ int main(int argc, char *argv[])
88 #endif /* CONFIG_DPP */
90 + wpa_supplicant_event = hostapd_wpa_event;
91 + wpa_supplicant_event_global = hostapd_wpa_event_global;
93 c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:q");
95 --- a/src/ap/drv_callbacks.c
96 +++ b/src/ap/drv_callbacks.c
97 @@ -2341,8 +2341,8 @@ err:
98 #endif /* CONFIG_OWE */
101 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
102 - union wpa_event_data *data)
103 +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
104 + union wpa_event_data *data)
106 struct hostapd_data *hapd = ctx;
107 struct sta_info *sta;
108 @@ -2674,7 +2674,7 @@ void wpa_supplicant_event(void *ctx, enu
112 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
113 +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
114 union wpa_event_data *data)
116 struct hapd_interfaces *interfaces = ctx;
117 --- a/src/drivers/driver.h
118 +++ b/src/drivers/driver.h
119 @@ -6760,8 +6760,8 @@ union wpa_event_data {
120 * Driver wrapper code should call this function whenever an event is received
123 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
124 - union wpa_event_data *data);
125 +extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
126 + union wpa_event_data *data);
129 * wpa_supplicant_event_global - Report a driver event for wpa_supplicant
130 @@ -6773,7 +6773,7 @@ void wpa_supplicant_event(void *ctx, enu
131 * Same as wpa_supplicant_event(), but we search for the interface in
134 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
135 +extern void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
136 union wpa_event_data *data);
139 --- a/src/drivers/drivers.c
140 +++ b/src/drivers/drivers.c
142 #include "utils/common.h"
145 +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
146 + union wpa_event_data *data);
147 +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
148 + union wpa_event_data *data);
150 const struct wpa_driver_ops *const wpa_drivers[] =
152 --- a/wpa_supplicant/Makefile
153 +++ b/wpa_supplicant/Makefile
154 @@ -10,6 +10,7 @@ ALL += dbus/fi.w1.wpa_supplicant1.servic
155 EXTRA_TARGETS=dynamic_eap_methods
158 +-include $(if $(MULTICALL),../hostapd/.config)
159 include ../src/build.rules
161 ifdef CONFIG_BUILD_PASN_SO
162 @@ -388,7 +389,9 @@ endif
163 ifdef CONFIG_IBSS_RSN
164 NEED_RSN_AUTHENTICATOR=y
165 CFLAGS += -DCONFIG_IBSS_RSN
167 CFLAGS += -DCONFIG_NO_VLAN
172 @@ -980,6 +983,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
173 CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
174 LIBS += -ldl -rdynamic
178 + OBJS += ../src/eap_common/eap_common.o
183 @@ -987,9 +994,11 @@ NEED_EAP_COMMON=y
184 NEED_RSN_AUTHENTICATOR=y
185 CFLAGS += -DCONFIG_AP
188 CFLAGS += -DCONFIG_NO_RADIUS
189 CFLAGS += -DCONFIG_NO_ACCOUNTING
190 CFLAGS += -DCONFIG_NO_VLAN
192 OBJS += ../src/ap/hostapd.o
193 OBJS += ../src/ap/wpa_auth_glue.o
194 OBJS += ../src/ap/utils.o
195 @@ -1080,6 +1089,12 @@ endif
197 OBJS += ../src/ap/hs20.o
201 + OBJS += ../src/eap_server/eap_server.o
202 + OBJS += ../src/eap_server/eap_server_identity.o
203 + OBJS += ../src/eap_server/eap_server_methods.o
208 @@ -1089,7 +1104,9 @@ NEED_GAS=y
211 ifdef NEED_RSN_AUTHENTICATOR
213 CFLAGS += -DCONFIG_NO_RADIUS
216 OBJS += ../src/ap/wpa_auth.o
217 OBJS += ../src/ap/wpa_auth_ie.o
218 @@ -2079,6 +2096,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
221 include ../src/objs.mk
222 +wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
223 + $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c
226 + @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
228 wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
229 $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
231 @@ -2211,6 +2234,12 @@ eap_gpsk.so: $(SRC_EAP_GPSK)
232 $(Q)sed -e 's|\@BINDIR\@|$(BINDIR)|g' $< >$@
236 + @printf "%s " "$(CFLAGS)"
239 + @printf "%s " "$(LDFLAGS) $(LIBS) $(EXTRALIBS)"
241 wpa_supplicant.exe: wpa_supplicant
244 --- a/wpa_supplicant/eapol_test.c
245 +++ b/wpa_supplicant/eapol_test.c
247 #include "ctrl_iface.h"
248 #include "pcsc_funcs.h"
249 #include "wpas_glue.h"
250 +#include "drivers/driver.h"
252 +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
253 + union wpa_event_data *data);
254 +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
255 + union wpa_event_data *data);
257 const struct wpa_driver_ops *const wpa_drivers[] = { NULL };
259 @@ -1325,6 +1330,10 @@ static void usage(void)
260 "option several times.\n");
263 +extern void supplicant_event(void *ctx, enum wpa_event_type event,
264 + union wpa_event_data *data);
265 +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
266 + union wpa_event_data *data);
268 int main(int argc, char *argv[])
270 @@ -1348,6 +1357,8 @@ int main(int argc, char *argv[])
271 if (os_program_init())
274 + wpa_supplicant_event = supplicant_event;
275 + wpa_supplicant_event_global = supplicant_event_global;
276 hostapd_logger_register_cb(hostapd_logger_cb);
278 os_memset(&eapol_test, 0, sizeof(eapol_test));
279 --- a/wpa_supplicant/events.c
280 +++ b/wpa_supplicant/events.c
281 @@ -5919,8 +5919,8 @@ static void wpas_link_reconfig(struct wp
285 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
286 - union wpa_event_data *data)
287 +void supplicant_event(void *ctx, enum wpa_event_type event,
288 + union wpa_event_data *data)
290 struct wpa_supplicant *wpa_s = ctx;
292 @@ -6872,7 +6872,7 @@ void wpa_supplicant_event(void *ctx, enu
296 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
297 +void supplicant_event_global(void *ctx, enum wpa_event_type event,
298 union wpa_event_data *data)
300 struct wpa_supplicant *wpa_s;
301 --- a/wpa_supplicant/wpa_priv.c
302 +++ b/wpa_supplicant/wpa_priv.c
303 @@ -1039,8 +1039,8 @@ static void wpa_priv_send_ft_response(st
307 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
308 - union wpa_event_data *data)
309 +static void supplicant_event(void *ctx, enum wpa_event_type event,
310 + union wpa_event_data *data)
312 struct wpa_priv_interface *iface = ctx;
314 @@ -1103,7 +1103,7 @@ void wpa_supplicant_event(void *ctx, enu
318 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
319 +void supplicant_event_global(void *ctx, enum wpa_event_type event,
320 union wpa_event_data *data)
322 struct wpa_priv_global *global = ctx;
323 @@ -1217,6 +1217,8 @@ int main(int argc, char *argv[])
324 if (os_program_init())
327 + wpa_supplicant_event = supplicant_event;
328 + wpa_supplicant_event_global = supplicant_event_global;
329 wpa_priv_fd_workaround();
331 os_memset(&global, 0, sizeof(global));
332 --- a/wpa_supplicant/wpa_supplicant.c
333 +++ b/wpa_supplicant/wpa_supplicant.c
334 @@ -7583,7 +7583,6 @@ struct wpa_interface * wpa_supplicant_ma
340 * wpa_supplicant_match_existing - Match existing interfaces
341 * @global: Pointer to global data from wpa_supplicant_init()
342 @@ -7618,6 +7617,11 @@ static int wpa_supplicant_match_existing
344 #endif /* CONFIG_MATCH_IFACE */
346 +extern void supplicant_event(void *ctx, enum wpa_event_type event,
347 + union wpa_event_data *data);
349 +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
350 + union wpa_event_data *data);
353 * wpa_supplicant_add_iface - Add a new network interface
354 @@ -7874,6 +7878,8 @@ struct wpa_global * wpa_supplicant_init(
355 #ifndef CONFIG_NO_WPA_MSG
356 wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
357 #endif /* CONFIG_NO_WPA_MSG */
358 + wpa_supplicant_event = supplicant_event;
359 + wpa_supplicant_event_global = supplicant_event_global;
361 if (params->wpa_debug_file_path)
362 wpa_debug_open_file(params->wpa_debug_file_path);