cli: fix reporting of mixed WPA2/WPA3 versions

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2019-09-20 08:55:37 +02:00
parent 7faeaeafe1
commit 02112f9b10

View file

@ -203,6 +203,8 @@ static char * format_enc_suites(int suites)
static char * format_encryption(struct iwinfo_crypto_entry *c) static char * format_encryption(struct iwinfo_crypto_entry *c)
{ {
static char buf[512]; static char buf[512];
char *pos = buf;
int i, n;
if (!c) if (!c)
{ {
@ -234,31 +236,25 @@ static char * format_encryption(struct iwinfo_crypto_entry *c)
/* WPA */ /* WPA */
else if (c->wpa_version) else if (c->wpa_version)
{ {
switch (c->wpa_version) { for (i = 0, n = 0; i < 3; i++)
case 4: if (c->wpa_version & (1 << i))
snprintf(buf, sizeof(buf), "WPA3 %s (%s)", n++;
format_enc_suites(c->auth_suites),
format_enc_ciphers(c->pair_ciphers | c->group_ciphers));
break;
case 3: if (n > 1)
snprintf(buf, sizeof(buf), "mixed WPA/WPA2 %s (%s)", pos += sprintf(pos, "mixed ");
format_enc_suites(c->auth_suites),
format_enc_ciphers(c->pair_ciphers | c->group_ciphers));
break;
case 2: for (i = 0; i < 3; i++)
snprintf(buf, sizeof(buf), "WPA2 %s (%s)", if (c->wpa_version & (1 << i))
format_enc_suites(c->auth_suites), if (i)
format_enc_ciphers(c->pair_ciphers | c->group_ciphers)); pos += sprintf(pos, "WPA%d/", i + 1);
break; else
pos += sprintf(pos, "WPA/");
case 1: pos--;
snprintf(buf, sizeof(buf), "WPA %s (%s)",
sprintf(pos, " %s (%s)",
format_enc_suites(c->auth_suites), format_enc_suites(c->auth_suites),
format_enc_ciphers(c->pair_ciphers | c->group_ciphers)); format_enc_ciphers(c->pair_ciphers | c->group_ciphers));
break;
}
} }
else else
{ {