Remove obsolete logics
authorJiwan Kim <ji-wan.kim@samsung.com>
Mon, 12 Jun 2017 04:17:17 +0000 (13:17 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 17 Jul 2017 02:35:36 +0000 (11:35 +0900)
- low-level logic are moved into connman and wpa_supplicant.

14 files changed:
include/mesh-dhcp.h [deleted file]
include/mesh-monitor.h
include/mesh-netlink.h
include/mesh-network.h [deleted file]
include/mesh-request.h
include/mesh.h
packaging/meshd.spec
src/mesh-dhcp.c [deleted file]
src/mesh-monitor.c
src/mesh-netlink.c
src/mesh-network.c [deleted file]
src/mesh-request.c
src/mesh-service-interface.c
src/meshd.c

diff --git a/include/mesh-dhcp.h b/include/mesh-dhcp.h
deleted file mode 100644 (file)
index fb23d8c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#ifndef __MESH_DHCP_H__
-#define __MESH_DHCP_H__
-
-typedef void (*dhcp_finished_cb)(const char* interface, const char* ip_address,
-               void *user_data);
-int mesh_dhcp_request(const char* interface,
-               dhcp_finished_cb callback, void *user_data);
-int mesh_dhcp_stop_request();
-
-#endif /* __MESH_DHCP_H__ */
index 0cff15c..d9d6dc3 100644 (file)
@@ -16,7 +16,7 @@
  * limitations under the License.
  *
  */
- #ifndef __MESH_MONITOR_H__
+#ifndef __MESH_MONITOR_H__
 #define __MESH_MONITOR_H__
 
 int mesh_start_peer_monitor(void *pdata);
index 659e194..2697e4e 100644 (file)
 #ifndef __MESH_NETLINK_H__
 #define __MESH_NETLINK_H__
 
-int mesh_netlink_set_type_managed(const char* interface);
-int mesh_netlink_create_mesh_interface(const char* base_if_name,
-               const char* mesh_if_name, const char* mesh_id);
-int mesh_netlink_delete_mesh_interface(const char* mesh_if_name);
-int mesh_netlink_set_mesh_channel(const char* base_if_name, int channel);
-int mesh_netlink_join_mesh(const char* base_if_name, const char* mesh_id);
-
-int mesh_netlink_trigger_full_scan(const char* mesh_if_name);
-int mesh_netlink_trigger_specific_scan(const char* mesh_if_name,
-               const char* mesh_id, int channel);
-int mesh_netlink_cancel_scan(const char* mesh_if_name);
-int mesh_netlink_get_scan_result(const char* mesh_if_name, GList **scan_list);
 int mesh_netlink_set_mesh_parameter(const char* mesh_if_name,
                const char* param_name, unsigned int value);
 
diff --git a/include/mesh-network.h b/include/mesh-network.h
deleted file mode 100644 (file)
index a26f86e..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#ifndef __MESH_NETWORK_H__
-#define __MESH_NETWORK_H__
-
-int mesh_network_load_mesh_network(GList **saved_network);
-
-int mesh_network_add_mesh_network(GList **saved_network, const char *mesh_id,
-               int mesh_channel, int security);
-int mesh_network_get_saved_mesh_network(GList **saved_network);
-int mesh_network_select_saved_mesh_network(GList **saved_network, const char *mesh_id,
-               int mesh_channel, int security);
-int mesh_network_forget_saved_mesh_network(GList **saved_network, const char *mesh_id,
-               int mesh_channel, int security);
-int mesh_network_clear_saved_mesh_network(GList **saved_network);
-
-int mesh_network_get_first_mesh_network(GList *saved_network,
-               mesh_network_info_s *info);
-
-#endif /* __MESH_NETWORK_H__ */
index e8ac42a..97fdcf2 100644 (file)
@@ -19,9 +19,6 @@
 #ifndef __MESH_REQUEST_H__
 #define __MESH_REQUEST_H__
 
-int mesh_request_dhcp(const char* interface);
-int mesh_request_stop_dhcp();
-
 /* Newly functions */
 int mesh_request_ipc_enable_network(mesh_service *service);
 int mesh_request_ipc_disable_network(mesh_service *service);
@@ -41,42 +38,18 @@ int mesh_request_ipc_disconnect_mesh_network(mesh_service *service,
 int mesh_request_ipc_remove_mesh_network(mesh_service *service,
                gchar *mesh_id, gint channel, meshd_security_type_e sec);
 
-int mesh_request_enable_mesh(const char* base_interface,
-               const char* mesh_interface, GList *saved_network,
-               mesh_network_info_s **joined_network);
-int mesh_request_disable_mesh(const char* mesh_interface);
-
 int mesh_request_set_mesh_gate(const char* bridge_interface,
                const char* mesh_interface, const char* external_interface);
 int mesh_request_unset_mesh_gate(const char* bridge_interface,
                const char* mesh_interface, const char* external_interface);
 
+
 /* Bridge network */
-int mesh_request_create_bridge(const char* bridge_interface,
-               const char* mesh_interface);
-int mesh_request_remove_bridge(const char* bridge_interface);
 int mesh_request_add_bridge_interface(const char* bridge_interface,
                const char* interface);
 int mesh_request_remove_bridge_interface(const char* bridge_interface,
                const char* interface);
 
-int mesh_request_scan(const char* mesh_interface);
-int mesh_request_specific_scan(const char* mesh_interface, const char* mesh_id,
-               int mesh_channel);
-int mesh_request_cancel_scan(const char* mesh_interface);
-int mesh_request_get_scan_result(const char* mesh_interface, GList **scan_list);
-
-/* Saved network */
-int mesh_request_load_saved_mesh_network(GList **network_list);
-int mesh_request_add_mesh_network(GList **saved_network,
-               const char *mesh_id, int channel, int security);
-int mesh_request_get_saved_mesh_network(GList **saved_network);
-int mesh_request_select_saved_mesh_network(GList **saved_network,
-               const char *mesh_id, int channel, int security);
-int mesh_request_forget_saved_mesh_network(GList **saved_network,
-               const char *mesh_id, int channel, int security);
-int mesh_request_clear_saved_mesh_network(GList **saved_network);
-
 /* Soft AP */
 int mesh_request_set_softap_config(const char* softap_interface,
                const char *ssid, const char* mode, int channel, int visibility,
index 33fabc1..89416f0 100644 (file)
@@ -74,7 +74,6 @@ typedef struct _mesh_network_info {
 typedef struct {
        gchar *object_path; /**< Object path from connman */
        gchar *mesh_id; /**< The mesh id */
-       gint mesh_id_len; /**< Length of mesh id */
        gchar *bssid; /**< BSSID */
        gint rssi; /**< RSSI */
        gint channel; /**< Channel */
@@ -156,7 +155,6 @@ typedef struct _mesh_service {
 
        mesh_interface_s *interface_info; /**< Name of network interfaces */
        gboolean mesh_activated; /**< Stored if mesh network is activated */
-       GList *saved_mesh_network; /**< Saved mesh network list */
        GList *scanned_mesh_network; /**< Scanned mesh network list */
        GList *connected_mesh_peers; /**< Connected mesh peer list */
        mesh_network_info_s *joined_network; /**< Joined network info */
index 45fdf7d..481390b 100644 (file)
@@ -61,9 +61,6 @@ cp meshd.service %{buildroot}%{_unitdir}/meshd.service
 %post
 chmod 755 %{_sbindir}/mesh.sh
 
-# For configuration file
-mkdir -p %TZ_SYS_VAR/lib/mesh
-
 %files
 %manifest meshd.manifest
 %license LICENSE
diff --git a/src/mesh-dhcp.c b/src/mesh-dhcp.c
deleted file mode 100644 (file)
index d12ccfc..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <glib.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-service.h"
-#include "mesh-dhcp.h"
-
-#define DHCP_PATH        "/usr/bin/dhcp"
-#define DHCP_RETRY_COUNT "10"
-
-typedef struct {
-       GPid child_pid;
-       guint child_source;
-       guint output_source;
-       guint error_source;
-
-       dhcp_finished_cb callback;
-       const char* interface;
-       char* ip_address;
-       void *user_data;
-} spawn_info_s;
-
-static spawn_info_s *dhcp_info = NULL;
-
-static char* __get_obtained_ip_address(const char *str)
-{
-       char *token = NULL;
-       char *tmp = NULL;
-       char *found = NULL;
-       char *ptr = NULL;
-       int local_index = 0;
-
-       tmp = g_strdup(str);
-
-       token = strtok_r(tmp, " ", &ptr);
-       while (token != NULL) {
-               local_index++;
-               if (local_index == 3) {
-                       found = g_strdup(token);
-               }
-               token = strtok_r(NULL, " ", &ptr);
-       }
-
-       g_free(tmp);
-
-       return found;
-}
-
-static gboolean _child_logger(GIOChannel *source, GIOCondition condition,
-               gpointer data)
-{
-       gchar *buf = NULL;
-       gchar *address = NULL;
-       GError *error = NULL;
-       GIOStatus status = G_IO_STATUS_NORMAL;
-
-       NOTUSED(condition);
-       NOTUSED(data);
-
-       while(G_IO_STATUS_NORMAL == status) {
-               status = g_io_channel_read_line(source, &buf, NULL, NULL, &error);
-               if (G_IO_STATUS_ERROR == status) {
-                       MESH_LOGE("Failed to read i/o [%s]", error->message);
-                       g_free(buf);
-                       g_error_free(error);
-               } else if (G_IO_STATUS_EOF != status) {
-                       if (NULL == buf) continue;
-                       MESH_LOGD("[CHILD] %s", buf);
-
-                       /* Check if IP obtained */
-                       if (g_str_has_prefix((const gchar*)buf, "Lease of ")) {
-                               address = __get_obtained_ip_address(buf);
-                               if (NULL == address)
-                                       address = g_strdup("0.0.0.0");
-
-                               MESH_LOGD("[Found] %s", address);
-                               if (dhcp_info)
-                                       dhcp_info->ip_address = address;
-                       }
-               }
-       }
-
-       /* Do not remove */
-       return TRUE;
-}
-
-static void _child_process_watcher(GPid pid, gint status, gpointer user_data)
-{
-       NOTUSED(user_data);
-
-       g_spawn_close_pid(pid);
-       if (dhcp_info) {
-               dhcp_info->callback(dhcp_info->interface,
-                               dhcp_info->ip_address, dhcp_info->user_data);
-
-               g_source_remove(dhcp_info->error_source);
-               g_source_remove(dhcp_info->output_source);
-               g_source_remove(dhcp_info->child_source);
-               g_free(dhcp_info->ip_address);
-
-               g_free(dhcp_info);
-               dhcp_info = NULL;
-       }
-       MESH_LOGD("[CHILD] terminated with [%d]", status);
-}
-
-static int _internal_request_dhcp(const char *interface_name)
-{
-       gboolean result = FALSE;
-
-       /* spawn DHCP process */
-       GError *error = NULL;
-       gint standard_output = 0;
-       gint standard_error = 0;
-       GIOChannel *output_channel = NULL;
-       GIOChannel *error_channel = NULL;
-       gchar *request_dhcp[] = {
-               (char *)DHCP_PATH,
-               (char *)"-v",
-               (char *)"-A",
-               (char *)"5",
-               (char *)"-i",
-               (char *)interface_name,
-               (char *)"-q",
-               NULL
-       };
-
-       if (NULL == dhcp_info) {
-               MESH_LOGE("Unexpected parameter failure");
-               return MESHD_ERROR_OPERATION_FAILED;
-       }
-
-       result = g_spawn_async_with_pipes(NULL,
-               request_dhcp,
-               NULL,
-               (G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD),
-               NULL,
-               NULL,
-               &(dhcp_info->child_pid),
-               NULL,
-               &standard_output,
-               &standard_error,
-               &error);
-       if (result == FALSE) {
-               MESH_LOGE("Failed to request DHCP! : [%s]", error->message);
-               g_error_free(error);
-               g_free(dhcp_info);
-               dhcp_info = NULL;
-
-               return MESHD_ERROR_OPERATION_FAILED;
-       }
-
-       output_channel = g_io_channel_unix_new(standard_output);
-       error_channel = g_io_channel_unix_new(standard_error);
-       g_io_channel_set_flags(output_channel, G_IO_FLAG_NONBLOCK, NULL);
-       g_io_channel_set_flags(error_channel, G_IO_FLAG_NONBLOCK, NULL);
-       dhcp_info->output_source = g_io_add_watch(output_channel,
-                       (G_IO_IN | G_IO_ERR), _child_logger, NULL);
-       dhcp_info->error_source = g_io_add_watch(error_channel,
-                       (G_IO_IN | G_IO_ERR), _child_logger, NULL);
-       g_io_channel_unref(output_channel);
-       g_io_channel_unref(error_channel);
-
-       dhcp_info->child_source = g_child_watch_add(dhcp_info->child_pid,
-                       _child_process_watcher, NULL);
-
-       MESH_LOGD("DHCP requested");
-       return MESHD_ERROR_NONE;
-}
-
-int mesh_dhcp_request(const char* interface,
-               dhcp_finished_cb callback, void *user_data)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL != dhcp_info) {
-               MESH_LOGE("DHCP is requested already");
-               return MESHD_ERROR_IN_PROGRESS;
-       }
-
-       dhcp_info = g_new0(spawn_info_s, 1);
-       if (NULL == dhcp_info) {
-               MESH_LOGE("Falied to allocate information");
-               return MESHD_ERROR_OUT_OF_MEMORY;
-       }
-
-       dhcp_info->interface = interface;
-       dhcp_info->callback = callback;
-       dhcp_info->user_data = user_data;
-       ret = _internal_request_dhcp(interface);
-
-       return ret;
-}
-
-int mesh_dhcp_stop_request()
-{
-       gboolean result;
-       GError *error = NULL;
-
-       if (NULL == dhcp_info) {
-               MESH_LOGE("DHCP is not requested or terminated already !");
-               return MESHD_ERROR_NONE;
-       }
-
-       result = g_spawn_command_line_async("/usr/bin/killall dhcp", &error);
-       if (FALSE == result) {
-               MESH_LOGE("Failed to terminate DHCP : [%s]", error->message);
-               g_error_free(error);
-               return MESHD_ERROR_OPERATION_FAILED;
-       }
-
-       g_source_remove(dhcp_info->output_source);
-       g_source_remove(dhcp_info->error_source);
-
-       g_free(dhcp_info);
-       dhcp_info = NULL;
-
-       return MESHD_ERROR_NONE;
-}
index 058fcc1..abe15dc 100644 (file)
  */
 #include <glib.h>
 
-#if 0
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#endif
-
 #include "mesh.h"
 #include "mesh-log.h"
 #include "mesh-util.h"
index 841de3f..cce1032 100644 (file)
 
 #include "nl80211.h"
 
-#define INTERFACE_TYPE_MANAGED      "managed"
-#define INTERFACE_TYPE_MESHPOINT    "mp"
-#define INTERFACE_TYPE_NAME_MAX_LEN 8
-
 #define MESH_PARAM_HWMP_ROOTMODE  "mesh_hwmp_rootmode"
 #define MESH_PARAM_GATE_ANNOUNCE  "mesh_gate_announcements"
-#define MESH_PARAM_STR_LEN_MAX    23
-#define MESH_ELEMENT_ID           114
-#define MAX_MAC_ADDR_LEN          18
-#define ETH_ALEN 6
+#define MAX_MAC_ADDR_LEN  18
+#define ETH_ALEN          6
 
 #define BIT(x) (1ULL<<(x))
 
 typedef enum {
        MESH_NL_CALLBACK_FINISHED = 0,
        MESH_NL_CALLBACK_TRYING,
-       MESH_NL_CALLBACK_SCAN_FINISHED,
 } mesh_nl_callback_state_e;
 
 typedef struct {
@@ -71,9 +64,7 @@ typedef struct {
        struct nl_cb *cb;
        struct nl_cb *s_cb;
 
-       gchar* scanning_interface;
        bool error_occured;
-       GList **scan_list;
        GList **station_list;
        GList **mpath_list;
 } mesh_nl_state;
@@ -93,58 +84,9 @@ enum plink_state {
        BLOCKED
 };
 
-static bool scan_in_progress = FALSE;
-
 /* For event handler */
 static mesh_nl_state *event_state = NULL;
 
-#if 0
-gboolean _handle_nl_response_message(GIOChannel *source,
-       GIOCondition condition, gpointer data);
-#endif
-
-static int __channel_to_frequency(int channel, enum nl80211_band band)
-{
-       if (channel <= 0)
-               return 0;
-
-       switch (band) {
-       case NL80211_BAND_2GHZ:
-               if (channel == 14)
-                       return 2484;
-               else if (channel < 14)
-                       return 2407 + channel * 5;
-               break;
-       case NL80211_BAND_5GHZ:
-               if (channel >= 182 && channel <= 196)
-                       return 4000 + channel * 5;
-               else
-                       return 5000 + channel * 5;
-               break;
-       default:
-               break;
-       }
-
-       /* not supported */
-       return 0;
-}
-
-static int __frequency_to_channel(int freq)
-{
-       if (freq == 2484)
-               return 14;
-       else if (freq < 2484)
-               return (freq - 2407) / 5;
-       else if (freq >= 4910 && freq <= 4980)
-               return (freq - 4000) / 5;
-       else if (freq <= 45000)
-               return (freq - 5000) / 5;
-       else if (freq >= 58320 && freq <= 64800)
-               return (freq - 56160) / 2160;
-       else
-               return 0;
-}
-
 static int __initialize_nl80211(mesh_nl_state *state)
 {
        int err = MESHD_ERROR_NONE;
@@ -189,32 +131,6 @@ static void __clean_nl80211(mesh_nl_state *state)
        }
 }
 
-static int __get_if_type_from_string(const char* type_string,
-               enum nl80211_iftype *type)
-{
-       if (NULL == type_string || NULL == type) {
-               MESH_LOGE("Invalid parameter");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       if (strncmp(type_string, "adhoc", INTERFACE_TYPE_NAME_MAX_LEN) == 0 ||
-               strncmp(type_string, "ibss", INTERFACE_TYPE_NAME_MAX_LEN) == 0) {
-               *type = NL80211_IFTYPE_ADHOC;
-       } else if (strncmp(type_string, "managed", INTERFACE_TYPE_NAME_MAX_LEN) == 0 ||
-               strncmp(type_string, "mgd", INTERFACE_TYPE_NAME_MAX_LEN) == 0 ||
-               strncmp(type_string, "station", INTERFACE_TYPE_NAME_MAX_LEN) == 0) {
-               *type = NL80211_IFTYPE_STATION;
-       } else if (strncmp(type_string, "mp", INTERFACE_TYPE_NAME_MAX_LEN) == 0 ||
-               strncmp(type_string, "mesh", INTERFACE_TYPE_NAME_MAX_LEN) == 0) {
-               *type = NL80211_IFTYPE_MESH_POINT;
-       } else {
-               MESH_LOGE("Invalid interface type [%s]", type_string);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
 static int __get_device_index_from_string(const char* if_name, int *index)
 {
        int device_index = 0;
@@ -234,8 +150,7 @@ static int __get_device_index_from_string(const char* if_name, int *index)
        return MESHD_ERROR_NONE;
 }
 
-static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
-                        void *arg)
+static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
 {
        mesh_nl_state *state = (mesh_nl_state *)arg;
        char buf[256] = { 0, };
@@ -448,13 +363,12 @@ static int __prepare_listen_events(mesh_nl_state *state)
        return 0;
 }
 
-static mesh_nl_state *_create_mesh_nl_state(const char* scan_if_name)
+static mesh_nl_state *_create_mesh_nl_state()
 {
        mesh_nl_state *state = g_new0(mesh_nl_state, 1);
 
        state->nl80211_id = -1;
        state->callback_state = MESH_NL_CALLBACK_TRYING;
-       state->scanning_interface = g_strdup(scan_if_name);
        state->error_occured = FALSE;
 
        return state;
@@ -465,40 +379,10 @@ static void _delete_mesh_nl_state(mesh_nl_state **state)
        if (NULL == state || NULL == *state)
                return;
 
-       if ((*state)->scanning_interface)
-               g_free((*state)->scanning_interface);
        g_free(*state);
        *state = NULL;
 }
 
-#if 0
-/* These variables and function is required for event callback. */
-static int (*mesh_nl_event_callback)(struct nl_msg *, void *);
-static void *mesh_nl_event_callback_data;
-
-static void register_handler(int (*handler)(struct nl_msg *, void *), void *data)
-{
-       MESH_LOGD("register_handler : [%p]", handler);
-       mesh_nl_event_callback = handler;
-       mesh_nl_event_callback_data = data;
-}
-
-static gboolean _dump_scan_results(gpointer user_data)
-{
-       char *if_name = (char *)user_data;
-       MESH_LOGD("_dump_scan_results [%s]", if_name);
-
-       if (NULL == if_name) {
-               MESH_LOGE("Invalid parameter");
-               return G_SOURCE_REMOVE;
-       }
-
-       _send_nl_get_scan_result(if_name);
-       g_free(if_name);
-       return G_SOURCE_REMOVE;
-}
-#endif
-
 static int valid_handler(struct nl_msg *msg, void *arg)
 {
        struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
@@ -584,14 +468,6 @@ static int __initialize_netlink_message(mesh_nl_state *state)
        nl_cb_set(state->cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, state);
        nl_cb_set(state->cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, state);
 
-#if 0
-       /* If async logic is required */
-       //GIOChannel *channel = NULL;
-       channel = g_io_channel_unix_new(state->nl_socket);
-       state->source = g_io_add_watch(state->sock_channel,
-                       (G_IO_IN | G_IO_ERR), _handle_nl_response_message, state);
-       g_io_channel_unref(channel);
-#endif
        MESH_LOGD("netlink socket initialized");
 
        return MESHD_ERROR_NONE;
@@ -602,32 +478,6 @@ DESTROY:
        return err;
 }
 
-static gboolean _on_socket_io_received(GIOChannel *source,
-               GIOCondition condition, gpointer data)
-{
-       mesh_nl_state *state = (mesh_nl_state *)data;
-       int test = 0;
-
-       NOTUSED(source);
-       NOTUSED(condition);
-
-       MESH_LOGD("I/O received");
-
-       state->callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state->callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state->nl_socket, state->cb);
-       }
-
-       /* Close related resources if response received */
-       __clean_netlink_message(state);
-       __clean_nl80211(state);
-       _delete_mesh_nl_state(&state);
-
-       /* remove */
-       return FALSE;
-}
-
 static gboolean _on_socket_event_io_received(GIOChannel *source,
                GIOCondition condition, gpointer data)
 {
@@ -658,419 +508,124 @@ static void _on_remove_event_io_handler()
        }
 }
 
-#if 0
-/* If async logic is required */
-static gboolean _handle_nl_response_message(GIOChannel *source,
-       GIOCondition condition, gpointer data)
+static void mac_addr_n2a(char *mac_addr, unsigned char *arg)
 {
-       mesh_nl_state *state = (mesh_nl_state *)data;
-
-       if (NULL == state) {
-               MESH_LOGE("state is not exist !");
-               return FALSE;
-       }
-
-       nl_recvmsgs(state.nl_socket, state.cb);
-       if (state->callback_state) {
-               return FALSE;
-       }
-
-       return TRUE;
+       snprintf(mac_addr, MAX_MAC_ADDR_LEN+1,
+                       "%02X:%02X:%02X:%02X:%02X:%02X",
+                       arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
 }
-#endif
 
-static int _send_nl_set_type_managed(const char* base_if_name)
+static char *get_chain_signal(struct nlattr *attr_list)
 {
-       mesh_nl_state state = {
-               .nl80211_id = -1,
-               .callback_state = MESH_NL_CALLBACK_TRYING,
-               .event_source = 0,
-               .nl_socket = NULL,
-               .msg = NULL,
-               .cb = NULL,
-               .s_cb = NULL,
-               .scanning_interface = NULL,
-               .error_occured = FALSE,
-       };
-       enum nl80211_iftype type;
-       int err = MESHD_ERROR_NONE;
-       int device_index = 0;
-       int ret;
-       int test = 0;
-
-       ret = __initialize_nl80211(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize nl80211");
-               return ret;
-       }
+       struct nlattr *attr;
+       static char buf[64];
+       char *cur = buf;
+       int i = 0, rem;
+       const char *prefix;
 
-       ret = __initialize_netlink_message(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
-       }
+       if (!attr_list)
+               return (char *)"";
 
-       /* Set command into message */
-       genlmsg_put(state.msg, 0, 0, state.nl80211_id, 0,
-                   0, NL80211_CMD_SET_INTERFACE, 0);
+       nla_for_each_nested(attr, attr_list, rem) {
+               if (i++ > 0)
+                       prefix = ", ";
+               else
+                       prefix = "[";
 
-       /* Add attributes into message */
-       ret = __get_device_index_from_string(base_if_name, &device_index);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get base interface device index");
-               err = ret;
-               goto DESTROY;
+               cur += snprintf(cur, sizeof(buf) - (cur - buf), "%s%d", prefix,
+                               (int8_t) nla_get_u8(attr));
        }
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
 
-       ret = __get_if_type_from_string(INTERFACE_TYPE_MANAGED, &type);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get interface type");
-               err = ret;
-               goto DESTROY;
-       }
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFTYPE, type);
+       if (i)
+               snprintf(cur, sizeof(buf) - (cur - buf), "] ");
 
-       /* Send message into kernel */
-       ret = nl_send_auto(state.nl_socket, state.msg);
-       if (ret < 0) {
-               MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
-                               nl_geterror(ret), ret);
-               err = MESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
-       }
+       return buf;
+}
 
-       /* sync response */
-       state.callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state.nl_socket, state.cb);
-       }
+static int parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen)
+{
+       int rate = 0;
+       char *pos = buf;
+       struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+       static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+               [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+               [NL80211_RATE_INFO_BITRATE32] = { .type = NLA_U32 },
+               [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
+               [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+               [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+       };
 
-DESTROY:
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
+       if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX, bitrate_attr, rate_policy)) {
+               snprintf(buf, buflen, "failed to parse nested rate attributes!");
+               return 0;
+       }
 
-       return err;
+       if (rinfo[NL80211_RATE_INFO_BITRATE32])
+               rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE32]);
+       else if (rinfo[NL80211_RATE_INFO_BITRATE])
+               rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+       if (rate > 0)
+               pos += snprintf(pos, buflen - (pos - buf),
+                               "%d.%d MBit/s", rate / 10, rate % 10);
 
