Fresh pull from upstream
[librecmc/librecmc.git] / package / network / services / hostapd / patches / 200-multicall.patch
1 --- a/hostapd/Makefile
2 +++ b/hostapd/Makefile
3 @@ -28,6 +28,7 @@ CFLAGS += -I$(abspath ../src/utils)
4  export BINDIR ?= /usr/local/bin/
5  
6  -include .config
7 +-include $(if $(MULTICALL), ../wpa_supplicant/.config)
8  
9  ifndef CONFIG_NO_GITVER
10  # Add VERSION_STR postfix for builds from a git repository
11 @@ -198,7 +199,8 @@ endif
12  
13  ifdef CONFIG_NO_VLAN
14  CFLAGS += -DCONFIG_NO_VLAN
15 -else
16 +endif
17 +ifneq ($(findstring CONFIG_NO_VLAN,$(CFLAGS)), CONFIG_NO_VLAN)
18  OBJS += ../src/ap/vlan_init.o
19  OBJS += ../src/ap/vlan_ifconfig.o
20  OBJS += ../src/ap/vlan.o
21 @@ -330,10 +332,14 @@ CFLAGS += -DCONFIG_MBO
22  OBJS += ../src/ap/mbo_ap.o
23  endif
24  
25 +ifndef MULTICALL
26 +CFLAGS += -DNO_SUPPLICANT
27 +endif
28 +
29  include ../src/drivers/drivers.mak
30 -OBJS += $(DRV_AP_OBJS)
31 -CFLAGS += $(DRV_AP_CFLAGS)
32 -LDFLAGS += $(DRV_AP_LDFLAGS)
33 +OBJS += $(sort $(DRV_AP_OBJS) $(if $(MULTICALL),$(DRV_WPA_OBJS)))
34 +CFLAGS += $(DRV_AP_CFLAGS) $(if $(MULTICALL),$(DRV_WPA_CFLAGS))
35 +LDFLAGS += $(DRV_AP_LDFLAGS) $(if $(MULTICALL),$(DRV_WPA_LDFLAGS))
36  LIBS += $(DRV_AP_LIBS)
37  
38  ifdef CONFIG_L2_PACKET
39 @@ -1073,6 +1079,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR)
40  
41  BCHECK=../src/drivers/build.hostapd
42  
43 +hostapd_multi.a: $(BCHECK) $(OBJS)
44 +       $(Q)$(CC) -c -o hostapd_multi.o -Dmain=hostapd_main $(CFLAGS) main.c
45 +       @$(E) "  CC " $<
46 +       @rm -f $@
47 +       @$(AR) cr $@ hostapd_multi.o $(OBJS)
48 +
49  hostapd: $(BCHECK) $(OBJS)
50         $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
51         @$(E) "  LD " $@
52 @@ -1114,6 +1126,12 @@ HOBJS += ../src/crypto/aes-internal.o
53  HOBJS += ../src/crypto/aes-internal-enc.o
54  endif
55  
56 +dump_cflags:
57 +       @printf "%s " "$(CFLAGS)"
58 +
59 +dump_ldflags:
60 +       @printf "%s " "$(LDFLAGS) $(LIBS) $(EXTRALIBS)"
61 +
62  nt_password_hash: $(NOBJS)
63         $(Q)$(CC) $(LDFLAGS) -o nt_password_hash $(NOBJS) $(LIBS_n)
64         @$(E) "  LD " $@
65 --- a/wpa_supplicant/Makefile
66 +++ b/wpa_supplicant/Makefile
67 @@ -27,6 +27,7 @@ CFLAGS += -I$(abspath ../src)
68  CFLAGS += -I$(abspath ../src/utils)
69  
70  -include .config
71 +-include $(if $(MULTICALL),../hostapd/.config)
72  
73  ifndef CONFIG_NO_GITVER
74  # Add VERSION_STR postfix for builds from a git repository
75 @@ -329,7 +330,9 @@ endif
76  ifdef CONFIG_IBSS_RSN
77  NEED_RSN_AUTHENTICATOR=y
78  CFLAGS += -DCONFIG_IBSS_RSN
79 +ifndef MULTICALL
80  CFLAGS += -DCONFIG_NO_VLAN
81 +endif
82  OBJS += ibss_rsn.o
83  endif
84  
85 @@ -820,6 +823,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
86  CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
87  LIBS += -ldl -rdynamic
88  endif
89 +else
90 +  ifdef MULTICALL
91 +    OBJS += ../src/eap_common/eap_common.o
92 +  endif
93  endif
94  
95  ifdef CONFIG_MACSEC
96 @@ -840,9 +847,11 @@ NEED_EAP_COMMON=y
97  NEED_RSN_AUTHENTICATOR=y
98  CFLAGS += -DCONFIG_AP
99  OBJS += ap.o
100 +ifndef MULTICALL
101  CFLAGS += -DCONFIG_NO_RADIUS
102  CFLAGS += -DCONFIG_NO_ACCOUNTING
103  CFLAGS += -DCONFIG_NO_VLAN
104 +endif
105  OBJS += ../src/ap/hostapd.o
106  OBJS += ../src/ap/wpa_auth_glue.o
107  OBJS += ../src/ap/utils.o
108 @@ -910,6 +919,12 @@ endif
109  ifdef CONFIG_HS20
110  OBJS += ../src/ap/hs20.o
111  endif
112 +else
113 +  ifdef MULTICALL
114 +    OBJS += ../src/eap_server/eap_server.o
115 +    OBJS += ../src/eap_server/eap_server_identity.o
116 +    OBJS += ../src/eap_server/eap_server_methods.o
117 +  endif
118  endif
119  
120  ifdef CONFIG_MBO
121 @@ -918,7 +933,9 @@ CFLAGS += -DCONFIG_MBO
122  endif
123  
124  ifdef NEED_RSN_AUTHENTICATOR
125 +ifndef MULTICALL
126  CFLAGS += -DCONFIG_NO_RADIUS
127 +endif
128  NEED_AES_WRAP=y
129  OBJS += ../src/ap/wpa_auth.o
130  OBJS += ../src/ap/wpa_auth_ie.o
131 @@ -1706,6 +1723,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
132  
133  $(OBJS_c) $(OBJS_t) $(OBJS_t2) $(OBJS) $(BCHECK) $(EXTRA_progs): .config
134  
135 +wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
136 +       $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c
137 +       @$(E) "  CC " $<
138 +       @rm -f $@
139 +       @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
140 +
141  wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
142         $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
143         @$(E) "  LD " $@
144 @@ -1808,6 +1831,12 @@ endif
145                 -e 's|\@DBUS_INTERFACE\@|$(DBUS_INTERFACE)|g' $< >$@
146         @$(E) "  sed" $<
147  
148 +dump_cflags:
149 +       @printf "%s " "$(CFLAGS)"
150 +
151 +dump_ldflags:
152 +       @printf "%s " "$(LDFLAGS) $(LIBS) $(EXTRALIBS)"
153 +
154  wpa_supplicant.exe: wpa_supplicant
155         mv -f $< $@
156  wpa_cli.exe: wpa_cli
157 --- a/src/drivers/driver.h
158 +++ b/src/drivers/driver.h
159 @@ -4968,8 +4968,8 @@ union wpa_event_data {
160   * Driver wrapper code should call this function whenever an event is received
161   * from the driver.
162   */
163 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
164 -                         union wpa_event_data *data);
165 +extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
166 +                                   union wpa_event_data *data);
167  
168  /**
169   * wpa_supplicant_event_global - Report a driver event for wpa_supplicant
170 @@ -4981,7 +4981,7 @@ void wpa_supplicant_event(void *ctx, enu
171   * Same as wpa_supplicant_event(), but we search for the interface in
172   * wpa_global.
173   */
174 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
175 +extern void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
176                                  union wpa_event_data *data);
177  
178  /*
179 --- a/src/ap/drv_callbacks.c
180 +++ b/src/ap/drv_callbacks.c
181 @@ -1163,8 +1163,8 @@ static void hostapd_event_dfs_cac_starte
182  #endif /* NEED_AP_MLME */
183  
184  
185 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
186 -                         union wpa_event_data *data)
187 +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
188 +                      union wpa_event_data *data)
189  {
190         struct hostapd_data *hapd = ctx;
191  #ifndef CONFIG_NO_STDOUT_DEBUG
192 @@ -1373,7 +1373,7 @@ void wpa_supplicant_event(void *ctx, enu
193  }
194  
195  
196 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
197 +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
198                                  union wpa_event_data *data)
199  {
200         struct hapd_interfaces *interfaces = ctx;
201 --- a/wpa_supplicant/wpa_priv.c
202 +++ b/wpa_supplicant/wpa_priv.c
203 @@ -1031,8 +1031,8 @@ static void wpa_priv_send_ft_response(st
204  }
205  
206  
207 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
208 -                         union wpa_event_data *data)
209 +static void supplicant_event(void *ctx, enum wpa_event_type event,
210 +                            union wpa_event_data *data)
211  {
212         struct wpa_priv_interface *iface = ctx;
213  
214 @@ -1101,7 +1101,7 @@ void wpa_supplicant_event(void *ctx, enu
215  }
216  
217  
218 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
219 +void supplicant_event_global(void *ctx, enum wpa_event_type event,
220                                  union wpa_event_data *data)
221  {
222         struct wpa_priv_global *global = ctx;
223 @@ -1213,6 +1213,8 @@ int main(int argc, char *argv[])
224         if (os_program_init())
225                 return -1;
226  
227 +       wpa_supplicant_event = supplicant_event;
228 +       wpa_supplicant_event_global = supplicant_event_global;
229         wpa_priv_fd_workaround();
230  
231         os_memset(&global, 0, sizeof(global));
232 --- a/wpa_supplicant/events.c
233 +++ b/wpa_supplicant/events.c
234 @@ -3610,8 +3610,8 @@ static void wpa_supplicant_event_assoc_a
235  }
236  
237  
238 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
239 -                         union wpa_event_data *data)
240 +void supplicant_event(void *ctx, enum wpa_event_type event,
241 +                     union wpa_event_data *data)
242  {
243         struct wpa_supplicant *wpa_s = ctx;
244         int resched;
245 @@ -4315,7 +4315,7 @@ void wpa_supplicant_event(void *ctx, enu
246  #endif /* CONFIG_AP */
247                 break;
248         case EVENT_ACS_CHANNEL_SELECTED:
249 -#ifdef CONFIG_ACS
250 +#if defined(CONFIG_ACS) && defined(CONFIG_AP)
251                 if (!wpa_s->ap_iface)
252                         break;
253                 hostapd_acs_channel_selected(wpa_s->ap_iface->bss[0],
254 @@ -4337,7 +4337,7 @@ void wpa_supplicant_event(void *ctx, enu
255  }
256  
257  
258 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
259 +void supplicant_event_global(void *ctx, enum wpa_event_type event,
260                                  union wpa_event_data *data)
261  {
262         struct wpa_supplicant *wpa_s;
263 --- a/wpa_supplicant/wpa_supplicant.c
264 +++ b/wpa_supplicant/wpa_supplicant.c
265 @@ -5136,7 +5136,6 @@ struct wpa_interface * wpa_supplicant_ma
266         return NULL;
267  }
268  
269 -
270  /**
271   * wpa_supplicant_match_existing - Match existing interfaces
272   * @global: Pointer to global data from wpa_supplicant_init()
273 @@ -5173,6 +5172,11 @@ static int wpa_supplicant_match_existing
274  
275  #endif /* CONFIG_MATCH_IFACE */
276  
277 +extern void supplicant_event(void *ctx, enum wpa_event_type event,
278 +                            union wpa_event_data *data);
279 +
280 +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
281 +                                union wpa_event_data *data);
282  
283  /**
284   * wpa_supplicant_add_iface - Add a new network interface
285 @@ -5428,6 +5432,8 @@ struct wpa_global * wpa_supplicant_init(
286  #ifndef CONFIG_NO_WPA_MSG
287         wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
288  #endif /* CONFIG_NO_WPA_MSG */
289 +       wpa_supplicant_event = supplicant_event;
290 +       wpa_supplicant_event_global = supplicant_event_global;
291  
292         if (params->wpa_debug_file_path)
293                 wpa_debug_open_file(params->wpa_debug_file_path);
294 --- a/hostapd/main.c
295 +++ b/hostapd/main.c
296 @@ -583,6 +583,11 @@ fail:
297         return -1;
298  }
299  
300 +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
301 +                       union wpa_event_data *data);
302 +
303 +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
304 +                                union wpa_event_data *data);
305  
306  #ifdef CONFIG_WPS
307  static int gen_uuid(const char *txt_addr)
308 @@ -660,6 +665,8 @@ int main(int argc, char *argv[])
309         interfaces.global_ctrl_sock = -1;
310         dl_list_init(&interfaces.global_ctrl_dst);
311  
312 +       wpa_supplicant_event = hostapd_wpa_event;
313 +       wpa_supplicant_event_global = hostapd_wpa_event_global;
314         for (;;) {
315                 c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:");
316                 if (c < 0)
317 --- a/src/drivers/drivers.c
318 +++ b/src/drivers/drivers.c
319 @@ -10,6 +10,10 @@
320  #include "utils/common.h"
321  #include "driver.h"
322  
323 +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
324 +                            union wpa_event_data *data);
325 +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
326 +                            union wpa_event_data *data);
327  
328  const struct wpa_driver_ops *const wpa_drivers[] =
329  {
330 --- a/wpa_supplicant/eapol_test.c
331 +++ b/wpa_supplicant/eapol_test.c
332 @@ -29,7 +29,12 @@
333  #include "ctrl_iface.h"
334  #include "pcsc_funcs.h"
335  #include "wpas_glue.h"
336 +#include "drivers/driver.h"
337  
338 +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
339 +                            union wpa_event_data *data);
340 +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
341 +                            union wpa_event_data *data);
342  
343  const struct wpa_driver_ops *const wpa_drivers[] = { NULL };
344  
345 @@ -1295,6 +1300,10 @@ static void usage(void)
346                "option several times.\n");
347  }
348  
349 +extern void supplicant_event(void *ctx, enum wpa_event_type event,
350 +                            union wpa_event_data *data);
351 +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
352 +                            union wpa_event_data *data);
353  
354  int main(int argc, char *argv[])
355  {
356 @@ -1315,6 +1324,8 @@ int main(int argc, char *argv[])
357         if (os_program_init())
358                 return -1;
359  
360 +       wpa_supplicant_event = supplicant_event;
361 +       wpa_supplicant_event_global = supplicant_event_global;
362         hostapd_logger_register_cb(hostapd_logger_cb);
363  
364         os_memset(&eapol_test, 0, sizeof(eapol_test));