Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * hostapd / Hardware feature query and different modes |
| 3 | * Copyright 2002-2003, Instant802 Networks, Inc. |
| 4 | * Copyright 2005-2006, Devicescape Software, Inc. |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 5 | * Copyright (c) 2008-2012, Jouni Malinen <j@w1.fi> |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 6 | * |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 7 | * This software may be distributed under the terms of the BSD license. |
| 8 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include "utils/includes.h" |
| 12 | |
| 13 | #include "utils/common.h" |
| 14 | #include "utils/eloop.h" |
| 15 | #include "common/ieee802_11_defs.h" |
| 16 | #include "common/ieee802_11_common.h" |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 17 | #include "common/wpa_ctrl.h" |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 18 | #include "common/hw_features_common.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 19 | #include "hostapd.h" |
| 20 | #include "ap_config.h" |
| 21 | #include "ap_drv_ops.h" |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 22 | #include "acs.h" |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 23 | #include "ieee802_11.h" |
| 24 | #include "beacon.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 25 | #include "hw_features.h" |
| 26 | |
| 27 | |
| 28 | void hostapd_free_hw_features(struct hostapd_hw_modes *hw_features, |
| 29 | size_t num_hw_features) |
| 30 | { |
| 31 | size_t i; |
| 32 | |
| 33 | if (hw_features == NULL) |
| 34 | return; |
| 35 | |
| 36 | for (i = 0; i < num_hw_features; i++) { |
| 37 | os_free(hw_features[i].channels); |
| 38 | os_free(hw_features[i].rates); |
| 39 | } |
| 40 | |
| 41 | os_free(hw_features); |
| 42 | } |
| 43 | |
| 44 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 45 | #ifndef CONFIG_NO_STDOUT_DEBUG |
| 46 | static char * dfs_info(struct hostapd_channel_data *chan) |
| 47 | { |
| 48 | static char info[256]; |
| 49 | char *state; |
| 50 | |
| 51 | switch (chan->flag & HOSTAPD_CHAN_DFS_MASK) { |
| 52 | case HOSTAPD_CHAN_DFS_UNKNOWN: |
| 53 | state = "unknown"; |
| 54 | break; |
| 55 | case HOSTAPD_CHAN_DFS_USABLE: |
| 56 | state = "usable"; |
| 57 | break; |
| 58 | case HOSTAPD_CHAN_DFS_UNAVAILABLE: |
| 59 | state = "unavailable"; |
| 60 | break; |
| 61 | case HOSTAPD_CHAN_DFS_AVAILABLE: |
| 62 | state = "available"; |
| 63 | break; |
| 64 | default: |
| 65 | return ""; |
| 66 | } |
| 67 | os_snprintf(info, sizeof(info), " (DFS state = %s)", state); |
| 68 | info[sizeof(info) - 1] = '\0'; |
| 69 | |
| 70 | return info; |
| 71 | } |
| 72 | #endif /* CONFIG_NO_STDOUT_DEBUG */ |
| 73 | |
| 74 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 75 | int hostapd_get_hw_features(struct hostapd_iface *iface) |
| 76 | { |
| 77 | struct hostapd_data *hapd = iface->bss[0]; |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 78 | int i, j; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 79 | u16 num_modes, flags; |
| 80 | struct hostapd_hw_modes *modes; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 81 | u8 dfs_domain; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 82 | |
| 83 | if (hostapd_drv_none(hapd)) |
| 84 | return -1; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 85 | modes = hostapd_get_hw_feature_data(hapd, &num_modes, &flags, |
| 86 | &dfs_domain); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 87 | if (modes == NULL) { |
| 88 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
| 89 | HOSTAPD_LEVEL_DEBUG, |
| 90 | "Fetching hardware channel/rate support not " |
| 91 | "supported."); |
| 92 | return -1; |
| 93 | } |
| 94 | |
| 95 | iface->hw_flags = flags; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 96 | iface->dfs_domain = dfs_domain; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 97 | |
| 98 | hostapd_free_hw_features(iface->hw_features, iface->num_hw_features); |
| 99 | iface->hw_features = modes; |
| 100 | iface->num_hw_features = num_modes; |
| 101 | |
| 102 | for (i = 0; i < num_modes; i++) { |
| 103 | struct hostapd_hw_modes *feature = &modes[i]; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 104 | int dfs_enabled = hapd->iconf->ieee80211h && |
| 105 | (iface->drv_flags & WPA_DRIVER_FLAGS_RADAR); |
| 106 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 107 | /* set flag for channels we can use in current regulatory |
| 108 | * domain */ |
| 109 | for (j = 0; j < feature->num_channels; j++) { |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 110 | int dfs = 0; |
| 111 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 112 | /* |
| 113 | * Disable all channels that are marked not to allow |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 114 | * to initiate radiation (a.k.a. passive scan and no |
| 115 | * IBSS). |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 116 | * Use radar channels only if the driver supports DFS. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 117 | */ |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 118 | if ((feature->channels[j].flag & |
| 119 | HOSTAPD_CHAN_RADAR) && dfs_enabled) { |
| 120 | dfs = 1; |
Dmitry Shmidt | d11f019 | 2014-03-24 12:09:47 -0700 | [diff] [blame] | 121 | } else if (((feature->channels[j].flag & |
| 122 | HOSTAPD_CHAN_RADAR) && |
| 123 | !(iface->drv_flags & |
| 124 | WPA_DRIVER_FLAGS_DFS_OFFLOAD)) || |
| 125 | (feature->channels[j].flag & |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 126 | HOSTAPD_CHAN_NO_IR)) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 127 | feature->channels[j].flag |= |
| 128 | HOSTAPD_CHAN_DISABLED; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 131 | if (feature->channels[j].flag & HOSTAPD_CHAN_DISABLED) |
| 132 | continue; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 133 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 134 | wpa_printf(MSG_MSGDUMP, "Allowed channel: mode=%d " |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 135 | "chan=%d freq=%d MHz max_tx_power=%d dBm%s", |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 136 | feature->mode, |
| 137 | feature->channels[j].chan, |
| 138 | feature->channels[j].freq, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 139 | feature->channels[j].max_tx_power, |
| 140 | dfs ? dfs_info(&feature->channels[j]) : ""); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 144 | return 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 148 | int hostapd_prepare_rates(struct hostapd_iface *iface, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 149 | struct hostapd_hw_modes *mode) |
| 150 | { |
| 151 | int i, num_basic_rates = 0; |
| 152 | int basic_rates_a[] = { 60, 120, 240, -1 }; |
| 153 | int basic_rates_b[] = { 10, 20, -1 }; |
| 154 | int basic_rates_g[] = { 10, 20, 55, 110, -1 }; |
| 155 | int *basic_rates; |
| 156 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 157 | if (iface->conf->basic_rates) |
| 158 | basic_rates = iface->conf->basic_rates; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 159 | else switch (mode->mode) { |
| 160 | case HOSTAPD_MODE_IEEE80211A: |
| 161 | basic_rates = basic_rates_a; |
| 162 | break; |
| 163 | case HOSTAPD_MODE_IEEE80211B: |
| 164 | basic_rates = basic_rates_b; |
| 165 | break; |
| 166 | case HOSTAPD_MODE_IEEE80211G: |
| 167 | basic_rates = basic_rates_g; |
| 168 | break; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 169 | case HOSTAPD_MODE_IEEE80211AD: |
| 170 | return 0; /* No basic rates for 11ad */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 171 | default: |
| 172 | return -1; |
| 173 | } |
| 174 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 175 | i = 0; |
| 176 | while (basic_rates[i] >= 0) |
| 177 | i++; |
Dmitry Shmidt | 4530cfd | 2012-09-09 15:20:40 -0700 | [diff] [blame] | 178 | if (i) |
| 179 | i++; /* -1 termination */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 180 | os_free(iface->basic_rates); |
| 181 | iface->basic_rates = os_malloc(i * sizeof(int)); |
| 182 | if (iface->basic_rates) |
| 183 | os_memcpy(iface->basic_rates, basic_rates, i * sizeof(int)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 184 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 185 | os_free(iface->current_rates); |
| 186 | iface->num_rates = 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 187 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 188 | iface->current_rates = |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 189 | os_calloc(mode->num_rates, sizeof(struct hostapd_rate_data)); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 190 | if (!iface->current_rates) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 191 | wpa_printf(MSG_ERROR, "Failed to allocate memory for rate " |
| 192 | "table."); |
| 193 | return -1; |
| 194 | } |
| 195 | |
| 196 | for (i = 0; i < mode->num_rates; i++) { |
| 197 | struct hostapd_rate_data *rate; |
| 198 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 199 | if (iface->conf->supported_rates && |
| 200 | !hostapd_rate_found(iface->conf->supported_rates, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 201 | mode->rates[i])) |
| 202 | continue; |
| 203 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 204 | rate = &iface->current_rates[iface->num_rates]; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 205 | rate->rate = mode->rates[i]; |
| 206 | if (hostapd_rate_found(basic_rates, rate->rate)) { |
| 207 | rate->flags |= HOSTAPD_RATE_BASIC; |
| 208 | num_basic_rates++; |
| 209 | } |
| 210 | wpa_printf(MSG_DEBUG, "RATE[%d] rate=%d flags=0x%x", |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 211 | iface->num_rates, rate->rate, rate->flags); |
| 212 | iface->num_rates++; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 215 | if ((iface->num_rates == 0 || num_basic_rates == 0) && |
| 216 | (!iface->conf->ieee80211n || !iface->conf->require_ht)) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 217 | wpa_printf(MSG_ERROR, "No rates remaining in supported/basic " |
| 218 | "rate sets (%d,%d).", |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 219 | iface->num_rates, num_basic_rates); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 220 | return -1; |
| 221 | } |
| 222 | |
| 223 | return 0; |
| 224 | } |
| 225 | |
| 226 | |
| 227 | #ifdef CONFIG_IEEE80211N |
| 228 | static int ieee80211n_allowed_ht40_channel_pair(struct hostapd_iface *iface) |
| 229 | { |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 230 | int pri_chan, sec_chan; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 231 | |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 232 | pri_chan = iface->conf->channel; |
| 233 | sec_chan = pri_chan + iface->conf->secondary_channel * 4; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 234 | |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 235 | return allowed_ht40_channel_pair(iface->current_mode, pri_chan, |
| 236 | sec_chan); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | |
| 240 | static void ieee80211n_switch_pri_sec(struct hostapd_iface *iface) |
| 241 | { |
| 242 | if (iface->conf->secondary_channel > 0) { |
| 243 | iface->conf->channel += 4; |
| 244 | iface->conf->secondary_channel = -1; |
| 245 | } else { |
| 246 | iface->conf->channel -= 4; |
| 247 | iface->conf->secondary_channel = 1; |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 252 | static int ieee80211n_check_40mhz_5g(struct hostapd_iface *iface, |
| 253 | struct wpa_scan_results *scan_res) |
| 254 | { |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 255 | int pri_chan, sec_chan; |
| 256 | int res; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 257 | |
| 258 | pri_chan = iface->conf->channel; |
Dmitry Shmidt | b36ed7c | 2014-03-17 10:57:26 -0700 | [diff] [blame] | 259 | sec_chan = pri_chan + iface->conf->secondary_channel * 4; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 260 | |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 261 | res = check_40mhz_5g(iface->current_mode, scan_res, pri_chan, sec_chan); |
| 262 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 263 | if (res == 2) { |
| 264 | if (iface->conf->no_pri_sec_switch) { |
| 265 | wpa_printf(MSG_DEBUG, |
| 266 | "Cannot switch PRI/SEC channels due to local constraint"); |
| 267 | } else { |
| 268 | ieee80211n_switch_pri_sec(iface); |
| 269 | } |
| 270 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 271 | |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 272 | return !!res; |
Dmitry Shmidt | 6dc03bd | 2014-05-16 10:40:13 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 276 | static int ieee80211n_check_40mhz_2g4(struct hostapd_iface *iface, |
| 277 | struct wpa_scan_results *scan_res) |
| 278 | { |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 279 | int pri_chan, sec_chan; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 280 | |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 281 | pri_chan = iface->conf->channel; |
| 282 | sec_chan = pri_chan + iface->conf->secondary_channel * 4; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 283 | |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 284 | return check_40mhz_2g4(iface->current_mode, scan_res, pri_chan, |
| 285 | sec_chan); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 289 | static void ieee80211n_check_scan(struct hostapd_iface *iface) |
| 290 | { |
| 291 | struct wpa_scan_results *scan_res; |
| 292 | int oper40; |
| 293 | int res; |
| 294 | |
| 295 | /* Check list of neighboring BSSes (from scan) to see whether 40 MHz is |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 296 | * allowed per IEEE Std 802.11-2012, 10.15.3.2 */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 297 | |
| 298 | iface->scan_cb = NULL; |
| 299 | |
| 300 | scan_res = hostapd_driver_get_scan_results(iface->bss[0]); |
| 301 | if (scan_res == NULL) { |
| 302 | hostapd_setup_interface_complete(iface, 1); |
| 303 | return; |
| 304 | } |
| 305 | |
| 306 | if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A) |
| 307 | oper40 = ieee80211n_check_40mhz_5g(iface, scan_res); |
| 308 | else |
| 309 | oper40 = ieee80211n_check_40mhz_2g4(iface, scan_res); |
| 310 | wpa_scan_results_free(scan_res); |
| 311 | |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 312 | iface->secondary_ch = iface->conf->secondary_channel; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 313 | if (!oper40) { |
| 314 | wpa_printf(MSG_INFO, "20/40 MHz operation not permitted on " |
| 315 | "channel pri=%d sec=%d based on overlapping BSSes", |
| 316 | iface->conf->channel, |
| 317 | iface->conf->channel + |
| 318 | iface->conf->secondary_channel * 4); |
| 319 | iface->conf->secondary_channel = 0; |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 320 | if (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX) { |
| 321 | /* |
| 322 | * TODO: Could consider scheduling another scan to check |
| 323 | * if channel width can be changed if no coex reports |
| 324 | * are received from associating stations. |
| 325 | */ |
| 326 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | res = ieee80211n_allowed_ht40_channel_pair(iface); |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 330 | if (!res) { |
| 331 | iface->conf->secondary_channel = 0; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 332 | hostapd_set_oper_centr_freq_seg0_idx(iface->conf, 0); |
| 333 | hostapd_set_oper_centr_freq_seg1_idx(iface->conf, 0); |
| 334 | hostapd_set_oper_chwidth(iface->conf, CHANWIDTH_USE_HT); |
Dmitry Shmidt | b97e428 | 2016-02-08 10:16:07 -0800 | [diff] [blame] | 335 | res = 1; |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 336 | wpa_printf(MSG_INFO, "Fallback to 20 MHz"); |
| 337 | } |
| 338 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 339 | hostapd_setup_interface_complete(iface, !res); |
| 340 | } |
| 341 | |
| 342 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 343 | static void ieee80211n_scan_channels_2g4(struct hostapd_iface *iface, |
| 344 | struct wpa_driver_scan_params *params) |
| 345 | { |
| 346 | /* Scan only the affected frequency range */ |
| 347 | int pri_freq, sec_freq; |
| 348 | int affected_start, affected_end; |
| 349 | int i, pos; |
| 350 | struct hostapd_hw_modes *mode; |
| 351 | |
| 352 | if (iface->current_mode == NULL) |
| 353 | return; |
| 354 | |
| 355 | pri_freq = hostapd_hw_get_freq(iface->bss[0], iface->conf->channel); |
| 356 | if (iface->conf->secondary_channel > 0) |
| 357 | sec_freq = pri_freq + 20; |
| 358 | else |
| 359 | sec_freq = pri_freq - 20; |
Dmitry Shmidt | 4171258 | 2015-06-29 11:02:15 -0700 | [diff] [blame] | 360 | /* |
| 361 | * Note: Need to find the PRI channel also in cases where the affected |
| 362 | * channel is the SEC channel of a 40 MHz BSS, so need to include the |
| 363 | * scanning coverage here to be 40 MHz from the center frequency. |
| 364 | */ |
| 365 | affected_start = (pri_freq + sec_freq) / 2 - 40; |
| 366 | affected_end = (pri_freq + sec_freq) / 2 + 40; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 367 | wpa_printf(MSG_DEBUG, "40 MHz affected channel range: [%d,%d] MHz", |
| 368 | affected_start, affected_end); |
| 369 | |
| 370 | mode = iface->current_mode; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 371 | params->freqs = os_calloc(mode->num_channels + 1, sizeof(int)); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 372 | if (params->freqs == NULL) |
| 373 | return; |
| 374 | pos = 0; |
| 375 | |
| 376 | for (i = 0; i < mode->num_channels; i++) { |
| 377 | struct hostapd_channel_data *chan = &mode->channels[i]; |
| 378 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 379 | continue; |
| 380 | if (chan->freq < affected_start || |
| 381 | chan->freq > affected_end) |
| 382 | continue; |
| 383 | params->freqs[pos++] = chan->freq; |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 388 | static void ieee80211n_scan_channels_5g(struct hostapd_iface *iface, |
| 389 | struct wpa_driver_scan_params *params) |
| 390 | { |
| 391 | /* Scan only the affected frequency range */ |
| 392 | int pri_freq; |
| 393 | int affected_start, affected_end; |
| 394 | int i, pos; |
| 395 | struct hostapd_hw_modes *mode; |
| 396 | |
| 397 | if (iface->current_mode == NULL) |
| 398 | return; |
| 399 | |
| 400 | pri_freq = hostapd_hw_get_freq(iface->bss[0], iface->conf->channel); |
| 401 | if (iface->conf->secondary_channel > 0) { |
| 402 | affected_start = pri_freq - 10; |
| 403 | affected_end = pri_freq + 30; |
| 404 | } else { |
| 405 | affected_start = pri_freq - 30; |
| 406 | affected_end = pri_freq + 10; |
| 407 | } |
| 408 | wpa_printf(MSG_DEBUG, "40 MHz affected channel range: [%d,%d] MHz", |
| 409 | affected_start, affected_end); |
| 410 | |
| 411 | mode = iface->current_mode; |
| 412 | params->freqs = os_calloc(mode->num_channels + 1, sizeof(int)); |
| 413 | if (params->freqs == NULL) |
| 414 | return; |
| 415 | pos = 0; |
| 416 | |
| 417 | for (i = 0; i < mode->num_channels; i++) { |
| 418 | struct hostapd_channel_data *chan = &mode->channels[i]; |
| 419 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 420 | continue; |
| 421 | if (chan->freq < affected_start || |
| 422 | chan->freq > affected_end) |
| 423 | continue; |
| 424 | params->freqs[pos++] = chan->freq; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 429 | static void ap_ht40_scan_retry(void *eloop_data, void *user_data) |
| 430 | { |
| 431 | #define HT2040_COEX_SCAN_RETRY 15 |
| 432 | struct hostapd_iface *iface = eloop_data; |
| 433 | struct wpa_driver_scan_params params; |
| 434 | int ret; |
| 435 | |
| 436 | os_memset(¶ms, 0, sizeof(params)); |
| 437 | if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) |
| 438 | ieee80211n_scan_channels_2g4(iface, ¶ms); |
| 439 | else |
| 440 | ieee80211n_scan_channels_5g(iface, ¶ms); |
| 441 | |
| 442 | ret = hostapd_driver_scan(iface->bss[0], ¶ms); |
| 443 | iface->num_ht40_scan_tries++; |
| 444 | os_free(params.freqs); |
| 445 | |
| 446 | if (ret == -EBUSY && |
| 447 | iface->num_ht40_scan_tries < HT2040_COEX_SCAN_RETRY) { |
| 448 | wpa_printf(MSG_ERROR, |
| 449 | "Failed to request a scan of neighboring BSSes ret=%d (%s) - try to scan again (attempt %d)", |
| 450 | ret, strerror(-ret), iface->num_ht40_scan_tries); |
| 451 | eloop_register_timeout(1, 0, ap_ht40_scan_retry, iface, NULL); |
| 452 | return; |
| 453 | } |
| 454 | |
| 455 | if (ret == 0) { |
| 456 | iface->scan_cb = ieee80211n_check_scan; |
| 457 | return; |
| 458 | } |
| 459 | |
| 460 | wpa_printf(MSG_DEBUG, |
| 461 | "Failed to request a scan in device, bringing up in HT20 mode"); |
| 462 | iface->conf->secondary_channel = 0; |
| 463 | iface->conf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; |
| 464 | hostapd_setup_interface_complete(iface, 0); |
| 465 | } |
| 466 | |
| 467 | |
| 468 | void hostapd_stop_setup_timers(struct hostapd_iface *iface) |
| 469 | { |
| 470 | eloop_cancel_timeout(ap_ht40_scan_retry, iface, NULL); |
| 471 | } |
| 472 | |
| 473 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 474 | static int ieee80211n_check_40mhz(struct hostapd_iface *iface) |
| 475 | { |
| 476 | struct wpa_driver_scan_params params; |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 477 | int ret; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 478 | |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 479 | /* Check that HT40 is used and PRI / SEC switch is allowed */ |
| 480 | if (!iface->conf->secondary_channel || iface->conf->no_pri_sec_switch) |
| 481 | return 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 482 | |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 483 | hostapd_set_state(iface, HAPD_IFACE_HT_SCAN); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 484 | wpa_printf(MSG_DEBUG, "Scan for neighboring BSSes prior to enabling " |
| 485 | "40 MHz channel"); |
| 486 | os_memset(¶ms, 0, sizeof(params)); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 487 | if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) |
| 488 | ieee80211n_scan_channels_2g4(iface, ¶ms); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 489 | else |
| 490 | ieee80211n_scan_channels_5g(iface, ¶ms); |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 491 | |
| 492 | ret = hostapd_driver_scan(iface->bss[0], ¶ms); |
| 493 | os_free(params.freqs); |
| 494 | |
| 495 | if (ret == -EBUSY) { |
| 496 | wpa_printf(MSG_ERROR, |
| 497 | "Failed to request a scan of neighboring BSSes ret=%d (%s) - try to scan again", |
| 498 | ret, strerror(-ret)); |
| 499 | iface->num_ht40_scan_tries = 1; |
| 500 | eloop_cancel_timeout(ap_ht40_scan_retry, iface, NULL); |
| 501 | eloop_register_timeout(1, 0, ap_ht40_scan_retry, iface, NULL); |
| 502 | return 1; |
| 503 | } |
| 504 | |
| 505 | if (ret < 0) { |
| 506 | wpa_printf(MSG_ERROR, |
| 507 | "Failed to request a scan of neighboring BSSes ret=%d (%s)", |
| 508 | ret, strerror(-ret)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 509 | return -1; |
| 510 | } |
| 511 | |
| 512 | iface->scan_cb = ieee80211n_check_scan; |
| 513 | return 1; |
| 514 | } |
| 515 | |
| 516 | |
| 517 | static int ieee80211n_supported_ht_capab(struct hostapd_iface *iface) |
| 518 | { |
| 519 | u16 hw = iface->current_mode->ht_capab; |
| 520 | u16 conf = iface->conf->ht_capab; |
| 521 | |
| 522 | if ((conf & HT_CAP_INFO_LDPC_CODING_CAP) && |
| 523 | !(hw & HT_CAP_INFO_LDPC_CODING_CAP)) { |
| 524 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 525 | "HT capability [LDPC]"); |
| 526 | return 0; |
| 527 | } |
| 528 | |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 529 | /* |
| 530 | * Driver ACS chosen channel may not be HT40 due to internal driver |
| 531 | * restrictions. |
| 532 | */ |
| 533 | if (!iface->conf->acs && (conf & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) && |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 534 | !(hw & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) { |
| 535 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 536 | "HT capability [HT40*]"); |
| 537 | return 0; |
| 538 | } |
| 539 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 540 | switch (conf & HT_CAP_INFO_SMPS_MASK) { |
| 541 | case HT_CAP_INFO_SMPS_STATIC: |
| 542 | if (!(iface->smps_modes & WPA_DRIVER_SMPS_MODE_STATIC)) { |
| 543 | wpa_printf(MSG_ERROR, |
| 544 | "Driver does not support configured HT capability [SMPS-STATIC]"); |
| 545 | return 0; |
| 546 | } |
| 547 | break; |
| 548 | case HT_CAP_INFO_SMPS_DYNAMIC: |
| 549 | if (!(iface->smps_modes & WPA_DRIVER_SMPS_MODE_DYNAMIC)) { |
| 550 | wpa_printf(MSG_ERROR, |
| 551 | "Driver does not support configured HT capability [SMPS-DYNAMIC]"); |
| 552 | return 0; |
| 553 | } |
| 554 | break; |
| 555 | case HT_CAP_INFO_SMPS_DISABLED: |
| 556 | default: |
| 557 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | if ((conf & HT_CAP_INFO_GREEN_FIELD) && |
| 561 | !(hw & HT_CAP_INFO_GREEN_FIELD)) { |
| 562 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 563 | "HT capability [GF]"); |
| 564 | return 0; |
| 565 | } |
| 566 | |
| 567 | if ((conf & HT_CAP_INFO_SHORT_GI20MHZ) && |
| 568 | !(hw & HT_CAP_INFO_SHORT_GI20MHZ)) { |
| 569 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 570 | "HT capability [SHORT-GI-20]"); |
| 571 | return 0; |
| 572 | } |
| 573 | |
| 574 | if ((conf & HT_CAP_INFO_SHORT_GI40MHZ) && |
| 575 | !(hw & HT_CAP_INFO_SHORT_GI40MHZ)) { |
| 576 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 577 | "HT capability [SHORT-GI-40]"); |
| 578 | return 0; |
| 579 | } |
| 580 | |
| 581 | if ((conf & HT_CAP_INFO_TX_STBC) && !(hw & HT_CAP_INFO_TX_STBC)) { |
| 582 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 583 | "HT capability [TX-STBC]"); |
| 584 | return 0; |
| 585 | } |
| 586 | |
| 587 | if ((conf & HT_CAP_INFO_RX_STBC_MASK) > |
| 588 | (hw & HT_CAP_INFO_RX_STBC_MASK)) { |
| 589 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 590 | "HT capability [RX-STBC*]"); |
| 591 | return 0; |
| 592 | } |
| 593 | |
| 594 | if ((conf & HT_CAP_INFO_DELAYED_BA) && |
| 595 | !(hw & HT_CAP_INFO_DELAYED_BA)) { |
| 596 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 597 | "HT capability [DELAYED-BA]"); |
| 598 | return 0; |
| 599 | } |
| 600 | |
| 601 | if ((conf & HT_CAP_INFO_MAX_AMSDU_SIZE) && |
| 602 | !(hw & HT_CAP_INFO_MAX_AMSDU_SIZE)) { |
| 603 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 604 | "HT capability [MAX-AMSDU-7935]"); |
| 605 | return 0; |
| 606 | } |
| 607 | |
| 608 | if ((conf & HT_CAP_INFO_DSSS_CCK40MHZ) && |
| 609 | !(hw & HT_CAP_INFO_DSSS_CCK40MHZ)) { |
| 610 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 611 | "HT capability [DSSS_CCK-40]"); |
| 612 | return 0; |
| 613 | } |
| 614 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 615 | if ((conf & HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT) && |
| 616 | !(hw & HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT)) { |
| 617 | wpa_printf(MSG_ERROR, "Driver does not support configured " |
| 618 | "HT capability [LSIG-TXOP-PROT]"); |
| 619 | return 0; |
| 620 | } |
| 621 | |
| 622 | return 1; |
| 623 | } |
| 624 | |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 625 | |
| 626 | #ifdef CONFIG_IEEE80211AC |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 627 | static int ieee80211ac_supported_vht_capab(struct hostapd_iface *iface) |
| 628 | { |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 629 | struct hostapd_hw_modes *mode = iface->current_mode; |
| 630 | u32 hw = mode->vht_capab; |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 631 | u32 conf = iface->conf->vht_capab; |
| 632 | |
| 633 | wpa_printf(MSG_DEBUG, "hw vht capab: 0x%x, conf vht capab: 0x%x", |
| 634 | hw, conf); |
| 635 | |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 636 | if (mode->mode == HOSTAPD_MODE_IEEE80211G && |
| 637 | iface->conf->bss[0]->vendor_vht && |
| 638 | mode->vht_capab == 0 && iface->hw_features) { |
| 639 | int i; |
| 640 | |
| 641 | for (i = 0; i < iface->num_hw_features; i++) { |
| 642 | if (iface->hw_features[i].mode == |
| 643 | HOSTAPD_MODE_IEEE80211A) { |
| 644 | mode = &iface->hw_features[i]; |
| 645 | hw = mode->vht_capab; |
| 646 | wpa_printf(MSG_DEBUG, |
| 647 | "update hw vht capab based on 5 GHz band: 0x%x", |
| 648 | hw); |
| 649 | break; |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 654 | return ieee80211ac_cap_check(hw, conf); |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 655 | } |
| 656 | #endif /* CONFIG_IEEE80211AC */ |
| 657 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 658 | |
| 659 | #ifdef CONFIG_IEEE80211AX |
| 660 | static int ieee80211ax_supported_he_capab(struct hostapd_iface *iface) |
| 661 | { |
| 662 | return 1; |
| 663 | } |
| 664 | #endif /* CONFIG_IEEE80211AX */ |
| 665 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 666 | #endif /* CONFIG_IEEE80211N */ |
| 667 | |
| 668 | |
| 669 | int hostapd_check_ht_capab(struct hostapd_iface *iface) |
| 670 | { |
| 671 | #ifdef CONFIG_IEEE80211N |
| 672 | int ret; |
| 673 | if (!iface->conf->ieee80211n) |
| 674 | return 0; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 675 | |
| 676 | if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211B && |
| 677 | iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G && |
| 678 | (iface->conf->ht_capab & HT_CAP_INFO_DSSS_CCK40MHZ)) { |
| 679 | wpa_printf(MSG_DEBUG, |
| 680 | "Disable HT capability [DSSS_CCK-40] on 5 GHz band"); |
| 681 | iface->conf->ht_capab &= ~HT_CAP_INFO_DSSS_CCK40MHZ; |
| 682 | } |
| 683 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 684 | if (!ieee80211n_supported_ht_capab(iface)) |
| 685 | return -1; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 686 | #ifdef CONFIG_IEEE80211AX |
| 687 | if (iface->conf->ieee80211ax && |
| 688 | !ieee80211ax_supported_he_capab(iface)) |
| 689 | return -1; |
| 690 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 691 | #ifdef CONFIG_IEEE80211AC |
Hai Shalom | 39ba6fc | 2019-01-22 12:40:38 -0800 | [diff] [blame] | 692 | if (iface->conf->ieee80211ac && |
| 693 | !ieee80211ac_supported_vht_capab(iface)) |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 694 | return -1; |
| 695 | #endif /* CONFIG_IEEE80211AC */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 696 | ret = ieee80211n_check_40mhz(iface); |
| 697 | if (ret) |
| 698 | return ret; |
| 699 | if (!ieee80211n_allowed_ht40_channel_pair(iface)) |
| 700 | return -1; |
| 701 | #endif /* CONFIG_IEEE80211N */ |
| 702 | |
| 703 | return 0; |
| 704 | } |
| 705 | |
| 706 | |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame^] | 707 | int hostapd_check_edmg_capab(struct hostapd_iface *iface) |
| 708 | { |
| 709 | struct hostapd_hw_modes *mode = iface->hw_features; |
| 710 | struct ieee80211_edmg_config edmg; |
| 711 | |
| 712 | if (!iface->conf->enable_edmg) |
| 713 | return 0; |
| 714 | |
| 715 | hostapd_encode_edmg_chan(iface->conf->enable_edmg, |
| 716 | iface->conf->edmg_channel, |
| 717 | iface->conf->channel, |
| 718 | &edmg); |
| 719 | |
| 720 | if (mode->edmg.channels && ieee802_edmg_is_allowed(mode->edmg, edmg)) |
| 721 | return 0; |
| 722 | |
| 723 | wpa_printf(MSG_WARNING, "Requested EDMG configuration is not valid"); |
| 724 | wpa_printf(MSG_INFO, "EDMG capab: channels 0x%x, bw_config %d", |
| 725 | mode->edmg.channels, mode->edmg.bw_config); |
| 726 | wpa_printf(MSG_INFO, |
| 727 | "Requested EDMG configuration: channels 0x%x, bw_config %d", |
| 728 | edmg.channels, edmg.bw_config); |
| 729 | return -1; |
| 730 | } |
| 731 | |
| 732 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 733 | static int hostapd_is_usable_chan(struct hostapd_iface *iface, |
| 734 | int channel, int primary) |
| 735 | { |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 736 | struct hostapd_channel_data *chan; |
| 737 | |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 738 | if (!iface->current_mode) |
| 739 | return 0; |
| 740 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 741 | chan = hw_get_channel_chan(iface->current_mode, channel, NULL); |
| 742 | if (!chan) |
| 743 | return 0; |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 744 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 745 | if ((primary && chan_pri_allowed(chan)) || |
| 746 | (!primary && !(chan->flag & HOSTAPD_CHAN_DISABLED))) |
| 747 | return 1; |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 748 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 749 | wpa_printf(MSG_INFO, |
| 750 | "Channel %d (%s) not allowed for AP mode, flags: 0x%x%s%s", |
| 751 | channel, primary ? "primary" : "secondary", |
| 752 | chan->flag, |
| 753 | chan->flag & HOSTAPD_CHAN_NO_IR ? " NO-IR" : "", |
| 754 | chan->flag & HOSTAPD_CHAN_RADAR ? " RADAR" : ""); |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 755 | return 0; |
| 756 | } |
| 757 | |
| 758 | |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame^] | 759 | static int hostapd_is_usable_edmg(struct hostapd_iface *iface) |
| 760 | { |
| 761 | int i, contiguous = 0; |
| 762 | int num_of_enabled = 0; |
| 763 | int max_contiguous = 0; |
| 764 | struct ieee80211_edmg_config edmg; |
| 765 | |
| 766 | if (!iface->conf->enable_edmg) |
| 767 | return 1; |
| 768 | |
| 769 | hostapd_encode_edmg_chan(iface->conf->enable_edmg, |
| 770 | iface->conf->edmg_channel, |
| 771 | iface->conf->channel, |
| 772 | &edmg); |
| 773 | if (!(edmg.channels & BIT(iface->conf->channel - 1))) |
| 774 | return 0; |
| 775 | |
| 776 | /* 60 GHz channels 1..6 */ |
| 777 | for (i = 0; i < 6; i++) { |
| 778 | if (edmg.channels & BIT(i)) { |
| 779 | contiguous++; |
| 780 | num_of_enabled++; |
| 781 | } else { |
| 782 | contiguous = 0; |
| 783 | continue; |
| 784 | } |
| 785 | |
| 786 | /* P802.11ay defines that the total number of subfields |
| 787 | * set to one does not exceed 4. |
| 788 | */ |
| 789 | if (num_of_enabled > 4) |
| 790 | return 0; |
| 791 | |
| 792 | if (!hostapd_is_usable_chan(iface, i + 1, 1)) |
| 793 | return 0; |
| 794 | |
| 795 | if (contiguous > max_contiguous) |
| 796 | max_contiguous = contiguous; |
| 797 | } |
| 798 | |
| 799 | /* Check if the EDMG configuration is valid under the limitations |
| 800 | * of P802.11ay. |
| 801 | */ |
| 802 | /* check bw_config against contiguous EDMG channels */ |
| 803 | switch (edmg.bw_config) { |
| 804 | case EDMG_BW_CONFIG_4: |
| 805 | if (!max_contiguous) |
| 806 | return 0; |
| 807 | break; |
| 808 | case EDMG_BW_CONFIG_5: |
| 809 | if (max_contiguous < 2) |
| 810 | return 0; |
| 811 | break; |
| 812 | default: |
| 813 | return 0; |
| 814 | } |
| 815 | |
| 816 | return 1; |
| 817 | } |
| 818 | |
| 819 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 820 | static int hostapd_is_usable_chans(struct hostapd_iface *iface) |
| 821 | { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 822 | int secondary_chan; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 823 | struct hostapd_channel_data *pri_chan; |
| 824 | |
| 825 | pri_chan = hw_get_channel_chan(iface->current_mode, |
| 826 | iface->conf->channel, NULL); |
| 827 | if (!pri_chan) |
| 828 | return 0; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 829 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 830 | if (!hostapd_is_usable_chan(iface, iface->conf->channel, 1)) |
| 831 | return 0; |
| 832 | |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame^] | 833 | if (!hostapd_is_usable_edmg(iface)) |
| 834 | return 0; |
| 835 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 836 | if (!iface->conf->secondary_channel) |
| 837 | return 1; |
| 838 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 839 | if (!iface->conf->ht40_plus_minus_allowed) |
| 840 | return hostapd_is_usable_chan( |
| 841 | iface, iface->conf->channel + |
| 842 | iface->conf->secondary_channel * 4, 0); |
| 843 | |
| 844 | /* Both HT40+ and HT40- are set, pick a valid secondary channel */ |
| 845 | secondary_chan = iface->conf->channel + 4; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 846 | if (hostapd_is_usable_chan(iface, secondary_chan, 0) && |
| 847 | (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40P)) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 848 | iface->conf->secondary_channel = 1; |
| 849 | return 1; |
| 850 | } |
| 851 | |
| 852 | secondary_chan = iface->conf->channel - 4; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 853 | if (hostapd_is_usable_chan(iface, secondary_chan, 0) && |
| 854 | (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40M)) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 855 | iface->conf->secondary_channel = -1; |
| 856 | return 1; |
| 857 | } |
| 858 | |
| 859 | return 0; |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 860 | } |
| 861 | |
| 862 | |
| 863 | static enum hostapd_chan_status |
| 864 | hostapd_check_chans(struct hostapd_iface *iface) |
| 865 | { |
| 866 | if (iface->conf->channel) { |
| 867 | if (hostapd_is_usable_chans(iface)) |
| 868 | return HOSTAPD_CHAN_VALID; |
| 869 | else |
| 870 | return HOSTAPD_CHAN_INVALID; |
| 871 | } |
| 872 | |
| 873 | /* |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 874 | * The user set channel=0 or channel=acs_survey |
| 875 | * which is used to trigger ACS. |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 876 | */ |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 877 | |
| 878 | switch (acs_init(iface)) { |
| 879 | case HOSTAPD_CHAN_ACS: |
| 880 | return HOSTAPD_CHAN_ACS; |
| 881 | case HOSTAPD_CHAN_VALID: |
| 882 | case HOSTAPD_CHAN_INVALID: |
| 883 | default: |
| 884 | return HOSTAPD_CHAN_INVALID; |
| 885 | } |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | |
| 889 | static void hostapd_notify_bad_chans(struct hostapd_iface *iface) |
| 890 | { |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 891 | if (!iface->current_mode) { |
| 892 | hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, |
| 893 | HOSTAPD_LEVEL_WARNING, |
| 894 | "Hardware does not support configured mode"); |
| 895 | return; |
| 896 | } |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 897 | hostapd_logger(iface->bss[0], NULL, |
| 898 | HOSTAPD_MODULE_IEEE80211, |
| 899 | HOSTAPD_LEVEL_WARNING, |
| 900 | "Configured channel (%d) not found from the " |
| 901 | "channel list of current mode (%d) %s", |
| 902 | iface->conf->channel, |
| 903 | iface->current_mode->mode, |
| 904 | hostapd_hw_mode_txt(iface->current_mode->mode)); |
| 905 | hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, |
| 906 | HOSTAPD_LEVEL_WARNING, |
| 907 | "Hardware does not support configured channel"); |
| 908 | } |
| 909 | |
| 910 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 911 | int hostapd_acs_completed(struct hostapd_iface *iface, int err) |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 912 | { |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 913 | int ret = -1; |
| 914 | |
| 915 | if (err) |
| 916 | goto out; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 917 | |
| 918 | switch (hostapd_check_chans(iface)) { |
| 919 | case HOSTAPD_CHAN_VALID: |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 920 | wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, |
| 921 | ACS_EVENT_COMPLETED "freq=%d channel=%d", |
| 922 | hostapd_hw_get_freq(iface->bss[0], |
| 923 | iface->conf->channel), |
| 924 | iface->conf->channel); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 925 | break; |
| 926 | case HOSTAPD_CHAN_ACS: |
| 927 | wpa_printf(MSG_ERROR, "ACS error - reported complete, but no result available"); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 928 | wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 929 | hostapd_notify_bad_chans(iface); |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 930 | goto out; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 931 | case HOSTAPD_CHAN_INVALID: |
| 932 | default: |
| 933 | wpa_printf(MSG_ERROR, "ACS picked unusable channels"); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 934 | wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 935 | hostapd_notify_bad_chans(iface); |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 936 | goto out; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | ret = hostapd_check_ht_capab(iface); |
| 940 | if (ret < 0) |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 941 | goto out; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 942 | if (ret == 1) { |
| 943 | wpa_printf(MSG_DEBUG, "Interface initialization will be completed in a callback"); |
| 944 | return 0; |
| 945 | } |
| 946 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 947 | ret = 0; |
| 948 | out: |
| 949 | return hostapd_setup_interface_complete(iface, ret); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 950 | } |
| 951 | |
| 952 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 953 | /** |
| 954 | * hostapd_select_hw_mode - Select the hardware mode |
| 955 | * @iface: Pointer to interface data. |
Jouni Malinen | 87fd279 | 2011-05-16 18:35:42 +0300 | [diff] [blame] | 956 | * Returns: 0 on success, < 0 on failure |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 957 | * |
| 958 | * Sets up the hardware mode, channel, rates, and passive scanning |
| 959 | * based on the configuration. |
| 960 | */ |
| 961 | int hostapd_select_hw_mode(struct hostapd_iface *iface) |
| 962 | { |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 963 | int i; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame^] | 964 | int freq = -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 965 | |
| 966 | if (iface->num_hw_features < 1) |
| 967 | return -1; |
| 968 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 969 | if ((iface->conf->hw_mode == HOSTAPD_MODE_IEEE80211G || |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 970 | iface->conf->ieee80211n || iface->conf->ieee80211ac || |
| 971 | iface->conf->ieee80211ax) && |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 972 | iface->conf->channel == 14) { |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 973 | wpa_printf(MSG_INFO, "Disable OFDM/HT/VHT/HE on channel 14"); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 974 | iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211B; |
| 975 | iface->conf->ieee80211n = 0; |
| 976 | iface->conf->ieee80211ac = 0; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 977 | iface->conf->ieee80211ax = 0; |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 978 | } |
| 979 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 980 | iface->current_mode = NULL; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame^] | 981 | if (iface->conf->channel && iface->conf->op_class) |
| 982 | freq = ieee80211_chan_to_freq(NULL, iface->conf->op_class, |
| 983 | iface->conf->channel); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 984 | for (i = 0; i < iface->num_hw_features; i++) { |
| 985 | struct hostapd_hw_modes *mode = &iface->hw_features[i]; |
| 986 | if (mode->mode == iface->conf->hw_mode) { |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame^] | 987 | if (freq > 0 && !hw_get_chan(mode, freq)) |
| 988 | continue; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 989 | iface->current_mode = mode; |
| 990 | break; |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | if (iface->current_mode == NULL) { |
Dmitry Shmidt | b1e5210 | 2015-05-29 12:36:29 -0700 | [diff] [blame] | 995 | if (!(iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) || |
| 996 | !(iface->drv_flags & WPA_DRIVER_FLAGS_SUPPORT_HW_MODE_ANY)) |
| 997 | { |
| 998 | wpa_printf(MSG_ERROR, |
| 999 | "Hardware does not support configured mode"); |
| 1000 | hostapd_logger(iface->bss[0], NULL, |
| 1001 | HOSTAPD_MODULE_IEEE80211, |
| 1002 | HOSTAPD_LEVEL_WARNING, |
| 1003 | "Hardware does not support configured mode (%d) (hw_mode in hostapd.conf)", |
| 1004 | (int) iface->conf->hw_mode); |
| 1005 | return -2; |
| 1006 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1007 | } |
| 1008 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 1009 | switch (hostapd_check_chans(iface)) { |
| 1010 | case HOSTAPD_CHAN_VALID: |
| 1011 | return 0; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 1012 | case HOSTAPD_CHAN_ACS: /* ACS will run and later complete */ |
| 1013 | return 1; |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 1014 | case HOSTAPD_CHAN_INVALID: |
| 1015 | default: |
| 1016 | hostapd_notify_bad_chans(iface); |
Jouni Malinen | 87fd279 | 2011-05-16 18:35:42 +0300 | [diff] [blame] | 1017 | return -3; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1018 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | |
| 1022 | const char * hostapd_hw_mode_txt(int mode) |
| 1023 | { |
| 1024 | switch (mode) { |
| 1025 | case HOSTAPD_MODE_IEEE80211A: |
| 1026 | return "IEEE 802.11a"; |
| 1027 | case HOSTAPD_MODE_IEEE80211B: |
| 1028 | return "IEEE 802.11b"; |
| 1029 | case HOSTAPD_MODE_IEEE80211G: |
| 1030 | return "IEEE 802.11g"; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1031 | case HOSTAPD_MODE_IEEE80211AD: |
| 1032 | return "IEEE 802.11ad"; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1033 | default: |
| 1034 | return "UNKNOWN"; |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | |
| 1039 | int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan) |
| 1040 | { |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 1041 | return hw_get_freq(hapd->iface->current_mode, chan); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | |
| 1045 | int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq) |
| 1046 | { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1047 | int i, channel; |
| 1048 | struct hostapd_hw_modes *mode; |
| 1049 | |
Hai Shalom | 1dc4d20 | 2019-04-29 16:22:27 -0700 | [diff] [blame] | 1050 | if (hapd->iface->current_mode) { |
| 1051 | channel = hw_get_chan(hapd->iface->current_mode, freq); |
| 1052 | if (channel) |
| 1053 | return channel; |
| 1054 | } |
| 1055 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1056 | /* Check other available modes since the channel list for the current |
| 1057 | * mode did not include the specified frequency. */ |
Hai Shalom | 1dc4d20 | 2019-04-29 16:22:27 -0700 | [diff] [blame] | 1058 | if (!hapd->iface->hw_features) |
| 1059 | return 0; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1060 | for (i = 0; i < hapd->iface->num_hw_features; i++) { |
| 1061 | mode = &hapd->iface->hw_features[i]; |
| 1062 | channel = hw_get_chan(mode, freq); |
| 1063 | if (channel) |
| 1064 | return channel; |
| 1065 | } |
| 1066 | return 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1067 | } |