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 e018adad4af42418270afb76fcfbb39cd38c9fec..c6d10abc12bcf2faa3235929daaf8bbfaf8f8788 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 909dc847155efea95e36b91550c891ed16f6fcca..3dc509138c6d63b3a1b3e76034af9c6780798ce6 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);
 }