0c82d84d6baac31f8aac37e29476e0db289ec5e2
[librecmc/librecmc.git] /
1 From 9a8ca54a264a2820af614043e7af853166b320b0 Mon Sep 17 00:00:00 2001
2 From: Peter Oh <peter.oh@bowerswilkins.com>
3 Date: Tue, 29 May 2018 14:39:14 -0700
4 Subject: [PATCH 10/18] mesh: consider mesh interface on dfs event handler
5
6 Once mesh starts supporting DFS channels, it has to handle DFS related events
7 from drivers, hence add mesh interface to the check list.
8
9 Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
10 Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
11 ---
12  wpa_supplicant/ap.c     | 71 ++++++++++++++++++++++++++++++-----------
13  wpa_supplicant/events.c |  7 ++--
14  2 files changed, 57 insertions(+), 21 deletions(-)
15
16 --- a/wpa_supplicant/ap.c
17 +++ b/wpa_supplicant/ap.c
18 @@ -1379,13 +1379,18 @@ int ap_ctrl_iface_chanswitch(struct wpa_
19  void wpas_ap_ch_switch(struct wpa_supplicant *wpa_s, int freq, int ht,
20                        int offset, int width, int cf1, int cf2)
21  {
22 -       if (!wpa_s->ap_iface)
23 -               return;
24 +       struct hostapd_iface *iface = wpa_s->ap_iface;
25  
26 +       if (!wpa_s->ap_iface) {
27 +               if (!wpa_s->ifmsh)
28 +                       return;
29 +               else
30 +                       iface = wpa_s->ifmsh;
31 +       }
32         wpa_s->assoc_freq = freq;
33         if (wpa_s->current_ssid)
34                 wpa_s->current_ssid->frequency = freq;
35 -       hostapd_event_ch_switch(wpa_s->ap_iface->bss[0], freq, ht,
36 +       hostapd_event_ch_switch(iface->bss[0], freq, ht,
37                                 offset, width, cf1, cf2);
38  }
39  
40 @@ -1582,10 +1587,16 @@ int wpas_ap_pmksa_cache_add_external(str
41  void wpas_ap_event_dfs_radar_detected(struct wpa_supplicant *wpa_s,
42                                       struct dfs_event *radar)
43  {
44 -       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
45 -               return;
46 +       struct hostapd_iface *iface = wpa_s->ap_iface;
47 +
48 +       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
49 +               if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
50 +                       return;
51 +               else
52 +                       iface = wpa_s->ifmsh;
53 +       }
54         wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq);
55 -       hostapd_dfs_radar_detected(wpa_s->ap_iface, radar->freq,
56 +       hostapd_dfs_radar_detected(iface, radar->freq,
57                                    radar->ht_enabled, radar->chan_offset,
58                                    radar->chan_width,
59                                    radar->cf1, radar->cf2);
60 @@ -1595,10 +1606,16 @@ void wpas_ap_event_dfs_radar_detected(st
61  void wpas_ap_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
62                                    struct dfs_event *radar)
63  {
64 -       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
65 -               return;
66 +       struct hostapd_iface *iface = wpa_s->ap_iface;
67 +
68 +       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
69 +               if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
70 +                       return;
71 +               else
72 +                       iface = wpa_s->ifmsh;
73 +       }
74         wpa_printf(MSG_DEBUG, "DFS CAC started on %d MHz", radar->freq);
75 -       hostapd_dfs_start_cac(wpa_s->ap_iface, radar->freq,
76 +       hostapd_dfs_start_cac(iface, radar->freq,
77                               radar->ht_enabled, radar->chan_offset,
78                               radar->chan_width, radar->cf1, radar->cf2);
79  }
80 @@ -1607,10 +1624,16 @@ void wpas_ap_event_dfs_cac_started(struc
81  void wpas_ap_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
82                                     struct dfs_event *radar)
83  {
84 -       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
85 -               return;
86 +       struct hostapd_iface *iface = wpa_s->ap_iface;
87 +
88 +       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
89 +               if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
90 +                       return;
91 +               else
92 +                       iface = wpa_s->ifmsh;
93 +       }
94         wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq);
95 -       hostapd_dfs_complete_cac(wpa_s->ap_iface, 1, radar->freq,
96 +       hostapd_dfs_complete_cac(iface, 1, radar->freq,
97                                  radar->ht_enabled, radar->chan_offset,
98                                  radar->chan_width, radar->cf1, radar->cf2);
99  }
100 @@ -1619,10 +1642,16 @@ void wpas_ap_event_dfs_cac_finished(stru
101  void wpas_ap_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
102                                    struct dfs_event *radar)
103  {
104 -       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
105 -               return;
106 +       struct hostapd_iface *iface = wpa_s->ap_iface;
107 +
108 +       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
109 +               if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
110 +                       return;
111 +               else
112 +                       iface = wpa_s->ifmsh;
113 +       }
114         wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq);
115 -       hostapd_dfs_complete_cac(wpa_s->ap_iface, 0, radar->freq,
116 +       hostapd_dfs_complete_cac(iface, 0, radar->freq,
117                                  radar->ht_enabled, radar->chan_offset,
118                                  radar->chan_width, radar->cf1, radar->cf2);
119  }
120 @@ -1631,10 +1660,16 @@ void wpas_ap_event_dfs_cac_aborted(struc
121  void wpas_ap_event_dfs_cac_nop_finished(struct wpa_supplicant *wpa_s,
122                                         struct dfs_event *radar)
123  {
124 -       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0])
125 -               return;
126 +       struct hostapd_iface *iface = wpa_s->ap_iface;
127 +
128 +       if (!wpa_s->ap_iface || !wpa_s->ap_iface->bss[0]) {
129 +               if (!wpa_s->ifmsh || !wpa_s->ifmsh->bss[0])
130 +                       return;
131 +               else
132 +                       iface = wpa_s->ifmsh;
133 +       }
134         wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq);
135 -       hostapd_dfs_nop_finished(wpa_s->ap_iface, radar->freq,
136 +       hostapd_dfs_nop_finished(iface, radar->freq,
137                                  radar->ht_enabled, radar->chan_offset,
138                                  radar->chan_width, radar->cf1, radar->cf2);
139  }
140 --- a/wpa_supplicant/events.c
141 +++ b/wpa_supplicant/events.c
142 @@ -3840,7 +3840,7 @@ static void wpas_event_dfs_cac_started(s
143                                        struct dfs_event *radar)
144  {
145  #if defined(NEED_AP_MLME) && defined(CONFIG_AP)
146 -       if (wpa_s->ap_iface) {
147 +       if (wpa_s->ap_iface || wpa_s->ifmsh) {
148                 wpas_ap_event_dfs_cac_started(wpa_s, radar);
149         } else
150  #endif /* NEED_AP_MLME && CONFIG_AP */
151 @@ -3861,7 +3861,7 @@ static void wpas_event_dfs_cac_finished(
152                                         struct dfs_event *radar)
153  {
154  #if defined(NEED_AP_MLME) && defined(CONFIG_AP)
155 -       if (wpa_s->ap_iface) {
156 +       if (wpa_s->ap_iface || wpa_s->ifmsh) {
157                 wpas_ap_event_dfs_cac_finished(wpa_s, radar);
158         } else
159  #endif /* NEED_AP_MLME && CONFIG_AP */
160 @@ -3877,7 +3877,7 @@ static void wpas_event_dfs_cac_aborted(s
161                                        struct dfs_event *radar)
162  {
163  #if defined(NEED_AP_MLME) && defined(CONFIG_AP)
164 -       if (wpa_s->ap_iface) {
165 +       if (wpa_s->ap_iface || wpa_s->ifmsh) {
166                 wpas_ap_event_dfs_cac_aborted(wpa_s, radar);
167         } else
168  #endif /* NEED_AP_MLME && CONFIG_AP */
169 @@ -4328,6 +4328,7 @@ void wpa_supplicant_event(void *ctx, enu
170  #ifdef CONFIG_AP
171                 if (wpa_s->current_ssid->mode == WPAS_MODE_AP ||
172                     wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO ||
173 +                   wpa_s->current_ssid->mode == WPAS_MODE_MESH ||
174                     wpa_s->current_ssid->mode ==
175                     WPAS_MODE_P2P_GROUP_FORMATION) {
176                         wpas_ap_ch_switch(wpa_s, data->ch_switch.freq,