station: build roaming consortium IE for netdev_connect

Per the hotspot 2.0 spec, if a matching roaming consortium OI is
found it should be added to the (Re)Association request. vendor_ies
can now be provided to netdev_connect, which get appended to the IE
attribute.
This commit is contained in:
James Prestwood 2019-07-12 14:00:02 -07:00 committed by Denis Kenzior
parent f57ba70235
commit 7286a12240
1 changed files with 28 additions and 3 deletions

View File

@ -494,6 +494,12 @@ static bool station_start_anqp(struct station *station, struct network *network,
*ptr++ = 0; /* reserved */
*ptr++ = ANQP_HS20_OSU_PROVIDERS_NAI_LIST;
/*
* TODO: Additional roaming consortiums can be queried if indicated
* by the roaming consortium IE. The IE contains up to the first 3, and
* these are checked in hs20_find_settings_file.
*/
entry->pending = anqp_request(netdev_get_ifindex(station->netdev),
netdev_get_address(station->netdev),
bss, anqp, ptr - anqp,
@ -2153,6 +2159,10 @@ static void station_connect_cb(struct netdev *netdev, enum netdev_result result,
int __station_connect_network(struct station *station, struct network *network,
struct scan_bss *bss)
{
const uint8_t *rc = NULL;
size_t rc_len = 0;
uint8_t rc_buf[32];
struct iovec iov;
struct handshake_state *hs;
int r;
@ -2160,9 +2170,24 @@ int __station_connect_network(struct station *station, struct network *network,
if (!hs)
return -ENOTSUP;
r = netdev_connect(station->netdev, bss, hs, NULL, 0,
station_netdev_event, station_connect_cb,
station);
if (bss->hs20_capable) {
/*
* If a matching roaming consortium OI is found for the network
* this single RC value will be set in the handshake and used
* during (Re)Association.
*/
rc = hs20_get_roaming_consortium(network, &rc_len);
if (rc) {
ie_build_roaming_consortium(rc, rc_len, rc_buf);
iov.iov_base = rc_buf;
iov.iov_len = rc_buf[1] + 2;
}
}
r = netdev_connect(station->netdev, bss, hs, rc ? &iov : NULL,
rc ? 1 : 0, station_netdev_event,
station_connect_cb, station);
if (r < 0) {
handshake_state_free(hs);
return r;