gsupplicant: Creating an helper function to compute bss security
[platform/upstream/connman.git] / gsupplicant / supplicant.c
index 25a88af..8d87dae 100644 (file)
@@ -1096,7 +1096,7 @@ static char *create_group(struct g_supplicant_bss *bss)
        return g_string_free(str, FALSE);
 }
 
-static void add_bss_to_network(struct g_supplicant_bss *bss)
+static void add_or_replace_bss_to_network(struct g_supplicant_bss *bss)
 {
        GSupplicantInterface *interface = bss->interface;
        GSupplicantNetwork *network;
@@ -1345,6 +1345,19 @@ static void bss_process_ies(DBusMessageIter *iter, void *user_data)
        }
 }
 
+static void bss_compute_security(struct g_supplicant_bss *bss)
+{
+       if (bss->ieee8021x == TRUE)
+               bss->security = G_SUPPLICANT_SECURITY_IEEE8021X;
+       else if (bss->psk == TRUE)
+               bss->security = G_SUPPLICANT_SECURITY_PSK;
+       else if (bss->privacy == TRUE)
+               bss->security = G_SUPPLICANT_SECURITY_WEP;
+       else
+               bss->security = G_SUPPLICANT_SECURITY_NONE;
+}
+
+
 static void bss_property(const char *key, DBusMessageIter *iter,
                                                        void *user_data)
 {
@@ -1356,16 +1369,9 @@ static void bss_property(const char *key, DBusMessageIter *iter,
        SUPPLICANT_DBG("key %s", key);
 
        if (key == NULL) {
-               if (bss->ieee8021x == TRUE)
-                       bss->security = G_SUPPLICANT_SECURITY_IEEE8021X;
-               else if (bss->psk == TRUE)
-                       bss->security = G_SUPPLICANT_SECURITY_PSK;
-               else if (bss->privacy == TRUE)
-                       bss->security = G_SUPPLICANT_SECURITY_WEP;
-               else
-                       bss->security = G_SUPPLICANT_SECURITY_NONE;
+               bss_compute_security(bss);
 
-               add_bss_to_network(bss);
+               add_or_replace_bss_to_network(bss);
                return;
        }