First git repo commit for the libreCMC project
[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 @@ -193,7 +194,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 @@ -318,10 +320,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 @@ -1054,6 +1060,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 @@ -1095,6 +1107,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 @@ -313,7 +314,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 @@ -804,6 +807,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 @@ -824,9 +831,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 @@ -899,10 +908,18 @@ 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 NEED_RSN_AUTHENTICATOR
121 +ifndef MULTICALL
122  CFLAGS += -DCONFIG_NO_RADIUS
123 +endif
124  NEED_AES_WRAP=y
125  OBJS += ../src/ap/wpa_auth.o
126  OBJS += ../src/ap/wpa_auth_ie.o
127 @@ -1685,6 +1702,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
128  
129  $(OBJS_c) $(OBJS_t) $(OBJS_t2) $(OBJS) $(BCHECK) $(EXTRA_progs): .config
130  
131 +wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
132 +       $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c
133 +       @$(E) "  CC " $<
134 +       @rm -f $@
135 +       @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
136 +
137  wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
138         $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
139         @$(E) "  LD " $@
140 @@ -1787,6 +1810,12 @@ endif
141                 -e 's|\@DBUS_INTERFACE\@|$(DBUS_INTERFACE)|g' $< >$@
142         @$(E) "  sed" $<
143  
144 +dump_cflags:
145 +       @printf "%s " "$(CFLAGS)"
146 +
147 +dump_ldflags:
148 +       @printf "%s " "$(LDFLAGS) $(LIBS) $(EXTRALIBS)"
149 +
150  wpa_supplicant.exe: wpa_supplicant
151         mv -f $< $@
152  wpa_cli.exe: wpa_cli
153 --- a/src/drivers/driver.h
154 +++ b/src/drivers/driver.h
155 @@ -4870,8 +4870,8 @@ union wpa_event_data {
156   * Driver wrapper code should call this function whenever an event is received
157   * from the driver.
158   */
159 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
160 -                         union wpa_event_data *data);
161 +extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
162 +                                   union wpa_event_data *data);
163  
164  /**
165   * wpa_supplicant_event_global - Report a driver event for wpa_supplicant
166 @@ -4883,7 +4883,7 @@ void wpa_supplicant_event(void *ctx, enu
167   * Same as wpa_supplicant_event(), but we search for the interface in
168   * wpa_global.
169   */
170 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
171 +extern void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
172                                  union wpa_event_data *data);
173  
174  /*
175 --- a/src/ap/drv_callbacks.c
176 +++ b/src/ap/drv_callbacks.c
177 @@ -1164,8 +1164,8 @@ static void hostapd_event_dfs_cac_starte
178  #endif /* NEED_AP_MLME */
179  
180  
181 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
182 -                         union wpa_event_data *data)
183 +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
184 +                      union wpa_event_data *data)
185  {
186         struct hostapd_data *hapd = ctx;
187  #ifndef CONFIG_NO_STDOUT_DEBUG
188 @@ -1374,7 +1374,7 @@ void wpa_supplicant_event(void *ctx, enu
189  }
190  
191  
192 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
193 +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
194                                  union wpa_event_data *data)
195  {
196         struct hapd_interfaces *interfaces = ctx;
197 --- a/wpa_supplicant/wpa_priv.c
198 +++ b/wpa_supplicant/wpa_priv.c
199 @@ -940,8 +940,8 @@ static void wpa_priv_send_ft_response(st
200  }
201  
202  
203 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
204 -                         union wpa_event_data *data)
205 +static void supplicant_event(void *ctx, enum wpa_event_type event,
206 +                            union wpa_event_data *data)
207  {
208         struct wpa_priv_interface *iface = ctx;
209  
210 @@ -1010,7 +1010,7 @@ void wpa_supplicant_event(void *ctx, enu
211  }
212  
213  
214 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
215 +void supplicant_event_global(void *ctx, enum wpa_event_type event,
216                                  union wpa_event_data *data)
217  {
218         struct wpa_priv_global *global = ctx;
219 @@ -1122,6 +1122,8 @@ int main(int argc, char *argv[])
220         if (os_program_init())
221                 return -1;
222  
223 +       wpa_supplicant_event = supplicant_event;
224 +       wpa_supplicant_event_global = supplicant_event_global;
225         wpa_priv_fd_workaround();
226  
227         os_memset(&global, 0, sizeof(global));
228 --- a/wpa_supplicant/events.c
229 +++ b/wpa_supplicant/events.c
230 @@ -3398,8 +3398,8 @@ static void wpa_supplicant_event_assoc_a
231  }
232  
233  
234 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
235 -                         union wpa_event_data *data)
236 +void supplicant_event(void *ctx, enum wpa_event_type event,
237 +                     union wpa_event_data *data)
238  {
239         struct wpa_supplicant *wpa_s = ctx;
240         int resched;
241 @@ -4074,7 +4074,7 @@ void wpa_supplicant_event(void *ctx, enu
242  #endif /* CONFIG_AP */
243                 break;
244         case EVENT_ACS_CHANNEL_SELECTED:
245 -#ifdef CONFIG_ACS
246 +#if defined(CONFIG_ACS) && defined(CONFIG_AP)
247                 if (!wpa_s->ap_iface)
248                         break;
249                 hostapd_acs_channel_selected(wpa_s->ap_iface->bss[0],
250 @@ -4096,7 +4096,7 @@ void wpa_supplicant_event(void *ctx, enu
251  }
252  
253  
254 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
255 +void supplicant_event_global(void *ctx, enum wpa_event_type event,
256                                  union wpa_event_data *data)
257  {
258         struct wpa_supplicant *wpa_s;
259 --- a/wpa_supplicant/wpa_supplicant.c
260 +++ b/wpa_supplicant/wpa_supplicant.c
261 @@ -5094,7 +5094,6 @@ struct wpa_interface * wpa_supplicant_ma
262         return NULL;
263  }
264  
265 -
266  /**
267   * wpa_supplicant_match_existing - Match existing interfaces
268   * @global: Pointer to global data from wpa_supplicant_init()
269 @@ -5131,6 +5130,11 @@ static int wpa_supplicant_match_existing
270  
271  #endif /* CONFIG_MATCH_IFACE */
272  
273 +extern void supplicant_event(void *ctx, enum wpa_event_type event,
274 +                            union wpa_event_data *data);
275 +
276 +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
277 +                                union wpa_event_data *data);
278  
279  /**
280   * wpa_supplicant_add_iface - Add a new network interface
281 @@ -5386,6 +5390,8 @@ struct wpa_global * wpa_supplicant_init(
282  #ifndef CONFIG_NO_WPA_MSG
283         wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
284  #endif /* CONFIG_NO_WPA_MSG */
285 +       wpa_supplicant_event = supplicant_event;
286 +       wpa_supplicant_event_global = supplicant_event_global;
287  
288         if (params->wpa_debug_file_path)
289                 wpa_debug_open_file(params->wpa_debug_file_path);
290 --- a/hostapd/main.c
291 +++ b/hostapd/main.c
292 @@ -583,6 +583,11 @@ fail:
293         return -1;
294  }
295  
296 +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
297 +                       union wpa_event_data *data);
298 +
299 +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
300 +                                union wpa_event_data *data);
301  
302  #ifdef CONFIG_WPS
303  static int gen_uuid(const char *txt_addr)
304 @@ -660,6 +665,8 @@ int main(int argc, char *argv[])
305         interfaces.global_ctrl_sock = -1;
306         dl_list_init(&interfaces.global_ctrl_dst);
307  
308 +       wpa_supplicant_event = hostapd_wpa_event;
309 +       wpa_supplicant_event_global = hostapd_wpa_event_global;
310         for (;;) {
311                 c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:");
312                 if (c < 0)
313 --- a/src/drivers/drivers.c
314 +++ b/src/drivers/drivers.c
315 @@ -10,6 +10,10 @@
316  #include "utils/common.h"
317  #include "driver.h"
318  
319 +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
320 +                            union wpa_event_data *data);
321 +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
322 +                            union wpa_event_data *data);
323  
324  const struct wpa_driver_ops *const wpa_drivers[] =
325  {
326 --- a/wpa_supplicant/eapol_test.c
327 +++ b/wpa_supplicant/eapol_test.c
328 @@ -29,7 +29,12 @@
329  #include "ctrl_iface.h"
330  #include "pcsc_funcs.h"
331  #include "wpas_glue.h"
332 +#include "drivers/driver.h"
333  
334 +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
335 +                            union wpa_event_data *data);
336 +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
337 +                            union wpa_event_data *data);
338  
339  const struct wpa_driver_ops *const wpa_drivers[] = { NULL };
340  
341 @@ -1295,6 +1300,10 @@ static void usage(void)
342                "option several times.\n");
343  }
344  
345 +extern void supplicant_event(void *ctx, enum wpa_event_type event,
346 +                            union wpa_event_data *data);
347 +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
348 +                            union wpa_event_data *data);
349  
350  int main(int argc, char *argv[])
351  {
352 @@ -1315,6 +1324,8 @@ int main(int argc, char *argv[])
353         if (os_program_init())
354                 return -1;
355  
356 +       wpa_supplicant_event = supplicant_event;
357 +       wpa_supplicant_event_global = supplicant_event_global;
358         hostapd_logger_register_cb(hostapd_logger_cb);
359  
360         os_memset(&eapol_test, 0, sizeof(eapol_test));