Send Mac policy parameters in CreateInterface dbus call. 86/257686/1 accepted/tizen/unified/20210506.103545 submit/tizen/20210503.112345
authorNishant Chaprana <n.chaprana@samsung.com>
Thu, 29 Apr 2021 10:01:45 +0000 (15:31 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Thu, 29 Apr 2021 10:01:45 +0000 (15:31 +0530)
This patch will send mac policy parameters in CreateInteraface dbus call
and will make 3 dbus calls to set mac policy parameters when interface is
already created in wpa_supplicant.

Change-Id: Icd7ce43d1b67fe5211ab15d2ab20fd47038907f1
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
gsupplicant/gsupplicant.h
gsupplicant/supplicant.c
packaging/connman.spec
plugins/ethernet.c
plugins/wifi.c
src/device.c

index 991554b..05af5de 100755 (executable)
@@ -312,6 +312,11 @@ void g_supplicant_interface_cancel(GSupplicantInterface *interface);
 
 int g_supplicant_interface_create(const char *ifname, const char *driver,
                                        const char *bridge,
+#ifdef TIZEN_EXT
+                                       unsigned int mac_policy,
+                                       unsigned int preassoc_mac_policy,
+                                       unsigned int random_mac_lifetime,
+#endif /* TIZEN_EXT */
                                        GSupplicantInterfaceCallback callback,
                                                        void *user_data);
 int g_supplicant_interface_remove(GSupplicantInterface *interface,
index bb1bfa7..0f01e95 100755 (executable)
@@ -5692,7 +5692,7 @@ static void interface_create_params(DBusMessageIter *iter, void *user_data)
        }
 
 #ifdef TIZEN_EXT
-       if (!g_strcmp0(data->driver, "wifi")) {
+       if (data->driver && g_strstr_len(data->driver, strlen(data->driver), "nl80211")) {
                supplicant_dbus_dict_append_basic(&dict, "MacAddr",
                                DBUS_TYPE_UINT32, &data->mac_addr);
 
@@ -5967,6 +5967,11 @@ int g_supplicant_interface_mesh_peer_change_status(
 
 int g_supplicant_interface_create(const char *ifname, const char *driver,
                                        const char *bridge,
+#ifdef TIZEN_EXT
+                                       unsigned int mac_policy,
+                                       unsigned int preassoc_mac_policy,
+                                       unsigned int random_mac_lifetime,
+#endif /* TIZEN_EXT */
                                        GSupplicantInterfaceCallback callback,
                                                        void *user_data)
 {
@@ -5989,6 +5994,11 @@ int g_supplicant_interface_create(const char *ifname, const char *driver,
        data->driver = g_strdup(driver);
        data->bridge = g_strdup(bridge);
        data->callback = callback;
+#ifdef TIZEN_EXT
+       data->mac_addr = mac_policy;
+       data->preassoc_mac_addr = preassoc_mac_policy;
+       data->random_mac_lifetime = random_mac_lifetime;
+#endif /* TIZEN_EXT */
        data->user_data = user_data;
 
        ret = supplicant_dbus_method_call(SUPPLICANT_PATH,
index ac63c63..72c277a 100644 (file)
@@ -6,7 +6,7 @@
 
 Name:           connman
 Version:        1.38
-Release:        6
+Release:        7
 License:        GPL-2.0+
 Summary:        Connection Manager
 Url:            http://connman.net
index 3bf80a5..4dda80c 100644 (file)
@@ -247,7 +247,7 @@ static int eapol_interface_create(void)
         *  already created interface will not start EAP handshake.
         */
        return g_supplicant_interface_create(ifname, driver, NULL,
-                       interface_create_callback, ethernet);
+                       0, 0, 60, interface_create_callback, ethernet);
 }
 
 static void enable_eapol_reply(DBusPendingCall *call, void *user_data)
index 5b4a0aa..6a886d5 100755 (executable)
@@ -175,6 +175,9 @@ struct wifi_data {
        bool allow_full_scan;
        unsigned int automaxspeed_timeout;
        GSupplicantScanParams *hidden_scan_params;
+       unsigned int mac_policy;
+       unsigned int preassoc_mac_policy;
+       unsigned int mac_lifetime;
 #endif
        int disconnect_code;
        int assoc_code;
@@ -2435,12 +2438,6 @@ static void setup_autoscan(struct wifi_data *wifi)
 #endif
 }
 
-#ifdef TIZEN_EXT
-int wifi_set_mac_policy(struct connman_device *device, unsigned int policy);
-int wifi_set_preassoc_mac_policy(struct connman_device *device, unsigned int policy);
-int wifi_set_random_mac_lifetime(struct connman_device *device, unsigned int lifetime);
-#endif /* TIZEN_EXT */
-
 static void finalize_interface_creation(struct wifi_data *wifi)
 {
        DBG("interface is ready wifi %p tethering %d", wifi, wifi->tethering);
@@ -2452,17 +2449,6 @@ static void finalize_interface_creation(struct wifi_data *wifi)
 
        connman_device_set_powered(wifi->device, true);
 
-#ifdef TIZEN_EXT
-       wifi_set_mac_policy(wifi->device,
-                               connman_device_get_mac_policy(wifi->device));
-
-       wifi_set_preassoc_mac_policy(wifi->device,
-                               connman_device_get_preassoc_mac_policy(wifi->device));
-
-       wifi_set_random_mac_lifetime(wifi->device,
-                               connman_device_get_random_mac_lifetime(wifi->device));
-#endif /* TIZEN_EXT */
-
        if (wifi->p2p_device)
                return;
 
@@ -2513,6 +2499,11 @@ static int wifi_enable(struct connman_device *device)
 
        interface = connman_inet_ifname(index);
        ret = g_supplicant_interface_create(interface, driver, NULL,
+#ifdef TIZEN_EXT
+                       connman_device_get_mac_policy(device),
+                       connman_device_get_preassoc_mac_policy(device),
+                       connman_device_get_random_mac_lifetime(device),
+#endif /* TIZEN_EXT */
                                                interface_create_callback,
                                                        wifi);
        g_free(interface);
@@ -5963,6 +5954,9 @@ static void sta_remove_callback(int result,
        info->wifi->interface = NULL;
 
        g_supplicant_interface_create(info->ifname, driver, info->wifi->bridge,
+#ifdef TIZEN_EXT
+                       0, 0, 60,
+#endif /* TIZEN_EXT */
                                                ap_create_callback,
                                                        info);
 }
index 53aa111..89258ba 100755 (executable)
@@ -266,6 +266,13 @@ int __connman_device_enable(struct connman_device *device)
        if (err == -EALREADY) {
                /* If device is already powered, but connman is not updated */
                connman_device_set_powered(device, true);
+#ifdef TIZEN_EXT
+               if (device->type == CONNMAN_DEVICE_TYPE_WIFI) {
+                       device->driver->set_mac_policy(device, device->mac_policy);
+                       device->driver->set_preassoc_mac_policy(device, device->preassoc_mac_policy);
+                       device->driver->set_random_mac_lifetime(device, device->random_mac_lifetime);
+               }
+#endif /* TIZEN_EXT */
                goto done;
        }
        /*