[package] iwinfo: replace internal constant mode strings with enums
[openwrt.git] / package / iwinfo / src / iwinfo_cli.c
index dc8ed8b148df3a028a5c269e191f3515517577ea..0fdb21ec677c2f6977597b9962db620ef7ac0ec8 100644 (file)
@@ -230,19 +230,19 @@ static char * format_encryption(struct iwinfo_crypto_entry *c)
                                case 3:
                                        snprintf(buf, sizeof(buf), "mixed WPA/WPA2 %s (%s)",
                                                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;
 
                                case 2:
                                        snprintf(buf, sizeof(buf), "WPA2 %s (%s)",
                                                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;
 
                                case 1:
                                        snprintf(buf, sizeof(buf), "WPA %s (%s)",
                                                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;
                        }
                }
@@ -391,10 +391,13 @@ static char * print_bssid(const struct iwinfo_ops *iw, const char *ifname)
 
 static char * print_mode(const struct iwinfo_ops *iw, const char *ifname)
 {
+       int mode;
        static char buf[128];
 
-       if (iw->mode(ifname, buf))
-               snprintf(buf, sizeof(buf), "unknown");
+       if (iw->mode(ifname, &mode))
+               mode = IWINFO_OPMODE_UNKNOWN;
+
+       snprintf(buf, sizeof(buf), "%s", IWINFO_OPMODE_NAMES[mode]);
 
        return buf;
 }
@@ -572,7 +575,7 @@ static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname)
                printf("          ESSID: %s\n",
                        format_ssid(e->ssid));
                printf("          Mode: %s  Channel: %s\n",
-                       e->mode ? (char *)e->mode : "unknown",
+                       IWINFO_OPMODE_NAMES[e->mode],
                        format_channel(e->channel));
                printf("          Signal: %s  Quality: %s/%s\n",
                        format_signal(e->signal - 0x100),