-nla_put_failure:
-       MESH_LOGE("Failed to message build");
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
+       if (rinfo[NL80211_RATE_INFO_MCS])
+               pos += snprintf(pos, buflen - (pos - buf),
+                               " MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
+       if (rinfo[NL80211_RATE_INFO_VHT_MCS])
+               pos += snprintf(pos, buflen - (pos - buf),
+                               " VHT-MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_VHT_MCS]));
+       if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+               pos += snprintf(pos, buflen - (pos - buf), " 40MHz");
+       if (rinfo[NL80211_RATE_INFO_80_MHZ_WIDTH])
+               pos += snprintf(pos, buflen - (pos - buf), " 80MHz");
+       if (rinfo[NL80211_RATE_INFO_80P80_MHZ_WIDTH])
+               pos += snprintf(pos, buflen - (pos - buf), " 80P80MHz");
+       if (rinfo[NL80211_RATE_INFO_160_MHZ_WIDTH])
+               pos += snprintf(pos, buflen - (pos - buf), " 160MHz");
+       if (rinfo[NL80211_RATE_INFO_SHORT_GI])
+               pos += snprintf(pos, buflen - (pos - buf), " short GI");
+       if (rinfo[NL80211_RATE_INFO_VHT_NSS])
+               pos += snprintf(pos, buflen - (pos - buf),
+                               " VHT-NSS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_VHT_NSS]));
 
-       return MESHD_ERROR_OPERATION_FAILED;
+       return rate;
 }
 
-static int _send_nl_create_mesh_interface(const char* base_if_name,
-               const char* mesh_if_name, const char* mesh_id)
+static void parse_bss_param(struct nlattr *bss_param_attr, mesh_station_info_s *station_info)
 {
-       mesh_nl_state state = {
-               .nl80211_id = -1,
-               .callback_state = MESH_NL_CALLBACK_TRYING,
-               .event_source = 0,
-               .nl_socket = NULL,
-               .msg = NULL,
-               .cb = NULL,
-               .s_cb = NULL,
-               .scanning_interface = NULL,
-               .error_occured = FALSE,
+       struct nlattr *bss_param_info[NL80211_STA_BSS_PARAM_MAX + 1], *info;
+       static struct nla_policy bss_poilcy[NL80211_STA_BSS_PARAM_MAX + 1] = {
+               [NL80211_STA_BSS_PARAM_CTS_PROT] = { .type = NLA_FLAG },
+               [NL80211_STA_BSS_PARAM_SHORT_PREAMBLE] = { .type = NLA_FLAG },
+               [NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME] = { .type = NLA_FLAG },
+               [NL80211_STA_BSS_PARAM_DTIM_PERIOD] = { .type = NLA_U8 },
+               [NL80211_STA_BSS_PARAM_BEACON_INTERVAL] = { .type = NLA_U16 },
        };
-       enum nl80211_iftype type;
-       int err = MESHD_ERROR_NONE;
-       int device_index = 0;
-       int ret;
-       int test = 0;
 
-       ret = __initialize_nl80211(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize nl80211");
-               return ret;
+       if (nla_parse_nested(bss_param_info, NL80211_STA_BSS_PARAM_MAX, bss_param_attr, bss_poilcy)) {
+               MESH_LOGE("failed to parse nested bss param attributes!");
        }
 
-       ret = __initialize_netlink_message(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
+       info = bss_param_info[NL80211_STA_BSS_PARAM_DTIM_PERIOD];
+       if (info) {
+               station_info->dtim_period = nla_get_u8(info);
+               MESH_LOGD("    DTIM period:\t%u", station_info->dtim_period);
        }
-
-       /* Set command into message */
-       genlmsg_put(state.msg, 0, 0, state.nl80211_id, 0,
-                   0, NL80211_CMD_NEW_INTERFACE, 0);
-
-       /* Add attributes into message */
-       ret = __get_device_index_from_string(base_if_name, &device_index);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get base interface device index");
-               err = ret;
-               goto DESTROY;
+       info = bss_param_info[NL80211_STA_BSS_PARAM_BEACON_INTERVAL];
+       if (info) {
+               station_info->beacon_interval = nla_get_u16(info);
+               MESH_LOGD("    beacon interval:%u", station_info->beacon_interval);
        }
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
-
-       ret = __get_if_type_from_string(INTERFACE_TYPE_MESHPOINT, &type);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get interface type");
-               err = ret;
-               goto DESTROY;
-       }
-       NLA_PUT_STRING(state.msg, NL80211_ATTR_IFNAME, mesh_if_name);
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFTYPE, type);
-
-       /* Set Mesh ID */
-       NLA_PUT(state.msg, NL80211_ATTR_MESH_ID, strlen(mesh_id), mesh_id);
-
-       /* Send message into kernel */
-       ret = nl_send_auto(state.nl_socket, state.msg);
-       if (ret < 0) {
-               MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
-                               nl_geterror(ret), ret);
-               err = MESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
-       }
-
-       /* sync response */
-       state.callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state.nl_socket, state.cb);
-       }
-
-DESTROY:
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return err;
-
-nla_put_failure:
-       MESH_LOGE("Failed to message build");
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return MESHD_ERROR_OPERATION_FAILED;
-}
-
-static int _send_nl_delete_mesh_interface(const char* mesh_if_name)
-{
-       mesh_nl_state state = {
-               .nl80211_id = -1,
-               .callback_state = MESH_NL_CALLBACK_TRYING,
-               .event_source = 0,
-               .nl_socket = NULL,
-               .msg = NULL,
-               .cb = NULL,
-               .s_cb = NULL,
-               .scanning_interface = NULL,
-               .error_occured = FALSE,
-       };
-       int err = MESHD_ERROR_NONE;
-       int device_index = 0;
-       int ret;
-       int test = 0;
-
-       ret = __initialize_nl80211(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize nl80211");
-               return ret;
-       }
-
-       ret = __initialize_netlink_message(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
-       }
-
-       /* Set command into message */
-       genlmsg_put(state.msg, 0, 0, state.nl80211_id, 0,
-                   0, NL80211_CMD_DEL_INTERFACE, 0);
-
-       /* Add attributes into message */
-       ret = __get_device_index_from_string(mesh_if_name, &device_index);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get mesh interface device index");
-               err = ret;
-               goto DESTROY;
-       }
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
-
-       /* Send message into kernel */
-       ret = nl_send_auto(state.nl_socket, state.msg);
-       if (ret < 0) {
-               MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
-                               nl_geterror(ret), ret);
-               err = MESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
-       }
-
-       /* sync response */
-       state.callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state.nl_socket, state.cb);
-       }
-
-DESTROY:
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return err;
-
-nla_put_failure:
-       MESH_LOGE("Failed to message build");
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return MESHD_ERROR_OPERATION_FAILED;
-}
-
-static void mac_addr_n2a(char *mac_addr, unsigned char *arg)
-{
-       snprintf(mac_addr, MAX_MAC_ADDR_LEN+1,
-                       "%02X:%02X:%02X:%02X:%02X:%02X",
-                       arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
-}
-
-// ASCII
-static char* _get_meshid(const uint8_t len, const uint8_t *data)
-{
-       int i;
-       char buf[64] = {0, };
-       char *result = g_try_malloc0(sizeof(char) * len+1);
-       if (NULL == result) {
-               MESH_LOGE("Failed to allocate");
-               return NULL;
-       }
-
-       for (i = 0; i < len; i++) {
-               result[i] = data[i];
-               if (/*isprint(data[i]) && */data[i] != ' ' && data[i] != '\\')
-                       //printf("%c", data[i]);
-                       buf[i] = data[i];
-               else if (data[i] == ' ' &&
-                        (i != 0 && i != len -1))
-                       //printf(" ");
-                       buf[i] = ' ';
-               else
-                       //printf("\\x%.2x", data[i]);
-                       buf[i] = '?';
-       }
-       result[len] = '\0';
-       MESH_LOGD("  : %s", buf);
-
-       return result;
-}
-
-static char *get_chain_signal(struct nlattr *attr_list)
-{
-       struct nlattr *attr;
-       static char buf[64];
-       char *cur = buf;
-       int i = 0, rem;
-       const char *prefix;
-
-       if (!attr_list)
-               return (char *)"";
-
-       nla_for_each_nested(attr, attr_list, rem) {
-               if (i++ > 0)
-                       prefix = ", ";
-               else
-                       prefix = "[";
-
-               cur += snprintf(cur, sizeof(buf) - (cur - buf), "%s%d", prefix,
-                               (int8_t) nla_get_u8(attr));
-       }
-
-       if (i)
-               snprintf(cur, sizeof(buf) - (cur - buf), "] ");
-
-       return buf;
-}
-
-static int parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen)
-{
-       int rate = 0;
-       char *pos = buf;
-       struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
-       static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
-               [NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
-               [NL80211_RATE_INFO_BITRATE32] = { .type = NLA_U32 },
-               [NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
-               [NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
-               [NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
-       };
-
-       if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
-                            bitrate_attr, rate_policy)) {
-               snprintf(buf, buflen, "failed to parse nested rate attributes!");
-               return 0;
-       }
-
-       if (rinfo[NL80211_RATE_INFO_BITRATE32])
-               rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE32]);
-       else if (rinfo[NL80211_RATE_INFO_BITRATE])
-               rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
-       if (rate > 0)
-               pos += snprintf(pos, buflen - (pos - buf),
-                               "%d.%d MBit/s", rate / 10, rate % 10);
-
-       if (rinfo[NL80211_RATE_INFO_MCS])
-               pos += snprintf(pos, buflen - (pos - buf),
-                               " MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
-       if (rinfo[NL80211_RATE_INFO_VHT_MCS])
-               pos += snprintf(pos, buflen - (pos - buf),
-                               " VHT-MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_VHT_MCS]));
-       if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
-               pos += snprintf(pos, buflen - (pos - buf), " 40MHz");
-       if (rinfo[NL80211_RATE_INFO_80_MHZ_WIDTH])
-               pos += snprintf(pos, buflen - (pos - buf), " 80MHz");
-       if (rinfo[NL80211_RATE_INFO_80P80_MHZ_WIDTH])
-               pos += snprintf(pos, buflen - (pos - buf), " 80P80MHz");
-       if (rinfo[NL80211_RATE_INFO_160_MHZ_WIDTH])
-               pos += snprintf(pos, buflen - (pos - buf), " 160MHz");
-       if (rinfo[NL80211_RATE_INFO_SHORT_GI])
-               pos += snprintf(pos, buflen - (pos - buf), " short GI");
-       if (rinfo[NL80211_RATE_INFO_VHT_NSS])
-               pos += snprintf(pos, buflen - (pos - buf),
-                               " VHT-NSS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_VHT_NSS]));
-
-       return rate;
-}
-
-static void parse_bss_param(struct nlattr *bss_param_attr, mesh_station_info_s *station_info)
-{
-       struct nlattr *bss_param_info[NL80211_STA_BSS_PARAM_MAX + 1], *info;
-       static struct nla_policy bss_poilcy[NL80211_STA_BSS_PARAM_MAX + 1] = {
-               [NL80211_STA_BSS_PARAM_CTS_PROT] = { .type = NLA_FLAG },
-               [NL80211_STA_BSS_PARAM_SHORT_PREAMBLE] = { .type = NLA_FLAG },
-               [NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME] = { .type = NLA_FLAG },
-               [NL80211_STA_BSS_PARAM_DTIM_PERIOD] = { .type = NLA_U8 },
-               [NL80211_STA_BSS_PARAM_BEACON_INTERVAL] = { .type = NLA_U16 },
-       };
-
-       if (nla_parse_nested(bss_param_info, NL80211_STA_BSS_PARAM_MAX,
-                            bss_param_attr, bss_poilcy)) {
-               MESH_LOGE("failed to parse nested bss param attributes!");
-       }
-
-       info = bss_param_info[NL80211_STA_BSS_PARAM_DTIM_PERIOD];
-       if (info) {
-               station_info->dtim_period = nla_get_u8(info);
-               MESH_LOGD("    DTIM period:\t%u", station_info->dtim_period);
-       }
-       info = bss_param_info[NL80211_STA_BSS_PARAM_BEACON_INTERVAL];
-       if (info) {
-               station_info->beacon_interval = nla_get_u16(info);
-               MESH_LOGD("    beacon interval:%u", station_info->beacon_interval);
-       }
-       info = bss_param_info[NL80211_STA_BSS_PARAM_CTS_PROT];
-       if (info) {
-               MESH_LOGD("    CTS protection:");
-               if (nla_get_u16(info)) {
-                       MESH_LOGD("    yes");
-                       station_info->cts_protection = TRUE;
-               } else {
-                       MESH_LOGD("    no");
-                       station_info->cts_protection = FALSE;
-               }
+       info = bss_param_info[NL80211_STA_BSS_PARAM_CTS_PROT];
+       if (info) {
+               MESH_LOGD("    CTS protection:");
+               if (nla_get_u16(info)) {
+                       MESH_LOGD("    yes");
+                       station_info->cts_protection = TRUE;
+               } else {
+                       MESH_LOGD("    no");
+                       station_info->cts_protection = FALSE;
+               }
        }
        info = bss_param_info[NL80211_STA_BSS_PARAM_SHORT_PREAMBLE];
        if (info) {
@@ -1116,123 +671,7 @@ static void print_power_mode(struct nlattr *a)
        }
 }
 
-static int _on_receive_bss_information(struct nl_msg *msg, void *arg)
-{
-       struct nlattr *tb[NL80211_ATTR_MAX + 1];
-       struct nlattr *bss[NL80211_BSS_MAX + 1];
-       struct genlmsghdr *general_header = nlmsg_data(nlmsg_hdr(msg));
-       mesh_nl_state *state = (mesh_nl_state *)arg;
-       mesh_scan_result_s *scan_info = NULL;
-
-       char mac_addr[20], ifname[20];
-       char *mesh_id = NULL;
-       guint mesh_id_len = 0;
-       int signal_mbm = 0;
-       unsigned char signal_un = 0;
-       int frequency = 0;
-       int is_mesh_bss = FALSE;
-       static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
-               [NL80211_BSS_BSSID] = { .type = NLA_UNSPEC },
-               [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
-               [NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 },
-               [NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
-               [NL80211_BSS_INFORMATION_ELEMENTS] = { .type = NLA_UNSPEC },
-               [NL80211_BSS_BEACON_IES] = { .type = NLA_UNSPEC },
-       };
-
-       if (NULL == state) {
-               MESH_LOGE("Invalid state data");
-               goto FINISH;
-       }
-
-       nla_parse(tb, NL80211_ATTR_MAX,
-                       genlmsg_attrdata(general_header, 0),
-                       genlmsg_attrlen(general_header, 0), NULL);
-
-       if (!tb[NL80211_ATTR_BSS]) {
-               MESH_LOGE("Missing BSS information");
-               goto FINISH;
-       }
-       if (nla_parse_nested(bss, NL80211_BSS_MAX,
-                       tb[NL80211_ATTR_BSS], bss_policy)) {
-               MESH_LOGE("failed to parse nested attributes!");
-               goto FINISH;
-       }
-
-       /* BSS information elements */
-       if (bss[NL80211_BSS_INFORMATION_ELEMENTS]) {
-               uint8_t *ie = nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
-               int ielen   = nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]);
-               uint8_t len = ie[1];
-
-               while (ielen >= 2 && ielen >= ie[1]) {
-                       len = ie[1];
-                       switch (ie[0]) {
-                       case MESH_ELEMENT_ID: /* MESH ID */
-                               MESH_LOGD("MESH ID");
-                               mesh_id = _get_meshid(len, ie+2);
-                               mesh_id_len = len;
-                               is_mesh_bss = TRUE;
-                               break;
-                       default:
-                               break;
-                       }
-                       ielen -= ie[1] + 2;
-                       ie    += ie[1] + 2;
-               }
-       }
-       if (FALSE == is_mesh_bss) {
-               /* This is not an mesh bss */
-               goto FINISH;
-       }
-
-       /* Get BSS */
-       mac_addr_n2a(mac_addr, nla_data(bss[NL80211_BSS_BSSID]));
-       if (tb[NL80211_ATTR_IFINDEX]) {
-               if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
-               MESH_LOGD("BSS %s (interface: %s)", mac_addr, ifname);
-       } else {
-               MESH_LOGD("BSS %s", mac_addr);
-       }
-
-       /* Get Frequency */
-       if (bss[NL80211_BSS_FREQUENCY]) {
-               frequency = nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
-               MESH_LOGD("  frequency: %d", frequency);
-       }
-
-       /* Signal strength */
-       if (bss[NL80211_BSS_SIGNAL_MBM]) {
-               signal_mbm = nla_get_u32(bss[NL80211_BSS_SIGNAL_MBM]);
-               MESH_LOGD("  signal: %d.%.2d dBm",
-                               signal_mbm / 100, signal_mbm % 100);
-       }
-       if (bss[NL80211_BSS_SIGNAL_UNSPEC]) {
-               signal_un = nla_get_u8(bss[NL80211_BSS_SIGNAL_UNSPEC]);
-               MESH_LOGD("  signal: %d/100", signal_un);
-       }
-
-       scan_info = g_try_new0(mesh_scan_result_s, 1);
-       if (NULL == scan_info) {
-               MESH_LOGE("Failed to allocate scan info !");
-               goto FINISH;
-       }
-
-       scan_info->mesh_id = g_memdup(mesh_id, mesh_id_len + 1);
-       scan_info->bssid = g_strdup(mac_addr);
-       scan_info->rssi = (signal_mbm != 0) ? signal_mbm : signal_un;
-       scan_info->channel = __frequency_to_channel(frequency);
-       scan_info->data_rate = 0;
-       *(state->scan_list) = g_list_prepend(*(state->scan_list), scan_info);
-
-       MESH_LOGD("");
-
-FINISH:
-       g_free(mesh_id);
-       return NL_SKIP;
-}
-
-static int _on_receive_station_info(struct nl_msg *msg, void *arg)
+static int _on_receive_station_info(struct nl_msg *msg, void *arg)
 {
        struct nlattr *tb[NL80211_ATTR_MAX + 1];
        struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
@@ -1587,7 +1026,7 @@ static int _on_receive_mpath_info(struct nl_msg *msg, void *arg)
        mesh_mpath_info_s *mpath_info = NULL;
 
        nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
-                 genlmsg_attrlen(gnlh, 0), NULL);
+               genlmsg_attrlen(gnlh, 0), NULL);
 
        /*
         * TODO: validate the interface and mac address!
@@ -1600,8 +1039,8 @@ static int _on_receive_mpath_info(struct nl_msg *msg, void *arg)
                return NL_SKIP;
        }
        if (nla_parse_nested(pinfo, NL80211_MPATH_INFO_MAX,
-                            tb[NL80211_ATTR_MPATH_INFO],
-                            mpath_policy)) {
+                       tb[NL80211_ATTR_MPATH_INFO],
+                       mpath_policy)) {
                MESH_LOGE("failed to parse nested attributes!");
                return NL_SKIP;
        }
@@ -1633,669 +1072,77 @@ static int _on_receive_mpath_info(struct nl_msg *msg, void *arg)
                MESH_LOGD("Metric : %u", mpath_info->metric);
        }
        if (pinfo[NL80211_MPATH_INFO_FRAME_QLEN]) {
-               mpath_info->qlen = nla_get_u32(pinfo[NL80211_MPATH_INFO_FRAME_QLEN]);
-               MESH_LOGD("QLEN : %u", mpath_info->qlen);
-       }
-       if (pinfo[NL80211_MPATH_INFO_EXPTIME]) {
-               mpath_info->exptime = nla_get_u32(pinfo[NL80211_MPATH_INFO_EXPTIME]);
-               MESH_LOGD("ExpTime : %u", mpath_info->exptime);
-       }
-       if (pinfo[NL80211_MPATH_INFO_DISCOVERY_TIMEOUT]) {
-               mpath_info->discovery_timeout =
-                               nla_get_u32(pinfo[NL80211_MPATH_INFO_DISCOVERY_TIMEOUT]);
-               MESH_LOGD("Discovery Timeout : %u", mpath_info->discovery_timeout);
-       }
-       if (pinfo[NL80211_MPATH_INFO_DISCOVERY_RETRIES]) {
-               mpath_info->discovery_retries =
-                               nla_get_u8(pinfo[NL80211_MPATH_INFO_DISCOVERY_RETRIES]);
-               MESH_LOGD("Discovery Retries : %u", mpath_info->discovery_retries);
-       }
-       if (pinfo[NL80211_MPATH_INFO_FLAGS]) {
-               mpath_info->flags = nla_get_u8(pinfo[NL80211_MPATH_INFO_FLAGS]);
-               MESH_LOGD("Flags : 0x%x", mpath_info->flags);
-       }
-
-       MESH_LOGD("");
-       *(state->mpath_list) = g_list_prepend(*(state->mpath_list), mpath_info);
-
-       return NL_SKIP;
-}
-
-static int _on_receive_mesh_event(struct nl_msg *msg, void *arg)
-{
-       struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
-       struct nlattr *tb[NL80211_ATTR_MAX + 1];
-       char ifname[16] = { 0, };
-       char macbuf[6*3];
-
-       NOTUSED(arg);
-
-       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
-                 genlmsg_attrlen(gnlh, 0), NULL);
-
-       if (tb[NL80211_ATTR_IFINDEX]) {
-               if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
-               MESH_LOGD("%s: ", ifname);
-       }
-
-       switch (gnlh->cmd) {
-       case NL80211_CMD_NEW_STATION:
-               mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
-               MESH_LOGD("[%s] new station [%s]", ifname, macbuf);
-               break;
-       case NL80211_CMD_DEL_STATION:
-               mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
-               MESH_LOGD("[%s] del station [%s]", ifname, macbuf);
-               break;
-       case NL80211_CMD_NEW_MPATH:
-               mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
-               MESH_LOGD("[%s] new mpath [%s]", ifname, macbuf);
-
-               mesh_notify_station_joined((const char*)macbuf);
-               break;
-       case NL80211_CMD_DEL_MPATH:
-               mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
-               MESH_LOGD("[%s] del mpath [%s]", ifname, macbuf);
-
-               mesh_notify_station_left((const char*)macbuf);
-               break;
-       default:
-               MESH_LOGD("event [%d] is not handled", gnlh->cmd);
-               break;
-       }
-
-       return NL_SKIP;
-}
-
-static int _send_nl_trigger_full_scan(const char* mesh_if_name)
-{
-       /* Nested message */
-       struct nl_msg *ssids = NULL;
-       mesh_nl_state *state = NULL;
-       int err = MESHD_ERROR_NONE;
-       int device_index = 0;
-       int ret;
-       int test = 0;
-       unsigned char mesh_ie[2];
-       GIOChannel *recv_channel = NULL;
-
-       if (scan_in_progress) {
-               MESH_LOGE("Scan is requested already.");
-               return MESHD_ERROR_IN_PROGRESS;
-       }
-       scan_in_progress = TRUE;
-
-       state = _create_mesh_nl_state(mesh_if_name);
-
-       ret = __initialize_nl80211(state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize nl80211");
-               scan_in_progress = FALSE;
-               return ret;
-       }
-
-       /* Subscribe multicast group should be proceed before scanning */
-       ret = __prepare_listen_events(state);
-       if (ret) {
-               MESH_LOGE("__prepare_listen_events : [%d]", ret);
-               goto DESTROY;
-       }
-
-       ret = __initialize_netlink_message(state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
-       }
-
-       ssids = nlmsg_alloc();
-       if (NULL == ssids) {
-               MESH_LOGE("Failed to allocate ssid");
-               goto DESTROY;
-       }
-
-       /* Set command into message */
-       genlmsg_put(state->msg, 0, 0, state->nl80211_id, 0,
-                   0, NL80211_CMD_TRIGGER_SCAN, 0);
-
-       /* Add attributes into message */
-       ret = __get_device_index_from_string(mesh_if_name, &device_index);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get mesh interface device index");
-               err = ret;
-               goto DESTROY;
-       }
-       NLA_PUT_U32(state->msg, NL80211_ATTR_IFINDEX, device_index);
-
-       /* Scan all SSIDS */
-       NLA_PUT(ssids, 1, 0, "");
-       nla_put_nested(state->msg, NL80211_ATTR_SCAN_SSIDS, ssids);
-
-       /* IMPORTANT: Add mesh_id to get mesh bss properly */
-       mesh_ie[0] = MESH_ELEMENT_ID; /* Mesh element ID */
-       mesh_ie[1] = 0;
-       NLA_PUT(state->msg, NL80211_ATTR_IE, 2, mesh_ie);
-
-       /* Set callbacks for scan */
-       nl_cb_set(state->cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, state);
-       nl_cb_err(state->cb, NL_CB_CUSTOM, error_handler, state);
-       nl_cb_set(state->cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, state);
-       nl_cb_set(state->cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, state);
-       nl_cb_set(state->cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);  // No sequence checking for multicast messages.
-
-       /* Send message into kernel */
-       ret = nl_send_auto(state->nl_socket, state->msg);
-       if (ret < 0) {
-               MESH_LOGE("Failed to nl_send_auto() [%s](%d)", nl_geterror(ret), ret);
-               err = MESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
-       }
-
-       /* Wait for ACK */
-       state->callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state->callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state->nl_socket, state->cb);
-       }
-
-       /* Register I/O callback to wait asynchronously */
-       if (FALSE == state->error_occured) {
-               recv_channel = g_io_channel_unix_new(nl_socket_get_fd(state->nl_socket));
-               state->event_source = g_io_add_watch(recv_channel,
-                               (G_IO_IN | G_IO_ERR), _on_socket_io_received, state);
-               g_io_channel_unref(recv_channel);
-       } else {
-               MESH_LOGE("Error responded. do not wait for scan done event");
-               goto DESTROY;
-       }
-
-       if (ssids)
-               nlmsg_free(ssids);
-
-       /* Resource should be free on I/O callback */
-       return MESHD_ERROR_NONE;
-
-nla_put_failure:
-       MESH_LOGE("Failed to message build");
-       err = MESHD_ERROR_OPERATION_FAILED;
-
-DESTROY:
-       if (ssids)
-               nlmsg_free(ssids);
-       __clean_netlink_message(state);
-       __clean_nl80211(state);
-       _delete_mesh_nl_state(&state);
-
-       scan_in_progress = FALSE;
-
-       return err;
-}
-
-static int _send_nl_get_scan_result(const char* if_name, GList **scan_list)
-{
-       mesh_nl_state state = {
-               .nl80211_id = -1,
-               .callback_state = MESH_NL_CALLBACK_TRYING,
-               .event_source = 0,
-               .nl_socket = NULL,
-               .msg = NULL,
-               .cb = NULL,
-               .s_cb = NULL,
-               .scanning_interface = (char*)if_name,
-               .scan_list = scan_list
-       };
-       int err = MESHD_ERROR_NONE;
-       int device_index = 0;
-       int ret;
-       int test = 0;
-
-       ret = __initialize_nl80211(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize nl80211");
-               return ret;
-       }
-
-       ret = __initialize_netlink_message(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
-       }
-
-       /* Set command into message */
-       genlmsg_put(state.msg, 0, 0, state.nl80211_id, 0,
-                   NLM_F_DUMP, NL80211_CMD_GET_SCAN, 0);
-
-       /* Add attributes into message */
-       MESH_LOGD("Dump scan result with interface [%s]", if_name);
-       ret = __get_device_index_from_string(if_name, &device_index);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get mesh interface device index");
-               err = ret;
-               goto DESTROY;
-       }
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
-
-       /* Register valid callback to dump result */
-       nl_cb_set(state.cb, NL_CB_VALID, NL_CB_CUSTOM,
-                       _on_receive_bss_information, &state);
-
-       /* Send message into kernel */
-       ret = nl_send_auto(state.nl_socket, state.msg);
-       if (ret < 0) {
-               MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
-                               nl_geterror(ret), ret);
-               err = MESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
-       }
-
-       /* sync response */
-       state.callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state.nl_socket, state.cb);
-       }
-       MESH_LOGD("Finished");
-
-DESTROY:
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return err;
-
-nla_put_failure:
-       MESH_LOGE("Failed to message build");
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return MESHD_ERROR_OPERATION_FAILED;
-}
-
-static int _send_nl_trigger_specific_scan(const char* mesh_if_name,
-               const char* mesh_id, int mesh_channel)
-{
-       /* Nested message */
-       struct nl_msg *ssids = NULL, *freqs = NULL;
-       enum nl80211_band band;
-       mesh_nl_state *state = NULL;
-       int err = MESHD_ERROR_NONE;
-       int device_index = 0;
-       int ret;
-       int i = 1;
-       int test = 0;
-       unsigned int freq = 0;
-       unsigned char *mesh_ie = NULL;
-       size_t mesh_id_len = 0;
-       GIOChannel *recv_channel = NULL;
-
-       if (scan_in_progress) {
-               MESH_LOGE("Scan is requested already.");
-               return MESHD_ERROR_IN_PROGRESS;
-       }
-       scan_in_progress = TRUE;
-
-       state = _create_mesh_nl_state(mesh_if_name);
-
-       ret = __initialize_nl80211(state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize nl80211");
-               scan_in_progress = FALSE;
-               return ret;
-       }
-
-       /* Subscribe multicast group should be proceed before scanning */
-       ret = __prepare_listen_events(state);
-       if (ret) {
-               MESH_LOGE("__prepare_listen_events : [%d]", ret);
-               goto DESTROY;
-       }
-
-       ret = __initialize_netlink_message(state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
-       }
-
-       if (mesh_id) {
-               ssids = nlmsg_alloc();
-               if (NULL == ssids) {
-                       MESH_LOGE("Failed to allocate ssid");
-                       goto DESTROY;
-               }
-       }
-
-       freqs = nlmsg_alloc();
-       if (NULL == freqs) {
-
-               MESH_LOGE("Failed to allocate frequency");
-               goto DESTROY;
-       }
-
-       /* Set command into message */
-       genlmsg_put(state->msg, 0, 0, state->nl80211_id, 0,
-                   0, NL80211_CMD_TRIGGER_SCAN, 0);
-
-       /* Add attributes into message */
-       ret = __get_device_index_from_string(mesh_if_name, &device_index);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get mesh interface device index");
-               err = ret;
-               goto DESTROY;
-       }
-       NLA_PUT_U32(state->msg, NL80211_ATTR_IFINDEX, device_index);
-
-       /* Set frequency to scan */
-       band = (mesh_channel <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
-       freq = __channel_to_frequency(mesh_channel, band);
-       NLA_PUT_U32(freqs, i, freq);
-
-       /* Set default SSID to scan */
-       NLA_PUT(ssids, 1, 0, "");
-
-       /* Set frequency and SSID into message */
-       nla_put_nested(state->msg, NL80211_ATTR_SCAN_FREQUENCIES, freqs);
-       nla_put_nested(state->msg, NL80211_ATTR_SCAN_SSIDS, ssids);
-
-       /* IMPORTANT: Set mesh_id to find */
-       mesh_id_len = strlen(mesh_id);
-       mesh_ie = g_try_malloc0(2 + mesh_id_len);
-       if (NULL == mesh_ie) {
-               err = MESHD_ERROR_OUT_OF_MEMORY;
-               goto DESTROY;
-       }
-       mesh_ie[0] = MESH_ELEMENT_ID; /* Mesh element ID */
-       mesh_ie[1] = mesh_id_len;
-       memcpy(&mesh_ie[2], mesh_id, mesh_id_len);
-       NLA_PUT(state->msg, NL80211_ATTR_IE, 2 + mesh_id_len, mesh_ie);
-
-       /* Set callbacks for scan */
-       nl_cb_set(state->cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, state);
-       nl_cb_err(state->cb, NL_CB_CUSTOM, error_handler, state);
-       nl_cb_set(state->cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, state);
-       nl_cb_set(state->cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, state);
-       nl_cb_set(state->cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);  // No sequence checking for multicast messages.
-
-       /* Send message into kernel */
-       ret = nl_send_auto(state->nl_socket, state->msg);
-       if (ret < 0) {
-               MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
-                               nl_geterror(ret), ret);
-               err = MESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
-       }
-
-       /* Wait for ACK */
-       state->callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state->callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state->nl_socket, state->cb);
-       }
-
-       /* Register I/O callback to wait asynchronously */
-       if (FALSE == state->error_occured) {
-               recv_channel = g_io_channel_unix_new(nl_socket_get_fd(state->nl_socket));
-               state->event_source = g_io_add_watch(recv_channel,
-                               (G_IO_IN | G_IO_ERR), _on_socket_io_received, state);
-               g_io_channel_unref(recv_channel);
-       } else {
-               MESH_LOGE("Error responded. do not wait for scan done event");
-               goto DESTROY;
-       }
-
-       if (ssids)
-               nlmsg_free(ssids);
-       if (freqs)
-               nlmsg_free(freqs);
-
-       /* Resource should be free on I/O callback */
-       return MESHD_ERROR_NONE;
-
-nla_put_failure:
-       MESH_LOGE("Failed to message build");
-       err = MESHD_ERROR_OPERATION_FAILED;
-
-DESTROY:
-       if (ssids)
-               nlmsg_free(ssids);
-       if (freqs)
-               nlmsg_free(freqs);
-       __clean_netlink_message(state);
-       __clean_nl80211(state);
-       _delete_mesh_nl_state(&state);
-
-       scan_in_progress = FALSE;
-
-       return err;
-}
-
-static int _send_nl_abort_scan(const char* mesh_if_name)
-{
-       mesh_nl_state state = {
-               .nl80211_id = -1,
-               .callback_state = MESH_NL_CALLBACK_TRYING,
-               .event_source = 0,
-               .nl_socket = NULL,
-               .msg = NULL,
-               .cb = NULL,
-               .s_cb = NULL,
-               .scanning_interface = NULL,
-               .error_occured = FALSE,
-       };
-       int err = MESHD_ERROR_NONE;
-       int device_index = 0;
-       int ret;
-       int test = 0;
-
-       ret = __initialize_nl80211(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize nl80211");
-               return ret;
-       }
-
-       ret = __initialize_netlink_message(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
-       }
-
-       /* Set command into message */
-       genlmsg_put(state.msg, 0, 0, state.nl80211_id, 0,
-                   0, NL80211_CMD_ABORT_SCAN, 0);
-
-       /* Add attributes into message */
-       ret = __get_device_index_from_string(mesh_if_name, &device_index);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get mesh interface device index");
-               err = ret;
-               goto DESTROY;
-       }
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
-
-       /* Send message into kernel */
-       ret = nl_send_auto(state.nl_socket, state.msg);
-       if (ret < 0) {
-               MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
-                               nl_geterror(ret), ret);
-               err = MESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
-       }
-
-       /* sync response */
-       state.callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state.nl_socket, state.cb);
-       }
-
-DESTROY:
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return err;
-
-nla_put_failure:
-       MESH_LOGE("Failed to message build");
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return MESHD_ERROR_OPERATION_FAILED;
-}
-
-static int _send_nl_set_mesh_channel(const char* mesh_if_name, int channel)
-{
-       mesh_nl_state state = {
-               .nl80211_id = -1,
-               .callback_state = MESH_NL_CALLBACK_TRYING,
-               .event_source = 0,
-               .nl_socket = NULL,
-               .msg = NULL,
-               .cb = NULL,
-               .s_cb = NULL,
-               .scanning_interface = NULL,
-               .error_occured = FALSE,
-       };
-       enum nl80211_band band;
-
-       int err = MESHD_ERROR_NONE;
-       int device_index = 0;
-       unsigned int freq = 0;
-       int ret;
-       int test = 0;
-
-       ret = __initialize_nl80211(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize nl80211");
-               return ret;
-       }
-
-       ret = __initialize_netlink_message(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
-       }
-
-       /* Set command into message */
-       genlmsg_put(state.msg, 0, 0, state.nl80211_id, 0,
-                   0, NL80211_CMD_SET_WIPHY, 0);
-
-       /* Add attributes into message */
-       ret = __get_device_index_from_string(mesh_if_name, &device_index);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get mesh device index");
-               err = ret;
-               goto DESTROY;
+               mpath_info->qlen = nla_get_u32(pinfo[NL80211_MPATH_INFO_FRAME_QLEN]);
+               MESH_LOGD("QLEN : %u", mpath_info->qlen);
        }
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
-
-       band = (channel <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
-       freq = __channel_to_frequency(channel, band);
-       MESH_LOGD("Setting frequency [%d]", freq);
-       NLA_PUT_U32(state.msg, NL80211_ATTR_WIPHY_FREQ, freq);
-
-       /* NO HT */
-       NLA_PUT_U32(state.msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_NO_HT);
-
-       /* Send message into kernel */
-       ret = nl_send_auto(state.nl_socket, state.msg);
-       if (ret < 0) {
-               MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
-                               nl_geterror(ret), ret);
-               err = MESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
+       if (pinfo[NL80211_MPATH_INFO_EXPTIME]) {
+               mpath_info->exptime = nla_get_u32(pinfo[NL80211_MPATH_INFO_EXPTIME]);
+               MESH_LOGD("ExpTime : %u", mpath_info->exptime);
        }
-
-       /* sync response */
-       state.callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state.nl_socket, state.cb);
+       if (pinfo[NL80211_MPATH_INFO_DISCOVERY_TIMEOUT]) {
+               mpath_info->discovery_timeout =
+                               nla_get_u32(pinfo[NL80211_MPATH_INFO_DISCOVERY_TIMEOUT]);
+               MESH_LOGD("Discovery Timeout : %u", mpath_info->discovery_timeout);
+       }
+       if (pinfo[NL80211_MPATH_INFO_DISCOVERY_RETRIES]) {
+               mpath_info->discovery_retries =
+                               nla_get_u8(pinfo[NL80211_MPATH_INFO_DISCOVERY_RETRIES]);
+               MESH_LOGD("Discovery Retries : %u", mpath_info->discovery_retries);
+       }
+       if (pinfo[NL80211_MPATH_INFO_FLAGS]) {
+               mpath_info->flags = nla_get_u8(pinfo[NL80211_MPATH_INFO_FLAGS]);
+               MESH_LOGD("Flags : 0x%x", mpath_info->flags);
        }
 
