From 716ca530e1c4515d8683c9d5be3d56b301758b66 Mon Sep 17 00:00:00 2001 From: James <> Date: Wed, 4 Nov 2015 11:49:21 +0000 Subject: trunk-47381 --- ...e-SSID-element-length-before-copying-it-C.patch | 37 + ...integer-underflow-in-WMM-Action-frame-par.patch | 36 + .../services/hostapd/patches/110-bool_fix.patch | 14 + .../hostapd/patches/120-daemonize_fix.patch | 97 +++ .../hostapd/patches/130-no_eapol_fix.patch | 14 + .../140-disable_bridge_packet_workaround.patch | 12 + .../services/hostapd/patches/200-multicall.patch | 276 +++++++ .../services/hostapd/patches/300-noscan.patch | 57 ++ .../hostapd/patches/310-rescan_immediately.patch | 11 + .../hostapd/patches/320-optional_rfkill.patch | 61 ++ .../hostapd/patches/330-nl80211_fix_set_freq.patch | 11 + .../hostapd/patches/340-reload_freq_change.patch | 44 ++ .../patches/350-nl80211_del_beacon_bss.patch | 72 ++ .../hostapd/patches/360-ctrl_iface_reload.patch | 104 +++ .../hostapd/patches/370-ap_sta_support.patch | 237 ++++++ .../patches/380-disable_ctrl_iface_mib.patch | 178 +++++ .../patches/390-wpa_ie_cap_workaround.patch | 56 ++ .../patches/400-wps_single_auth_enc_type.patch | 25 + .../hostapd/patches/410-limit_debug_messages.patch | 214 +++++ .../hostapd/patches/420-indicate-features.patch | 82 ++ .../hostapd/patches/430-hostapd_cli_ifdef.patch | 50 ++ .../hostapd/patches/431-wpa_cli_ifdef.patch | 13 + .../hostapd/patches/440-max_num_sta_probe.patch | 13 + .../services/hostapd/patches/450-scan_wait.patch | 66 ++ ...ant-add-new-config-params-to-be-used-with.patch | 188 +++++ ...80211-use-new-parameters-during-ibss-join.patch | 59 ++ .../patches/462-wpa_s-support-htmode-param.patch | 156 ++++ .../patches/470-wait-for-nullfunc-longer.patch | 11 + .../hostapd/patches/600-ubus_support.patch | 858 +++++++++++++++++++++ 29 files changed, 3052 insertions(+) create mode 100644 package/network/services/hostapd/patches/001-P2P-Validate-SSID-element-length-before-copying-it-C.patch create mode 100644 package/network/services/hostapd/patches/002-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch create mode 100644 package/network/services/hostapd/patches/110-bool_fix.patch create mode 100644 package/network/services/hostapd/patches/120-daemonize_fix.patch create mode 100644 package/network/services/hostapd/patches/130-no_eapol_fix.patch create mode 100644 package/network/services/hostapd/patches/140-disable_bridge_packet_workaround.patch create mode 100644 package/network/services/hostapd/patches/200-multicall.patch create mode 100644 package/network/services/hostapd/patches/300-noscan.patch create mode 100644 package/network/services/hostapd/patches/310-rescan_immediately.patch create mode 100644 package/network/services/hostapd/patches/320-optional_rfkill.patch create mode 100644 package/network/services/hostapd/patches/330-nl80211_fix_set_freq.patch create mode 100644 package/network/services/hostapd/patches/340-reload_freq_change.patch create mode 100644 package/network/services/hostapd/patches/350-nl80211_del_beacon_bss.patch create mode 100644 package/network/services/hostapd/patches/360-ctrl_iface_reload.patch create mode 100644 package/network/services/hostapd/patches/370-ap_sta_support.patch create mode 100644 package/network/services/hostapd/patches/380-disable_ctrl_iface_mib.patch create mode 100644 package/network/services/hostapd/patches/390-wpa_ie_cap_workaround.patch create mode 100644 package/network/services/hostapd/patches/400-wps_single_auth_enc_type.patch create mode 100644 package/network/services/hostapd/patches/410-limit_debug_messages.patch create mode 100644 package/network/services/hostapd/patches/420-indicate-features.patch create mode 100644 package/network/services/hostapd/patches/430-hostapd_cli_ifdef.patch create mode 100644 package/network/services/hostapd/patches/431-wpa_cli_ifdef.patch create mode 100644 package/network/services/hostapd/patches/440-max_num_sta_probe.patch create mode 100644 package/network/services/hostapd/patches/450-scan_wait.patch create mode 100644 package/network/services/hostapd/patches/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch create mode 100644 package/network/services/hostapd/patches/461-driver_nl80211-use-new-parameters-during-ibss-join.patch create mode 100644 package/network/services/hostapd/patches/462-wpa_s-support-htmode-param.patch create mode 100644 package/network/services/hostapd/patches/470-wait-for-nullfunc-longer.patch create mode 100644 package/network/services/hostapd/patches/600-ubus_support.patch (limited to 'package/network/services/hostapd/patches') diff --git a/package/network/services/hostapd/patches/001-P2P-Validate-SSID-element-length-before-copying-it-C.patch b/package/network/services/hostapd/patches/001-P2P-Validate-SSID-element-length-before-copying-it-C.patch new file mode 100644 index 0000000..e408fbe --- /dev/null +++ b/package/network/services/hostapd/patches/001-P2P-Validate-SSID-element-length-before-copying-it-C.patch @@ -0,0 +1,37 @@ +From 9ed4eee345f85e3025c33c6e20aa25696e341ccd Mon Sep 17 00:00:00 2001 +From: Jouni Malinen +Date: Tue, 7 Apr 2015 11:32:11 +0300 +Subject: [PATCH] P2P: Validate SSID element length before copying it + (CVE-2015-1863) + +This fixes a possible memcpy overflow for P2P dev->oper_ssid in +p2p_add_device(). The length provided by the peer device (0..255 bytes) +was used without proper bounds checking and that could have resulted in +arbitrary data of up to 223 bytes being written beyond the end of the +dev->oper_ssid[] array (of which about 150 bytes would be beyond the +heap allocation) when processing a corrupted management frame for P2P +peer discovery purposes. + +This could result in corrupted state in heap, unexpected program +behavior due to corrupted P2P peer device information, denial of service +due to process crash, exposure of memory contents during GO Negotiation, +and potentially arbitrary code execution. + +Thanks to Google security team for reporting this issue and smart +hardware research group of Alibaba security team for discovering it. + +Signed-off-by: Jouni Malinen +--- + src/p2p/p2p.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/src/p2p/p2p.c ++++ b/src/p2p/p2p.c +@@ -778,6 +778,7 @@ int p2p_add_device(struct p2p_data *p2p, + if (os_memcmp(addr, p2p_dev_addr, ETH_ALEN) != 0) + os_memcpy(dev->interface_addr, addr, ETH_ALEN); + if (msg.ssid && ++ msg.ssid[1] <= sizeof(dev->oper_ssid) && + (msg.ssid[1] != P2P_WILDCARD_SSID_LEN || + os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN) + != 0)) { diff --git a/package/network/services/hostapd/patches/002-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch b/package/network/services/hostapd/patches/002-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch new file mode 100644 index 0000000..bc4d60f --- /dev/null +++ b/package/network/services/hostapd/patches/002-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch @@ -0,0 +1,36 @@ +From ef566a4d4f74022e1fdb0a2addfe81e6de9f4aae Mon Sep 17 00:00:00 2001 +From: Jouni Malinen +Date: Wed, 29 Apr 2015 02:21:53 +0300 +Subject: [PATCH] AP WMM: Fix integer underflow in WMM Action frame parser + +The length of the WMM Action frame was not properly validated and the +length of the information elements (int left) could end up being +negative. This would result in reading significantly past the stack +buffer while parsing the IEs in ieee802_11_parse_elems() and while doing +so, resulting in segmentation fault. + +This can result in an invalid frame being used for a denial of service +attack (hostapd process killed) against an AP with a driver that uses +hostapd for management frame processing (e.g., all mac80211-based +drivers). + +Thanks to Kostya Kortchinsky of Google security team for discovering and +reporting this issue. + +Signed-off-by: Jouni Malinen +--- + src/ap/wmm.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/src/ap/wmm.c ++++ b/src/ap/wmm.c +@@ -274,6 +274,9 @@ void hostapd_wmm_action(struct hostapd_d + return; + } + ++ if (left < 0) ++ return; /* not a valid WMM Action frame */ ++ + /* extract the tspec info element */ + if (ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed) { + hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, diff --git a/package/network/services/hostapd/patches/110-bool_fix.patch b/package/network/services/hostapd/patches/110-bool_fix.patch new file mode 100644 index 0000000..865c014 --- /dev/null +++ b/package/network/services/hostapd/patches/110-bool_fix.patch @@ -0,0 +1,14 @@ +--- a/src/ap/ieee802_1x.c ++++ b/src/ap/ieee802_1x.c +@@ -2332,9 +2332,9 @@ void ieee802_1x_notify_pre_auth(struct e + } + + +-static const char * bool_txt(Boolean bool) ++static const char * bool_txt(Boolean bool_val) + { +- return bool ? "TRUE" : "FALSE"; ++ return bool_val ? "TRUE" : "FALSE"; + } + + diff --git a/package/network/services/hostapd/patches/120-daemonize_fix.patch b/package/network/services/hostapd/patches/120-daemonize_fix.patch new file mode 100644 index 0000000..032e207 --- /dev/null +++ b/package/network/services/hostapd/patches/120-daemonize_fix.patch @@ -0,0 +1,97 @@ +--- a/src/utils/os_unix.c ++++ b/src/utils/os_unix.c +@@ -10,6 +10,7 @@ + + #include + #include ++#include + + #ifdef ANDROID + #include +@@ -155,59 +156,46 @@ int os_gmtime(os_time_t t, struct os_tm + return 0; + } + +- +-#ifdef __APPLE__ +-#include +-static int os_daemon(int nochdir, int noclose) ++int os_daemonize(const char *pid_file) + { +- int devnull; ++ int pid = 0, i, devnull; + +- if (chdir("/") < 0) +- return -1; ++#if defined(__uClinux__) || defined(__sun__) ++ return -1; ++#else /* defined(__uClinux__) || defined(__sun__) */ + +- devnull = open("/dev/null", O_RDWR); +- if (devnull < 0) ++#ifndef __APPLE__ ++ pid = fork(); ++ if (pid < 0) + return -1; ++#endif + +- if (dup2(devnull, STDIN_FILENO) < 0) { +- close(devnull); +- return -1; ++ if (pid > 0) { ++ if (pid_file) { ++ FILE *f = fopen(pid_file, "w"); ++ if (f) { ++ fprintf(f, "%u\n", pid); ++ fclose(f); ++ } ++ } ++ _exit(0); + } + +- if (dup2(devnull, STDOUT_FILENO) < 0) { +- close(devnull); ++ if (setsid() < 0) + return -1; +- } + +- if (dup2(devnull, STDERR_FILENO) < 0) { +- close(devnull); ++ if (chdir("/") < 0) + return -1; +- } +- +- return 0; +-} +-#else /* __APPLE__ */ +-#define os_daemon daemon +-#endif /* __APPLE__ */ + +- +-int os_daemonize(const char *pid_file) +-{ +-#if defined(__uClinux__) || defined(__sun__) +- return -1; +-#else /* defined(__uClinux__) || defined(__sun__) */ +- if (os_daemon(0, 0)) { +- perror("daemon"); ++ devnull = open("/dev/null", O_RDWR); ++ if (devnull < 0) + return -1; +- } + +- if (pid_file) { +- FILE *f = fopen(pid_file, "w"); +- if (f) { +- fprintf(f, "%u\n", getpid()); +- fclose(f); +- } +- } ++ for (i = 0; i <= STDERR_FILENO; i++) ++ dup2(devnull, i); ++ ++ if (devnull > 2) ++ close(devnull); + + return -0; + #endif /* defined(__uClinux__) || defined(__sun__) */ diff --git a/package/network/services/hostapd/patches/130-no_eapol_fix.patch b/package/network/services/hostapd/patches/130-no_eapol_fix.patch new file mode 100644 index 0000000..d23b47b --- /dev/null +++ b/package/network/services/hostapd/patches/130-no_eapol_fix.patch @@ -0,0 +1,14 @@ +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -252,9 +252,10 @@ void wpa_supplicant_cancel_auth_timeout( + */ + void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s) + { ++ struct wpa_ssid *ssid = wpa_s->current_ssid; ++ + #ifdef IEEE8021X_EAPOL + struct eapol_config eapol_conf; +- struct wpa_ssid *ssid = wpa_s->current_ssid; + + #ifdef CONFIG_IBSS_RSN + if (ssid->mode == WPAS_MODE_IBSS && diff --git a/package/network/services/hostapd/patches/140-disable_bridge_packet_workaround.patch b/package/network/services/hostapd/patches/140-disable_bridge_packet_workaround.patch new file mode 100644 index 0000000..6337d8d --- /dev/null +++ b/package/network/services/hostapd/patches/140-disable_bridge_packet_workaround.patch @@ -0,0 +1,12 @@ +--- a/src/l2_packet/l2_packet_linux.c ++++ b/src/l2_packet/l2_packet_linux.c +@@ -307,8 +307,7 @@ struct l2_packet_data * l2_packet_init_b + + l2 = l2_packet_init(br_ifname, own_addr, protocol, rx_callback, + rx_callback_ctx, l2_hdr); +- if (!l2) +- return NULL; ++ return l2; + + /* + * The Linux packet socket behavior has changed over the years and there diff --git a/package/network/services/hostapd/patches/200-multicall.patch b/package/network/services/hostapd/patches/200-multicall.patch new file mode 100644 index 0000000..de4a3a8 --- /dev/null +++ b/package/network/services/hostapd/patches/200-multicall.patch @@ -0,0 +1,276 @@ +--- a/hostapd/Makefile ++++ b/hostapd/Makefile +@@ -17,6 +17,7 @@ export BINDIR ?= /usr/local/bin/ + # CFLAGS += -DUSE_KERNEL_HEADERS -I/usr/src/linux/include + + -include .config ++-include $(if $(MULTICALL), ../wpa_supplicant/.config) + + ifdef CONFIG_TESTING_OPTIONS + CFLAGS += -DCONFIG_TESTING_OPTIONS +@@ -242,10 +243,14 @@ ifdef CONFIG_IEEE80211AC + CFLAGS += -DCONFIG_IEEE80211AC + endif + ++ifndef MULTICALL ++CFLAGS += -DNO_SUPPLICANT ++endif ++ + include ../src/drivers/drivers.mak +-OBJS += $(DRV_AP_OBJS) +-CFLAGS += $(DRV_AP_CFLAGS) +-LDFLAGS += $(DRV_AP_LDFLAGS) ++OBJS += $(sort $(DRV_AP_OBJS) $(if $(MULTICALL),$(DRV_WPA_OBJS))) ++CFLAGS += $(DRV_AP_CFLAGS) $(if $(MULTICALL),$(DRV_WPA_CFLAGS)) ++LDFLAGS += $(DRV_AP_LDFLAGS) $(if $(MULTICALL),$(DRV_WPA_LDFLAGS)) + LIBS += $(DRV_AP_LIBS) + + ifdef CONFIG_L2_PACKET +@@ -941,6 +946,12 @@ install: $(addprefix $(DESTDIR)$(BINDIR) + + BCHECK=../src/drivers/build.hostapd + ++hostapd_multi.a: $(BCHECK) $(OBJS) ++ $(Q)$(CC) -c -o hostapd_multi.o -Dmain=hostapd_main $(CFLAGS) main.c ++ @$(E) " CC " $< ++ @rm -f $@ ++ @$(AR) cr $@ hostapd_multi.o $(OBJS) ++ + hostapd: $(BCHECK) $(OBJS) + $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS) + @$(E) " LD " $@ +@@ -980,6 +991,12 @@ HOBJS += ../src/crypto/aes-internal.o + HOBJS += ../src/crypto/aes-internal-enc.o + endif + ++dump_cflags: ++ @echo -n $(CFLAGS) " " ++ ++dump_ldflags: ++ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " " ++ + nt_password_hash: $(NOBJS) + $(Q)$(CC) $(LDFLAGS) -o nt_password_hash $(NOBJS) $(LIBS_n) + @$(E) " LD " $@ +--- a/wpa_supplicant/Makefile ++++ b/wpa_supplicant/Makefile +@@ -15,6 +15,7 @@ CFLAGS += -I$(abspath ../src) + CFLAGS += -I$(abspath ../src/utils) + + -include .config ++-include $(if $(MULTICALL),../hostapd/.config) + + ifdef CONFIG_TESTING_OPTIONS + CFLAGS += -DCONFIG_TESTING_OPTIONS +@@ -773,6 +774,10 @@ ifdef CONFIG_DYNAMIC_EAP_METHODS + CFLAGS += -DCONFIG_DYNAMIC_EAP_METHODS + LIBS += -ldl -rdynamic + endif ++else ++ ifdef MULTICALL ++ OBJS += ../src/eap_common/eap_common.o ++ endif + endif + + ifdef CONFIG_MACSEC +@@ -793,9 +798,11 @@ NEED_EAP_COMMON=y + NEED_RSN_AUTHENTICATOR=y + CFLAGS += -DCONFIG_AP + OBJS += ap.o ++ifndef MULTICALL + CFLAGS += -DCONFIG_NO_RADIUS + CFLAGS += -DCONFIG_NO_ACCOUNTING + CFLAGS += -DCONFIG_NO_VLAN ++endif + OBJS += ../src/ap/hostapd.o + OBJS += ../src/ap/wpa_auth_glue.o + OBJS += ../src/ap/utils.o +@@ -858,10 +865,18 @@ endif + ifdef CONFIG_HS20 + OBJS += ../src/ap/hs20.o + endif ++else ++ ifdef MULTICALL ++ OBJS += ../src/eap_server/eap_server.o ++ OBJS += ../src/eap_server/eap_server_identity.o ++ OBJS += ../src/eap_server/eap_server_methods.o ++ endif + endif + + ifdef NEED_RSN_AUTHENTICATOR ++ifndef MULTICALL + CFLAGS += -DCONFIG_NO_RADIUS ++endif + NEED_AES_WRAP=y + OBJS += ../src/ap/wpa_auth.o + OBJS += ../src/ap/wpa_auth_ie.o +@@ -1603,6 +1618,12 @@ wpa_priv: $(BCHECK) $(OBJS_priv) + + $(OBJS_c) $(OBJS_t) $(OBJS_t2) $(OBJS) $(BCHECK) $(EXTRA_progs): .config + ++wpa_supplicant_multi.a: .config $(BCHECK) $(OBJS) $(EXTRA_progs) ++ $(Q)$(CC) -c -o wpa_supplicant_multi.o -Dmain=wpa_supplicant_main $(CFLAGS) main.c ++ @$(E) " CC " $< ++ @rm -f $@ ++ @$(AR) cr $@ wpa_supplicant_multi.o $(OBJS) ++ + wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs) + $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS) + @$(E) " LD " $@ +@@ -1694,6 +1715,12 @@ endif + $(Q)sed -e 's|\@BINDIR\@|$(BINDIR)|g' $< >$@ + @$(E) " sed" $< + ++dump_cflags: ++ @echo -n $(CFLAGS) " " ++ ++dump_ldflags: ++ @echo -n $(LDFLAGS) $(LIBS) $(EXTRALIBS) " " ++ + wpa_supplicant.exe: wpa_supplicant + mv -f $< $@ + wpa_cli.exe: wpa_cli +--- a/src/drivers/driver.h ++++ b/src/drivers/driver.h +@@ -4581,8 +4581,8 @@ union wpa_event_data { + * Driver wrapper code should call this function whenever an event is received + * from the driver. + */ +-void wpa_supplicant_event(void *ctx, enum wpa_event_type event, +- union wpa_event_data *data); ++extern void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); + + + /* +--- a/src/ap/drv_callbacks.c ++++ b/src/ap/drv_callbacks.c +@@ -1075,8 +1075,8 @@ static void hostapd_event_dfs_cac_starte + #endif /* NEED_AP_MLME */ + + +-void wpa_supplicant_event(void *ctx, enum wpa_event_type event, +- union wpa_event_data *data) ++void hostapd_wpa_event(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data) + { + struct hostapd_data *hapd = ctx; + #ifndef CONFIG_NO_STDOUT_DEBUG +--- a/wpa_supplicant/wpa_priv.c ++++ b/wpa_supplicant/wpa_priv.c +@@ -819,8 +819,8 @@ static void wpa_priv_send_ft_response(st + } + + +-void wpa_supplicant_event(void *ctx, enum wpa_event_type event, +- union wpa_event_data *data) ++static void supplicant_event(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data) + { + struct wpa_priv_interface *iface = ctx; + +@@ -961,6 +961,7 @@ int main(int argc, char *argv[]) + if (os_program_init()) + return -1; + ++ wpa_supplicant_event = supplicant_event; + wpa_priv_fd_workaround(); + + for (;;) { +--- a/wpa_supplicant/events.c ++++ b/wpa_supplicant/events.c +@@ -3138,8 +3138,8 @@ static void wpa_supplicant_event_assoc_a + } + + +-void wpa_supplicant_event(void *ctx, enum wpa_event_type event, +- union wpa_event_data *data) ++void supplicant_event(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data) + { + struct wpa_supplicant *wpa_s = ctx; + +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -4300,6 +4300,9 @@ static void wpa_supplicant_deinit_iface( + os_free(wpa_s); + } + ++extern void supplicant_event(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); ++ + + /** + * wpa_supplicant_add_iface - Add a new network interface +@@ -4526,6 +4529,7 @@ struct wpa_global * wpa_supplicant_init( + #ifndef CONFIG_NO_WPA_MSG + wpa_msg_register_ifname_cb(wpa_supplicant_msg_ifname_cb); + #endif /* CONFIG_NO_WPA_MSG */ ++ wpa_supplicant_event = supplicant_event; + + if (params->wpa_debug_file_path) + wpa_debug_open_file(params->wpa_debug_file_path); +--- a/hostapd/main.c ++++ b/hostapd/main.c +@@ -511,6 +511,9 @@ static int hostapd_get_ctrl_iface_group( + return 0; + } + ++void hostapd_wpa_event(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); ++ + + #ifdef CONFIG_WPS + static int gen_uuid(const char *txt_addr) +@@ -562,6 +565,7 @@ int main(int argc, char *argv[]) + interfaces.global_iface_name = NULL; + interfaces.global_ctrl_sock = -1; + ++ wpa_supplicant_event = hostapd_wpa_event; + for (;;) { + c = getopt(argc, argv, "b:Bde:f:hKP:Ttu:vg:G:"); + if (c < 0) +--- a/src/drivers/drivers.c ++++ b/src/drivers/drivers.c +@@ -10,6 +10,9 @@ + #include "utils/common.h" + #include "driver.h" + ++void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); ++ + #ifdef CONFIG_DRIVER_WEXT + extern struct wpa_driver_ops wpa_driver_wext_ops; /* driver_wext.c */ + #endif /* CONFIG_DRIVER_WEXT */ +--- a/wpa_supplicant/eapol_test.c ++++ b/wpa_supplicant/eapol_test.c +@@ -28,8 +28,12 @@ + #include "ctrl_iface.h" + #include "pcsc_funcs.h" + #include "wpas_glue.h" ++#include "drivers/driver.h" + + ++void (*wpa_supplicant_event)(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); ++ + struct wpa_driver_ops *wpa_drivers[] = { NULL }; + + +@@ -1203,6 +1207,8 @@ static void usage(void) + "option several times.\n"); + } + ++extern void supplicant_event(void *ctx, enum wpa_event_type event, ++ union wpa_event_data *data); + + int main(int argc, char *argv[]) + { +@@ -1221,6 +1227,7 @@ int main(int argc, char *argv[]) + if (os_program_init()) + return -1; + ++ wpa_supplicant_event = supplicant_event; + hostapd_logger_register_cb(hostapd_logger_cb); + + os_memset(&eapol_test, 0, sizeof(eapol_test)); diff --git a/package/network/services/hostapd/patches/300-noscan.patch b/package/network/services/hostapd/patches/300-noscan.patch new file mode 100644 index 0000000..57d8fe2 --- /dev/null +++ b/package/network/services/hostapd/patches/300-noscan.patch @@ -0,0 +1,57 @@ +--- a/hostapd/config_file.c ++++ b/hostapd/config_file.c +@@ -2771,6 +2771,10 @@ static int hostapd_config_fill(struct ho + } + #endif /* CONFIG_IEEE80211W */ + #ifdef CONFIG_IEEE80211N ++ } else if (os_strcmp(buf, "noscan") == 0) { ++ conf->noscan = atoi(pos); ++ } else if (os_strcmp(buf, "ht_coex") == 0) { ++ conf->no_ht_coex = !atoi(pos); + } else if (os_strcmp(buf, "ieee80211n") == 0) { + conf->ieee80211n = atoi(pos); + } else if (os_strcmp(buf, "ht_capab") == 0) { +--- a/src/ap/ap_config.h ++++ b/src/ap/ap_config.h +@@ -619,6 +619,8 @@ struct hostapd_config { + + int ht_op_mode_fixed; + u16 ht_capab; ++ int noscan; ++ int no_ht_coex; + int ieee80211n; + int secondary_channel; + int require_ht; +--- a/src/ap/hw_features.c ++++ b/src/ap/hw_features.c +@@ -461,7 +461,7 @@ static int ieee80211n_check_40mhz(struct + struct wpa_driver_scan_params params; + int ret; + +- if (!iface->conf->secondary_channel) ++ if (!iface->conf->secondary_channel || iface->conf->noscan) + return 0; /* HT40 not used */ + + hostapd_set_state(iface, HAPD_IFACE_HT_SCAN); +--- a/src/ap/ieee802_11_ht.c ++++ b/src/ap/ieee802_11_ht.c +@@ -221,6 +221,9 @@ void hostapd_2040_coex_action(struct hos + if (!(iface->conf->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) + return; + ++ if (iface->conf->noscan || iface->conf->no_ht_coex) ++ return; ++ + if (len < IEEE80211_HDRLEN + 2 + sizeof(*bc_ie)) + return; + +@@ -346,6 +349,9 @@ void ht40_intolerant_add(struct hostapd_ + if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G) + return; + ++ if (iface->conf->noscan || iface->conf->no_ht_coex) ++ return; ++ + wpa_printf(MSG_INFO, "HT: Forty MHz Intolerant is set by STA " MACSTR + " in Association Request", MAC2STR(sta->addr)); + diff --git a/package/network/services/hostapd/patches/310-rescan_immediately.patch b/package/network/services/hostapd/patches/310-rescan_immediately.patch new file mode 100644 index 0000000..7be8c32 --- /dev/null +++ b/package/network/services/hostapd/patches/310-rescan_immediately.patch @@ -0,0 +1,11 @@ +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -3249,7 +3249,7 @@ wpa_supplicant_alloc(struct wpa_supplica + if (wpa_s == NULL) + return NULL; + wpa_s->scan_req = INITIAL_SCAN_REQ; +- wpa_s->scan_interval = 5; ++ wpa_s->scan_interval = 1; + wpa_s->new_connection = 1; + wpa_s->parent = parent ? parent : wpa_s; + wpa_s->sched_scanning = 0; diff --git a/package/network/services/hostapd/patches/320-optional_rfkill.patch b/package/network/services/hostapd/patches/320-optional_rfkill.patch new file mode 100644 index 0000000..75b4b07 --- /dev/null +++ b/package/network/services/hostapd/patches/320-optional_rfkill.patch @@ -0,0 +1,61 @@ +--- a/src/drivers/drivers.mak ++++ b/src/drivers/drivers.mak +@@ -34,7 +34,6 @@ NEED_SME=y + NEED_AP_MLME=y + NEED_NETLINK=y + NEED_LINUX_IOCTL=y +-NEED_RFKILL=y + + ifdef CONFIG_LIBNL32 + DRV_LIBS += -lnl-3 +@@ -116,7 +115,6 @@ DRV_WPA_CFLAGS += -DCONFIG_DRIVER_WEXT + CONFIG_WIRELESS_EXTENSION=y + NEED_NETLINK=y + NEED_LINUX_IOCTL=y +-NEED_RFKILL=y + endif + + ifdef CONFIG_DRIVER_NDIS +@@ -142,7 +140,6 @@ endif + ifdef CONFIG_WIRELESS_EXTENSION + DRV_WPA_CFLAGS += -DCONFIG_WIRELESS_EXTENSION + DRV_WPA_OBJS += ../src/drivers/driver_wext.o +-NEED_RFKILL=y + endif + + ifdef NEED_NETLINK +@@ -155,6 +152,7 @@ endif + + ifdef NEED_RFKILL + DRV_OBJS += ../src/drivers/rfkill.o ++DRV_WPA_CFLAGS += -DCONFIG_RFKILL + endif + + ifdef CONFIG_VLAN_NETLINK +--- a/src/drivers/rfkill.h ++++ b/src/drivers/rfkill.h +@@ -18,8 +18,24 @@ struct rfkill_config { + void (*unblocked_cb)(void *ctx); + }; + ++#ifdef CONFIG_RFKILL + struct rfkill_data * rfkill_init(struct rfkill_config *cfg); + void rfkill_deinit(struct rfkill_data *rfkill); + int rfkill_is_blocked(struct rfkill_data *rfkill); ++#else ++static inline struct rfkill_data * rfkill_init(struct rfkill_config *cfg) ++{ ++ return (void *) 1; ++} ++ ++static inline void rfkill_deinit(struct rfkill_data *rfkill) ++{ ++} ++ ++static inline int rfkill_is_blocked(struct rfkill_data *rfkill) ++{ ++ return 0; ++} ++#endif + + #endif /* RFKILL_H */ diff --git a/package/network/services/hostapd/patches/330-nl80211_fix_set_freq.patch b/package/network/services/hostapd/patches/330-nl80211_fix_set_freq.patch new file mode 100644 index 0000000..dd90877 --- /dev/null +++ b/package/network/services/hostapd/patches/330-nl80211_fix_set_freq.patch @@ -0,0 +1,11 @@ +--- a/src/drivers/driver_nl80211.c ++++ b/src/drivers/driver_nl80211.c +@@ -3616,7 +3616,7 @@ static int nl80211_set_channel(struct i8 + freq->freq, freq->ht_enabled, freq->vht_enabled, + freq->bandwidth, freq->center_freq1, freq->center_freq2); + +- msg = nl80211_drv_msg(drv, 0, set_chan ? NL80211_CMD_SET_CHANNEL : ++ msg = nl80211_bss_msg(bss, 0, set_chan ? NL80211_CMD_SET_CHANNEL : + NL80211_CMD_SET_WIPHY); + if (!msg || nl80211_put_freq_params(msg, freq) < 0) { + nlmsg_free(msg); diff --git a/package/network/services/hostapd/patches/340-reload_freq_change.patch b/package/network/services/hostapd/patches/340-reload_freq_change.patch new file mode 100644 index 0000000..91b6196 --- /dev/null +++ b/package/network/services/hostapd/patches/340-reload_freq_change.patch @@ -0,0 +1,44 @@ +--- a/src/ap/hostapd.c ++++ b/src/ap/hostapd.c +@@ -76,6 +76,16 @@ static void hostapd_reload_bss(struct ho + #endif /* CONFIG_NO_RADIUS */ + + ssid = &hapd->conf->ssid; ++ ++ hostapd_set_freq(hapd, hapd->iconf->hw_mode, hapd->iface->freq, ++ hapd->iconf->channel, ++ hapd->iconf->ieee80211n, ++ hapd->iconf->ieee80211ac, ++ hapd->iconf->secondary_channel, ++ hapd->iconf->vht_oper_chwidth, ++ hapd->iconf->vht_oper_centr_freq_seg0_idx, ++ hapd->iconf->vht_oper_centr_freq_seg1_idx); ++ + if (!ssid->wpa_psk_set && ssid->wpa_psk && !ssid->wpa_psk->next && + ssid->wpa_passphrase_set && ssid->wpa_passphrase) { + /* +@@ -175,21 +185,12 @@ int hostapd_reload_config(struct hostapd + oldconf = hapd->iconf; + iface->conf = newconf; + ++ if (iface->conf->channel) ++ iface->freq = hostapd_hw_get_freq(hapd, iface->conf->channel); ++ + for (j = 0; j < iface->num_bss; j++) { + hapd = iface->bss[j]; + hapd->iconf = newconf; +- hapd->iconf->channel = oldconf->channel; +- hapd->iconf->acs = oldconf->acs; +- hapd->iconf->secondary_channel = oldconf->secondary_channel; +- hapd->iconf->ieee80211n = oldconf->ieee80211n; +- hapd->iconf->ieee80211ac = oldconf->ieee80211ac; +- hapd->iconf->ht_capab = oldconf->ht_capab; +- hapd->iconf->vht_capab = oldconf->vht_capab; +- hapd->iconf->vht_oper_chwidth = oldconf->vht_oper_chwidth; +- hapd->iconf->vht_oper_centr_freq_seg0_idx = +- oldconf->vht_oper_centr_freq_seg0_idx; +- hapd->iconf->vht_oper_centr_freq_seg1_idx = +- oldconf->vht_oper_centr_freq_seg1_idx; + hapd->conf = newconf->bss[j]; + hostapd_reload_bss(hapd); + } diff --git a/package/network/services/hostapd/patches/350-nl80211_del_beacon_bss.patch b/package/network/services/hostapd/patches/350-nl80211_del_beacon_bss.patch new file mode 100644 index 0000000..a14fa03 --- /dev/null +++ b/package/network/services/hostapd/patches/350-nl80211_del_beacon_bss.patch @@ -0,0 +1,72 @@ +--- a/src/drivers/driver_nl80211.c ++++ b/src/drivers/driver_nl80211.c +@@ -2254,13 +2254,18 @@ wpa_driver_nl80211_finish_drv_init(struc + } + + +-static int wpa_driver_nl80211_del_beacon(struct wpa_driver_nl80211_data *drv) ++static int wpa_driver_nl80211_del_beacon(struct i802_bss *bss) + { ++ struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + ++ if (!bss->beacon_set) ++ return 0; ++ ++ bss->beacon_set = 0; + wpa_printf(MSG_DEBUG, "nl80211: Remove beacon (ifindex=%d)", +- drv->ifindex); +- msg = nl80211_drv_msg(drv, 0, NL80211_CMD_DEL_BEACON); ++ bss->ifindex); ++ msg = nl80211_bss_msg(bss, 0, NL80211_CMD_DEL_BEACON); + return send_and_recv_msgs(drv, msg, NULL, NULL); + } + +@@ -2311,7 +2316,7 @@ static void wpa_driver_nl80211_deinit(st + nl80211_remove_monitor_interface(drv); + + if (is_ap_interface(drv->nlmode)) +- wpa_driver_nl80211_del_beacon(drv); ++ wpa_driver_nl80211_del_beacon(bss); + + if (drv->eapol_sock >= 0) { + eloop_unregister_read_sock(drv->eapol_sock); +@@ -4140,8 +4145,7 @@ static void nl80211_teardown_ap(struct i + nl80211_remove_monitor_interface(drv); + else + nl80211_mgmt_unsubscribe(bss, "AP teardown"); +- +- bss->beacon_set = 0; ++ wpa_driver_nl80211_del_beacon(bss); + } + + +@@ -6066,8 +6070,6 @@ static int wpa_driver_nl80211_if_remove( + } else { + wpa_printf(MSG_DEBUG, "nl80211: First BSS - reassign context"); + nl80211_teardown_ap(bss); +- if (!bss->added_if && !drv->first_bss->next) +- wpa_driver_nl80211_del_beacon(drv); + nl80211_destroy_bss(bss); + if (!bss->added_if) + i802_set_iface_flags(bss, 0); +@@ -6389,8 +6391,7 @@ static int wpa_driver_nl80211_deinit_ap( + struct wpa_driver_nl80211_data *drv = bss->drv; + if (!is_ap_interface(drv->nlmode)) + return -1; +- wpa_driver_nl80211_del_beacon(drv); +- bss->beacon_set = 0; ++ wpa_driver_nl80211_del_beacon(bss); + + /* + * If the P2P GO interface was dynamically added, then it is +@@ -6409,8 +6410,7 @@ static int wpa_driver_nl80211_stop_ap(vo + struct wpa_driver_nl80211_data *drv = bss->drv; + if (!is_ap_interface(drv->nlmode)) + return -1; +- wpa_driver_nl80211_del_beacon(drv); +- bss->beacon_set = 0; ++ wpa_driver_nl80211_del_beacon(bss); + return 0; + } + diff --git a/package/network/services/hostapd/patches/360-ctrl_iface_reload.patch b/package/network/services/hostapd/patches/360-ctrl_iface_reload.patch new file mode 100644 index 0000000..06b005e --- /dev/null +++ b/package/network/services/hostapd/patches/360-ctrl_iface_reload.patch @@ -0,0 +1,104 @@ +--- a/hostapd/ctrl_iface.c ++++ b/hostapd/ctrl_iface.c +@@ -45,6 +45,7 @@ + #include "wps/wps.h" + #include "config_file.h" + #include "ctrl_iface.h" ++#include "config_file.h" + + + struct wpa_ctrl_dst { +@@ -55,6 +56,7 @@ struct wpa_ctrl_dst { + int errors; + }; + ++static char *reload_opts = NULL; + + static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level, + const char *buf, size_t len); +@@ -164,6 +166,61 @@ static int hostapd_ctrl_iface_new_sta(st + return 0; + } + ++static char *get_option(char *opt, char *str) ++{ ++ int len = strlen(str); ++ ++ if (!strncmp(opt, str, len)) ++ return opt + len; ++ else ++ return NULL; ++} ++ ++static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname) ++{ ++ struct hostapd_config *conf; ++ char *opt, *val; ++ ++ conf = hostapd_config_read(fname); ++ if (!conf) ++ return NULL; ++ ++ for (opt = strtok(reload_opts, " "); ++ opt; ++ opt = strtok(NULL, " ")) { ++ ++ if ((val = get_option(opt, "channel="))) ++ conf->channel = atoi(val); ++ else if ((val = get_option(opt, "ht_capab="))) ++ conf->ht_capab = atoi(val); ++ else if ((val = get_option(opt, "ht_capab_mask="))) ++ conf->ht_capab &= atoi(val); ++ else if ((val = get_option(opt, "sec_chan="))) ++ conf->secondary_channel = atoi(val); ++ else if ((val = get_option(opt, "hw_mode="))) ++ conf->hw_mode = atoi(val); ++ else if ((val = get_option(opt, "ieee80211n="))) ++ conf->ieee80211n = atoi(val); ++ else ++ break; ++ } ++ ++ return conf; ++} ++ ++static int hostapd_ctrl_iface_update(struct hostapd_data *hapd, char *txt) ++{ ++ struct hostapd_config * (*config_read_cb)(const char *config_fname); ++ struct hostapd_iface *iface = hapd->iface; ++ ++ config_read_cb = iface->interfaces->config_read_cb; ++ iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read; ++ reload_opts = txt; ++ ++ hostapd_reload_config(iface); ++ ++ iface->interfaces->config_read_cb = config_read_cb; ++} + + #ifdef CONFIG_IEEE80211W + #ifdef NEED_AP_MLME +@@ -2086,6 +2143,8 @@ static void hostapd_ctrl_iface_receive(i + } else if (os_strncmp(buf, "VENDOR ", 7) == 0) { + reply_len = hostapd_ctrl_iface_vendor(hapd, buf + 7, reply, + reply_size); ++ } else if (os_strncmp(buf, "UPDATE ", 7) == 0) { ++ hostapd_ctrl_iface_update(hapd, buf + 7); + } else if (os_strcmp(buf, "ERP_FLUSH") == 0) { + ieee802_1x_erp_flush(hapd); + #ifdef RADIUS_SERVER +--- a/src/ap/ctrl_iface_ap.c ++++ b/src/ap/ctrl_iface_ap.c +@@ -541,5 +541,11 @@ int hostapd_parse_csa_settings(const cha + + int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd) + { +- return hostapd_drv_stop_ap(hapd); ++ struct hostapd_iface *iface = hapd->iface; ++ int i; ++ ++ for (i = 0; i < iface->num_bss; i++) ++ hostapd_drv_stop_ap(iface->bss[i]); ++ ++ return 0; + } diff --git a/package/network/services/hostapd/patches/370-ap_sta_support.patch b/package/network/services/hostapd/patches/370-ap_sta_support.patch new file mode 100644 index 0000000..ea235e6 --- /dev/null +++ b/package/network/services/hostapd/patches/370-ap_sta_support.patch @@ -0,0 +1,237 @@ +--- a/wpa_supplicant/wpa_supplicant_i.h ++++ b/wpa_supplicant/wpa_supplicant_i.h +@@ -110,6 +110,11 @@ struct wpa_interface { + const char *ifname; + + /** ++ * hostapd_ctrl - path to hostapd control socket for notification ++ */ ++ const char *hostapd_ctrl; ++ ++ /** + * bridge_ifname - Optional bridge interface name + * + * If the driver interface (ifname) is included in a Linux bridge +@@ -442,6 +447,8 @@ struct wpa_supplicant { + #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ + char bridge_ifname[16]; + ++ struct wpa_ctrl *hostapd; ++ + char *confname; + char *confanother; + +--- a/wpa_supplicant/Makefile ++++ b/wpa_supplicant/Makefile +@@ -14,6 +14,10 @@ CFLAGS += $(EXTRA_CFLAGS) + CFLAGS += -I$(abspath ../src) + CFLAGS += -I$(abspath ../src/utils) + ++ifdef MULTICALL ++CFLAGS += -DMULTICALL ++endif ++ + -include .config + -include $(if $(MULTICALL),../hostapd/.config) + +@@ -84,6 +88,8 @@ OBJS_c += ../src/utils/wpa_debug.o + OBJS_c += ../src/utils/common.o + OBJS += wmm_ac.o + ++OBJS += ../src/common/wpa_ctrl.o ++ + ifndef CONFIG_OS + ifdef CONFIG_NATIVE_WINDOWS + CONFIG_OS=win32 +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -107,6 +107,55 @@ const char *wpa_supplicant_full_license5 + "\n"; + #endif /* CONFIG_NO_STDOUT_DEBUG */ + ++static int hostapd_stop(struct wpa_supplicant *wpa_s) ++{ ++ const char *cmd = "STOP_AP"; ++ char buf[256]; ++ size_t len = sizeof(buf); ++ ++ if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) { ++ wpa_printf(MSG_ERROR, "\nFailed to stop hostapd AP interfaces\n"); ++ return -1; ++ } ++ return 0; ++} ++ ++static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) ++{ ++ char *cmd = NULL; ++ char buf[256]; ++ size_t len = sizeof(buf); ++ enum hostapd_hw_mode hw_mode; ++ u8 channel; ++ int sec_chan = 0; ++ int ret; ++ ++ if (!bss) ++ return; ++ ++ if (bss->ht_param & HT_INFO_HT_PARAM_STA_CHNL_WIDTH) { ++ int sec = bss->ht_param & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK; ++ if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE) ++ sec_chan = 1; ++ else if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW) ++ sec_chan = -1; ++ } ++ ++ hw_mode = ieee80211_freq_to_chan(bss->freq, &channel); ++ if (asprintf(&cmd, "UPDATE channel=%d sec_chan=%d hw_mode=%d", ++ channel, sec_chan, hw_mode) < 0) ++ return -1; ++ ++ ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL); ++ free(cmd); ++ ++ if (ret < 0) { ++ wpa_printf(MSG_ERROR, "\nFailed to reload hostapd AP interfaces\n"); ++ return -1; ++ } ++ return 0; ++} ++ + /* Configure default/group WEP keys for static WEP */ + int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) + { +@@ -743,8 +792,12 @@ void wpa_supplicant_set_state(struct wpa + wpas_p2p_completed(wpa_s); + + sme_sched_obss_scan(wpa_s, 1); ++ if (wpa_s->hostapd) ++ hostapd_reload(wpa_s, wpa_s->current_bss); + } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING || + state == WPA_ASSOCIATED) { ++ if (wpa_s->hostapd) ++ hostapd_stop(wpa_s); + wpa_s->new_connection = 1; + wpa_drv_set_operstate(wpa_s, 0); + #ifndef IEEE8021X_EAPOL +@@ -4038,6 +4091,20 @@ static int wpa_supplicant_init_iface(str + sizeof(wpa_s->bridge_ifname)); + } + ++ if (iface->hostapd_ctrl) { ++ char *cmd = "STOP_AP"; ++ char buf[256]; ++ int len = sizeof(buf); ++ ++ wpa_s->hostapd = wpa_ctrl_open(iface->hostapd_ctrl); ++ if (!wpa_s->hostapd) { ++ wpa_printf(MSG_ERROR, "\nFailed to connect to hostapd\n"); ++ return -1; ++ } ++ if (hostapd_stop(wpa_s) < 0) ++ return -1; ++ } ++ + /* RSNA Supplicant Key Management - INITIALIZE */ + eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE); + eapol_sm_notify_portValid(wpa_s->eapol, FALSE); +@@ -4280,6 +4347,11 @@ static void wpa_supplicant_deinit_iface( + if (terminate) + wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING); + ++ if (wpa_s->hostapd) { ++ wpa_ctrl_close(wpa_s->hostapd); ++ wpa_s->hostapd = NULL; ++ } ++ + if (wpa_s->ctrl_iface) { + wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface); + wpa_s->ctrl_iface = NULL; +--- a/wpa_supplicant/bss.c ++++ b/wpa_supplicant/bss.c +@@ -11,6 +11,7 @@ + #include "utils/common.h" + #include "utils/eloop.h" + #include "common/ieee802_11_defs.h" ++#include "common/ieee802_11_common.h" + #include "drivers/driver.h" + #include "wpa_supplicant_i.h" + #include "config.h" +@@ -277,6 +278,10 @@ static void calculate_update_time(const + static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src, + struct os_reltime *fetch_time) + { ++ struct ieee80211_ht_capabilities *capab; ++ struct ieee80211_ht_operation *oper; ++ struct ieee802_11_elems elems; ++ + dst->flags = src->flags; + os_memcpy(dst->bssid, src->bssid, ETH_ALEN); + dst->freq = src->freq; +@@ -289,6 +294,15 @@ static void wpa_bss_copy_res(struct wpa_ + dst->est_throughput = src->est_throughput; + dst->snr = src->snr; + ++ memset(&elems, 0, sizeof(elems)); ++ ieee802_11_parse_elems((u8 *) (src + 1), src->ie_len, &elems, 0); ++ capab = (struct ieee80211_ht_capabilities *) elems.ht_capabilities; ++ oper = (struct ieee80211_ht_operation *) elems.ht_operation; ++ if (capab) ++ dst->ht_capab = le_to_host16(capab->ht_capabilities_info); ++ if (oper) ++ dst->ht_param = oper->ht_param; ++ + calculate_update_time(fetch_time, src->age, &dst->last_update); + } + +--- a/wpa_supplicant/main.c ++++ b/wpa_supplicant/main.c +@@ -33,7 +33,7 @@ static void usage(void) + "vW] [-P] " + "[-g] \\\n" + " [-G] \\\n" +- " -i -c [-C] [-D] " ++ " -i -c [-C] [-D] [-H] " + "[-p] \\\n" + " [-b] [-e]" + #ifdef CONFIG_DEBUG_FILE +@@ -84,6 +84,7 @@ static void usage(void) + #endif /* CONFIG_DEBUG_LINUX_TRACING */ + printf(" -t = include timestamp in debug messages\n" + " -h = show this help text\n" ++ " -H = connect to a hostapd instance to manage state changes\n" + " -L = show license (BSD)\n" + " -o = override driver parameter for new interfaces\n" + " -O = override ctrl_interface parameter for new interfaces\n" +@@ -175,7 +176,7 @@ int main(int argc, char *argv[]) + + for (;;) { + c = getopt(argc, argv, +- "b:Bc:C:D:de:f:g:G:hi:I:KLm:No:O:p:P:qsTtuvW"); ++ "b:Bc:C:D:de:f:g:G:hH:i:I:KLm:No:O:p:P:qsTtuvW"); + if (c < 0) + break; + switch (c) { +@@ -222,6 +223,9 @@ int main(int argc, char *argv[]) + usage(); + exitcode = 0; + goto out; ++ case 'H': ++ iface->hostapd_ctrl = optarg; ++ break; + case 'i': + iface->ifname = optarg; + break; +--- a/wpa_supplicant/bss.h ++++ b/wpa_supplicant/bss.h +@@ -72,6 +72,10 @@ struct wpa_bss { + u8 ssid[32]; + /** Length of SSID */ + size_t ssid_len; ++ /** HT caapbilities */ ++ u16 ht_capab; ++ /* Five octets of HT Operation Information */ ++ u8 ht_param; + /** Frequency of the channel in MHz (e.g., 2412 = channel 1) */ + int freq; + /** Beacon interval in TUs (host byte order) */ diff --git a/package/network/services/hostapd/patches/380-disable_ctrl_iface_mib.patch b/package/network/services/hostapd/patches/380-disable_ctrl_iface_mib.patch new file mode 100644 index 0000000..3a41b82 --- /dev/null +++ b/package/network/services/hostapd/patches/380-disable_ctrl_iface_mib.patch @@ -0,0 +1,178 @@ +--- a/hostapd/Makefile ++++ b/hostapd/Makefile +@@ -168,6 +168,9 @@ endif + ifdef CONFIG_NO_CTRL_IFACE + CFLAGS += -DCONFIG_NO_CTRL_IFACE + else ++ifdef CONFIG_CTRL_IFACE_MIB ++CFLAGS += -DCONFIG_CTRL_IFACE_MIB ++endif + OBJS += ctrl_iface.o + OBJS += ../src/ap/ctrl_iface_ap.o + endif +--- a/hostapd/ctrl_iface.c ++++ b/hostapd/ctrl_iface.c +@@ -1953,6 +1953,7 @@ static void hostapd_ctrl_iface_receive(i + reply_size); + } else if (os_strcmp(buf, "STATUS-DRIVER") == 0) { + reply_len = hostapd_drv_status(hapd, reply, reply_size); ++#ifdef CONFIG_CTRL_IFACE_MIB + } else if (os_strcmp(buf, "MIB") == 0) { + reply_len = ieee802_11_get_mib(hapd, reply, reply_size); + if (reply_len >= 0) { +@@ -1994,6 +1995,7 @@ static void hostapd_ctrl_iface_receive(i + } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) { + reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply, + reply_size); ++#endif + } else if (os_strcmp(buf, "ATTACH") == 0) { + if (hostapd_ctrl_iface_attach(hapd, &from, fromlen)) + reply_len = -1; +--- a/wpa_supplicant/Makefile ++++ b/wpa_supplicant/Makefile +@@ -837,6 +837,9 @@ ifdef CONFIG_WNM + OBJS += ../src/ap/wnm_ap.o + endif + ifdef CONFIG_CTRL_IFACE ++ifdef CONFIG_CTRL_IFACE_MIB ++CFLAGS += -DCONFIG_CTRL_IFACE_MIB ++endif + OBJS += ../src/ap/ctrl_iface_ap.o + endif + +--- a/wpa_supplicant/ctrl_iface.c ++++ b/wpa_supplicant/ctrl_iface.c +@@ -1795,7 +1795,7 @@ static int wpa_supplicant_ctrl_iface_sta + pos += ret; + } + +-#ifdef CONFIG_AP ++#if defined(CONFIG_AP) && defined(CONFIG_CTRL_IFACE_MIB) + if (wpa_s->ap_iface) { + pos += ap_ctrl_iface_wpa_get_status(wpa_s, pos, + end - pos, +@@ -7896,6 +7896,7 @@ char * wpa_supplicant_ctrl_iface_process + reply_len = -1; + } else if (os_strncmp(buf, "NOTE ", 5) == 0) { + wpa_printf(MSG_INFO, "NOTE: %s", buf + 5); ++#ifdef CONFIG_CTRL_IFACE_MIB + } else if (os_strcmp(buf, "MIB") == 0) { + reply_len = wpa_sm_get_mib(wpa_s->wpa, reply, reply_size); + if (reply_len >= 0) { +@@ -7903,6 +7904,7 @@ char * wpa_supplicant_ctrl_iface_process + reply + reply_len, + reply_size - reply_len); + } ++#endif + } else if (os_strncmp(buf, "STATUS", 6) == 0) { + reply_len = wpa_supplicant_ctrl_iface_status( + wpa_s, buf + 6, reply, reply_size); +@@ -8353,6 +8355,7 @@ char * wpa_supplicant_ctrl_iface_process + reply_len = wpa_supplicant_ctrl_iface_bss( + wpa_s, buf + 4, reply, reply_size); + #ifdef CONFIG_AP ++#ifdef CONFIG_CTRL_IFACE_MIB + } else if (os_strcmp(buf, "STA-FIRST") == 0) { + reply_len = ap_ctrl_iface_sta_first(wpa_s, reply, reply_size); + } else if (os_strncmp(buf, "STA ", 4) == 0) { +@@ -8361,12 +8364,15 @@ char * wpa_supplicant_ctrl_iface_process + } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) { + reply_len = ap_ctrl_iface_sta_next(wpa_s, buf + 9, reply, + reply_size); ++#endif ++#ifdef CONFIG_CTRL_IFACE_MIB + } else if (os_strncmp(buf, "DEAUTHENTICATE ", 15) == 0) { + if (ap_ctrl_iface_sta_deauthenticate(wpa_s, buf + 15)) + reply_len = -1; + } else if (os_strncmp(buf, "DISASSOCIATE ", 13) == 0) { + if (ap_ctrl_iface_sta_disassociate(wpa_s, buf + 13)) + reply_len = -1; ++#endif + } else if (os_strncmp(buf, "CHAN_SWITCH ", 12) == 0) { + if (ap_ctrl_iface_chanswitch(wpa_s, buf + 12)) + reply_len = -1; +--- a/src/ap/ctrl_iface_ap.c ++++ b/src/ap/ctrl_iface_ap.c +@@ -22,6 +22,7 @@ + #include "ctrl_iface_ap.h" + #include "ap_drv_ops.h" + ++#ifdef CONFIG_CTRL_IFACE_MIB + + static int hostapd_get_sta_tx_rx(struct hostapd_data *hapd, + struct sta_info *sta, +@@ -224,6 +225,7 @@ int hostapd_ctrl_iface_sta_next(struct h + return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen); + } + ++#endif + + #ifdef CONFIG_P2P_MANAGER + static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype, +--- a/src/ap/ieee802_1x.c ++++ b/src/ap/ieee802_1x.c +@@ -2337,6 +2337,7 @@ static const char * bool_txt(Boolean boo + return bool_val ? "TRUE" : "FALSE"; + } + ++#ifdef CONFIG_CTRL_IFACE_MIB + + int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen) + { +@@ -2512,6 +2513,7 @@ int ieee802_1x_get_mib_sta(struct hostap + return len; + } + ++#endif + + static void ieee802_1x_finished(struct hostapd_data *hapd, + struct sta_info *sta, int success, +--- a/src/ap/wpa_auth.c ++++ b/src/ap/wpa_auth.c +@@ -2999,6 +2999,7 @@ static const char * wpa_bool_txt(int boo + return bool ? "TRUE" : "FALSE"; + } + ++#ifdef CONFIG_CTRL_IFACE_MIB + + #define RSN_SUITE "%02x-%02x-%02x-%d" + #define RSN_SUITE_ARG(s) \ +@@ -3143,7 +3144,7 @@ int wpa_get_mib_sta(struct wpa_state_mac + + return len; + } +- ++#endif + + void wpa_auth_countermeasures_start(struct wpa_authenticator *wpa_auth) + { +--- a/src/rsn_supp/wpa.c ++++ b/src/rsn_supp/wpa.c +@@ -2032,6 +2032,8 @@ static u32 wpa_key_mgmt_suite(struct wpa + } + + ++#ifdef CONFIG_CTRL_IFACE_MIB ++ + #define RSN_SUITE "%02x-%02x-%02x-%d" + #define RSN_SUITE_ARG(s) \ + ((s) >> 24) & 0xff, ((s) >> 16) & 0xff, ((s) >> 8) & 0xff, (s) & 0xff +@@ -2115,6 +2117,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, ch + + return (int) len; + } ++#endif + #endif /* CONFIG_CTRL_IFACE */ + + +--- a/wpa_supplicant/ap.c ++++ b/wpa_supplicant/ap.c +@@ -1015,7 +1015,7 @@ int wpas_ap_wps_nfc_report_handover(stru + #endif /* CONFIG_WPS */ + + +-#ifdef CONFIG_CTRL_IFACE ++#if defined(CONFIG_CTRL_IFACE) && defined(CONFIG_CTRL_IFACE_MIB) + + int ap_ctrl_iface_sta_first(struct wpa_supplicant *wpa_s, + char *buf, size_t buflen) diff --git a/package/network/services/hostapd/patches/390-wpa_ie_cap_workaround.patch b/package/network/services/hostapd/patches/390-wpa_ie_cap_workaround.patch new file mode 100644 index 0000000..1065a7f --- /dev/null +++ b/package/network/services/hostapd/patches/390-wpa_ie_cap_workaround.patch @@ -0,0 +1,56 @@ +--- a/src/common/wpa_common.c ++++ b/src/common/wpa_common.c +@@ -1228,6 +1228,31 @@ u32 wpa_akm_to_suite(int akm) + } + + ++static void wpa_fixup_wpa_ie_rsn(u8 *assoc_ie, const u8 *wpa_msg_ie, ++ size_t rsn_ie_len) ++{ ++ int pos, count; ++ ++ pos = sizeof(struct rsn_ie_hdr) + RSN_SELECTOR_LEN; ++ if (rsn_ie_len < pos + 2) ++ return; ++ ++ count = WPA_GET_LE16(wpa_msg_ie + pos); ++ pos += 2 + count * RSN_SELECTOR_LEN; ++ if (rsn_ie_len < pos + 2) ++ return; ++ ++ count = WPA_GET_LE16(wpa_msg_ie + pos); ++ pos += 2 + count * RSN_SELECTOR_LEN; ++ if (rsn_ie_len < pos + 2) ++ return; ++ ++ if (!assoc_ie[pos] && !assoc_ie[pos + 1] && ++ (wpa_msg_ie[pos] || wpa_msg_ie[pos + 1])) ++ memcpy(&assoc_ie[pos], &wpa_msg_ie[pos], 2); ++} ++ ++ + int wpa_compare_rsn_ie(int ft_initial_assoc, + const u8 *ie1, size_t ie1len, + const u8 *ie2, size_t ie2len) +@@ -1235,8 +1260,19 @@ int wpa_compare_rsn_ie(int ft_initial_as + if (ie1 == NULL || ie2 == NULL) + return -1; + +- if (ie1len == ie2len && os_memcmp(ie1, ie2, ie1len) == 0) +- return 0; /* identical IEs */ ++ if (ie1len == ie2len) { ++ u8 *ie_tmp; ++ ++ if (os_memcmp(ie1, ie2, ie1len) == 0) ++ return 0; /* identical IEs */ ++ ++ ie_tmp = alloca(ie1len); ++ memcpy(ie_tmp, ie1, ie1len); ++ wpa_fixup_wpa_ie_rsn(ie_tmp, ie2, ie1len); ++ ++ if (os_memcmp(ie_tmp, ie2, ie1len) == 0) ++ return 0; /* only mismatch in RSN capabilties */ ++ } + + #ifdef CONFIG_IEEE80211R + if (ft_initial_assoc) { diff --git a/package/network/services/hostapd/patches/400-wps_single_auth_enc_type.patch b/package/network/services/hostapd/patches/400-wps_single_auth_enc_type.patch new file mode 100644 index 0000000..083af5b --- /dev/null +++ b/package/network/services/hostapd/patches/400-wps_single_auth_enc_type.patch @@ -0,0 +1,25 @@ +--- a/src/ap/wps_hostapd.c ++++ b/src/ap/wps_hostapd.c +@@ -1052,11 +1052,9 @@ int hostapd_init_wps(struct hostapd_data + + if (conf->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)) + wps->encr_types |= WPS_ENCR_AES; +- if (conf->rsn_pairwise & WPA_CIPHER_TKIP) ++ else if (conf->rsn_pairwise & WPA_CIPHER_TKIP) + wps->encr_types |= WPS_ENCR_TKIP; +- } +- +- if (conf->wpa & WPA_PROTO_WPA) { ++ } else if (conf->wpa & WPA_PROTO_WPA) { + if (conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK) + wps->auth_types |= WPS_AUTH_WPAPSK; + if (conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X) +@@ -1064,7 +1062,7 @@ int hostapd_init_wps(struct hostapd_data + + if (conf->wpa_pairwise & WPA_CIPHER_CCMP) + wps->encr_types |= WPS_ENCR_AES; +- if (conf->wpa_pairwise & WPA_CIPHER_TKIP) ++ else if (conf->wpa_pairwise & WPA_CIPHER_TKIP) + wps->encr_types |= WPS_ENCR_TKIP; + } + diff --git a/package/network/services/hostapd/patches/410-limit_debug_messages.patch b/package/network/services/hostapd/patches/410-limit_debug_messages.patch new file mode 100644 index 0000000..da88732 --- /dev/null +++ b/package/network/services/hostapd/patches/410-limit_debug_messages.patch @@ -0,0 +1,214 @@ +--- a/src/utils/wpa_debug.c ++++ b/src/utils/wpa_debug.c +@@ -201,7 +201,7 @@ void wpa_debug_close_linux_tracing(void) + * + * Note: New line '\n' is added to the end of the text when printing to stdout. + */ +-void wpa_printf(int level, const char *fmt, ...) ++void _wpa_printf(int level, const char *fmt, ...) + { + va_list ap; + +@@ -248,8 +248,8 @@ void wpa_printf(int level, const char *f + } + + +-static void _wpa_hexdump(int level, const char *title, const u8 *buf, +- size_t len, int show) ++void _wpa_hexdump(int level, const char *title, const u8 *buf, ++ size_t len, int show) + { + size_t i; + +@@ -375,20 +375,8 @@ static void _wpa_hexdump(int level, cons + #endif /* CONFIG_ANDROID_LOG */ + } + +-void wpa_hexdump(int level, const char *title, const void *buf, size_t len) +-{ +- _wpa_hexdump(level, title, buf, len, 1); +-} +- +- +-void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len) +-{ +- _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys); +-} +- +- +-static void _wpa_hexdump_ascii(int level, const char *title, const void *buf, +- size_t len, int show) ++void _wpa_hexdump_ascii(int level, const char *title, const void *buf, ++ size_t len, int show) + { + size_t i, llen; + const u8 *pos = buf; +@@ -495,20 +483,6 @@ static void _wpa_hexdump_ascii(int level + } + + +-void wpa_hexdump_ascii(int level, const char *title, const void *buf, +- size_t len) +-{ +- _wpa_hexdump_ascii(level, title, buf, len, 1); +-} +- +- +-void wpa_hexdump_ascii_key(int level, const char *title, const void *buf, +- size_t len) +-{ +- _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys); +-} +- +- + #ifdef CONFIG_DEBUG_FILE + static char *last_path = NULL; + #endif /* CONFIG_DEBUG_FILE */ +@@ -602,7 +576,7 @@ void wpa_msg_register_ifname_cb(wpa_msg_ + } + + +-void wpa_msg(void *ctx, int level, const char *fmt, ...) ++void _wpa_msg(void *ctx, int level, const char *fmt, ...) + { + va_list ap; + char *buf; +@@ -640,7 +614,7 @@ void wpa_msg(void *ctx, int level, const + } + + +-void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...) ++void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...) + { + va_list ap; + char *buf; +--- a/src/utils/wpa_debug.h ++++ b/src/utils/wpa_debug.h +@@ -49,6 +49,17 @@ int wpa_debug_reopen_file(void); + void wpa_debug_close_file(void); + void wpa_debug_setup_stdout(void); + ++/* internal */ ++void _wpa_hexdump(int level, const char *title, const u8 *buf, ++ size_t len, int show); ++void _wpa_hexdump_ascii(int level, const char *title, const void *buf, ++ size_t len, int show); ++extern int wpa_debug_show_keys; ++ ++#ifndef CONFIG_MSG_MIN_PRIORITY ++#define CONFIG_MSG_MIN_PRIORITY 0 ++#endif ++ + /** + * wpa_debug_printf_timestamp - Print timestamp for debug output + * +@@ -69,9 +80,15 @@ void wpa_debug_print_timestamp(void); + * + * Note: New line '\n' is added to the end of the text when printing to stdout. + */ +-void wpa_printf(int level, const char *fmt, ...) ++void _wpa_printf(int level, const char *fmt, ...) + PRINTF_FORMAT(2, 3); + ++#define wpa_printf(level, ...) \ ++ do { \ ++ if (level >= CONFIG_MSG_MIN_PRIORITY) \ ++ _wpa_printf(level, __VA_ARGS__); \ ++ } while(0) ++ + /** + * wpa_hexdump - conditional hex dump + * @level: priority level (MSG_*) of the message +@@ -83,7 +100,13 @@ PRINTF_FORMAT(2, 3); + * output may be directed to stdout, stderr, and/or syslog based on + * configuration. The contents of buf is printed out has hex dump. + */ +-void wpa_hexdump(int level, const char *title, const void *buf, size_t len); ++static inline void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len) ++{ ++ if (level < CONFIG_MSG_MIN_PRIORITY) ++ return; ++ ++ _wpa_hexdump(level, title, buf, len, 1); ++} + + static inline void wpa_hexdump_buf(int level, const char *title, + const struct wpabuf *buf) +@@ -105,7 +128,13 @@ static inline void wpa_hexdump_buf(int l + * like wpa_hexdump(), but by default, does not include secret keys (passwords, + * etc.) in debug output. + */ +-void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len); ++static inline void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len) ++{ ++ if (level < CONFIG_MSG_MIN_PRIORITY) ++ return; ++ ++ _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys); ++} + + static inline void wpa_hexdump_buf_key(int level, const char *title, + const struct wpabuf *buf) +@@ -127,8 +156,14 @@ static inline void wpa_hexdump_buf_key(i + * the hex numbers and ASCII characters (for printable range) are shown. 16 + * bytes per line will be shown. + */ +-void wpa_hexdump_ascii(int level, const char *title, const void *buf, +- size_t len); ++static inline void wpa_hexdump_ascii(int level, const char *title, ++ const u8 *buf, size_t len) ++{ ++ if (level < CONFIG_MSG_MIN_PRIORITY) ++ return; ++ ++ _wpa_hexdump_ascii(level, title, buf, len, 1); ++} + + /** + * wpa_hexdump_ascii_key - conditional hex dump, hide keys +@@ -144,8 +179,14 @@ void wpa_hexdump_ascii(int level, const + * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by + * default, does not include secret keys (passwords, etc.) in debug output. + */ +-void wpa_hexdump_ascii_key(int level, const char *title, const void *buf, +- size_t len); ++static inline void wpa_hexdump_ascii_key(int level, const char *title, ++ const u8 *buf, size_t len) ++{ ++ if (level < CONFIG_MSG_MIN_PRIORITY) ++ return; ++ ++ _wpa_hexdump_ascii(level, title, buf, len, wpa_debug_show_keys); ++} + + /* + * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce +@@ -181,7 +222,12 @@ void wpa_hexdump_ascii_key(int level, co + * + * Note: New line '\n' is added to the end of the text when printing to stdout. + */ +-void wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4); ++void _wpa_msg(void *ctx, int level, const char *fmt, ...) PRINTF_FORMAT(3, 4); ++#define wpa_msg(ctx, level, ...) \ ++ do { \ ++ if (level >= CONFIG_MSG_MIN_PRIORITY) \ ++ _wpa_msg(ctx, level, __VA_ARGS__); \ ++ } while(0) + + /** + * wpa_msg_ctrl - Conditional printf for ctrl_iface monitors +@@ -195,8 +241,13 @@ void wpa_msg(void *ctx, int level, const + * attached ctrl_iface monitors. In other words, it can be used for frequent + * events that do not need to be sent to syslog. + */ +-void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...) ++void _wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...) + PRINTF_FORMAT(3, 4); ++#define wpa_msg_ctrl(ctx, level, ...) \ ++ do { \ ++ if (level >= CONFIG_MSG_MIN_PRIORITY) \ ++ _wpa_msg_ctrl(ctx, level, __VA_ARGS__); \ ++ } while(0) + + /** + * wpa_msg_global - Global printf for ctrl_iface monitors diff --git a/package/network/services/hostapd/patches/420-indicate-features.patch b/package/network/services/hostapd/patches/420-indicate-features.patch new file mode 100644 index 0000000..64c92df --- /dev/null +++ b/package/network/services/hostapd/patches/420-indicate-features.patch @@ -0,0 +1,82 @@ +--- a/hostapd/main.c ++++ b/hostapd/main.c +@@ -15,6 +15,7 @@ + #include "utils/common.h" + #include "utils/eloop.h" + #include "utils/uuid.h" ++#include "utils/build_features.h" + #include "crypto/random.h" + #include "crypto/tls.h" + #include "common/version.h" +@@ -567,7 +568,7 @@ int main(int argc, char *argv[]) + + wpa_supplicant_event = hostapd_wpa_event; + for (;;) { +- c = getopt(argc, argv, "b:Bde:f:hKP:Ttu:vg:G:"); ++ c = getopt(argc, argv, "b:Bde:f:hKP:Ttu:g:G:v::"); + if (c < 0) + break; + switch (c) { +@@ -604,6 +605,8 @@ int main(int argc, char *argv[]) + break; + #endif /* CONFIG_DEBUG_LINUX_TRACING */ + case 'v': ++ if (optarg) ++ exit(!has_feature(optarg)); + show_version(); + exit(1); + break; +--- a/wpa_supplicant/main.c ++++ b/wpa_supplicant/main.c +@@ -12,6 +12,7 @@ + #endif /* __linux__ */ + + #include "common.h" ++#include "build_features.h" + #include "wpa_supplicant_i.h" + #include "driver_i.h" + #include "p2p_supplicant.h" +@@ -176,7 +177,7 @@ int main(int argc, char *argv[]) + + for (;;) { + c = getopt(argc, argv, +- "b:Bc:C:D:de:f:g:G:hH:i:I:KLm:No:O:p:P:qsTtuvW"); ++ "b:Bc:C:D:de:f:g:G:hH:i:I:KLm:No:O:p:P:qsTtuv::W"); + if (c < 0) + break; + switch (c) { +@@ -279,8 +280,12 @@ int main(int argc, char *argv[]) + break; + #endif /* CONFIG_DBUS */ + case 'v': +- printf("%s\n", wpa_supplicant_version); +- exitcode = 0; ++ if (optarg) { ++ exitcode = !has_feature(optarg); ++ } else { ++ printf("%s\n", wpa_supplicant_version); ++ exitcode = 0; ++ } + goto out; + case 'W': + params.wait_for_monitor++; +--- /dev/null ++++ b/src/utils/build_features.h +@@ -0,0 +1,17 @@ ++#ifndef BUILD_FEATURES_H ++#define BUILD_FEATURES_H ++ ++static inline int has_feature(const char *feat) ++{ ++#ifdef IEEE8021X_EAPOL ++ if (!strcmp(feat, "eap")) ++ return 1; ++#endif ++#ifdef IEEE80211N ++ if (!strcmp(feat, "11n")) ++ return 1; ++#endif ++ return 0; ++} ++ ++#endif /* BUILD_FEATURES_H */ diff --git a/package/network/services/hostapd/patches/430-hostapd_cli_ifdef.patch b/package/network/services/hostapd/patches/430-hostapd_cli_ifdef.patch new file mode 100644 index 0000000..85d2e16 --- /dev/null +++ b/package/network/services/hostapd/patches/430-hostapd_cli_ifdef.patch @@ -0,0 +1,50 @@ +--- a/hostapd/hostapd_cli.c ++++ b/hostapd/hostapd_cli.c +@@ -67,7 +67,6 @@ static const char *commands_help = + #ifdef CONFIG_IEEE80211W + " sa_query send SA Query to a station\n" + #endif /* CONFIG_IEEE80211W */ +-#ifdef CONFIG_WPS + " wps_pin [timeout] [addr] add WPS Enrollee PIN\n" + " wps_check_pin verify PIN checksum\n" + " wps_pbc indicate button pushed to initiate PBC\n" +@@ -80,7 +79,6 @@ static const char *commands_help = + " wps_ap_pin [params..] enable/disable AP PIN\n" + " wps_config configure AP\n" + " wps_get_status show current WPS status\n" +-#endif /* CONFIG_WPS */ + " get_config show current configuration\n" + " help show this usage help\n" + " interface [ifname] show interfaces/select interface\n" +@@ -353,7 +351,6 @@ static int hostapd_cli_cmd_sa_query(stru + #endif /* CONFIG_IEEE80211W */ + + +-#ifdef CONFIG_WPS + static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc, + char *argv[]) + { +@@ -579,7 +576,6 @@ static int hostapd_cli_cmd_wps_config(st + ssid_hex, argv[1]); + return wpa_ctrl_command(ctrl, buf); + } +-#endif /* CONFIG_WPS */ + + + static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc, +@@ -1027,7 +1023,6 @@ static struct hostapd_cli_cmd hostapd_cl + #ifdef CONFIG_IEEE80211W + { "sa_query", hostapd_cli_cmd_sa_query }, + #endif /* CONFIG_IEEE80211W */ +-#ifdef CONFIG_WPS + { "wps_pin", hostapd_cli_cmd_wps_pin }, + { "wps_check_pin", hostapd_cli_cmd_wps_check_pin }, + { "wps_pbc", hostapd_cli_cmd_wps_pbc }, +@@ -1041,7 +1036,6 @@ static struct hostapd_cli_cmd hostapd_cl + { "wps_ap_pin", hostapd_cli_cmd_wps_ap_pin }, + { "wps_config", hostapd_cli_cmd_wps_config }, + { "wps_get_status", hostapd_cli_cmd_wps_get_status }, +-#endif /* CONFIG_WPS */ + { "disassoc_imminent", hostapd_cli_cmd_disassoc_imminent }, + { "ess_disassoc", hostapd_cli_cmd_ess_disassoc }, + { "bss_tm_req", hostapd_cli_cmd_bss_tm_req }, diff --git a/package/network/services/hostapd/patches/431-wpa_cli_ifdef.patch b/package/network/services/hostapd/patches/431-wpa_cli_ifdef.patch new file mode 100644 index 0000000..874ff4b --- /dev/null +++ b/package/network/services/hostapd/patches/431-wpa_cli_ifdef.patch @@ -0,0 +1,13 @@ +--- a/wpa_supplicant/wpa_cli.c ++++ b/wpa_supplicant/wpa_cli.c +@@ -26,6 +26,10 @@ + #endif /* ANDROID */ + + ++#ifndef CONFIG_P2P ++#define CONFIG_P2P ++#endif ++ + static const char *wpa_cli_version = + "wpa_cli v" VERSION_STR "\n" + "Copyright (c) 2004-2015, Jouni Malinen and contributors"; diff --git a/package/network/services/hostapd/patches/440-max_num_sta_probe.patch b/package/network/services/hostapd/patches/440-max_num_sta_probe.patch new file mode 100644 index 0000000..74aef26 --- /dev/null +++ b/package/network/services/hostapd/patches/440-max_num_sta_probe.patch @@ -0,0 +1,13 @@ +--- a/src/ap/beacon.c ++++ b/src/ap/beacon.c +@@ -664,6 +664,10 @@ void handle_probe_req(struct hostapd_dat + return; + } + ++ if (!sta && hapd->num_sta >= hapd->conf->max_num_sta) ++ wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " ignored," ++ " too many connected stations.", MAC2STR(mgmt->sa)); ++ + #ifdef CONFIG_INTERWORKING + if (hapd->conf->interworking && + elems.interworking && elems.interworking_len >= 1) { diff --git a/package/network/services/hostapd/patches/450-scan_wait.patch b/package/network/services/hostapd/patches/450-scan_wait.patch new file mode 100644 index 0000000..87ebd45 --- /dev/null +++ b/package/network/services/hostapd/patches/450-scan_wait.patch @@ -0,0 +1,66 @@ +--- a/hostapd/main.c ++++ b/hostapd/main.c +@@ -36,6 +36,8 @@ struct hapd_global { + }; + + static struct hapd_global global; ++static int daemonize = 0; ++static char *pid_file = NULL; + + + #ifndef CONFIG_NO_HOSTAPD_LOGGER +@@ -142,6 +144,14 @@ static void hostapd_logger_cb(void *ctx, + } + #endif /* CONFIG_NO_HOSTAPD_LOGGER */ + ++static void hostapd_setup_complete_cb(void *ctx) ++{ ++ if (daemonize && os_daemonize(pid_file)) { ++ perror("daemon"); ++ return; ++ } ++ daemonize = 0; ++} + + /** + * hostapd_driver_init - Preparate driver interface +@@ -160,6 +170,8 @@ static int hostapd_driver_init(struct ho + return -1; + } + ++ hapd->setup_complete_cb = hostapd_setup_complete_cb; ++ + /* Initialize the driver interface */ + if (!(b[0] | b[1] | b[2] | b[3] | b[4] | b[5])) + b = NULL; +@@ -381,8 +393,6 @@ static void hostapd_global_deinit(const + #endif /* CONFIG_NATIVE_WINDOWS */ + + eap_server_unregister_methods(); +- +- os_daemonize_terminate(pid_file); + } + + +@@ -408,11 +418,6 @@ static int hostapd_global_run(struct hap + } + #endif /* EAP_SERVER_TNC */ + +- if (daemonize && os_daemonize(pid_file)) { +- wpa_printf(MSG_ERROR, "daemon: %s", strerror(errno)); +- return -1; +- } +- + eloop_run(); + + return 0; +@@ -542,8 +547,7 @@ int main(int argc, char *argv[]) + struct hapd_interfaces interfaces; + int ret = 1; + size_t i, j; +- int c, debug = 0, daemonize = 0; +- char *pid_file = NULL; ++ int c, debug = 0; + const char *log_file = NULL; + const char *entropy_file = NULL; + char **bss_config = NULL, **tmp_bss; diff --git a/package/network/services/hostapd/patches/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch b/package/network/services/hostapd/patches/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch new file mode 100644 index 0000000..217e701 --- /dev/null +++ b/package/network/services/hostapd/patches/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch @@ -0,0 +1,188 @@ +From 4bb69d15477e0f2b00e166845341dc933de47c58 Mon Sep 17 00:00:00 2001 +From: Antonio Quartulli +Date: Sun, 3 Jun 2012 18:22:56 +0200 +Subject: [PATCHv2 601/602] wpa_supplicant: add new config params to be used + with the ibss join command + +Signed-hostap: Antonio Quartulli +--- + src/drivers/driver.h | 6 +++ + wpa_supplicant/config.c | 96 +++++++++++++++++++++++++++++++++++++++ + wpa_supplicant/config_ssid.h | 6 +++ + wpa_supplicant/wpa_supplicant.c | 23 +++++++--- + 4 files changed, 124 insertions(+), 7 deletions(-) + +--- a/src/drivers/driver.h ++++ b/src/drivers/driver.h +@@ -19,6 +19,7 @@ + + #define WPA_SUPPLICANT_DRIVER_VERSION 4 + ++#include "drivers/nl80211_copy.h" + #include "common/defs.h" + #include "utils/list.h" + +@@ -538,6 +539,9 @@ struct wpa_driver_associate_params { + * responsible for selecting with which BSS to associate. */ + const u8 *bssid; + ++ unsigned char rates[NL80211_MAX_SUPP_RATES]; ++ int mcast_rate; ++ + /** + * bssid_hint - BSSID of a proposed AP + * +--- a/wpa_supplicant/config.c ++++ b/wpa_supplicant/config.c +@@ -15,6 +15,7 @@ + #include "rsn_supp/wpa.h" + #include "eap_peer/eap.h" + #include "p2p/p2p.h" ++#include "drivers/nl80211_copy.h" + #include "config.h" + + +@@ -1722,6 +1723,97 @@ static char * wpa_config_write_mesh_basi + #endif /* CONFIG_MESH */ + + ++static int wpa_config_parse_mcast_rate(const struct parse_data *data, ++ struct wpa_ssid *ssid, int line, ++ const char *value) ++{ ++ ssid->mcast_rate = (int)(strtod(value, NULL) * 10); ++ ++ return 0; ++} ++ ++#ifndef NO_CONFIG_WRITE ++static char * wpa_config_write_mcast_rate(const struct parse_data *data, ++ struct wpa_ssid *ssid) ++{ ++ char *value; ++ int res; ++ ++ if (!ssid->mcast_rate == 0) ++ return NULL; ++ ++ value = os_malloc(6); /* longest: 300.0 */ ++ if (value == NULL) ++ return NULL; ++ res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10); ++ if (res < 0) { ++ os_free(value); ++ return NULL; ++ } ++ return value; ++} ++#endif /* NO_CONFIG_WRITE */ ++ ++static int wpa_config_parse_rates(const struct parse_data *data, ++ struct wpa_ssid *ssid, int line, ++ const char *value) ++{ ++ int i; ++ char *pos, *r, *sptr, *end; ++ double rate; ++ ++ pos = (char *)value; ++ r = strtok_r(pos, ",", &sptr); ++ i = 0; ++ while (pos && i < NL80211_MAX_SUPP_RATES) { ++ rate = 0.0; ++ if (r) ++ rate = strtod(r, &end); ++ ssid->rates[i] = rate * 2; ++ if (*end != '\0' || rate * 2 != ssid->rates[i]) ++ return 1; ++ ++ i++; ++ r = strtok_r(NULL, ",", &sptr); ++ } ++ ++ return 0; ++} ++ ++#ifndef NO_CONFIG_WRITE ++static char * wpa_config_write_rates(const struct parse_data *data, ++ struct wpa_ssid *ssid) ++{ ++ char *value, *pos; ++ int res, i; ++ ++ if (ssid->rates[0] <= 0) ++ return NULL; ++ ++ value = os_malloc(6 * NL80211_MAX_SUPP_RATES + 1); ++ if (value == NULL) ++ return NULL; ++ pos = value; ++ for (i = 0; i < NL80211_MAX_SUPP_RATES - 1; i++) { ++ res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2); ++ if (res < 0) { ++ os_free(value); ++ return NULL; ++ } ++ pos += res; ++ } ++ res = os_snprintf(pos, 6, "%.1f", ++ (double)ssid->rates[NL80211_MAX_SUPP_RATES - 1] / 2); ++ if (res < 0) { ++ os_free(value); ++ return NULL; ++ } ++ ++ value[6 * NL80211_MAX_SUPP_RATES] = '\0'; ++ return value; ++} ++#endif /* NO_CONFIG_WRITE */ ++ + /* Helper macros for network block parser */ + + #ifdef OFFSET +@@ -1947,6 +2039,9 @@ static const struct parse_data ssid_fiel + { INT(ap_max_inactivity) }, + { INT(dtim_period) }, + { INT(beacon_int) }, ++ { INT_RANGE(fixed_freq, 0, 1) }, ++ { FUNC(rates) }, ++ { FUNC(mcast_rate) }, + #ifdef CONFIG_MACSEC + { INT_RANGE(macsec_policy, 0, 1) }, + #endif /* CONFIG_MACSEC */ +--- a/wpa_supplicant/config_ssid.h ++++ b/wpa_supplicant/config_ssid.h +@@ -12,6 +12,7 @@ + #include "common/defs.h" + #include "utils/list.h" + #include "eap_peer/eap_config.h" ++#include "drivers/nl80211_copy.h" + + #define MAX_SSID_LEN 32 + +@@ -675,6 +676,9 @@ struct wpa_ssid { + */ + void *parent_cred; + ++ unsigned char rates[NL80211_MAX_SUPP_RATES]; ++ double mcast_rate; ++ + #ifdef CONFIG_MACSEC + /** + * macsec_policy - Determines the policy for MACsec secure session +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -2266,6 +2266,13 @@ static void wpas_start_assoc_cb(struct w + params.beacon_int = ssid->beacon_int; + else + params.beacon_int = wpa_s->conf->beacon_int; ++ params.fixed_freq = ssid->fixed_freq; ++ i = 0; ++ while (i < NL80211_MAX_SUPP_RATES) { ++ params.rates[i] = ssid->rates[i]; ++ i++; ++ } ++ params.mcast_rate = ssid->mcast_rate; + } + + params.wpa_ie = wpa_ie; diff --git a/package/network/services/hostapd/patches/461-driver_nl80211-use-new-parameters-during-ibss-join.patch b/package/network/services/hostapd/patches/461-driver_nl80211-use-new-parameters-during-ibss-join.patch new file mode 100644 index 0000000..730cc31 --- /dev/null +++ b/package/network/services/hostapd/patches/461-driver_nl80211-use-new-parameters-during-ibss-join.patch @@ -0,0 +1,59 @@ +From ffc4445958a3ed4064f2e1bf73fa478a61c5cf7b Mon Sep 17 00:00:00 2001 +From: Antonio Quartulli +Date: Sun, 3 Jun 2012 18:42:25 +0200 +Subject: [PATCHv2 602/602] driver_nl80211: use new parameters during ibss join + +Signed-hostap: Antonio Quartulli +--- + src/drivers/driver_nl80211.c | 33 ++++++++++++++++++++++++++++++++- + 1 file changed, 32 insertions(+), 1 deletion(-) + +--- a/src/drivers/driver_nl80211.c ++++ b/src/drivers/driver_nl80211.c +@@ -4398,7 +4398,7 @@ static int wpa_driver_nl80211_ibss(struc + struct wpa_driver_associate_params *params) + { + struct nl_msg *msg; +- int ret = -1; ++ int ret = -1, i; + int count = 0; + + wpa_printf(MSG_DEBUG, "nl80211: Join IBSS (ifindex=%d)", drv->ifindex); +@@ -4425,6 +4425,37 @@ retry: + nl80211_put_beacon_int(msg, params->beacon_int)) + goto fail; + ++ if (params->fixed_freq) { ++ wpa_printf(MSG_DEBUG, " * fixed_freq"); ++ nla_put_flag(msg, NL80211_ATTR_FREQ_FIXED); ++ } ++ ++ if (params->beacon_int > 0) { ++ wpa_printf(MSG_DEBUG, " * beacon_int=%d", ++ params->beacon_int); ++ nla_put_u32(msg, NL80211_ATTR_BEACON_INTERVAL, ++ params->beacon_int); ++ } ++ ++ if (params->rates[0] > 0) { ++ wpa_printf(MSG_DEBUG, " * basic_rates:"); ++ i = 0; ++ while (i < NL80211_MAX_SUPP_RATES && ++ params->rates[i] > 0) { ++ wpa_printf(MSG_DEBUG, " %.1f", ++ (double)params->rates[i] / 2); ++ i++; ++ } ++ nla_put(msg, NL80211_ATTR_BSS_BASIC_RATES, i, ++ params->rates); ++ } ++ ++ if (params->mcast_rate > 0) { ++ wpa_printf(MSG_DEBUG, " * mcast_rate=%.1f", ++ (double)params->mcast_rate / 10); ++ nla_put_u32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate); ++ } ++ + ret = nl80211_set_conn_keys(params, msg); + if (ret) + goto fail; diff --git a/package/network/services/hostapd/patches/462-wpa_s-support-htmode-param.patch b/package/network/services/hostapd/patches/462-wpa_s-support-htmode-param.patch new file mode 100644 index 0000000..30bb2dc --- /dev/null +++ b/package/network/services/hostapd/patches/462-wpa_s-support-htmode-param.patch @@ -0,0 +1,156 @@ +From b9329c5dfeed7d5c55d2117d8dfe326fc40c8fb1 Mon Sep 17 00:00:00 2001 +From: Antonio Quartulli +Date: Tue, 3 Jul 2012 00:36:24 +0200 +Subject: [PATCH] wpa_s: support htmode param + +possible values are HT20, HT40-, HT40+ and NOHT + +Signed-off-by: Antonio Quartulli +--- + src/drivers/driver.h | 2 ++ + src/drivers/driver_nl80211.c | 16 ++++++++++ + wpa_supplicant/config.c | 66 +++++++++++++++++++++++++++++++++++++++ + wpa_supplicant/config_ssid.h | 2 ++ + wpa_supplicant/wpa_supplicant.c | 2 ++ + 5 files changed, 88 insertions(+) + +--- a/src/drivers/driver.h ++++ b/src/drivers/driver.h +@@ -541,6 +541,8 @@ struct wpa_driver_associate_params { + + unsigned char rates[NL80211_MAX_SUPP_RATES]; + int mcast_rate; ++ int ht_set; ++ unsigned int htmode; + + /** + * bssid_hint - BSSID of a proposed AP +--- a/src/drivers/driver_nl80211.c ++++ b/src/drivers/driver_nl80211.c +@@ -4456,6 +4456,22 @@ retry: + nla_put_u32(msg, NL80211_ATTR_MCAST_RATE, params->mcast_rate); + } + ++ if (params->ht_set) { ++ switch(params->htmode) { ++ case NL80211_CHAN_HT20: ++ wpa_printf(MSG_DEBUG, " * ht=HT20"); ++ break; ++ case NL80211_CHAN_HT40PLUS: ++ wpa_printf(MSG_DEBUG, " * ht=HT40+"); ++ break; ++ case NL80211_CHAN_HT40MINUS: ++ wpa_printf(MSG_DEBUG, " * ht=HT40-"); ++ break; ++ } ++ nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, ++ params->htmode); ++ } ++ + ret = nl80211_set_conn_keys(params, msg); + if (ret) + goto fail; +--- a/wpa_supplicant/config.c ++++ b/wpa_supplicant/config.c +@@ -1754,6 +1754,71 @@ static char * wpa_config_write_mcast_rat + } + #endif /* NO_CONFIG_WRITE */ + ++static int wpa_config_parse_htmode(const struct parse_data *data, ++ struct wpa_ssid *ssid, int line, ++ const char *value) ++{ ++ int i; ++ static const struct { ++ const char *name; ++ unsigned int val; ++ } htmap[] = { ++ { .name = "HT20", .val = NL80211_CHAN_HT20, }, ++ { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, }, ++ { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, }, ++ { .name = "NOHT", .val = NL80211_CHAN_NO_HT, }, ++ }; ++ ssid->ht_set = 0;; ++ for (i = 0; i < 4; i++) { ++ if (strcasecmp(htmap[i].name, value) == 0) { ++ ssid->htmode = htmap[i].val; ++ ssid->ht_set = 1; ++ break; ++ } ++ } ++ ++ return 0; ++} ++ ++#ifndef NO_CONFIG_WRITE ++static char * wpa_config_write_htmode(const struct parse_data *data, ++ struct wpa_ssid *ssid) ++{ ++ char *value; ++ int res; ++ ++ value = os_malloc(6); /* longest: HT40+ */ ++ if (value == NULL) ++ return NULL; ++ ++ switch(ssid->htmode) { ++ case NL80211_CHAN_HT20: ++ res = os_snprintf(value, 4, "HT20"); ++ break; ++ case NL80211_CHAN_HT40PLUS: ++ res = os_snprintf(value, 5, "HT40+"); ++ break; ++ case NL80211_CHAN_HT40MINUS: ++ res = os_snprintf(value, 5, "HT40-"); ++ break; ++ case NL80211_CHAN_NO_HT: ++ res = os_snprintf(value, 4, "NOHT"); ++ break; ++ default: ++ os_free(value); ++ return NULL; ++ } ++ ++ if (res < 0) { ++ os_free(value); ++ return NULL; ++ } ++ ++ return value; ++} ++#endif /* NO_CONFIG_WRITE */ ++ ++ + static int wpa_config_parse_rates(const struct parse_data *data, + struct wpa_ssid *ssid, int line, + const char *value) +@@ -2042,6 +2107,7 @@ static const struct parse_data ssid_fiel + { INT_RANGE(fixed_freq, 0, 1) }, + { FUNC(rates) }, + { FUNC(mcast_rate) }, ++ { FUNC(htmode) }, + #ifdef CONFIG_MACSEC + { INT_RANGE(macsec_policy, 0, 1) }, + #endif /* CONFIG_MACSEC */ +--- a/wpa_supplicant/config_ssid.h ++++ b/wpa_supplicant/config_ssid.h +@@ -678,6 +678,8 @@ struct wpa_ssid { + + unsigned char rates[NL80211_MAX_SUPP_RATES]; + double mcast_rate; ++ int ht_set; ++ unsigned int htmode; + + #ifdef CONFIG_MACSEC + /** +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -2273,6 +2273,8 @@ static void wpas_start_assoc_cb(struct w + i++; + } + params.mcast_rate = ssid->mcast_rate; ++ params.ht_set = ssid->ht_set; ++ params.htmode = ssid->htmode; + } + + params.wpa_ie = wpa_ie; diff --git a/package/network/services/hostapd/patches/470-wait-for-nullfunc-longer.patch b/package/network/services/hostapd/patches/470-wait-for-nullfunc-longer.patch new file mode 100644 index 0000000..e6bbddd --- /dev/null +++ b/package/network/services/hostapd/patches/470-wait-for-nullfunc-longer.patch @@ -0,0 +1,11 @@ +--- a/src/ap/sta_info.h ++++ b/src/ap/sta_info.h +@@ -179,7 +179,7 @@ struct sta_info { + * AP_DISASSOC_DELAY seconds. Similarly, the station will be deauthenticated + * after AP_DEAUTH_DELAY seconds has passed after disassociation. */ + #define AP_MAX_INACTIVITY (5 * 60) +-#define AP_DISASSOC_DELAY (1) ++#define AP_DISASSOC_DELAY (3) + #define AP_DEAUTH_DELAY (1) + /* Number of seconds to keep STA entry with Authenticated flag after it has + * been disassociated. */ diff --git a/package/network/services/hostapd/patches/600-ubus_support.patch b/package/network/services/hostapd/patches/600-ubus_support.patch new file mode 100644 index 0000000..df2eac8 --- /dev/null +++ b/package/network/services/hostapd/patches/600-ubus_support.patch @@ -0,0 +1,858 @@ +--- a/hostapd/Makefile ++++ b/hostapd/Makefile +@@ -121,6 +121,11 @@ OBJS += ../src/common/hw_features_common + + OBJS += ../src/eapol_auth/eapol_auth_sm.o + ++ifdef CONFIG_UBUS ++CFLAGS += -DUBUS_SUPPORT ++OBJS += ../src/ap/ubus.o ++LIBS += -lubox -lubus ++endif + + ifdef CONFIG_CODE_COVERAGE + CFLAGS += -O0 -fprofile-arcs -ftest-coverage +--- a/src/ap/hostapd.h ++++ b/src/ap/hostapd.h +@@ -13,6 +13,7 @@ + #include "utils/list.h" + #include "ap_config.h" + #include "drivers/driver.h" ++#include "ubus.h" + + struct wpa_ctrl_dst; + struct radius_server_data; +@@ -103,6 +104,7 @@ struct hostapd_data { + struct hostapd_iface *iface; + struct hostapd_config *iconf; + struct hostapd_bss_config *conf; ++ struct hostapd_ubus_bss ubus; + int interface_added; /* virtual interface added for this BSS */ + unsigned int started:1; + unsigned int disabled:1; +@@ -286,6 +288,8 @@ struct hostapd_iface { + struct hostapd_config *conf; + char phy[16]; /* Name of the PHY (radio) */ + ++ struct hostapd_ubus_iface ubus; ++ + enum hostapd_iface_state { + HAPD_IFACE_UNINITIALIZED, + HAPD_IFACE_DISABLED, +--- /dev/null ++++ b/src/ap/ubus.c +@@ -0,0 +1,511 @@ ++/* ++ * hostapd / ubus support ++ * Copyright (c) 2013, Felix Fietkau ++ * ++ * This software may be distributed under the terms of the BSD license. ++ * See README for more details. ++ */ ++ ++#include "utils/includes.h" ++#include "utils/common.h" ++#include "utils/eloop.h" ++#include "common/ieee802_11_defs.h" ++#include "hostapd.h" ++#include "wps_hostapd.h" ++#include "sta_info.h" ++#include "ubus.h" ++ ++static struct ubus_context *ctx; ++static struct blob_buf b; ++static int ctx_ref; ++ ++static inline struct hostapd_data *get_hapd_from_object(struct ubus_object *obj) ++{ ++ return container_of(obj, struct hostapd_data, ubus.obj); ++} ++ ++ ++struct ubus_banned_client { ++ struct avl_node avl; ++ u8 addr[ETH_ALEN]; ++}; ++ ++static void ubus_receive(int sock, void *eloop_ctx, void *sock_ctx) ++{ ++ struct ubus_context *ctx = eloop_ctx; ++ ubus_handle_event(ctx); ++} ++ ++static void ubus_reconnect_timeout(void *eloop_data, void *user_ctx) ++{ ++ if (ubus_reconnect(ctx, NULL)) { ++ eloop_register_timeout(1, 0, ubus_reconnect_timeout, ctx, NULL); ++ return; ++ } ++ ++ eloop_register_read_sock(ctx->sock.fd, ubus_receive, ctx, NULL); ++} ++ ++static void hostapd_ubus_connection_lost(struct ubus_context *ctx) ++{ ++ eloop_unregister_read_sock(ctx->sock.fd); ++ eloop_register_timeout(1, 0, ubus_reconnect_timeout, ctx, NULL); ++} ++ ++static bool hostapd_ubus_init(void) ++{ ++ if (ctx) ++ return true; ++ ++ ctx = ubus_connect(NULL); ++ if (!ctx) ++ return false; ++ ++ ctx->connection_lost = hostapd_ubus_connection_lost; ++ eloop_register_read_sock(ctx->sock.fd, ubus_receive, ctx, NULL); ++ return true; ++} ++ ++static void hostapd_ubus_ref_inc(void) ++{ ++ ctx_ref++; ++} ++ ++static void hostapd_ubus_ref_dec(void) ++{ ++ ctx_ref--; ++ if (!ctx) ++ return; ++ ++ if (ctx_ref) ++ return; ++ ++ eloop_unregister_read_sock(ctx->sock.fd); ++ ubus_free(ctx); ++ ctx = NULL; ++} ++ ++void hostapd_ubus_add_iface(struct hostapd_iface *iface) ++{ ++ if (!hostapd_ubus_init()) ++ return; ++} ++ ++void hostapd_ubus_free_iface(struct hostapd_iface *iface) ++{ ++ if (!ctx) ++ return; ++} ++ ++static void ++hostapd_bss_del_ban(void *eloop_data, void *user_ctx) ++{ ++ struct ubus_banned_client *ban = eloop_data; ++ struct hostapd_data *hapd = user_ctx; ++ ++ avl_delete(&hapd->ubus.banned, &ban->avl); ++ free(ban); ++} ++ ++static void ++hostapd_bss_ban_client(struct hostapd_data *hapd, u8 *addr, int time) ++{ ++ struct ubus_banned_client *ban; ++ ++ if (time < 0) ++ time = 0; ++ ++ ban = avl_find_element(&hapd->ubus.banned, addr, ban, avl); ++ if (!ban) { ++ if (!time) ++ return; ++ ++ ban = os_zalloc(sizeof(*ban)); ++ memcpy(ban->addr, addr, sizeof(ban->addr)); ++ ban->avl.key = ban->addr; ++ avl_insert(&hapd->ubus.banned, &ban->avl); ++ } else { ++ eloop_cancel_timeout(hostapd_bss_del_ban, ban, hapd); ++ if (!time) { ++ hostapd_bss_del_ban(ban, hapd); ++ return; ++ } ++ } ++ ++ eloop_register_timeout(0, time * 1000, hostapd_bss_del_ban, ban, hapd); ++} ++ ++static int ++hostapd_bss_get_clients(struct ubus_context *ctx, struct ubus_object *obj, ++ struct ubus_request_data *req, const char *method, ++ struct blob_attr *msg) ++{ ++ struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); ++ struct sta_info *sta; ++ void *list, *c; ++ char mac_buf[20]; ++ static const struct { ++ const char *name; ++ uint32_t flag; ++ } sta_flags[] = { ++ { "auth", WLAN_STA_AUTH }, ++ { "assoc", WLAN_STA_ASSOC }, ++ { "authorized", WLAN_STA_AUTHORIZED }, ++ { "preauth", WLAN_STA_PREAUTH }, ++ { "wds", WLAN_STA_WDS }, ++ { "wmm", WLAN_STA_WMM }, ++ { "ht", WLAN_STA_HT }, ++ { "vht", WLAN_STA_VHT }, ++ { "wps", WLAN_STA_WPS }, ++ { "mfp", WLAN_STA_MFP }, ++ }; ++ ++ blob_buf_init(&b, 0); ++ blobmsg_add_u32(&b, "freq", hapd->iface->freq); ++ list = blobmsg_open_table(&b, "clients"); ++ for (sta = hapd->sta_list; sta; sta = sta->next) { ++ int i; ++ ++ sprintf(mac_buf, MACSTR, MAC2STR(sta->addr)); ++ c = blobmsg_open_table(&b, mac_buf); ++ for (i = 0; i < ARRAY_SIZE(sta_flags); i++) ++ blobmsg_add_u8(&b, sta_flags[i].name, ++ !!(sta->flags & sta_flags[i].flag)); ++ blobmsg_add_u32(&b, "aid", sta->aid); ++ blobmsg_close_table(&b, c); ++ } ++ blobmsg_close_array(&b, list); ++ ubus_send_reply(ctx, req, b.head); ++ ++ return 0; ++} ++ ++enum { ++ DEL_CLIENT_ADDR, ++ DEL_CLIENT_REASON, ++ DEL_CLIENT_DEAUTH, ++ DEL_CLIENT_BAN_TIME, ++ __DEL_CLIENT_MAX ++}; ++ ++static const struct blobmsg_policy del_policy[__DEL_CLIENT_MAX] = { ++ [DEL_CLIENT_ADDR] = { "addr", BLOBMSG_TYPE_STRING }, ++ [DEL_CLIENT_REASON] = { "reason", BLOBMSG_TYPE_INT32 }, ++ [DEL_CLIENT_DEAUTH] = { "deauth", BLOBMSG_TYPE_INT8 }, ++ [DEL_CLIENT_BAN_TIME] = { "ban_time", BLOBMSG_TYPE_INT32 }, ++}; ++ ++static int ++hostapd_bss_del_client(struct ubus_context *ctx, struct ubus_object *obj, ++ struct ubus_request_data *req, const char *method, ++ struct blob_attr *msg) ++{ ++ struct blob_attr *tb[__DEL_CLIENT_MAX]; ++ struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); ++ struct sta_info *sta; ++ bool deauth = false; ++ int reason; ++ u8 addr[ETH_ALEN]; ++ ++ blobmsg_parse(del_policy, __DEL_CLIENT_MAX, tb, blob_data(msg), blob_len(msg)); ++ ++ if (!tb[DEL_CLIENT_ADDR]) ++ return UBUS_STATUS_INVALID_ARGUMENT; ++ ++ if (hwaddr_aton(blobmsg_data(tb[DEL_CLIENT_ADDR]), addr)) ++ return UBUS_STATUS_INVALID_ARGUMENT; ++ ++ if (tb[DEL_CLIENT_REASON]) ++ reason = blobmsg_get_u32(tb[DEL_CLIENT_REASON]); ++ ++ if (tb[DEL_CLIENT_DEAUTH]) ++ deauth = blobmsg_get_bool(tb[DEL_CLIENT_DEAUTH]); ++ ++ sta = ap_get_sta(hapd, addr); ++ if (sta) { ++ if (deauth) { ++ hostapd_drv_sta_deauth(hapd, addr, reason); ++ ap_sta_deauthenticate(hapd, sta, reason); ++ } else { ++ hostapd_drv_sta_disassoc(hapd, addr, reason); ++ ap_sta_disassociate(hapd, sta, reason); ++ } ++ } ++ ++ if (tb[DEL_CLIENT_BAN_TIME]) ++ hostapd_bss_ban_client(hapd, addr, blobmsg_get_u32(tb[DEL_CLIENT_BAN_TIME])); ++ ++ return 0; ++} ++ ++static void ++blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const u8 *addr) ++{ ++ char *s; ++ ++ s = blobmsg_alloc_string_buffer(buf, name, 20); ++ sprintf(s, MACSTR, MAC2STR(addr)); ++ blobmsg_add_string_buffer(buf); ++} ++ ++static int ++hostapd_bss_list_bans(struct ubus_context *ctx, struct ubus_object *obj, ++ struct ubus_request_data *req, const char *method, ++ struct blob_attr *msg) ++{ ++ struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); ++ struct ubus_banned_client *ban; ++ void *c; ++ ++ blob_buf_init(&b, 0); ++ c = blobmsg_open_array(&b, "clients"); ++ avl_for_each_element(&hapd->ubus.banned, ban, avl) ++ blobmsg_add_macaddr(&b, NULL, ban->addr); ++ blobmsg_close_array(&b, c); ++ ubus_send_reply(ctx, req, b.head); ++ ++ return 0; ++} ++ ++static int ++hostapd_bss_wps_start(struct ubus_context *ctx, struct ubus_object *obj, ++ struct ubus_request_data *req, const char *method, ++ struct blob_attr *msg) ++{ ++ int rc; ++ struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); ++ ++ rc = hostapd_wps_button_pushed(hapd, NULL); ++ ++ if (rc != 0) ++ return UBUS_STATUS_NOT_SUPPORTED; ++ ++ return 0; ++} ++ ++static int ++hostapd_bss_wps_cancel(struct ubus_context *ctx, struct ubus_object *obj, ++ struct ubus_request_data *req, const char *method, ++ struct blob_attr *msg) ++{ ++ int rc; ++ struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); ++ ++ rc = hostapd_wps_cancel(hapd); ++ ++ if (rc != 0) ++ return UBUS_STATUS_NOT_SUPPORTED; ++ ++ return 0; ++} ++ ++static int ++hostapd_bss_update_beacon(struct ubus_context *ctx, struct ubus_object *obj, ++ struct ubus_request_data *req, const char *method, ++ struct blob_attr *msg) ++{ ++ int rc; ++ struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); ++ ++ rc = ieee802_11_set_beacon(hapd); ++ ++ if (rc != 0) ++ return UBUS_STATUS_NOT_SUPPORTED; ++ ++ return 0; ++} ++ ++enum { ++ CSA_FREQ, ++ CSA_BCN_COUNT, ++ __CSA_MAX ++}; ++ ++static const struct blobmsg_policy csa_policy[__CSA_MAX] = { ++ /* ++ * for now, frequency and beacon count are enough, add more ++ * parameters on demand ++ */ ++ [CSA_FREQ] = { "freq", BLOBMSG_TYPE_INT32 }, ++ [CSA_BCN_COUNT] = { "bcn_count", BLOBMSG_TYPE_INT32 }, ++}; ++ ++#ifdef NEED_AP_MLME ++static int ++hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj, ++ struct ubus_request_data *req, const char *method, ++ struct blob_attr *msg) ++{ ++ struct blob_attr *tb[__CSA_MAX]; ++ struct hostapd_data *hapd = get_hapd_from_object(obj); ++ struct csa_settings css; ++ ++ blobmsg_parse(csa_policy, __CSA_MAX, tb, blob_data(msg), blob_len(msg)); ++ ++ if (!tb[CSA_FREQ]) ++ return UBUS_STATUS_INVALID_ARGUMENT; ++ ++ memset(&css, 0, sizeof(css)); ++ css.freq_params.freq = blobmsg_get_u32(tb[CSA_FREQ]); ++ if (tb[CSA_BCN_COUNT]) ++ css.cs_count = blobmsg_get_u32(tb[CSA_BCN_COUNT]); ++ ++ if (hostapd_switch_channel(hapd, &css) != 0) ++ return UBUS_STATUS_NOT_SUPPORTED; ++ return UBUS_STATUS_OK; ++} ++#endif ++ ++enum { ++ VENDOR_ELEMENTS, ++ __VENDOR_ELEMENTS_MAX ++}; ++ ++static const struct blobmsg_policy ve_policy[__VENDOR_ELEMENTS_MAX] = { ++ /* vendor elements are provided as hex-string */ ++ [VENDOR_ELEMENTS] = { "vendor_elements", BLOBMSG_TYPE_STRING }, ++}; ++ ++static int ++hostapd_vendor_elements(struct ubus_context *ctx, struct ubus_object *obj, ++ struct ubus_request_data *req, const char *method, ++ struct blob_attr *msg) ++{ ++ struct blob_attr *tb[__VENDOR_ELEMENTS_MAX]; ++ struct hostapd_data *hapd = get_hapd_from_object(obj); ++ ++ blobmsg_parse(ve_policy, __VENDOR_ELEMENTS_MAX, tb, ++ blob_data(msg), blob_len(msg)); ++ ++ if (!tb[VENDOR_ELEMENTS]) ++ return UBUS_STATUS_INVALID_ARGUMENT; ++ ++ const char *vendor_elements = blobmsg_data(tb[VENDOR_ELEMENTS]); ++ if (hostapd_set_iface(hapd->iconf, hapd->conf, "vendor_elements", ++ vendor_elements) != 0) ++ return UBUS_STATUS_NOT_SUPPORTED; ++ ++ /* update beacons if vendor elements were set successfully */ ++ if (ieee802_11_update_beacons(hapd->iface) != 0) ++ return UBUS_STATUS_NOT_SUPPORTED; ++ return UBUS_STATUS_OK; ++} ++ ++static const struct ubus_method bss_methods[] = { ++ UBUS_METHOD_NOARG("get_clients", hostapd_bss_get_clients), ++ UBUS_METHOD("del_client", hostapd_bss_del_client, del_policy), ++ UBUS_METHOD_NOARG("list_bans", hostapd_bss_list_bans), ++ UBUS_METHOD_NOARG("wps_start", hostapd_bss_wps_start), ++ UBUS_METHOD_NOARG("wps_cancel", hostapd_bss_wps_cancel), ++ UBUS_METHOD_NOARG("update_beacon", hostapd_bss_update_beacon), ++#ifdef NEED_AP_MLME ++ UBUS_METHOD("switch_chan", hostapd_switch_chan, csa_policy), ++#endif ++ UBUS_METHOD("set_vendor_elements", hostapd_vendor_elements, ve_policy), ++}; ++ ++static struct ubus_object_type bss_object_type = ++ UBUS_OBJECT_TYPE("hostapd_bss", bss_methods); ++ ++static int avl_compare_macaddr(const void *k1, const void *k2, void *ptr) ++{ ++ return memcmp(k1, k2, ETH_ALEN); ++} ++ ++void hostapd_ubus_add_bss(struct hostapd_data *hapd) ++{ ++ struct ubus_object *obj = &hapd->ubus.obj; ++ char *name; ++ int ret; ++ ++ if (!hostapd_ubus_init()) ++ return; ++ ++ if (asprintf(&name, "hostapd.%s", hapd->conf->iface) < 0) ++ return; ++ ++ avl_init(&hapd->ubus.banned, avl_compare_macaddr, false, NULL); ++ obj->name = name; ++ obj->type = &bss_object_type; ++ obj->methods = bss_object_type.methods; ++ obj->n_methods = bss_object_type.n_methods; ++ ret = ubus_add_object(ctx, obj); ++ hostapd_ubus_ref_inc(); ++} ++ ++void hostapd_ubus_free_bss(struct hostapd_data *hapd) ++{ ++ struct ubus_object *obj = &hapd->ubus.obj; ++ char *name = (char *) obj->name; ++ ++ if (!ctx) ++ return; ++ ++ if (obj->id) { ++ ubus_remove_object(ctx, obj); ++ hostapd_ubus_ref_dec(); ++ } ++ ++ free(name); ++} ++ ++struct ubus_event_req { ++ struct ubus_notify_request nreq; ++ bool deny; ++}; ++ ++static void ++ubus_event_cb(struct ubus_notify_request *req, int idx, int ret) ++{ ++ struct ubus_event_req *ureq = container_of(req, struct ubus_event_req, nreq); ++ ++ if (ret) ++ ureq->deny = true; ++} ++ ++int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req) ++{ ++ struct ubus_banned_client *ban; ++ const char *types[HOSTAPD_UBUS_TYPE_MAX] = { ++ [HOSTAPD_UBUS_PROBE_REQ] = "probe", ++ [HOSTAPD_UBUS_AUTH_REQ] = "auth", ++ [HOSTAPD_UBUS_ASSOC_REQ] = "assoc", ++ }; ++ const char *type = "mgmt"; ++ struct ubus_event_req ureq = {}; ++ const u8 *addr; ++ ++ if (req->mgmt_frame) ++ addr = req->mgmt_frame->sa; ++ else ++ addr = req->addr; ++ ++ ban = avl_find_element(&hapd->ubus.banned, addr, ban, avl); ++ if (ban) ++ return -2; ++ ++ if (!hapd->ubus.obj.has_subscribers) ++ return 0; ++ ++ if (req->type < ARRAY_SIZE(types)) ++ type = types[req->type]; ++ ++ blob_buf_init(&b, 0); ++ blobmsg_add_macaddr(&b, "address", addr); ++ if (req->mgmt_frame) ++ blobmsg_add_macaddr(&b, "target", req->mgmt_frame->da); ++ if (req->frame_info) ++ blobmsg_add_u32(&b, "signal", req->frame_info->ssi_signal); ++ blobmsg_add_u32(&b, "freq", hapd->iface->freq); ++ ++ if (ubus_notify_async(ctx, &hapd->ubus.obj, type, b.head, &ureq.nreq)) ++ return 0; ++ ++ ureq.nreq.status_cb = ubus_event_cb; ++ ubus_complete_request(ctx, &ureq.nreq.req, 100); ++ ++ if (ureq.deny) ++ return -1; ++ ++ return 0; ++} +--- /dev/null ++++ b/src/ap/ubus.h +@@ -0,0 +1,78 @@ ++/* ++ * hostapd / ubus support ++ * Copyright (c) 2013, Felix Fietkau ++ * ++ * This software may be distributed under the terms of the BSD license. ++ * See README for more details. ++ */ ++#ifndef __HOSTAPD_UBUS_H ++#define __HOSTAPD_UBUS_H ++ ++enum hostapd_ubus_event_type { ++ HOSTAPD_UBUS_PROBE_REQ, ++ HOSTAPD_UBUS_AUTH_REQ, ++ HOSTAPD_UBUS_ASSOC_REQ, ++ HOSTAPD_UBUS_TYPE_MAX ++}; ++ ++struct hostapd_ubus_request { ++ enum hostapd_ubus_event_type type; ++ const struct ieee80211_mgmt *mgmt_frame; ++ const struct hostapd_frame_info *frame_info; ++ const u8 *addr; ++}; ++ ++struct hostapd_iface; ++struct hostapd_data; ++ ++#ifdef UBUS_SUPPORT ++ ++#include ++#include ++ ++struct hostapd_ubus_iface { ++ struct ubus_object obj; ++}; ++ ++struct hostapd_ubus_bss { ++ struct ubus_object obj; ++ struct avl_tree banned; ++}; ++ ++void hostapd_ubus_add_iface(struct hostapd_iface *iface); ++void hostapd_ubus_free_iface(struct hostapd_iface *iface); ++void hostapd_ubus_add_bss(struct hostapd_data *hapd); ++void hostapd_ubus_free_bss(struct hostapd_data *hapd); ++ ++int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req); ++ ++#else ++ ++struct hostapd_ubus_iface {}; ++ ++struct hostapd_ubus_bss {}; ++ ++static inline void hostapd_ubus_add_iface(struct hostapd_iface *iface) ++{ ++} ++ ++static inline void hostapd_ubus_free_iface(struct hostapd_iface *iface) ++{ ++} ++ ++static inline void hostapd_ubus_add_bss(struct hostapd_data *hapd) ++{ ++} ++ ++static inline void hostapd_ubus_free_bss(struct hostapd_data *hapd) ++{ ++} ++ ++static inline int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req) ++{ ++ return 0; ++} ++ ++#endif ++ ++#endif +--- a/src/ap/hostapd.c ++++ b/src/ap/hostapd.c +@@ -277,6 +277,7 @@ static void hostapd_free_hapd_data(struc + hapd->started = 0; + + wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface); ++ hostapd_ubus_free_bss(hapd); + iapp_deinit(hapd->iapp); + hapd->iapp = NULL; + accounting_deinit(hapd); +@@ -1098,6 +1099,8 @@ static int hostapd_setup_bss(struct host + if (hapd->driver && hapd->driver->set_operstate) + hapd->driver->set_operstate(hapd->drv_priv, 1); + ++ hostapd_ubus_add_bss(hapd); ++ + return 0; + } + +@@ -1384,6 +1387,7 @@ int hostapd_setup_interface_complete(str + if (err) + goto fail; + ++ hostapd_ubus_add_iface(iface); + wpa_printf(MSG_DEBUG, "Completing interface initialization"); + if (iface->conf->channel) { + #ifdef NEED_AP_MLME +@@ -1544,6 +1548,7 @@ dfs_offload: + + fail: + wpa_printf(MSG_ERROR, "Interface initialization failed"); ++ hostapd_ubus_free_iface(iface); + hostapd_set_state(iface, HAPD_IFACE_DISABLED); + wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); + if (iface->interfaces && iface->interfaces->terminate_on_error) +@@ -1873,6 +1878,7 @@ void hostapd_interface_deinit_free(struc + (unsigned int) iface->conf->num_bss); + driver = iface->bss[0]->driver; + drv_priv = iface->bss[0]->drv_priv; ++ hostapd_ubus_free_iface(iface); + hostapd_interface_deinit(iface); + wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit", + __func__, driver, drv_priv); +--- a/src/ap/ieee802_11.c ++++ b/src/ap/ieee802_11.c +@@ -881,7 +881,8 @@ int auth_sae_init_committed(struct hosta + + + static void handle_auth(struct hostapd_data *hapd, +- const struct ieee80211_mgmt *mgmt, size_t len) ++ const struct ieee80211_mgmt *mgmt, size_t len, ++ struct hostapd_frame_info *fi) + { + u16 auth_alg, auth_transaction, status_code; + u16 resp = WLAN_STATUS_SUCCESS; +@@ -897,6 +898,11 @@ static void handle_auth(struct hostapd_d + char *identity = NULL; + char *radius_cui = NULL; + u16 seq_ctrl; ++ struct hostapd_ubus_request req = { ++ .type = HOSTAPD_UBUS_AUTH_REQ, ++ .mgmt_frame = mgmt, ++ .frame_info = fi, ++ }; + + if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) { + wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)", +@@ -983,6 +989,14 @@ static void handle_auth(struct hostapd_d + resp = WLAN_STATUS_UNSPECIFIED_FAILURE; + goto fail; + } ++ ++ if (hostapd_ubus_handle_event(hapd, &req)) { ++ wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n", ++ MAC2STR(mgmt->sa)); ++ resp = WLAN_STATUS_UNSPECIFIED_FAILURE; ++ goto fail; ++ } ++ + if (res == HOSTAPD_ACL_PENDING) { + wpa_printf(MSG_DEBUG, "Authentication frame from " MACSTR + " waiting for an external authentication", +@@ -1694,13 +1708,18 @@ static void send_assoc_resp(struct hosta + + static void handle_assoc(struct hostapd_data *hapd, + const struct ieee80211_mgmt *mgmt, size_t len, +- int reassoc) ++ int reassoc, struct hostapd_frame_info *fi) + { + u16 capab_info, listen_interval, seq_ctrl, fc; + u16 resp = WLAN_STATUS_SUCCESS; + const u8 *pos; + int left, i; + struct sta_info *sta; ++ struct hostapd_ubus_request req = { ++ .type = HOSTAPD_UBUS_ASSOC_REQ, ++ .mgmt_frame = mgmt, ++ .frame_info = fi, ++ }; + + if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) : + sizeof(mgmt->u.assoc_req))) { +@@ -1820,6 +1839,13 @@ static void handle_assoc(struct hostapd_ + goto fail; + } + ++ if (hostapd_ubus_handle_event(hapd, &req)) { ++ wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", ++ MAC2STR(mgmt->sa)); ++ resp = WLAN_STATUS_UNSPECIFIED_FAILURE; ++ goto fail; ++ } ++ + sta->capability = capab_info; + sta->listen_interval = listen_interval; + +@@ -2236,7 +2262,7 @@ int ieee802_11_mgmt(struct hostapd_data + + + if (stype == WLAN_FC_STYPE_PROBE_REQ) { +- handle_probe_req(hapd, mgmt, len, fi->ssi_signal); ++ handle_probe_req(hapd, mgmt, len, fi); + return 1; + } + +@@ -2251,17 +2277,17 @@ int ieee802_11_mgmt(struct hostapd_data + switch (stype) { + case WLAN_FC_STYPE_AUTH: + wpa_printf(MSG_DEBUG, "mgmt::auth"); +- handle_auth(hapd, mgmt, len); ++ handle_auth(hapd, mgmt, len, fi); + ret = 1; + break; + case WLAN_FC_STYPE_ASSOC_REQ: + wpa_printf(MSG_DEBUG, "mgmt::assoc_req"); +- handle_assoc(hapd, mgmt, len, 0); ++ handle_assoc(hapd, mgmt, len, 0, fi); + ret = 1; + break; + case WLAN_FC_STYPE_REASSOC_REQ: + wpa_printf(MSG_DEBUG, "mgmt::reassoc_req"); +- handle_assoc(hapd, mgmt, len, 1); ++ handle_assoc(hapd, mgmt, len, 1, fi); + ret = 1; + break; + case WLAN_FC_STYPE_DISASSOC: +--- a/src/ap/beacon.c ++++ b/src/ap/beacon.c +@@ -542,7 +542,7 @@ static enum ssid_match_result ssid_match + + void handle_probe_req(struct hostapd_data *hapd, + const struct ieee80211_mgmt *mgmt, size_t len, +- int ssi_signal) ++ struct hostapd_frame_info *fi) + { + u8 *resp; + struct ieee802_11_elems elems; +@@ -550,8 +550,14 @@ void handle_probe_req(struct hostapd_dat + size_t ie_len; + struct sta_info *sta = NULL; + size_t i, resp_len; ++ int ssi_signal = fi->ssi_signal; + int noack; + enum ssid_match_result res; ++ struct hostapd_ubus_request req = { ++ .type = HOSTAPD_UBUS_PROBE_REQ, ++ .mgmt_frame = mgmt, ++ .frame_info = fi, ++ }; + + ie = mgmt->u.probe_req.variable; + if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req)) +@@ -710,6 +716,12 @@ void handle_probe_req(struct hostapd_dat + } + #endif /* CONFIG_P2P */ + ++ if (hostapd_ubus_handle_event(hapd, &req)) { ++ wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n", ++ MAC2STR(mgmt->sa)); ++ return; ++ } ++ + /* TODO: verify that supp_rates contains at least one matching rate + * with AP configuration */ + +--- a/src/ap/beacon.h ++++ b/src/ap/beacon.h +@@ -14,7 +14,7 @@ struct ieee80211_mgmt; + + void handle_probe_req(struct hostapd_data *hapd, + const struct ieee80211_mgmt *mgmt, size_t len, +- int ssi_signal); ++ struct hostapd_frame_info *fi); + int ieee802_11_set_beacon(struct hostapd_data *hapd); + int ieee802_11_set_beacons(struct hostapd_iface *iface); + int ieee802_11_update_beacons(struct hostapd_iface *iface); +--- a/src/ap/drv_callbacks.c ++++ b/src/ap/drv_callbacks.c +@@ -49,6 +49,10 @@ int hostapd_notif_assoc(struct hostapd_d + u16 reason = WLAN_REASON_UNSPECIFIED; + u16 status = WLAN_STATUS_SUCCESS; + const u8 *p2p_dev_addr = NULL; ++ struct hostapd_ubus_request req = { ++ .type = HOSTAPD_UBUS_ASSOC_REQ, ++ .addr = addr, ++ }; + + if (addr == NULL) { + /* +@@ -113,6 +117,12 @@ int hostapd_notif_assoc(struct hostapd_d + } + sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2); + ++ if (hostapd_ubus_handle_event(hapd, &req)) { ++ wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n", ++ MAC2STR(req.addr)); ++ goto fail; ++ } ++ + #ifdef CONFIG_P2P + if (elems.p2p) { + wpabuf_free(sta->p2p_ie); -- cgit v1.2.3