hostapd: fix compile of -mini variants
[oweals/openwrt.git] / package / network / services / hostapd / patches / 0101-mesh-factor-out-mesh-join-function.patch
1 From 91c0f3f6a9ecae3c9106bef8a8606fab0792dd28 Mon Sep 17 00:00:00 2001
2 From: Peter Oh <peter.oh@bowerswilkins.com>
3 Date: Thu, 12 Apr 2018 02:48:58 -0700
4 Subject: [PATCH 01/15] mesh: factor out mesh join function
5
6 mesh join function consitss of 2 parts which are preparing
7 configurations and sending join event to driver.
8 Since physical mesh join event could happen either right
9 after mesh configuration is done or after CAC is done
10 in case of DFS channel is used, factor out the function
11 into 2 parts to reduce redundant calls.
12
13 Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
14 ---
15  wpa_supplicant/mesh.c             | 120 ++++++++++++++++--------------
16  wpa_supplicant/mesh.h             |   1 +
17  wpa_supplicant/wpa_supplicant_i.h |   1 +
18  3 files changed, 68 insertions(+), 54 deletions(-)
19
20 --- a/wpa_supplicant/mesh.c
21 +++ b/wpa_supplicant/mesh.c
22 @@ -25,6 +25,7 @@
23  #include "mesh_mpm.h"
24  #include "mesh_rsn.h"
25  #include "mesh.h"
26 +#include "drivers/driver_nl80211.h"
27  
28  
29  static void wpa_supplicant_mesh_deinit(struct wpa_supplicant *wpa_s)
30 @@ -359,13 +360,48 @@ void wpa_supplicant_mesh_add_scan_ie(str
31  }
32  
33  
34 +void wpas_join_mesh(struct wpa_supplicant *wpa_s)
35 +{
36 +       struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
37 +       struct wpa_ssid *ssid = wpa_s->current_ssid;
38 +       int ret = 0;
39 +
40 +       if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
41 +               wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
42 +               wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
43 +               wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
44 +       }
45 +
46 +       if (wpa_s->ifmsh) {
47 +               params->ies = wpa_s->ifmsh->mconf->rsn_ie;
48 +               params->ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
49 +               params->basic_rates = wpa_s->ifmsh->basic_rates;
50 +               params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
51 +               params->conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
52 +       }
53 +
54 +       ret = wpa_drv_join_mesh(wpa_s, params);
55 +       if (ret)
56 +               wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d\n", ret);
57 +
58 +       /* hostapd sets the interface down until we associate */
59 +       wpa_drv_set_operstate(wpa_s, 1);
60 +
61 +       if (!ret)
62 +               wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
63 +
64 +       return;
65 +}
66 +
67 +
68  int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
69                              struct wpa_ssid *ssid)
70  {
71 -       struct wpa_driver_mesh_join_params params;
72 +       struct wpa_driver_mesh_join_params *params =
73 +               os_zalloc(sizeof(struct wpa_driver_mesh_join_params));
74         int ret = 0;
75  
76 -       if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency) {
77 +       if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency || !params) {
78                 ret = -ENOENT;
79                 goto out;
80         }
81 @@ -376,22 +412,22 @@ int wpa_supplicant_join_mesh(struct wpa_
82         wpa_s->group_cipher = WPA_CIPHER_NONE;
83         wpa_s->mgmt_group_cipher = 0;
84  
85 -       os_memset(&params, 0, sizeof(params));
86 -       params.meshid = ssid->ssid;
87 -       params.meshid_len = ssid->ssid_len;
88 -       ibss_mesh_setup_freq(wpa_s, ssid, &params.freq);
89 -       wpa_s->mesh_ht_enabled = !!params.freq.ht_enabled;
90 -       wpa_s->mesh_vht_enabled = !!params.freq.vht_enabled;
91 -       if (params.freq.ht_enabled && params.freq.sec_channel_offset)
92 -               ssid->ht40 = params.freq.sec_channel_offset;
93 +       params->meshid = ssid->ssid;
94 +       params->meshid_len = ssid->ssid_len;
95 +       ibss_mesh_setup_freq(wpa_s, ssid, &params->freq);
96 +       wpa_s->mesh_ht_enabled = !!params->freq.ht_enabled;
97 +       wpa_s->mesh_vht_enabled = !!params->freq.vht_enabled;
98 +       if (params->freq.ht_enabled && params->freq.sec_channel_offset)
99 +               ssid->ht40 = params->freq.sec_channel_offset;
100 +
101         if (wpa_s->mesh_vht_enabled) {
102                 ssid->vht = 1;
103 -               switch (params.freq.bandwidth) {
104 +               switch (params->freq.bandwidth) {
105                 case 80:
106 -                       if (params.freq.center_freq2) {
107 +                       if (params->freq.center_freq2) {
108                                 ssid->max_oper_chwidth = VHT_CHANWIDTH_80P80MHZ;
109                                 ssid->vht_center_freq2 =
110 -                                       params.freq.center_freq2;
111 +                                       params->freq.center_freq2;
112                         } else {
113                                 ssid->max_oper_chwidth = VHT_CHANWIDTH_80MHZ;
114                         }
115 @@ -405,67 +441,43 @@ int wpa_supplicant_join_mesh(struct wpa_
116                 }
117         }
118         if (ssid->beacon_int > 0)
119 -               params.beacon_int = ssid->beacon_int;
120 +               params->beacon_int = ssid->beacon_int;
121         else if (wpa_s->conf->beacon_int > 0)
122 -               params.beacon_int = wpa_s->conf->beacon_int;
123 +               params->beacon_int = wpa_s->conf->beacon_int;
124         if (ssid->dtim_period > 0)
125 -               params.dtim_period = ssid->dtim_period;
126 +               params->dtim_period = ssid->dtim_period;
127         else if (wpa_s->conf->dtim_period > 0)
128 -               params.dtim_period = wpa_s->conf->dtim_period;
129 -       params.conf.max_peer_links = wpa_s->conf->max_peer_links;
130 +               params->dtim_period = wpa_s->conf->dtim_period;
131 +       params->conf.max_peer_links = wpa_s->conf->max_peer_links;
132         if (ssid->mesh_rssi_threshold < DEFAULT_MESH_RSSI_THRESHOLD) {
133 -               params.conf.rssi_threshold = ssid->mesh_rssi_threshold;
134 -               params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
135 +               params->conf.rssi_threshold = ssid->mesh_rssi_threshold;
136 +               params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
137         }
138  
139         if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
140 -               params.flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
141 -               params.flags |= WPA_DRIVER_MESH_FLAG_AMPE;
142 +               params->flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
143 +               params->flags |= WPA_DRIVER_MESH_FLAG_AMPE;
144                 wpa_s->conf->user_mpm = 1;
145         }
146  
147         if (wpa_s->conf->user_mpm) {
148 -               params.flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
149 -               params.conf.auto_plinks = 0;
150 +               params->flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
151 +               params->conf.auto_plinks = 0;
152         } else {
153 -               params.flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
154 -               params.conf.auto_plinks = 1;
155 +               params->flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
156 +               params->conf.auto_plinks = 1;
157         }
158 -       params.conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
159 +       params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
160  
161 -       if (wpa_supplicant_mesh_init(wpa_s, ssid, &params.freq)) {
162 +       wpa_s->mesh_params = params;
163 +       if (wpa_supplicant_mesh_init(wpa_s, ssid, &params->freq)) {
164                 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
165                 wpa_drv_leave_mesh(wpa_s);
166                 ret = -1;
167                 goto out;
168         }
169  
170 -       if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
171 -               wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
172 -               wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
173 -               wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
174 -       }
175 -
176 -       if (wpa_s->ifmsh) {
177 -               params.ies = wpa_s->ifmsh->mconf->rsn_ie;
178 -               params.ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
179 -               params.basic_rates = wpa_s->ifmsh->basic_rates;
180 -               params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
181 -               params.conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
182 -       }
183 -
184 -       wpa_msg(wpa_s, MSG_INFO, "joining mesh %s",
185 -               wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
186 -       ret = wpa_drv_join_mesh(wpa_s, &params);
187 -       if (ret)
188 -               wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret);
189 -
190 -       /* hostapd sets the interface down until we associate */
191 -       wpa_drv_set_operstate(wpa_s, 1);
192 -
193 -       if (!ret)
194 -               wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
195 -
196 +       wpas_join_mesh(wpa_s);
197  out:
198         return ret;
199  }
200 --- a/wpa_supplicant/mesh.h
201 +++ b/wpa_supplicant/mesh.h
202 @@ -21,6 +21,7 @@ int wpas_mesh_add_interface(struct wpa_s
203  int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr);
204  int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
205                        int duration);
206 +void wpas_join_mesh(struct wpa_supplicant *wpa_s);
207  
208  #ifdef CONFIG_MESH
209  
210 --- a/wpa_supplicant/wpa_supplicant_i.h
211 +++ b/wpa_supplicant/wpa_supplicant_i.h
212 @@ -810,6 +810,7 @@ struct wpa_supplicant {
213         unsigned int mesh_if_created:1;
214         unsigned int mesh_ht_enabled:1;
215         unsigned int mesh_vht_enabled:1;
216 +       struct wpa_driver_mesh_join_params *mesh_params;
217  #ifdef CONFIG_PMKSA_CACHE_EXTERNAL
218         /* struct external_pmksa_cache::list */
219         struct dl_list mesh_external_pmksa_cache;