-DESTROY:
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return err;
-
-nla_put_failure:
-       MESH_LOGE("Failed to message build");
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
+       MESH_LOGD("");
+       *(state->mpath_list) = g_list_prepend(*(state->mpath_list), mpath_info);
 
-       return MESHD_ERROR_OPERATION_FAILED;
+       return NL_SKIP;
 }
 
-static int _send_nl_join_mesh(const char* mesh_if_name, const char* mesh_id)
+static int _on_receive_mesh_event(struct nl_msg *msg, void *arg)
 {
-       mesh_nl_state state = {
-               .nl80211_id = -1,
-               .callback_state = MESH_NL_CALLBACK_TRYING,
-               .event_source = 0,
-               .nl_socket = NULL,
-               .msg = NULL,
-               .cb = NULL,
-               .s_cb = NULL,
-               .scanning_interface = NULL,
-               .error_occured = FALSE,
-       };
-       int err = MESHD_ERROR_NONE;
-       int device_index = 0;
-       int ret;
-       int test = 0;
-
-       ret = __initialize_nl80211(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize nl80211");
-               return ret;
-       }
+       struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+       struct nlattr *tb[NL80211_ATTR_MAX + 1];
+       char ifname[16] = { 0, };
+       char macbuf[6*3];
 
-       ret = __initialize_netlink_message(&state);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
-       }
+       NOTUSED(arg);
 
