iwinfo: add support for GCMP cipher
[project/iwinfo.git] / iwinfo_lua.c
index 3d9d95e54b5fa4d36614118d569e2f82dd00f8d8..abe848bc4c2a058448f57a3d82d4f17231286e7c 100644 (file)
@@ -61,6 +61,9 @@ static char * iwinfo_crypto_print_ciphers(int ciphers)
        if (ciphers & IWINFO_CIPHER_CCMP)
                pos += sprintf(pos, "CCMP, ");
 
+       if (ciphers & IWINFO_CIPHER_GCMP)
+               pos += sprintf(pos, "GCMP, ");
+
        if (ciphers & IWINFO_CIPHER_WRAP)
                pos += sprintf(pos, "WRAP, ");
 
@@ -106,6 +109,8 @@ static char * iwinfo_crypto_print_suites(int suites)
 static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c)
 {
        static char desc[512] = { 0 };
+       char *pos = desc;
+       int i, n;
 
        if (c)
        {
@@ -135,35 +140,26 @@ static char * iwinfo_crypto_desc(struct iwinfo_crypto_entry *c)
                        /* WPA */
                        else if (c->wpa_version)
                        {
-                               switch (c->wpa_version) {
-                                       case 4:
-                                               sprintf(desc, "WPA3 %s (%s)",
-                                                       iwinfo_crypto_print_suites(c->auth_suites),
-                                                       iwinfo_crypto_print_ciphers(
-                                                               c->pair_ciphers | c->group_ciphers));
-                                               break;
-
-                                       case 3:
-                                               sprintf(desc, "mixed WPA/WPA2 %s (%s)",
-                                                       iwinfo_crypto_print_suites(c->auth_suites),
-                                                       iwinfo_crypto_print_ciphers(
-                                                               c->pair_ciphers | c->group_ciphers));
-                                               break;
-
-                                       case 2:
-                                               sprintf(desc, "WPA2 %s (%s)",
-                                                       iwinfo_crypto_print_suites(c->auth_suites),
-                                                       iwinfo_crypto_print_ciphers(
-                                                               c->pair_ciphers | c->group_ciphers));
-                                               break;
-
-                                       case 1:
-                                               sprintf(desc, "WPA %s (%s)",
-                                                       iwinfo_crypto_print_suites(c->auth_suites),
-                                                       iwinfo_crypto_print_ciphers(
-                                                               c->pair_ciphers | c->group_ciphers));
-                                               break;
-                               }
+                               for (i = 0, n = 0; i < 3; i++)
+                                       if (c->wpa_version & (1 << i))
+                                               n++;
+
+                               if (n > 1)
+                                       pos += sprintf(pos, "mixed ");
+
+                               for (i = 0; i < 3; i++)
+                                       if (c->wpa_version & (1 << i))
+                                               if (i)
+                                                       pos += sprintf(pos, "WPA%d/", i + 1);
+                                               else
+                                                       pos += sprintf(pos, "WPA/");
+
+                               pos--;
+
+                               sprintf(pos, " %s (%s)",
+                                       iwinfo_crypto_print_suites(c->auth_suites),
+                                       iwinfo_crypto_print_ciphers(
+                                               c->pair_ciphers | c->group_ciphers));
                        }
                        else
                        {