200-multicall.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. From: Felix Fietkau <[email protected]>
  2. Date: Sat, 23 Jan 2010 08:28:26 +0000
  3. Subject: [PATCH] Add option to build a multicall binary
  4. This allows building both hostapd and wpa_supplicant as a single binary
  5. (wpad).
  6. --- a/hostapd/Makefile
  7. +++ b/hostapd/Makefile
  8. @@ -1,6 +1,7 @@
  9. ALL=hostapd hostapd_cli
  10. CONFIG_FILE = .config
  11. +-include $(if $(MULTICALL), ../wpa_supplicant/.config)
  12. include ../src/build.rules
  13. ifdef LIBS
  14. @@ -200,7 +201,8 @@ endif
  15. ifdef CONFIG_NO_VLAN
  16. CFLAGS += -DCONFIG_NO_VLAN
  17. -else
  18. +endif
  19. +ifneq ($(findstring CONFIG_NO_VLAN,$(CFLAGS)), CONFIG_NO_VLAN)
  20. OBJS += ../src/ap/vlan_init.o
  21. OBJS += ../src/ap/vlan_ifconfig.o
  22. OBJS += ../src/ap/vlan.o
  23. @@ -360,10 +362,14 @@ CFLAGS += -DCONFIG_MBO
  24. OBJS += ../src/ap/mbo_ap.o
  25. endif
  26. +ifndef MULTICALL
  27. +CFLAGS += -DNO_SUPPLICANT
  28. +endif
  29. +
  30. include ../src/drivers/drivers.mak
  31. -OBJS += $(DRV_AP_OBJS)
  32. -CFLAGS += $(DRV_AP_CFLAGS)
  33. -LDFLAGS += $(DRV_AP_LDFLAGS)
  34. +OBJS += $(sort $(DRV_AP_OBJS) $(if $(MULTICALL),$(DRV_WPA_OBJS)))
  35. +CFLAGS += $(DRV_AP_CFLAGS) $(if $(MULTICALL),$(DRV_WPA_CFLAGS))
  36. +LDFLAGS += $(DRV_AP_LDFLAGS) $(if $(MULTICALL),$(DRV_WPA_LDFLAGS))
  37. LIBS += $(DRV_AP_LIBS)
  38. ifdef CONFIG_L2_PACKET
  39. @@ -1406,6 +1412,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR)
  40. _OBJS_VAR := OBJS
  41. include ../src/objs.mk
  42. +hostapd_multi.a: $(BCHECK) $(OBJS)
  43. + $(Q)$(CC) -c -o hostapd_multi.o -Dmain=hostapd_main $(CFLAGS) main.c
  44. + @$(E) " CC " $<
  45. + @rm -f $@
  46. + @$(AR) cr $@ hostapd_multi.o $(OBJS)
  47. +
  48. hostapd: $(OBJS)
  49. $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
  50. @$(E) " LD " $@
  51. @@ -1494,6 +1506,12 @@ include ../src/objs.mk
  52. _OBJS_VAR := SOBJS
  53. include ../src/objs.mk
  54. +dump_cflags:
  55. + @printf "%s " "$(CFLAGS)"
  56. +
  57. +dump_ldflags:
  58. + @printf "%s " "$(LDFLAGS) $(LIBS) $(EXTRALIBS)"
  59. +
  60. nt_password_hash: $(NOBJS)
  61. $(Q)$(CC) $(LDFLAGS) -o nt_password_hash $(NOBJS) $(LIBS_n)
  62. @$(E) " LD " $@
  63. --- a/hostapd/main.c
  64. +++ b/hostapd/main.c
  65. @@ -737,6 +737,11 @@ fail:
  66. return -1;
  67. }
  68. +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
  69. + union wpa_event_data *data);
  70. +
  71. +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
  72. + union wpa_event_data *data);
  73. #ifdef CONFIG_WPS
  74. static int gen_uuid(const char *txt_addr)
  75. @@ -858,6 +863,8 @@ int main(int argc, char *argv[])
  76. return -1;
  77. #endif /* CONFIG_DPP */
  78. + wpa_supplicant_event = hostapd_wpa_event;
  79. + wpa_supplicant_event_global = hostapd_wpa_event_global;
  80. for (;;) {
  81. c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:q");
  82. if (c < 0)
  83. --- a/src/ap/drv_callbacks.c
  84. +++ b/src/ap/drv_callbacks.c
  85. @@ -2566,8 +2566,8 @@ static void hostapd_mld_iface_disable(st
  86. #endif /* CONFIG_IEEE80211BE */
  87. -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
  88. - union wpa_event_data *data)
  89. +void hostapd_wpa_event(void *ctx, enum wpa_event_type event,
  90. + union wpa_event_data *data)
  91. {
  92. struct hostapd_data *hapd = ctx;
  93. struct sta_info *sta;
  94. @@ -2925,7 +2925,7 @@ void wpa_supplicant_event(void *ctx, enu
  95. }
  96. -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
  97. +void hostapd_wpa_event_global(void *ctx, enum wpa_event_type event,
  98. union wpa_event_data *data)
  99. {
  100. struct hapd_interfaces *interfaces = ctx;
  101. --- a/src/drivers/driver.h
  102. +++ b/src/drivers/driver.h
  103. @@ -7161,8 +7161,8 @@ union wpa_event_data {
  104. * Driver wrapper code should call this function whenever an event is received
  105. * from the driver.
  106. */
  107. -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
  108. - union wpa_event_data *data);
  109. +extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
  110. + union wpa_event_data *data);
  111. /**
  112. * wpa_supplicant_event_global - Report a driver event for wpa_supplicant
  113. @@ -7174,7 +7174,7 @@ void wpa_supplicant_event(void *ctx, enu
  114. * Same as wpa_supplicant_event(), but we search for the interface in
  115. * wpa_global.
  116. */
  117. -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
  118. +extern void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
  119. union wpa_event_data *data);
  120. /*
  121. --- a/src/drivers/drivers.c
  122. +++ b/src/drivers/drivers.c
  123. @@ -10,6 +10,10 @@
  124. #include "utils/common.h"
  125. #include "driver.h"
  126. +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
  127. + union wpa_event_data *data);
  128. +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
  129. + union wpa_event_data *data);
  130. const struct wpa_driver_ops *const wpa_drivers[] =
  131. {
  132. --- a/wpa_supplicant/Makefile
  133. +++ b/wpa_supplicant/Makefile
  134. @@ -10,6 +10,7 @@ ALL += dbus/fi.w1.wpa_supplicant1.servic
  135. EXTRA_TARGETS=dynamic_eap_methods
  136. CONFIG_FILE=.config
  137. +-include $(if $(MULTICALL),../hostapd/.config)
  138. include ../src/build.rules
  139. ifdef CONFIG_BUILD_PASN_SO
  140. @@ -390,7 +391,9 @@ endif
  141. ifdef CONFIG_IBSS_RSN
  142. NEED_RSN_AUTHENTICATOR=y
  143. CFLAGS += -DCONFIG_IBSS_RSN
  144. +ifndef MULTICALL
  145. CFLAGS += -DCONFIG_NO_VLAN
  146. +endif
  147. OBJS += ibss_rsn.o
  148. endif
  149. @@ -984,6 +987,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS
  150. CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS
  151. LIBS += -ldl -rdynamic
  152. endif
  153. +else
  154. + ifdef MULTICALL
  155. + OBJS += ../src/eap_common/eap_common.o
  156. + endif
  157. endif
  158. ifdef CONFIG_AP
  159. @@ -991,9 +998,11 @@ NEED_EAP_COMMON=y
  160. NEED_RSN_AUTHENTICATOR=y
  161. CFLAGS += -DCONFIG_AP
  162. OBJS += ap.o
  163. +ifndef MULTICALL
  164. CFLAGS += -DCONFIG_NO_RADIUS
  165. CFLAGS += -DCONFIG_NO_ACCOUNTING
  166. CFLAGS += -DCONFIG_NO_VLAN
  167. +endif
  168. OBJS += ../src/ap/hostapd.o
  169. OBJS += ../src/ap/wpa_auth_glue.o
  170. OBJS += ../src/ap/utils.o
  171. @@ -1084,6 +1093,12 @@ endif
  172. ifdef CONFIG_HS20
  173. OBJS += ../src/ap/hs20.o
  174. endif
  175. +else
  176. + ifdef MULTICALL
  177. + OBJS += ../src/eap_server/eap_server.o
  178. + OBJS += ../src/eap_server/eap_server_identity.o
  179. + OBJS += ../src/eap_server/eap_server_methods.o
  180. + endif
  181. endif
  182. ifdef CONFIG_MBO
  183. @@ -1093,7 +1108,9 @@ NEED_GAS=y
  184. endif
  185. ifdef NEED_RSN_AUTHENTICATOR
  186. +ifndef MULTICALL
  187. CFLAGS += -DCONFIG_NO_RADIUS
  188. +endif
  189. NEED_AES_WRAP=y
  190. OBJS += ../src/ap/wpa_auth.o
  191. OBJS += ../src/ap/wpa_auth_ie.o
  192. @@ -2084,6 +2101,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv)
  193. _OBJS_VAR := OBJS
  194. include ../src/objs.mk
  195. +wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs)
  196. + $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c
  197. + @$(E) " CC " $<
  198. + @rm -f $@
  199. + @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS)
  200. +
  201. wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
  202. $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
  203. @$(E) " LD " $@
  204. @@ -2216,6 +2239,12 @@ eap_gpsk.so: $(SRC_EAP_GPSK)
  205. $(Q)sed -e 's|\@BINDIR\@|$(BINDIR)|g' $< >$@
  206. @$(E) " sed" $<
  207. +dump_cflags:
  208. + @printf "%s " "$(CFLAGS)"
  209. +
  210. +dump_ldflags:
  211. + @printf "%s " "$(LDFLAGS) $(LIBS) $(EXTRALIBS)"
  212. +
  213. wpa_supplicant.exe: wpa_supplicant
  214. mv -f $< $@
  215. wpa_cli.exe: wpa_cli
  216. --- a/wpa_supplicant/eapol_test.c
  217. +++ b/wpa_supplicant/eapol_test.c
  218. @@ -31,7 +31,12 @@
  219. #include "ctrl_iface.h"
  220. #include "pcsc_funcs.h"
  221. #include "wpas_glue.h"
  222. +#include "drivers/driver.h"
  223. +void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event,
  224. + union wpa_event_data *data);
  225. +void (*wpa_supplicant_event_global)(void *ctx, enum wpa_event_type event,
  226. + union wpa_event_data *data);
  227. const struct wpa_driver_ops *const wpa_drivers[] = { NULL };
  228. @@ -1328,6 +1333,10 @@ static void usage(void)
  229. "option several times.\n");
  230. }
  231. +extern void supplicant_event(void *ctx, enum wpa_event_type event,
  232. + union wpa_event_data *data);
  233. +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
  234. + union wpa_event_data *data);
  235. int main(int argc, char *argv[])
  236. {
  237. @@ -1351,6 +1360,8 @@ int main(int argc, char *argv[])
  238. if (os_program_init())
  239. return -1;
  240. + wpa_supplicant_event = supplicant_event;
  241. + wpa_supplicant_event_global = supplicant_event_global;
  242. hostapd_logger_register_cb(hostapd_logger_cb);
  243. os_memset(&eapol_test, 0, sizeof(eapol_test));
  244. --- a/wpa_supplicant/events.c
  245. +++ b/wpa_supplicant/events.c
  246. @@ -6255,8 +6255,8 @@ static int wpas_pasn_auth(struct wpa_sup
  247. #endif /* CONFIG_PASN */
  248. -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
  249. - union wpa_event_data *data)
  250. +void supplicant_event(void *ctx, enum wpa_event_type event,
  251. + union wpa_event_data *data)
  252. {
  253. struct wpa_supplicant *wpa_s = ctx;
  254. int resched;
  255. @@ -7228,7 +7228,7 @@ void wpa_supplicant_event(void *ctx, enu
  256. }
  257. -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
  258. +void supplicant_event_global(void *ctx, enum wpa_event_type event,
  259. union wpa_event_data *data)
  260. {
  261. struct wpa_supplicant *wpa_s;
  262. --- a/wpa_supplicant/wpa_priv.c
  263. +++ b/wpa_supplicant/wpa_priv.c
  264. @@ -1042,8 +1042,8 @@ static void wpa_priv_send_ft_response(st
  265. }
  266. -void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
  267. - union wpa_event_data *data)
  268. +static void supplicant_event(void *ctx, enum wpa_event_type event,
  269. + union wpa_event_data *data)
  270. {
  271. struct wpa_priv_interface *iface = ctx;
  272. @@ -1106,7 +1106,7 @@ void wpa_supplicant_event(void *ctx, enu
  273. }
  274. -void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event,
  275. +void supplicant_event_global(void *ctx, enum wpa_event_type event,
  276. union wpa_event_data *data)
  277. {
  278. struct wpa_priv_global *global = ctx;
  279. @@ -1220,6 +1220,8 @@ int main(int argc, char *argv[])
  280. if (os_program_init())
  281. return -1;
  282. + wpa_supplicant_event = supplicant_event;
  283. + wpa_supplicant_event_global = supplicant_event_global;
  284. wpa_priv_fd_workaround();
  285. os_memset(&global, 0, sizeof(global));
  286. --- a/wpa_supplicant/wpa_supplicant.c
  287. +++ b/wpa_supplicant/wpa_supplicant.c
  288. @@ -8128,7 +8128,6 @@ struct wpa_interface * wpa_supplicant_ma
  289. return NULL;
  290. }
  291. -
  292. /**
  293. * wpa_supplicant_match_existing - Match existing interfaces
  294. * @global: Pointer to global data from wpa_supplicant_init()
  295. @@ -8163,6 +8162,11 @@ static int wpa_supplicant_match_existing
  296. #endif /* CONFIG_MATCH_IFACE */
  297. +extern void supplicant_event(void *ctx, enum wpa_event_type event,
  298. + union wpa_event_data *data);
  299. +
  300. +extern void supplicant_event_global(void *ctx, enum wpa_event_type event,
  301. + union wpa_event_data *data);
  302. /**
  303. * wpa_supplicant_add_iface - Add a new network interface
  304. @@ -8419,6 +8423,8 @@ struct wpa_global * wpa_supplicant_init(
  305. #ifndef CONFIG_NO_WPA_MSG
  306. wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb);
  307. #endif /* CONFIG_NO_WPA_MSG */
  308. + wpa_supplicant_event = supplicant_event;
  309. + wpa_supplicant_event_global = supplicant_event_global;
  310. if (params->wpa_debug_file_path)
  311. wpa_debug_open_file(params->wpa_debug_file_path);