Added CAPIs for EAP AnonymousIdentity 86/201886/5
authorJaehyun Kim <jeik01.kim@samsung.com>
Wed, 20 Mar 2019 12:09:12 +0000 (21:09 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Fri, 29 Mar 2019 11:30:52 +0000 (11:30 +0000)
Change-Id: I013af1c16c22b7d7525616b5a2945969d505aabc
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/network_dbus.h
include/network_wlan.h
include/wifi-manager.h
src/network_dbus.c
src/network_internal.c
src/wifi_ap.c

index 94631b9..b7b5cb1 100755 (executable)
@@ -50,6 +50,7 @@ extern "C" {
 #define CONNMAN_CONFIG_FIELD_SSID                              "SSID"
 #define CONNMAN_CONFIG_FIELD_EAP_METHOD                        "EAP"
 #define CONNMAN_CONFIG_FIELD_IDENTITY                  "Identity"
+#define CONNMAN_CONFIG_FIELD_ANONYMOUS_IDENTITY                "AnonymousIdentity"
 #define CONNMAN_CONFIG_FIELD_PASSPHRASE                        "Passphrase"
 #define CONNMAN_CONFIG_FIELD_PHASE2                            "Phase2"
 #define CONNMAN_CONFIG_FIELD_CA_CERT_FILE              "CACertFile"
@@ -69,6 +70,7 @@ typedef struct {
        char *eap_type;
        char *eap_auth;
        char *identity;
+       char *anonymous_identity;
        char *password;
        char *ca_cert_file;
        char *client_cert_file;
index 9a23bd2..cd133d0 100755 (executable)
@@ -195,6 +195,7 @@ typedef struct {
 typedef struct {
        char username[NET_WLAN_USERNAME_LEN+1];                                                 /** User name */
        char password[NET_WLAN_PASSWORD_LEN+1];                                                 /** Password */
+       char anonymous_identity[NET_WLAN_USERNAME_LEN+1];                                       /** AnonymousIdentity */
 
        /**
         * Following fields are mandatory for EAP-TLS,
index 435d630..2560b41 100755 (executable)
@@ -3054,6 +3054,34 @@ int wifi_manager_ap_set_eap_passphrase(wifi_manager_ap_h ap, const char *user_na
 int wifi_manager_ap_get_eap_passphrase(wifi_manager_ap_h ap, char **user_name, bool *is_password_set);
 
 /**
+ * @brief Sets access point anonymous identity.
+ * @since_tizen 5.5
+ * @param[in] ap                    The access point handle
+ * @param[in] anonymous_identity    The anonymous identity
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @retval #WIFI_ERROR_INVALID_OPERATION            Invalid operation
+ * @retval #WIFI_ERROR_NOT_SUPPORTED                Not supported
+ */
+int wifi_manager_ap_set_eap_anonymous_identity(wifi_manager_ap_h ap, const char *anonymous_identity);
+
+/**
+ * @brief Gets access point anonymous identity.
+ * @since_tizen 5.5
+ * @remarks You must release @a anonymous_identity using free().
+ * @param[in] ap                    The access point handle
+ * @param[out] anonymous_identity   The anonymous identity of access point
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @retval #WIFI_ERROR_OUT_OF_MEMORY                Out of memory
+ * @retval #WIFI_ERROR_INVALID_OPERATION            Invalid operation
+ * @retval #WIFI_ERROR_NOT_SUPPORTED                Not supported
+ */
+int wifi_manager_ap_get_eap_anonymous_identity(wifi_manager_ap_h ap, char **anonymous_identity);
+
+/**
  * @brief Gets the CA Certificate of EAP.
  * @since_tizen 3.0
  * @remarks This function is valid only if the EAP type is #WIFI_MANAGER_EAP_TYPE_TLS.
index 9253786..1631840 100755 (executable)
@@ -1088,6 +1088,10 @@ int _net_dbus_set_eap_config_fields_and_connect(
                g_variant_builder_add(builder, "{ss}",
                                CONNMAN_CONFIG_FIELD_IDENTITY, wifi_info->identity);
 
+       if (wifi_info->anonymous_identity)
+               g_variant_builder_add(builder, "{ss}",
+                               CONNMAN_CONFIG_FIELD_ANONYMOUS_IDENTITY, wifi_info->anonymous_identity);
+
        if (wifi_info->password)
                g_variant_builder_add(builder, "{ss}",
                                CONNMAN_CONFIG_FIELD_PASSPHRASE, wifi_info->password);
index 6a24aa4..6ecc61b 100755 (executable)
@@ -318,6 +318,10 @@ int _net_open_connection_with_wifi_info(const net_wifi_connection_info_s* wifi_i
                if (wifi_info->security_info.authentication.eap.private_key_passwd[0] != '\0')
                        wifi_connection_info.private_key_password =
                                        (char *)wifi_info->security_info.authentication.eap.private_key_passwd;
+
+               if (wifi_info->security_info.authentication.eap.anonymous_identity[0] != '\0')
+                       wifi_connection_info.anonymous_identity =
+                                       (char *)wifi_info->security_info.authentication.eap.anonymous_identity;
                break;
 
        default:
index 4f065d6..c4f3b85 100755 (executable)
@@ -1997,6 +1997,61 @@ EXPORT_API int wifi_manager_ap_get_eap_passphrase(wifi_manager_ap_h ap,
        return WIFI_MANAGER_ERROR_NONE;
 }
 
+EXPORT_API int wifi_manager_ap_set_eap_anonymous_identity(wifi_manager_ap_h ap, const char *anonymous_identity)
+{
+       __NETWORK_CAPI_FUNC_ENTER__;
+
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       if (_wifi_check_ap_validity(ap) == false || anonymous_identity == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       net_profile_info_s *profile_info = ap;
+       if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) {
+               __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+       }
+
+       g_strlcpy(profile_info->security_info.authentication.eap.anonymous_identity,
+                       anonymous_identity, NET_WLAN_USERNAME_LEN+1);
+
+       __NETWORK_CAPI_FUNC_EXIT__;
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
+EXPORT_API int wifi_manager_ap_get_eap_anonymous_identity(wifi_manager_ap_h ap, char **anonymous_identity)
+{
+       __NETWORK_CAPI_FUNC_ENTER__;
+
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       if (_wifi_check_ap_validity(ap) == false || anonymous_identity == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       net_profile_info_s *profile_info = ap;
+       if (profile_info->security_info.sec_mode != WLAN_SEC_MODE_IEEE8021X) {
+               __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
+       }
+
+       *anonymous_identity = strdup(profile_info->security_info.authentication.eap.anonymous_identity);
+       if (*anonymous_identity == NULL) {
+               __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+       }
+
+       __NETWORK_CAPI_FUNC_EXIT__;
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
 EXPORT_API int wifi_manager_ap_get_eap_ca_cert_file(wifi_manager_ap_h ap, char **file)
 {
        __NETWORK_CAPI_FUNC_ENTER__;