hostapd: update to git HEAD of 2018-05-21, allow build against wolfssl
[openwrt/openwrt.git] / package / network / services / hostapd / patches / 360-ctrl_iface_reload.patch
1 --- a/hostapd/ctrl_iface.c
2 +++ b/hostapd/ctrl_iface.c
3 @@ -60,6 +60,7 @@
4 #include "fst/fst_ctrl_iface.h"
5 #include "config_file.h"
6 #include "ctrl_iface.h"
7 +#include "config_file.h"
8
9
10 #define HOSTAPD_CLI_DUP_VALUE_MAX_LEN 256
11 @@ -78,6 +79,7 @@ static void hostapd_ctrl_iface_send(stru
12 enum wpa_msg_type type,
13 const char *buf, size_t len);
14
15 +static char *reload_opts = NULL;
16
17 static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd,
18 struct sockaddr_storage *from,
19 @@ -129,6 +131,61 @@ static int hostapd_ctrl_iface_new_sta(st
20 return 0;
21 }
22
23 +static char *get_option(char *opt, char *str)
24 +{
25 + int len = strlen(str);
26 +
27 + if (!strncmp(opt, str, len))
28 + return opt + len;
29 + else
30 + return NULL;
31 +}
32 +
33 +static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
34 +{
35 + struct hostapd_config *conf;
36 + char *opt, *val;
37 +
38 + conf = hostapd_config_read(fname);
39 + if (!conf)
40 + return NULL;
41 +
42 + for (opt = strtok(reload_opts, " ");
43 + opt;
44 + opt = strtok(NULL, " ")) {
45 +
46 + if ((val = get_option(opt, "channel=")))
47 + conf->channel = atoi(val);
48 + else if ((val = get_option(opt, "ht_capab=")))
49 + conf->ht_capab = atoi(val);
50 + else if ((val = get_option(opt, "ht_capab_mask=")))
51 + conf->ht_capab &= atoi(val);
52 + else if ((val = get_option(opt, "sec_chan=")))
53 + conf->secondary_channel = atoi(val);
54 + else if ((val = get_option(opt, "hw_mode=")))
55 + conf->hw_mode = atoi(val);
56 + else if ((val = get_option(opt, "ieee80211n=")))
57 + conf->ieee80211n = atoi(val);
58 + else
59 + break;
60 + }
61 +
62 + return conf;
63 +}
64 +
65 +static int hostapd_ctrl_iface_update(struct hostapd_data *hapd, char *txt)
66 +{
67 + struct hostapd_config * (*config_read_cb)(const char *config_fname);
68 + struct hostapd_iface *iface = hapd->iface;
69 +
70 + config_read_cb = iface->interfaces->config_read_cb;
71 + iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
72 + reload_opts = txt;
73 +
74 + hostapd_reload_config(iface);
75 +
76 + iface->interfaces->config_read_cb = config_read_cb;
77 +}
78
79 #ifdef CONFIG_IEEE80211W
80 #ifdef NEED_AP_MLME
81 @@ -3031,6 +3088,8 @@ static int hostapd_ctrl_iface_receive_pr
82 } else if (os_strncmp(buf, "VENDOR ", 7) == 0) {
83 reply_len = hostapd_ctrl_iface_vendor(hapd, buf + 7, reply,
84 reply_size);
85 + } else if (os_strncmp(buf, "UPDATE ", 7) == 0) {
86 + hostapd_ctrl_iface_update(hapd, buf + 7);
87 } else if (os_strcmp(buf, "ERP_FLUSH") == 0) {
88 ieee802_1x_erp_flush(hapd);
89 #ifdef RADIUS_SERVER
90 --- a/src/ap/ctrl_iface_ap.c
91 +++ b/src/ap/ctrl_iface_ap.c
92 @@ -864,7 +864,13 @@ int hostapd_parse_csa_settings(const cha
93
94 int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd)
95 {
96 - return hostapd_drv_stop_ap(hapd);
97 + struct hostapd_iface *iface = hapd->iface;
98 + int i;
99 +
100 + for (i = 0; i < iface->num_bss; i++)
101 + hostapd_drv_stop_ap(iface->bss[i]);
102 +
103 + return 0;
104 }
105
106