int _net_dbus_set_auto_connect_mode(int connect_mode);
int _net_dbus_wifi_set_autoconnect(const char *profile_name, gboolean autoconnect);
int _net_dbus_wifi_get_autoconnect(const char *profile_name, gboolean *autoconnect);
+int _net_dbus_set_ip_conflict_period(unsigned int initial_time);
+
#ifdef __cplusplus
}
NET_EVENT_WIFI_WPS_RSP,
NET_EVENT_WIFI_SCANNING_IND,
NET_EVENT_WIFI_BSSID_SCAN_IND,
+ NET_EVENT_WIFI_IP_CONFLICT_IND,
NET_EVENT_WIFI_TDLS_DISCOVERED_IND,
NET_EVENT_WIFI_TDLS_CONNECTED_IND,
NET_EVENT_WIFI_TDLS_DISCONNECTED_IND,
} net_ssid_scan_bss_info_s;
typedef struct {
+ char *state;
+ char *mac;
+} net_ip_conflict_info_s;
+
+typedef struct {
unsigned char ssid[NET_WLAN_ESSID_LEN + 1];
char bssid[NET_WLAN_BSSID_LEN + 1];
int rssi;
int net_config_load_eap_configurations(const gchar *config_id,
gchar **name, void *security_type, gchar **proxy_address,
gboolean *is_hidden, void **eap_config, void *last_error);
-
+int net_set_ip_conflict_detect_mode(gboolean detect);
+int net_ip_conflict_detect_is_enabled(gboolean *state);
+int net_wifi_set_ip_conflict_period(unsigned int initial_time);
+int net_wifi_get_ip_conflict_state(unsigned int *state);
+int net_wifi_get_ip_conflict_period(unsigned int* initial_time);
/**
* \}
*/
#define NETCONFIG_SIGNAL_DPM_WIFI "DPMWifi"
#define NETCONFIG_SIGNAL_DPM_WIFI_PROFILE "DPMWifiProfile"
#define NETCONFIG_SIGNAL_WPS_FAIL_EVENT "WpsFailEvent"
+#define NETCONFIG_SIGNAL_IP_CONFLICT_EVENT "IpConflictEvent"
#define __NETWORK_FUNC_ENTER__ /*WIFI_LOG(WIFI_INFO, "Enter (%s)", __func__);*/
#define __NETWORK_FUNC_EXIT__ /*WIFI_LOG(WIFI_INFO, "Quit (%s)", __func__);*/
NETWORK_REQUEST_TYPE_ENROLL_WPS,
NETWORK_REQUEST_TYPE_SPECIFIC_SCAN,
NETWORK_REQUEST_TYPE_BSSID_SCAN,
+ NETWORK_REQUEST_TYPE_IP_CONFLICT,
NETWORK_REQUEST_TYPE_MULTI_SCAN,
NETWORK_REQUEST_TYPE_SET_DEFAULT,
NETWORK_REQUEST_TYPE_RESET_DEFAULT,
} wifi_manager_connection_state_e;
/**
+ * @brief Enumeration for the state of the static IP conflict.
+ * @since_tizen 5.0
+ */
+typedef enum {
+ WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN = 0, /**< Unknown state */
+ WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED = 1, /**< Resolved state */
+ WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED = 2, /**< Conflict state */
+} wifi_manager_ip_conflict_state_e;
+
+/**
* @brief Enumeration for the RSSI level.
* @since_tizen 3.0
*/
typedef void(*wifi_manager_connection_state_changed_cb)(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void *user_data);
/**
+ * @brief Called when the IP conflict state is changed.
+ * @since_tizen 5.0
+ * @remarks @a mac should not be freed. @a mac is available only in the callback. To use
+ * outside the callback, make a copy.
+ * @param[in] mac The destination MAC address causing conflict
+ * @param[in] state The current state
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see wifi_manager_set_ip_conflict_cb()
+ * @see wifi_manager_unset_ip_conflict_cb()
+ */
+typedef void(*wifi_manager_ip_conflict_cb)(char *mac, wifi_manager_ip_conflict_state_e state, void *user_data);
+
+/**
* @brief Called when the RSSI of connected Wi-Fi is changed.
* @since_tizen 3.0
* @param[in] rssi_level The level of RSSI
const char *peer_mac_addr);
+/**
+ * @brief Registers the callback called when IP conflict state is changed.
+ * @since_tizen 5.0
+ * @param[in] wifi The Wi-Fi handle
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_set_ip_conflict_cb(wifi_manager_h wifi,
+ wifi_manager_ip_conflict_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback called when IP conflict state is changed.
+ * @since_tizen 5.0
+ * @param[in] wifi The Wi-Fi handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_unset_ip_conflict_cb(wifi_manager_h wifi);
+/**
+ * @brief Enables or disables IP conflict detection.
+ * @since_tizen 5.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set
+ *
+ * @param[in] wifi The Wi-Fi handle
+ * @param[in] detect True or false boolean to enable or disable
+ *
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_set_ip_conflict_detect_enable(wifi_manager_h wifi,
+ bool detect);
+
+/**
+ * @brief Checks whether IP conflict detection is enabled.
+ * @since_tizen 5.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi The Wi-Fi handle
+ * @param[out] state @c true if IP conflict detection is enabled,
+ * otherwise @c false if IP conflict detection is disabled.
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_ip_conflict_detect_is_enabled(wifi_manager_h wifi, bool *state);
+
+/**
+ * @brief Gets the state of the IP conflict.
+ * @since_tizen 5.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] wifi The Wi-Fi handle
+ * @param[out] state The current state of IP conflict
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_get_ip_conflict_state(wifi_manager_h wifi,
+ wifi_manager_ip_conflict_state_e *state);
/**
* @}
WIFI_SCAN_CHANGED_CB,
WIFI_SPECIFIC_SCAN_CB,
WIFI_BSSID_SCAN_CB,
+ WIFI_IP_CONFLICT_CB,
WIFI_MULTI_SCAN_CB,
WIFI_MANAGER_CONNECTION_STATE_CB,
WIFI_ACTIVATED_CB,
void *bssid_scan_user_data;
wifi_manager_connection_state_changed_cb connection_state_cb;
void *connection_state_user_data;
+ wifi_manager_ip_conflict_cb ip_conflict_cb;
+ void *ip_conflict_user_data;
wifi_manager_activated_cb activated_cb;
void *activated_user_data;
wifi_manager_deactivated_cb deactivated_cb;
int _wifi_set_auto_connect(int connect_mode);
int _wifi_set_ap_auto_connect(wifi_manager_ap_h ap_h, bool autoconnect);
int _wifi_get_ap_auto_connect(wifi_manager_ap_h ap_h, bool *autoconnect);
+int _wifi_ip_conflict_detect_enable_set(bool detect);
+int _wifi_ip_conflict_detect_is_enabled(bool *state);
+int _wifi_set_ip_conflict_period(unsigned int initial_time);
+int _wifi_get_ip_conflict_state(wifi_manager_ip_conflict_state_e *state);
+int _wifi_get_ip_conflict_period(unsigned int* initial_time);
/* WIFI Privilege Check */
int _wifi_check_get_privilege();
/**
+ * @brief Changes the IP conflict detection period in seconds.
+ * @since_tizen 5.0
+ *
+ * @param[in] wifi The Wi-Fi handle
+ * @param[in] initial_time The period time in seconds of the ARP detect ping
+ *
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_set_ip_conflict_period(wifi_manager_h wifi, unsigned int initial_time);
+
+/**
+ * @brief Gets the IP conflict detection period in seconds.
+ * @since_tizen 5.0
+ *
+ * @param[in] wifi The Wi-Fi handle
+ * @param[out] initial_time The period time in seconds of the ARP detect ping
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_get_ip_conflict_period(wifi_manager_h wifi, unsigned int *initial_time);
+
+/**
* @}
*/
}
//LCOV_EXCL_STOP
+int _net_dbus_set_ip_conflict_period(unsigned int initial_time)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariant *params;
+
+ params = g_variant_new("(u)", initial_time);
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "SetIpConflictPeriod", params, &Error);
+
+ if (Error != NET_ERR_NONE)
+ WIFI_LOG(WIFI_ERROR, "_net_invoke_dbus_method failed"); //LCOV_EXCL_LINE
+
+ if (message != NULL)
+ g_variant_unref(message); //LCOV_EXCL_LINE
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
int _net_dbus_get_technology_state(network_tech_state_info_s* tech_state)
{
__NETWORK_FUNC_ENTER__;
return Error;
}
+static int __net_set_ip_conflict_detect_mode(bool detect)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariant *params;
+ params = g_variant_new("(b)", detect);
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "IpConflictSetEnable", params, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set conflict detect enable mode"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__;
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+static int __net_ip_conflict_detect_is_enabled(gboolean *state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "IsIpConflictDetectEnabled", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get conflict detect enable mode"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__;
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_get(message, "(b)", state);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+
static int __net_check_profile_privilege()
{
__NETWORK_FUNC_ENTER__;
return Error;
}
+int net_set_ip_conflict_detect_mode(gboolean detect)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = __net_set_ip_conflict_detect_mode(detect);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set ip conflict detection enable", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+ __NETWORK_FUNC_EXIT__;
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_ip_conflict_detect_is_enabled(gboolean *state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = __net_ip_conflict_detect_is_enabled(state);
+ if (Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get ip conflict detection mode", //LCOV_EXCL_LINE
+ _net_print_error(Error));
+ __NETWORK_FUNC_EXIT__;
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
int net_check_profile_privilege()
{
net_err_e Error = NET_ERR_NONE;
return NET_ERR_NONE;
}
+int net_wifi_set_ip_conflict_period(unsigned int initial_time)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ if ((Error = _net_dbus_set_ip_conflict_period(initial_time)) != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR,
+ "Failed to set ip conflict detect period. Error [%s]",
+ _net_print_error(Error));
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ __NETWORK_FUNC_EXIT__;
+ return NET_ERR_NONE;
+}
+
+int net_wifi_get_ip_conflict_period(unsigned int* initial_time)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetIpConflictPeriod", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get IP conflict detection period"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__;
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_get(message, "(u)", initial_time);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_wifi_get_ip_conflict_state(unsigned int *state)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ message = _net_invoke_dbus_method(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
+ NETCONFIG_WIFI_INTERFACE, "GetIpConflictState", NULL, &Error);
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get IP conflict state"); //LCOV_EXCL_LINE
+ __NETWORK_FUNC_EXIT__;
+ return Error; //LCOV_EXCL_LINE
+ }
+
+ g_variant_get(message, "(u)", state);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
int net_wifi_get_autoscan(gboolean *autoscan)
{
__NETWORK_FUNC_ENTER__;
return NET_ERR_NONE;
}
+static int __net_handle_ip_conflict_rsp(GVariant *param)
+{
+ GVariantIter *iter = NULL;
+ GVariant *value = NULL;
+ gchar *key = NULL;
+ const gchar *state = NULL;
+ const gchar *mac = NULL;
+ net_ip_conflict_info_s conflict_info;
+ conflict_info.state = NULL;
+ conflict_info.mac = NULL;
+ net_event_info_s event_data;
+ memset(&event_data, 0, sizeof(event_data));
+
+ g_variant_get(param, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "state") == 0) {
+ state = g_variant_get_string(value, NULL);
+ conflict_info.state = g_strdup(state);
+ } else if (g_strcmp0(key, "mac") == 0) {
+ mac = g_variant_get_string(value, NULL);
+ conflict_info.mac = g_strdup(mac);
+ }
+ }
+ g_variant_iter_free(iter);
+
+
+ WIFI_LOG(WIFI_INFO,
+ "Received the signal: %s",
+ NETCONFIG_SIGNAL_IP_CONFLICT_EVENT);
+
+ event_data.Error = NET_ERR_NONE;
+ event_data.Event = NET_EVENT_WIFI_IP_CONFLICT_IND;
+ event_data.Datalength = sizeof(net_ip_conflict_info_s);
+ event_data.Data = &conflict_info;
+ _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)
__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);
+ else if (g_strcmp0(sig, NETCONFIG_SIGNAL_IP_CONFLICT_EVENT) == 0)
+ __net_handle_ip_conflict_rsp(param);
}
static void __net_netconfig_network_signal_filter(GDBusConnection *conn,
}
}
+static void __ip_conflict_cb(net_event_info_s *event_cb)
+{
+ GSList *list;
+ char *mac = NULL;
+ char *state = NULL;
+ net_ip_conflict_info_s *conflict_info = NULL;
+ wifi_manager_ip_conflict_state_e conflict_state = WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN;
+
+ __clear_profile_list(&bss_profile_iterator);
+
+ if (event_cb->Data) {
+ conflict_info = (net_ip_conflict_info_s *)event_cb->Data;
+ state = conflict_info->state;
+ if (!strcmp(state, "conflict")) {
+ conflict_state = WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED;
+ mac = conflict_info->mac;
+ } else if (!strcmp(state, "unknown")) {
+ conflict_state = WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN;
+ } else if (!strcmp(state, "resolved")) {
+ conflict_state = WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED;
+ }
+ }
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_IP_CONFLICT_CB)) {
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->ip_conflict_cb)
+ local_handle->ip_conflict_cb(mac, conflict_state,
+ local_handle->ip_conflict_user_data);
+
+ }
+ }
+
+ if (conflict_info) {
+ g_free(conflict_info->mac);
+ g_free(conflict_info->state);
+ }
+}
+
static void __multi_scan_cb(net_event_info_s *event_cb)
{
GSList *list;
WIFI_LOG(WIFI_INFO, "Got BSSID scan done IND\n");
__bssid_scan_cb(event_cb);
break;
+ case NET_EVENT_WIFI_IP_CONFLICT_IND:
+ WIFI_LOG(WIFI_INFO, "Got ip conflict event IND\n");
+ __ip_conflict_cb(event_cb);
+ break;
case NET_EVENT_WIFI_SCAN_CHANGED:
WIFI_LOG(WIFI_INFO, "Got Wi-Fi ScanChanged event\n");
wifi_manager_scan_state_e *scan_state = (wifi_manager_scan_state_e *)event_cb->Data;
if (local_handle->bssid_scan_cb)
++count;
break;
+ case WIFI_IP_CONFLICT_CB:
+ if (local_handle->ip_conflict_cb)
+ ++count;
+ break;
case WIFI_MULTI_SCAN_CB:
if (local_handle->multi_scan_cb)
++count;
return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
+
+int _wifi_ip_conflict_detect_enable_set(bool detect)
+{
+ int rv = NET_ERR_NONE;
+
+ rv = net_set_ip_conflict_detect_mode(detect);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_INVALID_OPERATION) {
+ WIFI_LOG(WIFI_ERROR, "Mode was already set");
+ } else if (rv == NET_ERR_NONE) {
+ return WIFI_MANAGER_ERROR_NONE;
+ }
+
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+}
+
bool _wifi_check_ap_validity(wifi_manager_ap_h ap_h)
{
GSList *list = NULL;
return WIFI_MANAGER_ERROR_NONE;
}
+int _wifi_ip_conflict_detect_is_enabled(bool *state)
+{
+ int rv;
+ gboolean is_enabled = FALSE;
+ rv = net_ip_conflict_detect_is_enabled(&is_enabled);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv == NET_ERR_NONE) {
+ *state = is_enabled;
+ return WIFI_MANAGER_ERROR_NONE;
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
int _wifi_scan_request(wifi_manager_h wifi,
wifi_manager_scan_finished_cb callback, void *user_data)
{
return WIFI_MANAGER_ERROR_NONE;
}
+int _wifi_set_ip_conflict_period(unsigned int initial_time)
+{
+ int rv = 0;
+
+ rv = net_wifi_set_ip_conflict_period(initial_time);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied");
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
int _wifi_get_autoscan(bool *autoscan)
{
int rv;
return WIFI_MANAGER_ERROR_NONE;
}
+int _wifi_get_ip_conflict_period(unsigned int* initial_time)
+{
+ int rv;
+
+ rv = net_wifi_get_ip_conflict_period(initial_time);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get IP conflict detection period"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_get_ip_conflict_state(wifi_manager_ip_conflict_state_e *state)
+{
+ int rv;
+
+ rv = net_wifi_get_ip_conflict_state(state);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get IP conflict state"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
int _wifi_get_module_state(wifi_manager_module_state_e *state)
{
int rv = 0;
return WIFI_MANAGER_ERROR_NONE;
}
+static int __wifi_set_ip_conflict_cb(wifi_manager_h wifi,
+ void *callback, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ local_handle->ip_conflict_cb = callback;
+ local_handle->ip_conflict_user_data = user_data;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
static int __wifi_set_rssi_level_changed_cb(wifi_manager_h wifi,
void *callback, void *user_data)
{
return __wifi_set_connection_state_changed_cb(wifi, NULL, NULL);
}
+EXPORT_API int wifi_manager_set_ip_conflict_cb(wifi_manager_h wifi,
+ wifi_manager_ip_conflict_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (callback == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_ip_conflict_cb(wifi, callback, user_data);
+}
+
+EXPORT_API int wifi_manager_unset_ip_conflict_cb(wifi_manager_h wifi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_ip_conflict_cb(wifi, NULL, NULL);
+}
+
+EXPORT_API int wifi_manager_set_ip_conflict_detect_enable(wifi_manager_h wifi,
+ bool detect)
+{
+ int rv;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_ip_conflict_detect_enable_set(detect);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Failed to change ip conflict detect mode", rv); //LCOV_EXCL_LINE
+
+ return rv;
+}
+
+EXPORT_API int wifi_manager_ip_conflict_detect_is_enabled(wifi_manager_h wifi, bool *state)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (state == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_ip_conflict_detect_is_enabled(state);
+}
+
+EXPORT_API int wifi_manager_set_ip_conflict_period(wifi_manager_h wifi,
+ unsigned int initial_time)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_set_ip_conflict_period(initial_time);
+}
+
+EXPORT_API int wifi_manager_get_ip_conflict_period(wifi_manager_h wifi,
+ unsigned int *initial_time)
+
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ if (initial_time == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_get_ip_conflict_period(initial_time);
+}
+
+EXPORT_API int wifi_manager_get_ip_conflict_state(wifi_manager_h wifi,
+ wifi_manager_ip_conflict_state_e *state)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ if (state == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return _wifi_get_ip_conflict_state(state);
+}
+
EXPORT_API int wifi_manager_set_rssi_level_changed_cb(wifi_manager_h wifi,
wifi_manager_rssi_level_changed_cb callback, void *user_data)
{
(char *)user_data, __test_convert_error_to_string(error_code));
}
+static void __test_ip_conflict_callback(char *mac, wifi_manager_ip_conflict_state_e state, void *user_data)
+{
+ if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED)
+ printf("[%s] Ip conflict detected : %s\n", (char *)user_data, mac);
+ else if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED)
+ printf("Ip conflict removed\n");
+ else
+ printf("Ip conflict state unknown\n");
+}
+
static void __test_scan_request_callback(wifi_manager_error_e error_code, void* user_data)
{
if (user_data != NULL)
wifi_manager_set_device_state_changed_cb(wifi, __test_device_state_callback, "1");
wifi_manager_set_scan_state_changed_cb(wifi, __test_scan_changed_callback, "1");
wifi_manager_set_background_scan_cb(wifi, __test_bg_scan_completed_callback, "1");
+ wifi_manager_set_ip_conflict_cb(wifi, __test_ip_conflict_callback, "1");
wifi_manager_set_connection_state_changed_cb(wifi, __test_connection_state_callback, "1");
wifi_manager_set_rssi_level_changed_cb(wifi, __test_rssi_level_callback, "1");
wifi_manager_tdls_set_state_changed_cb(wifi, __test_tdls_state_callback, "1");
return 1;
}
+int test_wifi_manager_set_ip_conflict_detect_enable()
+{
+ int rv = 0;
+ int choice;
+ bool state = false;
+
+ printf("Input '1'(enable)/'0'(disable) for ip conflict detection : ");
+ rv = scanf("%d", &choice);
+ if (choice == 1)
+ state = true;
+ else if (choice == 0)
+ state = false;
+ else
+ return -1;
+
+ rv = wifi_manager_set_ip_conflict_detect_enable(wifi, state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set ip conflict detection state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Succesfully set the ip conflict detection !\n");
+ return 1;
+}
+
+int test_wifi_manager_ip_conflict_detect_is_enabled()
+{
+ int rv = 0;
+ bool state = false;
+
+ rv = wifi_manager_ip_conflict_detect_is_enabled(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get ip conflict detection state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("IP conflict detection is %s\n", state ? "enabled" : "disabled");
+ printf("Succesfully get the ip conflict detection !\n");
+ return 1;
+}
+
+int test_wifi_manager_get_ip_conflict_state()
+{
+ int rv = 0;
+ wifi_manager_ip_conflict_state_e state;
+
+ rv = wifi_manager_get_ip_conflict_state(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get ip conflict state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ switch (state) {
+ case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED:
+ printf("IP Conflict present\n");
+ break;
+ case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED:
+ printf("IP Conflict absent\n");
+ break;
+ case WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN:
+ printf("IP Conflict state is unknown\n");
+ break;
+ default:
+ printf("Unhandled state\n");
+ break;
+ }
+
+ printf("Succesfully get the ip conflict state!\n");
+ return 1;
+}
+
+int test_wifi_manager_get_ip_conflict_period()
+{
+ int rv = 0;
+ unsigned int initial_time;
+
+ rv = wifi_manager_get_ip_conflict_period(wifi, &initial_time);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get ip conflict time period [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Initial time = %d seconds!\n", initial_time);
+ printf("Succesfully get the ip conflict detect period!\n");
+ return 1;
+}
+
+int test_wifi_manager_set_ip_conflict_period()
+{
+ int rv = 0;
+ int initial_interval;
+
+ printf("Enter initial interval for ARP ping\n");
+ rv = scanf("%d", &initial_interval);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_set_ip_conflict_period(wifi, initial_interval);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set ip conflict detection period [%s]\n",
+ __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Succesfully set the ip conflict detect period!\n");
+ return 1;
+}
+
int test_wifi_manager_connect_specific_ap(void)
{
int rv;
printf("C - Add VSIE\n");
printf("D - Get VSIE\n");
printf("E - Remove VSIE\n");
+ printf("F - Set IP conflict detection mode\n");
+ printf("G - Get IP conflict detection mode\n");
+ printf("H - Get IP conflict state\n");
/* Extension API */
printf(LOG_BLUE "[Extension API]\n" LOG_END);
- printf("F - Set Enable or Disable Auto Scan\n");
- printf("G - Set Mode of Auto Scan\n");
- printf("H - Get Enable or Disable Auto Scan\n");
- printf("I - Get Mode of Auto Scan\n");
- printf("J - Flush BSS\n");
- printf("K - Set enable or disable auto connect\n");
- printf("L - Get enable or disable auto connect\n");
- printf("M - Set enable or disable of Wi-Fi profile auto-connect\n");
- printf("N - Get enable or disable of Wi-Fi profile auto-connect\n");
+ printf("I - Set Enable or Disable Auto Scan\n");
+ printf("J - Set Mode of Auto Scan\n");
+ printf("K - Get Enable or Disable Auto Scan\n");
+ printf("L - Get Mode of Auto Scan\n");
+ printf("M - Flush BSS\n");
+ printf("N - Set enable or disable auto connect\n");
+ printf("O - Get enable or disable auto connect\n");
+ printf("P - Set enable or disable of Wi-Fi profile auto-connect\n");
+ printf("Q - Get enable or disable of Wi-Fi profile auto-connect\n");
+ printf("R - Set the IP conflict detection period\n");
+ printf("S - Get the IP conflict detection period\n");
printf(LOG_RED "0 - Exit \n" LOG_END);
printf("ENTER - Show options menu.......\n");
case 'E':
rv = test_wifi_manager_remove_vsie();
break;
-/* Extension API */
case 'F':
- rv = test_wifi_manager_set_autoscan_state();
+ rv = test_wifi_manager_set_ip_conflict_detect_enable();
break;
case 'G':
- rv = test_wifi_manager_set_autoscan_mode();
+ rv = test_wifi_manager_ip_conflict_detect_is_enabled();
break;
case 'H':
- rv = test_wifi_manager_get_autoscan_state();
+ rv = test_wifi_manager_get_ip_conflict_state();
break;
+/* Extension API */
case 'I':
- rv = test_wifi_manager_get_autoscan_mode();
+ rv = test_wifi_manager_set_autoscan_state();
break;
case 'J':
- rv = test_wifi_manager_flush_bss();
+ rv = test_wifi_manager_set_autoscan_mode();
break;
case 'K':
- rv = test_wifi_manager_set_auto_connect();
+ rv = test_wifi_manager_get_autoscan_state();
break;
case 'L':
- rv = test_wifi_manager_get_auto_connect();
+ rv = test_wifi_manager_get_autoscan_mode();
break;
case 'M':
- rv = test_wifi_manager_set_ap_auto_connect();
+ rv = test_wifi_manager_flush_bss();
break;
case 'N':
+ rv = test_wifi_manager_set_auto_connect();
+ break;
+ case 'O':
+ rv = test_wifi_manager_get_auto_connect();
+ break;
+ case 'P':
+ rv = test_wifi_manager_set_ap_auto_connect();
+ break;
+ case 'Q':
rv = test_wifi_manager_get_ap_auto_connect();
break;
+ case 'R':
+ rv = test_wifi_manager_set_ip_conflict_period();
+ break;
+ case 'S':
+ rv = test_wifi_manager_get_ip_conflict_period();
+ break;
default:
break;
}
return TRUE;
}
-