Skip to content

Commit

Permalink
wpa: Import wpa_supplicant/hostapd commit b26f5c0fe
Browse files Browse the repository at this point in the history
This is the December/January update to vendor/wpa committed upstream
2021-12-13.

(cherry picked from commit 32a9565)
  • Loading branch information
cschuber committed Feb 8, 2022
1 parent e3c87ef commit f3ba7fe
Show file tree
Hide file tree
Showing 52 changed files with 1,380 additions and 298 deletions.
3 changes: 3 additions & 0 deletions contrib/wpa/hostapd/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ NEED_ASN1=y
ifdef CONFIG_DPP2
L_CFLAGS += -DCONFIG_DPP2
endif
ifdef CONFIG_DPP3
L_CFLAGS += -DCONFIG_DPP3
endif
endif

ifdef CONFIG_PASN
Expand Down
3 changes: 3 additions & 0 deletions contrib/wpa/hostapd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@ NEED_ASN1=y
ifdef CONFIG_DPP2
CFLAGS += -DCONFIG_DPP2
endif
ifdef CONFIG_DPP3
CFLAGS += -DCONFIG_DPP3
endif
endif

ifdef CONFIG_PASN
Expand Down
10 changes: 10 additions & 0 deletions contrib/wpa/hostapd/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3193,6 +3193,16 @@ static int hostapd_config_fill(struct hostapd_config *conf,
conf->acs_freq_list_present = 1;
} else if (os_strcmp(buf, "acs_exclude_6ghz_non_psc") == 0) {
conf->acs_exclude_6ghz_non_psc = atoi(pos);
} else if (os_strcmp(buf, "min_tx_power") == 0) {
int val = atoi(pos);

if (val < 0 || val > 255) {
wpa_printf(MSG_ERROR,
"Line %d: invalid min_tx_power %d (expected 0..255)",
line, val);
return 1;
}
conf->min_tx_power = val;
} else if (os_strcmp(buf, "beacon_int") == 0) {
int val = atoi(pos);
/* MIB defines range as 1..65535, but very small values
Expand Down
10 changes: 7 additions & 3 deletions contrib/wpa/hostapd/ctrl_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
return -1;

val = atoi(value);
if (val < 0 || val > 1)
if (val < 0 || val > MBO_ASSOC_DISALLOW_REASON_LOW_RSSI)
return -1;

hapd->mbo_assoc_disallow = val;
Expand Down Expand Up @@ -3463,7 +3463,9 @@ static int hostapd_ctrl_iface_get_capability(struct hostapd_data *hapd,
if (os_strcmp(field, "dpp") == 0) {
int res;

#ifdef CONFIG_DPP2
#ifdef CONFIG_DPP3
res = os_snprintf(buf, buflen, "DPP=3");
#elif defined(CONFIG_DPP2)
res = os_snprintf(buf, buflen, "DPP=2");
#else /* CONFIG_DPP2 */
res = os_snprintf(buf, buflen, "DPP=1");
Expand Down Expand Up @@ -4492,7 +4494,9 @@ static void hostapd_ctrl_iface_flush(struct hapd_interfaces *interfaces)
#ifdef CONFIG_TESTING_OPTIONS
#ifdef CONFIG_DPP
dpp_test = DPP_TEST_DISABLED;
#ifdef CONFIG_DPP2
#ifdef CONFIG_DPP3
dpp_version_override = 3;
#elif defined(CONFIG_DPP2)
dpp_version_override = 2;
#else /* CONFIG_DPP2 */
dpp_version_override = 1;
Expand Down
8 changes: 8 additions & 0 deletions contrib/wpa/hostapd/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,11 @@ CONFIG_IPV6=y
# production use.
# This requires CONFIG_IEEE80211W=y to be enabled, too.
#CONFIG_PASN=y

# Device Provisioning Protocol (DPP) (also known as Wi-Fi Easy Connect)
CONFIG_DPP=y
# DPP version 2 support
CONFIG_DPP2=y
# DPP version 3 support (experimental and still changing; do not enable for
# production use)
#CONFIG_DPP3=y
4 changes: 4 additions & 0 deletions contrib/wpa/hostapd/hostapd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ channel=1
# Default behavior is to include all PSC and non-PSC channels.
#acs_exclude_6ghz_non_psc=1

# Set minimum permitted max TX power (in dBm) for ACS and DFS channel selection.
# (default 0, i.e., not constraint)
#min_tx_power=20

# Beacon interval in kus (1.024 ms) (default: 100; range 15..65535)
beacon_int=100

Expand Down
9 changes: 9 additions & 0 deletions contrib/wpa/src/ap/acs.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ static void acs_survey_mode_interference_factor(
if (!is_in_freqlist(iface, chan))
continue;

if (chan->max_tx_power < iface->conf->min_tx_power)
continue;

wpa_printf(MSG_DEBUG, "ACS: Survey analysis for channel %d (%d MHz)",
chan->chan, chan->freq);

Expand Down Expand Up @@ -673,6 +676,9 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
if (!is_in_freqlist(iface, chan))
continue;

if (chan->max_tx_power < iface->conf->min_tx_power)
continue;

if (!chan_bw_allowed(chan, bw, 1, 1)) {
wpa_printf(MSG_DEBUG,
"ACS: Channel %d: BW %u is not supported",
Expand Down Expand Up @@ -1047,6 +1053,9 @@ static int * acs_request_scan_add_freqs(struct hostapd_iface *iface,
if (!is_in_freqlist(iface, chan))
continue;

if (chan->max_tx_power < iface->conf->min_tx_power)
continue;

*freq++ = chan->freq;
}

Expand Down
3 changes: 3 additions & 0 deletions contrib/wpa/src/ap/ap_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct mesh_conf {
int dot11MeshRetryTimeout; /* msec */
int dot11MeshConfirmTimeout; /* msec */
int dot11MeshHoldingTimeout; /* msec */
int mesh_fwding;
};

#define MAX_STA_COUNT 2007
Expand Down Expand Up @@ -696,6 +697,7 @@ struct hostapd_bss_config {

#define MESH_ENABLED BIT(0)
int mesh;
int mesh_fwding;

u8 radio_measurements[RRM_CAPABILITIES_IE_LEN];

Expand Down Expand Up @@ -953,6 +955,7 @@ struct hostapd_config {
struct wpa_freq_range_list acs_freq_list;
u8 acs_freq_list_present;
int acs_exclude_dfs;
u8 min_tx_power;
enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
int acs_exclude_6ghz_non_psc;
enum {
Expand Down
3 changes: 2 additions & 1 deletion contrib/wpa/src/ap/ap_drv_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,8 @@ static void hostapd_get_hw_mode_any_channels(struct hostapd_data *hapd,
continue;
if (!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
!(hapd->iface->conf->acs_exclude_dfs &&
(chan->flag & HOSTAPD_CHAN_RADAR)))
(chan->flag & HOSTAPD_CHAN_RADAR)) &&
!(chan->max_tx_power < hapd->iface->conf->min_tx_power))
int_array_add_unique(freq_list, chan->freq);
}
}
Expand Down
8 changes: 2 additions & 6 deletions contrib/wpa/src/ap/beacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,7 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
pos = hostapd_eid_txpower_envelope(hapd, pos);
#endif /* CONFIG_IEEE80211AX */

if ((hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) ||
(hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax))
pos = hostapd_eid_wb_chsw_wrapper(hapd, pos);
pos = hostapd_eid_wb_chsw_wrapper(hapd, pos);

pos = hostapd_eid_rnr(hapd, pos, WLAN_FC_STYPE_PROBE_RESP);
pos = hostapd_eid_fils_indic(hapd, pos, 0);
Expand Down Expand Up @@ -1594,9 +1592,7 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
tailpos = hostapd_eid_txpower_envelope(hapd, tailpos);
#endif /* CONFIG_IEEE80211AX */

if ((hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) ||
(hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax))
tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos);
tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos);

tailpos = hostapd_eid_rnr(hapd, tailpos, WLAN_FC_STYPE_BEACON);
tailpos = hostapd_eid_fils_indic(hapd, tailpos, 0);
Expand Down
3 changes: 3 additions & 0 deletions contrib/wpa/src/ap/dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ static int dfs_find_channel(struct hostapd_iface *iface,
continue;
}

if (chan->max_tx_power < iface->conf->min_tx_power)
continue;

if (ret_chan && idx == channel_idx) {
wpa_printf(MSG_DEBUG, "Selected channel %d (%d)",
chan->freq, chan->chan);
Expand Down
69 changes: 62 additions & 7 deletions contrib/wpa/src/ap/dpp_hostapd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1554,17 +1554,38 @@ static void hostapd_dpp_send_peer_disc_resp(struct hostapd_data *hapd,

#ifdef CONFIG_TESTING_OPTIONS
skip_connector:
if (dpp_test == DPP_TEST_NO_PROTOCOL_VERSION_PEER_DISC_RESP) {
wpa_printf(MSG_INFO, "DPP: TESTING - no Protocol Version");
goto skip_proto_ver;
}
#endif /* CONFIG_TESTING_OPTIONS */

#ifdef CONFIG_DPP2
if (DPP_VERSION > 1) {
u8 ver = DPP_VERSION;
#ifdef CONFIG_DPP3
int conn_ver;

conn_ver = dpp_get_connector_version(hapd->conf->dpp_connector);
if (conn_ver > 0 && ver != conn_ver) {
wpa_printf(MSG_DEBUG,
"DPP: Use Connector version %d instead of current protocol version %d",
conn_ver, ver);
ver = conn_ver;
}
#endif /* CONFIG_DPP3 */

/* Protocol Version */
wpabuf_put_le16(msg, DPP_ATTR_PROTOCOL_VERSION);
wpabuf_put_le16(msg, 1);
wpabuf_put_u8(msg, DPP_VERSION);
wpabuf_put_u8(msg, ver);
}
#endif /* CONFIG_DPP2 */

#ifdef CONFIG_TESTING_OPTIONS
skip_proto_ver:
#endif /* CONFIG_TESTING_OPTIONS */

wpa_printf(MSG_DEBUG, "DPP: Send Peer Discovery Response to " MACSTR
" status=%d", MAC2STR(src), status);
wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
Expand Down Expand Up @@ -1648,6 +1669,28 @@ static void hostapd_dpp_rx_peer_disc_req(struct hostapd_data *hapd,
return;
}

#ifdef CONFIG_DPP3
if (intro.peer_version && intro.peer_version >= 2) {
const u8 *version;
u16 version_len;
u8 attr_version = 1;

version = dpp_get_attr(buf, len, DPP_ATTR_PROTOCOL_VERSION,
&version_len);
if (version && version_len >= 1)
attr_version = version[0];
if (attr_version != intro.peer_version) {
wpa_printf(MSG_INFO,
"DPP: Protocol version mismatch (Connector: %d Attribute: %d",
intro.peer_version, attr_version);
hostapd_dpp_send_peer_disc_resp(hapd, src, freq,
trans_id[0],
DPP_STATUS_NO_MATCH);
return;
}
}
#endif /* CONFIG_DPP3 */

if (!expire || (os_time_t) hapd->conf->dpp_netaccesskey_expiry < expire)
expire = hapd->conf->dpp_netaccesskey_expiry;
if (expire)
Expand All @@ -1670,7 +1713,7 @@ static void hostapd_dpp_rx_peer_disc_req(struct hostapd_data *hapd,
static void
hostapd_dpp_rx_pkex_exchange_req(struct hostapd_data *hapd, const u8 *src,
const u8 *buf, size_t len,
unsigned int freq)
unsigned int freq, bool v2)
{
struct wpabuf *msg;

Expand Down Expand Up @@ -1698,7 +1741,7 @@ hostapd_dpp_rx_pkex_exchange_req(struct hostapd_data *hapd, const u8 *src,
hapd->own_addr, src,
hapd->dpp_pkex_identifier,
hapd->dpp_pkex_code,
buf, len);
buf, len, v2);
if (!hapd->dpp_pkex) {
wpa_printf(MSG_DEBUG,
"DPP: Failed to process the request - ignore it");
Expand Down Expand Up @@ -1910,8 +1953,18 @@ void hostapd_dpp_rx_action(struct hostapd_data *hapd, const u8 *src,
case DPP_PA_PEER_DISCOVERY_REQ:
hostapd_dpp_rx_peer_disc_req(hapd, src, buf, len, freq);
break;
#ifdef CONFIG_DPP3
case DPP_PA_PKEX_EXCHANGE_REQ:
hostapd_dpp_rx_pkex_exchange_req(hapd, src, buf, len, freq);
/* This is for PKEXv2, but for now, process only with
* CONFIG_DPP3 to avoid issues with a capability that has not
* been tested with other implementations. */
hostapd_dpp_rx_pkex_exchange_req(hapd, src, buf, len, freq,
true);
break;
#endif /* CONFIG_DPP3 */
case DPP_PA_PKEX_V1_EXCHANGE_REQ:
hostapd_dpp_rx_pkex_exchange_req(hapd, src, buf, len, freq,
false);
break;
case DPP_PA_PKEX_EXCHANGE_RESP:
hostapd_dpp_rx_pkex_exchange_resp(hapd, src, buf, len, freq);
Expand Down Expand Up @@ -2118,23 +2171,25 @@ int hostapd_dpp_pkex_add(struct hostapd_data *hapd, const char *cmd)
if (!hapd->dpp_pkex_code)
return -1;

if (os_strstr(cmd, " init=1")) {
if (os_strstr(cmd, " init=1") || os_strstr(cmd, " init=2")) {
struct wpabuf *msg;
bool v2 = os_strstr(cmd, " init=2") != NULL;

wpa_printf(MSG_DEBUG, "DPP: Initiating PKEX");
dpp_pkex_free(hapd->dpp_pkex);
hapd->dpp_pkex = dpp_pkex_init(hapd->msg_ctx, own_bi,
hapd->own_addr,
hapd->dpp_pkex_identifier,
hapd->dpp_pkex_code);
hapd->dpp_pkex_code, v2);
if (!hapd->dpp_pkex)
return -1;

msg = hapd->dpp_pkex->exchange_req;
/* TODO: Which channel to use? */
wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR
" freq=%u type=%d", MAC2STR(broadcast), 2437,
DPP_PA_PKEX_EXCHANGE_REQ);
v2 ? DPP_PA_PKEX_EXCHANGE_REQ :
DPP_PA_PKEX_V1_EXCHANGE_REQ);
hostapd_drv_send_action(hapd, 2437, 0, broadcast,
wpabuf_head(msg), wpabuf_len(msg));
}
Expand Down
6 changes: 6 additions & 0 deletions contrib/wpa/src/ap/drv_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,12 @@ void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
hapd->iconf->ch_switch_vht_config = 0;
hapd->iconf->ch_switch_he_config = 0;

if (width == CHAN_WIDTH_40 || width == CHAN_WIDTH_80 ||
width == CHAN_WIDTH_80P80 || width == CHAN_WIDTH_160)
hapd->iconf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
else if (width == CHAN_WIDTH_20 || width == CHAN_WIDTH_20_NOHT)
hapd->iconf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;

hapd->iconf->secondary_channel = offset;
hostapd_set_oper_chwidth(hapd->iconf, chwidth);
hostapd_set_oper_centr_freq_seg0_idx(hapd->iconf, seg0_idx);
Expand Down
15 changes: 15 additions & 0 deletions contrib/wpa/src/ap/hostapd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3461,6 +3461,20 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd,
NULL))
return -1;

switch (params->bandwidth) {
case 0:
case 20:
conf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
break;
case 40:
case 80:
case 160:
conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
break;
default:
return -1;
}

switch (params->bandwidth) {
case 0:
case 20:
Expand All @@ -3482,6 +3496,7 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd,

conf->channel = channel;
conf->ieee80211n = params->ht_enabled;
conf->ieee80211ac = params->vht_enabled;
conf->secondary_channel = params->sec_channel_offset;
ieee80211_freq_to_chan(params->center_freq1,
&seg0);
Expand Down
Loading

0 comments on commit f3ba7fe

Please sign in to comment.