diff options
author | Nishant Chaprana <n.chaprana@samsung.com> | 2020-04-29 09:59:30 +0530 |
---|---|---|
committer | Nishant Chaprana <n.chaprana@samsung.com> | 2020-05-04 14:39:06 +0530 |
commit | 581b2a808687d38a6181808b385a16c5fc2ed526 (patch) | |
tree | 632071e60652db31f8923ce507ae81e0ed7354c5 | |
parent | 5d602b3212b4d107bd8706357c89e79ebbcf0e70 (diff) | |
download | connman-581b2a808687d38a6181808b385a16c5fc2ed526.tar.gz connman-581b2a808687d38a6181808b385a16c5fc2ed526.tar.bz2 connman-581b2a808687d38a6181808b385a16c5fc2ed526.zip |
Add support of EAP on Ethernet.
Change-Id: I373ab90bbb699be56d9e416346a51b0795ed1e8b
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
-rw-r--r-- | configure.ac | 5 | ||||
-rwxr-xr-x | gsupplicant/dbus.c | 1 | ||||
-rwxr-xr-x | gsupplicant/gsupplicant.h | 18 | ||||
-rwxr-xr-x | gsupplicant/supplicant.c | 102 | ||||
-rwxr-xr-x | include/network.h | 3 | ||||
-rw-r--r-- | packaging/connman.spec | 3 | ||||
-rw-r--r-- | plugins/ethernet.c | 134 | ||||
-rwxr-xr-x | plugins/wifi.c | 157 | ||||
-rwxr-xr-x | src/connman.h | 4 | ||||
-rwxr-xr-x | src/network.c | 19 | ||||
-rwxr-xr-x | src/service.c | 73 |
11 files changed, 517 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index 75ba90cc..bdece8d7 100644 --- a/configure.ac +++ b/configure.ac @@ -92,6 +92,11 @@ AC_ARG_ENABLE(tizen-ext-wifi-mesh, [CFLAGS="$CFLAGS -DTIZEN_EXT_WIFI_MESH"], [enable_tizen_ext_wifi_mesh="no"]) AM_CONDITIONAL(TIZEN_EXT_WIFI_MESH, test "${enable_tizen_ext_wifi_mesh}" != "no") +AC_ARG_ENABLE(tizen-ext-eap-on-ethernet, + AC_HELP_STRING([--enable-tizen-ext-eap-on-ethernet], [enable TIZEN extensions for EAP on Ethernet]), + [CFLAGS="$CFLAGS -DTIZEN_EXT_EAP_ON_ETHERNET"], [enable_tizen_ext_eap_on_ethernet="no"]) +AM_CONDITIONAL(TIZEN_EXT_EAP_ON_ETHERNET, test "${enable_tizen_ext_eap_on_ethernet}" != "no") + AC_ARG_ENABLE(tizen-maintain-online, AC_HELP_STRING([--enable-tizen-maintain-online], [enable TIZEN extensions]), [if (test "${enableval}" = "yes"); then diff --git a/gsupplicant/dbus.c b/gsupplicant/dbus.c index 2957979a..9ad8e080 100755 --- a/gsupplicant/dbus.c +++ b/gsupplicant/dbus.c @@ -30,6 +30,7 @@ #include <glib.h> #include "dbus.h" +#include <connman/log.h> #define TIMEOUT 30000 diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index 6dfd9c72..6cf85f3c 100755 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -487,6 +487,10 @@ GSupplicantNetwork *g_supplicant_interface_get_network(GSupplicantInterface *int const char *group); #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +typedef void (*g_supplicant_eap_callback)(GSupplicantInterface *interface, bool status); +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + struct _GSupplicantCallbacks { void (*system_ready) (void); void (*system_killed) (void); @@ -531,6 +535,10 @@ struct _GSupplicantCallbacks { void (*mesh_peer_connected) (GSupplicantMeshPeer *mesh_peer); void (*mesh_peer_disconnected) (GSupplicantMeshPeer *mesh_peer); #endif + +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + g_supplicant_eap_callback eap; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ }; typedef struct _GSupplicantCallbacks GSupplicantCallbacks; @@ -542,7 +550,17 @@ void g_supplicant_set_ins_settings(GSupplicantINSPreferredFreq preferred_freq_bs unsigned int assoc_reject_score, int signal_level3_5ghz, int signal_level3_24ghz); #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +void g_supplicant_replace_config_file(const char *ifname, const char *config_file); +void g_supplicant_register_eap_callback(g_supplicant_eap_callback cb); +void g_supplicant_unregister_eap_callback(void); +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +int g_supplicant_register(GSupplicantCallbacks *callbacks); +#else /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ int g_supplicant_register(const GSupplicantCallbacks *callbacks); +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ void g_supplicant_unregister(const GSupplicantCallbacks *callbacks); static inline diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index d59085d0..759e165b 100755 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -69,7 +69,11 @@ static DBusConnection *connection; +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +static GSupplicantCallbacks *callbacks_pointer; +#else /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ static const GSupplicantCallbacks *callbacks_pointer; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ static dbus_bool_t system_available = FALSE; static dbus_bool_t system_ready = FALSE; @@ -906,6 +910,19 @@ static void callback_sta_deauthorized(GSupplicantInterface *interface, callbacks_pointer->sta_deauthorized(interface, addr); } +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +static void callback_eap(GSupplicantInterface *interface, bool status) +{ + if (!callbacks_pointer) + return; + + if (!callbacks_pointer->eap) + return; + + callbacks_pointer->eap(interface, status); +} +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + static void callback_peer_found(GSupplicantPeer *peer) { if (!callbacks_pointer) @@ -3441,6 +3458,21 @@ static void wps_property(const char *key, DBusMessageIter *iter, } +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +void g_supplicant_replace_config_file(const char *ifname, const char *config_file) +{ + if (!ifname) + return; + + if (!config_file) + return; + + SUPPLICANT_DBG("New {%s, %s}", ifname, config_file); + g_hash_table_replace(config_file_table, + g_strdup(ifname), g_strdup(config_file)); +} +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + static void interface_property(const char *key, DBusMessageIter *iter, void *user_data) { @@ -4015,6 +4047,40 @@ static void signal_sta_deauthorized(const char *path, DBusMessageIter *iter) callback_sta_deauthorized(interface, addr); } +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +static void signal_eap(const char *path, DBusMessageIter *iter) +{ + GSupplicantInterface *interface; + const char *str = NULL; + + SUPPLICANT_DBG("EAPOL_DEBUG callback eap signal"); + + interface = g_hash_table_lookup(interface_table, path); + if (!interface) + return; + + // TODO: Identify EAP fail condition, currently timeout is used for failure. + + dbus_message_iter_get_basic(iter, &str); + if (!str) + return; + + if (g_strcmp0("completion", str)) + return; + + dbus_message_iter_next(iter); + + dbus_message_iter_get_basic(iter, &str); + if (!str) + return; + + if (!g_strcmp0("success", str)) + callback_eap(interface, true); + else + callback_eap(interface, false); +} +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + static void signal_bss_changed(const char *path, DBusMessageIter *iter) { GSupplicantInterface *interface; @@ -5090,6 +5156,10 @@ static struct { signal_mesh_peer_disconnected }, #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + { SUPPLICANT_INTERFACE ".Interface", "EAP", signal_eap }, +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + { } }; @@ -5764,7 +5834,6 @@ static void interface_remove_params(DBusMessageIter *iter, void *user_data) &data->interface->path); } - int g_supplicant_interface_remove(GSupplicantInterface *interface, GSupplicantInterfaceCallback callback, void *user_data) @@ -8221,7 +8290,37 @@ void g_supplicant_set_ins_settings(GSupplicantINSPreferredFreq preferred_freq_bs } #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +void g_supplicant_register_eap_callback(g_supplicant_eap_callback cb) +{ + SUPPLICANT_DBG("g_supplicant_register_eap_callback %p", cb); + + if (!callbacks_pointer) { + SUPPLICANT_DBG("callbacks_pointer is NULL"); + return; + } + + callbacks_pointer->eap = cb; +} + +void g_supplicant_unregister_eap_callback(void) +{ + SUPPLICANT_DBG("g_supplicant_unregister_eap_callback"); + + if (!callbacks_pointer) { + SUPPLICANT_DBG("callbacks_pointer is NULL"); + return; + } + + callbacks_pointer->eap = NULL; +} +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +int g_supplicant_register(GSupplicantCallbacks *callbacks) +#else /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ int g_supplicant_register(const GSupplicantCallbacks *callbacks) +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ { connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); if (!connection) @@ -8283,6 +8382,7 @@ int g_supplicant_register(const GSupplicantCallbacks *callbacks) } else invoke_introspect_method(); + SUPPLICANT_DBG("supplicant dbus setup completed"); return 0; } diff --git a/include/network.h b/include/network.h index fc68d300..a9f4f017 100755 --- a/include/network.h +++ b/include/network.h @@ -146,6 +146,9 @@ bool connman_network_get_connecting(struct connman_network *network); #if defined TIZEN_EXT void connman_network_set_connecting(struct connman_network *network); #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +bool connman_network_check_validity(struct connman_network *network); +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ int connman_network_set_available(struct connman_network *network, bool available); bool connman_network_get_available(struct connman_network *network); diff --git a/packaging/connman.spec b/packaging/connman.spec index 3351c8d9..7ff85ebe 100644 --- a/packaging/connman.spec +++ b/packaging/connman.spec @@ -5,7 +5,7 @@ Name: connman Version: 1.37 -Release: 38 +Release: 39 License: GPL-2.0+ Summary: Connection Manager Url: http://connman.net @@ -154,6 +154,7 @@ chmod +x bootstrap --enable-client \ --enable-tizen-ext \ --disable-tizen-ext-ins \ + --enable-tizen-ext-eap-on-ethernet \ --enable-pacrunner \ --enable-wifi=builtin \ %if %{with connman_openconnect} diff --git a/plugins/ethernet.c b/plugins/ethernet.c index 9e157467..6702cd38 100644 --- a/plugins/ethernet.c +++ b/plugins/ethernet.c @@ -53,6 +53,11 @@ #include <connman/mesh.h> #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +#include <connman/option.h> +#include <gsupplicant/gsupplicant.h> +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + static bool eth_tethering = false; struct ethernet_data { @@ -60,6 +65,9 @@ struct ethernet_data { unsigned flags; unsigned int watch; struct connman_network *network; +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + GSupplicantInterface *interface; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ }; @@ -142,6 +150,123 @@ static void eth_network_remove(struct connman_network *network) DBG("network %p", network); } +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +static struct connman_network *g_network = NULL; + +void handle_eap_signal(GSupplicantInterface *interface, bool status) +{ + DBG("captured EAP signal"); + + if (!g_network) + return; + + if (g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; + + if (!connman_network_check_validity(g_network)) + return; + + DBG("network is valid"); + + g_supplicant_unregister_eap_callback(); + + if (!status) { + // Should we mark service as non favorite or make autoconnect as false? + + g_supplicant_interface_remove(interface, NULL, NULL); + connman_network_set_error(g_network, CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL); + g_network = NULL; + return; + } + + connman_network_set_connected(g_network, status); + g_network = NULL; +} + +static void interface_create_callback(int result, + GSupplicantInterface *interface, void *user_data) +{ + struct ethernet_data *ethernet = user_data; + + if (result < 0 || !interface || !ethernet) + return; + + DBG("result %d ifname %s, ethernet %p", result, + g_supplicant_interface_get_ifname(interface), + ethernet); + + ethernet->interface = interface; + g_supplicant_interface_set_data(interface, ethernet); +} + +static int eth_network_connect(struct connman_network *network) +{ + DBG("network %p", network); + + struct connman_service *service = connman_service_lookup_from_network(network); + + if (service && __connman_service_get_use_eapol(service)) { + struct connman_device *device = connman_network_get_device(network); + struct ethernet_data *ethernet = connman_device_get_data(device); + const char *driver = "wired"; + int index = connman_network_get_index(network); + char *ifname = connman_inet_ifname(index);; + char *config_file = NULL; + + g_supplicant_register_eap_callback(handle_eap_signal); + g_network = network; + + if (asprintf(&config_file, "/opt/usr/data/network/%s-eapol.conf", ifname) < 0) + return -ENOMEM; + + DBG("config_file %s", config_file); + + g_supplicant_replace_config_file(ifname, config_file); + free(config_file); + + /* + * TODO: RemoveInterface if already present because + * already created interface will not start EAP handshake. + */ + g_supplicant_interface_create(ifname, driver, NULL, + interface_create_callback, ethernet); + + g_free(ifname); + + return 0; + } + + connman_network_set_connected(network, true); + + return 0; +} + +static int eth_network_disconnect(struct connman_network *network) +{ + DBG("network %p", network); + + struct connman_service *service = connman_service_lookup_from_network(network); + + if (service && __connman_service_get_use_eapol(service)) { + struct connman_device *device = connman_network_get_device(network); + struct ethernet_data *ethernet = connman_device_get_data(device); + + g_network = NULL; + g_supplicant_unregister_eap_callback(); + g_supplicant_interface_remove(ethernet->interface, NULL, NULL); + connman_network_set_associating(network, false); + connman_network_set_connected(network, false); + + return 0; + } + + connman_network_set_connected(network, false); + + return 0; +} + +#else /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + static int eth_network_connect(struct connman_network *network) { DBG("network %p", network); @@ -160,6 +285,8 @@ static int eth_network_disconnect(struct connman_network *network) return 0; } +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + static struct connman_network_driver eth_network_driver = { .name = "cable", .type = CONNMAN_NETWORK_TYPE_ETHERNET, @@ -281,6 +408,9 @@ static int eth_dev_probe(struct connman_device *device) ethernet->index = connman_device_get_index(device); ethernet->flags = 0; +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + ethernet->interface = NULL; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ ethernet->watch = connman_rtnl_add_newlink_watch(ethernet->index, ethernet_newlink, device); @@ -296,6 +426,10 @@ static void eth_dev_remove(struct connman_device *device) connman_device_set_data(device, NULL); +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + g_supplicant_interface_remove(ethernet->interface, NULL, NULL); +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + connman_rtnl_remove_watch(ethernet->watch); remove_network(device, ethernet); diff --git a/plugins/wifi.c b/plugins/wifi.c index bce1424f..cbc6b152 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -3905,6 +3905,15 @@ static void interface_added(GSupplicantInterface *interface) { const char *ifname = g_supplicant_interface_get_ifname(interface); const char *driver = g_supplicant_interface_get_driver(interface); +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + #if defined TIZEN_EXT bool is_5_0_ghz_supported = g_supplicant_interface_get_is_5_0_ghz_supported(interface); #endif @@ -4179,6 +4188,15 @@ static void interface_state(GSupplicantInterface *interface) struct connman_device *device; struct wifi_data *wifi; GSupplicantState state = g_supplicant_interface_get_state(interface); +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + bool wps; bool old_connected; @@ -4442,6 +4460,15 @@ static void interface_removed(GSupplicantInterface *interface) { const char *ifname = g_supplicant_interface_get_ifname(interface); struct wifi_data *wifi; +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + DBG("ifname %s", ifname); @@ -4510,6 +4537,15 @@ static void p2p_support(GSupplicantInterface *interface) { char dev_type[17] = {}; const char *hostname; +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + DBG(""); @@ -4536,11 +4572,29 @@ static void p2p_support(GSupplicantInterface *interface) static void scan_started(GSupplicantInterface *interface) { +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + DBG(""); } static void scan_finished(GSupplicantInterface *interface) { +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + #if defined TIZEN_EXT struct wifi_data *wifi; bool is_associating = false; @@ -4577,6 +4631,15 @@ static void scan_finished(GSupplicantInterface *interface) static void ap_create_fail(GSupplicantInterface *interface) { +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + struct wifi_data *wifi = g_supplicant_interface_get_data(interface); int ret; @@ -4742,6 +4805,15 @@ static void network_added(GSupplicantNetwork *supplicant_network) #endif interface = g_supplicant_network_get_interface(supplicant_network); +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + wifi = g_supplicant_interface_get_data(interface); name = g_supplicant_network_get_name(supplicant_network); security = g_supplicant_network_get_security(supplicant_network); @@ -4890,6 +4962,15 @@ static void network_removed(GSupplicantNetwork *network) #endif interface = g_supplicant_network_get_interface(network); +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + wifi = g_supplicant_interface_get_data(interface); identifier = g_supplicant_network_get_identifier(network); name = g_supplicant_network_get_name(network); @@ -4940,6 +5021,15 @@ static void network_changed(GSupplicantNetwork *network, const char *property) #endif interface = g_supplicant_network_get_interface(network); +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + wifi = g_supplicant_interface_get_data(interface); identifier = g_supplicant_network_get_identifier(network); name = g_supplicant_network_get_name(network); @@ -5057,6 +5147,15 @@ static void network_associated(GSupplicantNetwork *network) interface = g_supplicant_network_get_interface(network); if (!interface) return; +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + wifi = g_supplicant_interface_get_data(interface); if (!wifi) @@ -5103,6 +5202,15 @@ static void network_associated(GSupplicantNetwork *network) static void sta_authorized(GSupplicantInterface *interface, const char *addr) { +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + struct wifi_data *wifi = g_supplicant_interface_get_data(interface); DBG("wifi %p station %s authorized", wifi, addr); @@ -5116,6 +5224,15 @@ static void sta_authorized(GSupplicantInterface *interface, static void sta_deauthorized(GSupplicantInterface *interface, const char *addr) { +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + struct wifi_data *wifi = g_supplicant_interface_get_data(interface); DBG("wifi %p station %s deauthorized", wifi, addr); @@ -5351,6 +5468,15 @@ static void network_merged(GSupplicantNetwork *network) if (!interface) return; +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + state = g_supplicant_interface_get_state(interface); if (state < G_SUPPLICANT_STATE_AUTHENTICATING) return; @@ -5411,6 +5537,15 @@ static void assoc_failed(void *user_data) static void scan_done(GSupplicantInterface *interface) { +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + GList *list; int scan_type = CONNMAN_SCAN_TYPE_WPA_SUPPLICANT; struct wifi_data *wifi; @@ -5443,6 +5578,15 @@ static void debug(const char *str) static void disconnect_reasoncode(GSupplicantInterface *interface, int reasoncode) { +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + struct wifi_data *wifi = g_supplicant_interface_get_data(interface); if (wifi != NULL) { @@ -5452,6 +5596,15 @@ static void disconnect_reasoncode(GSupplicantInterface *interface, static void assoc_status_code(GSupplicantInterface *interface, int status_code) { +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If supplicant interface's driver is wired then skip it, + * because it meanti only for ethernet not Wi-Fi. + */ + if (!g_strcmp0("wired", g_supplicant_interface_get_driver(interface))) + return; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + struct wifi_data *wifi = g_supplicant_interface_get_data(interface); if (wifi != NULL) { @@ -5459,7 +5612,11 @@ static void assoc_status_code(GSupplicantInterface *interface, int status_code) } } +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +static GSupplicantCallbacks callbacks = { +#else /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ static const GSupplicantCallbacks callbacks = { +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ .system_ready = system_ready, .system_killed = system_killed, .interface_added = interface_added, diff --git a/src/connman.h b/src/connman.h index a2608396..2f2f5a8e 100755 --- a/src/connman.h +++ b/src/connman.h @@ -823,6 +823,10 @@ bool __connman_service_get_auto_connect_mode(void); void __connman_service_set_auto_connect_mode(bool enable); #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +int __connman_service_get_use_eapol(struct connman_service *service); +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + bool __connman_service_remove(struct connman_service *service); bool __connman_service_is_provider_pending(struct connman_service *service); void __connman_service_set_provider_pending(struct connman_service *service, diff --git a/src/network.c b/src/network.c index f1183b37..334202c0 100755 --- a/src/network.c +++ b/src/network.c @@ -1730,6 +1730,13 @@ static gboolean __connman_network_clear_associating_delayed(gpointer user_data) } #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +bool connman_network_check_validity(struct connman_network *network) +{ + return (NULL == g_slist_find(network_list, network)) ? false : true; +} +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + /** * connman_network_set_associating: * @network: network structure @@ -2069,6 +2076,18 @@ int __connman_network_connect(struct connman_network *network) return err; } +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * Note: If EAP on Ethernet is ON, then network will be connected + * after EAP Success event is recieved, from plugin/ethernet.c + */ + struct connman_service *service = connman_service_lookup_from_network(network); + if (service && __connman_service_get_use_eapol(service)) { + connman_network_set_associating(network, true); + return 0; + } +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + set_connected(network); return err; diff --git a/src/service.c b/src/service.c index 20123197..e21f68a0 100755 --- a/src/service.c +++ b/src/service.c @@ -240,6 +240,12 @@ struct connman_service { #endif int ins_score; #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + /* + * To indicate use of EAP over Ethernet. + */ + bool use_eapol; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ }; static bool allow_property_changed(struct connman_service *service); @@ -882,6 +888,9 @@ static int service_load(struct connman_service *service) #if defined TIZEN_EXT bool internet_connection; #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + bool use_eapol; +#endif DBG("service %p", service); @@ -1018,6 +1027,14 @@ static int service_load(struct connman_service *service) if (!error) service->autoconnect = autoconnect; g_clear_error(&error); + +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + use_eapol = g_key_file_get_boolean(keyfile, + service->identifier, "UseEapol", &error); + if (!error) + service->use_eapol = use_eapol; + g_clear_error(&error); +#endif break; } @@ -1357,6 +1374,10 @@ static int service_save(struct connman_service *service) if (service->favorite) g_key_file_set_boolean(keyfile, service->identifier, "AutoConnect", service->autoconnect); +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + g_key_file_set_boolean(keyfile, service->identifier, + "UseEapol", service->use_eapol); +#endif break; } @@ -2826,6 +2847,26 @@ void connman_service_set_disconnection_requested(struct connman_service *service } #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +static void use_eapol_changed(struct connman_service *service) +{ + dbus_bool_t use_eapol; + + if (!service->path) + return; + + if (!allow_property_changed(service)) + return; + + use_eapol = service->use_eapol; + connman_dbus_property_changed_basic(service->path, + CONNMAN_SERVICE_INTERFACE, + "UseEapol", + DBUS_TYPE_BOOLEAN, + &use_eapol); +} +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + static void strength_changed(struct connman_service *service) { if (service->strength == 0) @@ -4111,6 +4152,11 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited, break; #endif case CONNMAN_SERVICE_TYPE_ETHERNET: +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + val = service->use_eapol; + connman_dbus_dict_append_basic(dict, "UseEapol", + DBUS_TYPE_BOOLEAN, &val); +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ case CONNMAN_SERVICE_TYPE_BLUETOOTH: case CONNMAN_SERVICE_TYPE_GADGET: connman_dbus_dict_append_dict(dict, "Ethernet", @@ -5020,6 +5066,18 @@ const char *__connman_service_get_passphrase(struct connman_service *service) return service->passphrase; } +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET +int __connman_service_get_use_eapol(struct connman_service *service) +{ + if (!service) { + DBG("Service is NULL"); + return -1; + } + + return service->use_eapol; +} +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ + static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg, void *user_data) { @@ -5725,6 +5783,18 @@ static DBusMessage *set_property(DBusConnection *conn, __connman_service_set_passphrase(service, passphrase); #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + } else if (g_str_equal(name, "UseEapol")) { + dbus_bool_t use_eapol; + + if (type != DBUS_TYPE_BOOLEAN) + return __connman_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&value, &use_eapol); + + service->use_eapol = use_eapol; + service_save(service); +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ } else return __connman_error_invalid_property(msg); @@ -7142,6 +7212,9 @@ static void service_initialize(struct connman_service *service) service->user_pdn_connection_refcount = 0; __sync_synchronize(); #endif +#if defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET + service->use_eapol = false; +#endif /* defined TIZEN_EXT && defined TIZEN_EXT_EAP_ON_ETHERNET */ } /** |