-       /* Set command into message */
-       genlmsg_put(state.msg, 0, 0, state.nl80211_id, 0,
-                   0, NL80211_CMD_JOIN_MESH, 0);
+       nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL);
 
-       /* Add attributes into message */
-       ret = __get_device_index_from_string(mesh_if_name, &device_index);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get mesh device index");
-               err = ret;
-               goto DESTROY;
+       if (tb[NL80211_ATTR_IFINDEX]) {
+               if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
+               MESH_LOGD("%s: ", ifname);
        }
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
 
-       NLA_PUT(state.msg, NL80211_ATTR_MESH_ID, strlen(mesh_id), mesh_id);
+       switch (gnlh->cmd) {
+       case NL80211_CMD_NEW_STATION:
+               mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
+               MESH_LOGD("[%s] new station [%s]", ifname, macbuf);
+               break;
+       case NL80211_CMD_DEL_STATION:
+               mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
+               MESH_LOGD("[%s] del station [%s]", ifname, macbuf);
+               break;
+       case NL80211_CMD_NEW_MPATH:
+               mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
+               MESH_LOGD("[%s] new mpath [%s]", ifname, macbuf);
 
-       /* Send message into kernel */
-       ret = nl_send_auto(state.nl_socket, state.msg);
-       if (ret < 0) {
-               MESH_LOGE("Failed to nl_send_auto() [%s](%d)",
-                               nl_geterror(ret), ret);
-               err = MESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
-       }
+               mesh_notify_station_joined((const char*)macbuf);
+               break;
+       case NL80211_CMD_DEL_MPATH:
+               mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
+               MESH_LOGD("[%s] del mpath [%s]", ifname, macbuf);
 
-       /* sync response */
-       state.callback_state = MESH_NL_CALLBACK_TRYING;
-       while (state.callback_state == MESH_NL_CALLBACK_TRYING) {
-               MESH_LOGD("  count [%02d]", ++test);
-               nl_recvmsgs(state.nl_socket, state.cb);
+               mesh_notify_station_left((const char*)macbuf);
+               break;
+       default:
+               MESH_LOGD("event [%d] is not handled", gnlh->cmd);
+               break;
        }
 
-DESTROY:
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return err;
-
-nla_put_failure:
-       MESH_LOGE("Failed to message build");
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return MESHD_ERROR_OPERATION_FAILED;
+       return NL_SKIP;
 }
 
 static int _send_nl_set_mesh_parameter(const char* mesh_if_name,
@@ -2309,7 +1156,6 @@ static int _send_nl_set_mesh_parameter(const char* mesh_if_name,
                .msg = NULL,
                .cb = NULL,
                .s_cb = NULL,
-               .scanning_interface = NULL,
                .error_occured = FALSE,
        };
        struct nlattr *container;
@@ -2406,7 +1252,6 @@ static int _send_nl_get_station_info(const char* if_name, GList **station_list)
                .msg = NULL,
                .cb = NULL,
                .s_cb = NULL,
-               .scanning_interface = (char*)if_name,
                .station_list = station_list
        };
        int err = MESHD_ERROR_NONE;
