Added APIs to support EAPoL connection. 72/230972/9 submit/tizen/20200504.135236
authorNiraj Kumar Goit <niraj.g@samsung.com>
Thu, 16 Apr 2020 08:33:04 +0000 (14:03 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Sun, 3 May 2020 19:06:23 +0000 (00:36 +0530)
Change-Id: Ie6cb28c31c2ad147ce371b1241b00b3969daef8e
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
include/connection_extension.h
include/net_connection_private.h
src/connection.c
src/connection_profile.c
src/libnetwork.c
test/connection_test.c

index 3086599..4d6038c 100755 (executable)
@@ -368,6 +368,7 @@ int connection_profile_get_ethernet_eap_type(connection_profile_h profile, conne
  * @retval #CONNECTION_ERROR_INVALID_PARAMETER         Invalid parameter
  * @retval #CONNECTION_ERROR_INVALID_OPERATION         Invalid operation
  * @retval #CONNECTION_ERROR_NOT_SUPPORTED             Not supported
+ * @pre This function needs connection_profile_set_ethernet_eap_type() before use.
  */
 int connection_profile_set_ethernet_eap_auth_type(connection_profile_h profile,
                                                connection_ethernet_eap_auth_type_e type);
index 0550e32..08f27ea 100755 (executable)
@@ -202,6 +202,11 @@ net_state_type_t _connection_profile_convert_to_net_state(connection_profile_sta
 int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile,
                        connection_cellular_subscriber_id_e sim_id);
 
+int _connection_libnet_enable_ethernet_eap(bool enable, const char *profilename);
+int _connection_libnet_ethernet_eap_enabled(bool *enabled);
+int _connection_libnet_profile_save_ethernet_eap_config(connection_handle_s *conn_handle,
+                       connection_profile_h profile);
+
 int _connection_libnet_start_tcpdump(connection_handle_s *conn_handle);
 int _connection_libnet_stop_tcpdump(connection_handle_s *conn_handle);
 int _connection_libnet_get_tcpdump_state(connection_handle_s *conn_handle,
index 100e958..cb6f53f 100755 (executable)
@@ -1811,3 +1811,30 @@ EXPORT_API int connection_profile_get_tcpdump_state(connection_h connection, gbo
        CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
+
+EXPORT_API int connection_profile_save_ethernet_eap_config(connection_h connection,
+                                                       connection_profile_h profile)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE);
+
+       int rv;
+
+       if (!__connection_check_handle_validity(connection) ||
+               !_connection_libnet_check_profile_validity(profile)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       rv = _connection_libnet_profile_save_ethernet_eap_config(connection, profile);
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to save ethernet eap config.");
+               CONN_UNLOCK;
+               return rv;
+       }
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
index 9fdd65b..8122d25 100755 (executable)
@@ -49,6 +49,136 @@ static net_dev_info_t* __profile_get_net_info(net_profile_info_t *profile_info)
        }
 }
 
+static bool __profile_ethernet_validate_eap_auth_type(net_dev_info_t *net_info)
+{
+       connection_ethernet_eap_type_e eap_type = net_info->eap.eap_type;
+
+       if (net_info->use_eapol == false)
+               return false;
+
+       if (eap_type != CONNECTION_ETHERNET_EAP_TYPE_PEAP &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_TTLS &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_FAST)
+               return false;
+
+       return true;
+}
+
+static bool __profile_ethernet_validate_eap_identity(net_dev_info_t *net_info)
+{
+       connection_ethernet_eap_type_e eap_type = net_info->eap.eap_type;
+
+       if (net_info->use_eapol == false)
+               return false;
+
+       if (eap_type != CONNECTION_ETHERNET_EAP_TYPE_MD5 &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_PEAP &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_TLS &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_TTLS &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_FAST)
+               return false;
+
+       return true;
+}
+
+static bool __profile_ethernet_validate_eap_anonymous_identity(net_dev_info_t *net_info)
+{
+       connection_ethernet_eap_type_e eap_type = net_info->eap.eap_type;
+
+       if (net_info->use_eapol == false)
+               return false;
+
+       if (eap_type != CONNECTION_ETHERNET_EAP_TYPE_PEAP &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_TTLS &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_FAST)
+               return false;
+
+       return true;
+}
+
+static bool __profile_ethernet_validate_eap_pac_file(net_dev_info_t *net_info)
+{
+       connection_ethernet_eap_type_e eap_type = net_info->eap.eap_type;
+
+       if (net_info->use_eapol == false)
+               return false;
+
+       if (eap_type != CONNECTION_ETHERNET_EAP_TYPE_FAST)
+               return false;
+
+       return true;
+}
+
+static bool __profile_ethernet_validate_eap_peap_version(net_dev_info_t *net_info)
+{
+       connection_ethernet_eap_type_e eap_type = net_info->eap.eap_type;
+
+       if (net_info->use_eapol == false)
+               return false;
+
+       if (eap_type != CONNECTION_ETHERNET_EAP_TYPE_PEAP)
+               return false;
+
+       return true;
+}
+
+static bool __profile_ethernet_validate_eap_private_key_file(net_dev_info_t *net_info)
+{
+       connection_ethernet_eap_type_e eap_type = net_info->eap.eap_type;
+
+       if (net_info->use_eapol == false)
+               return false;
+
+       if (eap_type != CONNECTION_ETHERNET_EAP_TYPE_TLS)
+               return false;
+
+       return true;
+}
+
+static bool __profile_ethernet_validate_eap_client_cert_file(net_dev_info_t *net_info)
+{
+       connection_ethernet_eap_type_e eap_type = net_info->eap.eap_type;
+
+       if (net_info->use_eapol == false)
+               return false;
+
+       if (eap_type != CONNECTION_ETHERNET_EAP_TYPE_TLS)
+               return false;
+
+       return true;
+}
+
+static bool __profile_ethernet_validate_eap_ca_cert_file(net_dev_info_t *net_info)
+{
+       connection_ethernet_eap_type_e eap_type = net_info->eap.eap_type;
+
+       if (net_info->use_eapol == false)
+               return false;
+
+       if (eap_type != CONNECTION_ETHERNET_EAP_TYPE_PEAP &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_TLS &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_TTLS)
+               return false;
+
+       return true;
+}
+
+static bool __profile_ethernet_validate_eap_passphrase(net_dev_info_t *net_info)
+{
+       connection_ethernet_eap_type_e eap_type = net_info->eap.eap_type;
+
+       if (net_info->use_eapol == false)
+               return false;
+
+       if (eap_type != CONNECTION_ETHERNET_EAP_TYPE_MD5 &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_PEAP &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_TTLS &&
+                       eap_type != CONNECTION_ETHERNET_EAP_TYPE_FAST)
+               return false;
+
+       return true;
+}
+
 static char *__profile_convert_ip_to_string(net_addr_t *ip_addr, connection_address_family_e address_family)
 {
        unsigned char *ipaddr = NULL;
@@ -2528,3 +2658,686 @@ EXPORT_API int connection_profile_get_prefix_length(connection_profile_h profile
        CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
+
+EXPORT_API int connection_profile_is_ethernet_eap_enabled(connection_profile_h profile, bool *enabled)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!(_connection_libnet_check_profile_validity(profile)) ||
+                       enabled == NULL) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = _connection_libnet_ethernet_eap_enabled(enabled);
+       if (ret != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get EAP over Ethernet enabled status.");
+               CONN_UNLOCK;
+               return ret;
+       }
+
+       CONNECTION_LOG(CONNECTION_INFO, "EAP over Ethernet enabled status: [%s]", enabled ? "true" : "false");
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_enable_ethernet_eap(connection_profile_h profile, bool enable)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!_connection_libnet_check_profile_validity(profile)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *profile_info = profile;
+       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+       int ret = _connection_libnet_enable_ethernet_eap(enable, net_info->ProfileName);
+       if (ret != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable EAP over ethernet");
+               CONN_UNLOCK;
+               return ret;
+       }
+
+       net_info->use_eapol = enable;
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_type(connection_profile_h profile,
+                       connection_ethernet_eap_type_e type)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!_connection_libnet_check_profile_validity(profile)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *profile_info = profile;
+       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+       if (net_info->use_eapol == false) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_OPERATION;
+       }
+       net_info->eap.eap_type = type;
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_type(connection_profile_h profile,
+                       connection_ethernet_eap_type_e *type)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!_connection_libnet_check_profile_validity(profile) || type == NULL) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *profile_info = profile;
+       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+       if (net_info->use_eapol == false) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_OPERATION;
+       }
+
+       *type = net_info->eap.eap_type;
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_passphrase(connection_profile_h profile,
+                       const char *user_name, const char *password)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!_connection_libnet_check_profile_validity(profile) ||
+                       user_name == NULL || password == NULL) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *profile_info = profile;
+       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_passphrase(net_info)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_OPERATION;
+       }
+
+       g_strlcpy(net_info->eap.username, user_name, NET_USERNAME_LEN+1);
+       g_strlcpy(net_info->eap.password, password, NET_PASSWORD_LEN+1);
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_passphrase(connection_profile_h profile,
+                       char **user_name, bool *is_password_set)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!_connection_libnet_check_profile_validity(profile) ||
+                       user_name == NULL || is_password_set == NULL) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *profile_info = profile;
+       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_passphrase(net_info)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_OPERATION;
+       }
+
+       *user_name = strdup(net_info->eap.username);
+       if (*user_name == NULL)  {
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_OUT_OF_MEMORY;
+       }
+
+       if (strlen(net_info->eap.password) > 0)
+               *is_password_set = true;
+       else
+               *is_password_set = false;
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_identity(connection_profile_h profile,
+                               const char *identity)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                        identity == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_identity(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        g_strlcpy(net_info->eap.username, identity, NET_USERNAME_LEN+1);
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_identity(connection_profile_h profile,
+                               char **identity)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                       identity == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_identity(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        *identity = strdup(net_info->eap.username);
+        if (*identity == NULL)  {
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_OUT_OF_MEMORY;
+        }
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_ca_cert_file(connection_profile_h profile,
+                               const char *file)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                        file == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_ca_cert_file(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        g_strlcpy(net_info->eap.ca_cert_filename, file, NET_CA_CERT_FILENAME_LEN+1);
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_ca_cert_file(connection_profile_h profile,
+                               char **file)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                        file == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_ca_cert_file(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        *file = strdup(net_info->eap.ca_cert_filename);
+        if (*file == NULL)  {
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_OUT_OF_MEMORY;
+        }
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_client_cert_file(connection_profile_h profile,
+                               const char *file)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                        file == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_client_cert_file(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        g_strlcpy(net_info->eap.client_cert_filename, file, NET_CLIENT_CERT_FILENAME_LEN+1);
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_client_cert_file(connection_profile_h profile,
+                               char **file)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                        file == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_client_cert_file(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        *file = strdup(net_info->eap.client_cert_filename);
+        if (*file == NULL)  {
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_OUT_OF_MEMORY;
+        }
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_private_key_file(connection_profile_h profile,
+                                char **file)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                        file == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_private_key_file(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        *file = strdup(net_info->eap.private_key_filename);
+        if (*file == NULL)  {
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_OUT_OF_MEMORY;
+        }
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_private_key_info(connection_profile_h profile,
+                                const char *file, const char *password)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                        file == NULL || password == NULL) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_private_key_file(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        g_strlcpy(net_info->eap.private_key_filename, file, NET_PRIVATE_KEY_FILENAME_LEN+1);
+        g_strlcpy(net_info->eap.private_key_passwd, password, NET_PRIVATE_KEY_PASSWD_LEN+1);
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_anonymous_identity(connection_profile_h profile,
+                               const char *anonymous_identity)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                      anonymous_identity == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_anonymous_identity(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        g_strlcpy(net_info->eap.anonymous_identity, anonymous_identity, NET_USERNAME_LEN+1);
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_anonymous_identity(connection_profile_h profile,
+                               char **anonymous_identity)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                       anonymous_identity == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_anonymous_identity(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        *anonymous_identity= strdup(net_info->eap.anonymous_identity);
+        if (*anonymous_identity== NULL)  {
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_OUT_OF_MEMORY;
+        }
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_pac_file(connection_profile_h profile,
+                               const char *file)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                        file == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_pac_file(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        g_strlcpy(net_info->eap.pac_filename, file, NET_PAC_FILENAME_LEN+1);
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_pac_file(connection_profile_h profile,
+                               char **file)
+{
+        CONN_LOCK;
+
+        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                        TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+        if (!_connection_libnet_check_profile_validity(profile) ||
+                        file == NULL ) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_PARAMETER;
+        }
+
+        net_profile_info_t *profile_info = profile;
+        net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_pac_file(net_info)) {
+                CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_INVALID_OPERATION;
+        }
+
+        *file = strdup(net_info->eap.pac_filename);
+        if (*file == NULL)  {
+                CONN_UNLOCK;
+                return CONNECTION_ERROR_OUT_OF_MEMORY;
+        }
+
+        CONN_UNLOCK;
+        return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_auth_type(connection_profile_h profile,
+                       connection_ethernet_eap_auth_type_e type)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!_connection_libnet_check_profile_validity(profile)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *profile_info = profile;
+       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+       if (false == __profile_ethernet_validate_eap_auth_type(net_info)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_OPERATION;
+       }
+
+       net_info->eap.eap_auth = type;
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_auth_type(connection_profile_h profile,
+                       connection_ethernet_eap_auth_type_e *type)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!_connection_libnet_check_profile_validity(profile) || type == NULL) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *profile_info = profile;
+       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+       if (false == __profile_ethernet_validate_eap_auth_type(net_info)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_OPERATION;
+       }
+
+       *type = net_info->eap.eap_auth;
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_ethernet_eap_peap_version(connection_profile_h profile,
+                       connection_ethernet_eap_peap_version_e version)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!_connection_libnet_check_profile_validity(profile)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *profile_info = profile;
+       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_peap_version(net_info)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_OPERATION;
+       }
+       net_info->eap.peap_version= version;
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_ethernet_eap_peap_version(connection_profile_h profile,
+                       connection_ethernet_eap_peap_version_e *version)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
+                       TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!_connection_libnet_check_profile_validity(profile) || version == NULL) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_PARAMETER;
+       }
+
+       net_profile_info_t *profile_info = profile;
+       net_dev_info_t *net_info = __profile_get_net_info(profile_info);
+
+        if (false == __profile_ethernet_validate_eap_peap_version(net_info)) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation");
+               CONN_UNLOCK;
+               return CONNECTION_ERROR_INVALID_OPERATION;
+       }
+
+       *version = net_info->eap.peap_version;
+
+       CONN_UNLOCK;
+       return CONNECTION_ERROR_NONE;
+}
index ca063eb..8b225e5 100755 (executable)
@@ -1362,6 +1362,61 @@ int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile,
        return CONNECTION_ERROR_NONE;
 }
 
+int _connection_libnet_enable_ethernet_eap(bool enable, const char *profilename)
+{
+       int rv = 0;
+
+       rv = net_ethernet_eap_enable(enable, profilename);
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+               return CONNECTION_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable EAP over ethernet[%d]", rv);
+               return CONNECTION_ERROR_OPERATION_FAILED;
+       }
+
+       return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_ethernet_eap_enabled(bool *enabled)
+{
+       int rv = 0;
+       gboolean eap_enabled = false;
+
+       rv = net_ethernet_eap_supported(&eap_enabled);
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+               return CONNECTION_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable EAP over ethernet[%d]", rv);
+               return CONNECTION_ERROR_OPERATION_FAILED;
+       }
+
+       *enabled = eap_enabled;
+       return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_profile_save_ethernet_eap_config(connection_handle_s *conn_handle,
+                       connection_profile_h profile)
+{
+       int rv;
+
+       net_profile_info_t *profile_info = profile;
+
+       rv = net_save_ethernet_eap_config(conn_handle->network_info_handle,
+                       &profile_info->ProfileInfo.Ethernet.net_info);
+
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+               return CONNECTION_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to save eap config[%d]", rv);
+               return CONNECTION_ERROR_OPERATION_FAILED;
+       }
+
+       return CONNECTION_ERROR_NONE;
+}
+
 int _connection_libnet_check_get_privilege(void)
 {
        int rv;
index 7236b33..b7c17e0 100755 (executable)
@@ -2469,6 +2469,456 @@ int test_mptcp_get_scheduler(void)
        return 1;
 }
 
+int test_ethernet_eap_connect(void)
+{
+       int rv;
+       int input;
+       bool enabled = false;
+       int type = 0;
+       int auth_type = 0;
+       char input_str1[100];
+       char input_str2[100];
+       connection_profile_h profile;
+
+       printf("\n** Choose a ethernet profile to connect. **\n");
+
+       if (test_get_user_selected_profile(&profile, true) == false)
+               return -1;
+
+       test_get_user_int("Input options (0:Use LAN 1:Use EAPoL) :", &input);
+       if (input == 1) {
+               if (connection_profile_enable_ethernet_eap(profile, true) != CONNECTION_ERROR_NONE) {
+                       printf("Failed to enable EAP over Ethernet\n");
+                       return -1;
+               }
+       } else {
+               printf("Disabling EAPoL. Use proper option for normal Lan connection.\n");
+               if (connection_profile_enable_ethernet_eap(profile, false) != CONNECTION_ERROR_NONE)
+                       printf("Failed to disable EAP over Ethernet\n");
+               return -1;
+       }
+
+       if (connection_profile_is_ethernet_eap_enabled(profile, &enabled) != CONNECTION_ERROR_NONE) {
+               printf("Failed to get ethernet eap enabled status!!\n");
+               return -1;
+       }
+
+       printf("EAP over Ethernet is %s\n", enabled ? "enabled" : "not enabled");
+
+       printf("Input EAP type:\n");
+       printf("0 -> CONNECTION_ETHERNET_EAP_TYPE_MD5\n");
+       printf("1 -> CONNECTION_ETHERNET_EAP_TYPE_PEAP\n");
+       printf("2 -> CONNECTION_ETHERNET_EAP_TYPE_TLS\n");
+       printf("3 -> CONNECTION_ETHERNET_EAP_TYPE_TTLS\n");
+       printf("4 -> CONNECTION_ETHERNET_EAP_TYPE_FAST\n");
+       rv = scanf("%d", &type);
+
+       switch (type) {
+       case CONNECTION_ETHERNET_EAP_TYPE_MD5:
+               rv = connection_profile_set_ethernet_eap_type(profile, type);
+               if (rv != CONNECTION_ERROR_NONE) {
+                       printf("Fail to set eap type : %s\n", test_print_error(rv));
+                       return -1;
+               }
+
+               printf("Input user name for ethernet:");
+               rv = scanf("%99s", input_str1);
+
+               printf("Input password for ethernet:");
+               rv = scanf("%99s", input_str2);
+
+               rv = connection_profile_set_ethernet_eap_passphrase(profile, input_str1, input_str2);
+               if (rv != CONNECTION_ERROR_NONE) {
+                       printf("Fail to set eap passphrase : %s\n", test_print_error(rv));
+                       return -1;
+               }
+               break;
+
+       case CONNECTION_ETHERNET_EAP_TYPE_TLS:
+               {
+                       rv = connection_profile_set_ethernet_eap_type(profile, type);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap type : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input user identity for ethernet:");
+                       rv = scanf("%99s", input_str1);
+
+                       rv = connection_profile_set_ethernet_eap_identity(profile, input_str1);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap identity : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input user certificate for ethernet:");
+                       rv = scanf("%129s", input_str1);
+
+                       rv = connection_profile_set_ethernet_eap_client_cert_file(profile, input_str1);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap user cetificate : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input CA certificate for ethernet:");
+                       rv = scanf("%129s", input_str1);
+
+                       rv = connection_profile_set_ethernet_eap_ca_cert_file(profile, input_str1);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap CA cetificate : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input private key for ethernet:");
+                       rv = scanf("%129s", input_str1);
+
+                       printf("Input private key password for ethernet:");
+                       rv = scanf("%129s", input_str2);
+
+                       rv = connection_profile_set_ethernet_eap_private_key_info(profile, input_str1, input_str2);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap private key  passphrase : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+               }
+                break;
+
+       case CONNECTION_ETHERNET_EAP_TYPE_PEAP:
+               {
+                       rv = connection_profile_set_ethernet_eap_type(profile, type);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap type : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input anonymous_identity for PEAP ethernet:");
+                       rv = scanf("%99s", input_str1);
+
+                       rv = connection_profile_set_ethernet_eap_anonymous_identity(profile, input_str1);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap anonymous_identity: %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input CA file for PEAP ethernet:");
+                       rv = scanf("%129s", input_str1);
+
+                       rv = connection_profile_set_ethernet_eap_ca_cert_file(profile, input_str1);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap CA file : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       int peap_version = 0;
+                       printf("Input peap version[ 0 ~ 2] for PEAP ethernet:");
+                       rv = scanf("%1d", &peap_version);
+
+                       rv = connection_profile_set_ethernet_eap_peap_version(profile, peap_version);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap peap version : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input authentication type[3:MSCHAPV2 4:GTC 5:MD5] for PEAP ethernet:");
+                       rv = scanf("%1d", &auth_type);
+
+                       rv = connection_profile_set_ethernet_eap_auth_type(profile, auth_type);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap authentication type : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input username for PEAP ethernet:");
+                       rv = scanf("%129s", input_str1);
+
+                       printf("Input password for PEAP ethernet:");
+                       rv = scanf("%129s", input_str2);
+
+                       rv = connection_profile_set_ethernet_eap_passphrase(profile, input_str1, input_str2);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap username and password : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+               }
+                break;
+
+       case CONNECTION_ETHERNET_EAP_TYPE_TTLS:
+               {
+                       rv = connection_profile_set_ethernet_eap_type(profile, type);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap type : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input anonymous_identity for TTLS ethernet:");
+                       rv = scanf("%99s", input_str1);
+
+                       rv = connection_profile_set_ethernet_eap_anonymous_identity(profile, input_str1);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap anonymous_identity: %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input CA file for TTLS ethernet:");
+                       rv = scanf("%129s", input_str1);
+
+                       rv = connection_profile_set_ethernet_eap_ca_cert_file(profile, input_str1);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap CA file : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input authentication type[1:PAP, 2:MSCHAP, 3:MSCHAPV2] for TTLS ethernet:");
+                       rv = scanf("%1d", &auth_type);
+
+                       rv = connection_profile_set_ethernet_eap_auth_type(profile, auth_type);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap authentication type : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input username for TTLS ethernet:");
+                       rv = scanf("%129s", input_str1);
+
+                       printf("Input password for TTLS ethernet:");
+                       rv = scanf("%129s", input_str2);
+
+                       rv = connection_profile_set_ethernet_eap_passphrase(profile, input_str1, input_str2);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap username and password : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+               }
+                break;
+
+       case CONNECTION_ETHERNET_EAP_TYPE_FAST:
+               {
+                       rv = connection_profile_set_ethernet_eap_type(profile, type);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap type : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input anonymous_identity for FAST ethernet:");
+                       rv = scanf("%99s", input_str1);
+
+                       rv = connection_profile_set_ethernet_eap_anonymous_identity(profile, input_str1);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap anonymous_identity: %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input pac file for FAST ethernet:");
+                       rv = scanf("%129s", input_str1);
+
+                       rv = connection_profile_set_ethernet_eap_pac_file(profile, input_str1);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap pac file : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input authentication type[3:MSCHAPV2, 4:GTC] for FAST ethernet:");
+                       rv = scanf("%1d", &auth_type);
+
+                       rv = connection_profile_set_ethernet_eap_auth_type(profile, auth_type);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap authentication type : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+
+                       printf("Input username for FAST ethernet:");
+                       rv = scanf("%129s", input_str1);
+
+                       printf("Input password for FAST ethernet:");
+                       rv = scanf("%129s", input_str2);
+
+                       rv = connection_profile_set_ethernet_eap_passphrase(profile, input_str1, input_str2);
+                       if (rv != CONNECTION_ERROR_NONE) {
+                               printf("Fail to set eap username and password : %s\n", test_print_error(rv));
+                               return -1;
+                       }
+               }
+                break;
+
+       default:
+               printf("Invalid EAP type\n");
+               return -1;
+       }
+
+       rv = connection_profile_save_ethernet_eap_config(connection, profile);
+       if (rv != CONNECTION_ERROR_NONE) {
+               printf("Fail to save eap config : %s\n", test_print_error(rv));
+               return -1;
+       }
+
+       if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
+               printf("Connection open Failed!!\n");
+               return -1;
+       }
+
+       return 1;
+}
+
+static const char *test_print_eap_type(connection_ethernet_eap_type_e type)
+{
+       switch (type) {
+       case CONNECTION_ETHERNET_EAP_TYPE_MD5:
+               return "MD5";
+       case CONNECTION_ETHERNET_EAP_TYPE_PEAP:
+               return "PEAP";
+       case CONNECTION_ETHERNET_EAP_TYPE_TLS:
+               return "TLS";
+       case CONNECTION_ETHERNET_EAP_TYPE_TTLS:
+               return "TTLS";
+       case CONNECTION_ETHERNET_EAP_TYPE_FAST:
+               return "FAST";
+       default:
+               return NULL;
+       }
+}
+
+static const char *test_print_eap_auth_type(connection_ethernet_eap_auth_type_e type)
+{
+       switch (type) {
+       case CONNECTION_ETHERNET_EAP_AUTH_TYPE_PAP:
+               return "PAP";
+       case CONNECTION_ETHERNET_EAP_AUTH_TYPE_MSCHAP:
+               return "MSCHAP";
+       case CONNECTION_ETHERNET_EAP_AUTH_TYPE_MSCHAPV2:
+               return "MSCHAPV2";
+       case CONNECTION_ETHERNET_EAP_AUTH_TYPE_GTC:
+               return "GTC";
+       case CONNECTION_ETHERNET_EAP_AUTH_TYPE_MD5:
+               return "MD5";
+       case CONNECTION_ETHERNET_EAP_AUTH_TYPE_NONE:
+               return "NONE";
+       default:
+               return NULL;
+       }
+}
+
+int test_get_eapol_info(void)
+{
+       connection_profile_type_e prof_type;
+       connection_profile_state_e profile_state;
+       connection_profile_h profile;
+       char *profile_name = NULL;
+       connection_ethernet_eap_type_e type;
+       connection_ethernet_eap_auth_type_e auth_type;
+       connection_ethernet_eap_peap_version_e peapver;
+       char *str = NULL;
+
+       printf("\n** Choose a ethernet profile to print eapol info. **\n");
+       if (test_get_user_selected_profile(&profile, true) == false)
+               return -1;
+
+       if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
+               printf("Fail to get profile name\n");
+               return -1;
+       } else {
+               printf("Profile Name : %s\n", profile_name);
+               g_free(profile_name);
+       }
+
+       if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE) {
+               printf("Fail to get profile type\n");
+               return -1;
+       }
+
+       if (prof_type != CONNECTION_PROFILE_TYPE_ETHERNET) {
+               printf("Not ethernet profile\n");
+               return -1;
+       }
+
+       if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
+               printf("Fail to get profile state\n");
+               return -1;
+       } else
+               printf("Profile State : %s\n", test_print_state(profile_state));
+
+
+       if (connection_profile_get_ethernet_eap_type(profile, &type)  != CONNECTION_ERROR_NONE) {
+               printf("Fail to get eap type\n");
+               return -1;
+       } else {
+               printf("eap_type: %s\n", test_print_eap_type(type));
+       }
+
+       if (connection_profile_get_ethernet_eap_identity(profile, &str) != CONNECTION_ERROR_NONE) {
+               printf("Fail to get eap identity\n");
+               return -1;
+       } else {
+               printf("identity: %s\n", str);
+       }
+
+       if (type == CONNECTION_ETHERNET_EAP_TYPE_MD5)
+               goto out;
+
+       if (type == CONNECTION_ETHERNET_EAP_TYPE_PEAP || type == CONNECTION_ETHERNET_EAP_TYPE_TTLS ||
+                       type == CONNECTION_ETHERNET_EAP_TYPE_FAST) {
+               if (connection_profile_get_ethernet_eap_anonymous_identity(profile, &str) != CONNECTION_ERROR_NONE) {
+                       printf("Fail to get eap anonymous_identity\n");
+                       return -1;
+               } else {
+                       printf("anonymous_identity: %s\n", str);
+               }
+       }
+
+       if (connection_profile_get_ethernet_eap_ca_cert_file(profile, &str) != CONNECTION_ERROR_NONE) {
+               printf("Fail to get eap ca_cert_file\n");
+               return -1;
+       } else {
+               printf("ca_cert_file: %s\n", str);
+       }
+
+       if (type == CONNECTION_ETHERNET_EAP_TYPE_TLS) {
+               if (connection_profile_get_ethernet_eap_client_cert_file(profile, &str) != CONNECTION_ERROR_NONE) {
+                       printf("Fail to get eap client_cert_file\n");
+                       return -1;
+               } else {
+                       printf("client_cert_file: %s\n", str);
+               }
+
+               if (connection_profile_get_ethernet_eap_private_key_file(profile, &str) != CONNECTION_ERROR_NONE) {
+                       printf("Fail to get eap private_key_file\n");
+                       return -1;
+               } else {
+                       printf("private_key_file: %s\n", str);
+               }
+       }
+
+       if (type == CONNECTION_ETHERNET_EAP_TYPE_PEAP || type == CONNECTION_ETHERNET_EAP_TYPE_TTLS ||
+                       type == CONNECTION_ETHERNET_EAP_TYPE_FAST) {
+               if (connection_profile_get_ethernet_eap_auth_type(profile, &auth_type) != CONNECTION_ERROR_NONE) {
+                       printf("Fail to get eap auth type\n");
+                       return -1;
+               } else {
+                       printf("eap_auth: %s\n", test_print_eap_auth_type(auth_type));
+               }
+       }
+
+       if (type == CONNECTION_ETHERNET_EAP_TYPE_PEAP) {
+               if (connection_profile_get_ethernet_eap_peap_version(profile, &peapver) != CONNECTION_ERROR_NONE) {
+                       printf("Fail to get eap peap_version\n");
+                       return -1;
+               } else {
+                       printf("peap_version: %d\n", peapver);
+               }
+       }
+
+       if (type == CONNECTION_ETHERNET_EAP_TYPE_FAST) {
+               if (connection_profile_get_ethernet_eap_pac_file(profile, &str) != CONNECTION_ERROR_NONE) {
+                       printf("Fail to get eap pac_file\n");
+                       return -1;
+               } else {
+                       printf("pac_file: %s\n", str);
+               }
+       }
+
+out:
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -2558,6 +3008,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("P   - Get MPTCP Scheduler (internal)\n");
                printf(LOG_GREEN "Q   - Create Handle and set callbacks in C# API\n" LOG_END);
                printf("R   - Destroy Handle(unset callbacks automatically in C# API)\n");
+               printf("S   - Connect Ethernet EAP)\n");
+               printf("T   - Get EAPoL info)\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
                printf("ENTER   - Show options menu.......\n");
        }
@@ -2715,6 +3167,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'R':
                rv = test_deregister_client_cs();
                break;
+       case 'S':
+               rv = test_ethernet_eap_connect();
+               break;
+       case 'T':
+               rv = test_get_eapol_info();
+               break;
 
        }