From: Jaehyun Kim Date: Tue, 20 Feb 2018 06:37:40 +0000 (+0900) Subject: Added new dbus method to support bssid based connection X-Git-Tag: accepted/tizen/unified/20180227.062953~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fconnman.git;a=commitdiff_plain;h=63d4f774d04c381000e45e7490bc838da9b36027 Added new dbus method to support bssid based connection Change-Id: I95d2a56c1d26db06cbdb5c85dc0e2b33b3c10da3 Signed-off-by: Jaehyun Kim --- diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index 46d065b..0476ff6 100755 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -173,6 +173,8 @@ struct _GSupplicantSSID { int ignore_broadcast_ssid; #if defined TIZEN_EXT unsigned char *bssid; + unsigned int bssid_for_connect_len; + unsigned char bssid_for_connect[6]; #endif }; diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index 724520e..9b7a934 100644 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -4815,7 +4815,8 @@ static void interface_select_network_params(DBusMessageIter *iter, dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &interface->network_path); #if defined TIZEN_EXT - dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &ssid->freq); + if (!ssid->bssid_for_connect_len) + dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &ssid->freq); #endif } @@ -4842,14 +4843,20 @@ static void interface_add_network_result(const char *error, #if defined TIZEN_EXT SUPPLICANT_DBG(".Interface.SelectNetworkFreq"); -#endif + GSupplicantSSID *ssid = data->ssid; -#if defined TIZEN_EXT - supplicant_dbus_method_call(data->interface->path, - SUPPLICANT_INTERFACE ".Interface", "SelectNetworkFreq", - interface_select_network_params, - interface_select_network_result, data, - interface); + if (!ssid->bssid_for_connect_len) + supplicant_dbus_method_call(data->interface->path, + SUPPLICANT_INTERFACE ".Interface", "SelectNetworkFreq", + interface_select_network_params, + interface_select_network_result, data, + interface); + else + supplicant_dbus_method_call(data->interface->path, + SUPPLICANT_INTERFACE ".Interface", "SelectNetwork", + interface_select_network_params, + interface_select_network_result, data, + interface); #else supplicant_dbus_method_call(data->interface->path, SUPPLICANT_INTERFACE ".Interface", "SelectNetwork", @@ -5401,9 +5408,16 @@ static void interface_add_network_params(DBusMessageIter *iter, void *user_data) supplicant_dbus_dict_close(iter, &dict); return; } - snprintf(bssid, 18, "%02x:%02x:%02x:%02x:%02x:%02x", + + if (ssid->bssid_for_connect_len) + snprintf(bssid, 18, "%02x:%02x:%02x:%02x:%02x:%02x", + ssid->bssid_for_connect[0], ssid->bssid_for_connect[1], ssid->bssid_for_connect[2], + ssid->bssid_for_connect[3], ssid->bssid_for_connect[4], ssid->bssid_for_connect[5]); + else + snprintf(bssid, 18, "%02x:%02x:%02x:%02x:%02x:%02x", ssid->bssid[0], ssid->bssid[1], ssid->bssid[2], ssid->bssid[3], ssid->bssid[4], ssid->bssid[5]); + supplicant_dbus_dict_append_basic(&dict, "bssid", DBUS_TYPE_STRING, &bssid); g_free(bssid); diff --git a/plugins/wifi.c b/plugins/wifi.c index c66f838..3d7636c 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -2393,6 +2393,8 @@ static void connect_callback(int result, GSupplicantInterface *interface, DBG("network %p result %d", network, result); #if defined TIZEN_EXT + set_connman_bssid(RESET_BSSID, NULL); + for (list = iface_list; list; list = list->next) { wifi = list->data; @@ -2500,7 +2502,16 @@ static void ssid_init(GSupplicantSSID *ssid, struct connman_network *network) ssid->bssid = connman_network_get_bssid(network); #endif #if defined TIZEN_EXT - ssid->freq = connman_network_get_frequency(network); + if (set_connman_bssid(CHECK_BSSID, NULL) == 6) { + ssid->bssid_for_connect_len = 6; + set_connman_bssid(GET_BSSID, (char *)ssid->bssid_for_connect); + DBG("BSSID : %02x:%02x:%02x:%02x:%02x:%02x", + ssid->bssid_for_connect[0], ssid->bssid_for_connect[1], + ssid->bssid_for_connect[2], ssid->bssid_for_connect[3], + ssid->bssid_for_connect[4], ssid->bssid_for_connect[5]); + } else { + ssid->freq = connman_network_get_frequency(network); + } #endif if (connman_setting_get_bool("BackgroundScanning")) @@ -2803,7 +2814,7 @@ static bool handle_wps_completion(GSupplicantInterface *interface, return true; } - ret = send_encryption_request(passphrase, passphrase); + ret = send_encryption_request(passphrase, network); g_free(passphrase); diff --git a/src/connman.h b/src/connman.h index 4125463..a5977b8 100755 --- a/src/connman.h +++ b/src/connman.h @@ -564,6 +564,17 @@ void __connman_technology_remove_interface(enum connman_service_type type, void __connman_technology_notify_regdom_by_device(struct connman_device *device, int result, const char *alpha2); +#if defined TIZEN_EXT +enum bssid_type { + CHECK_BSSID = 0, + GET_BSSID = 1, + SET_BSSID = 2, + RESET_BSSID = 3, +}; + +int set_connman_bssid(enum bssid_type mode, char *bssid); +#endif + #include int __connman_device_init(const char *device, const char *nodevice); diff --git a/src/technology.c b/src/technology.c index 5aea9f4..5d5b70f 100755 --- a/src/technology.c +++ b/src/technology.c @@ -25,6 +25,9 @@ #include #include +#if defined TIZEN_EXT +#include +#endif #include @@ -876,6 +879,49 @@ make_reply: return reply; } +#if defined TIZEN_EXT +int set_connman_bssid(enum bssid_type mode, char *bssid) +{ + static unsigned char bssid_for_connect[6]; + static int bssid_len; + + DBG("mode : %d", mode); + + if (mode == CHECK_BSSID) { + return bssid_len; + } + + if (mode == GET_BSSID && bssid) { + memcpy(bssid, bssid_for_connect, 6); + return bssid_len; + } + + if (mode == RESET_BSSID) { + bssid_len = 0; + return bssid_len; + } + + if (mode != SET_BSSID || !bssid) { + DBG("Invalid parameter"); + return 0; + } + + bssid_len = sscanf(bssid, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", + &bssid_for_connect[0], &bssid_for_connect[1], &bssid_for_connect[2], + &bssid_for_connect[3], &bssid_for_connect[4], &bssid_for_connect[5]); + if (bssid_len != 6) { + DBG("Incorrect BSSID format. bssid_len = %d", bssid_len); + bssid_len = 0; + } + + DBG("SET BSSID len : %d, BSSID : %02x:%02x:%02x:%02x:%02x:%02x", bssid_len, + bssid_for_connect[0], bssid_for_connect[1], bssid_for_connect[2], + bssid_for_connect[3], bssid_for_connect[4], bssid_for_connect[5]); + + return bssid_len; +} +#endif + static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -1023,6 +1069,17 @@ static DBusMessage *set_property(DBusConnection *conn, dbus_message_iter_get_basic(&value, &enable); return set_powered(technology, msg, enable); +#if defined TIZEN_EXT + } else if (g_str_equal(name, "SetBSSID")) { + char *key; + + if (type != DBUS_TYPE_STRING) + return __connman_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&value, &key); + DBG("BSSID %s", key); + set_connman_bssid(SET_BSSID, key); +#endif } else return __connman_error_invalid_property(msg);