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 /plugins | |
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>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ethernet.c | 134 | ||||
-rwxr-xr-x | plugins/wifi.c | 157 |
2 files changed, 291 insertions, 0 deletions
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, |