Merge pull request #580 from wigyori/cc-libpcap
[15.05/openwrt.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 @@ -190,7 +191,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 @@ -315,10 +317,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 @@ -1051,6 +1057,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 @@ -1092,6 +1104,12 @@ HOBJS += ../src/crypto/aes-internal.o
53  HOBJS += ../src/crypto/aes-internal-enc.o
54  endif
55  
56 +dump_cflags:
57 +       @echo -n $(CFLAGS) " "
58 +
59 +dump_ldflags:
60 +       @echo -n $(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 @@ -803,6 +804,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
76  CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
77  LIBS += -ldl -rdynamic
78  endif
79 +else
80 +  ifdef MULTICALL
81 +    OBJS += ../src/eap_common/eap_common.o
82 +  endif
83  endif
84  
85  ifdef CONFIG_MACSEC
86 @@ -823,9 +828,11 @@ NEED_EAP_COMMON=y
87  NEED_RSN_AUTHENTICATOR=y
88  CFLAGS += -DCONFIG_AP
89  OBJS += ap.o
90 +ifndef MULTICALL
91  CFLAGS += -DCONFIG_NO_RADIUS
92  CFLAGS += -DCONFIG_NO_ACCOUNTING
93  CFLAGS += -DCONFIG_NO_VLAN
94 +endif
95  OBJS += ../src/ap/hostapd.o
96  OBJS += ../src/ap/wpa_auth_glue.o
97  OBJS += ../src/ap/utils.o
98 @@ -898,10 +905,18 @@ endif
99  ifdef CONFIG_HS20
100  OBJS += ../src/ap/hs20.o
101  endif
102 +else
103 +  ifdef MULTICALL
104 +    OBJS += ../src/eap_server/eap_server.o
105 +    OBJS += ../src/eap_server/eap_server_identity.o
106 +    OBJS += ../src/eap_server/eap_server_methods.o
107 +  endif
108  endif
109  
110  ifdef NEED_RSN_AUTHENTICATOR
111 +ifndef MULTICALL
112  CFLAGS += -DCONFIG_NO_RADIUS
113 +endif
114  NEED_AES_WRAP=y
115  OBJS += ../src/ap/wpa_auth.o
116  OBJS += ../src/ap/wpa_auth_ie.o
117 @@ -1680,6 +1695,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
118  
119  $(OBJS_c) $(OBJS_t) $(OBJS_t2) $(OBJS) $(BCHECK) $(EXTRA_progs): .config
120  
121 +wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
122 +       $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c
123 +       @$(E) "  CC " $<
124 +       @rm -f $@
125 +       @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
126 +
127  wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
128         $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
129         @$(E) "  LD " $@
130 @@ -1782,6 +1803,12 @@ endif
131                 -e 's|\@DBUS_INTERFACE\@|$(DBUS_INTERFACE)|g' $< >$@
132         @$(E) "  sed" $<
133  
134 +dump_cflags:
135 +       @echo -n $(CFLAGS) " "
136 +
137 +dump_ldflags:
138 +       @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " "
139 +
140  wpa_supplicant.exe: wpa_supplicant
141         mv -f $< $@
142  wpa_cli.exe: wpa_cli
143 --- a/src/drivers/driver.h
144 +++ b/src/drivers/driver.h
145 @@ -4794,8 +4794,8 @@ union wpa_event_data {
146   * Driver wrapper code should call this function whenever an event is received
147   * from the driver.
148   */
149 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
150 -                         union wpa_event_data *data);
151 +extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
152 +                                   union wpa_event_data *data);
153  
154  /**
155   * wpa_supplicant_event_global - Report a driver event for wpa_supplicant
156 @@ -4807,7 +4807,7 @@ void wpa_supplicant_event(void *ctx, enu
157   * Same as wpa_supplicant_event(), but we search for the interface in
158   * wpa_global.
159   */
160 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
161 +extern void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
162                                  union wpa_event_data *data);
163  
164  /*
165 --- a/src/ap/drv_callbacks.c
166 +++ b/src/ap/drv_callbacks.c
167 @@ -1157,8 +1157,8 @@ static void hostapd_event_dfs_cac_starte
168  #endif /* NEED_AP_MLME */
169  
170  
171 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
172 -                         union wpa_event_data *data)
173 +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
174 +                      union wpa_event_data *data)
175  {
176         struct hostapd_data *hapd = ctx;
177  #ifndef CONFIG_NO_STDOUT_DEBUG
178 @@ -1367,7 +1367,7 @@ void wpa_supplicant_event(void *ctx, enu
179  }
180  
181  
182 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
183 +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
184                                  union wpa_event_data *data)
185  {
186         struct hapd_interfaces *interfaces = ctx;
187 --- a/wpa_supplicant/wpa_priv.c
188 +++ b/wpa_supplicant/wpa_priv.c
189 @@ -940,8 +940,8 @@ static void wpa_priv_send_ft_response(st
190  }
191  
192  
193 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
194 -                         union wpa_event_data *data)
195 +static void supplicant_event(void *ctx, enum wpa_event_type event,
196 +                            union wpa_event_data *data)
197  {
198         struct wpa_priv_interface *iface = ctx;
199  
200 @@ -1010,7 +1010,7 @@ void wpa_supplicant_event(void *ctx, enu
201  }
202  
203  
204 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
205 +void supplicant_event_global(void *ctx, enum wpa_event_type event,
206                                  union wpa_event_data *data)
207  {
208         struct wpa_priv_global *global = ctx;
209 @@ -1122,6 +1122,8 @@ int main(int argc, char *argv[])
210         if (os_program_init())
211                 return -1;
212  
213 +       wpa_supplicant_event = supplicant_event;
214 +       wpa_supplicant_event_global = supplicant_event_global;
215         wpa_priv_fd_workaround();
216  
217         os_memset(&global, 0, sizeof(global));
218 --- a/wpa_supplicant/events.c
219 +++ b/wpa_supplicant/events.c
220 @@ -3384,8 +3384,8 @@ static void wpa_supplicant_event_assoc_a
221  }
222  
223  
224 -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
225 -                         union wpa_event_data *data)
226 +void supplicant_event(void *ctx, enum wpa_event_type event,
227 +                     union wpa_event_data *data)
228  {
229         struct wpa_supplicant *wpa_s = ctx;
230         int resched;
231 @@ -4051,7 +4051,7 @@ void wpa_supplicant_event(void *ctx, enu
232  #endif /* CONFIG_AP */
233                 break;
234         case EVENT_ACS_CHANNEL_SELECTED:
235 -#ifdef CONFIG_ACS
236 +#if defined(CONFIG_ACS) && defined(CONFIG_AP)
237                 if (!wpa_s->ap_iface)
238                         break;
239                 hostapd_acs_channel_selected(wpa_s->ap_iface->bss[0],
240 @@ -4065,7 +4065,7 @@ void wpa_supplicant_event(void *ctx, enu
241  }
242  
243  
244 -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
245 +void supplicant_event_global(void *ctx, enum wpa_event_type event,
246                                  union wpa_event_data *data)
247  {
248         struct wpa_supplicant *wpa_s;
249 --- a/wpa_supplicant/wpa_supplicant.c
250 +++ b/wpa_supplicant/wpa_supplicant.c
251 @@ -4982,7 +4982,6 @@ struct wpa_interface * wpa_supplicant_ma
252         return NULL;
253  }
254  
255 -
256  /**
257   * wpa_supplicant_match_existing - Match existing interfaces
258   * @global: Pointer to global data from wpa_supplicant_init()
259 @@ -5019,6 +5018,11 @@ static int wpa_supplicant_match_existing
260  
261  #endif /* CONFIG_MATCH_IFACE */
262  
263 +extern void supplicant_event(void *ctx, enum wpa_event_type event,
264 +                            union wpa_event_data *data);
265 +
266 +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
267 +                                union wpa_event_data *data);
268  
269  /**
270   * wpa_supplicant_add_iface - Add a new network interface
271 @@ -5274,6 +5278,8 @@ struct wpa_global * wpa_supplicant_init(
272  #ifndef CONFIG_NO_WPA_MSG
273         wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
274  #endif /* CONFIG_NO_WPA_MSG */
275 +       wpa_supplicant_event = supplicant_event;
276 +       wpa_supplicant_event_global = supplicant_event_global;
277  
278         if (params->wpa_debug_file_path)
279                 wpa_debug_open_file(params->wpa_debug_file_path);
280 --- a/hostapd/main.c
281 +++ b/hostapd/main.c
282 @@ -583,6 +583,11 @@ fail:
283         return -1;
284  }
285  
286 +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
287 +                       union wpa_event_data *data);
288 +
289 +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
290 +                                union wpa_event_data *data);
291  
292  #ifdef CONFIG_WPS
293  static int gen_uuid(const char *txt_addr)
294 @@ -660,6 +665,8 @@ int main(int argc, char *argv[])
295         interfaces.global_ctrl_sock = -1;
296         dl_list_init(&interfaces.global_ctrl_dst);
297  
298 +       wpa_supplicant_event = hostapd_wpa_event;
299 +       wpa_supplicant_event_global = hostapd_wpa_event_global;
300         for (;;) {
301                 c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:");
302                 if (c < 0)
303 --- a/src/drivers/drivers.c
304 +++ b/src/drivers/drivers.c
305 @@ -10,6 +10,11 @@
306  #include "utils/common.h"
307  #include "driver.h"
308  
309 +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
310 +                            union wpa_event_data *data);
311 +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
312 +                            union wpa_event_data *data);
313 +
314  #ifdef CONFIG_DRIVER_WEXT
315  extern struct wpa_driver_ops wpa_driver_wext_ops; /* driver_wext.c */
316  #endif /* CONFIG_DRIVER_WEXT */
317 --- a/wpa_supplicant/eapol_test.c
318 +++ b/wpa_supplicant/eapol_test.c
319 @@ -29,7 +29,12 @@
320  #include "ctrl_iface.h"
321  #include "pcsc_funcs.h"
322  #include "wpas_glue.h"
323 +#include "drivers/driver.h"
324  
325 +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
326 +                            union wpa_event_data *data);
327 +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
328 +                            union wpa_event_data *data);
329  
330  const struct wpa_driver_ops *const wpa_drivers[] = { NULL };
331  
332 @@ -1295,6 +1300,10 @@ static void usage(void)
333                "option several times.\n");
334  }
335  
336 +extern void supplicant_event(void *ctx, enum wpa_event_type event,
337 +                            union wpa_event_data *data);
338 +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
339 +                            union wpa_event_data *data);
340  
341  int main(int argc, char *argv[])
342  {
343 @@ -1315,6 +1324,8 @@ int main(int argc, char *argv[])
344         if (os_program_init())
345                 return -1;
346  
347 +       wpa_supplicant_event = supplicant_event;
348 +       wpa_supplicant_event_global = supplicant_event_global;
349         hostapd_logger_register_cb(hostapd_logger_cb);
350  
351         os_memset(&eapol_test, 0, sizeof(eapol_test));