knownnetworks: get matched RC on match_roaming_consortium

The HS20 module had its own getter for returning the matched roaming
consortium. Since we already have the network_info op for matching
we might as well return the matched RC rather than just a bool. This
allows the RC to be included in (Re)Association without the need for
a specific getter.
This commit is contained in:
James Prestwood 2019-09-06 11:11:01 -07:00 committed by Denis Kenzior
parent 1104d69e29
commit af46cc0ed2
4 changed files with 39 additions and 20 deletions

View File

@ -192,9 +192,11 @@ static bool hotspot_match_hessid(const struct network_info *info,
return !memcmp(config->hessid, hessid, 6);
}
static bool hotspot_match_roaming_consortium(const struct network_info *info,
static const uint8_t *hotspot_match_roaming_consortium(
const struct network_info *info,
const uint8_t *rc_ie,
size_t rc_len)
size_t rc_len,
size_t *rc_len_out)
{
const uint8_t *rc1, *rc2, *rc3;
size_t rc1_len, rc2_len, rc3_len;
@ -202,26 +204,35 @@ static bool hotspot_match_roaming_consortium(const struct network_info *info,
super);
if (!config->rc || !rc_ie)
return false;
return NULL;
if (ie_parse_roaming_consortium_from_data(rc_ie, rc_ie[1] + 2, NULL,
&rc1, &rc1_len, &rc2, &rc2_len,
&rc3, &rc3_len) < 0)
return false;
return NULL;
/* rc1 is guarenteed to be set if the above returns success */
if (rc1_len == config->rc_len && !memcmp(rc1, config->rc, rc1_len))
return true;
if (rc1_len == config->rc_len && !memcmp(rc1, config->rc, rc1_len)) {
if (rc_len_out)
*rc_len_out = rc1_len;
return rc1;
}
if (rc2 && rc2_len == config->rc_len &&
!memcmp(rc2, config->rc, rc2_len))
return true;
!memcmp(rc2, config->rc, rc2_len)) {
if (rc_len_out)
*rc_len_out = rc2_len;
return rc2;
}
if (rc3 && rc1_len == config->rc_len &&
!memcmp(rc3, config->rc, rc3_len))
return true;
!memcmp(rc3, config->rc, rc3_len)) {
if (rc_len_out)
*rc_len_out = rc3_len;
return rc3;
}
return false;
return NULL;
}
static bool hotspot_match_nai_realms(const struct network_info *info,

View File

@ -221,14 +221,17 @@ bool network_info_match_hessid(const struct network_info *info,
return info->ops->match_hessid(info, hessid);
}
bool network_info_match_roaming_consortium(const struct network_info *info,
const uint8_t *network_info_match_roaming_consortium(
const struct network_info *info,
const uint8_t *rc,
size_t rc_len)
size_t rc_len,
size_t *rc_len_out)
{
if (!info->ops->match_roaming_consortium)
return false;
return NULL;
return info->ops->match_roaming_consortium(info, rc, rc_len);
return info->ops->match_roaming_consortium(info, rc, rc_len,
rc_len_out);
}
bool network_info_match_nai_realm(const struct network_info *info,

View File

@ -41,9 +41,11 @@ struct network_info_ops {
bool (*match_hessid)(const struct network_info *info,
const uint8_t *hessid);
bool (*match_roaming_consortium)(const struct network_info *info,
const uint8_t *(*match_roaming_consortium)(
const struct network_info *info,
const uint8_t *rc_ie,
size_t rc_len);
size_t rc_len,
size_t *rc_len_out);
bool (*match_nai_realms)(const struct network_info *info,
const char **nai_realms);
};
@ -96,9 +98,11 @@ const char *network_info_get_type(const struct network_info *info);
bool network_info_match_hessid(const struct network_info *info,
const uint8_t *hessid);
bool network_info_match_roaming_consortium(const struct network_info *info,
const uint8_t *network_info_match_roaming_consortium(
const struct network_info *info,
const uint8_t *rc,
size_t rc_len);
size_t rc_len,
size_t *rc_len_out);
bool network_info_match_nai_realm(const struct network_info *info,
const char **nai_realms);

View File

@ -575,7 +575,8 @@ static bool hotspot_info_matches(struct network *network,
return true;
if (network_info_match_roaming_consortium(info, bss->rc_ie,
bss->rc_ie[1] + 2))
bss->rc_ie[1] + 2,
NULL))
return true;
return false;