wifi-manager: Notify WPS Connection Errors to application 53/132753/3
authorSaurav Babu <saurav.babu@samsung.com>
Wed, 7 Jun 2017 10:44:02 +0000 (16:14 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Wed, 7 Jun 2017 10:52:14 +0000 (16:22 +0530)
Change-Id: I3b68ed8677f3930c12a76dd4e9d3349de2dd0e8d
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
include/network_error.h
include/network_internal.h
src/network_signal.c
src/wifi_internal.c
test/wifi_manager_test.c

index ba6f1df..447b3a7 100755 (executable)
@@ -41,6 +41,9 @@ typedef enum {
        NET_ERR_CONNECTION_LOGIN_FAILED = -893,                 /** Connection failure : login failed */
        NET_ERR_CONNECTION_AUTH_FAILED = -892,                  /** Connection failure : authentication failed */
        NET_ERR_CONNECTION_INVALID_KEY = -891,                  /** Connection failure : invalid key */
+       NET_ERR_CONNECTION_WPS_OVERLAP = -890,                  /** Connection failure : wps overlap */
+       NET_ERR_CONNECTION_WPS_TIMEOUT = -889,                  /** Connection failure : wps timeout */
+       NET_ERR_CONNECTION_WPS_WEP_PROHIBITED = -888,   /** Connection failure : wps wep prohibited */
 
        /* Other Error */
        NET_ERR_ACCESS_DENIED = -799,                                   /** Access(permission) denied */
index 8c9ad17..e21e695 100755 (executable)
@@ -102,6 +102,7 @@ extern "C" {
 #define NETCONFIG_SIGNAL_WIFI_CONNECT_FAIL     "WiFiConnectFail"
 #define NETCONFIG_SIGNAL_DPM_WIFI                      "DPMWifi"
 #define NETCONFIG_SIGNAL_DPM_WIFI_PROFILE      "DPMWifiProfile"
+#define NETCONFIG_SIGNAL_WPS_FAIL_EVENT                "WpsFailEvent"
 
 #define __NETWORK_FUNC_ENTER__         /*WIFI_LOG(WIFI_INFO, "Enter (%s)", __func__);*/
 #define __NETWORK_FUNC_EXIT__          /*WIFI_LOG(WIFI_INFO, "Quit (%s)", __func__);*/
index d077024..fb43d1d 100755 (executable)
 #include "network_dbus.h"
 #include "network_signal.h"
 
+/* WPS Errors */
+#define NET_WPS_CFG_NO_ERROR 0
+#define NET_WPS_CFG_MULTIPLE_PBC_DETECTED 12
+#define NET_WPS_CFG_MSG_TIMEOUT 16
+#define NET_WPS_EI_NO_ERROR 0
+#define NET_WPS_EI_OPERATION_FAILED 1
+#define NET_WPS_EI_SECURITY_WEP_PROHIBITED 2
+
 extern __thread network_info_s NetworkInfo;
 extern __thread network_request_table_s request_table[NETWORK_REQUEST_TYPE_MAX];
 
@@ -952,6 +960,57 @@ static int __net_handle_wifi_connect_fail_event(GVariant *param)
        return NET_ERR_NONE;
 }
 
+static int __net_handle_wifi_wps_fail_event_rsp(GVariant *param)
+{
+       GVariantIter *iter = NULL;
+       GVariant *value = NULL;
+       const char *key = NULL;
+       gint32 config_error = 0;
+       gint32 error_indication = 0;
+
+       g_variant_get(param, "(a{sv})", &iter);
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+               if (g_strcmp0(key, "config_error") == 0) {
+                       config_error = g_variant_get_int32(value);
+                       WIFI_LOG(WIFI_INFO, "Config Error: %d", config_error);
+               } else if (g_strcmp0(key, "error_indication") == 0) {
+                       error_indication = g_variant_get_int32(value);
+                       WIFI_LOG(WIFI_INFO, "Error Indication: %d", error_indication);
+               }
+       }
+       g_variant_iter_free(iter);
+
+       net_event_info_s event_data;
+       memset(&event_data, 0, sizeof(event_data));
+
+       if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS_WITHOUT_SSID].flag ==
+                                                                               TRUE)
+               memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS_WITHOUT_SSID], 0,
+                               sizeof(network_request_table_s));
+
+       event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+       if (config_error == NET_WPS_CFG_MSG_TIMEOUT &&
+                       error_indication == NET_WPS_EI_NO_ERROR)
+               event_data.Error = NET_ERR_CONNECTION_WPS_TIMEOUT;
+       else if (config_error == NET_WPS_CFG_NO_ERROR &&
+                       error_indication == NET_WPS_EI_OPERATION_FAILED)
+               event_data.Error = NET_ERR_CONNECTION_CONNECT_FAILED;
+       else if (config_error == NET_WPS_CFG_MULTIPLE_PBC_DETECTED &&
+                       error_indication == NET_WPS_EI_NO_ERROR)
+               event_data.Error = NET_ERR_CONNECTION_WPS_OVERLAP;
+       else if (config_error == NET_WPS_CFG_NO_ERROR &&
+                       error_indication == NET_WPS_EI_SECURITY_WEP_PROHIBITED)
+               event_data.Error = NET_ERR_CONNECTION_WPS_WEP_PROHIBITED;
+
+       event_data.Datalength = 0;
+       event_data.Data = NULL;
+
+       _net_client_callback(&event_data);
+
+       return NET_ERR_NONE;
+}
+
 static void __net_connman_manager_signal_filter(GDBusConnection *conn,
                const gchar *name, const gchar *path, const gchar *interface,
                const gchar *sig, GVariant *param, gpointer user_data)
