Add support of EAP on Ethernet. 99/232199/10
authorNishant Chaprana <n.chaprana@samsung.com>
Wed, 29 Apr 2020 04:29:30 +0000 (09:59 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Mon, 4 May 2020 09:09:06 +0000 (14:39 +0530)
Change-Id: I373ab90bbb699be56d9e416346a51b0795ed1e8b
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
configure.ac
gsupplicant/dbus.c
gsupplicant/gsupplicant.h
gsupplicant/supplicant.c
include/network.h
packaging/connman.spec
plugins/ethernet.c
plugins/wifi.c
src/connman.h
src/network.c
src/service.c

index 75ba90cc2433ecf0f4784c0f663b38aa0f41f454..bdece8d778dcb7ef2cadfe394c4071d531278d27 100644 (file)
@@ -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
index 2957979a435fbaf773fd172e09f957a09679062c..9ad8e080ec501735ceb3593e3ff605c20ff7be81 100755 (executable)
@@ -30,6 +30,7 @@
 #include <glib.h>
 
 #include "dbus.h"
+#include <connman/log.h>
 
 #define TIMEOUT 30000
 
index 6dfd9c7294d32443e6845673d70e59e3554f5a4d..6cf85f3c1795f92fe292e45c1fc4d698f781dcf4 100755 (executable)
@@ -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
index d59085d00fa9f463727d32288f52083026175267..759e165bdd00db66f7ecebec03f24ec4d99fb346 100755 (executable)
 
 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;
 }
 
index fc68d3001d74811d84067ab979b4d08a889fb288..a9f4f01721f32e9435b24e7ab6801670b5a7f5b2 100755 (executable)
@@ -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);
index 3351c8d9a97f85864b973320667efeeb0051546a..7ff85ebe3963c7f2fa163633c1bf208c10e4680b 100644 (file)
@@ -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}
index 9e157467f2c079316b32c763a4b39b96771fe488..6702cd38ef44a46407d831d49d69c255ec4c1334 100644 (file)
 #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);
index bce1424fec8f206b95d9f6e291f8f4e624b72d87..cbc6b152641c04c9a9c0ccfd21265af40a51d8c7 100755 (executable)
@@ -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,
index a2608396f4141118b630890e083d8c8fccf89f7c..2f2f5a8ea89e0ac25bd98dd2b5d121b69c61cc06 100755 (executable)
@@ -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,
index f1183b37de873ea44e8c8bb0bc1ee57c9d16e6ce..334202c0590fe3529c98a2ce3ac360da8b47156a 100755 (executable)
@@ -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;
index 201231979fb3de9129f4d31113a3e3e09e50fd0f..e21f68a05d4beb9563206ad6ed9cea03fd5aacf3 100755 (executable)
@@ -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 */
 }
 
 /**