2011-09-08 19:52:23 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2009, Atheros Communications, Inc.
|
2013-01-08 22:51:16 +01:00
|
|
|
* Copyright (c) 2011-2013, Qualcomm Atheros, Inc.
|
2011-09-08 19:52:23 +02:00
|
|
|
*
|
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
2015-01-19 02:45:01 +01:00
|
|
|
#include <sys/stat.h>
|
2011-09-08 19:52:23 +02:00
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "eloop.h"
|
|
|
|
#include "common/ieee802_11_common.h"
|
|
|
|
#include "common/ieee802_11_defs.h"
|
|
|
|
#include "common/gas.h"
|
|
|
|
#include "common/wpa_ctrl.h"
|
2013-07-26 21:12:37 +02:00
|
|
|
#include "rsn_supp/wpa.h"
|
2011-09-08 19:52:23 +02:00
|
|
|
#include "wpa_supplicant_i.h"
|
|
|
|
#include "driver_i.h"
|
|
|
|
#include "config.h"
|
2013-01-25 23:10:41 +01:00
|
|
|
#include "scan.h"
|
2011-09-08 19:52:23 +02:00
|
|
|
#include "bss.h"
|
2021-02-07 16:06:19 +01:00
|
|
|
#include "bssid_ignore.h"
|
2011-09-08 19:52:23 +02:00
|
|
|
#include "gas_query.h"
|
|
|
|
#include "interworking.h"
|
|
|
|
#include "hs20_supplicant.h"
|
2015-12-11 02:01:46 +01:00
|
|
|
#include "base64.h"
|
2024-01-19 16:52:54 +01:00
|
|
|
#include "notify.h"
|
2011-09-08 19:52:23 +02:00
|
|
|
|
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
#define OSU_MAX_ITEMS 10
|
|
|
|
|
|
|
|
struct osu_lang_string {
|
|
|
|
char lang[4];
|
|
|
|
char text[253];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osu_icon {
|
|
|
|
u16 width;
|
|
|
|
u16 height;
|
|
|
|
char lang[4];
|
|
|
|
char icon_type[256];
|
|
|
|
char filename[256];
|
|
|
|
unsigned int id;
|
|
|
|
unsigned int failed:1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osu_provider {
|
|
|
|
u8 bssid[ETH_ALEN];
|
2015-04-07 11:00:13 +02:00
|
|
|
u8 osu_ssid[SSID_MAX_LEN];
|
2013-01-25 23:10:41 +01:00
|
|
|
u8 osu_ssid_len;
|
2018-09-12 01:52:50 +02:00
|
|
|
u8 osu_ssid2[SSID_MAX_LEN];
|
|
|
|
u8 osu_ssid2_len;
|
2013-01-25 23:10:41 +01:00
|
|
|
char server_uri[256];
|
|
|
|
u32 osu_methods; /* bit 0 = OMA-DM, bit 1 = SOAP-XML SPP */
|
|
|
|
char osu_nai[256];
|
2018-10-05 19:51:51 +02:00
|
|
|
char osu_nai2[256];
|
2013-01-25 23:10:41 +01:00
|
|
|
struct osu_lang_string friendly_name[OSU_MAX_ITEMS];
|
|
|
|
size_t friendly_name_count;
|
|
|
|
struct osu_lang_string serv_desc[OSU_MAX_ITEMS];
|
|
|
|
size_t serv_desc_count;
|
|
|
|
struct osu_icon icon[OSU_MAX_ITEMS];
|
|
|
|
size_t icon_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-04-06 16:14:41 +02:00
|
|
|
void hs20_configure_frame_filters(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
struct wpa_bss *bss = wpa_s->current_bss;
|
|
|
|
const u8 *ie;
|
|
|
|
const u8 *ext_capa;
|
|
|
|
u32 filter = 0;
|
|
|
|
|
|
|
|
if (!bss || !is_hs20_network(wpa_s, wpa_s->current_ssid, bss)) {
|
2023-12-22 15:54:15 +01:00
|
|
|
/* Not configuring frame filtering - BSS is not a Hotspot 2.0
|
|
|
|
* network */
|
2016-04-06 16:14:41 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ie = wpa_bss_get_vendor_ie(bss, HS20_IE_VENDOR_TYPE);
|
|
|
|
|
|
|
|
/* Check if DGAF disabled bit is zero (5th byte in the IE) */
|
|
|
|
if (!ie || ie[1] < 5)
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"Not configuring frame filtering - Can't extract DGAF bit");
|
|
|
|
else if (!(ie[6] & HS20_DGAF_DISABLED))
|
|
|
|
filter |= WPA_DATA_FRAME_FILTER_FLAG_GTK;
|
|
|
|
|
|
|
|
ext_capa = wpa_bss_get_ie(bss, WLAN_EID_EXT_CAPAB);
|
|
|
|
if (!ext_capa || ext_capa[1] < 2) {
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"Not configuring frame filtering - Can't extract Proxy ARP bit");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:56:41 +01:00
|
|
|
if (wpa_bss_ext_capab(bss, WLAN_EXT_CAPAB_PROXY_ARP))
|
2016-04-06 16:14:41 +02:00
|
|
|
filter |= WPA_DATA_FRAME_FILTER_FLAG_ARP |
|
|
|
|
WPA_DATA_FRAME_FILTER_FLAG_NA;
|
|
|
|
|
|
|
|
wpa_drv_configure_frame_filters(wpa_s, filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-07 23:51:04 +01:00
|
|
|
void wpas_hs20_add_indication(struct wpabuf *buf, int pps_mo_id, int ap_release)
|
2011-09-08 19:52:23 +02:00
|
|
|
{
|
2018-12-07 23:51:04 +01:00
|
|
|
int release;
|
2012-11-02 11:08:11 +01:00
|
|
|
u8 conf;
|
|
|
|
|
2018-12-07 23:51:04 +01:00
|
|
|
release = (HS20_VERSION >> 4) + 1;
|
|
|
|
if (ap_release > 0 && release > ap_release)
|
|
|
|
release = ap_release;
|
|
|
|
if (release < 2)
|
|
|
|
pps_mo_id = -1;
|
|
|
|
|
2011-09-08 19:52:23 +02:00
|
|
|
wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
|
2012-11-02 11:08:11 +01:00
|
|
|
wpabuf_put_u8(buf, pps_mo_id >= 0 ? 7 : 5);
|
2011-09-08 19:52:23 +02:00
|
|
|
wpabuf_put_be24(buf, OUI_WFA);
|
|
|
|
wpabuf_put_u8(buf, HS20_INDICATION_OUI_TYPE);
|
2018-12-07 23:51:04 +01:00
|
|
|
conf = (release - 1) << 4;
|
2012-11-02 11:08:11 +01:00
|
|
|
if (pps_mo_id >= 0)
|
|
|
|
conf |= HS20_PPS_MO_ID_PRESENT;
|
|
|
|
wpabuf_put_u8(buf, conf);
|
|
|
|
if (pps_mo_id >= 0)
|
|
|
|
wpabuf_put_le16(buf, pps_mo_id);
|
2011-09-08 19:52:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-17 16:22:56 +02:00
|
|
|
void wpas_hs20_add_roam_cons_sel(struct wpabuf *buf,
|
|
|
|
const struct wpa_ssid *ssid)
|
|
|
|
{
|
|
|
|
if (!ssid->roaming_consortium_selection ||
|
|
|
|
!ssid->roaming_consortium_selection_len)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
|
|
|
|
wpabuf_put_u8(buf, 4 + ssid->roaming_consortium_selection_len);
|
|
|
|
wpabuf_put_be24(buf, OUI_WFA);
|
|
|
|
wpabuf_put_u8(buf, HS20_ROAMING_CONS_SEL_OUI_TYPE);
|
|
|
|
wpabuf_put_data(buf, ssid->roaming_consortium_selection,
|
|
|
|
ssid->roaming_consortium_selection_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-07 23:51:04 +01:00
|
|
|
int get_hs20_version(struct wpa_bss *bss)
|
|
|
|
{
|
|
|
|
const u8 *ie;
|
|
|
|
|
|
|
|
if (!bss)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ie = wpa_bss_get_vendor_ie(bss, HS20_IE_VENDOR_TYPE);
|
|
|
|
if (!ie || ie[1] < 5)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return ((ie[6] >> 4) & 0x0f) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-05 15:29:21 +02:00
|
|
|
int is_hs20_network(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
|
|
|
|
struct wpa_bss *bss)
|
|
|
|
{
|
|
|
|
if (!wpa_s->conf->hs20 || !ssid)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (ssid->parent_cred)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (bss && !wpa_bss_get_vendor_ie(bss, HS20_IE_VENDOR_TYPE))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This may catch some non-Hotspot 2.0 cases, but it is safer to do that
|
|
|
|
* than cause Hotspot 2.0 connections without indication element getting
|
|
|
|
* added. Non-Hotspot 2.0 APs should ignore the unknown vendor element.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X))
|
|
|
|
return 0;
|
|
|
|
if (!(ssid->pairwise_cipher & WPA_CIPHER_CCMP))
|
|
|
|
return 0;
|
|
|
|
if (ssid->proto != WPA_PROTO_RSN)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-02 11:08:11 +01:00
|
|
|
int hs20_get_pps_mo_id(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
|
|
|
|
{
|
|
|
|
struct wpa_cred *cred;
|
|
|
|
|
2014-06-30 18:59:17 +02:00
|
|
|
if (ssid == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (ssid->update_identifier)
|
|
|
|
return ssid->update_identifier;
|
|
|
|
|
|
|
|
if (ssid->parent_cred == NULL)
|
2012-11-02 11:08:11 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (cred = wpa_s->conf->cred; cred; cred = cred->next) {
|
|
|
|
if (ssid->parent_cred == cred)
|
|
|
|
return cred->update_identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 01:36:13 +01:00
|
|
|
void hs20_put_anqp_req(u32 stypes, const u8 *payload, size_t payload_len,
|
|
|
|
struct wpabuf *buf)
|
2011-09-08 19:52:23 +02:00
|
|
|
{
|
|
|
|
u8 *len_pos;
|
|
|
|
|
|
|
|
if (buf == NULL)
|
2014-03-25 01:36:13 +01:00
|
|
|
return;
|
2011-09-08 19:52:23 +02:00
|
|
|
|
|
|
|
len_pos = gas_anqp_add_element(buf, ANQP_VENDOR_SPECIFIC);
|
|
|
|
wpabuf_put_be24(buf, OUI_WFA);
|
|
|
|
wpabuf_put_u8(buf, HS20_ANQP_OUI_TYPE);
|
|
|
|
if (stypes == BIT(HS20_STYPE_NAI_HOME_REALM_QUERY)) {
|
|
|
|
wpabuf_put_u8(buf, HS20_STYPE_NAI_HOME_REALM_QUERY);
|
|
|
|
wpabuf_put_u8(buf, 0); /* Reserved */
|
|
|
|
if (payload)
|
|
|
|
wpabuf_put_data(buf, payload, payload_len);
|
2012-12-20 20:15:05 +01:00
|
|
|
} else if (stypes == BIT(HS20_STYPE_ICON_REQUEST)) {
|
|
|
|
wpabuf_put_u8(buf, HS20_STYPE_ICON_REQUEST);
|
|
|
|
wpabuf_put_u8(buf, 0); /* Reserved */
|
|
|
|
if (payload)
|
|
|
|
wpabuf_put_data(buf, payload, payload_len);
|
2011-09-08 19:52:23 +02:00
|
|
|
} else {
|
|
|
|
u8 i;
|
|
|
|
wpabuf_put_u8(buf, HS20_STYPE_QUERY_LIST);
|
|
|
|
wpabuf_put_u8(buf, 0); /* Reserved */
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
if (stypes & BIT(i))
|
|
|
|
wpabuf_put_u8(buf, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gas_anqp_set_element_len(buf, len_pos);
|
|
|
|
|
|
|
|
gas_anqp_set_len(buf);
|
2014-03-25 01:36:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-11 20:03:09 +02:00
|
|
|
static struct wpabuf * hs20_build_anqp_req(u32 stypes, const u8 *payload,
|
|
|
|
size_t payload_len)
|
2014-03-25 01:36:13 +01:00
|
|
|
{
|
|
|
|
struct wpabuf *buf;
|
|
|
|
|
|
|
|
buf = gas_anqp_build_initial_req(0, 100 + payload_len);
|
|
|
|
if (buf == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hs20_put_anqp_req(stypes, payload, payload_len, buf);
|
2011-09-08 19:52:23 +02:00
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hs20_anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst, u32 stypes,
|
2015-12-11 02:01:46 +01:00
|
|
|
const u8 *payload, size_t payload_len, int inmem)
|
2011-09-08 19:52:23 +02:00
|
|
|
{
|
|
|
|
struct wpabuf *buf;
|
|
|
|
int ret = 0;
|
|
|
|
int freq;
|
|
|
|
struct wpa_bss *bss;
|
|
|
|
int res;
|
2015-12-11 02:01:46 +01:00
|
|
|
struct icon_entry *icon_entry;
|
2011-09-08 19:52:23 +02:00
|
|
|
|
|
|
|
bss = wpa_bss_get_bssid(wpa_s, dst);
|
2015-04-28 13:01:04 +02:00
|
|
|
if (!bss) {
|
|
|
|
wpa_printf(MSG_WARNING,
|
|
|
|
"ANQP: Cannot send query to unknown BSS "
|
|
|
|
MACSTR, MAC2STR(dst));
|
2011-09-08 19:52:23 +02:00
|
|
|
return -1;
|
2015-04-28 13:01:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wpa_bss_anqp_unshare_alloc(bss);
|
|
|
|
freq = bss->freq;
|
2011-09-08 19:52:23 +02:00
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "HS20: ANQP Query Request to " MACSTR " for "
|
|
|
|
"subtypes 0x%x", MAC2STR(dst), stypes);
|
|
|
|
|
|
|
|
buf = hs20_build_anqp_req(stypes, payload, payload_len);
|
|
|
|
if (buf == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2020-04-22 16:04:43 +02:00
|
|
|
res = gas_query_req(wpa_s->gas, dst, freq, 0, 0, buf, anqp_resp_cb,
|
|
|
|
wpa_s);
|
2011-09-08 19:52:23 +02:00
|
|
|
if (res < 0) {
|
|
|
|
wpa_printf(MSG_DEBUG, "ANQP: Failed to send Query Request");
|
2013-10-21 12:13:42 +02:00
|
|
|
wpabuf_free(buf);
|
2015-12-11 02:01:46 +01:00
|
|
|
return -1;
|
2011-09-08 19:52:23 +02:00
|
|
|
} else
|
|
|
|
wpa_printf(MSG_DEBUG, "ANQP: Query started with dialog token "
|
|
|
|
"%u", res);
|
|
|
|
|
2015-12-11 02:01:46 +01:00
|
|
|
if (inmem) {
|
|
|
|
icon_entry = os_zalloc(sizeof(struct icon_entry));
|
|
|
|
if (!icon_entry)
|
|
|
|
return -1;
|
|
|
|
os_memcpy(icon_entry->bssid, dst, ETH_ALEN);
|
|
|
|
icon_entry->file_name = os_malloc(payload_len + 1);
|
|
|
|
if (!icon_entry->file_name) {
|
|
|
|
os_free(icon_entry);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
os_memcpy(icon_entry->file_name, payload, payload_len);
|
|
|
|
icon_entry->file_name[payload_len] = '\0';
|
|
|
|
icon_entry->dialog_token = res;
|
|
|
|
|
2015-12-19 17:49:32 +01:00
|
|
|
dl_list_add(&wpa_s->icon_head, &icon_entry->list);
|
2015-12-11 02:01:46 +01:00
|
|
|
}
|
|
|
|
|
2011-09-08 19:52:23 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-11 02:01:46 +01:00
|
|
|
static struct icon_entry * hs20_find_icon(struct wpa_supplicant *wpa_s,
|
|
|
|
const u8 *bssid,
|
|
|
|
const char *file_name)
|
|
|
|
{
|
|
|
|
struct icon_entry *icon;
|
|
|
|
|
2015-12-19 17:49:32 +01:00
|
|
|
dl_list_for_each(icon, &wpa_s->icon_head, struct icon_entry, list) {
|
Use ether_addr_equal() to compare whether two MAC addresses are equal
This was done with spatch using the following semantic patch and minor
manual edits to clean up coding style and avoid compiler warnings in
driver_wext.c:
@@
expression a,b;
@@
- os_memcmp(a, b, ETH_ALEN) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- os_memcmp(a, b, ETH_ALEN) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !os_memcmp(a, b, ETH_ALEN)
+ ether_addr_equal(a, b)
Signed-off-by: Jouni Malinen <j@w1.fi>
2024-01-13 22:15:36 +01:00
|
|
|
if (ether_addr_equal(icon->bssid, bssid) &&
|
2015-12-11 02:01:46 +01:00
|
|
|
os_strcmp(icon->file_name, file_name) == 0 && icon->image)
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hs20_get_icon(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
|
|
|
const char *file_name, size_t offset, size_t size,
|
|
|
|
char *reply, size_t buf_len)
|
|
|
|
{
|
|
|
|
struct icon_entry *icon;
|
|
|
|
size_t out_size;
|
2019-11-27 14:55:33 +01:00
|
|
|
char *b64;
|
2015-12-11 02:01:46 +01:00
|
|
|
size_t b64_size;
|
|
|
|
int reply_size;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "HS20: Get icon " MACSTR " %s @ %u +%u (%u)",
|
|
|
|
MAC2STR(bssid), file_name, (unsigned int) offset,
|
|
|
|
(unsigned int) size, (unsigned int) buf_len);
|
|
|
|
|
|
|
|
icon = hs20_find_icon(wpa_s, bssid, file_name);
|
|
|
|
if (!icon || !icon->image || offset >= icon->image_len)
|
|
|
|
return -1;
|
|
|
|
if (size > icon->image_len - offset)
|
|
|
|
size = icon->image_len - offset;
|
|
|
|
out_size = buf_len - 3 /* max base64 padding */;
|
|
|
|
if (size * 4 > out_size * 3)
|
|
|
|
size = out_size * 3 / 4;
|
|
|
|
if (size == 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
b64 = base64_encode(&icon->image[offset], size, &b64_size);
|
2016-07-04 18:34:22 +02:00
|
|
|
if (b64 && buf_len >= b64_size) {
|
2015-12-11 02:01:46 +01:00
|
|
|
os_memcpy(reply, b64, b64_size);
|
|
|
|
reply_size = b64_size;
|
|
|
|
} else {
|
|
|
|
reply_size = -1;
|
|
|
|
}
|
|
|
|
os_free(b64);
|
|
|
|
return reply_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hs20_free_icon_entry(struct icon_entry *icon)
|
|
|
|
{
|
|
|
|
wpa_printf(MSG_DEBUG, "HS20: Free stored icon from " MACSTR
|
|
|
|
" dialog_token=%u file_name=%s image_len=%u",
|
|
|
|
MAC2STR(icon->bssid), icon->dialog_token,
|
|
|
|
icon->file_name ? icon->file_name : "N/A",
|
|
|
|
(unsigned int) icon->image_len);
|
|
|
|
os_free(icon->file_name);
|
|
|
|
os_free(icon->image);
|
|
|
|
os_free(icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hs20_del_icon(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
|
|
|
const char *file_name)
|
|
|
|
{
|
2015-12-19 17:49:32 +01:00
|
|
|
struct icon_entry *icon, *tmp;
|
2015-12-11 02:01:46 +01:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (!bssid)
|
|
|
|
wpa_printf(MSG_DEBUG, "HS20: Delete all stored icons");
|
|
|
|
else if (!file_name)
|
|
|
|
wpa_printf(MSG_DEBUG, "HS20: Delete all stored icons for "
|
|
|
|
MACSTR, MAC2STR(bssid));
|
|
|
|
else
|
|
|
|
wpa_printf(MSG_DEBUG, "HS20: Delete stored icons for "
|
|
|
|
MACSTR " file name %s", MAC2STR(bssid), file_name);
|
|
|
|
|
2015-12-19 17:49:32 +01:00
|
|
|
dl_list_for_each_safe(icon, tmp, &wpa_s->icon_head, struct icon_entry,
|
|
|
|
list) {
|
Use ether_addr_equal() to compare whether two MAC addresses are equal
This was done with spatch using the following semantic patch and minor
manual edits to clean up coding style and avoid compiler warnings in
driver_wext.c:
@@
expression a,b;
@@
- os_memcmp(a, b, ETH_ALEN) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- os_memcmp(a, b, ETH_ALEN) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !os_memcmp(a, b, ETH_ALEN)
+ ether_addr_equal(a, b)
Signed-off-by: Jouni Malinen <j@w1.fi>
2024-01-13 22:15:36 +01:00
|
|
|
if ((!bssid || ether_addr_equal(icon->bssid, bssid)) &&
|
2015-12-11 02:01:46 +01:00
|
|
|
(!file_name ||
|
2015-12-19 17:49:32 +01:00
|
|
|
os_strcmp(icon->file_name, file_name) == 0)) {
|
|
|
|
dl_list_del(&icon->list);
|
|
|
|
hs20_free_icon_entry(icon);
|
2015-12-11 02:01:46 +01:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count == 0 ? -1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 02:45:01 +01:00
|
|
|
static void hs20_set_osu_access_permission(const char *osu_dir,
|
|
|
|
const char *fname)
|
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
|
|
|
|
/* Get OSU directory information */
|
|
|
|
if (stat(osu_dir, &statbuf) < 0) {
|
|
|
|
wpa_printf(MSG_WARNING, "Cannot stat the OSU directory %s",
|
|
|
|
osu_dir);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chmod(fname, statbuf.st_mode) < 0) {
|
|
|
|
wpa_printf(MSG_WARNING,
|
|
|
|
"Cannot change the permissions for %s", fname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-06 19:28:04 +01:00
|
|
|
if (lchown(fname, statbuf.st_uid, statbuf.st_gid) < 0) {
|
2015-01-19 02:45:01 +01:00
|
|
|
wpa_printf(MSG_WARNING, "Cannot change the ownership for %s",
|
|
|
|
fname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-19 17:53:27 +01:00
|
|
|
|
|
|
|
static void hs20_remove_duplicate_icons(struct wpa_supplicant *wpa_s,
|
|
|
|
struct icon_entry *new_icon)
|
|
|
|
{
|
|
|
|
struct icon_entry *icon, *tmp;
|
|
|
|
|
|
|
|
dl_list_for_each_safe(icon, tmp, &wpa_s->icon_head, struct icon_entry,
|
|
|
|
list) {
|
|
|
|
if (icon == new_icon)
|
|
|
|
continue;
|
Use ether_addr_equal() to compare whether two MAC addresses are equal
This was done with spatch using the following semantic patch and minor
manual edits to clean up coding style and avoid compiler warnings in
driver_wext.c:
@@
expression a,b;
@@
- os_memcmp(a, b, ETH_ALEN) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- os_memcmp(a, b, ETH_ALEN) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !os_memcmp(a, b, ETH_ALEN)
+ ether_addr_equal(a, b)
Signed-off-by: Jouni Malinen <j@w1.fi>
2024-01-13 22:15:36 +01:00
|
|
|
if (ether_addr_equal(icon->bssid, new_icon->bssid) &&
|
2015-12-19 17:53:27 +01:00
|
|
|
os_strcmp(icon->file_name, new_icon->file_name) == 0) {
|
|
|
|
dl_list_del(&icon->list);
|
|
|
|
hs20_free_icon_entry(icon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
static int hs20_process_icon_binary_file(struct wpa_supplicant *wpa_s,
|
|
|
|
const u8 *sa, const u8 *pos,
|
2015-12-11 02:01:46 +01:00
|
|
|
size_t slen, u8 dialog_token)
|
2013-01-25 23:10:41 +01:00
|
|
|
{
|
|
|
|
char fname[256];
|
|
|
|
int png;
|
|
|
|
FILE *f;
|
|
|
|
u16 data_len;
|
2015-12-11 02:01:46 +01:00
|
|
|
struct icon_entry *icon;
|
|
|
|
|
2015-12-19 17:49:32 +01:00
|
|
|
dl_list_for_each(icon, &wpa_s->icon_head, struct icon_entry, list) {
|
2015-12-11 02:01:46 +01:00
|
|
|
if (icon->dialog_token == dialog_token && !icon->image &&
|
Use ether_addr_equal() to compare whether two MAC addresses are equal
This was done with spatch using the following semantic patch and minor
manual edits to clean up coding style and avoid compiler warnings in
driver_wext.c:
@@
expression a,b;
@@
- os_memcmp(a, b, ETH_ALEN) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- os_memcmp(a, b, ETH_ALEN) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !os_memcmp(a, b, ETH_ALEN)
+ ether_addr_equal(a, b)
Signed-off-by: Jouni Malinen <j@w1.fi>
2024-01-13 22:15:36 +01:00
|
|
|
ether_addr_equal(icon->bssid, sa)) {
|
2017-03-07 10:17:23 +01:00
|
|
|
icon->image = os_memdup(pos, slen);
|
2015-12-11 02:01:46 +01:00
|
|
|
if (!icon->image)
|
|
|
|
return -1;
|
|
|
|
icon->image_len = slen;
|
2015-12-19 17:53:27 +01:00
|
|
|
hs20_remove_duplicate_icons(wpa_s, icon);
|
2015-12-11 02:01:46 +01:00
|
|
|
wpa_msg(wpa_s, MSG_INFO,
|
2016-07-11 20:50:41 +02:00
|
|
|
RX_HS20_ICON MACSTR " %s %u",
|
2015-12-11 02:01:46 +01:00
|
|
|
MAC2STR(sa), icon->file_name,
|
|
|
|
(unsigned int) icon->image_len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2013-01-25 23:10:41 +01:00
|
|
|
|
2016-07-11 20:50:41 +02:00
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP MACSTR " Icon Binary File",
|
2013-01-25 23:10:41 +01:00
|
|
|
MAC2STR(sa));
|
|
|
|
|
|
|
|
if (slen < 4) {
|
|
|
|
wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short Icon Binary File "
|
|
|
|
"value from " MACSTR, MAC2STR(sa));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Download Status Code %u", *pos);
|
|
|
|
if (*pos != 0)
|
|
|
|
return -1;
|
|
|
|
pos++;
|
|
|
|
slen--;
|
|
|
|
|
|
|
|
if ((size_t) 1 + pos[0] > slen) {
|
|
|
|
wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short Icon Binary File "
|
|
|
|
"value from " MACSTR, MAC2STR(sa));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
wpa_hexdump_ascii(MSG_DEBUG, "Icon Type", pos + 1, pos[0]);
|
|
|
|
png = os_strncasecmp((char *) pos + 1, "image/png", 9) == 0;
|
|
|
|
slen -= 1 + pos[0];
|
|
|
|
pos += 1 + pos[0];
|
|
|
|
|
|
|
|
if (slen < 2) {
|
|
|
|
wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short Icon Binary File "
|
|
|
|
"value from " MACSTR, MAC2STR(sa));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
data_len = WPA_GET_LE16(pos);
|
|
|
|
pos += 2;
|
|
|
|
slen -= 2;
|
|
|
|
|
|
|
|
if (data_len > slen) {
|
|
|
|
wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short Icon Binary File "
|
|
|
|
"value from " MACSTR, MAC2STR(sa));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "Icon Binary Data: %u bytes", data_len);
|
|
|
|
if (wpa_s->conf->osu_dir == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
wpa_s->osu_icon_id++;
|
|
|
|
if (wpa_s->osu_icon_id == 0)
|
|
|
|
wpa_s->osu_icon_id++;
|
|
|
|
snprintf(fname, sizeof(fname), "%s/osu-icon-%u.%s",
|
|
|
|
wpa_s->conf->osu_dir, wpa_s->osu_icon_id,
|
|
|
|
png ? "png" : "icon");
|
|
|
|
f = fopen(fname, "wb");
|
|
|
|
if (f == NULL)
|
|
|
|
return -1;
|
2015-01-19 02:45:01 +01:00
|
|
|
|
|
|
|
hs20_set_osu_access_permission(wpa_s->conf->osu_dir, fname);
|
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
if (fwrite(pos, slen, 1, f) != 1) {
|
|
|
|
fclose(f);
|
|
|
|
unlink(fname);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
|
2016-07-11 20:50:41 +02:00
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP_ICON "%s", fname);
|
2013-01-25 23:10:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hs20_continue_icon_fetch(void *eloop_ctx, void *sock_ctx)
|
|
|
|
{
|
|
|
|
struct wpa_supplicant *wpa_s = eloop_ctx;
|
|
|
|
if (wpa_s->fetch_osu_icon_in_progress)
|
|
|
|
hs20_next_osu_icon(wpa_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hs20_osu_icon_fetch_result(struct wpa_supplicant *wpa_s, int res)
|
|
|
|
{
|
|
|
|
size_t i, j;
|
2013-06-15 05:41:51 +02:00
|
|
|
struct os_reltime now, tmp;
|
|
|
|
int dur;
|
|
|
|
|
|
|
|
os_get_reltime(&now);
|
|
|
|
os_reltime_sub(&now, &wpa_s->osu_icon_fetch_start, &tmp);
|
|
|
|
dur = tmp.sec * 1000 + tmp.usec / 1000;
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Icon fetch dur=%d ms res=%d",
|
|
|
|
dur, res);
|
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
for (i = 0; i < wpa_s->osu_prov_count; i++) {
|
|
|
|
struct osu_provider *osu = &wpa_s->osu_prov[i];
|
|
|
|
for (j = 0; j < osu->icon_count; j++) {
|
|
|
|
struct osu_icon *icon = &osu->icon[j];
|
|
|
|
if (icon->id || icon->failed)
|
|
|
|
continue;
|
|
|
|
if (res < 0)
|
|
|
|
icon->failed = 1;
|
|
|
|
else
|
|
|
|
icon->id = wpa_s->osu_icon_id;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-08 19:52:23 +02:00
|
|
|
void hs20_parse_rx_hs20_anqp_resp(struct wpa_supplicant *wpa_s,
|
2015-01-17 16:47:32 +01:00
|
|
|
struct wpa_bss *bss, const u8 *sa,
|
2015-12-11 02:01:46 +01:00
|
|
|
const u8 *data, size_t slen, u8 dialog_token)
|
2011-09-08 19:52:23 +02:00
|
|
|
{
|
|
|
|
const u8 *pos = data;
|
|
|
|
u8 subtype;
|
2012-09-04 15:02:29 +02:00
|
|
|
struct wpa_bss_anqp *anqp = NULL;
|
2013-01-25 23:10:41 +01:00
|
|
|
int ret;
|
2011-09-08 19:52:23 +02:00
|
|
|
|
|
|
|
if (slen < 2)
|
|
|
|
return;
|
|
|
|
|
2012-09-04 15:02:29 +02:00
|
|
|
if (bss)
|
|
|
|
anqp = bss->anqp;
|
|
|
|
|
2011-09-08 19:52:23 +02:00
|
|
|
subtype = *pos++;
|
|
|
|
slen--;
|
|
|
|
|
|
|
|
pos++; /* Reserved */
|
|
|
|
slen--;
|
|
|
|
|
|
|
|
switch (subtype) {
|
|
|
|
case HS20_STYPE_CAPABILITY_LIST:
|
2016-07-11 20:50:41 +02:00
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP MACSTR
|
2011-09-08 19:52:23 +02:00
|
|
|
" HS Capability List", MAC2STR(sa));
|
|
|
|
wpa_hexdump_ascii(MSG_DEBUG, "HS Capability List", pos, slen);
|
2015-02-18 03:35:09 +01:00
|
|
|
if (anqp) {
|
|
|
|
wpabuf_free(anqp->hs20_capability_list);
|
|
|
|
anqp->hs20_capability_list =
|
|
|
|
wpabuf_alloc_copy(pos, slen);
|
|
|
|
}
|
2011-09-08 19:52:23 +02:00
|
|
|
break;
|
|
|
|
case HS20_STYPE_OPERATOR_FRIENDLY_NAME:
|
2016-07-11 20:50:41 +02:00
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP MACSTR
|
2011-09-08 19:52:23 +02:00
|
|
|
" Operator Friendly Name", MAC2STR(sa));
|
|
|
|
wpa_hexdump_ascii(MSG_DEBUG, "oper friendly name", pos, slen);
|
2012-09-04 15:02:29 +02:00
|
|
|
if (anqp) {
|
|
|
|
wpabuf_free(anqp->hs20_operator_friendly_name);
|
|
|
|
anqp->hs20_operator_friendly_name =
|
2011-09-08 19:52:23 +02:00
|
|
|
wpabuf_alloc_copy(pos, slen);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case HS20_STYPE_WAN_METRICS:
|
2012-10-03 12:58:56 +02:00
|
|
|
wpa_hexdump(MSG_DEBUG, "WAN Metrics", pos, slen);
|
|
|
|
if (slen < 13) {
|
|
|
|
wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short WAN "
|
|
|
|
"Metrics value from " MACSTR, MAC2STR(sa));
|
|
|
|
break;
|
|
|
|
}
|
2016-07-11 20:50:41 +02:00
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP MACSTR
|
2012-10-03 12:58:56 +02:00
|
|
|
" WAN Metrics %02x:%u:%u:%u:%u:%u", MAC2STR(sa),
|
|
|
|
pos[0], WPA_GET_LE32(pos + 1), WPA_GET_LE32(pos + 5),
|
|
|
|
pos[9], pos[10], WPA_GET_LE16(pos + 11));
|
2012-09-04 15:02:29 +02:00
|
|
|
if (anqp) {
|
|
|
|
wpabuf_free(anqp->hs20_wan_metrics);
|
|
|
|
anqp->hs20_wan_metrics = wpabuf_alloc_copy(pos, slen);
|
2011-09-08 19:52:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case HS20_STYPE_CONNECTION_CAPABILITY:
|
2016-07-11 20:50:41 +02:00
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP MACSTR
|
2011-09-08 19:52:23 +02:00
|
|
|
" Connection Capability", MAC2STR(sa));
|
|
|
|
wpa_hexdump_ascii(MSG_DEBUG, "conn capability", pos, slen);
|
2012-09-04 15:02:29 +02:00
|
|
|
if (anqp) {
|
|
|
|
wpabuf_free(anqp->hs20_connection_capability);
|
|
|
|
anqp->hs20_connection_capability =
|
2011-09-08 19:52:23 +02:00
|
|
|
wpabuf_alloc_copy(pos, slen);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case HS20_STYPE_OPERATING_CLASS:
|
2016-07-11 20:50:41 +02:00
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP MACSTR
|
2011-09-08 19:52:23 +02:00
|
|
|
" Operating Class", MAC2STR(sa));
|
|
|
|
wpa_hexdump_ascii(MSG_DEBUG, "Operating Class", pos, slen);
|
2012-09-04 15:02:29 +02:00
|
|
|
if (anqp) {
|
|
|
|
wpabuf_free(anqp->hs20_operating_class);
|
|
|
|
anqp->hs20_operating_class =
|
2011-09-08 19:52:23 +02:00
|
|
|
wpabuf_alloc_copy(pos, slen);
|
|
|
|
}
|
|
|
|
break;
|
2013-01-08 22:51:16 +01:00
|
|
|
case HS20_STYPE_OSU_PROVIDERS_LIST:
|
2016-07-11 20:50:41 +02:00
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP MACSTR
|
2013-01-08 22:51:16 +01:00
|
|
|
" OSU Providers list", MAC2STR(sa));
|
2013-12-13 03:39:00 +01:00
|
|
|
wpa_s->num_prov_found++;
|
2013-01-08 22:51:16 +01:00
|
|
|
if (anqp) {
|
|
|
|
wpabuf_free(anqp->hs20_osu_providers_list);
|
|
|
|
anqp->hs20_osu_providers_list =
|
|
|
|
wpabuf_alloc_copy(pos, slen);
|
|
|
|
}
|
|
|
|
break;
|
2012-12-20 20:15:05 +01:00
|
|
|
case HS20_STYPE_ICON_BINARY_FILE:
|
2015-12-11 02:01:46 +01:00
|
|
|
ret = hs20_process_icon_binary_file(wpa_s, sa, pos, slen,
|
|
|
|
dialog_token);
|
2013-01-25 23:10:41 +01:00
|
|
|
if (wpa_s->fetch_osu_icon_in_progress) {
|
|
|
|
hs20_osu_icon_fetch_result(wpa_s, ret);
|
|
|
|
eloop_cancel_timeout(hs20_continue_icon_fetch,
|
|
|
|
wpa_s, NULL);
|
|
|
|
eloop_register_timeout(0, 0, hs20_continue_icon_fetch,
|
|
|
|
wpa_s, NULL);
|
|
|
|
}
|
|
|
|
break;
|
2018-04-16 12:16:39 +02:00
|
|
|
case HS20_STYPE_OPERATOR_ICON_METADATA:
|
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP MACSTR
|
|
|
|
" Operator Icon Metadata", MAC2STR(sa));
|
|
|
|
wpa_hexdump(MSG_DEBUG, "Operator Icon Metadata", pos, slen);
|
|
|
|
if (anqp) {
|
|
|
|
wpabuf_free(anqp->hs20_operator_icon_metadata);
|
|
|
|
anqp->hs20_operator_icon_metadata =
|
|
|
|
wpabuf_alloc_copy(pos, slen);
|
|
|
|
}
|
|
|
|
break;
|
2018-10-05 19:51:51 +02:00
|
|
|
case HS20_STYPE_OSU_PROVIDERS_NAI_LIST:
|
|
|
|
wpa_msg(wpa_s, MSG_INFO, RX_HS20_ANQP MACSTR
|
|
|
|
" OSU Providers NAI List", MAC2STR(sa));
|
|
|
|
if (anqp) {
|
|
|
|
wpabuf_free(anqp->hs20_osu_providers_nai_list);
|
|
|
|
anqp->hs20_osu_providers_nai_list =
|
|
|
|
wpabuf_alloc_copy(pos, slen);
|
|
|
|
}
|
|
|
|
break;
|
2013-01-25 23:10:41 +01:00
|
|
|
default:
|
|
|
|
wpa_printf(MSG_DEBUG, "HS20: Unsupported subtype %u", subtype);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void hs20_notify_parse_done(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
if (!wpa_s->fetch_osu_icon_in_progress)
|
|
|
|
return;
|
|
|
|
if (eloop_is_timeout_registered(hs20_continue_icon_fetch, wpa_s, NULL))
|
|
|
|
return;
|
|
|
|
/*
|
|
|
|
* We are going through icon fetch, but no icon response was received.
|
|
|
|
* Assume this means the current AP could not provide an answer to avoid
|
|
|
|
* getting stuck in fetch iteration.
|
|
|
|
*/
|
|
|
|
hs20_icon_fetch_failed(wpa_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hs20_free_osu_prov_entry(struct osu_provider *prov)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void hs20_free_osu_prov(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < wpa_s->osu_prov_count; i++)
|
|
|
|
hs20_free_osu_prov_entry(&wpa_s->osu_prov[i]);
|
|
|
|
os_free(wpa_s->osu_prov);
|
|
|
|
wpa_s->osu_prov = NULL;
|
|
|
|
wpa_s->osu_prov_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hs20_osu_fetch_done(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
char fname[256];
|
|
|
|
FILE *f;
|
|
|
|
size_t i, j;
|
|
|
|
|
|
|
|
wpa_s->fetch_osu_info = 0;
|
|
|
|
wpa_s->fetch_osu_icon_in_progress = 0;
|
2012-12-20 20:15:05 +01:00
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
if (wpa_s->conf->osu_dir == NULL) {
|
|
|
|
hs20_free_osu_prov(wpa_s);
|
|
|
|
wpa_s->fetch_anqp_in_progress = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(fname, sizeof(fname), "%s/osu-providers.txt",
|
|
|
|
wpa_s->conf->osu_dir);
|
|
|
|
f = fopen(fname, "w");
|
|
|
|
if (f == NULL) {
|
2016-07-15 12:21:12 +02:00
|
|
|
wpa_msg(wpa_s, MSG_INFO,
|
|
|
|
"Could not write OSU provider information");
|
2013-01-25 23:10:41 +01:00
|
|
|
hs20_free_osu_prov(wpa_s);
|
2016-03-01 19:26:38 +01:00
|
|
|
wpa_s->fetch_anqp_in_progress = 0;
|
2013-01-25 23:10:41 +01:00
|
|
|
return;
|
|
|
|
}
|
2015-01-19 02:45:01 +01:00
|
|
|
|
|
|
|
hs20_set_osu_access_permission(wpa_s->conf->osu_dir, fname);
|
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
for (i = 0; i < wpa_s->osu_prov_count; i++) {
|
|
|
|
struct osu_provider *osu = &wpa_s->osu_prov[i];
|
|
|
|
if (i > 0)
|
|
|
|
fprintf(f, "\n");
|
|
|
|
fprintf(f, "OSU-PROVIDER " MACSTR "\n"
|
|
|
|
"uri=%s\n"
|
|
|
|
"methods=%08x\n",
|
|
|
|
MAC2STR(osu->bssid), osu->server_uri, osu->osu_methods);
|
|
|
|
if (osu->osu_ssid_len) {
|
|
|
|
fprintf(f, "osu_ssid=%s\n",
|
|
|
|
wpa_ssid_txt(osu->osu_ssid,
|
|
|
|
osu->osu_ssid_len));
|
|
|
|
}
|
2018-09-12 01:52:50 +02:00
|
|
|
if (osu->osu_ssid2_len) {
|
|
|
|
fprintf(f, "osu_ssid2=%s\n",
|
|
|
|
wpa_ssid_txt(osu->osu_ssid2,
|
|
|
|
osu->osu_ssid2_len));
|
|
|
|
}
|
2013-01-25 23:10:41 +01:00
|
|
|
if (osu->osu_nai[0])
|
|
|
|
fprintf(f, "osu_nai=%s\n", osu->osu_nai);
|
2018-10-05 19:51:51 +02:00
|
|
|
if (osu->osu_nai2[0])
|
|
|
|
fprintf(f, "osu_nai2=%s\n", osu->osu_nai2);
|
2013-01-25 23:10:41 +01:00
|
|
|
for (j = 0; j < osu->friendly_name_count; j++) {
|
|
|
|
fprintf(f, "friendly_name=%s:%s\n",
|
|
|
|
osu->friendly_name[j].lang,
|
|
|
|
osu->friendly_name[j].text);
|
|
|
|
}
|
|
|
|
for (j = 0; j < osu->serv_desc_count; j++) {
|
|
|
|
fprintf(f, "desc=%s:%s\n",
|
|
|
|
osu->serv_desc[j].lang,
|
|
|
|
osu->serv_desc[j].text);
|
|
|
|
}
|
|
|
|
for (j = 0; j < osu->icon_count; j++) {
|
|
|
|
struct osu_icon *icon = &osu->icon[j];
|
|
|
|
if (icon->failed)
|
|
|
|
continue; /* could not fetch icon */
|
|
|
|
fprintf(f, "icon=%u:%u:%u:%s:%s:%s\n",
|
|
|
|
icon->id, icon->width, icon->height, icon->lang,
|
|
|
|
icon->icon_type, icon->filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
hs20_free_osu_prov(wpa_s);
|
|
|
|
|
|
|
|
wpa_msg(wpa_s, MSG_INFO, "OSU provider fetch completed");
|
|
|
|
wpa_s->fetch_anqp_in_progress = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void hs20_next_osu_icon(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
size_t i, j;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Ready to fetch next icon");
|
|
|
|
|
|
|
|
for (i = 0; i < wpa_s->osu_prov_count; i++) {
|
|
|
|
struct osu_provider *osu = &wpa_s->osu_prov[i];
|
|
|
|
for (j = 0; j < osu->icon_count; j++) {
|
|
|
|
struct osu_icon *icon = &osu->icon[j];
|
|
|
|
if (icon->id || icon->failed)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Try to fetch icon '%s' "
|
|
|
|
"from " MACSTR, icon->filename,
|
|
|
|
MAC2STR(osu->bssid));
|
2013-06-15 05:41:51 +02:00
|
|
|
os_get_reltime(&wpa_s->osu_icon_fetch_start);
|
2013-01-25 23:10:41 +01:00
|
|
|
if (hs20_anqp_send_req(wpa_s, osu->bssid,
|
|
|
|
BIT(HS20_STYPE_ICON_REQUEST),
|
|
|
|
(u8 *) icon->filename,
|
2015-12-11 02:01:46 +01:00
|
|
|
os_strlen(icon->filename),
|
|
|
|
0) < 0) {
|
2013-01-25 23:10:41 +01:00
|
|
|
icon->failed = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: No more icons to fetch");
|
|
|
|
hs20_osu_fetch_done(wpa_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hs20_osu_add_prov(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|
|
|
const u8 *osu_ssid, u8 osu_ssid_len,
|
2018-09-12 01:52:50 +02:00
|
|
|
const u8 *osu_ssid2, u8 osu_ssid2_len,
|
2013-01-25 23:10:41 +01:00
|
|
|
const u8 *pos, size_t len)
|
|
|
|
{
|
|
|
|
struct osu_provider *prov;
|
|
|
|
const u8 *end = pos + len;
|
|
|
|
u16 len2;
|
|
|
|
const u8 *pos2;
|
2014-12-04 23:56:05 +01:00
|
|
|
u8 uri_len, osu_method_len, osu_nai_len;
|
2013-01-25 23:10:41 +01:00
|
|
|
|
|
|
|
wpa_hexdump(MSG_DEBUG, "HS 2.0: Parsing OSU Provider", pos, len);
|
|
|
|
prov = os_realloc_array(wpa_s->osu_prov,
|
|
|
|
wpa_s->osu_prov_count + 1,
|
|
|
|
sizeof(*prov));
|
|
|
|
if (prov == NULL)
|
|
|
|
return;
|
|
|
|
wpa_s->osu_prov = prov;
|
|
|
|
prov = &prov[wpa_s->osu_prov_count];
|
|
|
|
os_memset(prov, 0, sizeof(*prov));
|
|
|
|
|
|
|
|
os_memcpy(prov->bssid, bss->bssid, ETH_ALEN);
|
|
|
|
os_memcpy(prov->osu_ssid, osu_ssid, osu_ssid_len);
|
|
|
|
prov->osu_ssid_len = osu_ssid_len;
|
2018-09-12 01:52:50 +02:00
|
|
|
if (osu_ssid2)
|
|
|
|
os_memcpy(prov->osu_ssid2, osu_ssid2, osu_ssid2_len);
|
|
|
|
prov->osu_ssid2_len = osu_ssid2_len;
|
2013-01-25 23:10:41 +01:00
|
|
|
|
|
|
|
/* OSU Friendly Name Length */
|
2015-10-18 11:04:16 +02:00
|
|
|
if (end - pos < 2) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU "
|
|
|
|
"Friendly Name Length");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
len2 = WPA_GET_LE16(pos);
|
|
|
|
pos += 2;
|
2014-12-04 23:56:05 +01:00
|
|
|
if (len2 > end - pos) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU "
|
|
|
|
"Friendly Name Duples");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pos2 = pos;
|
|
|
|
pos += len2;
|
|
|
|
|
|
|
|
/* OSU Friendly Name Duples */
|
2015-10-18 11:04:16 +02:00
|
|
|
while (pos - pos2 >= 4 && prov->friendly_name_count < OSU_MAX_ITEMS) {
|
2013-01-25 23:10:41 +01:00
|
|
|
struct osu_lang_string *f;
|
2020-11-03 18:56:39 +01:00
|
|
|
u8 slen;
|
|
|
|
|
|
|
|
slen = pos2[0];
|
|
|
|
if (1 + slen > pos - pos2) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Invalid OSU Friendly Name");
|
|
|
|
break;
|
|
|
|
}
|
2020-11-03 18:56:39 +01:00
|
|
|
if (slen < 3) {
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"Invalid OSU Friendly Name (no room for language)");
|
|
|
|
break;
|
|
|
|
}
|
2013-01-25 23:10:41 +01:00
|
|
|
f = &prov->friendly_name[prov->friendly_name_count++];
|
2020-11-03 18:56:39 +01:00
|
|
|
pos2++;
|
|
|
|
os_memcpy(f->lang, pos2, 3);
|
|
|
|
pos2 += 3;
|
|
|
|
slen -= 3;
|
|
|
|
os_memcpy(f->text, pos2, slen);
|
|
|
|
pos2 += slen;
|
2013-01-25 23:10:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* OSU Server URI */
|
2015-10-18 11:04:16 +02:00
|
|
|
if (end - pos < 1) {
|
2014-11-23 19:04:29 +01:00
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"HS 2.0: Not enough room for OSU Server URI length");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
uri_len = *pos++;
|
|
|
|
if (uri_len > end - pos) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU Server "
|
|
|
|
"URI");
|
|
|
|
return;
|
|
|
|
}
|
2014-11-23 19:04:29 +01:00
|
|
|
os_memcpy(prov->server_uri, pos, uri_len);
|
|
|
|
pos += uri_len;
|
2013-01-25 23:10:41 +01:00
|
|
|
|
|
|
|
/* OSU Method list */
|
2015-10-18 11:04:16 +02:00
|
|
|
if (end - pos < 1) {
|
2014-12-04 23:56:05 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU Method "
|
|
|
|
"list length");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
osu_method_len = pos[0];
|
|
|
|
if (osu_method_len > end - pos - 1) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU Method "
|
|
|
|
"list");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pos2 = pos + 1;
|
2014-12-04 23:56:05 +01:00
|
|
|
pos += 1 + osu_method_len;
|
2013-01-25 23:10:41 +01:00
|
|
|
while (pos2 < pos) {
|
|
|
|
if (*pos2 < 32)
|
|
|
|
prov->osu_methods |= BIT(*pos2);
|
|
|
|
pos2++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Icons Available Length */
|
2015-10-18 11:04:16 +02:00
|
|
|
if (end - pos < 2) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for Icons "
|
|
|
|
"Available Length");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
len2 = WPA_GET_LE16(pos);
|
|
|
|
pos += 2;
|
2014-12-04 23:56:05 +01:00
|
|
|
if (len2 > end - pos) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for Icons "
|
|
|
|
"Available");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pos2 = pos;
|
|
|
|
pos += len2;
|
|
|
|
|
|
|
|
/* Icons Available */
|
|
|
|
while (pos2 < pos) {
|
|
|
|
struct osu_icon *icon = &prov->icon[prov->icon_count];
|
2014-12-04 23:56:05 +01:00
|
|
|
u8 flen;
|
|
|
|
|
2015-10-18 11:04:16 +02:00
|
|
|
if (2 + 2 + 3 + 1 + 1 > pos - pos2) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Invalid Icon Metadata");
|
2012-12-20 20:15:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
icon->width = WPA_GET_LE16(pos2);
|
|
|
|
pos2 += 2;
|
|
|
|
icon->height = WPA_GET_LE16(pos2);
|
|
|
|
pos2 += 2;
|
|
|
|
os_memcpy(icon->lang, pos2, 3);
|
|
|
|
pos2 += 3;
|
2012-12-20 20:15:05 +01:00
|
|
|
|
2015-10-18 11:04:16 +02:00
|
|
|
flen = *pos2++;
|
|
|
|
if (flen > pos - pos2) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not room for Icon Type");
|
2012-12-20 20:15:05 +01:00
|
|
|
break;
|
|
|
|
}
|
2015-10-18 11:04:16 +02:00
|
|
|
os_memcpy(icon->icon_type, pos2, flen);
|
|
|
|
pos2 += flen;
|
2012-12-20 20:15:05 +01:00
|
|
|
|
2015-10-18 11:04:16 +02:00
|
|
|
if (pos - pos2 < 1) {
|
2014-12-04 23:56:05 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not room for Icon "
|
|
|
|
"Filename length");
|
|
|
|
break;
|
|
|
|
}
|
2015-10-18 11:04:16 +02:00
|
|
|
flen = *pos2++;
|
|
|
|
if (flen > pos - pos2) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not room for Icon "
|
|
|
|
"Filename");
|
2012-12-20 20:15:05 +01:00
|
|
|
break;
|
|
|
|
}
|
2015-10-18 11:04:16 +02:00
|
|
|
os_memcpy(icon->filename, pos2, flen);
|
|
|
|
pos2 += flen;
|
2012-12-20 20:15:05 +01:00
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
prov->icon_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OSU_NAI */
|
2015-10-18 11:04:16 +02:00
|
|
|
if (end - pos < 1) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU_NAI");
|
|
|
|
return;
|
|
|
|
}
|
2015-10-18 11:04:16 +02:00
|
|
|
osu_nai_len = *pos++;
|
|
|
|
if (osu_nai_len > end - pos) {
|
2014-12-04 23:56:05 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU_NAI");
|
|
|
|
return;
|
|
|
|
}
|
2015-10-18 11:04:16 +02:00
|
|
|
os_memcpy(prov->osu_nai, pos, osu_nai_len);
|
|
|
|
pos += osu_nai_len;
|
2013-01-25 23:10:41 +01:00
|
|
|
|
|
|
|
/* OSU Service Description Length */
|
2015-10-18 11:04:16 +02:00
|
|
|
if (end - pos < 2) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU "
|
|
|
|
"Service Description Length");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
len2 = WPA_GET_LE16(pos);
|
|
|
|
pos += 2;
|
2014-12-04 23:56:05 +01:00
|
|
|
if (len2 > end - pos) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU "
|
|
|
|
"Service Description Duples");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pos2 = pos;
|
|
|
|
pos += len2;
|
|
|
|
|
|
|
|
/* OSU Service Description Duples */
|
2015-10-18 11:04:16 +02:00
|
|
|
while (pos - pos2 >= 4 && prov->serv_desc_count < OSU_MAX_ITEMS) {
|
2013-01-25 23:10:41 +01:00
|
|
|
struct osu_lang_string *f;
|
2014-12-04 23:56:05 +01:00
|
|
|
u8 descr_len;
|
|
|
|
|
2015-10-18 11:04:16 +02:00
|
|
|
descr_len = *pos2++;
|
|
|
|
if (descr_len > pos - pos2 || descr_len < 3) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Invalid OSU Service "
|
|
|
|
"Description");
|
2012-12-20 20:15:05 +01:00
|
|
|
break;
|
|
|
|
}
|
2013-01-25 23:10:41 +01:00
|
|
|
f = &prov->serv_desc[prov->serv_desc_count++];
|
2015-10-18 11:04:16 +02:00
|
|
|
os_memcpy(f->lang, pos2, 3);
|
|
|
|
os_memcpy(f->text, pos2 + 3, descr_len - 3);
|
|
|
|
pos2 += descr_len;
|
2013-01-25 23:10:41 +01:00
|
|
|
}
|
2012-12-20 20:15:05 +01:00
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Added OSU Provider through " MACSTR,
|
|
|
|
MAC2STR(bss->bssid));
|
|
|
|
wpa_s->osu_prov_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void hs20_osu_icon_fetch(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
struct wpa_bss *bss;
|
|
|
|
struct wpabuf *prov_anqp;
|
|
|
|
const u8 *pos, *end;
|
|
|
|
u16 len;
|
2018-09-12 01:52:50 +02:00
|
|
|
const u8 *osu_ssid, *osu_ssid2;
|
|
|
|
u8 osu_ssid_len, osu_ssid2_len;
|
2013-01-25 23:10:41 +01:00
|
|
|
u8 num_providers;
|
|
|
|
|
|
|
|
hs20_free_osu_prov(wpa_s);
|
|
|
|
|
|
|
|
dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
|
2018-09-12 01:52:50 +02:00
|
|
|
struct wpa_ie_data data;
|
|
|
|
const u8 *ie;
|
|
|
|
|
2013-01-25 23:10:41 +01:00
|
|
|
if (bss->anqp == NULL)
|
|
|
|
continue;
|
|
|
|
prov_anqp = bss->anqp->hs20_osu_providers_list;
|
|
|
|
if (prov_anqp == NULL)
|
|
|
|
continue;
|
2023-10-11 11:50:05 +02:00
|
|
|
ie = wpa_bss_get_rsne(wpa_s, bss, NULL, false);
|
2018-09-12 01:52:50 +02:00
|
|
|
if (ie && wpa_parse_wpa_ie(ie, 2 + ie[1], &data) == 0 &&
|
|
|
|
(data.key_mgmt & WPA_KEY_MGMT_OSEN)) {
|
|
|
|
osu_ssid2 = bss->ssid;
|
|
|
|
osu_ssid2_len = bss->ssid_len;
|
|
|
|
} else {
|
|
|
|
osu_ssid2 = NULL;
|
|
|
|
osu_ssid2_len = 0;
|
|
|
|
}
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Parsing OSU Providers list from "
|
|
|
|
MACSTR, MAC2STR(bss->bssid));
|
|
|
|
wpa_hexdump_buf(MSG_DEBUG, "HS 2.0: OSU Providers list",
|
|
|
|
prov_anqp);
|
|
|
|
pos = wpabuf_head(prov_anqp);
|
|
|
|
end = pos + wpabuf_len(prov_anqp);
|
|
|
|
|
|
|
|
/* OSU SSID */
|
2015-10-18 11:04:16 +02:00
|
|
|
if (end - pos < 1)
|
2013-01-25 23:10:41 +01:00
|
|
|
continue;
|
2015-10-18 11:04:16 +02:00
|
|
|
if (1 + pos[0] > end - pos) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for "
|
|
|
|
"OSU SSID");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
osu_ssid_len = *pos++;
|
2015-04-07 11:00:13 +02:00
|
|
|
if (osu_ssid_len > SSID_MAX_LEN) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Invalid OSU SSID "
|
|
|
|
"Length %u", osu_ssid_len);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
osu_ssid = pos;
|
|
|
|
pos += osu_ssid_len;
|
|
|
|
|
2015-10-18 11:04:16 +02:00
|
|
|
if (end - pos < 1) {
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for "
|
|
|
|
"Number of OSU Providers");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
num_providers = *pos++;
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Number of OSU Providers: %u",
|
|
|
|
num_providers);
|
|
|
|
|
|
|
|
/* OSU Providers */
|
2015-10-18 11:04:16 +02:00
|
|
|
while (end - pos > 2 && num_providers > 0) {
|
2013-01-25 23:10:41 +01:00
|
|
|
num_providers--;
|
|
|
|
len = WPA_GET_LE16(pos);
|
|
|
|
pos += 2;
|
2014-11-23 17:55:06 +01:00
|
|
|
if (len > (unsigned int) (end - pos))
|
2013-01-25 23:10:41 +01:00
|
|
|
break;
|
|
|
|
hs20_osu_add_prov(wpa_s, bss, osu_ssid,
|
2018-09-12 01:52:50 +02:00
|
|
|
osu_ssid_len, osu_ssid2,
|
|
|
|
osu_ssid2_len, pos, len);
|
2013-01-25 23:10:41 +01:00
|
|
|
pos += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos != end) {
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Ignored %d bytes of "
|
|
|
|
"extra data after OSU Providers",
|
|
|
|
(int) (end - pos));
|
|
|
|
}
|
2018-10-05 19:51:51 +02:00
|
|
|
|
|
|
|
prov_anqp = bss->anqp->hs20_osu_providers_nai_list;
|
|
|
|
if (!prov_anqp)
|
|
|
|
continue;
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"HS 2.0: Parsing OSU Providers NAI List from "
|
|
|
|
MACSTR, MAC2STR(bss->bssid));
|
|
|
|
wpa_hexdump_buf(MSG_DEBUG, "HS 2.0: OSU Providers NAI List",
|
|
|
|
prov_anqp);
|
|
|
|
pos = wpabuf_head(prov_anqp);
|
|
|
|
end = pos + wpabuf_len(prov_anqp);
|
|
|
|
num_providers = 0;
|
|
|
|
while (end - pos > 0) {
|
|
|
|
len = *pos++;
|
|
|
|
if (end - pos < len) {
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"HS 2.0: Not enough room for OSU_NAI");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (num_providers >= wpa_s->osu_prov_count) {
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"HS 2.0: Ignore unexpected OSU Provider NAI List entries");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
os_memcpy(wpa_s->osu_prov[num_providers].osu_nai2,
|
|
|
|
pos, len);
|
|
|
|
pos += len;
|
|
|
|
num_providers++;
|
|
|
|
}
|
2013-01-25 23:10:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
wpa_s->fetch_osu_icon_in_progress = 1;
|
|
|
|
hs20_next_osu_icon(wpa_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hs20_osu_scan_res_handler(struct wpa_supplicant *wpa_s,
|
|
|
|
struct wpa_scan_results *scan_res)
|
|
|
|
{
|
|
|
|
wpa_printf(MSG_DEBUG, "OSU provisioning fetch scan completed");
|
2014-12-14 01:14:29 +01:00
|
|
|
if (!wpa_s->fetch_osu_waiting_scan) {
|
|
|
|
wpa_printf(MSG_DEBUG, "OSU fetch have been canceled");
|
|
|
|
return;
|
|
|
|
}
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_s->network_select = 0;
|
|
|
|
wpa_s->fetch_all_anqp = 1;
|
|
|
|
wpa_s->fetch_osu_info = 1;
|
|
|
|
wpa_s->fetch_osu_icon_in_progress = 0;
|
|
|
|
|
|
|
|
interworking_start_fetch_anqp(wpa_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-12 22:13:09 +02:00
|
|
|
int hs20_fetch_osu(struct wpa_supplicant *wpa_s, int skip_scan)
|
2013-01-25 23:10:41 +01:00
|
|
|
{
|
|
|
|
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Cannot start fetch_osu - "
|
|
|
|
"interface disabled");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wpa_s->scanning) {
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Cannot start fetch_osu - "
|
|
|
|
"scanning");
|
|
|
|
return -1;
|
2011-09-08 19:52:23 +02:00
|
|
|
}
|
2013-01-25 23:10:41 +01:00
|
|
|
|
|
|
|
if (wpa_s->conf->osu_dir == NULL) {
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Cannot start fetch_osu - "
|
|
|
|
"osu_dir not configured");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wpa_s->fetch_anqp_in_progress || wpa_s->network_select) {
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Cannot start fetch_osu - "
|
|
|
|
"fetch in progress (%d, %d)",
|
|
|
|
wpa_s->fetch_anqp_in_progress,
|
|
|
|
wpa_s->network_select);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpa_msg(wpa_s, MSG_INFO, "Starting OSU provisioning information fetch");
|
2013-12-13 03:39:00 +01:00
|
|
|
wpa_s->num_osu_scans = 0;
|
|
|
|
wpa_s->num_prov_found = 0;
|
2016-07-12 22:13:09 +02:00
|
|
|
if (skip_scan) {
|
|
|
|
wpa_s->network_select = 0;
|
|
|
|
wpa_s->fetch_all_anqp = 1;
|
|
|
|
wpa_s->fetch_osu_info = 1;
|
|
|
|
wpa_s->fetch_osu_icon_in_progress = 0;
|
|
|
|
|
|
|
|
interworking_start_fetch_anqp(wpa_s);
|
|
|
|
} else {
|
|
|
|
hs20_start_osu_scan(wpa_s);
|
|
|
|
}
|
2013-12-13 03:39:00 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void hs20_start_osu_scan(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
2014-12-14 01:14:29 +01:00
|
|
|
wpa_s->fetch_osu_waiting_scan = 1;
|
2013-12-13 03:39:00 +01:00
|
|
|
wpa_s->num_osu_scans++;
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_s->scan_req = MANUAL_SCAN_REQ;
|
|
|
|
wpa_s->scan_res_handler = hs20_osu_scan_res_handler;
|
|
|
|
wpa_supplicant_req_scan(wpa_s, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void hs20_cancel_fetch_osu(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
wpa_printf(MSG_DEBUG, "Cancel OSU fetch");
|
|
|
|
interworking_stop_fetch_anqp(wpa_s);
|
2014-12-14 01:14:29 +01:00
|
|
|
wpa_s->fetch_osu_waiting_scan = 0;
|
2013-01-25 23:10:41 +01:00
|
|
|
wpa_s->network_select = 0;
|
|
|
|
wpa_s->fetch_osu_info = 0;
|
|
|
|
wpa_s->fetch_osu_icon_in_progress = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void hs20_icon_fetch_failed(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
hs20_osu_icon_fetch_result(wpa_s, -1);
|
|
|
|
eloop_cancel_timeout(hs20_continue_icon_fetch, wpa_s, NULL);
|
|
|
|
eloop_register_timeout(0, 0, hs20_continue_icon_fetch, wpa_s, NULL);
|
2011-09-08 19:52:23 +02:00
|
|
|
}
|
2012-11-02 12:05:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
void hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
|
|
|
|
const char *url, u8 osu_method)
|
|
|
|
{
|
|
|
|
if (url)
|
|
|
|
wpa_msg(wpa_s, MSG_INFO, HS20_SUBSCRIPTION_REMEDIATION "%u %s",
|
|
|
|
osu_method, url);
|
|
|
|
else
|
|
|
|
wpa_msg(wpa_s, MSG_INFO, HS20_SUBSCRIPTION_REMEDIATION);
|
|
|
|
}
|
2013-07-26 21:12:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
void hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s, u8 code,
|
|
|
|
u16 reauth_delay, const char *url)
|
|
|
|
{
|
|
|
|
if (!wpa_sm_pmf_enabled(wpa_s->wpa)) {
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Ignore deauthentication imminent notice since PMF was not enabled");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpa_msg(wpa_s, MSG_INFO, HS20_DEAUTH_IMMINENT_NOTICE "%u %u %s",
|
|
|
|
code, reauth_delay, url);
|
|
|
|
|
|
|
|
if (code == HS20_DEAUTH_REASON_CODE_BSS) {
|
2021-02-07 16:02:37 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Add BSS to ignore list");
|
|
|
|
wpa_bssid_ignore_add(wpa_s, wpa_s->bssid);
|
2013-08-09 23:04:50 +02:00
|
|
|
/* TODO: For now, disable full ESS since some drivers may not
|
|
|
|
* support disabling per BSS. */
|
|
|
|
if (wpa_s->current_ssid) {
|
2014-02-27 23:29:34 +01:00
|
|
|
struct os_reltime now;
|
|
|
|
os_get_reltime(&now);
|
2013-08-09 23:04:50 +02:00
|
|
|
if (now.sec + reauth_delay <=
|
|
|
|
wpa_s->current_ssid->disabled_until.sec)
|
|
|
|
return;
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Disable network for %u seconds (BSS)",
|
|
|
|
reauth_delay);
|
|
|
|
wpa_s->current_ssid->disabled_until.sec =
|
|
|
|
now.sec + reauth_delay;
|
|
|
|
}
|
2013-07-26 21:12:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (code == HS20_DEAUTH_REASON_CODE_ESS && wpa_s->current_ssid) {
|
2014-02-27 23:29:34 +01:00
|
|
|
struct os_reltime now;
|
|
|
|
os_get_reltime(&now);
|
2013-07-26 21:12:37 +02:00
|
|
|
if (now.sec + reauth_delay <=
|
|
|
|
wpa_s->current_ssid->disabled_until.sec)
|
|
|
|
return;
|
|
|
|
wpa_printf(MSG_DEBUG, "HS 2.0: Disable network for %u seconds",
|
|
|
|
reauth_delay);
|
|
|
|
wpa_s->current_ssid->disabled_until.sec =
|
|
|
|
now.sec + reauth_delay;
|
|
|
|
}
|
|
|
|
}
|
2014-05-12 18:14:55 +02:00
|
|
|
|
|
|
|
|
2018-04-23 23:17:47 +02:00
|
|
|
void hs20_rx_t_c_acceptance(struct wpa_supplicant *wpa_s, const char *url)
|
|
|
|
{
|
|
|
|
if (!wpa_sm_pmf_enabled(wpa_s->wpa)) {
|
|
|
|
wpa_printf(MSG_DEBUG,
|
|
|
|
"HS 2.0: Ignore Terms and Conditions Acceptance since PMF was not enabled");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-19 16:52:54 +01:00
|
|
|
wpas_notify_hs20_t_c_acceptance(wpa_s, url);
|
2018-04-23 23:17:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-19 17:49:32 +01:00
|
|
|
void hs20_init(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
dl_list_init(&wpa_s->icon_head);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-12 18:14:55 +02:00
|
|
|
void hs20_deinit(struct wpa_supplicant *wpa_s)
|
|
|
|
{
|
|
|
|
eloop_cancel_timeout(hs20_continue_icon_fetch, wpa_s, NULL);
|
|
|
|
hs20_free_osu_prov(wpa_s);
|
2015-12-19 17:49:32 +01:00
|
|
|
if (wpa_s->icon_head.next)
|
|
|
|
hs20_del_icon(wpa_s, NULL, NULL);
|
2014-05-12 18:14:55 +02:00
|
|
|
}
|