@@ -982,6 +1041,8 @@ static void __net_netconfig_signal_filter(GDBusConnection *conn,
                __net_handle_wifi_tdls_disconnected_event(param);
        else if (g_strcmp0(sig, NETCONFIG_SIGNAL_WIFI_CONNECT_FAIL) == 0)
                __net_handle_wifi_connect_fail_event(param);
+       else if (g_strcmp0(sig, NETCONFIG_SIGNAL_WPS_FAIL_EVENT) == 0)
+               __net_handle_wifi_wps_fail_event_rsp(param);
 }
 
 static void __net_netconfig_network_signal_filter(GDBusConnection *conn,
index ff56b19..6c32fb7 100755 (executable)
@@ -79,6 +79,12 @@ static wifi_manager_error_e __convert_to_ap_error_type(net_err_e err_type)
                return WIFI_MANAGER_ERROR_NO_REPLY;
        case NET_ERR_ACCESS_DENIED:
                return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
+       case NET_ERR_CONNECTION_WPS_TIMEOUT:
+               return WIFI_MANAGER_ERROR_WPS_TIMEOUT;
+       case NET_ERR_CONNECTION_WPS_OVERLAP:
+               return WIFI_MANAGER_ERROR_WPS_OVERLAP;
+       case NET_ERR_CONNECTION_WPS_WEP_PROHIBITED:
+               return WIFI_MANAGER_ERROR_WPS_WEP_PROHIBITED;
        default:
                return WIFI_MANAGER_ERROR_OPERATION_FAILED;
        }
@@ -131,6 +137,12 @@ static const char *__convert_ap_error_type_to_string(wifi_manager_error_e err_ty
                return "PERMISSION_DENIED";
        case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
                return "NOT_SUPPROTED";
+       case WIFI_MANAGER_ERROR_WPS_OVERLAP:
+               return "WPS_OVERLAP";
+       case WIFI_MANAGER_ERROR_WPS_TIMEOUT:
+               return "WPS_TIMEOUT";
+       case WIFI_MANAGER_ERROR_WPS_WEP_PROHIBITED:
+               return "WPS_WEP_PROHIBITED";
 
        default:
                return "UNKNOWN";
@@ -766,7 +778,13 @@ static void _wifi_evt_cb(net_event_info_s *event_cb, void *user_data)
        case NET_EVENT_OPEN_IND:
                if ((_wifi_check_profile_name_validity(event_cb->ProfileName) !=
                        true) && (event_cb->Error !=
-                               NET_ERR_CONNECTION_CONNECT_FAILED))
+                               NET_ERR_CONNECTION_CONNECT_FAILED) &&
+                               (event_cb->Error !=
+                                NET_ERR_CONNECTION_WPS_TIMEOUT) &&
+                               (event_cb->Error !=
+                                NET_ERR_CONNECTION_WPS_OVERLAP) &&
+                               (event_cb->Error !=
+                                NET_ERR_CONNECTION_WPS_WEP_PROHIBITED))
                        return;
 
                result = __convert_to_ap_error_type(event_cb->Error);
index 64bbc36..2f6201b 100755 (executable)
@@ -90,6 +90,12 @@ static const char *__test_convert_error_to_string(wifi_manager_error_e err_type)
                return "PERMISSION_DENIED";
        case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
                return "NOT_SUPPORTED";
+       case WIFI_MANAGER_ERROR_WPS_OVERLAP:
+               return "WPS_OVERLAP";
+       case WIFI_MANAGER_ERROR_WPS_TIMEOUT:
+               return "WPS_TIMEOUT";
+       case WIFI_MANAGER_ERROR_WPS_WEP_PROHIBITED:
+               return "WPS_WEP_PROHIBITED";
        default:
                return "UNKNOWN";
        }