gsupplicant: Set WPA ciphers
authorSamuel Ortiz <sameo@linux.intel.com>
Wed, 2 Feb 2011 23:23:13 +0000 (00:23 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 2 Feb 2011 23:23:13 +0000 (00:23 +0100)
gsupplicant/gsupplicant.h
gsupplicant/supplicant.c

index e018ada..c6d10ab 100644 (file)
@@ -110,6 +110,8 @@ struct _GSupplicantSSID {
        unsigned int scan_ssid;
        GSupplicantMode mode;
        GSupplicantSecurity security;
+       unsigned int pairwise_cipher;
+       unsigned int group_cipher;
        unsigned int freq;
        const char *eap;
        const char *passphrase;
index 909dc84..3dc5091 100644 (file)
@@ -2667,6 +2667,65 @@ static void add_network_security_eap(DBusMessageIter *dict,
        g_free(eap_value);
 }
 
+static void add_network_security_ciphers(DBusMessageIter *dict,
+                                               GSupplicantSSID *ssid)
+{
+       unsigned int p_cipher, g_cipher, i;
+       char *pairwise, *group;
+       char *pair_ciphers[4];
+       char *group_ciphers[5];
+
+       p_cipher = ssid->pairwise_cipher;
+       g_cipher = ssid->group_cipher;
+
+       if (p_cipher == 0 && g_cipher == 0)
+               return;
+
+       i = 0;
+
+       if (p_cipher & G_SUPPLICANT_PAIRWISE_CCMP)
+               pair_ciphers[i++] = "CCMP";
+
+       if (p_cipher & G_SUPPLICANT_PAIRWISE_TKIP)
+               pair_ciphers[i++] = "TKIP";
+
+       if (p_cipher & G_SUPPLICANT_PAIRWISE_NONE)
+               pair_ciphers[i++] = "NONE";
+
+       pair_ciphers[i] = NULL;
+
+       i = 0;
+
+       if (g_cipher & G_SUPPLICANT_GROUP_CCMP)
+               group_ciphers[i++] = "CCMP";
+
+       if (g_cipher & G_SUPPLICANT_GROUP_TKIP)
+               group_ciphers[i++] = "TKIP";
+
+       if (g_cipher & G_SUPPLICANT_GROUP_WEP104)
+               group_ciphers[i++] = "WEP104";
+
+       if (g_cipher & G_SUPPLICANT_GROUP_WEP40)
+               group_ciphers[i++] = "WEP40";
+
+       group_ciphers[i] = NULL;
+
+       pairwise = g_strjoinv(" ", pair_ciphers);
+       group = g_strjoinv(" ", group_ciphers);
+
+       SUPPLICANT_DBG("cipher %s %s", pairwise, group);
+
+       supplicant_dbus_dict_append_basic(dict, "pairwise",
+                                               DBUS_TYPE_STRING,
+                                               &pairwise);
+       supplicant_dbus_dict_append_basic(dict, "group",
+                                               DBUS_TYPE_STRING,
+                                               &group);
+
+       g_free(pairwise);
+       g_free(group);
+}
+
 static void add_network_security(DBusMessageIter *dict, GSupplicantSSID *ssid)
 {
        char *key_mgmt;
@@ -2688,6 +2747,8 @@ static void add_network_security(DBusMessageIter *dict, GSupplicantSSID *ssid)
                break;
        }
 
+       add_network_security_ciphers(dict, ssid);
+
        supplicant_dbus_dict_append_basic(dict, "key_mgmt",
                                DBUS_TYPE_STRING, &key_mgmt);
 }