From 25f3c270d91fbddaa3e43b277cbdd28a1e9b4792 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 12 Sep 2018 04:00:27 +0300 Subject: [PATCH] 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). This is useful for testing single SSID transition mode cases. Signed-off-by: Jouni Malinen --- hs20/client/osu_client.c | 21 ++++++++++++++++++++- hs20/client/osu_client.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hs20/client/osu_client.c b/hs20/client/osu_client.c index a17469954..76ef9c449 100644 --- a/hs20/client/osu_client.c +++ b/hs20/client/osu_client.c @@ -2146,6 +2146,22 @@ static int osu_connect(struct hs20_osu_client *ctx, const char *bssid, if (ssid2 && ssid2[0] == '\0') 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); if (id < 0) return -1; @@ -3153,7 +3169,7 @@ int main(int argc, char *argv[]) return -1; 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) break; switch (c) { @@ -3170,6 +3186,9 @@ int main(int argc, char *argv[]) case 'N': no_prod_assoc = 1; break; + case 'o': + ctx.osu_ssid = optarg; + break; case 'O': friendly_name = optarg; break; diff --git a/hs20/client/osu_client.h b/hs20/client/osu_client.h index 9a7059edf..5c8e6d00b 100644 --- a/hs20/client/osu_client.h +++ b/hs20/client/osu_client.h @@ -47,6 +47,7 @@ struct hs20_osu_client { int client_cert_present; char **server_dnsname; size_t server_dnsname_count; + const char *osu_ssid; /* Enforced OSU_SSID for testing purposes */ #define WORKAROUND_OCSP_OPTIONAL 0x00000001 unsigned long int workarounds; };