@@ -2485,7 +1330,6 @@ static int _send_nl_del_station_info(const char* if_name, char* peer)
                .msg = NULL,
                .cb = NULL,
                .s_cb = NULL,
-               .scanning_interface = (char*)if_name,
                .station_list = NULL,
        };
        int err = MESHD_ERROR_NONE;
@@ -2552,7 +1396,6 @@ static int _send_nl_get_mpath_info(const char* if_name, GList **mpath_list)
                .msg = NULL,
                .cb = NULL,
                .s_cb = NULL,
-               .scanning_interface = (char*)if_name,
                .mpath_list = mpath_list
        };
        int err = MESHD_ERROR_NONE;
@@ -2637,7 +1480,6 @@ static int _send_nl_register_event_handler()
        ret = __initialize_nl80211(event_state);
        if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to initialize nl80211");
-               scan_in_progress = FALSE;
                return ret;
        }
 
@@ -2693,168 +1535,6 @@ DESTROY:
        return err;
 }
 
-int mesh_netlink_set_type_managed(const char* if_name)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == if_name || strlen(if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("set interface [%s] managed type", if_name);
-       ret = _send_nl_set_type_managed(if_name);
-
-       return ret;
-}
-
-int mesh_netlink_create_mesh_interface(const char* base_if_name,
-               const char* mesh_if_name, const char* mesh_id)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == base_if_name || strlen(base_if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", base_if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-       if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-       if (NULL == mesh_id || strlen(mesh_id) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_id);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Create mesh interface [%s] base on [%s] / Mesh ID [%s]",
-                       mesh_if_name, base_if_name, mesh_id);
-       ret = _send_nl_create_mesh_interface(base_if_name, mesh_if_name, mesh_id);
-
-       return ret;
-}
-
-int mesh_netlink_delete_mesh_interface(const char* mesh_if_name)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Delete mesh interface [%s]", mesh_if_name);
-       ret = _send_nl_delete_mesh_interface(mesh_if_name);
-
-       return ret;
-}
-
-int mesh_netlink_set_mesh_channel(const char* mesh_if_name, int channel)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Set mesh interface [%s] channel [%d]",
-                       mesh_if_name, channel);
-       ret = _send_nl_set_mesh_channel(mesh_if_name, channel);
-
-       return ret;
-}
-
-int mesh_netlink_join_mesh(const char* mesh_if_name, const char* mesh_id)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-       if (NULL == mesh_id || strlen(mesh_id) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_id);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Join into mesh ID [%s]", mesh_if_name);
-       ret = _send_nl_join_mesh(mesh_if_name, mesh_id);
-
-       return ret;
-}
-
-int mesh_netlink_trigger_full_scan(const char* mesh_if_name)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Scan mesh[%s]", mesh_if_name);
-       ret = _send_nl_trigger_full_scan(mesh_if_name);
-
-       return ret;
-}
-
-int mesh_netlink_trigger_specific_scan(const char* mesh_if_name,
-               const char* mesh_id, int channel)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Scan mesh[%s] id [%s] channel [%d]",
-                       mesh_if_name, mesh_id, channel);
-       ret = _send_nl_trigger_specific_scan(mesh_if_name, mesh_id, channel);
-
-       return ret;
-}
-
-int mesh_netlink_cancel_scan(const char* mesh_if_name)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Cancel scan on [%s]", mesh_if_name);
-       ret = _send_nl_abort_scan(mesh_if_name);
-
-       return ret;
-}
-
-int mesh_netlink_get_scan_result(const char* mesh_if_name, GList **scan_list)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
-               MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-       if (NULL == scan_list) {
-               MESH_LOGE("Invalid parameter [%p]", scan_list);
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Get scan result on [%s]", mesh_if_name);
-       ret = _send_nl_get_scan_result(mesh_if_name, scan_list);
-
-       /* List item is saved with reversed order for efficiency. */
-       *scan_list = g_list_reverse(*scan_list);
-
-       /* Enter to scan idle state */
-       scan_in_progress = FALSE;
-
-       return ret;
-}
-
 int mesh_netlink_set_mesh_parameter(const char* mesh_if_name,
                const char* param_name, unsigned int value)
 {
@@ -2894,7 +1574,6 @@ int mesh_netlink_get_station_info(const char* mesh_if_name, GList **station_list
 int mesh_netlink_del_station_info(const char* mesh_if_name, char *peer)
 {
        int ret = MESHD_ERROR_NONE;
-       //unsigned char peer_mac[ETH_ALEN] = {0,};
 
        if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
                MESH_LOGE("Invalid parameter [%p]", mesh_if_name);
diff --git a/src/mesh-network.c b/src/mesh-network.c
deleted file mode 100644 (file)
index c63e1a5..0000000
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Network Configuration Module
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <glib.h>
-#include <tzplatform_config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#include "mesh.h"
-#include "mesh-log.h"
-#include "mesh-util.h"
-#include "mesh-service.h"
-#include "mesh-network.h"
-
-#define MESH_NETWORK_LIST_FILE_PATH    tzplatform_mkpath(TZ_SYS_VAR, "/lib/mesh/mesh_network.conf")
-
-static void _list_destroy_notify(gpointer data)
-{
-       mesh_network_info_s *info = (mesh_network_info_s*)data;
-
-       if (info) {
-               g_free(info->mesh_id);
-               g_free(info);
-       }
-}
-
-static void _save_current_list_into_storage(GList *saved_network)
-{
-       GKeyFile* storage = NULL;
-       gboolean res = FALSE;
-       GError* error = NULL;
-       mesh_network_info_s *info = NULL;
-
-       GList *iter = NULL;
-       char str_group[16];
-       int group_index = 1;
-
-       storage = g_key_file_new();
-
-       /* Insert list item into storage list */
-       iter = saved_network;
-       while (iter != NULL) {
-               info = (mesh_network_info_s*)iter->data;
-
-               /* Generate item group */
-               snprintf(str_group, 16, "Item%d", group_index++);
-               g_key_file_set_string(storage, str_group, "mesh_id", info->mesh_id);
-               g_key_file_set_integer(storage, str_group, "channel", info->channel);
-               g_key_file_set_integer(storage, str_group, "security", info->security);
-
-               iter = g_list_next(iter);
-       }
-
-       MESH_LOGD("Saving network information list into storage..");
-       res = g_key_file_save_to_file(storage, MESH_NETWORK_LIST_FILE_PATH, &error);
-       if (FALSE == res) {
-               MESH_LOGE("Failed to save mesh network list into storage !");
-               MESH_LOGE("    [%s]", error->message);
-               g_error_free(error);
-       }
-
-       g_key_file_free(storage);
-}
-
-int mesh_network_load_mesh_network(GList **saved_network)
-{
-       GKeyFile* storage;
-       gboolean res = FALSE;
-       GError* error = NULL;
-
-       gsize list_count = 0;
-       gchar** group_list = NULL;
-       mesh_network_info_s *info = NULL;
-       char *mesh_id = NULL;
-       int mesh_channel;
-       int security;
-
-       gsize idx = 0;
-
-       /* Check if stored file exists */
-       res = g_file_test(MESH_NETWORK_LIST_FILE_PATH, G_FILE_TEST_EXISTS);
-       if (FALSE == res) {
-               MESH_LOGD("There is no saved networks on storage");
-               return MESHD_ERROR_NONE;
-       }
-
-       /* Get stored contents */
-       storage = g_key_file_new();
-       res = g_key_file_load_from_file(storage, MESH_NETWORK_LIST_FILE_PATH,
-                               G_KEY_FILE_NONE, &error);
-       if (FALSE == res) {
-               MESH_LOGE("Failed to get saved network list from storage !");
-               g_key_file_free(storage);
-               return MESHD_ERROR_IO_ERROR;
-       }
-
-       group_list = g_key_file_get_groups(storage, &list_count);
-       if (group_list) {
-               for(idx = 0; idx < list_count ; idx++) {
-                       mesh_id = g_key_file_get_string(storage, group_list[idx],
-                                               "mesh_id", NULL);
-                       mesh_channel = g_key_file_get_integer(storage, group_list[idx],
-                                               "channel", NULL);
-                       security = g_key_file_get_integer(storage, group_list[idx],
-                                               "security", NULL);
-
-                       MESH_LOGD("=========[%d / %d]==========", idx, list_count);
-                       MESH_LOGD("[%s] : ", group_list[idx]);
-                       MESH_LOGD("    mesh_id  : [%s]", mesh_id);
-                       MESH_LOGD("    channel  : [%d]", mesh_channel);
-                       MESH_LOGD("    security : [%d]", security);
-
-                       info = g_try_new0(mesh_network_info_s, 1);
-                       if (NULL == info) {
-                               MESH_LOGE("Failed to allocate memory !");
-                               g_key_file_free(storage);
-                               g_strfreev(group_list);
-                               return MESHD_ERROR_OUT_OF_MEMORY;
-                       }
-                       info->mesh_id = mesh_id;
-                       info->bssid = NULL;
-                       info->channel = mesh_channel;
-                       info->security = security;
-
-                       *saved_network = g_list_prepend(*saved_network, info);
-               }
-               /* Reverse list order to place higher priority sequence */
-               *saved_network = g_list_reverse(*saved_network);
-
-               g_strfreev(group_list);
-       } else {
-               MESH_LOGE("File exists but there is no data");
-               g_key_file_free(storage);
-               return MESHD_ERROR_NO_DATA;
-       }
-
-       g_key_file_free(storage);
-
-       return MESHD_ERROR_NONE;
-}
-
-int mesh_network_add_mesh_network(GList **saved_network, const char *mesh_id,
-               int mesh_channel, int security)
-{
-       int ret = MESHD_ERROR_NONE;
-       mesh_network_info_s *info = NULL;
-       GList *iter = NULL;
-       gboolean found = FALSE;
-       meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
-
-       meshd_check_null_ret_error("saved_network", saved_network,
-                       MESHD_ERROR_INVALID_PARAMETER);
-
-       iter = *saved_network;
-       while (iter != NULL) {
-               info = (mesh_network_info_s*)iter->data;
-
-               if (g_strcmp0(mesh_id, info->mesh_id) == 0) {
-                       if (info->channel == mesh_channel && info->security == sec)
-                       {
-                               found = TRUE;
-                               break;
-                       }
-               }
-               iter = g_list_next(iter);
-       }
-
-       if (found) {
-               MESH_LOGD("Already exists");
-               return MESHD_ERROR_NONE;
-       }
-
-       info = g_try_new0(mesh_network_info_s, 1);
-       if (NULL == info) {
-               MESH_LOGE("Failed to allocate memory !");
-               return MESHD_ERROR_OUT_OF_MEMORY;
-       }
-       info->mesh_id = g_strdup(mesh_id);
-       info->bssid = NULL;
-       info->channel = mesh_channel;
-       info->security = security;
-
-       *saved_network = g_list_prepend(*saved_network, info);
-
-       _save_current_list_into_storage(*saved_network);
-
-       return ret;
-}
-
-int mesh_network_get_saved_mesh_network(GList **saved_network)
-{
-       int ret = MESHD_ERROR_NONE;
-       GList *iter = NULL;
-       mesh_network_info_s *info = NULL;
-       int index = 1;
-
-       meshd_check_null_ret_error("saved_network", saved_network,
-                       MESHD_ERROR_INVALID_PARAMETER);
-
-       iter = *saved_network;
-       while (iter != NULL) {
-               info = (mesh_network_info_s*)iter->data;
-
-               MESH_LOGD("[%d] item :", index);
-               MESH_LOGD("   Mesh ID : [%s]", info->mesh_id);
-               MESH_LOGD("   channel : [%d]", info->channel);
-               MESH_LOGD("  security : [%d]", info->security);
-               MESH_LOGD("");
-
-               index++;
-               iter = g_list_next(iter);
-       }
-
-       return ret;
-}
-
-int mesh_network_get_first_mesh_network(GList *saved_network,
-               mesh_network_info_s *info)
-{
-       int ret = MESHD_ERROR_NO_DATA;
-       GList *iter = NULL;
-       int index = 1;
-       mesh_network_info_s *found;
-
-       meshd_check_null_ret_error("saved_network", saved_network,
-                       MESHD_ERROR_INVALID_PARAMETER);
-       meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
-
-       iter = saved_network;
-       while (iter != NULL) {
-               found = (mesh_network_info_s*)iter->data;
-
-               info->mesh_id = found->mesh_id;
-               info->bssid = NULL;
-               info->channel = found->channel;
-               info->security = found->security;
-
-               MESH_LOGD("[%d] item :", index);
-               MESH_LOGD("   Mesh ID : [%s]", info->mesh_id);
-               MESH_LOGD("   channel : [%d]", info->channel);
-               MESH_LOGD("  security : [%d]", info->security);
-               MESH_LOGD("");
-
-               ret = MESHD_ERROR_NONE;
-               break;
-       }
-
-       return ret;
-}
-
-int mesh_network_select_saved_mesh_network(GList **saved_network,
-               const char *mesh_id, int mesh_channel, int security)
-{
-       int ret = MESHD_ERROR_NONE;
-       GList *iter = NULL;
-       mesh_network_info_s *info = NULL;
-       mesh_network_info_s *moved = NULL;
-       gboolean found = FALSE;
-       meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
-
-       meshd_check_null_ret_error("saved_network", saved_network,
-                       MESHD_ERROR_INVALID_PARAMETER);
-
-       iter = *saved_network;
-       while (iter != NULL) {
-               info = (mesh_network_info_s*)iter->data;
-
-               if (g_strcmp0(mesh_id, info->mesh_id) == 0) {
-                       if (info->channel == mesh_channel && info->security == sec)
-                       {
-                               moved = g_try_new0(mesh_network_info_s, 1);
-                               if (NULL == moved) {
-                                       MESH_LOGE("Failed to allocate memory !");
-                                       return MESHD_ERROR_OUT_OF_MEMORY;
-                               }
-                               moved->mesh_id = g_strdup(info->mesh_id);
-                               moved->bssid = NULL;
-                               moved->channel = info->channel;
-                               moved->security = info->security;
-                               found = TRUE;
-                               break;
-                       }
-               }
-               iter = g_list_next(iter);
-       }
-
-       if (found) {
-               *saved_network = g_list_remove_link(*saved_network, iter);
-               g_list_free_full(iter, _list_destroy_notify);
-               *saved_network = g_list_prepend(*saved_network, moved);
-       } else {
-               MESH_LOGE("Not found from saved list");
-               ret = MESHD_ERROR_NO_DATA;
-       }
-
-       _save_current_list_into_storage(*saved_network);
-
-       return ret;
-}
-
-int mesh_network_forget_saved_mesh_network(GList **saved_network,
-               const char *mesh_id, int mesh_channel, int security)
-{
-       int ret = MESHD_ERROR_NONE;
-       GList *iter = NULL;
-       mesh_network_info_s *info = NULL;
-       gboolean found = FALSE;
-       meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
-
-       meshd_check_null_ret_error("saved_network", saved_network,
-                       MESHD_ERROR_INVALID_PARAMETER);
-
-       iter = *saved_network;
-       while (iter != NULL) {
-               info = (mesh_network_info_s*)iter->data;
-
-               if (g_strcmp0(mesh_id, info->mesh_id) == 0) {
-                       if (info->channel == mesh_channel && info->security == sec)
-                       {
-                               found = TRUE;
-                               break;
-                       }
-               }
-               iter = g_list_next(iter);
-       }
-
-       if (found) {
-               *saved_network = g_list_remove_link(*saved_network, iter);
-               g_list_free_full(iter, _list_destroy_notify);
-       } else {
-               MESH_LOGE("Not found from saved list");
-               ret = MESHD_ERROR_NO_DATA;
-       }
-
-       _save_current_list_into_storage(*saved_network);
-
-       return ret;
-}
-
-int mesh_network_clear_saved_mesh_network(GList **saved_network)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       meshd_check_null_ret_error("saved_network", saved_network,
-                       MESHD_ERROR_INVALID_PARAMETER);
-
-       g_list_free_full(*saved_network, _list_destroy_notify);
-       *saved_network = NULL;
-
-       return ret;
-}
index a835b9a..531d771 100644 (file)
 #include "mesh-bridge.h"
 #include "mesh-netlink.h"
 #include "mesh-interface.h"
-#include "mesh-dhcp.h"
 #include "mesh-request.h"
-#include "mesh-network.h"
 #include "mesh-softap.h"
 #include "mesh-gdbus.h"
 
-static void _on_dhcp_finished(const char* interface, const char* ip_address,
-               void *user_data)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       NOTUSED(user_data);
-       MESH_LOGD("[%s] IP address [%s] obtained.", interface, ip_address);
-
-       /* Just set IP address with given interface */
-       ret = mesh_interface_set(interface, ip_address, MESH_INTERFACE_DO_NOTHING);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to set IP address into interface");
-       }
-}
-
-int mesh_request_dhcp(const char* interface)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == interface) {
-               MESH_LOGE("Invalid parameter");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Request DHCP */
-       ret = mesh_dhcp_request(interface, _on_dhcp_finished, NULL);
-
-       return ret;
-}
-
-int mesh_request_stop_dhcp()
-{
-       int ret = MESHD_ERROR_NONE;
-
-       /* Terminate DHCP */
-       ret = mesh_dhcp_stop_request();
-
-       return ret;
-}
-
-int mesh_request_scan(const char* interface)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == interface) {
-               MESH_LOGE("Invalid parameters");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Set interface up state */
-       ret = mesh_interface_set(interface, NULL, MESH_INTERFACE_UP);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_interface_set");
-               return ret;
-       }
-
-       /* Request full scan */
-       ret = mesh_netlink_trigger_full_scan(interface);
-
-       return ret;
-}
-
-int mesh_request_specific_scan(const char* interface, const char* mesh_id,
-               int mesh_channel)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == interface || NULL == mesh_id) {
-               MESH_LOGE("Invalid parameters");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Set interface up state */
-       ret = mesh_interface_set(interface, NULL, MESH_INTERFACE_UP);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_interface_set");
-               return ret;
-       }
-
-       /* Request trigger scan */
-       ret = mesh_netlink_trigger_specific_scan(interface,
-                       mesh_id, mesh_channel);
-
-       return ret;
-}
-
-int mesh_request_cancel_scan(const char* interface)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == interface) {
-               MESH_LOGE("Invalid parameter");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Request cancel scan */
-       ret = mesh_netlink_cancel_scan(interface);
-
-       return ret;
-}
-
-int mesh_request_get_scan_result(const char* interface, GList **scan_list)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == interface) {
-               MESH_LOGE("Invalid parameter");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Request cancel scan */
-       ret = mesh_netlink_get_scan_result(interface, scan_list);
-
-       return ret;
-}
-
-int mesh_request_disable_mesh(const char* mesh_interface)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_interface) {
-               MESH_LOGE("Invalid parameter");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Request trigger scan */
-       ret = mesh_netlink_delete_mesh_interface(mesh_interface);
-
-       return MESHD_ERROR_NONE;
-}
-
-int mesh_request_enable_mesh(const char* base_interface,
-               const char* mesh_interface, GList *saved_network,
-               mesh_network_info_s **joined_network)
-{
-       int ret = MESHD_ERROR_NONE;
-       mesh_network_info_s info;
-
-       if (NULL == base_interface || NULL == mesh_interface) {
-               MESH_LOGE("Invalid interface name");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Get mesh_id and channel from saved network */
-       ret = mesh_network_get_first_mesh_network(saved_network, &info);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_network_get_first_mesh_network");
-               return ret;
-       }
-
-       /* Add virtual interface */
-       ret = mesh_netlink_set_type_managed(base_interface);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_netlink_set_type_managed");
-               return ret;
-       }
-
-       ret = mesh_interface_set(base_interface, NULL, MESH_INTERFACE_UP);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_interface_set");
-               return ret;
-       }
-
-       /* Create new mesh interface */
-       ret = mesh_netlink_create_mesh_interface(base_interface, mesh_interface,
-                               info.mesh_id);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_netlink_add_mesh_interface");
-               return ret;
-       }
-
-       /* Set mesh channel */
-       ret = mesh_netlink_set_mesh_channel(mesh_interface, info.channel);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_netlink_set_mesh_channel");
-               return ret;
-       }
-
-       /* Make base interface down */
-       ret = mesh_interface_set(base_interface, NULL, MESH_INTERFACE_DOWN);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to change base interface state");
-               return ret;
-       }
-
-       /* Make mesh interface up */
-       ret = mesh_interface_set(mesh_interface, NULL, MESH_INTERFACE_UP);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to change mesh interface state");
-               return ret;
-       }
-
-       /* Handle Mesh join event */
-       if (joined_network) {
-               if (*joined_network) {
-                       g_free((*joined_network)->mesh_id);
-                       g_free(*joined_network);
-               }
-
-               *joined_network = g_try_new0(mesh_network_info_s, 1);
-               if (NULL == *joined_network) {
-                       MESH_LOGE("Failed to allocate memory");
-               } else {
-                       (*joined_network)->mesh_id = g_strdup(info.mesh_id);
-                       (*joined_network)->bssid = mesh_interface_get_address(mesh_interface);
-                       (*joined_network)->channel = info.channel;
-                       (*joined_network)->security = info.security;
-                       MESH_LOGD("Joined mesh network");
-                       MESH_LOGD("    BSSID   : [%s]", info.mesh_id);
-                       MESH_LOGD("    channel : [%d]", info.channel);
-                       MESH_LOGD("    security: [%d]", info.security);
-               }
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
 int mesh_request_set_mesh_gate(const char* bridge_interface,
                const char* mesh_interface, const char* external_interface)
 {
@@ -273,12 +54,6 @@ int mesh_request_set_mesh_gate(const char* bridge_interface,
                        return ret;
                }
 
-               /* Add external interface into bridge */
-               ret = mesh_request_add_bridge_interface(bridge_interface, external_interface);
-               if (MESHD_ERROR_NONE != ret) {
-                       return ret;
-               }
-
                /* Set mesh parameters */
                ret = mesh_netlink_set_mesh_parameter(mesh_interface,
                                "mesh_hwmp_rootmode", 4);
@@ -304,6 +79,8 @@ int mesh_request_unset_mesh_gate(const char* bridge_interface,
 {
        int ret = MESHD_ERROR_NONE;
 
+       NOTUSED(external_interface);
+
        /* Set mesh parameters */
        ret = mesh_netlink_set_mesh_parameter(mesh_interface,
                        "mesh_hwmp_rootmode", 0);
@@ -317,12 +94,6 @@ int mesh_request_unset_mesh_gate(const char* bridge_interface,
                MESH_LOGE("Failed to set [mesh_gate_announcements] : 0");
        }
 
-       /* Remove external network from bridge */
-       ret = mesh_request_remove_bridge_interface(bridge_interface, external_interface);
-       if (MESHD_ERROR_NONE != ret) {
-               return ret;
-       }
-
        /* Turn STP off */
        ret = mesh_bridge_set_stp(bridge_interface, FALSE);
        if(MESHD_ERROR_NONE != ret) {
@@ -333,70 +104,6 @@ int mesh_request_unset_mesh_gate(const char* bridge_interface,
        return MESHD_ERROR_NONE;
 }
 
-int mesh_request_remove_bridge(const char* bridge_interface)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == bridge_interface) {
-               MESH_LOGE("Invalid interface name");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Removing bridge...");
-
-       /* Make bridge interface down */
-       ret = mesh_interface_set(bridge_interface, NULL, MESH_INTERFACE_DOWN);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to change bridge interface state");
-       }
-
-       /* Remove bridge interface */
-       ret = mesh_bridge_remove(bridge_interface);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to remove bridge [%s] !", bridge_interface);
-               return ret;
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
-int mesh_request_create_bridge(const char* bridge_interface,
-               const char* mesh_interface)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == bridge_interface || NULL == mesh_interface) {
-               MESH_LOGE("Invalid parameters");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Creating bridge [%s]...", bridge_interface);
-
-       /* Create bridge interface */
-       ret = mesh_bridge_create(bridge_interface);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to create bridge [%s] !", bridge_interface);
-               return ret;
-       }
-
-       /* Add mesh interface into bridge */
-       ret = mesh_bridge_add_interface(bridge_interface, mesh_interface);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to add interface[%s] into bridge[%s] !",
-                       mesh_interface, bridge_interface);
-               return ret;
-       }
-
-       /* Make bridge interface UP */
-       ret = mesh_interface_set(bridge_interface, NULL, MESH_INTERFACE_UP);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to change bridge interface state");
-               return ret;
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
 int mesh_request_add_bridge_interface(const char* bridge_interface,
                const char* interface)
 {
@@ -455,116 +162,6 @@ int mesh_request_remove_bridge_interface(const char* bridge_interface,
        return MESHD_ERROR_NONE;
 }
 
-int mesh_request_load_saved_mesh_network(GList **network_list)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       MESH_LOGD("Load saved mesh network from storage...");
-
-       ret = mesh_network_load_mesh_network(network_list);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to load mesh network");
-               return ret;
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
-int mesh_request_add_mesh_network(GList **network_list,
-               const char *mesh_id, int channel, int security)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_id) {
-               MESH_LOGE("Invalid mesh id");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Add a new mesh network...");
-
-       ret = mesh_network_add_mesh_network(network_list, mesh_id, channel, security);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to add a new mesh network");
-               return ret;
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
-int mesh_request_get_saved_mesh_network(GList **saved_network)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       MESH_LOGD("Get saved mesh network...");
-
-       ret = mesh_network_get_saved_mesh_network(saved_network);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to get mesh network list");
-               return ret;
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
-int mesh_request_select_saved_mesh_network(GList **saved_network,
-               const char *mesh_id, int channel, int security)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_id) {
-               MESH_LOGE("Invalid mesh id");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Get saved mesh network...");
-
-       ret = mesh_network_select_saved_mesh_network(saved_network, mesh_id,
-                       channel, security);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to select mesh network");
-               return ret;
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
-int mesh_request_forget_saved_mesh_network(GList **saved_network,
-               const char *mesh_id, int channel, int security)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       if (NULL == mesh_id) {
-               MESH_LOGE("Invalid mesh id");
-               return MESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       MESH_LOGD("Forget mesh network...");
-
-       ret = mesh_network_forget_saved_mesh_network(saved_network, mesh_id,
-                       channel, security);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to forget mesh network");
-               return ret;
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
-int mesh_request_clear_saved_mesh_network(GList **saved_network)
-{
-       int ret = MESHD_ERROR_NONE;
-
-       MESH_LOGD("Remove all saved mesh network...");
-
-       ret = mesh_network_clear_saved_mesh_network(saved_network);
-       if(MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to clear saved mesh network");
-               return ret;
-       }
-
-       return MESHD_ERROR_NONE;
-}
-
 int mesh_request_set_softap_config(const char* softap_interface,
                const char *ssid, const char* mode, int channel, int visibility,
                int max_sta, int security, const char* passphrase)
index 15d3d56..c922360 100644 (file)
@@ -176,13 +176,13 @@ static gboolean _meshd_dbus_handle_enable(Manager *object,
                MESH_LOGE("Failed to mesh_interface_initialize [%d]", ret);
                goto FINISH;
        }
-
+#if 0
        ret = mesh_request_load_saved_mesh_network(&service->saved_mesh_network);
        if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to mesh_request_load_saved_mesh_network [%d]", ret);
                goto FINISH;
        }
-
+#endif
 FINISH:
        net_mesh_emit_mesh_enabled(meshd_dbus_get_object(), ret);
 
@@ -227,21 +227,6 @@ static gboolean _meshd_dbus_handle_scan(NetMesh *object,
        if (MESHD_ERROR_NONE != ret)
                MESH_LOGE("Failed to mesh_request_ipc_mesh_scan !");
 
-#if 0
-       ret = mesh_request_scan(info->mesh_interface);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_scan on mesh interface[%s] !",
-                               info->mesh_interface);
-       }
-
-       /* Fall-back */
-       if (MESHD_ERROR_IN_PROGRESS != ret) {
-               ret = mesh_request_scan(info->base_interface);
-               if (MESHD_ERROR_NONE != ret)
-                       MESH_LOGE("Failed to mesh_request_scan on base interface[%s] !",
-                                       info->base_interface);
-       }
-#endif
        net_mesh_complete_scan(object, invocation, ret);
 
        return TRUE;
@@ -263,21 +248,6 @@ static gboolean _meshd_dbus_handle_specific_scan(NetMesh *object,
        if (MESHD_ERROR_NONE != ret)
                MESH_LOGE("Failed to mesh_request_specific_scan !");
 
-#if 0
-       ret = mesh_request_specific_scan(info->mesh_interface, mesh_id, channel);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_specific_scan on mesh interface[%s]",
-                               info->mesh_interface);
-       }
-
-       /* Fall-back */
-       if (MESHD_ERROR_IN_PROGRESS != ret) {
-               ret = mesh_request_specific_scan(info->base_interface, mesh_id, channel);
-               if (MESHD_ERROR_NONE != ret)
-                       MESH_LOGE("Failed to mesh_request_specific_scan on base interface[%s]",
-                                       info->base_interface);
-       }
-#endif
        net_mesh_complete_specific_scan(object, invocation, ret);
 
        return TRUE;
