lib: use common IWINFO_CIPHER_NAMES strings
[project/iwinfo.git] / iwinfo_lib.c
index 4ae8f591c93a2a6141e8e0c2847737837733510d..7fbf8112d88dec50132bb9fb2aa27bc1ce2c44c0 100644 (file)
 /*
  * name constants
  */
-const char *IWINFO_CIPHER_NAMES[] = {
+const char * const IWINFO_CIPHER_NAMES[IWINFO_CIPHER_COUNT] = {
        "NONE",
-       "WEP40",
+       "WEP-40",
        "TKIP",
        "WRAP",
        "CCMP",
-       "WEP104",
+       "WEP-104",
        "AES-OCB",
        "CKIP",
+       "GCMP",
+       "CCMP-256",
+       "GCMP-256",
 };
 
-const char *IWINFO_KMGMT_NAMES[] = {
+const char * const IWINFO_KMGMT_NAMES[IWINFO_KMGMT_COUNT] = {
        "NONE",
        "802.1X",
        "PSK",
+       "SAE",
+       "OWE",
 };
 
-const char *IWINFO_AUTH_NAMES[] = {
+const char * const IWINFO_AUTH_NAMES[IWINFO_AUTH_COUNT] = {
        "OPEN",
        "SHARED",
 };
 
-const char *IWINFO_OPMODE_NAMES[] = {
+const char * const IWINFO_OPMODE_NAMES[IWINFO_OPMODE_COUNT] = {
        "Unknown",
        "Master",
        "Ad-Hoc",
@@ -57,6 +62,40 @@ const char *IWINFO_OPMODE_NAMES[] = {
        "P2P Go",
 };
 
+const char * const IWINFO_HTMODE_NAMES[IWINFO_HTMODE_COUNT] = {
+       "HT20",
+       "HT40",
+       "VHT20",
+       "VHT40",
+       "VHT80",
+       "VHT80+80",
+       "VHT160",
+       "NOHT",
+       "HE20",
+       "HE40",
+       "HE80",
+       "HE80+80",
+       "HE160"
+};
+
+const char * const ht_secondary_offset[4] = {
+       "no secondary",
+       "above",
+       "[reserved!]",
+       "below",
+};
+
+const uint16_t ht_chan_width[2] = {
+       20,
+       2040,
+};
+
+const uint16_t vht_chan_width[4] = {
+       40, /* 40 MHz or lower (refer to ht to a more precise width) */
+       80, /* 80 MHz */
+       160, /* 160 MHz */
+       8080, /* 80+80 MHz */
+};
 
 /*
  * ISO3166 country labels
@@ -313,10 +352,6 @@ const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[] = {
        { 0,               "" }
 };
 
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-#endif
-
 static const struct iwinfo_ops *backends[] = {
 #ifdef USE_NL80211
        &nl80211_ops,
@@ -327,7 +362,9 @@ static const struct iwinfo_ops *backends[] = {
 #ifdef USE_WL
        &wl_ops,
 #endif
+#ifdef USE_WEXT
        &wext_ops,
+#endif
 };
 
 const char * iwinfo_type(const char *ifname)
@@ -350,6 +387,17 @@ const struct iwinfo_ops * iwinfo_backend(const char *ifname)
        return NULL;
 }
 
+const struct iwinfo_ops * iwinfo_backend_by_name(const char *name)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(backends); i++)
+               if (!strcmp(backends[i]->name, name))
+                       return backends[i];
+
+       return NULL;
+}
+
 void iwinfo_finish(void)
 {
        int i;