hostapd: adjust patches to work with git am
[openwrt/staging/xback.git] / package / network / services / hostapd / patches / 200-multicall.patch
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
4
5 This allows building both hostapd and wpa_supplicant as a single binary
6 (wpad).
7
8 --- a/hostapd/Makefile
9 +++ b/hostapd/Makefile
10 @@ -1,6 +1,7 @@
11 ALL=hostapd hostapd_cli
12 CONFIG_FILE = .config
13
14 +-include $(if $(MULTICALL), ../wpa_supplicant/.config)
15 include ../src/build.rules
16
17 ifdef LIBS
18 @@ -199,7 +200,8 @@ endif
19
20 ifdef CONFIG_NO_VLAN
21 CFLAGS += -DCONFIG_NO_VLAN
22 -else
23 +endif
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
30 endif
31
32 +ifndef MULTICALL
33 +CFLAGS += -DNO_SUPPLICANT
34 +endif
35 +
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)
44
45 ifdef CONFIG_L2_PACKET
46 @@ -1392,6 +1398,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR)
47 _OBJS_VAR := OBJS
48 include ../src/objs.mk
49
50 +hostapd_multi.a: $(BCHECK) $(OBJS)
51 + $(Q)$(CC) -c -o hostapd_multi.o -Dmain=hostapd_main $(CFLAGS) main.c
52 + @$(E) " CC " $<
53 + @rm -f $@
54 + @$(AR) cr $@ hostapd_multi.o $(OBJS)
55 +
56 hostapd: $(OBJS)
57 $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
58 @$(E) " LD " $@
59 @@ -1472,6 +1484,12 @@ include ../src/objs.mk
60 _OBJS_VAR := SOBJS
61 include ../src/objs.mk
62
63 +dump_cflags:
64 + @printf "%s " "$(CFLAGS)"
65 +
66 +dump_ldflags:
67 + @printf "%s " "$(LDFLAGS) $(LIBS) $(EXTRALIBS)"
68 +
69 nt_password_hash: $(NOBJS)
70 $(Q)$(CC) $(LDFLAGS) -o nt_password_hash $(NOBJS) $(LIBS_n)
71 @$(E) " LD " $@
72 --- a/hostapd/main.c
73 +++ b/hostapd/main.c
74 @@ -705,6 +705,11 @@ fail:
75 return -1;
76 }
77
78 +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
79 + union wpa_event_data *data);
80 +
81 +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
82 + union wpa_event_data *data);
83
84 #ifdef CONFIG_WPS
85 static int gen_uuid(const char *txt_addr)
86 @@ -798,6 +803,8 @@ int main(int argc, char *argv[])
87 return -1;
88 #endif /* CONFIG_DPP */
89
90 + wpa_supplicant_event = hostapd_wpa_event;
91 + wpa_supplicant_event_global = hostapd_wpa_event_global;
92 for (;;) {
93 c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:q");
94 if (c < 0)
95 --- a/src/ap/drv_callbacks.c
96 +++ b/src/ap/drv_callbacks.c
97 @@ -2341,8 +2341,8 @@ err:
98 #endif /* CONFIG_OWE */
99
100
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)
105 {
106 struct hostapd_data *hapd = ctx;
107 struct sta_info *sta;
108 @@ -2674,7 +2674,7 @@ void wpa_supplicant_event(void *ctx, enu
109 }
110
111
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)
115 {
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
121 * from the driver.
122 */
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);
127
128 /**
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
132 * wpa_global.
133 */
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);
137
138 /*
139 --- a/src/drivers/drivers.c
140 +++ b/src/drivers/drivers.c
141 @@ -10,6 +10,10 @@
142 #include "utils/common.h"
143 #include "driver.h"
144
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);
149
150 const struct wpa_driver_ops *const wpa_drivers[] =
151 {
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
156
157 CONFIG_FILE=.config
158 +-include $(if $(MULTICALL),../hostapd/.config)
159 include ../src/build.rules
160
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
166 +ifndef MULTICALL
167 CFLAGS += -DCONFIG_NO_VLAN
168 +endif
169 OBJS += ibss_rsn.o
170 endif
171
172 @@ -980,6 +983,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
173 CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
174 LIBS += -ldl -rdynamic
175 endif
176 +else
177 + ifdef MULTICALL
178 + OBJS += ../src/eap_common/eap_common.o
179 + endif
180 endif
181
182 ifdef CONFIG_AP
183 @@ -987,9 +994,11 @@ NEED_EAP_COMMON=y
184 NEED_RSN_AUTHENTICATOR=y
185 CFLAGS += -DCONFIG_AP
186 OBJS += ap.o
187 +ifndef MULTICALL
188 CFLAGS += -DCONFIG_NO_RADIUS
189 CFLAGS += -DCONFIG_NO_ACCOUNTING
190 CFLAGS += -DCONFIG_NO_VLAN
191 +endif
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
196 ifdef CONFIG_HS20
197 OBJS += ../src/ap/hs20.o
198 endif
199 +else
200 + ifdef MULTICALL
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
204 + endif
205 endif
206
207 ifdef CONFIG_MBO
208 @@ -1089,7 +1104,9 @@ NEED_GAS=y
209 endif
210
211 ifdef NEED_RSN_AUTHENTICATOR
212 +ifndef MULTICALL
213 CFLAGS += -DCONFIG_NO_RADIUS
214 +endif
215 NEED_AES_WRAP=y
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)
219
220 _OBJS_VAR := OBJS
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
224 + @$(E) " CC " $<
225 + @rm -f $@
226 + @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
227 +
228 wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
229 $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
230 @$(E) " LD " $@
231 @@ -2211,6 +2234,12 @@ eap_gpsk.so: $(SRC_EAP_GPSK)
232 $(Q)sed -e 's|\@BINDIR\@|$(BINDIR)|g' $< >$@
233 @$(E) " sed" $<
234
235 +dump_cflags:
236 + @printf "%s " "$(CFLAGS)"
237 +
238 +dump_ldflags:
239 + @printf "%s " "$(LDFLAGS) $(LIBS) $(EXTRALIBS)"
240 +
241 wpa_supplicant.exe: wpa_supplicant
242 mv -f $< $@
243 wpa_cli.exe: wpa_cli
244 --- a/wpa_supplicant/eapol_test.c
245 +++ b/wpa_supplicant/eapol_test.c
246 @@ -31,7 +31,12 @@
247 #include "ctrl_iface.h"
248 #include "pcsc_funcs.h"
249 #include "wpas_glue.h"
250 +#include "drivers/driver.h"
251
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);
256
257 const struct wpa_driver_ops *const wpa_drivers[] = { NULL };
258
259 @@ -1325,6 +1330,10 @@ static void usage(void)
260 "option several times.\n");
261 }
262
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);
267
268 int main(int argc, char *argv[])
269 {
270 @@ -1348,6 +1357,8 @@ int main(int argc, char *argv[])
271 if (os_program_init())
272 return -1;
273
274 + wpa_supplicant_event = supplicant_event;
275 + wpa_supplicant_event_global = supplicant_event_global;
276 hostapd_logger_register_cb(hostapd_logger_cb);
277
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
282 }
283
284
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)
289 {
290 struct wpa_supplicant *wpa_s = ctx;
291 int resched;
292 @@ -6872,7 +6872,7 @@ void wpa_supplicant_event(void *ctx, enu
293 }
294
295
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)
299 {
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
304 }
305
306
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)
311 {
312 struct wpa_priv_interface *iface = ctx;
313
314 @@ -1103,7 +1103,7 @@ void wpa_supplicant_event(void *ctx, enu
315 }
316
317
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)
321 {
322 struct wpa_priv_global *global = ctx;
323 @@ -1217,6 +1217,8 @@ int main(int argc, char *argv[])
324 if (os_program_init())
325 return -1;
326
327 + wpa_supplicant_event = supplicant_event;
328 + wpa_supplicant_event_global = supplicant_event_global;
329 wpa_priv_fd_workaround();
330
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
335 return NULL;
336 }
337
338 -
339 /**
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
343
344 #endif /* CONFIG_MATCH_IFACE */
345
346 +extern void supplicant_event(void *ctx, enum wpa_event_type event,
347 + union wpa_event_data *data);
348 +
349 +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
350 + union wpa_event_data *data);
351
352 /**
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;
360
361 if (params->wpa_debug_file_path)
362 wpa_debug_open_file(params->wpa_debug_file_path);