@@ -339,7 +309,6 @@ static gboolean _meshd_dbus_handle_get_found_mesh_networks(NetMesh *object,
 {
        int ret = MESHD_ERROR_NONE;
        mesh_service *service = (mesh_service *)user_data;
-       //mesh_interface_s *info = service->interface_info;
 
        GVariantBuilder builder;
        GVariant* networks;
@@ -352,25 +321,9 @@ static gboolean _meshd_dbus_handle_get_found_mesh_networks(NetMesh *object,
        if (MESHD_ERROR_NONE != ret)
                MESH_LOGE("Failed to mesh_request_ipc_mesh_get_peers");
 
-#if 0
-       ret = mesh_request_get_scan_result(info->mesh_interface, &service->scanned_mesh_network);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_get_scan_result");
-
-               /* Fall-back */
-               ret = mesh_request_get_scan_result(info->base_interface,
-                               &service->scanned_mesh_network);
-               if (MESHD_ERROR_NONE != ret) {
-                       MESH_LOGE("Failed to mesh_request_get_scan_result on base interface[%s]",
-                                       info->base_interface);
-
-                       g_dbus_method_invocation_return_error(invocation,
-                                       G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Request Failed");
-               }
-       }
-#endif
        g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
 
+       /* scanned_mesh_network would be filled above request */
        iter = service->scanned_mesh_network;
        while (iter != NULL) {
                scan_item = (mesh_scan_result_s*)iter->data;
@@ -393,10 +346,6 @@ static gboolean _meshd_dbus_handle_get_found_mesh_networks(NetMesh *object,
                iter = g_list_next(iter);
        }
 
-       /* Clear scan list */
-       //g_list_free_full(service->scanned_mesh_network, _on_scan_result_destroy);
-       //service->scanned_mesh_network = NULL;
-
        networks = g_variant_builder_end(&builder);
 
        net_mesh_complete_get_found_mesh_networks(object, invocation, networks, ret);
@@ -410,28 +359,11 @@ static gboolean _meshd_dbus_handle_enable_mesh(NetMesh *object,
 {
        int ret = MESHD_ERROR_NONE;
        mesh_service *service = (mesh_service *)user_data;
-       //mesh_interface_s *info = service->interface_info;
-
-#if 0 ///////////////////
-       /* Create or join mesh network and create bridge */
-       ret = mesh_request_enable_mesh(info->base_interface, info->mesh_interface,
-                               service->saved_mesh_network, &service->joined_network);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_enable_mesh [%d]", ret);
-               goto FINISH;
-       }
 
-       ret = mesh_request_create_bridge(info->bridge_interface, info->mesh_interface);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_create_bridge [%d]", ret);
-               goto FINISH;
-       }
-#endif
+       /* It handles creating virtual network and bridge */
        ret = mesh_request_ipc_enable_network(service);
-       if (MESHD_ERROR_NONE != ret) {
+       if (MESHD_ERROR_NONE != ret)
                MESH_LOGE("Failed to mesh_request_ipc_enable_network [%d]", ret);
-               goto FINISH;
-       }
 
 #if 0
        /* Detect external network state (i.e. Ethernet)
@@ -441,27 +373,8 @@ static gboolean _meshd_dbus_handle_enable_mesh(NetMesh *object,
        if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to mesh_request_set_mesh_gate [%d]", ret);
        }
-
-
-       /* TODO: Check if specific scan is required */
-       ret = mesh_request_specific_scan(info->mesh_interface,
-                       info->mesh_id, info->mesh_channel);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_specific_scan [%d]", ret);
-       }
-       ret = mesh_request_get_scan_result(info->mesh_interface,
-                       &service->scanned_mesh_network);
-
-       /* Request DHCP on bridge interface */
-       ret = mesh_request_dhcp(info->bridge_interface);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_dhcp [%d]", ret);
-       }
-
-       /* TODO: Notify bridge status to Connman */
 #endif
 
-FINISH:
        net_mesh_complete_enable_mesh(object, invocation, ret);
 
        return TRUE;
@@ -476,14 +389,7 @@ static gboolean _meshd_dbus_handle_disable_mesh(NetMesh *object,
        mesh_interface_s *info = service->interface_info;
 
        meshd_check_null_ret_error("info", info, FALSE);
-#if 0
-       /* Destroy bridge and return from mesh to infra mode */
-       if (service->joined_network) {
-               g_free(service->joined_network->mesh_id);
-               g_free(service->joined_network);
-               service->joined_network = NULL;
-       }
-#endif
+
        if (FALSE == service->mesh_activated) {
                MESH_LOGD("Mesh network is not activated yet");
                ret = MESHD_ERROR_OPERATION_FAILED;
@@ -495,23 +401,7 @@ static gboolean _meshd_dbus_handle_disable_mesh(NetMesh *object,
        if (MESHD_ERROR_NONE != ret) {
                MESH_LOGE("Failed to disable mesh network !");
        }
-#if 0
-       /* If DHCP is on progress, stop it */
-       ret = mesh_request_stop_dhcp();
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to stop DHCP request !");
-       }
-
-       ret = mesh_request_disable_mesh(info->mesh_interface);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_disable_mesh_gate");
-       }
 
-       ret = mesh_request_remove_bridge(info->bridge_interface);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_remove_bridge");
-       }
-#endif
        /* Make response */
        net_mesh_complete_disable_mesh(object, invocation, ret);
 
@@ -526,10 +416,6 @@ static gboolean _meshd_dbus_handle_get_joined_mesh_network(NetMesh *object,
        mesh_service *service = (mesh_service *)user_data;
        mesh_network_info_s *joined = NULL;
 
-       //gchar *meshid = strdup("meshnet");
-       //gchar *bssid = strdup("7c:dd:90:d8:2a:64");
-       //gint channel = 161;
-       //gint max_speed = 866;
        ret = mesh_request_ipc_get_joined_network(service);
        if (MESHD_ERROR_NONE == ret) {
                joined = service->joined_network;
@@ -704,59 +590,13 @@ static gboolean _meshd_dbus_handle_create_mesh_network(NetMesh *object,
        mesh_service *service = (mesh_service *)user_data;
        meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
 
-       //ret = mesh_request_add_mesh_network(&service->saved_mesh_network,
-       //              mesh_id, channel, security);
        ret = mesh_request_ipc_create_mesh_network(service, mesh_id, channel, sec);
 
        net_mesh_complete_create_mesh_network(object, invocation, ret);
 
        return TRUE;
 }
-#if 0
-static gboolean _meshd_dbus_handle_get_saved_mesh_network(NetMesh *object,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       int ret = MESHD_ERROR_NONE;
-       mesh_service *service = (mesh_service *)user_data;
 
-       GVariantBuilder builder;
-       GVariant* networks;
-       GList *iter = NULL;
-
-       ret = mesh_request_get_saved_mesh_network(&service->saved_mesh_network);
-       if (MESHD_ERROR_NONE != ret) {
-               MESH_LOGE("Failed to mesh_request_get_saved_mesh_network");
-
-               g_dbus_method_invocation_return_error(invocation,
-                               G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Request Failed");
-       } else {
-               /* TODO: Get station information and make variant data */
-               g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
-
-               iter = service->saved_mesh_network;
-               while (iter != NULL) {
-                       mesh_network_info_s *item = (mesh_network_info_s*)iter->data;
-
-                       g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
-                       g_variant_builder_add(&builder, "{sv}", "mesh_id",
-                                       g_variant_new_string(item->mesh_id));
-                       g_variant_builder_add(&builder, "{sv}", "channel",
-                                       g_variant_new_uint32(item->channel));
-                       g_variant_builder_add(&builder, "{sv}", "security",
-                                       g_variant_new_uint32(item->security));
-                       g_variant_builder_close(&builder);
-
-                       iter = g_list_next(iter);
-               }
-
-               networks = g_variant_builder_end(&builder);
-               net_mesh_complete_get_saved_mesh_network(object, invocation, networks, ret);
-       }
-
-       return TRUE;
-}
-#endif
 static gboolean _meshd_dbus_handle_connect_mesh_network(NetMesh *object,
                GDBusMethodInvocation *invocation,
                gchar *mesh_id, gint channel, gint security, gchar *passphrase,
@@ -765,12 +605,8 @@ static gboolean _meshd_dbus_handle_connect_mesh_network(NetMesh *object,
        int ret = MESHD_ERROR_NONE;
        mesh_service *service = (mesh_service *)user_data;
        meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
-       //ret = mesh_request_select_saved_mesh_network(&service->saved_mesh_network,
-       //              mesh_id, channel, security);
 
-/* ADDED */
        ret = mesh_request_ipc_connect_mesh_network(service, mesh_id, channel, sec, passphrase);
-/* ADDED */
 
        net_mesh_complete_connect_mesh_network(object, invocation, ret);
 
@@ -801,8 +637,6 @@ static gboolean _meshd_dbus_handle_forget_mesh_network(NetMesh *object,
        mesh_service *service = (mesh_service *)user_data;
        meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
 
-       //ret = mesh_request_forget_saved_mesh_network(&service->saved_mesh_network,
-       //              mesh_id, channel, security);
        ret = mesh_request_ipc_remove_mesh_network(service, mesh_id, channel, sec);
 
        net_mesh_complete_forget_mesh_network(object, invocation, ret);
@@ -979,43 +813,6 @@ static gboolean _meshd_dbus_handle_get_station_info(NetMesh *object,
                g_object_unref(station);
        }
 
-#if 0
-       g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
-       g_variant_builder_add(&builder, "{sv}", "station", g_variant_new_string("7c:dd:90:62:37:cf"));
-       g_variant_builder_add(&builder, "{sv}", "inactive_time", g_variant_new_uint32(1685));
-       g_variant_builder_add(&builder, "{sv}", "rx_bytes", g_variant_new_uint32(34174));
-       g_variant_builder_add(&builder, "{sv}", "rx_packets", g_variant_new_uint32(1181));
-       g_variant_builder_add(&builder, "{sv}", "tx_bytes", g_variant_new_uint32(6877));
-       g_variant_builder_add(&builder, "{sv}", "tx_packets", g_variant_new_uint32(76));
-       g_variant_builder_add(&builder, "{sv}", "tx_retries", g_variant_new_uint32(0));
-       g_variant_builder_add(&builder, "{sv}", "tx_failed", g_variant_new_uint32(0));
-       g_variant_builder_add(&builder, "{sv}", "beacon_loss", g_variant_new_uint32(0));
-       g_variant_builder_add(&builder, "{sv}", "signal", g_variant_new_int32(-64));
-       g_variant_builder_add(&builder, "{sv}", "signal_avg", g_variant_new_int32(-63));
-       g_variant_builder_add(&builder, "{sv}", "tx_bitrate", g_variant_new_uint32(540)); /* 10 times */
-       g_variant_builder_add(&builder, "{sv}", "rx_bitrate", g_variant_new_uint32(55)); /* 10 times */
-       g_variant_builder_add(&builder, "{sv}", "mesh_llid", g_variant_new_uint32(51731));
-       g_variant_builder_add(&builder, "{sv}", "mesh_plid", g_variant_new_uint32(35432));
-       g_variant_builder_add(&builder, "{sv}", "mesh_plink", g_variant_new_uint32(1)); /* 0 : DISCON, 1 : ESTAB */
-       g_variant_builder_add(&builder, "{sv}", "mesh_local_PS_mode", g_variant_new_uint32(1)); /* 0 : INACTIVE, 1 : ACTIVE */
-       g_variant_builder_add(&builder, "{sv}", "mesh_peer_PS_mode", g_variant_new_uint32(1)); /* 0 : INACTIVE, 1 : ACTIVE */
-       g_variant_builder_add(&builder, "{sv}", "mesh_none_peer_PS_mode", g_variant_new_uint32(1)); /* 0 : INACTIVE, 1 : ACTIVE */
-       g_variant_builder_add(&builder, "{sv}", "authorized", g_variant_new_boolean(TRUE));
-       g_variant_builder_add(&builder, "{sv}", "associated", g_variant_new_boolean(TRUE));
-       g_variant_builder_add(&builder, "{sv}", "preamble",g_variant_new_string("long"));
-       g_variant_builder_add(&builder, "{sv}", "WMM_WME", g_variant_new_boolean(TRUE));
-       g_variant_builder_add(&builder, "{sv}", "MFP", g_variant_new_boolean(FALSE));
-       g_variant_builder_add(&builder, "{sv}", "TDLS_peer", g_variant_new_boolean(FALSE));
-       g_variant_builder_add(&builder, "{sv}", "DTIM_period", g_variant_new_uint32(0));
-       g_variant_builder_add(&builder, "{sv}", "beacon_interval", g_variant_new_uint32(1000));
-       g_variant_builder_add(&builder, "{sv}", "short_slot_time", g_variant_new_boolean(TRUE));
-       g_variant_builder_add(&builder, "{sv}", "connected_time", g_variant_new_uint32(256));
-       station = g_variant_builder_end(&builder);
-
-       net_mesh_complete_get_station_info(object, invocation, station, ret);
-
-       g_object_unref(station);
-#endif
        return TRUE;
 }
 
@@ -1226,7 +1023,7 @@ static gboolean _meshd_dbus_interface_init(mesh_service *service)
                return FALSE;
        }
 
-       /* Get D-Bus owner to activate zigbee-daemon */
+       /* Get D-Bus owner to activate mesh service daemon */
        activation_dbus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
                        MESH_DBUS_INTERFACE".manager",
                        G_BUS_NAME_OWNER_FLAGS_REPLACE,
@@ -1273,10 +1070,10 @@ static void _meshd_dbus_deinit(mesh_service *service)
 
        if (service->joined_network) {
                g_free(service->joined_network->mesh_id);
+               g_free(service->joined_network->bssid);
                g_free(service->joined_network);
                service->joined_network = NULL;
        }
-       mesh_request_clear_saved_mesh_network(&service->saved_mesh_network);
 
        /* Clear scan list */
        g_list_free_full(service->scanned_mesh_network, _on_scan_result_destroy);
@@ -1286,7 +1083,7 @@ static void _meshd_dbus_deinit(mesh_service *service)
        service->interface_info = NULL;
 }
 
- /**< mesh service interface initialization */
+/**< Mesh service interface initialization */
 gboolean meshd_service_interface_init(mesh_service *service)
 {
        guint ret;
@@ -1295,14 +1092,14 @@ gboolean meshd_service_interface_init(mesh_service *service)
        /* Initialize dbus interface */
        ret = _meshd_dbus_interface_init(service);
        if (FALSE == ret) {
-               MESH_LOGE("zigbee_service_dbus_interface_init failed!!!");
+               MESH_LOGE("_meshd_dbus_interface_init failed!!!");
                return FALSE;
        }
 
        return TRUE;
 }
 
-/**< Zigbee service interface de-initialization */
+/**< Mesh service interface de-initialization */
 void meshd_service_interface_deinit(mesh_service *service)
 {
        meshd_check_null_ret("service", service);
index 5ce7f05..b671892 100644 (file)
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
        /* Initialize mesh service interface layer */
        ret = meshd_service_interface_init(service);
        if (G_UNLIKELY(FALSE == ret)) {
-               MESH_LOGE("zigbee_service_interface_init failed!");
+               MESH_LOGE("meshd_service_interface_init failed!");
                goto END;
        }