HS 2.0: Allow OSU SSID selection to be enforced for testing purposes

This allows hs20-osu-client to be requested to select a specific OSU
SSID with the new command line argument (-o<OSU_SSID>). This is useful
for testing single SSID transition mode cases.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2018-09-12 04:00:27 +03:00
parent b275c3ae51
commit 25f3c270d9
2 changed files with 21 additions and 1 deletions

View file

@ -2146,6 +2146,22 @@ static int osu_connect(struct hs20_osu_client *ctx, const char *bssid,
if (ssid2 && ssid2[0] == '\0') if (ssid2 && ssid2[0] == '\0')
ssid2 = NULL; ssid2 = NULL;
if (ctx->osu_ssid) {
if (os_strcmp(ssid, ctx->osu_ssid) == 0) {
wpa_printf(MSG_DEBUG,
"Enforced OSU SSID matches ANQP info");
ssid2 = NULL;
} else if (ssid2 && os_strcmp(ssid2, ctx->osu_ssid) == 0) {
wpa_printf(MSG_DEBUG,
"Enforced OSU SSID matches RSN[OSEN] info");
ssid = ssid2;
} else {
wpa_printf(MSG_INFO, "Enforced OSU SSID did not match");
write_summary(ctx, "Enforced OSU SSID did not match");
return -1;
}
}
id = add_network(ifname); id = add_network(ifname);
if (id < 0) if (id < 0)
return -1; return -1;
@ -3153,7 +3169,7 @@ int main(int argc, char *argv[])
return -1; return -1;
for (;;) { for (;;) {
c = getopt(argc, argv, "df:hKNO:qr:s:S:tw:x:"); c = getopt(argc, argv, "df:hKNo:O:qr:s:S:tw:x:");
if (c < 0) if (c < 0)
break; break;
switch (c) { switch (c) {
@ -3170,6 +3186,9 @@ int main(int argc, char *argv[])
case 'N': case 'N':
no_prod_assoc = 1; no_prod_assoc = 1;
break; break;
case 'o':
ctx.osu_ssid = optarg;
break;
case 'O': case 'O':
friendly_name = optarg; friendly_name = optarg;
break; break;

View file

@ -47,6 +47,7 @@ struct hs20_osu_client {
int client_cert_present; int client_cert_present;
char **server_dnsname; char **server_dnsname;
size_t server_dnsname_count; size_t server_dnsname_count;
const char *osu_ssid; /* Enforced OSU_SSID for testing purposes */
#define WORKAROUND_OCSP_OPTIONAL 0x00000001 #define WORKAROUND_OCSP_OPTIONAL 0x00000001
unsigned long int workarounds; unsigned long int workarounds;
}; };